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 2beba36be32606a7304c81055582a6cdd128c2b1..323b3aa1a392393186520a381d552510eed988ef 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 @@ -93,7 +93,12 @@ function MainController(profile) { localReference.changeView("showMainMenu", null); Util.unblockUI(); - + + var openNewSampleTab = Util.queryString.samplePermId; + + if(openNewSampleTab) { + localReference.changeView("showViewSamplePageFromPermId", openNewSampleTab); + } //Get datastores for automatic DSS configuration, the first one will be used localReference.serverFacade.listDataStores( function(dataStores) { @@ -136,30 +141,46 @@ function MainController(profile) { switch (newViewChange) { case "showInspectors": + document.title = "Show Inspectors"; this._showInspectors(); break; case "showMainMenu": + document.title = "Main Menu"; this._showMainMenu(); break; case "showSearchPage": + document.title = "Search"; this._showSearchPage(arg); break; case "showSamplesPage": + document.title = "Samples " + arg; this._showSamplesPage(arg); break; case "showSampleHierarchyPage": + document.title = "Hierarchy " + arg; this._showSampleHierarchyPage(arg); break; case "showCreateSamplePage": + document.title = "Create Sample " + arg; this._showCreateSamplePage(arg); break; case "showEditSamplePage": + document.title = arg; this._showEditSamplePage(arg); break; case "showViewSamplePageFromPermId": - this._showViewSamplePageFromPermId(arg); + var _this = this; + this.serverFacade.searchWithUniqueId(arg, 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 { + document.title = data[0].code; + _this._showViewSamplePage(data[0]); + } + }); break; case "showCreateDataSetPage": + document.title = "Create Data Set for " + arg; this._showCreateDataSetPage(arg); break; default: @@ -261,23 +282,17 @@ function MainController(profile) { }); } - this._showViewSamplePageFromPermId = function(permId) { - var localInstance = this; - this.serverFacade.searchWithUniqueId(permId, 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."); - } - //Update menu - var breadCrumbPage = new BreadCrumbPage('view-sample', "showViewSamplePageFromPermId", data[0].permId, 'View '+data[0].code); - localInstance.navigationBar.updateBreadCrumbPage(breadCrumbPage); + this._showViewSamplePage = function(sample) { + //Update menu + var breadCrumbPage = new BreadCrumbPage('view-sample', "showViewSamplePageFromPermId", sample.permId, 'View '+ sample.code); + this.navigationBar.updateBreadCrumbPage(breadCrumbPage); - //Show Form - var isELNExperiment = localInstance.profile.isELNExperiment(data[0].sampleTypeCode); - var sampleForm = new SampleForm(localInstance.serverFacade, localInstance.inspector, "mainContainer", localInstance.profile, data[0].sampleTypeCode, isELNExperiment, SampleFormMode.VIEW, data[0]); - sampleForm.init(); - localInstance.currentView = sampleForm; - history.pushState(null, "", ""); //History Push State - }); + //Show Form + var isELNExperiment = this.profile.isELNExperiment(sample.sampleTypeCode); + var sampleForm = new SampleForm(this.serverFacade, this.inspector, "mainContainer", this.profile, sample.sampleTypeCode, isELNExperiment, SampleFormMode.VIEW, sample); + sampleForm.init(); + this.currentView = sampleForm; + history.pushState(null, "", ""); //History Push State } this._showCreateDataSetPage = function(sample) { diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/util/Util.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/util/Util.js index d6ec1b6814d809b9e0d90d23e48503cf1817c781..15dca0ae8eeaf70926f13a1c028df08ef0f652f3 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/util/Util.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/util/Util.js @@ -20,6 +20,7 @@ * Contains methods used for common tasks. */ var Util = new function() { + // // Methods to block user input // @@ -224,6 +225,29 @@ var Util = new function() { var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; return text.replace(exp,"<a href='$1' target='_blank'>$1</a>"); } + + this.queryString = function () { + // This function is anonymous, is executed immediately and + // the return value is assigned to QueryString! + var query_string = {}; + var query = window.location.search.substring(1); + var vars = query.split("&"); + for (var i=0;i<vars.length;i++) { + var pair = vars[i].split("="); + // If first entry with this name + if (typeof query_string[pair[0]] === "undefined") { + query_string[pair[0]] = pair[1]; + // If second entry with this name + } else if (typeof query_string[pair[0]] === "string") { + var arr = [ query_string[pair[0]], pair[1] ]; + query_string[pair[0]] = arr; + // If third or later entry with this name + } else { + query_string[pair[0]].push(pair[1]); + } + } + return query_string; + } (); } diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleTable.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleTable.js index 5c1567239a5b195d96a2890c1f70bf1b7c927e10..ddc6ce1d0d46d2bfcb582289573a340c53d6234c 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleTable.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleTable.js @@ -372,11 +372,14 @@ function SampleTable(serverFacade, sampleTableId, profile, sampleTypeCode, inspe .selectAll("td").data(function(sample) { var tableFields = null; var imageOnClick = "javascript:Util.showImage($('#preview"+sample.identifier.replace(/\//g,'-')+"').attr('src')); event.stopPropagation();"; + var url = document.location.href; + url = url.substring(0,url.lastIndexOf("/") + 1); + var sampleLink = "<a href='"+url+"?samplePermId=" + sample.permId + "' target='_blank'>" + sample.code + "</a>"; if(localReference.isSearch) { - tableFields = [sample.code, "<img data-preview-loaded='false' onClick=\""+imageOnClick+"\" class='zoomableImage' id='preview"+sample.identifier.replace(/\//g,'-')+"' src='./img/image_loading.gif' style='height:80px;'></img>", sample.sampleTypeCode, sample.properties, sample.properties ]; + tableFields = [sampleLink, "<img data-preview-loaded='false' onClick=\""+imageOnClick+"\" class='zoomableImage' id='preview"+sample.identifier.replace(/\//g,'-')+"' src='./img/image_loading.gif' style='height:80px;'></img>", sample.sampleTypeCode, sample.properties, sample.properties ]; } else { - tableFields = [sample.code, "<img data-preview-loaded='false' onClick=\""+imageOnClick+"\" class='zoomableImage' id='preview"+sample.identifier.replace(/\//g,'-')+"' src='./img/image_loading.gif' style='height:80px;'></img>"]; + tableFields = [sampleLink, "<img data-preview-loaded='false' onClick=\""+imageOnClick+"\" class='zoomableImage' id='preview"+sample.identifier.replace(/\//g,'-')+"' src='./img/image_loading.gif' style='height:80px;'></img>"]; for(var i=0; i<sampleTypeProperties.length; i++) { var tableFieldValue = sample.properties[sampleTypeProperties[i]]; if(!tableFieldValue) {