Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The administrative control panel with DS-2625 makes it easier to craft new (potentially repository specific) content available to administrators only. If your admins need to see logs (but you don't want to give access to the whole machine), if they need to see environment variables, some specific queries, or just need a place for links to content harvesters/quality control; consider putting it together as a control panel tab. You'll need at least some Java knowledge...

Below you'll find details about the control panel configuration and an example of a "minimal" tab.


Configuration

The Out of the box the control panel is configured ( in dspace/config/modules/controlpanel.cfg. This file contains a list of named plugins (see PluginManager) implementing the ControlPanelTab interface. Then there is a list of enabled tabs, these will be visible in the actual control panel; this list is called simply controlpanel.tabs. The names given in the list are used as i18n message keys together with "xmlui.administrative.ControlPanel.tabs." as a prefix, ie. when you name a tab "Java Information" the message key is "xmlui.administrative.ControlPanel.tabs.Java Information". The message value is what you see in the control panel.

Currently the configured tabs ) to display 5 tabs. These are the same tabs that were present in the previous non-configurable version. You can remove any of these tabs or create new ones. The configuration file lists the tabs as named plugins (see PluginManager)

The actual file looks like this

them by removing/commenting the appropriate line. 

 

Creating new tabs

New tabs should extend AbstractControlPanelTab and implement addBody method.

A new tab is a matter of few lines:

--- /dev/null
+++ b/dspace-xmlui/src/main/java/org/dspace/app/xmlui/aspect/administrative/controlpanel/TestTab.java
@@ -0,0 +1,27 @@
+package #---------------------------------------------------------------#
#------------ADMIN CONTROL PANEL CONFIGURATIONS-----------------#
#---------------------------------------------------------------#

### Control Panel Tabs
controlpanel.tabs = Java Information, \
					Configuration, \
					SystemWide Alerts, \
					Harvesting, \
					Current Activity, \


plugin.named.org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelTab = \
		;
+
+import java.sql.SQLException;
+import java.util.Map;
+
+import org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelJavaTab = Java Information, \
		wing.WingException;
+import org.dspace.app.xmlui.aspectwing.administrative.controlpanel.ControlPanelConfigurationTab = Configuration, \
		element.Division;
+import org.dspace.app.xmlui.aspectwing.administrative.controlpanel.ControlPanelAlertsTab = SystemWide Alerts, \
		org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelHarvestingTab = Harvesting, \
		org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelCurrentActivityTab = Current Activity, \

 

controlpanel.tabs becomes the label of the tab and a link to it (eg. admin/panel?tab=Harvesting). The respective tabs can access their name or more precisely 

element.Para;
+
+public class TestTab extends AbstractControlPanelTab {
+
+	@Override
+	public void addBody(Map objectModel, Division div) throws WingException {
+		Para para = div.addPara();
+		para.addContent("I am your new tab. You can reach me via ");
+		para.addXref(this.web_link, this.web_link);
+	}
+
+}

Notice the link to the tab itself (ie. contextPath + "/admin/panel?tab=" + tab_nameunder ) is obtained with this.web_link

Creating new tabs

From the configuration example above all the tabs implement interface ControlPanelTab, but in new tab implementation you really want to extend AbstractControlPanelTab. Only method you need to implement/override is 

public void addBody(Map objectModel, Division div) throws SAXException, WingException, UIException, SQLException, IOException, AuthorizeException

 

Let's take as an example the ControlPanelConfigurationTab, which lists some of the important variables from config files, with the imports and i18n strings left out this tab boils down just to the few lines below

...

That comes in handy when the tab accepts parameters.

 

Now add the new tab to the configuration:

--- a/dspace/config/modules/controlpanel.cfg
+++ b/dspace/config/modules/controlpanel.cfg
@@ -10,6 +10,7 @@ controlpanel.tabs = Configuration
 controlpanel.tabs = SystemWide Alerts
 controlpanel.tabs = Harvesting
 controlpanel.tabs = Current Activity
+controlpanel.tabs = Test Tab
 
 ### Define Control Panel Tab Plugins / Names (one per line)
 ### These define the names of each Control Panel Tab plugin (names are used to enable/disable the tabs above)
@@ -19,3 +20,4 @@ plugin.named.org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPane
 plugin.named.org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelTab = org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelAlertsTab = SystemWide Alerts
 plugin.named.org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelTab = org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelHarvestingTab = Harvesting
 plugin.named.org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelTab = org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelCurrentActivityTab = Current Activity
+plugin.named.org.dspace.app.xmlui.aspect.administrative.controlpanel.ControlPanelTab = org.dspace.app.xmlui.aspect.administrative.controlpanel.TestTab = Test Tab
And finally the message key:
--- a/dspace-xmlui/src/main/webapp/i18n/messages.xml
+++ b/dspace-xmlui/src/main/webapp/i18n/messages.xml
@@ -2030,6 +2030,7 @@
 	<message key="xmlui.administrative.ControlPanel.tabs.SystemWide Alerts">SystemWide Alerts</message>
 	<message key="xmlui.administrative.ControlPanel.tabs.Harvesting">Harvesting</message>
 	<message key="xmlui.administrative.ControlPanel.tabs.Current Activity">Current Activity</message>
+	<message key="xmlui.administrative.ControlPanel.tabs.Test Tab">1..2..3 TEST</message>
 
 	<!-- org.dspace.app.xmlui.administrative.SystemwideAlerts -->
 	<message key="xmlui.administrative.SystemwideAlerts.countdown"><strong>In {0} minutes</strong>: </message>

 

For more elaborate examples refer to the already configured Tabs or see the ControlPanel* classes in https://github.com/ufal/lindat-dspace/tree/lindat/dspace-xmlui/src/main/java/cz/cuni/mff/ufal/dspace/app/xmlui/aspect/administrative