Commit b3a50bf8 authored by David Hoksza's avatar David Hoksza
Browse files

jquery ajax changed to pure javascript; selections work for both pre-12.2 and...

jquery ajax changed to pure javascript; selections work for both pre-12.2 and 12.2 minerva versions; cleaning of interface includes unchecking of legend and comments boxes
parent 0e232b5c
Pipeline #8652 passed with stage
in 38 seconds
const introJs = require('intro.js');
const selections = {
minervaMap: '.minerva-map'
, leftPanel: '.minerva-left-panel'
, drugTabLink: 'a:contains("DRUG")'
, drugTabSearchPanel: '.minerva-drug-panel .searchPanel'
, drugTabInput: '.minerva-drug-panel input.tt-input'
, drugTabSearchLink: '.minerva-drug-panel div[name="searchQuery"] a'
, clearButton: 'button[name="clearButton"]'
};
const selections = require('./selections');
const initializeStory = function(params) {
......@@ -99,14 +89,10 @@ function initializeStoryContet($introContainer, params){
function carryOutStep(steps) {
if (steps.indexOf(0) >= 0) {
params.cleanMinerva();
}
if (steps.indexOf(1) >= 0) {
$(selections.drugTabLink).click();
$(selections.drugTabInput).val("");
}
if (steps.indexOf(2) >= 0) {
$(selections.drugTabLink).click();
$(selections.drugTabInput).val(""); //when going back
$(selections.drugTabSearchLink)[0].click();
$(selections.drugTabInput).val("levodopa;carbidopa");
}
......@@ -120,9 +106,9 @@ function initializeStoryContet($introContainer, params){
let stepsToCarryOut = [];
if (this._direction == 'backward') {
// if (this._currentStep == 2) {
// // $(selections.clearButton).click();
// }
if (this._currentStep == 2 || this._currentStep == 1) {
stepsToCarryOut.push(0)
}
}
......
......@@ -14,6 +14,8 @@ const settings = {
, padding: 30
};
const selections = require('./selections');
// ******************************************************************************
// ********************* PLUGIN REGISTRATION WITH MINERVA *********************
// ******************************************************************************
......@@ -210,13 +212,13 @@ function startIntro($introContainer, intro, step = 0) {
//TODO the calc should be changed so that when the calc changes in the minerva code, the plugin still works correctly
if (settings.padding > 0) {
pluginContainer.closest('.tab-pane').css('height', `calc(100vh - 42px - ${settings.padding}px)`);
$('#minervaAppDiv').css('padding', `${settings.padding}px`);
$(selections.minervaApp).css('padding', `${settings.padding}px`);
//now we need to let Minerva know that a resize of the map happend which can be done only
//by simulating what Minerva does when plugin split bar is moved
$('.minerva-header-hide-button').click();
$('.minerva-header-hide-button').click();
$(selections.leftMenuHideButton).click();
$(selections.leftMenuHideButton).click();
}
......@@ -253,14 +255,14 @@ function intializeIntroJs(){
].forEach( intro => {
intro.onexit(function () {
if (settings.padding) {
$('#minervaAppDiv').css('padding', '0px');
$(selections.minervaApp).css('padding', '0px');
//TODO the calc should be changed so that when the calc changes in the minerva code, the plugin still works correctly
pluginContainer.closest('.tab-pane').css('height', 'calc(100vh - 42px)');
//now we need to let Minerva know that a resize of the map happend which can be done only
//by simulating what Minerva does when plugin split bar is moved
$('.minerva-header-hide-button').click();
$('.minerva-header-hide-button').click();
$(selections.leftMenuHideButton).click();
$(selections.leftMenuHideButton).click();
}
});
});
......@@ -268,7 +270,7 @@ function intializeIntroJs(){
function addDisabledInteractionMessage(){
$('.introjs-disableInteraction').click( (event) => {
$(selections.introJsDisableInteractions).click( (event) => {
$container.find(".modal").modal('show');
});
}
......@@ -281,21 +283,21 @@ function cleanStory($introContainer) {
}
function cleanMinerva(){
$('.minerva-overview-button:contains("CLEAR")').click();
$('[title="center map"]').click()
$('div[role="dialog"]').css('display', 'none');
$('table[name="generalOverlaysTab"] td:contains("Pathways")').parent().find('a').click();
$(selections.clearButton).click();
$(selections.centerMapLink).click();
$(selections.dialogs).css('display', 'none');
$(selections.pathwaysOverlayCheckbox).parent().find('a').click();
// $('table[name="generalOverlaysTab"] td:contains("Network")').parent().find('a').click();
$('table[name="generalOverlaysTab"] input').each(function(ix, e) {
$(selections.leftMenuInputs).add(selections.topCheckBoxes).each(function(ix, e) {
if ($(e).prop('checked')){
$(e).click();
};
}
});
$($('div[name="tabView"]:contains("SEARCH") .nav:has(i.fa-search) a')[0]).click();
$('a:contains("GENERIC")').click();
$(selections.genericTab)[0].click();
$(selections.genericSearchTab).click();
$('.ui-dialog button[title="Close"]').click();
$(selections.dialogCloseButtons).click();
}
......@@ -309,9 +311,29 @@ function queryMinervaApiMainModel(apiSuffix) {
let projectId = minervaProxy.project.data.getProjectId();
let apiBaseUrl = ServerConnector.getApiBaseUrl();
return $.ajax({
type: 'GET',
url: `${apiBaseUrl}projects/${projectId}/models/${mainModelId}/${apiSuffix}`,
dataType: 'json'
return new Promise(function (resolve, reject) {
var xhttp = new XMLHttpRequest();
xhttp.open("GET", `${apiBaseUrl}projects/${projectId}/models/${mainModelId}/${apiSuffix}`, true);
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// console.log('resolved', this);
resolve(JSON.parse(this.responseText))
}
if (this.status != 200) {
// console.log('rejected', this);
reject(this)
}
};
xhttp.send();
});
// return $.ajax({
// type: 'GET',
// url: `${apiBaseUrl}projects/${projectId}/models/${mainModelId}/${apiSuffix}`,
// dataType: 'json'
// });
}
\ No newline at end of file
const introJs = require('intro.js');
const selections = {
minervaMap: '.minerva-map'
, showOverviewButton: '.minerva-overview-button'
, overview: '.ui-dialog:has("img")' // TODO this needs to be changed for something specific
, overviewImg: '.ui-dialog img'
, closeOverview: '.ui-dialog button[title="Close"]' // TODO this actually selects cloe button of all dialogs
, leftPanel: '.minerva-left-panel'
, centerMapLink: '[title="center map"]'
, genericSearchInput: '.minerva-generic-search-panel input[name="searchInput"]'
, genericSearchLink: '.minerva-generic-search-panel a:has("img")'
, clearButton: 'button[name="clearButton"]'
};
const selections = require('./selections');
const synapseImgCoords = [[4960,1971],[5241,1971],[5241,2163],[4960,2163]];
const toMapImgCoords = [[5188,107], [5536,107 ],[5536,245], [5188,245]];
......
module.exports = {
minervaApp: '#minervaAppDiv'
, minervaMap: '.minerva-map'
, mapCanvas: '.minerva-map canvas'
, clearButton: 'button[name="clearButton"]'
, dialogs: 'div[role="dialog"]'
, pathwaysOverlayCheckbox: 'table[name="generalOverlaysTab"] td:contains("Pathways")'
, leftMenuInputs: 'table[name="generalOverlaysTab"] input'
, genericTab: 'div[name="tabView"]:contains("SEARCH") .nav:has(i.fa-search) a'
, genericSearchTab: 'a:contains("GENERIC")'
, dialogCloseButtons: '.ui-dialog button[title="Close"]'
, topCheckBoxes: '.minerva-top-checkbox-div input[type="checkbox"]'
, showOverviewButton: '.minerva-overview-button'
, overview: '.ui-dialog:has("img")' // TODO this needs to be changed for something specific
, overviewImg: '.ui-dialog img'
, closeOverview: '.ui-dialog button[title="Close"]' // TODO this actually selects cloe button of all dialogs
, leftPanel: '.minerva-left-panel'
, centerMapLink: '[title="center map"]'
, genericSearchInput: '.minerva-generic-search-panel input[name="searchInput"], #panel_tab_1 input[name="searchInput"]'
, genericSearchLink: '.minerva-generic-search-panel a:has("img"), #panel_tab_1 a:has("img")'
, molArt: '.minerva-molart-container .pv-inner-container'
, molArtCloseButton: '.minerva-molart-close-button'
, contextMenu: '.dropdown-menu[name="contextMenu"]'
, contextMenuMolArt: 'a:contains("MolArt")'
, prknMolArtLink: 'a:contains("O60260")'
, introJsFloatingDiv: '.introjs-tooltip.introjs-floating'
, drugTabLink: 'a:contains("DRUG")'
, drugTabSearchPanel: '.minerva-drug-panel .searchPanel, #panel_tab_2 .searchPanel'
, drugTabInput: '.minerva-drug-panel input.tt-input, #panel_tab_2 input.tt-input'
, drugTabSearchLink: '.minerva-drug-panel div[name="searchQuery"] a, #panel_tab_2 div[name="searchQuery"] a'
,leftMenuHideButton: '.minerva-header-hide-button'
,introJsDisableInteractions: 'introjs-disableInteraction'
};
......@@ -3,19 +3,7 @@ const introJs = require('intro.js');
let prknCoords = undefined;
const zoomLevel = 9;
const selections = {
minervaApp: '#minervaAppDiv'
, minervaMap: '.minerva-map'
, molArt: '.minerva-molart-container .pv-inner-container'
, molArtCloseButton: '.minerva-molart-close-button'
, clearButton: 'button[name="clearButton"]'
, mapCanvas: '.minerva-map canvas'
, contextMenu: '.dropdown-menu[name="contextMenu"]'
, contextMenuMolArt: 'a:contains("MolArt")'
, prknMolArtLink: 'a:contains("O60260")'
, centerMapLink: '[title="center map"]'
, introJsFloatingDiv: '.introjs-tooltip.introjs-floating'
};
const selections = require('./selections');
function getPrknCoordinates(params){
let compartmentId = undefined;
......@@ -38,7 +26,7 @@ function getPrknCoordinates(params){
prknCoords = [c.x, c.y];
}
})
});
}, error=>{console.error(error)});
}
const initializeStory = function(params) {
......@@ -138,7 +126,7 @@ function initializeStoryContet($introContainer, params){
//TODO remove setTimeout
setTimeout(function() {
$(selections.contextMenuMolArt).parent().find('ul').css('display', 'block')
}, 100);
}, 150);
}
if (steps.indexOf(3) >= 0) {
$(selections.prknMolArtLink).click();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment