From a993ae58f3c848bbf46c90f217d1dbc1f44828c1 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Wed, 23 Nov 2016 16:53:57 +0800 Subject: webui: products: Implement GET action "which" The "which" GET action try to locate the given executable name/path, in order to check whether the executable callable. This function will be used to check the validity of the specified FITS viewer, which opens the HPX FITS images. --- fg21sim/webui/static/js/products.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'fg21sim/webui/static') diff --git a/fg21sim/webui/static/js/products.js b/fg21sim/webui/static/js/products.js index 0b25eaa..72a7028 100644 --- a/fg21sim/webui/static/js/products.js +++ b/fg21sim/webui/static/js/products.js @@ -191,6 +191,25 @@ var getServerManifest = function (url) { }; +/** + * Locate the command in the `$PATH` on the server, which checks + * whether the command can be called. + * + * @param {String} cmd - The command name or path. + */ +var whichExecutable = function (url, cmd) { + return $.getJSON(url, {action: "which", cmd: JSON.stringify(cmd)}) + .fail(function (jqxhr) { + var modalData = {}; + modalData.icon = "times-circle"; + modalData.contents = "Cannot locate the command in PATH!"; + modalData.code = jqxhr.status; + modalData.reason = jqxhr.statusText; + showModalProducts(modalData); + }); +}; + + /** * Reset the products manifest on both the server side and client side */ @@ -270,7 +289,7 @@ $(document).ready(function () { // Save current products manifest $("#save-products").on("click", function () { - saveServerManifest(ajax_url); + saveServerManifest(ajax_url, true); }); // Show product information (metadata) -- cgit v1.2.2