#1 2015-02-08 08:38:07

karolina
Member
Registered: 2014-08-09

adding buttons to toolbars and menus

Hi,

Is it possible to add buttons to toolbars and context menus in other modules than admin modules?

Karolina

Offline

#2 2015-02-08 09:48:38

Arno Mittelbach
datenwerke
Registered: 2012-02-14

Re: adding buttons to toolbars and menus

Hi,

the short answer is that the script guide (Chapter 7) gives a pretty complete picture of what is possible. That is, the ClientExtensionService is currently restricted to the admin modules.

On the other hand, depending on what you have in mind it might be possible to cheat a bit, using the CreJavaScript object to make your changes with JavaScript on the client. We do, however, also plan on extending the possibilities of customizing the client. Could you tell us a bit about what you have in mind?

Cheers
Arno

Offline

#3 2015-02-08 10:27:14

karolina
Member
Registered: 2014-08-09

Re: adding buttons to toolbars and menus

Hi Arno,

Some things that just came to my mind: a button at a toolbar of on any kind of report:
- displaying context help
- a conversation tool with Eliza 2.0 (;-))
- live chat with help desk
- notepad tool
in general - buttons that can trigger any kind of groovy script that may be useful for users.

This is probably also one of possible ways of extending dynamic list for further data analysis.

Cheers,

Karolina

Offline

#4 2019-04-23 10:48:45

Patryx
Member
Registered: 2019-03-25

Re: adding buttons to toolbars and menus

Hi,
Has sth changed with the user defined buttons? Karolina's suggestions about possible ways of extending dynamic list are incredibly expected :-)

Offline

#5 2019-04-23 11:26:53

eduardo
Administrator
Registered: 2016-11-01
Website

Re: adding buttons to toolbars and menus

Hi Patryx,

this has not changed, only admin modules are currently customizable by this way.
However, I totally agree that this would be a very interesting feature, e.g. by allowing to add new buttons into the main toolbar, which is also visible by URL (inlinedisplay). I suppose this would solve the problems you have with the export you mentioned in other threads.

Thanks for pointing into this direction.

I raised ticket RS-3411 for this.

Regards,
Eduardo

Offline

#6 2019-04-23 12:40:47

eduardo
Administrator
Registered: 2016-11-01
Website

Re: adding buttons to toolbars and menus

Hi Patryx,

good news! This already works, just the documentation has to be updated and some minor errors corrected.

Please add the following script to your onlogin.d:

import net.datenwerke.rs.scripting.service.scripting.extensions.*

def service = GLOBALS.services['clientExtensionService']

def entry = new AddToolbarEntryExtension()
entry.setToolbarName("reportexecutor:main:toolbar")
entry.setLabel("display info")
entry.setScriptLocation("fileserver/bin/extensions/menu/displayreportinfo.groovy")

service.addToolbarEntry(entry)

Add the displayreportinfo.groovy script into fileserver/bin/extensions/menu:

import net.datenwerke.rs.terminal.service.terminal.obj.*

def result = new CommandResult()

def msg = new CreMessage("ID: " + context['id'] + ", args" + args)
result.addExtension(msg)

return result

And you have a new button in your report execution window:
FluxBB BBCode-Test
This button is also visible by calling a report from the URL (inlinereport).

In the displayreportinfo.groovy script you can do whatever you need, as it is executed in the server. You can execute the report, send it by email, etc.
You can access the report's key by e.g.: context['key']

This part doesn't seem to work, so I deleted it from the script in the documentation:
def cond = new DisplayCondition("classname", "net.datenwerke.security.client.usermanager.dto.UserDto")
entry.addDisplayCondition(cond)

I created ticket RS-3414 for investigating. This should only be necessary if you want to better control when the entry is displayed, e.g. only for dynamic lists. For the moment, you can add the button to all reports.

Please let me know if this works for you.

Regards,
Eduardo

Offline

#7 2019-04-24 09:13:28

Patryx
Member
Registered: 2019-03-25

Re: adding buttons to toolbars and menus

