diff options
author | mconway <michael.c.conway@gmail.com> | 2013-02-15 17:31:02 (GMT) |
---|---|---|
committer | mconway <michael.c.conway@gmail.com> | 2013-02-15 17:31:02 (GMT) |
commit | 59eaf16598bd4a323b82017f8542b794542acf63 (patch) | |
tree | 05c3999aa79c2fb70e319161cf9342ebdbc07a17 | |
parent | 26c8e6084e5f83ae130358c26713cde506e805d4 (diff) | |
download | QCG-Data-59eaf16598bd4a323b82017f8542b794542acf63.zip QCG-Data-59eaf16598bd4a323b82017f8542b794542acf63.tar.gz QCG-Data-59eaf16598bd4a323b82017f8542b794542acf63.tar.bz2 |
[#1204] cleanup initial view (should be info)
7 files changed, 115 insertions, 51 deletions
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy index 379618e..3efb564 100755 --- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy +++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/BrowseController.groovy @@ -64,6 +64,12 @@ class BrowseController { ViewState viewState = viewStateService.getViewStateFromSessionAndCreateIfNotThere() log.info("viewState:${viewState}") + + + if (viewState) { + mode = "path" + absPath = viewState.rootPath + } if (mode != null) { if (mode == "path") { @@ -185,11 +191,11 @@ class BrowseController { * If I have a preserved view state, initialize to that */ - String rootPath = viewStateService.retrieveRootPath() + ViewState viewState = viewStateService.getViewStateFromSessionAndCreateIfNotThere() - if (rootPath) { + if (viewState.rootPath) { - parent = rootPath + parent = viewState.rootPath icon = "folder" state = "closed" @@ -353,8 +359,7 @@ class BrowseController { throw new JargonException("no absolute path passed to the method") } - ViewState viewState = viewStateService.getViewStateFromSessionAndCreateIfNotThere() - viewState.browseView = "browse" + ViewState viewState = viewStateService.saveViewModeAndSelectedPath("browse", absPath) log.info "displayBrowseGridDetails for absPath: ${absPath}" try { @@ -406,7 +411,7 @@ class BrowseController { throw new JargonException("no absolute path passed to the method") } - viewStateService.saveViewMode("info") + viewStateService.saveViewModeAndSelectedPath("info", absPath) ViewNameAndModelValues mav = handleInfoLookup(absPath) render(view:mav.view, model:mav.model) @@ -583,6 +588,8 @@ class BrowseController { if (absPath == null) { throw new JargonException("no absolute path passed to the method") } + + viewStateService.saveViewModeAndSelectedPath("gallery", absPath) try { log.info "galleryView for absPath: ${absPath}" diff --git a/idrop-web/grails-app/i18n/messages.properties b/idrop-web/grails-app/i18n/messages.properties index c3ccc1e..b28e78c 100755 --- a/idrop-web/grails-app/i18n/messages.properties +++ b/idrop-web/grails-app/i18n/messages.properties @@ -173,7 +173,7 @@ heading.upload.ticket.collection=Select a local file to upload to the ticket col #page specific text -browse.page.prompt=Select a directory or file to see info and tags based on the view option +browse.page.prompt=Select a directory or file to see info and actions # messages error.confirm.password.missing=Confirmation password is null or blank diff --git a/idrop-web/grails-app/services/org/irods/mydrop/service/ViewStateService.groovy b/idrop-web/grails-app/services/org/irods/mydrop/service/ViewStateService.groovy index baabfcb..228e00e 100644 --- a/idrop-web/grails-app/services/org/irods/mydrop/service/ViewStateService.groovy +++ b/idrop-web/grails-app/services/org/irods/mydrop/service/ViewStateService.groovy @@ -52,6 +52,27 @@ class ViewStateService { return viewState.browseView } + /** + * Save a path and mode in the view state for later retrieval + * @param viewMode + * @param absolutePath + */ + public ViewState saveViewModeAndSelectedPath(String viewMode, String absolutePath) { + + if (viewMode == null) { + throw new IllegalArgumentException("null viewMode") + } + + if (absolutePath == null) { + throw new IllegalArgumentException("null absolutePath") + } + + ViewState viewState = getViewStateFromSessionAndCreateIfNotThere() + viewState.browseView = viewMode + viewState.selectedPath = absolutePath + return viewState + } + public void saveViewMode(String viewMode) { if (viewMode == null) { throw new IllegalArgumentException("null viewMode") diff --git a/idrop-web/grails-app/views/browse/_browseTabContent.gsp b/idrop-web/grails-app/views/browse/_browseTabContent.gsp index a4e775e..2d27b70 100755 --- a/idrop-web/grails-app/views/browse/_browseTabContent.gsp +++ b/idrop-web/grails-app/views/browse/_browseTabContent.gsp @@ -13,6 +13,7 @@ <div id="browseDialogArea"><!-- general area to spawn jquery dialogs --></div> + <div id="browser" class="wrapper" style="height:85%;width:100%;clear:both;overflow:hidden;"> <div id="dataTreeView" style="width: 100%; height: 700px; overflow: hidden;"> diff --git a/idrop-web/grails-app/views/browse/index.gsp b/idrop-web/grails-app/views/browse/index.gsp index c69296e..4280795 100755 --- a/idrop-web/grails-app/views/browse/index.gsp +++ b/idrop-web/grails-app/views/browse/index.gsp @@ -6,7 +6,9 @@ <div class="wrapper clearfix"
style="height: 820px; overflow:hidden;">
<g:hiddenField name="mode" id="mode" value="${mode}"/>
- <g:hiddenField name="presetPath" id="presetPath" value="${path}"/>
+ <g:hiddenField name="viewStateBrowseOptionVal" id="viewStateBrowseOptionVal" value="${viewState.browseView}"/>
+ <g:hiddenField name="presetPath" id="presetPath" value="${viewState.rootPath}"/>
+ <g:hiddenField id="viewStateSelectedPath" name="viewStateSelectedPath" value="${viewState.selectedPath}"/>
<g:render template="/browse/browseTabContent" />
</div>
@@ -31,12 +33,15 @@ });
var mode = $("#mode").val();
- var startPath = $("#presetPath").val();
+ browseOptionVal = $("#viewStateBrowseOptionVal").val();
+ dataTreePath = $("#presetPath").val();
+ var thisSelectedPath = $("#viewStateSelectedPath").val();
+
if (mode == null || mode=="") {
- retrieveBrowserFirstView("detect","");
+ retrieveBrowserFirstView("detect","", thisSelectedPath);
} else {
- retrieveBrowserFirstView(mode, startPath);
+ retrieveBrowserFirstView(mode, dataTreePath, thisSelectedPath);
}
$(window).bind( 'hashchange', function(e) {
diff --git a/idrop-web/web-app/js/mydrop/home.js b/idrop-web/web-app/js/mydrop/home.js index 26df227..18e6d17 100755 --- a/idrop-web/web-app/js/mydrop/home.js +++ b/idrop-web/web-app/js/mydrop/home.js @@ -22,6 +22,7 @@ var dataTreePath = ""; var browseOptionVal = "info"; var selectedPath = null; +var requestedSelectedPath = null; var selectedNode = null; var fileUploadUI = null; var aclDialogMessageSelector = "#aclDialogMessageArea"; @@ -57,7 +58,7 @@ var fileStarUrl = '/browse/starFile' * * @return */ -function retrieveBrowserFirstView(type, path) { +function retrieveBrowserFirstView(type, path, pathSelectedInTree) { if (dataTree != null) { dataTree = null; $("#dataTreeDiv").html(""); @@ -89,6 +90,7 @@ function retrieveBrowserFirstView(type, path) { dataTreeView = type; dataTreePath = path; + requestedSelectedPath = pathSelectedInTree; $.bbq.pushState(state); @@ -194,7 +196,15 @@ function browserFirstViewRetrieved(data) { } }); - + + + $("#dataTreeDiv").bind("loaded.jstree", function(e, data) { + if (requestedSelectedPath) { + selectTreePathFromIrodsPath(requestedSelectedPath); + } + }); + + $("#dataTreeDiv").bind("select_node.jstree", function(e, data) { nodeSelected(e, data.rslt.obj); }); @@ -245,7 +255,22 @@ function browserFirstViewRetrieved(data) { }); - updateBrowseDetailsForPathBasedOnCurrentModel(baseAbsPath); + /* + * selected path is set if a node in the tree was selected by user. If it's there it's a selection, so show that path in the tree + * + * if the selected path is not there, see if I am asking for a particular path to be revealed, this is passed by the index.gsp for + * the browse view and is used to initialize the requestedSelectedPath. In this case, select the path by finding it in the tree, + * causing the browse view to also be updated + * + * otherwise, just use the root of the tree as the initial selection + */ + if (selectedPath) { + updateBrowseDetailsForPathBasedOnCurrentModel(selectedPath); + } else if (requestedSelectedPath) { + // wait and do this after the tree loads, look at above function bound to load event + } else { + updateBrowseDetailsForPathBasedOnCurrentModel(baseAbsPath); + } } @@ -637,11 +662,10 @@ function updateBrowseDetailsForPathBasedOnCurrentModel(absPath) { absPath = baseAbsPath; } - if (browseOptionVal == null) { + if (browseOptionVal == null || browseOptionVal == "") { browseOptionVal = "info"; } - setPathCrumbtrail(absPath); if (browseOptionVal == "browse") { @@ -2018,7 +2042,7 @@ function addANodeToTheParentInTheTree(parentAbsolutePath, childRelativeName) { * Given an iRODS absolute path to a node, find and select that node * * @param irodsAbsolutePath - * irods absolute path + * irods absolute path is a string with a path, in the form /a/path/to/something */ function selectTreePathFromIrodsPath(irodsAbsolutePath) { @@ -2029,8 +2053,10 @@ function selectTreePathFromIrodsPath(irodsAbsolutePath) { if (irodsAbsolutePath == "/") { return false; } + + var splitPath = irodsAbsolutePath.split("/"); - selectTreePath(irodsAbsolutePath.split("/"), null, null); + selectTreePath(splitPath, null, null); } @@ -2139,7 +2165,15 @@ function selectTreePath(path, currentNode, currentIndex) { performOperationAtGivenTreePath(path, null, null, function(path, dataTree, currentNode) { $.jstree._reference(dataTree).open_node(currentNode); - $.jstree._reference(dataTree).select_node(currentNode, true); + + // see if this node should be selected by comparing paths + + var currentId = currentNode[0].id; + var idPath = currentId.split("/"); + if (path.length == idPath.length) { + $.jstree._reference(dataTree).select_node(currentNode, true); + } + }); } @@ -2305,7 +2339,7 @@ function performOperationAtGivenTreePath(path, currentNode, currentIndex, currentNode); currentNode = getPathInNode(children, value); if (currentNode == null) { - setMessage("Path not found in tree, please reload"); + //setMessage("Path not found in tree, please reload"); return false; } /* * else { if (index == path.length - 1) { end = true; } } @@ -2345,8 +2379,8 @@ function processStateChange(state) { } } - if (view == null && browseOptionVal == "info") { - browseOptionVal = "browse"; + if (statePath && view == null && browseOptionVal == "info") { + browseOptionVal = "info"; selectTreePathFromIrodsPath(statePath); } else if (view != browseOptionVal && statePath == selectedPath) { // view change only diff --git a/idrop-web/web-app/js/mydrop/lingo_common.js b/idrop-web/web-app/js/mydrop/lingo_common.js index c633cfd..3f353a4 100755 --- a/idrop-web/web-app/js/mydrop/lingo_common.js +++ b/idrop-web/web-app/js/mydrop/lingo_common.js @@ -361,8 +361,7 @@ function lcSendValueAndPlugHtmlInDiv(getUrl, resultDiv, context, throw ("no get url for call"); } - var img = document.createElement('IMG'); - img.setAttribute("src", +context + "/images/ajax-loader.gif"); + showBlockingPanel(); $(resultDiv).html(img); @@ -373,6 +372,7 @@ function lcSendValueAndPlugHtmlInDiv(getUrl, resultDiv, context, if (continueReq) { lcFillInDivWithHtml(data, resultDiv, postLoadFunction); } + unblockPanel(); }, "html").error(function(xhr, status, error) { resultDiv.html(""); @@ -386,6 +386,7 @@ function lcSendValueAndPlugHtmlInDiv(getUrl, resultDiv, context, } catch(err) { // ignore } + unblockPanel(); setErrorMessage(err); } @@ -401,10 +402,7 @@ function lcSendValueWithParamsAndPlugHtmlInDiv(getUrl, params, resultDiv, throw ("no get url for call"); } - var img = document.createElement('IMG'); - img.setAttribute("src", context + "/images/ajax-loader.gif"); - - $(resultDiv).html(img); + showBlockingPanel(); try { @@ -413,9 +411,11 @@ function lcSendValueWithParamsAndPlugHtmlInDiv(getUrl, params, resultDiv, if (continueReq) { lcFillInDivWithHtml(data, resultDiv, postLoadFunction); } + unblockPanel(); }, "html").error(function(xhr, status, error) { $(resultDiv).html(""); setErrorMessage(xhr.responseText); + unblockPanel(); }); } catch (err) { @@ -426,6 +426,7 @@ function lcSendValueWithParamsAndPlugHtmlInDiv(getUrl, params, resultDiv, } catch(err) { // ignore } + unblockPanel(); setErrorMessage(err); // console.log("javascript error:" + err); } @@ -444,10 +445,7 @@ function lcSendValueAndCallbackHtmlAfterErrorCheck(getUrl, divForAjaxError, return; } - var img = document.createElement('IMG'); - img.setAttribute("src", context + "/images/ajax-loader.gif"); - - $(divForLoadingGif).html(img); + showBlockingPanel(); try { @@ -462,11 +460,13 @@ function lcSendValueAndCallbackHtmlAfterErrorCheck(getUrl, divForAjaxError, $(divForLoadingGif).html(data); } + unblockPanel(); } }, "html").error(function(xhr, status, error) { $(divForLoadingGif).html(""); setErrorMessage(xhr.responseText); + unblockPanel(); }); } catch (err) { @@ -475,6 +475,7 @@ function lcSendValueAndCallbackHtmlAfterErrorCheck(getUrl, divForAjaxError, } catch(err) { // ignore } + unblockPanel(); setErrorMessage(err); // console.log("javascript error:" + err); } @@ -493,11 +494,8 @@ function lcSendValueAndCallbackHtmlAfterErrorCheckPreserveMessage(getUrl, divFor return; } - var img = document.createElement('IMG'); - img.setAttribute("src", context + "/images/ajax-loader.gif"); - - $(divForLoadingGif).html(img); - + showBlockingPanel(); + try { $.get(context + getUrl, function(data, status, xhr) { @@ -512,6 +510,7 @@ function lcSendValueAndCallbackHtmlAfterErrorCheckPreserveMessage(getUrl, divFor } } + unblockPanel(); }, "html").error(function(xhr, status, error) { try { @@ -519,11 +518,13 @@ function lcSendValueAndCallbackHtmlAfterErrorCheckPreserveMessage(getUrl, divFor } catch(err) { // ignore } + unblockPanel(); setErrorMessage(xhr.responseText); }); } catch (err) { $(divForLoadingGif).html(""); + unblockPanel(); if (err.indexOf("Runtime") > -1) { err = "Unable to view data, this may be a permissions issue"; @@ -547,11 +548,7 @@ function lcSendValueAndCallbackHtmlAfterErrorCheckThrowsException(getUrl, return; } - var img = document.createElement('IMG'); - img.setAttribute("src", context + "/images/ajax-loader.gif"); - - $(divForLoadingGif).html(img); - + showBlockingPanel(); $.get(context + getUrl, function(data, status, xhr) { var continueReq = checkForSessionTimeout(data, xhr); if (continueReq) { @@ -562,6 +559,7 @@ function lcSendValueAndCallbackHtmlAfterErrorCheckThrowsException(getUrl, $(divForLoadingGif).html(data); } } + unblockPanel(); }, "html").error(function(xhr, status, error) { $(divForLoadingGif).html(""); if (errorHandlingFunction == null) { @@ -569,6 +567,7 @@ function lcSendValueAndCallbackHtmlAfterErrorCheckThrowsException(getUrl, } else { errorHandlingFunction(); } + unblockPanel(); }); @@ -600,11 +599,7 @@ function lcSendValueViaPostAndCallbackHtmlAfterErrorCheck(postUrl, params, throw ("no post url for call"); } - var img = document.createElement('IMG'); - img.setAttribute("src", context + "/images/ajax-loader.gif"); - - $(divForLoadingGif).html(img); - + showBlockingPanel(); try { $.post(context + postUrl, params, function(data, status, xhr) { @@ -618,11 +613,13 @@ function lcSendValueViaPostAndCallbackHtmlAfterErrorCheck(postUrl, params, $(divForLoadingGif).html(data); } } + unblockPanel(); }, "html").error(function(xhr, status, error) { if (divForLoadingGif != null) { $(divForLoadingGif).html(""); } setErrorMessage(xhr.responseText); + unblockPanel(); }); @@ -633,6 +630,7 @@ function lcSendValueViaPostAndCallbackHtmlAfterErrorCheck(postUrl, params, // ignore } setErrorMessage(err); + unblockPanel(); } } @@ -656,11 +654,9 @@ function lcSendValueAndCallbackWithJsonAfterErrorCheck(getUrl, parms, callbackFunction(data); } }, "json").error(function(xhr, status, error) { - // continue? - var continueReq = checkForSessionTimeout(null, xhr); - if (continueReq) { + setErrorMessage(xhr.responseText); - } + }); } catch (err) { setErrorMessage(err); |