diff --git a/client-base/src/main/webapp/html/javascript/gene-table.js b/client-base/src/main/webapp/html/javascript/gene-table.js index a5fc26cd8..6d0a2dff6 100644 --- a/client-base/src/main/webapp/html/javascript/gene-table.js +++ b/client-base/src/main/webapp/html/javascript/gene-table.js @@ -167,7 +167,6 @@ function generateCyJSNetwork(url, requestParams, externalCall) { $("#loadingNetwork_Div").replaceWith('
Loading Network, please wait...
'); // Show loading spinner on 'tabviewer' div - $.post({ url: url, timeout: 1000000, @@ -183,8 +182,6 @@ function generateCyJSNetwork(url, requestParams, externalCall) { console.log(server_error.detail); alert(errorMsg); }).success(function (data) { - - // Network graph: JSON file. try { if (!externalCall) { @@ -260,6 +257,8 @@ function generateMultiGeneNetwork_forNewNetworkViewer(keyword, targetElement) { var candidatelist = []; var knetNotice; + var knetViewLimit = userAccessMgr.getGeneKnetLimit(); + var isUserPro = userAccessMgr.isLimitEnforced() var cb_list = $("input[name=candidates"); var cb_list_len = cb_list.length; @@ -268,26 +267,20 @@ function generateMultiGeneNetwork_forNewNetworkViewer(keyword, targetElement) { candidatelist.push(cb_list[i].value); } } - //console.log(candidatelist.length +" gene(s) selected."); - if (candidatelist == "") { - knetNotice = "Please select candidate genes." - jboxNotice(knetNotice, 'red', 300, 2000); - } - else if (candidatelist.length > knetview_limit/*20*/) { - if (enforce_genelist_limit === false) { // Pro plan user - knetNotice = 'Gene networks can only be created for up to max. ' + knetview_limit + ' genes.' + //console.log(candidatelist.length +" gene(s) selected."); + if (candidatelist.length > knetViewLimit/*20*/) { + if (!isUserPro) { // Pro plan user + knetNotice = 'Gene networks can only be created for up to max. ' + knetViewLimit + ' genes.'; } else { // Free plan user - knetNotice = 'Gene networks can only be created for up to max. ' + knetview_limit + ' genes.' - 'The KnetMiner Free Plan is limited to a network of ' + knetview_limit + ' genes. Upgrade to Pro plan now to create networks for 200 genes'; - + console.log('triggered Here') + knetNotice = '

The KnetMiner Free Plan is limited to a network of ' + knetViewLimit + ' genes.

Upgrade to Pro plan now to create networks
'; } - jboxNotice(knetNotice, 'red', 300, 2000); + jboxNotice(knetNotice,'black',10 , 10000,400); resetNetworkCall() - } else { generateCyJSNetwork(api_url + '/network', { keyword: keyword, list: candidatelist, isExportPlainJSON: false }, false); diff --git a/client-base/src/main/webapp/html/javascript/loginHandler/loginUtils.js b/client-base/src/main/webapp/html/javascript/loginHandler/loginUtils.js index fa9ecce57..44e220489 100644 --- a/client-base/src/main/webapp/html/javascript/loginHandler/loginUtils.js +++ b/client-base/src/main/webapp/html/javascript/loginHandler/loginUtils.js @@ -40,7 +40,7 @@ let sleep = time => new Promise((resolve) => setTimeout(resolve, time)); * @param {type} yPos * @returns {jBoxNotice} */ -function jboxNotice(content, colour, yPos, autoclose) { +function jboxNotice(content, colour, yPos, autoclose, width=autoclose,height=auto) { new jBox('Notice', { content: content, color: colour, @@ -48,7 +48,10 @@ function jboxNotice(content, colour, yPos, autoclose) { position: { x: 0, y: yPos - } + }, + width:width, + height:height + }); } diff --git a/client-base/src/main/webapp/html/javascript/user-access.js b/client-base/src/main/webapp/html/javascript/user-access.js index 8ed3b4c23..87e6c3b36 100644 --- a/client-base/src/main/webapp/html/javascript/user-access.js +++ b/client-base/src/main/webapp/html/javascript/user-access.js @@ -16,11 +16,13 @@ class UserAccessManager{ #current = null; #defaultGeneLimit = null; + #defaultKnetViewLimit = null; #isGeneLimitEnforced = null; constructor(){ this.#current = 'guest' this.#defaultGeneLimit = 20; + this.#defaultKnetViewLimit = 10; this.#isGeneLimitEnforced = true; } @@ -76,6 +78,7 @@ class UserAccessManager{ }else if(this.#current === 'pro'){ this.#isGeneLimitEnforced = false; + this.#defaultKnetViewLimit = 20 // TODO: don't mix business logic and UI // Have a separated function/component, like refreshUIrestrictions() and // call it outside of this class, after updates like setUserPlan() @@ -88,6 +91,10 @@ class UserAccessManager{ return this.#defaultGeneLimit } + getGeneKnetLimit(){ + return this.#defaultKnetViewLimit + } + // Checks if genes list limit is enforced or not. // Returns a boolean value to validate example queries restriction. // Primarily used to check if a user on a free or pro plan.