I will check it but even if it works it won't resolve my issue in 100%.
1. I have to call Report Execution View by url with my params (like report params, key of report etc) - let's say it's done.
2. I need a button for action, where I can execute report with filters and columns chosen by user in Report Execution View, save some data in database - so I need a Report object to have as a parameter.
3. I need to have such a button only for defined reports (let's say I have Report A, B, C, D, E and only calling url for Report A, B, and E will show such a button).

Point 1, 2, 3 could be solved by EXPORT hooks and Export button according to your clues.
BUT you didn't answer if I can skip downloading file?! In our solution we cannot force user to download any file using such a button.

Point 2, 3 I can't achieve using user buttons (this topic) because you mentioned that we couldn't control when such a button was visible for users according to defined reports sad What's more I don't have Report object with all settings done by user in Report Execution View.

The best for us in this case seems to be Export hook and button BUT we are blocked by downloading file. Is there any possibility to skip downloading and for example send sth as notification (like as a result of 'Sent to hook') or just do not nothing?
Please answer my question.

Last edited by Patryx (2019-04-24 09:32:37)

Offline

#8 2019-04-24 09:43:21

eduardo
Administrator
Registered: 2016-11-01
Website

Re: adding buttons to toolbars and menus

Hi Patryx,

I understand. I think the best would be to extend the "export hook" to allow exporting without sending a download file. At the moment, this is not possible. I created ticket RS-3422 for this.

We will evaluate if this change is necessary and feasible, since we would change a ground functionality of reportserver. I will post here when I have more information on this.

Regards,
Eduardo

Offline

#9 2019-04-24 09:54:03

Patryx
Member
Registered: 2019-03-25

Re: adding buttons to toolbars and menus

Hi Edurado,
Great, I hope you will be able to resolve the ticket soon - we look forward to this and also calling URL Report Execution View without login.

1. Will you try to add optionally notification in output as result of export hook?
In that case we could inform user by text about results of exporting or failure (it could be even helpful for today-working functions as export to html file, exel etc).
It would be nice to have such a possibility to choose if such a notification will show for users.

2. Would it be or is it possible to read which language is chosen and change 'My Format' word according to the language:

/* register format */
ces.addReportExportOutputFormat new TableReportDtoDec(), "My Format", "MY_CUSTOM_FORMAT", ""

""

The same how to recognise language inside hook if you add notification in future in export hook (to choose right text):)

3. Is it or would it be possible to omit word 'Export'? Let's say I have only my format chosen to export in a report. Let's say the button is called MAP. I don't want to have Map-Export, just button named Map in that case. Maybe I could change dictionary and clear value for Export but it is not a good solution because in other reports we want to use for example Excel export too (then Export word is expected).

