Skip to content

Commit

Permalink
Merge pull request #245 from fxprunayre/improvement/widgets/privilege…
Browse files Browse the repository at this point in the history
…sPanel

Widgets / Add privileges panel
  • Loading branch information
François Prunayre committed Sep 12, 2013
2 parents e71c6b9 + e580d3f commit 23a1711
Show file tree
Hide file tree
Showing 22 changed files with 525 additions and 36 deletions.
6 changes: 6 additions & 0 deletions core/src/main/java/org/fao/geonet/services/main/Info.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ else if (type.equals("harvester"))
new String[]{
"system/harvester/enableEditing"
}));

else if (type.equals("userGroupOnly"))
result.addContent(gc.getBean(SettingManager.class).getValues(
new String[]{
"system/metadataprivs/usergrouponly"
}));

else if (type.equals("categories"))
result.addContent(Lib.local.retrieve(dbms, "Categories"));
Expand Down
6 changes: 4 additions & 2 deletions web-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
<include>${project.build.directory}/classes/apps/js/ext-ux/MultiselectItemSelector-3.0/Multiselect.js</include>
<include>${project.build.directory}/classes/apps/js/ext-ux/LightBox/lightbox.js</include>
<include>${project.build.directory}/classes/apps/js/ext-ux/SuperBoxSelect/SuperBoxSelect.js</include>

<include>${project.build.directory}/classes/apps/js/ext-ux/CheckColumn.js</include>

<include>${project.build.directory}/classes/apps/js/proj4js-compressed.js</include>


Expand Down Expand Up @@ -411,7 +412,8 @@
<include>${project.build.directory}/classes/apps/js/GeoNetwork/lib/GeoNetwork/widgets/admin/MetadataInsertPanel.js</include>
<include>${project.build.directory}/classes/apps/js/GeoNetwork/lib/GeoNetwork/widgets/admin/SubTemplateManagerPanel.js</include>
<include>${project.build.directory}/classes/apps/js/GeoNetwork/lib/GeoNetwork/widgets/admin/ThesaurusManagerPanel.js</include>

<include>${project.build.directory}/classes/apps/js/GeoNetwork/lib/GeoNetwork/widgets/admin/PrivilegesPanel.js</include>

<include>${project.build.directory}/classes/apps/js/GeoNetwork/lib/GeoNetwork/widgets/OGCServiceQuickRegister.js</include>

<include>${project.build.directory}/classes/apps/js/GeoNetwork/lib/GeoNetwork/map/ExtentMap.js</include>
Expand Down
24 changes: 24 additions & 0 deletions web-client/src/main/resources/apps/css/gndefault.css
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,30 @@ ul.gn-relation-thumbnail {
display: none;
}

.filter-text-icon {
background-image: url(../images/default/find.png) !important;
width: 16px;
height: 16px;
border-color: transparent !important;
margin: 4px;
}

.privilges-not-user-groups .x-grid3-cell-inner {
color: gray;
}
.privileges-internal .x-grid3-cell-inner {
font-weight: bold;
}

.privileges-grid-disable {
color: gray;
}

.privileges-grid-disable .x-grid3-check-col,
.privileges-grid-disable .x-grid3-check-col-on {
opacity:0.4;
}

