From be628b13cf8e2ee0347199cdf8bcc1a135bedf6c Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Thu, 6 Jun 2013 08:40:29 +0000 Subject: [PATCH] SP-687 BIS-301: Adding domains to iPad debug app. SVN: 29306 --- .../1/as/webapps/ipad-debug/html/index.html | 2 + .../1/as/webapps/ipad-debug/html/webapp.js | 38 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/openbis-ipad/source/core-plugins/ipad-ui/1/as/webapps/ipad-debug/html/index.html b/openbis-ipad/source/core-plugins/ipad-ui/1/as/webapps/ipad-debug/html/index.html index 4a8ed84ba02..63e03f618a4 100644 --- a/openbis-ipad/source/core-plugins/ipad-ui/1/as/webapps/ipad-debug/html/index.html +++ b/openbis-ipad/source/core-plugins/ipad-ui/1/as/webapps/ipad-debug/html/index.html @@ -92,10 +92,12 @@ <div id="detail" class="span12" style="overflow: auto;"></div> </div> </div> <!-- /container --> + <div id="search" class="container"> <div class="row-fluid"> <form id="search-form" class="well form-inline" action="javascript:"> <input id="searchtext" type="text" placeholder="search text"> + <select id="searchdomains"></select> <button id="search-button" type="submit" class="btn">Search</button> </form> </div> diff --git a/openbis-ipad/source/core-plugins/ipad-ui/1/as/webapps/ipad-debug/html/webapp.js b/openbis-ipad/source/core-plugins/ipad-ui/1/as/webapps/ipad-debug/html/webapp.js index 5e04735534b..c499babe9c3 100644 --- a/openbis-ipad/source/core-plugins/ipad-ui/1/as/webapps/ipad-debug/html/webapp.js +++ b/openbis-ipad/source/core-plugins/ipad-ui/1/as/webapps/ipad-debug/html/webapp.js @@ -52,8 +52,8 @@ IpadModel.prototype.selectNormalEntity = function(permId, refcon, d) { } } -IpadModel.prototype.setSearchText = function(searchText) { - searchForText(searchText); +IpadModel.prototype.setSearchText = function(searchText, searchDomain) { + searchForText(searchText, searchDomain); } /// The model that manages state and implements the operations @@ -151,7 +151,6 @@ function displayCallInProgress(node) node.append("p").text("Getting data..."); } - function displayClientPreferences(data) { displayResults(clientPrefs, data) } function displayNavigation(data) { displayResults(navigation, data) } function displayRoot(data) { displayResults(root, data) } @@ -162,11 +161,16 @@ function displaySearchResults(data) { displayResults(searchresults, data) } /** * Request the client perferences and show them in the page. */ +function clientPreferencesCallback(data) { + displayClientPreferences(data); + updateSearchDomains(data); +} + function listClientPreferences() { var parameters = {requestKey : 'CLIENT_PREFS'}; displayCallInProgress(clientPrefs); - openbisServer.createReportFromAggregationService("DSS1", "ipad-read-service-v1", parameters, displayClientPreferences); + openbisServer.createReportFromAggregationService("DSS1", "ipad-read-service-v1", parameters, clientPreferencesCallback); } /** @@ -209,9 +213,9 @@ function detailsForEntity(permId, refcon) openbisServer.createReportFromAggregationService("DSS1", "ipad-read-service-v1", parameters, displayDetail); } -function searchForText(searchText) +function searchForText(searchText, searchDomain) { - var parameters = {requestKey : 'SEARCH', searchtext: searchText}; + var parameters = {requestKey : 'SEARCH', searchtext: searchText, searchdomain: searchDomain}; displayCallInProgress(searchresults); openbisServer.createReportFromAggregationService("DSS1", "ipad-read-service-v1", parameters, displaySearchResults); @@ -233,14 +237,32 @@ function searchTab() $('#activate-search').parent().addClass("active"); } + +function getClientPreferencesAsMap(data) { + var clientPrefsMap = {}; + for(var rowIndex = 0; rowIndex < data.result.rows.length; rowIndex++) { + var row = data.result.rows[rowIndex]; + clientPrefsMap[row[0].value] = [row[1].value]; + } + return clientPrefsMap; +} + +function updateSearchDomains(data) { + var clientPrefs = getClientPreferencesAsMap(data); + var domains = $.parseJSON(clientPrefs['SEARCH_DOMAINS'][0]); + for(var domainIndex = 0; domainIndex < domains.length; domainIndex++) { + $('#searchdomains').append(new Option(domains[domainIndex].label, domains[domainIndex].key, true, true)); + } +} + function configureTabs() { $('#activate-search').click(searchTab); $('#activate-home').click(homeTab); - $('#search-form').submit(function() { - model.setSearchText($.trim($('#searchtext').val())); + model.setSearchText($.trim($('#searchtext').val()), $('#search-domains-select').val()); }); + } function enterApp(data) -- GitLab