4. I am still not sure if export is good choice to solve my report in general. In Export report I have to implement init, nextRow, close. As I told you and explained in other post I take report, create my variant with added column, execute report and save expected data into database. So I can do it in one method, not need to have nextRow, close because it operates on input report during processing it. To use it I would have to do all task in init (execute my report with added column, save results in database) and skip nextRow and close. To sum up I would be forced to execute report twice (mine one in init and automatically by Output Hook) - it seems to be inefficient way....:(

Thank you.

Last edited by Patryx (2019-04-24 12:10:15)

Offline

#10 2019-04-24 10:53:11

Patryx
Member
Registered: 2019-03-25

Re: adding buttons to toolbars and menus

Hi Eduardo,
6# - for your information, this functionality works when it comes to add custom button ;-)

Last edited by Patryx (2019-04-24 12:01:19)

Offline

#11 2019-05-13 07:08:30

eduardo
Administrator
Registered: 2016-11-01
Website

Re: adding buttons to toolbars and menus

Hi Patryx,

Patryx wrote:

The best for us in this case seems to be Export hook and button BUT we are blocked by downloading file. Is there any possibility to skip downloading and for example send sth as notification (like as a result of 'Sent to hook') or just do not nothing?
Please answer my question.

I am happy to announce that we just finished development of ticket RS-3452 (allow to skip download file).

Now, you can install the GUI to skip the download and just notify the user when the script finishes executing like this:

import net.datenwerke.rs.base.client.reportengines.table.dto.decorator.TableReportDtoDec
import net.datenwerke.rs.scripting.service.scripting.extensions.AddReportExportFormatProvider

import net.datenwerke.rs.base.client.reportengines.table.dto.TableReportVariantDto
import net.datenwerke.rs.base.client.reportengines.table.dto.decorator.TableReportVariantDtoDec

/* obtain ClientExtensionService */
def ces = GLOBALS.services['clientExtensionService']

/* register format */
AddReportExportFormatProvider provider = new AddReportExportFormatProvider(new TableReportDtoDec(), "My Format", "MY_CUSTOM_FORMAT", "")
provider.skipDownload = true
ces.addReportExportOutputFormat provider 

""

In the server-side, you still create a file, but it may be empty, e.g.:

import net.datenwerke.rs.base.service.reportengines.table.output.generator.TableOutputGenerator
import net.datenwerke.rs.base.service.reportengines.table.hooks.TableOutputGeneratorProviderHook
import net.datenwerke.rs.base.service.reportengines.table.hooks.adapter.TableOutputGeneratorProviderHookAdapter
import net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledXHtmlReport

import java.io.OutputStream

import net.datenwerke.rs.base.service.reportengines.table.entities.Column.CellFormatter
import net.datenwerke.rs.base.service.reportengines.table.entities.TableReport
import net.datenwerke.rs.base.service.reportengines.table.output.object.TableDefinition
import net.datenwerke.rs.core.service.reportmanager.engine.CompiledReport
import net.datenwerke.rs.core.service.reportmanager.engine.config.ReportExecutionConfig
import net.datenwerke.rs.core.service.reportmanager.output.ReportOutputGenerator
import net.datenwerke.security.service.usermanager.entities.User
import net.datenwerke.rs.core.service.reportmanager.parameters.ParameterSet
import groovy.sql.Sql

def HOOK_NAME = "MY_ADDITIONAL_GENERATOR"

/* specify the generator */
class MyGenerator implements TableOutputGenerator {
  
  	def db = [url:'jdbc:sqlserver://IP;databaseName=myDb', user:'myUser', password:'password', driver:'com.microsoft.sqlserver.jdbc.SQLServerDriver']
 	def sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
  
  	def reportName = null
  
	int rows = 0
  
	void initialize(OutputStream os, TableDefinition td, boolean withSubtotals, TableReport report, TableReport originalReport, CellFormatter[] cellFormatters, ParameterSet parameters, User user, ReportExecutionConfig... configs ){
		reportName = report.name
    }

    void nextRow(){
      	rows++;
    }

    void close() {
      	def params = [reportName, rows+1]
 		sql.execute 'insert into execution_counts (report_name, number_of_rows) values (?, ?)', params
    }

    boolean supportsStreaming(){
       return false;
    }

    void addField( Object field, CellFormatter cellFormatter ){}

    CompiledXHtmlReport getTableObject() {
    	return new CompiledXHtmlReport("");
    }

    void addGroupRow (int[] subtotalIndices, Object[] subtotals, int[] subtotalGroupFieldIndices, Object[] subtotalGroupFieldValues, int rowSize, CellFormatter[] cellFormatters ){ }

    String[] getFormats() {
      	String[] formats = ['MY_CUSTOM_FORMAT']
      	return formats
    }

	boolean isCatchAll() { return false; }

	CompiledXHtmlReport getFormatInfo() {
    	return new CompiledXHtmlReport("");
	}

}

/* specify provider */
def provider = [
	provideGenerators : { ->
		return [new MyGenerator()]
	}
] as TableOutputGeneratorProviderHookAdapter

/* plugin hook */
GLOBALS.services.callbackRegistry.attachHook(HOOK_NAME, TableOutputGeneratorProviderHook.
class, provider)

In the example, you count the entries and insert them to a database. In this case, you don't need a download, as you pointed out. With the client-side configuration above, this is achieved smile

Regards,
Eduardo

Offline

#12 2019-05-13 12:30:48

Patryx
Member
Registered: 2019-03-25

Re: adding buttons to toolbars and menus

Thanks, it seems to resolve my issue. I look forward to version wink

Offline

#13 2019-05-14 07:17:51

eduardo
Administrator
Registered: 2016-11-01
Website

Re: adding buttons to toolbars and menus

Hi Patryx,

I sent you the preview release link by email. Remember this is just a preview release, so backup any important data you may have, just in any case. First, please test with the exact code above so we can be sure that this works in your installation too. Of course, the DB-configuration and inserts in the code may be commented out.

Regards,
Eduardo

Offline

#14 2019-05-14 12:38:47

Patryx
Member
Registered: 2019-03-25

Re: adding buttons to toolbars and menus

I can confirm that in the preview version 3.0.8 an export without dowloading file works smile

Offline

#15 2019-07-29 16:09:17

eduardo
Administrator
Registered: 2016-11-01
Website

Re: adding buttons to toolbars and menus

Hi Patryx,

ReportServer 3.0.8 is now available for download. Export skipping download RS-3422 is available here.

Regards,
Eduardo

Offline

Board footer

Powered by FluxBB