diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/index.html b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/index.html index 326300424e83ffe4c79b43a951a82d195b8ca390..c88b56a1e69da783d19db81ae0792ef0a04cfd62 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/index.html +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/index.html @@ -138,6 +138,10 @@ <script type="text/javascript" src="./js/views/ExperimentForm/ExperimentFormModel.js"></script> <script type="text/javascript" src="./js/views/ExperimentForm/ExperimentFormView.js"></script> + <script type="text/javascript" src="./js/views/UserManager/UserManagerController.js"></script> + <script type="text/javascript" src="./js/views/UserManager/UserManagerModel.js"></script> + <script type="text/javascript" src="./js/views/UserManager/UserManagerView.js"></script> + <script type="text/javascript" src="./js/views/DataSetForm/DataSetFormController.js"></script> <script type="text/javascript" src="./js/views/DataSetForm/DataSetFormModel.js"></script> <script type="text/javascript" src="./js/views/DataSetForm/DataSetFormView.js"></script> diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/controllers/MainController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/controllers/MainController.js index 3463104012c90ab433f55746ab4f9d4b567e5b94..cc6a663f58ed50c2d7f2b47c97d4d99726d96fce 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/controllers/MainController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/controllers/MainController.js @@ -88,7 +88,7 @@ function MainController(profile) { $('body').removeClass('bodyLogin'); $("#login-form-div").hide(); $("#main").show(); - + //Get Metadata from all sample types before showing the main menu this.serverFacade.listSampleTypes ( function(result) { @@ -164,6 +164,12 @@ function MainController(profile) { // switch (newViewChange) { + case "showUserManagerPage": + document.title = "User Manager"; + this._showUserManager(); + window.scrollTo(0,0); + break; + case "showVocabularyManagerPage": document.title = "Vocabulary Manager"; this._showVocabularyManager(); @@ -394,6 +400,12 @@ function MainController(profile) { this.currentView = null; } + this._showUserManager = function() { + var userManagerController = new UserManagerController(this); + userManagerController.init($("#mainContainer")); + this.currentView = userManagerController; + } + this._showSamplesPage = function(experimentIdentifier) { var sampleTableController = null; diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js index 959815198e32d5310d3de95cc780aeddc86a9c3c..b1a5c0d7859e614c0331aabacea08285f825ef24 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js @@ -48,6 +48,61 @@ function ServerFacade(openbisServer) { this.openbisServer.logout(callbackFunction); } + // + // User Related Functions + // + this.listPersons = function(callbackFunction) { + this.openbisServer.listPersons(callbackFunction); + }; + + this.registerUserPassword = function(userId, userPass, callbackFunction) { + this.createReportFromAggregationService( + profile.getDefaultDataStoreCode(), + { + "method" : "registerUserPassword", + "userId" : userId, + "password" : userPass + }, + function(data){ + if(data.result.rows[0][0].value == "OK") { + callbackFunction(true); + } else { + callbackFunction(false); + } + }); + } + + this.createELNUser = function(userId, userPass) { + var _this = this; + _this.registerUserPassword(userId, userPass, function(isSuccess){ + if(isSuccess) { + _this.openbisServer.registerPerson(userId, function(data) { + if(data.error) { + Util.showError(data.error.message); + } else { + _this.openbisServer.registerSpace(userId, "Space for user " + userId, function(data) { + if(data.error) { + Util.showError(data.error.message); + } else { + _this.openbisServer.registerPersonSpaceRole(userId, userId, "ADMIN", function(data) { + if(data.error) { + Util.showError(data.error.message); + } else { + Util.showSuccess("User " + userId + " created successfully."); + } + }); + } + + }); + } + + }); + } else { + Util.showError("User password can't be set."); + } + }); + } + // // Metadata Related Functions // @@ -289,54 +344,6 @@ function ServerFacade(openbisServer) { this.createReportFromAggregationService = function(dataStoreCode, parameters, callbackFunction) { this.openbisServer.createReportFromAggregationService(dataStoreCode, "newbrowserapi", parameters, callbackFunction); } - - this.registerUserPassword = function(userId, userPass, callbackFunction) { - this.createReportFromAggregationService( - profile.getDefaultDataStoreCode(), - { - "method" : "registerUserPassword", - "userId" : userId, - "password" : userPass - }, - function(data){ - if(data.result.rows[0][0].value == "OK") { - callbackFunction(true); - } else { - callbackFunction(false); - } - }); - } - - this.createELNUser = function(userId, userPass) { - var _this = this; - _this.registerUserPassword(userId, userPass, function(isSuccess){ - if(isSuccess) { - _this.openbisServer.registerPerson(userId, function(data) { - if(data.error) { - Util.showError(data.error.message); - } else { - _this.openbisServer.registerSpace(userId, "Space for user " + userId, function(data) { - if(data.error) { - Util.showError(data.error.message); - } else { - _this.openbisServer.registerPersonSpaceRole(userId, userId, "ADMIN", function(data) { - if(data.error) { - Util.showError(data.error.message); - } else { - Util.showSuccess("User " + userId + " created successfully."); - } - }); - } - - }); - } - - }); - } else { - Util.showError("User password can't be set."); - } - }); - } // // Configuration Related Functions diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SideMenu/SideMenuWidgetController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SideMenu/SideMenuWidgetController.js index d0dd636551e296d6148945b82b303ba508ba54c1..4031e7ebb129ea91f0c987e9031361b1d0f20158 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SideMenu/SideMenuWidgetController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SideMenu/SideMenuWidgetController.js @@ -310,6 +310,9 @@ function SideMenuWidgetController(mainController) { _this._sideMenuWidgetModel.menuStructure.newMenuIfSelected.children.push( new SideMenuWidgetComponent(true, false, "Vocabulary Viewer", "Vocabulary Viewer", _this._sideMenuWidgetModel.menuStructure, null, "showVocabularyManagerPage", null, "") ); + _this._sideMenuWidgetModel.menuStructure.newMenuIfSelected.children.push( + new SideMenuWidgetComponent(true, false, "User Manager", "User Manager", _this._sideMenuWidgetModel.menuStructure, null, "showUserManagerPage", null, "") + ); _this._sideMenuWidgetView.repaintFirst($container); }); diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerController.js new file mode 100644 index 0000000000000000000000000000000000000000..0795b88c75448a1b8fd268b10f9978c88b5c29db --- /dev/null +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerController.js @@ -0,0 +1,31 @@ +/* + * Copyright 2014 ETH Zuerich, Scientific IT Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function UserManagerController(mainController) { + this._mainController = mainController; + this._userManagerModel = new UserManagerModel(); + this._userManagerView = new UserManagerView(this, this._userManagerModel); + + this.init = function($container) { + var _this = this; + mainController.serverFacade.listPersons(function(data) { + if(data.result && data.result.length > 0) { + _this._userManagerModel.persons = data.result; + } + _this._userManagerView.repaint($container); + }); + } +} \ No newline at end of file diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerModel.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerModel.js new file mode 100644 index 0000000000000000000000000000000000000000..d1c80688793e1b03a1acca9fd045e8f84bc3bd62 --- /dev/null +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerModel.js @@ -0,0 +1,19 @@ +/* + * Copyright 2014 ETH Zuerich, Scientific IT Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function UserManagerModel() { + this.persons = []; +} \ No newline at end of file diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerView.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerView.js new file mode 100644 index 0000000000000000000000000000000000000000..f515d4b0583993cf12a93185d38ed0419018fe5e --- /dev/null +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/UserManager/UserManagerView.js @@ -0,0 +1,89 @@ +/* + * Copyright 2014 ETH Zuerich, Scientific IT Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function UserManagerView(userManagerController, userManagerModel) { + this._userManagerController = userManagerController; + this._userManagerModel = userManagerModel; + + this.repaint = function($container) { + $container.empty(); + + // + // Form template and title + // + var $containerColumn = $("<form>", { + "class" : FormUtil.formColumClass + " form-horizontal", + 'role' : "form", + "action" : "javascript:void(0);", + "onsubmit" : "" + }); + + $containerColumn.append($("<h1>").append(" User Manager")); + + // + // Data Grid + // + var dataGridContainer = $("<div>"); + + var _this = this; + + var columns = [ { + label : 'User ID', + property : 'userId', + sortable : true + } , { + label : 'Email', + property : 'email', + sortable : true + }, { + label : 'First Name', + property : 'firstName', + sortable : true + }, { + label : 'Last Name', + property : 'lastName', + sortable : true + }, { + label : 'Active', + property : 'active', + sortable : true + }]; + + var getDataList = function(callback) { + var dataList = []; + for(var idx = 0; idx < _this._userManagerModel.persons.length; idx++) { + var person = _this._userManagerModel.persons[idx]; + dataList.push({ + userId : person.userId, + email : person.email, + firstName : person.firstName, + lastName : person.lastName, + active : (person.active)?"True":"False" + }); + } + callback(dataList); + } + + var dataGrid = new DataGridController(null, columns, getDataList, null); + dataGrid.init(dataGridContainer); + + // + // Render + // + $containerColumn.append(dataGridContainer); + $container.append($containerColumn); + } +} \ No newline at end of file