#user-info-tip {
border-top: 1px solid #b6b6b6;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
"GeoNetwork/widgets/admin/HarvesterPanel.js",
"GeoNetwork/widgets/admin/SubTemplateManagerPanel.js",
"GeoNetwork/widgets/admin/ThesaurusManagerPanel.js",
"GeoNetwork/widgets/admin/PrivilegesPanel.js",
"GeoNetwork/widgets/view/ViewWindow.js",
"GeoNetwork/widgets/view/ViewPanel.js",
"GeoNetwork/widgets/editor/KeywordSelectionPanel.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ GeoNetwork.Catalogue = Ext.extend(Ext.util.Observable, {
mdProcessing: serviceUrl + 'metadata.processing.new',
mdMassiveChildrenForm: serviceUrl + 'metadata.batch.children.form',
mdAdmin: serviceUrl + 'metadata.admin.form',
mdAdminSave: serviceUrl + 'metadata.admin',
mdAdminXml: serviceUrl + 'xml.metadata.admin.form',
mdBatchAdminXml: serviceUrl + 'xml.metadata.batch.admin.form',
mdBatchSaveXml: serviceUrl + 'xml.metadata.batch.update.privileges',
mdValidate: serviceUrl + 'xml.metadata.validate',
mdSuggestion: serviceUrl + 'metadata.suggestion',
mdCategory: serviceUrl + 'metadata.category.form',
Expand Down Expand Up @@ -350,7 +354,7 @@ GeoNetwork.Catalogue = Ext.extend(Ext.util.Observable, {
getRegions: serviceUrl + 'xml.info?type=regions',
getSources: serviceUrl + 'xml.info?type=sources',
getUsers: serviceUrl + 'xml.info?type=users',
getSiteInfo: serviceUrl + 'xml.info?type=site&type=auth',
getSiteInfo: serviceUrl + 'xml.info?type=site&type=auth&type=userGroupOnly',
getInspireInfo: serviceUrl + 'xml.info?type=inspire',
getIsoLanguages: serviceUrl + 'isolanguages',
schemaInfo: serviceUrl + 'xml.schema.info',
Expand Down Expand Up @@ -417,6 +421,12 @@ GeoNetwork.Catalogue = Ext.extend(Ext.util.Observable, {
isAdmin: function(){
return this.identifiedUser.role === "Administrator";
},
/** api: method[canSetInternalPrivileges]
* Return true if current user can set privileges to internal groups (ie. internet, intranet)
*/
canSetInternalPrivileges: function(){
return this.identifiedUser.role === "Administrator" || this.identifiedUser.role === "Reviewer";
},
/** api: method[isReadOnly]
* Return true if GN is is read-only mode
*/
Expand Down Expand Up @@ -537,7 +547,7 @@ GeoNetwork.Catalogue = Ext.extend(Ext.util.Observable, {
getInfo: function (refresh) {
if (refresh || this.info === null) {
this.info = {};
var properties = ['name', 'organization', 'siteId', 'casEnabled'];
var properties = ['name', 'organization', 'siteId', 'casEnabled', 'userGroupOnly'];
var request = OpenLayers.Request.GET({
url: this.services.getSiteInfo,
async: false
Expand Down Expand Up @@ -1111,6 +1121,13 @@ GeoNetwork.Catalogue = Ext.extend(Ext.util.Observable, {
}
});
},
getNodeText: function(node){
if (node) {
return node.innerText || node.textContent || node.text;
} else {
return '';
}
},
/** api: method[isLoggedIn]
*
* Get the xml.info for me. If user is not identified
Expand All @@ -1134,13 +1151,13 @@ GeoNetwork.Catalogue = Ext.extend(Ext.util.Observable, {

if (response.status === 200 && authenticated) {
this.identifiedUser = {
id: me.getElementsByTagName('id')[0].innerText || me.getElementsByTagName('id')[0].textContent,
username: me.getElementsByTagName('username')[0].innerText || me.getElementsByTagName('username')[0].textContent,
name: me.getElementsByTagName('name')[0].innerText || me.getElementsByTagName('name')[0].textContent,
surname: me.getElementsByTagName('surname')[0].innerText || me.getElementsByTagName('surname')[0].textContent,
email: me.getElementsByTagName('email')[0].innerText || me.getElementsByTagName('email')[0].textContent,
hash: me.getElementsByTagName('hash')[0].innerText || me.getElementsByTagName('hash')[0].textContent,
role: me.getElementsByTagName('profile')[0].innerText || me.getElementsByTagName('profile')[0].textContent
id: this.getNodeText(me.getElementsByTagName('id')[0]),
username: this.getNodeText(me.getElementsByTagName('username')[0]),
name: this.getNodeText(me.getElementsByTagName('name')[0]),
surname: this.getNodeText(me.getElementsByTagName('surname')[0]),
email: this.getNodeText(me.getElementsByTagName('email')[0]),
hash: this.getNodeText(me.getElementsByTagName('hash')[0]),
role: this.getNodeText(me.getElementsByTagName('profile')[0])
};
this.onAfterLogin();
return true;
Expand Down Expand Up @@ -1314,45 +1331,66 @@ GeoNetwork.Catalogue = Ext.extend(Ext.util.Observable, {
* FIXME : Need work on GeoNetwork side to fix JS calls
*/
massiveOp: function(type, cb){
var url = this.services.massiveOp[type];
this.modalAction(OpenLayers.i18n('massiveOp') + " - " + type, url, cb);
if (type === 'Privileges') {
var url = this.services.mdBatchAdminXml + "?id=" + id;
var privilegesPanel = new GeoNetwork.admin.PrivilegesPanel({
id: id,
url: url,
batch: true,
onlyUserGroup: this.info.userGroupOnly.toLowerCase() === 'true' || false
});
this.modalAction(OpenLayers.i18n('setBatchPrivileges'), privilegesPanel, cb);
} else {
var url = this.services.massiveOp[type];
this.modalAction(OpenLayers.i18n('massiveOp') + " - " + type, url, cb);
}
},
/** private: method[modalAction]
*
* Create a modal window and load the URL content.
* Create a modal window and load the URL content or add the panel
* in the modal window.
*
* If no callback provided, default callback on error, close the window.
*
* TODO : retrieve error message on error (currently HTML services are
* called with HTML response not easy to parse)
*/
modalAction: function(title, url, cb){
if (url) {
modalAction: function(title, urlOrPanel, cb){
if (urlOrPanel) {
var app = this, win, defaultCb = function(el, success, response, options) {
if (!success){
app.showError('Catalogue error', title);
win.close();
}
};
win = new Ext.Window({
id: 'modalWindow',
layout: 'fit',
width: 700,
height: 400,
closeAction: 'destroy',
plain: true,
modal: true,
draggable: false,
title: title,
items: new Ext.Panel({

var item;
if(typeof(urlOrPanel) == 'string') {
item = new Ext.Panel({
autoLoad: {
url: url,
url: urlOrPanel,
callback: cb || defaultCb,
scope: win
},
border: false,
frame: false,
autoScroll: true
})
}
else {
item =urlOrPanel;
}
win = new Ext.Window({
id: 'modalWindow',
layout: 'fit',
width: 900,
height: 500,
closeAction: 'destroy',
plain: true,
modal: true,
draggable: false,
title: title,
items: item
});
win.show(this);
win.alignTo(Ext.getBody(), 't-t');
Expand All @@ -1363,8 +1401,13 @@ GeoNetwork.Catalogue = Ext.extend(Ext.util.Observable, {
* Metadata admin form for privileges
*/
metadataAdmin: function(id){
var url = this.services.mdAdmin + "?id=" + id;
this.modalAction(OpenLayers.i18n('setPrivileges'), url);
var url = this.services.mdAdminXml + "?id=" + id;
var privilegesPanel = new GeoNetwork.admin.PrivilegesPanel({
id: id,
url: url,
onlyUserGroup: this.info.userGroupOnly.toLowerCase() === 'true' || false
});
this.modalAction(OpenLayers.i18n('setPrivileges'), privilegesPanel);
},
/** api: method[metadataStatus]
* Open status form to update metadata status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Ext.namespace('GeoNetwork', 'GeoNetwork.Lang');
GeoNetwork.Lang.ca={
'metadata-not-found': 'Metadata with UUID ${uuid} not found or not shared with you.',
'harvestingAdmin': 'Harvesting',
'filterGroup': 'Filter group ...',
'checkAllOrNone': 'Check all/none',
'updateUserInfo': 'Edit my profile',
'updatePassword': 'Change my password',
'myMetadata': 'My metadata',
Expand Down Expand Up @@ -445,6 +447,7 @@ GeoNetwork.Lang.ca={
'removeSelected': 'Esborrar els seleccionats',
'ownerName': 'Propietari de la metadada',
'setPrivileges': 'Definir privilegis',
'setBatchPrivileges': 'Overwrite privileges of selected records',
'setCategories': 'Definir categories',
'massiveOp': 'Operació batch ',
'prepareDownload': 'Descarregar arxius',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Ext.namespace('GeoNetwork', 'GeoNetwork.Lang');
GeoNetwork.Lang.de = {
'metadata-not-found': 'Metadata with UUID ${uuid} not found or not shared with you.',
'harvestingAdmin': 'Harvesting',
'filterGroup': 'Filter group ...',
'checkAllOrNone': 'Check all/none',
'updateUserInfo': 'Edit my profile',
'updatePassword': 'Change my password',
'myMetadata': 'My metadata',
Expand Down Expand Up @@ -433,6 +435,7 @@ GeoNetwork.Lang.de = {
'removeSelected':'Auswahl entfernen',
'ownerName':'Metadatensatz Besitzer',
'setPrivileges':'Rechte festlegen',
'setBatchPrivileges': 'Overwrite privileges of selected records',
'setCategories':'Kategorien festlegen',
'massiveOp':'Batch-Betrieb',
'prepareDownload':'Herunterladen von Dateien',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Ext.namespace('GeoNetwork', 'GeoNetwork.Lang');
GeoNetwork.Lang.en = {
'metadata-not-found': 'Metadata with UUID ${uuid} not found or not shared with you.',
'harvestingAdmin': 'Harvesting',
'checkAllOrNone': 'Check all/none',
'filterGroup': 'Filter group ...',
'updateUserInfo': 'Edit my profile',
'updatePassword': 'Change my password',
'myMetadata': 'My metadata',
Expand Down Expand Up @@ -413,6 +415,7 @@ GeoNetwork.Lang.en = {
'removeSelected': 'Remove selected',
'ownerName': 'Metadata record owner',
'setPrivileges': 'Set privileges',
'setBatchPrivileges': 'Overwrite privileges of selected records',
'setCategories': 'Set categories',
'massiveOp': 'Batch operation ',
'prepareDownload': 'Download files',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Ext.namespace('GeoNetwork', 'GeoNetwork.Lang');
GeoNetwork.Lang.es = {
'metadata-not-found': 'Metadata with UUID ${uuid} not found or not shared with you.',
'updateUserInfo': 'Edit my profile',
'filterGroup': 'Filter group ...',
'checkAllOrNone': 'Check all/none',
'updatePassword': 'Change my password',
'myMetadata': 'My metadata',
'_owner': 'User identifier',
Expand Down Expand Up @@ -428,6 +430,7 @@ GeoNetwork.Lang.es = {
'removeSelected':'Eliminar la selección',
'ownerName':'Propietario del registro de metadatos',
'setPrivileges':'Establecer privilegios',
'setBatchPrivileges': 'Overwrite privileges of selected records',
'setCategories':'Establecer categorías',
'massiveOp':'Modo por lotes',
'prepareDownload':'Descarga de archivos',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Ext.namespace('GeoNetwork', 'GeoNetwork.Lang');
GeoNetwork.Lang.fr = {
'metadata-not-found': 'La métadonnée avec l\'identifiant ${uuid} n\'a pas été trouvée ou n\'est pas partagée avec vous.',
'Administrator': 'Administrateur',
'filterGroup': 'Filtrer les groupes ...',
'checkAllOrNone': 'Cocher tout/rien',
'Reviewer': 'Relecteur',
'RegisteredUser': 'Utilisateur inscrit',
'Editor': 'Éditeur',
Expand Down Expand Up @@ -454,6 +456,7 @@ GeoNetwork.Lang.fr = {
'metadata.update.forget.new': 'Ré-initialisation en cours ...',
'ownerName': 'Rédacteur de la métadonnée',
'setPrivileges': 'Définir les privilèges',
'setBatchPrivileges': 'Modifier tous les privilèges des fiches sélectionnées',
'setCategories': 'Choisir les catégories',
'massiveOp': 'Opération sur la sélection',
'prepareDownload': 'Télécharger les fichiers',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Ext.namespace('GeoNetwork', 'GeoNetwork.Lang');
GeoNetwork.Lang.nl = {
'metadata-not-found': 'Metadata with UUID ${uuid} not found or not shared with you.',
'harvestingAdmin': 'Harvesting',
'filterGroup': 'Filter group ...',
'checkAllOrNone': 'Check all/none',
'updateUserInfo': 'Edit my profile',
'updatePassword': 'Change my password',
'myMetadata': 'My metadata',
Expand Down Expand Up @@ -436,6 +438,7 @@ GeoNetwork.Lang.nl = {
'removeSelected': "Verwijder selectie",
'ownerName': "Metadata record eigenaar",
'setPrivileges': "Stel rechten in",
'setBatchPrivileges': 'Overwrite privileges of selected records',
'setCategories': "Stel categorieën in",
'massiveOp': "Bulk operatie",
'prepareDownload': "Download bestanden",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Ext.namespace('GeoNetwork', 'GeoNetwork.Lang');
GeoNetwork.Lang.pl = {
'metadata-not-found': 'Metadata with UUID ${uuid} not found or not shared with you.',
'harvestingAdmin': 'Harvesting',
'filterGroup': 'Filter group ...',
'checkAllOrNone': 'Check all/none',
'updateUserInfo': 'Edit my profile',
'updatePassword': 'Change my password',
'myMetadata': 'My metadata',
Expand Down Expand Up @@ -445,6 +447,7 @@ GeoNetwork.Lang.pl = {
'removeSelected': 'Usuń zaznaczone',
'ownerName': 'Właściciel metadanych',
'setPrivileges': 'Ustaw uprawnienia',
'setBatchPrivileges': 'Overwrite privileges of selected records',
'setCategories': 'Ustaw kategorie',
'massiveOp': 'Masowa operacja ',
'prepareDownload': 'Pobierz pliki',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ GeoNetwork.LoginForm = Ext.extend(Ext.FormPanel, {
autoHide: false,
bodyBorder: false,
border: false,
frame: false,
defaults: {
border: false
},
Expand Down
Loading

0 comments on commit 23a1711

Please sign in to comment.