From c68648190b062550fdbb7dbe7a282c87648b198d Mon Sep 17 00:00:00 2001 From: yvesn <yvesn> Date: Wed, 17 May 2017 11:24:55 +0000 Subject: [PATCH] SSDM-5068 : ELN config on GUI (Setup to start to work on the form) SVN: 38194 --- .../core-plugins/eln-lims/1/as/elnTypes.py | 7 +++ .../1/as/initializemasterdataminimum.py | 1 + .../1/as/webapps/eln-lims/html/index.html | 4 ++ .../eln-lims/html/js/config/Profile.js | 13 +++- .../html/js/controllers/MainController.js | 23 +++++++ .../SettingsForm/SettingsFormController.js | 29 +++++++++ .../views/SettingsForm/SettingsFormModel.js | 20 ++++++ .../js/views/SettingsForm/SettingsFormView.js | 62 +++++++++++++++++++ .../js/views/SideMenu/SideMenuWidgetView.js | 8 ++- .../reporting-plugins/eln-lims-api/script.py | 12 +++- 10 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormController.js create mode 100644 openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormModel.js create mode 100644 openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormView.js diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py index 67940a21bc9..d009f95fc21 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py @@ -918,6 +918,13 @@ WESTERN_BLOTTING_PROTOCOL = [FIRST_TIME_VERSIONED, True, "WESTERN_BLOTTING_PROTO [FIRST_TIME_VERSIONED, "ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", "ANNOTATIONS_WESTERN_BLOTTING_PROTOCOL", None] ]]; +## +## Types - Configuration +## +GENERAL_ELN_SETTINGS = [MANDATORY_ITEM_VERSION, False, "GENERAL_ELN_SETTINGS", "Used to store the settings of the ELN application", [ + [MANDATORY_ITEM_VERSION, "ELN_SETTINGS", "Settings", "ELN Settings", DataType.VARCHAR, None, "ELN Settings", None, None, False, False] +]]; + ## ## Types - Orders ## diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initializemasterdataminimum.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initializemasterdataminimum.py index f4d801f3a10..97873d43788 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initializemasterdataminimum.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initializemasterdataminimum.py @@ -57,6 +57,7 @@ def initBasicMasterData(tr): ## ## Sample Types - Non Materials ## + elnTypes.createSampleTypeWithProperties(tr, elnTypes.GENERAL_ELN_SETTINGS); elnTypes.createSampleTypeWithProperties(tr, elnTypes.EXPERIMENTAL_STEP); ## diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html index 4786e2cfd9c..2f91865d9bc 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html @@ -210,6 +210,10 @@ <script type="text/javascript" src="./js/views/LabNotebook/LabNotebookModel.js"></script> <script type="text/javascript" src="./js/views/LabNotebook/LabNotebookView.js"></script> + <script type="text/javascript" src="./js/views/SettingsForm/SettingsFormController.js"></script> + <script type="text/javascript" src="./js/views/SettingsForm/SettingsFormModel.js"></script> + <script type="text/javascript" src="./js/views/SettingsForm/SettingsFormView.js"></script> + <script type="text/javascript" src="./js/views/Inventory/InventoryController.js"></script> <script type="text/javascript" src="./js/views/Inventory/InventoryModel.js"></script> <script type="text/javascript" src="./js/views/Inventory/InventoryView.js"></script> diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js index b6c2328ecf4..5d1e6eb6274 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js @@ -46,6 +46,7 @@ $.extend(DefaultProfile.prototype, { showStorageManager : true, showAdvancedSearch : true, showTrashcan : true, + showSettings : true, showVocabularyViewer : true, showUserManager : true } @@ -127,7 +128,7 @@ $.extend(DefaultProfile.prototype, { this.searchDomains = [ { "@id" : -1, "@type" : "GobalSearch", label : "Global", name : "global"}]; this.inventorySpaces = ["MATERIALS", "METHODS"]; //"STOCK_CATALOG" - this.inventorySpacesReadOnly = []; //"STOCK_ORDERS" + this.inventorySpacesReadOnly = ["ELN_SETTINGS"]; //"STOCK_ORDERS" this.sampleTypeProtocols = ["GENERAL_PROTOCOL", "PCR_PROTOCOL", "WESTERN_BLOTTING_PROTOCOL"]; this.searchSamplesUsingV3OnDropbox = false; this.searchSamplesUsingV3OnDropboxRunCustom = false; @@ -137,6 +138,10 @@ $.extend(DefaultProfile.prototype, { return !this.isInventorySpace(space); } + this.isHiddenSpace = function(spaceCode) { + return $.inArray(spaceCode, this.hideSpaces) !== -1; + } + this.isInventorySpace = function(spaceCode) { return ($.inArray(spaceCode, this.inventorySpaces) !== -1) || ($.inArray(spaceCode, this.inventorySpacesReadOnly) !== -1); } @@ -146,9 +151,11 @@ $.extend(DefaultProfile.prototype, { this.copyPastePlainText = false; this.hideCodes = true; this.hideTypes = { - "sampleTypeCodes" : [], + "sampleTypeCodes" : ["GENERAL_ELN_SETTINGS"], "experimentTypeCodes" : [] - } + } + this.hideSpaces = ["ELN_SETTINGS"]; + this.propertyReplacingCode = "NAME"; this.sampleTypeDefinitionsExtension = { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js index 937bbc4a980..8443216a847 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js @@ -243,6 +243,14 @@ function MainController(profile) { try { switch (newViewChange) { + case "showSettingsPage": + document.title = "Settings"; + this._showSettingsPage(FormMode.VIEW); + break; + case "showEditSettingsPage": + document.title = "Edit Settings"; + this._showSettingsPage(FormMode.EDIT); + break; case "showExportTreePage": document.title = "Export Builder"; var newView = new ExportTreeController(this); @@ -640,6 +648,21 @@ function MainController(profile) { return modificableViews; } + this._showSettingsPage = function(mode) { + var _this = this; + this.serverFacade.searchSamples({ "sampleIdentifier" : "/ELN_SETTINGS/GENERAL_ELN_SETTINGS" }, function(data) { + if(!data[0]) { + window.alert("The item is no longer available, refresh the page, if the problem persists tell your admin that the Lucene index is probably corrupted."); + } else { + var newView = new SettingsFormController(this, data[0], mode); + var views = _this._getNewViewModel(true, true, false); + newView.init(views); + _this.currentView = newView; + //window.scrollTo(0,0); + } + }); + } + this._showStorageManager = function() { var views = this._getNewViewModel(true, true, false); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormController.js new file mode 100644 index 00000000000..718c15c1d1a --- /dev/null +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormController.js @@ -0,0 +1,29 @@ +/* + * 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 SettingsFormController(mainController, settingsSample, mode) { + this._mainController = mainController; + this._settingsFormModel = new SettingsFormModel(settingsSample, mode); + this._settingsFormView = new SettingsFormView(this, this._settingsFormModel); + + this.init = function(views) { + this._settingsFormView.repaint(views); + } + + this.save = function() { + alert("Save Clicked"); + } +} \ No newline at end of file diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormModel.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormModel.js new file mode 100644 index 00000000000..26ec6ab3a9d --- /dev/null +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormModel.js @@ -0,0 +1,20 @@ +/* + * 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 SettingsFormModel(settingsSample, mode) { + this.settingsSample = settingsSample; + this.mode = mode; +} \ No newline at end of file diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormView.js new file mode 100644 index 00000000000..da377ace208 --- /dev/null +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormView.js @@ -0,0 +1,62 @@ +/* + * 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 SettingsFormView(settingsFormController, settingsFormModel) { + this._settingsFormController = settingsFormController; + this._settingsFormModel = settingsFormModel; + + this.repaint = function(views) { + var _this = this; + var $container = views.content; + + var $form = $("<div>"); + var $formColumn = $("<div>"); + + $form.append($formColumn); + + var typeTitle = "Settings"; + + var $formTitle = $("<h2>").append(typeTitle); + + // + // Toolbar + // + var toolbarModel = []; + + + if(this._settingsFormModel.mode === FormMode.VIEW) { + //Edit + var $editButton = FormUtil.getButtonWithIcon("glyphicon-edit", function () { + mainController.changeView('showEditSettingsPage'); + }); + toolbarModel.push({ component : $editButton, tooltip: "Edit" }); + } else { //Create and Edit + //Save + var $saveBtn = FormUtil.getButtonWithIcon("glyphicon-floppy-disk", function() { + _this._settingsFormController.save(); + }, "Save"); + $saveBtn.removeClass("btn-default"); + $saveBtn.addClass("btn-primary"); + toolbarModel.push({ component : $saveBtn, tooltip: "Save" }); + } + + var $header = views.header; + $header.append($formTitle); + $header.append(FormUtil.getToolbar(toolbarModel)); + + $container.append($form); + } +} \ No newline at end of file diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js index 3f856ce84e2..10af15a01ba 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js @@ -206,6 +206,11 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { treeModelUtils.push({ title : trashCanLink, entityType: "TRASHCAN", key : "TRASHCAN", folder : false, lazy : false, view : "showTrashcanPage", icon : "glyphicon glyphicon-trash" }); } + if(profile.mainMenu.showSettings) { + var settingsLink = _this.getLinkForNode("Settings", "SETTINGS", "showSettingsPage", null); + treeModelUtils.push({ title : settingsLink, entityType: "SETTINGS", key : "SETTINGS", folder : false, lazy : false, view : "showSettingsPage", icon : "glyphicon glyphicon-cog" }); + } + treeModel.push({ title : "Utilities", entityType: "UTILITIES", key : "UTILITIES", folder : true, lazy : false, expanded : true, children : treeModelUtils, icon : "glyphicon glyphicon-wrench" }); treeModel.push({ title : "About", entityType: "ABOUT", key : "ABOUT", folder : false, lazy : false, view : "showAbout", icon : "glyphicon glyphicon-info-sign" }); @@ -244,7 +249,8 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { for (var i = 0; i < spaces.length; i++) { var space = spaces[i]; var isInventorySpace = profile.isInventorySpace(space.code); - if((type === "LAB_NOTEBOOK" && !isInventorySpace) || (type === "INVENTORY" && isInventorySpace)) { + var isHiddenSpace = profile.isHiddenSpace(space.code); + if(((type === "LAB_NOTEBOOK" && !isInventorySpace) || (type === "INVENTORY" && isInventorySpace)) && !isHiddenSpace) { var normalizedSpaceTitle = Util.getDisplayNameFromCode(space.code); var spaceLink = _this.getLinkForNode(normalizedSpaceTitle, space.getCode(), "showSpacePage", space.getCode()); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py index 2434b75559c..6c926ccdf14 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py @@ -354,6 +354,12 @@ def insertExperimentIfMissing(tr, experimentIdentifier, experimentType, experime experiment.setPropertyValue("NAME", experimentName); return experiment; +def insertSampleIfMissing(tr, sampleIdentifier, sampleType): + sample = tr.getSample(sampleIdentifier); + if sample == None: + sample = tr.createNewSample(sampleIdentifier, sampleType); + return sample; + def init(tr, parameters, tableBuilder): projectsCache = {}; installedTypes = getSampleTypes(tr, parameters); @@ -363,9 +369,10 @@ def init(tr, parameters, tableBuilder): isNewInstallation = inventorySpace == None and methodsSpace == None and materialsSpace == None; ## Installing Mandatory Spaces/Projects on every login if missing + insertSpaceIfMissing(tr, "ELN_SETTINGS"); insertSpaceIfMissing(tr, "METHODS"); insertSpaceIfMissing(tr, "MATERIALS"); - + if isSampleTypeAvailable(installedTypes, "SUPPLIER") and isSampleTypeAvailable(installedTypes, "PRODUCT") and isSampleTypeAvailable(installedTypes, "REQUEST") and isSampleTypeAvailable(installedTypes, "ORDER"): insertSpaceIfMissing(tr, "STOCK_CATALOG"); insertProjectIfMissing(tr, "/STOCK_CATALOG/PRODUCTS", projectsCache); @@ -387,6 +394,9 @@ def init(tr, parameters, tableBuilder): # On new installations check if the default types are installed to create their respective PROJECT/EXPERIMENTS if isNewInstallation: + if isSampleTypeAvailable(installedTypes, "GENERAL_ELN_SETTINGS"): + insertSampleIfMissing(tr, "/ELN_SETTINGS/GENERAL_ELN_SETTINGS", "GENERAL_ELN_SETTINGS"); + if isSampleTypeAvailable(installedTypes, "ANTIBODY"): insertProjectIfMissing(tr, "/MATERIALS/REAGENTS", projectsCache); insertExperimentIfMissing(tr, "/MATERIALS/REAGENTS/ANTIBODY_COLLECTION_1", "MATERIALS", "Antibody Collection 1"); -- GitLab