diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..4c8e77f73dc9ab17d7d6cec19defa40c7f5d9f30 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,12 @@ +image: node + +before_script: + - cd frontend-js + - npm install + - cd .. + +test_frontend: + script: + - cd frontend-js + - npm test + \ No newline at end of file diff --git a/CHANGELOG b/CHANGELOG index c2676d95aba4ed7e0ebf37528b679ace16e4272e..1eb8ddc1b403c90693a938fee296419777858e4b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,26 @@ +minerva (11.0.1) stable; urgency=medium + * Bug fix: logout caused issues with session data + + -- Piotr Gawron <piotr.gawron@uni.lu> Fri, 08 Sep 2017 12:00:00 +0200 + minerva (11.0.0) stable; urgency=medium + * Bug fix: security issue - access to specific map can be restricted + by the userlogin + * Bug fix: sbgn import + * Bug fix: mesh connector + * Rest API (documentation can be found here: + https://git-r3lab.uni.lu/piotr.gawron/minerva/blob/master/README.md) + * Selecting an element on the map shows info about it in the bottom left + corner (when Search tab is not open) + * Upload of data overlays allows to upload just names of the proteins + (or other elements), it can be done via file or just by typing in the + proper text box + * Layout changes: the main one is that there are only 3 tab panels + (search, overlay, info), so it should be easier to navigate + + -- Piotr Gawron <piotr.gawron@uni.lu> Mon, 28 Aug 2017 12:00:00 +0200 + minerva (10.0.5) stable; urgency=medium * Bug fix: interacting drugs can be found for RNAs diff --git a/README.md b/README.md index c8bb6d65f4fc5cbd20d1234135c1e1d56efa5339..1c4a3a4035e872ea0c8f7505b3bbc12d039678ff 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[](https://git-r3lab.uni.lu/piotr.gawron/minerva/commits/207-continous-integration-tests) + # Rest API (version 11) ## Introduction diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java index dde647a3bf294e8e2aaeeb1e3744ae451ee458c8..6703789f93909815b9ead7e506c659265d2b3e7e 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotator.java @@ -19,9 +19,9 @@ import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Species; /** - * Interface that allows to annotate {@link BioEntity elements} in the - * system. Different implementation use different resources to perform - * annotation. They can annotate different types of elements. + * Interface that allows to annotate {@link BioEntity elements} in the system. + * Different implementation use different resources to perform annotation. They + * can annotate different types of elements. * * @author Piotr Gawron * @@ -31,7 +31,7 @@ public abstract class ElementAnnotator extends CachableInterface { /** * Default class logger. */ - private final Logger logger = Logger.getLogger(ElementAnnotator.class); + private final Logger logger = Logger.getLogger(ElementAnnotator.class); /** * List of classes that can be annotated by this {@link IElementAnnotator @@ -42,7 +42,7 @@ public abstract class ElementAnnotator extends CachableInterface { /** * Should be this annotator used as a default annotatior. */ - private boolean isDefault = false; + private boolean isDefault = false; /** * Default constructor. @@ -61,8 +61,7 @@ public abstract class ElementAnnotator extends CachableInterface { if (BioEntity.class.isAssignableFrom(validClass)) { addValidClass((Class<? extends BioEntity>) validClass); } else { - throw new InvalidArgumentException( - "Cannot pass class of type: " + validClass + ". Only classes extending " + BioEntity.class + " are accepted."); + throw new InvalidArgumentException("Cannot pass class of type: " + validClass + ". Only classes extending " + BioEntity.class + " are accepted."); } } this.isDefault = isDefault; @@ -193,7 +192,7 @@ public abstract class ElementAnnotator extends CachableInterface { List<String> sortedSynonyms = new ArrayList<>(); sortedSynonyms.addAll(synonyms); Collections.sort(sortedSynonyms); - + element.setSynonyms(sortedSynonyms); } else { logger.warn(prefix + "Synonyms don't match: \"" + synonyms + "\", \"" + element.getSynonyms() + "\""); @@ -227,10 +226,12 @@ public abstract class ElementAnnotator extends CachableInterface { * value to set */ protected void setDescription(BioEntity element, String description) { - if (element.getNotes() == null || element.getNotes().equals("") || element.getNotes().equals(description)) { - element.setNotes(description); - } else if (!element.getNotes().toLowerCase().contains(description.toLowerCase())) { - element.setNotes(element.getNotes() + "\n" + description); + if (description != null) { + if (element.getNotes() == null || element.getNotes().equals("") || element.getNotes().equals(description)) { + element.setNotes(description); + } else if (!element.getNotes().toLowerCase().contains(description.toLowerCase())) { + element.setNotes(element.getNotes() + "\n" + description); + } } } diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java index 4ac8160718ce1fe15a0f85b6cabbaed1ee1351f7..27cd669cc89e4ef80fd72248a15226dfb7a12941 100644 --- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java +++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/annotators/EnsemblAnnotator.java @@ -41,7 +41,7 @@ public class EnsemblAnnotator extends ElementAnnotator implements IExternalServi /** * Version of the rest API that is supported by this annotator. */ - static final String SUPPORTED_VERSION = "6.0"; + static final String SUPPORTED_VERSION = "6.1"; /** * Url address of ensembl restfull service. diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java index b68e455da37eb7e0b00243a6afc9858cfb3ea534..98ad19ad4dc01856566b7fefaa0ad30befe659ba 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/DrugbankHTMLParserTest.java @@ -92,7 +92,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { } @Test - public void test3FindDrug() throws Exception { + public void testFindRapamycin() throws Exception { try { // finding synonym Drug rapamycinDrug = drugBankHTMLParser.findDrug("Rapamycin"); @@ -100,8 +100,7 @@ public class DrugbankHTMLParserTest extends AnnotationTestFunctions { assertEquals("Sirolimus", rapamycinDrug.getName()); assertEquals("DB00877", rapamycinDrug.getSources().get(0).getResource()); assertTrue(rapamycinDrug.getBloodBrainBarrier().equalsIgnoreCase("NO")); - boolean res = rapamycinDrug.getDescription().contains( - "A macrolide compound obtained from Streptomyces hygroscopicus that acts by selectively blocking the transcriptional activation of cytokines thereby inhibiting cytokine production. It is bioactive only when bound to immunophilins. Sirolimus is a potent immunosuppressant and possesses both antifungal and antineoplastic properties. [PubChem]"); + boolean res = rapamycinDrug.getDescription().contains("A macrolide compound obtained from Streptomyces"); assertTrue(res); assertEquals(3, rapamycinDrug.getTargets().size()); diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java index a02974da7d865847f035cc1e0541374f4a667b8d..1dac8112d686798431180401071b4f4eb5eefaf0 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/annotators/ElementAnnotatorTest.java @@ -85,6 +85,14 @@ public class ElementAnnotatorTest extends AnnotationTestFunctions { assertEquals(0, getWarnings().size()); } + @Test + public void testSetEmptyDescription() { + GenericProtein species = new GenericProtein("id"); + species.setNotes("X"); + annotator.setDescription(species, null); + assertEquals("X", species.getNotes()); + } + @Test public void testSetNotMatchingIchi() { Ion species = new Ion("id"); diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java index 13aac7e4274322704c0f9a06b4f4c245a59a844d..af923b647b8791a013b4a3e7c532d40c9e38c870 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/ConverterTest.java @@ -1,9 +1,17 @@ package lcsb.mapviewer.converter.graphics; import java.awt.Color; +import java.awt.Desktop; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import lcsb.mapviewer.commands.ColorExtractor; @@ -37,4 +45,42 @@ public class ConverterTest { } } + @Test + @Ignore("it's just code for generating scale") + public void testX() throws IOException { + BufferedImage tmpBI = new BufferedImage(900, 100, BufferedImage.TYPE_INT_ARGB); + Graphics2D tmpGraphics = tmpBI.createGraphics(); + int startX = 10; + int startY = 15; + int stepSize = 40; + int height = 25; + tmpGraphics.setColor(Color.BLACK); + for (int i = 0; i < 21; i++) { + tmpGraphics.drawLine(startX + i * stepSize, height+startY, startX + i * stepSize, height*2); + String str = ""+((double)(i-10))/((double)(10)); + tmpGraphics.drawString(str, startX + i * stepSize, height*2+startY); + } + for (int i = 0; i < 10 * stepSize; i++) { + double ratio = ((double) i) / ((double) (10 * stepSize)); + tmpGraphics.setBackground(getColor(ratio, Color.BLUE, Color.WHITE)); + tmpGraphics.setColor(getColor(ratio, Color.BLUE, Color.WHITE)); + tmpGraphics.drawRect(startX + i, startY , 1, height); + } + for (int i = 0; i < 10 * stepSize; i++) { + double ratio = ((double) i) / ((double) (10 * stepSize)); + tmpGraphics.setBackground(getColor(ratio, Color.WHITE, Color.RED)); + tmpGraphics.setColor(getColor(ratio, Color.WHITE, Color.RED)); + tmpGraphics.drawRect(10 * stepSize + startX + i, startY , 1, height); + } + ImageIO.write(tmpBI, "PNG", new File("tmp.png")); + Desktop.getDesktop().open(new File("tmp.png")); + } + + private Color getColor(double d, Color startColor, Color endColor) { + + return new Color((int) (startColor.getRed() + d * (endColor.getRed() - startColor.getRed())), // + (int) (startColor.getGreen() + d * (endColor.getGreen() - startColor.getGreen())), // + (int) (startColor.getBlue() + d * (endColor.getBlue() - startColor.getBlue()))); + } + } diff --git a/debian/create-debian-pkg.sh b/debian/create-debian-pkg.sh index f390d7a4080cc8f5a1a37433c3bbfd97d6f5a930..1a6936e6fc9fa7c2cd17bd88b313eb2a8acc7a19 100755 --- a/debian/create-debian-pkg.sh +++ b/debian/create-debian-pkg.sh @@ -49,6 +49,8 @@ gzip $SRC_DIR/minerva.txt #copy configuration of logrotate cp debian/logrotate/* $SRC_DIR/ +cp debian/scripts/common.sh $SRC_DIR/ + #copy changelog file cp CHANGELOG $ROOT_DIR/debian/template/changelog @@ -150,22 +152,17 @@ find -name '*.ex' ! -name 'minerva*' -type f -exec rm -f {} + #our pre/post inst/rm scripts use __CURRENT_VERSION__ as a version of currently #installed package -sed -i "s/__CURRENT_VERSION__/$current_version/g" debian/preinst -sed -i "s/__CURRENT_VERSION__/$current_version/g" debian/postinst -sed -i "s/__CURRENT_VERSION__/$current_version/g" debian/prerm -sed -i "s/__CURRENT_VERSION__/$current_version/g" debian/postrm - -sed -i "s/__LOG_FILE__/$LOG_FILE/g" debian/preinst -sed -i "s/__LOG_FILE__/$LOG_FILE/g" debian/postinst -sed -i "s/__LOG_FILE__/$LOG_FILE/g" debian/prerm -sed -i "s/__LOG_FILE__/$LOG_FILE/g" debian/postrm +sed -i "s/__CURRENT_VERSION__/$current_version/g" common.sh +sed -i "s/__LOG_FILE__/$LOG_FILE/g" common.sh #__DB_SCRIPT_DIR__ in our scripts points to place where db schema files are placed #in the filesystem where package is installed -sed -i "s/__DB_SCRIPT_DIR__/$DB_SCRIPT_DIR/g" debian/postinst -sed -i "s/__DB_SCRIPT_DIR__/$DB_SCRIPT_DIR/g" debian/postrm -sed -i "s/__DB_SCRIPT_DIR__/$DB_SCRIPT_DIR/g" debian/prerm -sed -i "s/__DB_SCRIPT_DIR__/$DB_SCRIPT_DIR/g" debian/preinst +sed -i "s/__DB_SCRIPT_DIR__/$DB_SCRIPT_DIR/g" common.sh + +sed -i -e "1r common.sh" debian/postinst +sed -i -e "1r common.sh" debian/postrm +sed -i -e "1r common.sh" debian/preinst +sed -i -e "1r common.sh" debian/prerm #put scripts into $DB_SCRIPT_DIR (it's a bit different than varaiable because it's not #escaped diff --git a/debian/scripts/common.sh b/debian/scripts/common.sh new file mode 100644 index 0000000000000000000000000000000000000000..246724cb9444cdf4d2c503fe804ab3d973ffa338 --- /dev/null +++ b/debian/scripts/common.sh @@ -0,0 +1,29 @@ +#file with common script functions for postrm/prerm/postinst/preinst +log(){ + echo "[" $CURRENT_VERSION "]" "$@" >>__LOG_FILE__ +} +LOG_FILE="__LOG_FILE__" + +DB_SCRIPT_DIR="__DB_SCRIPT_DIR__" + +#new (current) version of the package +CURRENT_VERSION="__CURRENT_VERSION__" +#if we update package then this will be the old version of the package +OLD_VERSION=$2 + +if [ "$OLD_VERSION" = "$CURRENT_VERSION" ] +then + OLD_VERSION=""; +fi + +TOMCAT_PACKAGE=""; +TOMCAT7_OK=$(dpkg-query -W --showformat='${Status}\n' tomcat7|grep "install ok installed") +TOMCAT8_OK=$(dpkg-query -W --showformat='${Status}\n' tomcat8|grep "install ok installed") +if [ "$TOMCAT7_OK" != "" ]; +then + TOMCAT_PACKAGE='tomcat7' +fi +if [ "$TOMCAT8_OK" != "" ]; +then + TOMCAT_PACKAGE='tomcat8' +fi diff --git a/debian/template/control b/debian/template/control index 25913b4c153d4c4f53324c1e96d205742ce30b35..dcb5946ab20574544cfcc59508f78714bc39af25 100644 --- a/debian/template/control +++ b/debian/template/control @@ -13,4 +13,4 @@ Description: Standalone web application for visualization, exploration and Tomcat server later to change the address. Section: science Homepage: http://r3lab.uni.lu/web/minerva-website/ -Depends: ${misc:Depends}, tomcat7, oracle-java8-set-default, postgresql (>=9.3) +Depends: ${misc:Depends}, tomcat7 | tomcat8, oracle-java8-set-default, postgresql (>=9.3) diff --git a/debian/template/install b/debian/template/install index 493361aaa4fa86ab02bede0f7ff7a1f42c031491..7e81d5fb433700abf97710e8570f13708aa0b5ef 100644 --- a/debian/template/install +++ b/debian/template/install @@ -1 +1 @@ -minerva.war /var/lib/tomcat7/webapps +minerva.war /usr/share/minerva/ diff --git a/debian/template/postinst b/debian/template/postinst index a1b144da74bc63a39bcf6be638790e68c0688b04..44228b77f9db6a5d9d50ee43d4917a886fe73f9e 100644 --- a/debian/template/postinst +++ b/debian/template/postinst @@ -13,28 +13,12 @@ # <conflicting-package> <version> # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package -log(){ - echo "$@" >>__LOG_FILE__ -} log "Running postinst" $1 $2; +invoke-rc.d $TOMCAT_PACKAGE status >> $LOG_FILE # we execute it here because if some packages are missing then dpkg will return non-zero exit code set -e - -#new (current) version of the package -CURRENT_VERSION="__CURRENT_VERSION__" -#if we update package then this will be the old version of the package -OLD_VERSION=$2 - -DB_SCRIPT_DIR="__DB_SCRIPT_DIR__" - -if [ "$OLD_VERSION" = "$CURRENT_VERSION" ] -then - OLD_VERSION=""; -fi - - case "$1" in configure) invoke-rc.d postgresql start @@ -42,9 +26,9 @@ case "$1" in #if we install if [ "$OLD_VERSION" = "" ] then - su - postgres -c "createuser -d -r -s map_viewer" >>__LOG_FILE__ 2>>__LOG_FILE__ - su - postgres -c "echo \"ALTER USER map_viewer WITH PASSWORD '123qweasdzxc';\"| psql" >>__LOG_FILE__ 2>>__LOG_FILE__ - su - postgres -c "createdb -O map_viewer map_viewer" >>__LOG_FILE__ 2>>__LOG_FILE__ + su - postgres -c "createuser -d -r -s map_viewer" >>$LOG_FILE 2>>$LOG_FILE + su - postgres -c "echo \"ALTER USER map_viewer WITH PASSWORD '123qweasdzxc';\"| psql" >>$LOG_FILE 2>>$LOG_FILE + su - postgres -c "createdb -O map_viewer map_viewer" >>$LOG_FILE 2>>$LOG_FILE hba_conf=`su - postgres -c "psql -t -P format=unaligned -c 'show hba_file';"`; cp $hba_conf $hba_conf".bac" @@ -53,13 +37,13 @@ case "$1" in invoke-rc.d postgresql restart #install base version of the framework - su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_0.sql" >>__LOG_FILE__ 2>>__LOG_FILE__ + su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_0.sql" >>$LOG_FILE 2>>$LOG_FILE #install patch to current version - su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_0_to_$CURRENT_VERSION\".sql\"" >>__LOG_FILE__ 2>>__LOG_FILE__ + su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_0_to_$CURRENT_VERSION\".sql\"" >>$LOG_FILE 2>>$LOG_FILE else #if we update the package - su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_$OLD_VERSION\"_to_\"$CURRENT_VERSION\".sql\"" >>__LOG_FILE__ 2>>__LOG_FILE__ + su - postgres -c "psql map_viewer -f $DB_SCRIPT_DIR/db_$OLD_VERSION\"_to_\"$CURRENT_VERSION\".sql\"" >>$LOG_FILE 2>>$LOG_FILE fi #print a disclaimer @@ -78,7 +62,10 @@ case "$1" in #we have to restart tomcat, because application was started on the old database and it might crash during deplyment #for instance in the new war file there was init script that uses some new database features, but they are not #availble when new war is deployed from debian package, so tomcat will catch SQL exception and stop deployment - invoke-rc.d tomcat7 restart + invoke-rc.d $TOMCAT_PACKAGE stop || true + rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva + ln -s /usr/share/minerva/minerva.war /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war + invoke-rc.d $TOMCAT_PACKAGE start ;; *) echo "postinst called with unknown argument \`$1'" >&2 diff --git a/debian/template/postrm b/debian/template/postrm index 1bbb913d1ea531617049d130f6a4fd0d442be495..89144fb629ef34fd3761bc2c749f6cebfcfd4840 100644 --- a/debian/template/postrm +++ b/debian/template/postrm @@ -7,9 +7,6 @@ # * <old-postrm> `upgrade' <new-version> # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package -log(){ - echo "$@" >>__LOG_FILE__ -} log "Running postrm" $1 $2; @@ -27,13 +24,15 @@ set -e case "$1" in upgrade) - rm -rf /var/lib/tomcat7/webapps/minerva - invoke-rc.d tomcat7 start || true - invoke-rc.d postgresql start || true + rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva + rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war +# invoke-rc.d $TOMCAT_PACKAGE start || true +# invoke-rc.d postgresql start || true ;; remove) - rm -rf /var/lib/tomcat7/webapps/minerva - invoke-rc.d tomcat7 start || true + rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva + rm -rf /var/lib/$TOMCAT_PACKAGE/webapps/minerva.war + invoke-rc.d $TOMCAT_PACKAGE start || true if [ "" = "$POSTGRES_OK" ] then log "No postgresql package found."; @@ -44,7 +43,7 @@ case "$1" in fi ;; abort-install) - invoke-rc.d tomcat7 start || true + invoke-rc.d $TOMCAT_PACKAGE start || true if [ "" = "$POSTGRES_OK" ]; then diff --git a/debian/template/preinst b/debian/template/preinst index 1abc655eb13bdd0e7687c11f932d13629824dd1d..c6ad957eb6803a810a043143bf5845e16a3017ef 100644 --- a/debian/template/preinst +++ b/debian/template/preinst @@ -9,11 +9,6 @@ # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package - -log(){ - echo "$@" >>__LOG_FILE__ -} - log "Running preinst" $1 $2; # we execute it here because if some packages are missing then dpkg will return non-zero exit code @@ -29,11 +24,11 @@ ln -s $path $DEFAULT_JAVA_SYMLINK case "$1" in install|upgrade) - invoke-rc.d tomcat7 stop || true + invoke-rc.d $TOMCAT_PACKAGE stop || true invoke-rc.d postgresql stop || true ;; abort-upgrade) - invoke-rc.d tomcat7 stop || true + invoke-rc.d $TOMCAT_PACKAGE stop || true invoke-rc.d postgresql stop || true ;; *) diff --git a/debian/template/prerm b/debian/template/prerm index d6c80c445fb07e3c6621618992daf9ed789f71b0..c43b60f8fa2c3f996db03de69cc8b7e261d9220e 100644 --- a/debian/template/prerm +++ b/debian/template/prerm @@ -8,14 +8,9 @@ set -e # * <new-preinst> `upgrade' <old-version> # for details, see http://www.debian.org/doc/debian-policy/ or # the debian-policy package -log(){ - echo "$@" >>__LOG_FILE__ -} log "Running preinst" $1 $2; -DB_SCRIPT_DIR="__DB_SCRIPT_DIR__" - # we execute it here because if some packages are missing then dpkg will return non-zero exit code set -e @@ -30,11 +25,11 @@ su - postgres -c "pg_dump map_viewer" | gzip > "$DUMP_FILE".gz case "$1" in upgrade) - invoke-rc.d tomcat7 stop || true + invoke-rc.d $TOMCAT_PACKAGE stop || true invoke-rc.d postgresql stop || true ;; remove) - invoke-rc.d tomcat7 stop || true + invoke-rc.d $TOMCAT_PACKAGE stop || true invoke-rc.d postgresql stop || true ;; *) diff --git a/frontend-js/.gitignore b/frontend-js/.gitignore index 23ccee19c2ced758953730bdbcbebf2b33922f62..6e21c03544a53f12f08700ccbb114dfbebe1e590 100644 --- a/frontend-js/.gitignore +++ b/frontend-js/.gitignore @@ -1,3 +1,4 @@ +.idea/workspace.xml /dist/ /coverage/ /node_modules/ diff --git a/frontend-js/.idea/dictionaries/piotr_gawron.xml b/frontend-js/.idea/dictionaries/piotr_gawron.xml new file mode 100644 index 0000000000000000000000000000000000000000..6a8c909a47f60a556bc261805af778533e72b7eb --- /dev/null +++ b/frontend-js/.idea/dictionaries/piotr_gawron.xml @@ -0,0 +1,7 @@ +<component name="ProjectDictionaryState"> + <dictionary name="piotr.gawron"> + <words> + <w>mailto</w> + </words> + </dictionary> +</component> \ No newline at end of file diff --git a/frontend-js/.idea/frontend-js.iml b/frontend-js/.idea/frontend-js.iml new file mode 100644 index 0000000000000000000000000000000000000000..69ef67a424b4d72230aac1a2e4ddc77c7a75b52b --- /dev/null +++ b/frontend-js/.idea/frontend-js.iml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="WEB_MODULE" version="4"> + <component name="NewModuleRootManager"> + <content url="file://$MODULE_DIR$"> + <excludeFolder url="file://$MODULE_DIR$/.tmp" /> + <excludeFolder url="file://$MODULE_DIR$/dist" /> + <excludeFolder url="file://$MODULE_DIR$/temp" /> + <excludeFolder url="file://$MODULE_DIR$/tmp" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/frontend-js/.idea/modules.xml b/frontend-js/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..45e3bd378c0fc59f695ea33bf88ea0ebcc9a62e4 --- /dev/null +++ b/frontend-js/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/frontend-js.iml" filepath="$PROJECT_DIR$/.idea/frontend-js.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/frontend-js/.idea/preferred-vcs.xml b/frontend-js/.idea/preferred-vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..848cfc44550cbfba31b047a54bb77ecd25feb0c7 --- /dev/null +++ b/frontend-js/.idea/preferred-vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="PreferredVcsStorage"> + <preferredVcsName>ApexVCS</preferredVcsName> + </component> +</project> \ No newline at end of file diff --git a/frontend-js/.idea/vcs.xml b/frontend-js/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc --- /dev/null +++ b/frontend-js/.idea/vcs.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="VcsDirectoryMappings"> + <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> + </component> +</project> \ No newline at end of file diff --git a/frontend-js/package.json b/frontend-js/package.json index 5fb54350658b7055fa7bba9c60112f64877eeed0..a421f03d02033e2d2348c13b8cb5eb863099b9b1 100644 --- a/frontend-js/package.json +++ b/frontend-js/package.json @@ -38,9 +38,11 @@ "dependencies": { "dual-listbox": "^1.0.7", "file-saver": "^1.3.3", + "del": "^3.0.0", "http-status-codes": "^1.1.6", "js-cookie": "^2.1.3", "log4js": "0.6.38", + "mkdirp": "^0.5.1", "pileup": "^0.6.8", "request": "^2.79.0" } diff --git a/frontend-js/scripts/clean.js b/frontend-js/scripts/clean.js new file mode 100644 index 0000000000000000000000000000000000000000..1822779c31f651f8caa6538c5138f32fd1f666cc --- /dev/null +++ b/frontend-js/scripts/clean.js @@ -0,0 +1,15 @@ +var del = require('del'); +var mkdirp = require('mkdirp'); + + +var exec = require('child_process').exec; +function puts(error, stdout, stderr) { console.log(stdout) } + + +var os = require('os'); +//control OS +//then run command depengin on the OS + +del(["dist/"]).then(function(){ + return mkdirp("dist"); +}); diff --git a/frontend-js/src/main/js/ConfigurationType.js b/frontend-js/src/main/js/ConfigurationType.js index aa792f821a083b1e4dfbb66bbb720ca43a89ff2f..ca7078fe5cc21ffc87eaba1dd3516153ea8dd8b7 100644 --- a/frontend-js/src/main/js/ConfigurationType.js +++ b/frontend-js/src/main/js/ConfigurationType.js @@ -1,16 +1,17 @@ "use strict"; var ConfigurationType = { - DEFAULT_MAP : "DEFAULT_MAP", - GOOGLE_ANALYTICS_IDENTIFIER : "GOOGLE_ANALYTICS_IDENTIFIER", - LOGO_IMG : "LOGO_IMG", - LOGO_LINK : "LOGO_LINK", - LEGEND_FILES : "LEGEND_FILES", - MIN_COLOR_VAL : "MIN_COLOR_VAL", - MAX_COLOR_VAL : "MAX_COLOR_VAL", - SIMPLE_COLOR_VAL : "SIMPLE_COLOR_VAL", - SEARCH_DISTANCE : "SEARCH_DISTANCE", - USER_MANUAL_FILE : "USER_MANUAL_FILE", + DEFAULT_MAP: "DEFAULT_MAP", + GOOGLE_ANALYTICS_IDENTIFIER: "GOOGLE_ANALYTICS_IDENTIFIER", + LOGO_IMG: "LOGO_IMG", + LOGO_LINK: "LOGO_LINK", + LEGEND_FILES: "LEGEND_FILES", + MIN_COLOR_VAL: "MIN_COLOR_VAL", + MAX_COLOR_VAL: "MAX_COLOR_VAL", + REQUEST_ACCOUNT_EMAIL: "REQUEST_ACCOUNT_EMAIL", + SIMPLE_COLOR_VAL: "SIMPLE_COLOR_VAL", + SEARCH_DISTANCE: "SEARCH_DISTANCE", + USER_MANUAL_FILE: "USER_MANUAL_FILE", }; module.exports = ConfigurationType; diff --git a/frontend-js/src/main/js/GuiConnector.js b/frontend-js/src/main/js/GuiConnector.js index 1cc63b91534a7f15b475de1e1914287bd1333bb9..f377b8ab177acafc302e15041874d6fd2ad2ba42 100644 --- a/frontend-js/src/main/js/GuiConnector.js +++ b/frontend-js/src/main/js/GuiConnector.js @@ -5,6 +5,7 @@ var logger = require('./logger'); var Functions = require('./Functions'); var SecurityError = require('./SecurityError'); var GuiMessageError = require('./gui/GuiMessageError'); +var NetworkError = require('./NetworkError'); /** * This static global object contains set of functions that returns/set data in @@ -26,11 +27,11 @@ GuiConnector.yPos = 0; * List of GET params passed via url. */ -GuiConnector.init = function() { +GuiConnector.init = function () { var self = this; if (!String.prototype.endsWith) { - String.prototype.endsWith = function(pattern) { + String.prototype.endsWith = function (pattern) { var d = this.length - pattern.length; return d >= 0 && this.lastIndexOf(pattern) === d; }; @@ -41,7 +42,7 @@ GuiConnector.init = function() { alert("This webpage works well with Chrome, Firefox and Safari."); } // bootstrap tab initialization - $("ul.nav-tabs a").click(function(e) { + $("ul.nav-tabs a").click(function (e) { e.preventDefault(); $(this).tab('show'); }); @@ -49,16 +50,17 @@ GuiConnector.init = function() { self.getParams = []; // find GuiConnector.getParams - window.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function() { + window.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () { function decode(s) { return decodeURIComponent(s.split("+").join(" ")); } + GuiConnector.getParams[decode(arguments[1])] = decode(arguments[2]); }); // forser browser to update mouse coordinates whenever mouse move - jQuery(document).ready(function() { - $(document).mousemove(function(e) { + jQuery(document).ready(function () { + $(document).mousemove(function (e) { GuiConnector.updateMouseCoordinates(e.pageX, e.pageY); }); }); @@ -70,7 +72,7 @@ GuiConnector.init = function() { self.addWindowResizeEvent(window.onresize); } - window.onresize = function() { + window.onresize = function () { for (var i = 0; i < self._windowResizeEvents.length; i++) { self._windowResizeEvents[i](); } @@ -78,18 +80,18 @@ GuiConnector.init = function() { } }; -GuiConnector.addWindowResizeEvent = function(handler) { +GuiConnector.addWindowResizeEvent = function (handler) { this._windowResizeEvents.push(handler); }; /** * Returns name of the file with LCSB logo. - * + * * @param bigLogo * {@link Boolean} value determining if we want to have big logo or * small one */ -GuiConnector.getLcsbLogoImg = function(bigLogo) { +GuiConnector.getLcsbLogoImg = function (bigLogo) { if (bigLogo) { return 'lcsb_logo_mid.png'; } else { @@ -101,26 +103,26 @@ GuiConnector.getLcsbLogoImg = function(bigLogo) { * Returns name of the file with image that should be presented when we are * wainting for data to be loaded. */ -GuiConnector.getLoadingImg = function() { +GuiConnector.getLoadingImg = function () { return "icons/ajax-loader.gif"; }; /** * Returns home directory for images in the application. */ -GuiConnector.getImgPrefix = function() { +GuiConnector.getImgPrefix = function () { return "resources/images/"; }; /** * Updates coordinates of the mouse in the browser. */ -GuiConnector.updateMouseCoordinates = function(x, y) { +GuiConnector.updateMouseCoordinates = function (x, y) { this.xPos = x; this.yPos = y; }; -GuiConnector.showProcessing = function(messageText) { +GuiConnector.showProcessing = function (messageText) { var self = GuiConnector; if (self._processingDialog === undefined) { self._processingDialog = document.createElement("div"); @@ -139,8 +141,8 @@ GuiConnector.showProcessing = function(messageText) { messageText = "PROCESSING"; } var messageImg = Functions.createElement({ - type : "img", - src : 'resources/images/icons/ajax-loader.gif', + type: "img", + src: 'resources/images/icons/ajax-loader.gif', }); self._processingDialogContent.innerHTML = ""; self._processingDialogContent.style.textAlign = "center"; @@ -151,12 +153,12 @@ GuiConnector.showProcessing = function(messageText) { $(self._processingDialog).dialog("open"); }; -GuiConnector.hideProcessing = function() { +GuiConnector.hideProcessing = function () { var self = GuiConnector; $(self._processingDialog).dialog("close"); }; -GuiConnector.alert = function(error) { +GuiConnector.alert = function (error) { var self = GuiConnector; logger.error(error); if (self._errorDialog === undefined) { @@ -165,20 +167,22 @@ GuiConnector.alert = function(error) { self._errorDialog.appendChild(self._errorDialogContent); document.body.appendChild(self._errorDialog); $(self._errorDialog).dialog({ - classes : { - "ui-dialog" : "ui-state-error" + classes: { + "ui-dialog": "ui-state-error" }, - modal : true, - title : "ERROR" + modal: true, + title: "ERROR" }).siblings('.ui-dialog-titlebar').css("background", "red"); } var message = error; if (message instanceof SecurityError) { - message = error.message + "<p>Please <a href=\"login.xhtml\">login</a> to access this resuorce</p>"; + message = error.message + "<p>Please <a href=\"login.xhtml\">login</a> to access this resource</p>"; + } else if (message instanceof NetworkError && (error.message === "XHR error" || error.message === "Failed to fetch")) { + message = "File to big.<br>Please reduce file size or contact administrators."; } else if (message instanceof GuiMessageError) { - message = error.message; + message = error.message; } else if (message instanceof Error) { - message = "Unexpected error occured:<p>" + error.message + "</p>"; + message = "Unexpected error occurred:<p>" + error.message + "</p>"; } self._errorDialogContent.innerHTML = message; $(self._errorDialog).dialog("open"); diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index 9b45634d588b0fe75d92495999b9f4a9535f4aba..535e6776cdfcd8bd004021fa94a09653dbe939cc 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -83,7 +83,7 @@ ServerConnector.returnUserOrSystemColor = function(userColor, systemPromisedColo }); }; -ServerConnector.getSimpleOverlayColorInt = function() { +ServerConnector.getSimpleOverlayColorInt = function () { var self = this; return self.getLoggedUser().then(function(user) { var userColor = user.getSimpleColor(); @@ -91,7 +91,7 @@ ServerConnector.getSimpleOverlayColorInt = function() { }); }; -ServerConnector.getMaxOverlayColorInt = function() { +ServerConnector.getMaxOverlayColorInt = function () { var self = this; return self.getLoggedUser().then(function(user) { var userColor = user.getMaxColor(); @@ -127,11 +127,11 @@ ServerConnector.sendRequest = function(params) { }).then(function(result) { content = result; return self.callListeners("onDataLoadStop", description); - }, function(error) { - return self.callListeners("onDataLoadStop", description).then(function() { + }, function (error) { + return self.callListeners("onDataLoadStop", description).then(function () { return Promise.reject(error); }); - }).then(function() { + }).then(function () { return content; }); @@ -141,7 +141,10 @@ ServerConnector._sendRequest = function(params) { return new Promise(function(resolve, reject) { request(params, function(error, response, body) { if (error) { - reject(error); + reject(new NetworkError(error.message, { + content: body, + url: url + })); } else if (response.statusCode !== 200) { reject(new NetworkError(params.url + " rejected with status code: " + response.statusCode, { content : body, @@ -187,17 +190,15 @@ ServerConnector.sendPatchRequest = function(url, json) { ServerConnector.getToken = function() { var self = this; - + var login = self.getSessionData(null).getLogin() var token = self.getSessionData(null).getToken(); - if (token === undefined) { + if (token === undefined || login === undefined) { return self.login(); } else { // if the project is not initialized then check if we can download data // using current token if (self.getSessionData().getProject() === null) { - return self.getConfiguration({ - token : token - }).then(function() { + return self.getConfiguration().then(function () { return token; // if there was an error accessing configuration it means our token is // invalid @@ -210,11 +211,11 @@ ServerConnector.getToken = function() { } }; -ServerConnector.getApiBaseUrl = function() { +ServerConnector.getApiBaseUrl = function () { return this.getServerBaseUrl() + "/api/"; }; -ServerConnector.getServerBaseUrl = function() { +ServerConnector.getServerBaseUrl = function () { if (this._serverBaseUrl === undefined) { var url = "" + window.location.href; if (!url.endsWith("/")) { @@ -225,7 +226,7 @@ ServerConnector.getServerBaseUrl = function() { return this._serverBaseUrl; }; -ServerConnector.createGetParams = function(params, prefix) { +ServerConnector.createGetParams = function (params, prefix) { var sorted = [], key; for (key in params) { @@ -261,7 +262,7 @@ ServerConnector.createGetParams = function(params, prefix) { return result; }; -ServerConnector.getApiUrl = function(paramObj) { +ServerConnector.getApiUrl = function (paramObj) { var type = paramObj.type; var method = paramObj.method; var params = this.createGetParams(paramObj.params); @@ -279,7 +280,7 @@ ServerConnector.getApiUrl = function(paramObj) { return result; }; -ServerConnector.getProjectsUrl = function(queryParams, filterParams) { +ServerConnector.getProjectsUrl = function (queryParams, filterParams) { return this.getApiUrl({ type : "projects/", params : filterParams, @@ -294,67 +295,73 @@ ServerConnector.getProjectUrl = function(queryParams, filterParams) { }); }; -ServerConnector.getProjectStatisticsUrl = function(queryParams, filterParams) { +ServerConnector.getProjectStatisticsUrl = function (queryParams, filterParams) { return this.getApiUrl({ url : this.getProjectUrl(queryParams) + "statistics/", params : filterParams, }); }; -ServerConnector.getPublicationsUrl = function(queryParams, filterParams) { +ServerConnector.getPublicationsUrl = function (queryParams, filterParams) { filterParams.start = filterParams.start || 0; filterParams.length = filterParams.length || 10; return this.getApiUrl({ - url : this.getModelsUrl(queryParams) + "publications/", - params : filterParams, + url: this.getModelsUrl(queryParams) + "publications/", + params: filterParams, }); }; -ServerConnector.getReferenceGenomeUrl = function(queryParams, filterParams) { +ServerConnector.getReferenceGenomeUrl = function (queryParams, filterParams) { var version = this.getIdOrAsterisk(queryParams.version); return this.getApiUrl({ - type : "genomics/taxonomies/" + queryParams.organism + "/genomeTypes/" + queryParams.type + "/versions/" + version - + "/", - params : filterParams + type: "genomics/taxonomies/" + queryParams.organism + "/genomeTypes/" + queryParams.type + "/versions/" + version + + "/", + params: filterParams }); }; -ServerConnector.loginUrl = function() { +ServerConnector.loginUrl = function () { return this.getApiUrl({ - type : "/doLogin", + type: "/doLogin", }); }; -ServerConnector.getSuggestedQueryListUrl = function(queryParams, filterParams) { +ServerConnector.logoutUrl = function () { return this.getApiUrl({ - url : this.getBioEntitiesUrl(queryParams) + "suggestedQueryList/", - params : filterParams, + type: "/doLogout", + }); +}; + +ServerConnector.getSuggestedQueryListUrl = function (queryParams, filterParams) { + return this.getApiUrl({ + url: this.getBioEntitiesUrl(queryParams) + "suggestedQueryList/", + params: filterParams, }); }; -ServerConnector.addCommentUrl = function(queryParams) { +ServerConnector.addCommentUrl = function (queryParams) { return this.getApiUrl({ - url : this.getCommentsUrl(queryParams) + url: this.getCommentsUrl(queryParams) }); }; -ServerConnector.addOverlayUrl = function(queryParams) { +ServerConnector.addOverlayUrl = function (queryParams) { return this.getApiUrl({ - url : this.getOverlaysUrl(queryParams) + url: this.getOverlaysUrl(queryParams) }); }; -ServerConnector.updateOverlayUrl = function(queryParams) { +ServerConnector.updateOverlayUrl = function (queryParams) { return this.getApiUrl({ - url : this.getOverlayByIdUrl(queryParams) + url: this.getOverlayByIdUrl(queryParams) }); }; -ServerConnector.deleteOverlayUrl = function(queryParams) { +ServerConnector.deleteOverlayUrl = function (queryParams) { return this.getApiUrl({ - url : this.getOverlayByIdUrl(queryParams), + url: this.getOverlayByIdUrl(queryParams), }); }; @@ -371,7 +378,7 @@ ServerConnector.getOverlaysUrl = function(queryParams, filterParams) { }); }; -ServerConnector.getCommentsUrl = function(queryParams, filterParams) { +ServerConnector.getCommentsUrl = function (queryParams, filterParams) { var modelId = this.getIdOrAsterisk(queryParams.modelId); var url = this.getProjectUrl(queryParams) + "comments/models/" + modelId + "/"; if (queryParams.elementType !== undefined) { @@ -386,41 +393,41 @@ ServerConnector.getCommentsUrl = function(queryParams, filterParams) { } } return this.getApiUrl({ - url : url, - params : filterParams, + url: url, + params: filterParams, }); }; -ServerConnector.getOverlayByIdUrl = function(queryParams, filterParams) { +ServerConnector.getOverlayByIdUrl = function (queryParams, filterParams) { return this.getApiUrl({ - url : this.getOverlaysUrl(queryParams) + queryParams.overlayId + "/", - params : filterParams, + url: this.getOverlaysUrl(queryParams) + queryParams.overlayId + "/", + params: filterParams, }); }; -ServerConnector.getOverlayElementsUrl = function(queryParams, filterParams) { +ServerConnector.getOverlayElementsUrl = function (queryParams, filterParams) { return this.getApiUrl({ - url : this.getModelsUrl(queryParams) + "bioEntities/", - params : filterParams, + url: this.getModelsUrl(queryParams) + "bioEntities/", + params: filterParams, }); }; -ServerConnector.getFullOverlayElementUrl = function(queryParams, filterParams) { +ServerConnector.getFullOverlayElementUrl = function (queryParams, filterParams) { return this.getApiUrl({ - url : this.getAliasesUrl(queryParams) + queryParams.id + "/", - params : filterParams, + url: this.getAliasesUrl(queryParams) + queryParams.id + "/", + params: filterParams, }); }; -ServerConnector.idsToString = function(ids) { +ServerConnector.idsToString = function (ids) { var result = ""; if (ids !== undefined) { - ids.sort(function(a, b) { + ids.sort(function (a, b) { return a - b; }); for (var i = 0; i < ids.length; i++) { @@ -436,7 +443,7 @@ ServerConnector.idsToString = function(ids) { return result; }; -ServerConnector.pointToString = function(point) { +ServerConnector.pointToString = function (point) { return point.x.toFixed(2) + "," + point.y.toFixed(2); }; @@ -449,17 +456,17 @@ ServerConnector.getModelsUrl = function(queryParams) { } return this.getApiUrl({ - url : url + "models/" + modelId + "/", + url: url + "models/" + modelId + "/", }); }; -ServerConnector.getBioEntitiesUrl = function(queryParams) { +ServerConnector.getBioEntitiesUrl = function (queryParams) { return this.getApiUrl({ - url : this.getModelsUrl(queryParams) + "bioEntities/", + url: this.getModelsUrl(queryParams) + "bioEntities/", }); }; -ServerConnector.getIdOrAsterisk = function(id) { +ServerConnector.getIdOrAsterisk = function (id) { if (id === undefined || id === "" || id === null) { return "*"; } else { @@ -467,81 +474,81 @@ ServerConnector.getIdOrAsterisk = function(id) { } }; -ServerConnector.getReactionsUrl = function(queryParams, filterParams) { +ServerConnector.getReactionsUrl = function (queryParams, filterParams) { return this.getApiUrl({ - url : this.getBioEntitiesUrl(queryParams) + "reactions/", - params : filterParams, + url: this.getBioEntitiesUrl(queryParams) + "reactions/", + params: filterParams, }); }; -ServerConnector.getAliasesUrl = function(queryParams, filterParams) { +ServerConnector.getAliasesUrl = function (queryParams, filterParams) { return this.getApiUrl({ - url : this.getBioEntitiesUrl(queryParams) + "elements/", - params : filterParams, + url: this.getBioEntitiesUrl(queryParams) + "elements/", + params: filterParams, }); }; -ServerConnector.getConfigurationUrl = function(queryParams, filterParams) { +ServerConnector.getConfigurationUrl = function (queryParams, filterParams) { var result = this.getApiUrl({ - type : "configuration/", - params : filterParams + type: "configuration/", + params: filterParams }); return result; }; -ServerConnector.getSearchUrl = function(queryParams, filterParams) { +ServerConnector.getSearchUrl = function (queryParams, filterParams) { return this.getApiUrl({ - url : this.getModelsUrl(queryParams) + "bioEntities:search", - params : filterParams, + url: this.getModelsUrl(queryParams) + "bioEntities:search", + params: filterParams, }); }; -ServerConnector.getSearchDrugsUrl = function(queryParams, filterParams) { +ServerConnector.getSearchDrugsUrl = function (queryParams, filterParams) { return this.getApiUrl({ url : this.getProjectUrl(queryParams) + "drugs:search", params : filterParams, }); }; -ServerConnector.getSearchMiRnasUrl = function(queryParams, filterParams) { +ServerConnector.getSearchMiRnasUrl = function (queryParams, filterParams) { return this.getApiUrl({ url : this.getProjectUrl(queryParams) + "miRnas:search", params : filterParams, }); }; -ServerConnector.getSearchChemicalsUrl = function(queryParams, filterParams) { +ServerConnector.getSearchChemicalsUrl = function (queryParams, filterParams) { return this.getApiUrl({ url : this.getProjectUrl(queryParams) + "chemicals:search", params : filterParams, }); }; -ServerConnector.getOverlaySourceUrl = function(queryParams, filterParams) { +ServerConnector.getOverlaySourceUrl = function (queryParams, filterParams) { return this.getApiUrl({ - url : this.getOverlaysUrl(queryParams) + queryParams.overlayId + ":downloadSource", - params : filterParams + url: this.getOverlaysUrl(queryParams) + queryParams.overlayId + ":downloadSource", + params: filterParams }); }; -ServerConnector.getImageUrl = function(queryParams, filterParams) { +ServerConnector.getImageUrl = function (queryParams, filterParams) { return this.getApiUrl({ url : this.getProjectUrl(queryParams) + "models/" + queryParams.modelId + ":downloadImage", params : filterParams, }); }; -ServerConnector.getModelPartUrl = function(queryParams, filterParams) { +ServerConnector.getModelPartUrl = function (queryParams, filterParams) { return this.getApiUrl({ url : this.getProjectUrl(queryParams) + "models/" + queryParams.modelId + ":downloadModel", params : filterParams, }); }; -ServerConnector.getProjectSourceUrl = function(queryParams, filterParams) { +ServerConnector.getProjectSourceUrl = function (queryParams, filterParams) { return this.getApiUrl({ - type : "projects/" + queryParams.projectId + ":downloadSource", - params : filterParams + type: "projects/" + queryParams.projectId + ":downloadSource", + params: filterParams }); }; @@ -566,10 +573,7 @@ ServerConnector.getUpdateUserPrivilegesUrl = function(queryParams, filterParams) }); }; -ServerConnector.getConfiguration = function(params) { - if (params === undefined) { - params = {}; - } +ServerConnector.getConfiguration = function () { var self = this; if (this._configuration === undefined) { return self.sendGetRequest(self.getConfigurationUrl()).then(function(content) { @@ -581,14 +585,17 @@ ServerConnector.getConfiguration = function(params) { } }; -ServerConnector.getConfigurationParam = function(paramId) { +ServerConnector.getConfigurationParam = function (paramId) { + if (paramId === undefined) { + return Promise.reject(new Error("Unknown param type")); + } var self = this; - return self.getConfiguration().then(function(configuration) { + return self.getConfiguration().then(function (configuration) { return configuration.getOption(paramId); }); }; -ServerConnector.getModels = function(projectId) { +ServerConnector.getModels = function (projectId) { var queryParams = {}; var filterParams = {}; var self = this; @@ -610,7 +617,7 @@ ServerConnector.getProject = function(projectId) { var filterParams = {}; var project; var self = this; - return self.getProjectId(projectId).then(function(result) { + return self.getProjectId(projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getProjectUrl(queryParams, filterParams)); }).then(function(content) { @@ -634,15 +641,15 @@ ServerConnector.getProject = function(projectId) { }).then(function(overlays) { project.getModel().addLayouts(overlays); return project; - }).then(null, function(error) { + }).then(null, function (error) { if ((error instanceof NetworkError)) { switch (error.statusCode) { - case HttpStatus.NOT_FOUND: - return null; - case HttpStatus.FORBIDDEN: - return Promise.reject(new SecurityError("Access denied.")); - default: - return Promise.reject(error); + case HttpStatus.NOT_FOUND: + return null; + case HttpStatus.FORBIDDEN: + return Promise.reject(new SecurityError("Access denied.")); + default: + return Promise.reject(error); } } else { return Promise.reject(error); @@ -731,22 +738,22 @@ ServerConnector.getProjectStatistics = function(projectId) { }); }; -ServerConnector.getLoggedUser = function() { +ServerConnector.getLoggedUser = function () { var self = this; if (self._loggedUser !== undefined) { return Promise.resolve(self._loggedUser); } else { - return self.getUser(self.getSessionData().getLogin()).then(function(user) { + return self.getUser(self.getSessionData().getLogin()).then(function (user) { self._loggedUser = user; return self._loggedUser; }); } }; -ServerConnector.getUser = function(login) { +ServerConnector.getUser = function (login) { var self = this; var queryParams = { - login : login, + login: login, }; var filterParams = {}; @@ -862,17 +869,17 @@ ServerConnector.getOverlayElements = function(overlayId, projectId) { }); }; -ServerConnector.getFullOverlayElement = function(params) { +ServerConnector.getFullOverlayElement = function (params) { var self = this; var queryParams = { - overlayId : params.overlay.getId(), - modelId : params.element.getModelId(), - id : params.element.getId(), + overlayId: params.overlay.getId(), + modelId: params.element.getModelId(), + id: params.element.getId(), }; var filterParams = {}; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getFullOverlayElementUrl(queryParams, filterParams)); }).then(function(content) { @@ -889,7 +896,7 @@ ServerConnector.getFullOverlayElement = function(params) { }); }; -ServerConnector.getProjectId = function(projectId) { +ServerConnector.getProjectId = function (projectId) { var self = this; if (projectId !== undefined && projectId !== null && projectId !== "") { return Promise.resolve(projectId); @@ -900,25 +907,25 @@ ServerConnector.getProjectId = function(projectId) { } }; -ServerConnector.getLogoImg = function() { +ServerConnector.getLogoImg = function () { return this.getConfigurationParam(ConfigurationType.LOGO_IMG); }; -ServerConnector.getLogoLink = function() { +ServerConnector.getLogoLink = function () { return this.getConfigurationParam(ConfigurationType.LOGO_LINK); }; -ServerConnector.getMaxSearchDistance = function() { +ServerConnector.getMaxSearchDistance = function () { return this.getConfigurationParam(ConfigurationType.SEARCH_DISTANCE); }; -ServerConnector.getOverlayById = function(overlayId, projectId) { +ServerConnector.getOverlayById = function (overlayId, projectId) { var self = this; var queryParams = { - overlayId : overlayId + overlayId: overlayId }; var filterParams = {}; - return self.getProjectId(projectId).then(function(data) { + return self.getProjectId(projectId).then(function (data) { queryParams.projectId = data; return self.sendGetRequest(self.getOverlayByIdUrl(queryParams, filterParams)); }).then(function(content) { @@ -926,7 +933,7 @@ ServerConnector.getOverlayById = function(overlayId, projectId) { }); }; -ServerConnector.getReactions = function(params) { +ServerConnector.getReactions = function (params) { var self = this; var queryParams = {}; if (params.ids === undefined) { @@ -936,9 +943,9 @@ ServerConnector.getReactions = function(params) { params.participantId = []; } var filterParams = { - id : params.ids, - columns : params.columns, - participantId : params.participantId, + id: params.ids, + columns: params.columns, + participantId: params.participantId, }; return self.getProjectId(params.projectId).then(function(result) { queryParams.projectId = result; @@ -1025,7 +1032,7 @@ ServerConnector.getComments = function(params) { }); }; -ServerConnector.getSessionData = function(project) { +ServerConnector.getSessionData = function (project) { if (this._sessionData === undefined) { this._sessionData = new SessionData(project); } @@ -1035,16 +1042,16 @@ ServerConnector.getSessionData = function(project) { return this._sessionData; }; -ServerConnector.getClosestElementsByCoordinates = function(params) { +ServerConnector.getClosestElementsByCoordinates = function (params) { var self = this; var queryParams = { - modelId : params.modelId + modelId: params.modelId }; var filterParams = { - coordinates : params.coordinates, - count : params.count, + coordinates: params.coordinates, + count: params.count, }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getSearchUrl(queryParams, filterParams)); }).then(function(content) { @@ -1057,20 +1064,20 @@ ServerConnector.getClosestElementsByCoordinates = function(params) { }); }; -ServerConnector.login = function(login, password) { +ServerConnector.login = function (login, password) { var self = this; var params = {}; - if (login !== undefined) { + if (login !== undefined && login !== "") { params.login = login; params.password = password; } else { params.login = "anonymous"; } self.getSessionData().setToken(""); - return self.sendPostRequest(self.loginUrl(), params).then(function() { + return self.sendPostRequest(self.loginUrl(), params).then(function () { self.getSessionData().setLogin(params.login); return Promise.resolve(self.getSessionData().getToken()); - }, function(error) { + }, function (error) { if (error instanceof NetworkError && error.statusCode === HttpStatus.FORBIDDEN) { throw new InvalidCredentialsError("Invalid credentials"); } else { @@ -1079,24 +1086,24 @@ ServerConnector.login = function(login, password) { }); }; -ServerConnector.logout = function() { +ServerConnector.logout = function () { var self = this; self.getSessionData().setToken(undefined); self.getSessionData().setLogin(undefined); - return Promise.resolve(); + return self.sendGetRequest(self.logoutUrl()); }; -ServerConnector.getElementsByQuery = function(params) { +ServerConnector.getElementsByQuery = function (params) { var self = this; var queryParams = { - modelId : params.modelId + modelId: params.modelId }; var filterParams = { - query : params.query, - perfectMatch : params.perfectMatch, + query: params.query, + perfectMatch: params.perfectMatch, }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getSearchUrl(queryParams, filterParams)); }).then(function(content) { @@ -1109,13 +1116,13 @@ ServerConnector.getElementsByQuery = function(params) { }); }; -ServerConnector.getDrugsByQuery = function(params) { +ServerConnector.getDrugsByQuery = function (params) { var self = this; var queryParams = {}; var filterParams = { - query : params.query + query: params.query }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getSearchDrugsUrl(queryParams, filterParams)); }).then(function(content) { @@ -1147,13 +1154,13 @@ ServerConnector.getMiRnasByQuery = function(params) { }); }; -ServerConnector.getChemicalsByQuery = function(params) { +ServerConnector.getChemicalsByQuery = function (params) { var self = this; var queryParams = {}; var filterParams = { - query : params.query + query: params.query }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getSearchChemicalsUrl(queryParams, filterParams)); }).then(function(content) { @@ -1166,93 +1173,93 @@ ServerConnector.getChemicalsByQuery = function(params) { }); }; -ServerConnector.getOverlaySourceDownloadUrl = function(params) { +ServerConnector.getOverlaySourceDownloadUrl = function (params) { var self = this; var queryParams = { - overlayId : params.overlayId + overlayId: params.overlayId }; var filterParams = {}; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.getOverlaySourceUrl(queryParams, filterParams); }); }; -ServerConnector.getImageDownloadUrl = function(params) { +ServerConnector.getImageDownloadUrl = function (params) { var self = this; var queryParams = { - projectId : params.projectId, - modelId : params.modelId, + projectId: params.projectId, + modelId: params.modelId, }; var filterParams = { - token : params.token, - polygonString : params.polygonString, - handlerClass : params.handlerClass, - backgroundOverlayId : params.backgroundOverlayId, - zoomLevel : params.zoomLevel, - overlayIds : this.idsToString(params.overlayIds), + token: params.token, + polygonString: params.polygonString, + handlerClass: params.handlerClass, + backgroundOverlayId: params.backgroundOverlayId, + zoomLevel: params.zoomLevel, + overlayIds: this.idsToString(params.overlayIds), }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.getImageUrl(queryParams, filterParams); }); }; -ServerConnector.getModelDownloadUrl = function(params) { +ServerConnector.getModelDownloadUrl = function (params) { var self = this; var queryParams = { - projectId : params.projectId, - modelId : params.modelId, + projectId: params.projectId, + modelId: params.modelId, }; var filterParams = { - token : params.token, - polygonString : params.polygonString, - handlerClass : params.handlerClass, - backgroundOverlayId : params.backgroundOverlayId, - zoomLevel : params.zoomLevel, - overlayIds : this.idsToString(params.overlayIds), + token: params.token, + polygonString: params.polygonString, + handlerClass: params.handlerClass, + backgroundOverlayId: params.backgroundOverlayId, + zoomLevel: params.zoomLevel, + overlayIds: this.idsToString(params.overlayIds), }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.getModelPartUrl(queryParams, filterParams); }); }; -ServerConnector.getImageConverters = function() { +ServerConnector.getImageConverters = function () { var self = this; - return self.getConfiguration().then(function(configuration) { + return self.getConfiguration().then(function (configuration) { return configuration.getImageConverters(); }); }; -ServerConnector.getModelConverters = function() { +ServerConnector.getModelConverters = function () { var self = this; - return self.getConfiguration().then(function(configuration) { + return self.getConfiguration().then(function (configuration) { return configuration.getModelConverters(); }); }; -ServerConnector.getProjectSourceDownloadUrl = function(params) { +ServerConnector.getProjectSourceDownloadUrl = function (params) { if (params === undefined) { params = {}; } var queryParams = {}; var filterParams = {}; var self = this; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.getProjectSourceUrl(queryParams, filterParams); }); }; -ServerConnector.getDrugNamesByTarget = function(params) { +ServerConnector.getDrugNamesByTarget = function (params) { var self = this; var queryParams = {}; var filterParams = { - columns : [ "name" ], - target : params.target.getType() + ":" + params.target.getId() + columns: ["name"], + target: params.target.getType() + ":" + params.target.getId() }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getSearchDrugsUrl(queryParams, filterParams)); }).then(function(content) { @@ -1265,14 +1272,14 @@ ServerConnector.getDrugNamesByTarget = function(params) { }); }; -ServerConnector.getMiRnaNamesByTarget = function(params) { +ServerConnector.getMiRnaNamesByTarget = function (params) { var self = this; var queryParams = {}; var filterParams = { - columns : [ "name" ], - target : params.target.getType() + ":" + params.target.getId() + columns: ["name"], + target: params.target.getType() + ":" + params.target.getId() }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getSearchMiRnasUrl(queryParams, filterParams)); }).then(function(content) { @@ -1285,14 +1292,14 @@ ServerConnector.getMiRnaNamesByTarget = function(params) { }); }; -ServerConnector.getChemicalNamesByTarget = function(params) { +ServerConnector.getChemicalNamesByTarget = function (params) { var self = this; var queryParams = {}; var filterParams = { - columns : [ "name" ], - target : params.target.getType() + ":" + params.target.getId() + columns: ["name"], + target: params.target.getType() + ":" + params.target.getId() }; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendGetRequest(self.getSearchChemicalsUrl(queryParams, filterParams)); }).then(function(content) { @@ -1305,13 +1312,13 @@ ServerConnector.getChemicalNamesByTarget = function(params) { }); }; -ServerConnector.addComment = function(params) { +ServerConnector.addComment = function (params) { var self = this; var queryParams = { - elementId : params.elementId, - elementType : params.elementType, - coordinates : self.pointToString(params.coordinates), - modelId : params.modelId, + elementId: params.elementId, + elementType: params.elementType, + coordinates: self.pointToString(params.coordinates), + modelId: params.modelId, }; var filterParams = params; delete filterParams.elementId; @@ -1322,10 +1329,10 @@ ServerConnector.addComment = function(params) { filterParams.coordinates = self.pointToString(params.coordinates); } delete filterParams.modelId; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendPostRequest(self.addCommentUrl(queryParams), filterParams); - }).then(function(content) { + }).then(function (content) { var response = JSON.parse(content); return new Comment(response); }); @@ -1368,13 +1375,13 @@ ServerConnector.updateOverlay = function(overlay) { return self.sendPatchRequest(self.updateOverlayUrl(queryParams), filterParams); }; -ServerConnector.removeOverlay = function(params) { +ServerConnector.removeOverlay = function (params) { var self = this; var queryParams = { - overlayId : params.overlayId + overlayId: params.overlayId }; var filterParams = {}; - return self.getProjectId(params.projectId).then(function(result) { + return self.getProjectId(params.projectId).then(function (result) { queryParams.projectId = result; return self.sendDeleteRequest(self.deleteOverlayUrl(queryParams), filterParams); }); @@ -1394,24 +1401,24 @@ ServerConnector.removeComment = function(params) { ServerConnector.getSuggestedQueryList = function(projectId) { var self = this; - return self.getProjectId(projectId).then(function(result) { + return self.getProjectId(projectId).then(function (result) { projectId = result; return self.sendGetRequest(self.getSuggestedQueryListUrl({ projectId : projectId })); - }).then(function(content) { + }).then(function (content) { return JSON.parse(content); }); }; -ServerConnector.getOverlayTypes = function() { +ServerConnector.getOverlayTypes = function () { var self = this; - return self.getConfiguration().then(function(configuration) { + return self.getConfiguration().then(function (configuration) { return configuration.getOverlayTypes(); }); }; -ServerConnector.getPublications = function(params) { +ServerConnector.getPublications = function (params) { var self = this; if (params === undefined) { params = {}; @@ -1419,11 +1426,11 @@ ServerConnector.getPublications = function(params) { var queryParams = {}; var filterParams = { - start : params.start, - length : params.length, - sortColumn : params.sortColumn, - sortOrder : params.sortOrder, - search : params.search, + start: params.start, + length: params.length, + sortColumn: params.sortColumn, + sortOrder: params.sortOrder, + search: params.search, }; return self.getProjectId(params.projectId).then(function(result) { queryParams.projectId = result; diff --git a/frontend-js/src/main/js/gui/AddOverlayDialog.js b/frontend-js/src/main/js/gui/AddOverlayDialog.js index 2f259e4b172013e5205b07556512c97433162376..ece24447a4ee238c8c4852710187eff1be2fe0d9 100644 --- a/frontend-js/src/main/js/gui/AddOverlayDialog.js +++ b/frontend-js/src/main/js/gui/AddOverlayDialog.js @@ -8,7 +8,7 @@ var GuiUtils = require('./leftPanel/GuiUtils'); var LayoutData = require('../map/data/LayoutData'); var NetworkError = require('../NetworkError'); -var Functions = require('../functions'); +var Functions = require('../Functions'); var logger = require('../logger'); var HttpStatus = require('http-status-codes'); @@ -89,10 +89,13 @@ AddOverlayDialog.prototype.processFile = function(file) { nameInput.value = data.name; } else { var filename = $("[name='overlay-file']", self.getElement())[0].value; - if (filename.indexOf(".") > 0) { - filename.substr(0, filename.indexOf(".") - 1); - } - nameInput.value = filename; + if (filename.indexOf(".") > 0) { + filename = filename.substr(0, filename.indexOf(".")); + } + if (filename.lastIndexOf("\\") >= 0) { + filename = filename.substr(filename.lastIndexOf("\\") + 1); + } + nameInput.value = filename; } if (data.description !== undefined) { descriptionInput.value = data.description; @@ -173,6 +176,8 @@ AddOverlayDialog.prototype.open = function() { var fileContent = self.getFileContent(); if (fileContent === null) { GuiConnector.alert("Neither file was selected nor data was entered"); + } else if (fileContent.length > 1024 * 256) { + GuiConnector.alert("File to big.<br>Please reduce file size or contact administrators."); } else { return self.addOverlay().then(function(result) { $(dialog).dialog("close"); diff --git a/frontend-js/src/main/js/gui/CommentDialog.js b/frontend-js/src/main/js/gui/CommentDialog.js index 5f4fe6f82785119e6837b89fb0ab56484c6ed9d8..1974a065715d6907b2c1b95be4a7f86a3ba1d375 100644 --- a/frontend-js/src/main/js/gui/CommentDialog.js +++ b/frontend-js/src/main/js/gui/CommentDialog.js @@ -85,6 +85,8 @@ CommentDialog.prototype._createGui = function() { pinnedLabel.innerHTML = "Pinned"; var pinnedCheckbox = document.createElement('input'); pinnedCheckbox.type = "checkbox"; + pinnedCheckbox.checked = "checked"; + table.appendChild(createRow([ pinnedLabel, pinnedCheckbox ])); this.setPinnedCheckbox(pinnedCheckbox); diff --git a/frontend-js/src/main/js/gui/LoginDialog.js b/frontend-js/src/main/js/gui/LoginDialog.js index 51c4bbae09c35840b14954df1dbae5ea56eba717..3df04cffff422f59c05771a8e0424f6c88160096 100644 --- a/frontend-js/src/main/js/gui/LoginDialog.js +++ b/frontend-js/src/main/js/gui/LoginDialog.js @@ -6,8 +6,9 @@ var AbstractGuiElement = require('./AbstractGuiElement'); var GuiConnector = require('../GuiConnector'); var InvalidCredentialsError = require('../InvalidCredentialsError'); var PanelControlElementType = require('./PanelControlElementType'); +var ConfigurationType = require("../ConfigurationType"); -var Functions = require('../functions'); +var Functions = require('../Functions'); var logger = require('../logger'); function LoginDialog(params) { @@ -15,18 +16,18 @@ function LoginDialog(params) { var self = this; self._createLoginTab(); $(self.getElement()).dialog({ - autoOpen : false, - resizable : false, + autoOpen: false, + resizable: false, }); var loginButton = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_BUTTON); - loginButton.onclick = function() { + loginButton.onclick = function () { var login = self.getControlElement(PanelControlElementType.USER_TAB_LOGIN_INPUT_TEXT).value; var password = self.getControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT).value; - return ServerConnector.login(login, password).then(function() { + return ServerConnector.login(login, password).then(function () { window.location.reload(false); - }).then(null, function(error) { + }).then(null, function (error) { if (error instanceof InvalidCredentialsError) { GuiConnector.alert("invalid credentials"); } else { @@ -40,16 +41,16 @@ function LoginDialog(params) { LoginDialog.prototype = Object.create(AbstractGuiElement.prototype); LoginDialog.prototype.constructor = LoginDialog; -LoginDialog.prototype.createTableRow = function(elements) { +LoginDialog.prototype.createTableRow = function (elements) { var row = Functions.createElement({ - type : "div", - style : "display: table-row;" + type: "div", + style: "display: table-row;" }); for (var i = 0; i < elements.length; i++) { var cell = Functions.createElement({ - type : "div", - style : "display: table-cell;" + type: "div", + style: "display: table-cell;" }); cell.appendChild(elements[i]); row.appendChild(cell); @@ -57,65 +58,81 @@ LoginDialog.prototype.createTableRow = function(elements) { return row; }; -LoginDialog.prototype._createLoginTab = function() { +LoginDialog.prototype._createLoginTab = function () { var self = this; var authorizationFormTab = Functions.createElement({ - type : "div", - style : "width:100%;display: table;border-spacing: 10px;" + type: "div", + style: "width:100%;display: table;border-spacing: 10px;" }); this.getElement().appendChild(authorizationFormTab); var loginLabel = Functions.createElement({ - type : "div", - content : "LOGIN:" + type: "div", + content: "LOGIN:" }); var loginInput = Functions.createElement({ - type : "input", - inputType : "text", - style : "width:100%", - name : "loginText" + type: "input", + inputType: "text", + style: "width:100%", + name: "loginText" }); this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_INPUT_TEXT, loginInput); - authorizationFormTab.appendChild(self.createTableRow([ loginLabel, loginInput ])); + authorizationFormTab.appendChild(self.createTableRow([loginLabel, loginInput])); var passwordLabel = Functions.createElement({ - type : "div", - content : "PASSWORD:" + type: "div", + content: "PASSWORD:" }); var passwordInput = Functions.createElement({ - type : "input", - inputType : "password", - style : "width:100%", - name : "passwordText" + type: "input", + inputType: "password", + style: "width:100%", + name: "passwordText" }); this.setControlElement(PanelControlElementType.USER_TAB_PASSOWRD_INPUT_TEXT, passwordInput); - authorizationFormTab.appendChild(self.createTableRow([ passwordLabel, passwordInput ])); + authorizationFormTab.appendChild(self.createTableRow([passwordLabel, passwordInput])); var centerTag = Functions.createElement({ - type : "center" + type: "center" }); this.getElement().appendChild(centerTag); var loginButton = Functions.createElement({ - type : "button", - name : "loginButton", - content : "LOGIN" + type: "button", + name: "loginButton", + content: "LOGIN" }); centerTag.appendChild(loginButton); this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_BUTTON, loginButton); + this.getElement().appendChild(Functions.createElement({type: "br"})); + this.getElement().appendChild(Functions.createElement({ + type: "a", + name: "requestAccount", + content: "Request an account", + href: "#", + })); + +}; + +LoginDialog.prototype.init = function () { + var self = this; + return ServerConnector.getConfigurationParam(ConfigurationType.REQUEST_ACCOUNT_EMAIL).then(function (value) { + var link = $("[name=requestAccount]", self.getElement()); + link.attr("href", "mailto:" + value + "?subject=MINERVA account request"); + }); }; -LoginDialog.prototype.open = function() { +LoginDialog.prototype.open = function () { var self = this; $(self.getElement()).dialog('option', 'title', 'AUTHORIZATION FORM'); $(self.getElement()).dialog("open"); }; -LoginDialog.prototype.destroy = function() { +LoginDialog.prototype.destroy = function () { $(this.getElement()).dialog("destroy"); }; diff --git a/frontend-js/src/main/js/gui/OverviewDialog.js b/frontend-js/src/main/js/gui/OverviewDialog.js index 9f59235c22a74cf2ea1719175d72e3ed6971d5e9..7237b783f1ba296c4c56dd13fc759c2625fc5f07 100644 --- a/frontend-js/src/main/js/gui/OverviewDialog.js +++ b/frontend-js/src/main/js/gui/OverviewDialog.js @@ -5,7 +5,7 @@ var AbstractGuiElement = require('./AbstractGuiElement'); var GuiConnector = require('../GuiConnector'); -var functions = require('../functions'); +var functions = require('../Functions'); var logger = require('../logger'); function OverviewDialog(params) { diff --git a/frontend-js/src/main/js/gui/admin/AddProjectDialog.js b/frontend-js/src/main/js/gui/admin/AddProjectDialog.js index b795684725a8951e126d858514bf8b33bf4f6ec3..8abb8cd323817b0f3c44f084a043d50cf3fe16d0 100644 --- a/frontend-js/src/main/js/gui/admin/AddProjectDialog.js +++ b/frontend-js/src/main/js/gui/admin/AddProjectDialog.js @@ -6,7 +6,7 @@ var Promise = require("bluebird"); var AbstractGuiElement = require('../AbstractGuiElement'); var GuiConnector = require('../../GuiConnector'); -var Functions = require('../../functions'); +var Functions = require('../../Functions'); var logger = require('../../logger'); var guiUtils = new (require('../leftPanel/GuiUtils'))(); diff --git a/frontend-js/src/main/js/gui/admin/EditProjectDialog.js b/frontend-js/src/main/js/gui/admin/EditProjectDialog.js index c61b199cb6c02037f970090dfb453315674d092b..702f7966703c8d059dcccdb674a105b29b56ef46 100644 --- a/frontend-js/src/main/js/gui/admin/EditProjectDialog.js +++ b/frontend-js/src/main/js/gui/admin/EditProjectDialog.js @@ -8,7 +8,7 @@ var AddOverlayDialog = require('../AddOverlayDialog'); var Annotation = require('../../map/data/Annotation'); var GuiConnector = require('../../GuiConnector'); -var Functions = require('../../functions'); +var Functions = require('../../Functions'); var logger = require('../../logger'); var guiUtils = new (require('../leftPanel/GuiUtils'))(); diff --git a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js index cf773acd3bffa346f359b3b7b75b89102a20e36d..b927d2f85c6f1c5f9d805c9c5a3be02ef977161e 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ChemicalPanel.js @@ -11,22 +11,25 @@ var PanelControlElementType = require('../PanelControlElementType'); function ChemicalPanel(params) { params.panelName = "chemical"; params.helpTip = '<p>source: Comparative Toxicogenomics Database <a target="_ctd" href="http://ctdbase.org/">ctdbase.org</a></p>' - + '<p>use only the full name of chemicals according to <a target="_ctd_chemicals" href="http://ctdbase.org/voc.go?type=chem"> ctdbase/chem</a> for search</p>' - + '<p>only curated associations between genes and chemicals with direct evidence to ' - + 'Parkinson Disease (<a href="http://bioportal.bioontology.org/ontologies/1351?p=terms&conceptid=D010300" target="_blank">D010300</a>) are displayed</p>' - + '<p>separate multiple search by semicolon'; + + '<p>only associations between genes and chemicals with direct evidence to ' + + 'Parkinson Disease (<a href="http://bioportal.bioontology.org/ontologies/1351?p=terms&conceptid=D010300" target="_blank">D010300</a>) are displayed</p>' + + '<p>use only the full name of chemicals according to <a target="_ctd_chemicals" href="http://ctdbase.org/voc.go?type=chem"> ctdbase/chem</a> for search</p>' + + 'if the chemical name includes comma(s), place a semicolon behind the name to avoid a segmentation of the name</p>' + + '<p>separate multiple search by semicolon'; params.placeholder = "full chemical name (CTD)"; + AbstractDbPanel.call(this, params); if (this.getMap().getProject().getDisease() === undefined) { this.disablePanel("DISEASE NOT DEFINED FOR PROJECT. PLEASE, DEFINE IT IN THE ADMIN SECTION."); } } + ChemicalPanel.prototype = Object.create(AbstractDbPanel.prototype); ChemicalPanel.prototype.constructor = ChemicalPanel; -ChemicalPanel.prototype.createPreamble = function(chemical) { +ChemicalPanel.prototype.createPreamble = function (chemical) { var self = this; var guiUtils = self.getGuiUtils(); var result = document.createElement("div"); @@ -37,8 +40,7 @@ ChemicalPanel.prototype.createPreamble = function(chemical) { result.appendChild(guiUtils.createParamLine("Description: ", chemical.getDescription())); result.appendChild(guiUtils.createArrayParamLine("Synonyms: ", chemical.getSynonyms())); result.appendChild(guiUtils.createParamLine("Direct Evidence: ", chemical.getDirectEvidence())); - result.appendChild(guiUtils - .createAnnotations("Directe Evidence Publications: ", chemical.getDirectEvidenceReferences())); + result.appendChild(guiUtils.createAnnotations("Direct Evidence Publications: ", chemical.getDirectEvidenceReferences())); result.appendChild(guiUtils.createAnnotations("Sources: ", chemical.getReferences())); result.appendChild(guiUtils.createNewLine()); } @@ -46,18 +48,18 @@ ChemicalPanel.prototype.createPreamble = function(chemical) { return result; }; -ChemicalPanel.prototype.createTableElement = function(target, icon) { +ChemicalPanel.prototype.createTableElement = function (target, icon) { return this.createTargetRow(target, icon); }; -ChemicalPanel.prototype.searchByQuery = function() { +ChemicalPanel.prototype.searchByQuery = function () { var self = this; var query = self.getControlElement(PanelControlElementType.SEARCH_INPUT).value; return self.getOverlayDb().searchByQuery(query); }; -ChemicalPanel.prototype.init = function() { +ChemicalPanel.prototype.init = function () { var query = ServerConnector.getSessionData().getChemicalQuery(); if (query !== undefined) { return this.getOverlayDb().searchByEncodedQuery(query); diff --git a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js index fe553ab1f70c2fad8f51b4989e9e637f37b62b97..a8ae7a7e411f49c94e0851a80e900bb60f441590 100644 --- a/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/LeftPanel.js @@ -151,6 +151,7 @@ LeftPanel.prototype.init = function() { resolve(); }); promises.push(initEvents); + promises.push(self.getLoginDialog().init()); return Promise.all(promises); }; @@ -185,7 +186,8 @@ LeftPanel.prototype.showElementDetails = function(element) { if (element !== undefined && (openTabName.indexOf("SEARCH") === -1 || searchTabName !== "GENERIC")) { var model = self.getMap().getSubmapById(element.getModelId()).getModel(); return model.getByIdentifiedElement(element, true).then(function(bioEntity) { - div.innerHTML = self.prepareElementDetailsContent(bioEntity).innerHTML; + div.innerHTML =""; + div.appendChild(self.prepareElementDetailsContent(bioEntity)); $(div).dialog("open"); $(div).dialog("option", "title", self.getElementTitle(bioEntity)); $(div).scrollTop(0); diff --git a/frontend-js/src/main/js/gui/leftPanel/MiRnaPanel.js b/frontend-js/src/main/js/gui/leftPanel/MiRnaPanel.js index 4cc29424ce41f56ce2d4e8af922f71db85bb63e3..f3ea0d84c5c4e6ddddbc5a6382e0463a2d72754e 100644 --- a/frontend-js/src/main/js/gui/leftPanel/MiRnaPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/MiRnaPanel.js @@ -27,7 +27,7 @@ MiRnaPanel.prototype.createPreamble = function(miRna) { result.appendChild(guiUtils.createLabel("NOT FOUND")); } else { var line = document.createElement("div"); - line.appendChild(guiUtils.createLabel("μRna: ")); + line.appendChild(guiUtils.createLabel("MiRNA: ")); line.appendChild(guiUtils.createLink("http://www.mirbase.org/cgi-bin/mirna_entry.pl?acc=" + miRna.getName(), miRna .getName())); line.appendChild(guiUtils.createNewLine()); diff --git a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js index f4c13ff1493d3f8bb8b227c609d95552cd32779a..684096e62fc6bda430bb87acd7d744ec92349cbd 100644 --- a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js @@ -14,8 +14,8 @@ function OverlayPanel(params) { params.panelName = "overlays"; params.scrollable = true; params.helpTip = "<p>Overlays tab allows to display or generate custom coloring of elements and interactions in the map.</p>" - + "<p>General overlays are overlays accessible for every user viewing the content.</p>" - + "<p>Custom overlays are user-provided overlays, this menu becomes available upon login (see below).</p>"; + + "<p>General overlays are overlays accessible for every user viewing the content.</p>" + + "<p>Custom overlays are user-provided overlays, this menu becomes available upon login (see below).</p>"; Panel.call(this, params); var self = this; @@ -24,7 +24,7 @@ function OverlayPanel(params) { var addButton = this.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON); - addButton.onclick = function() { + addButton.onclick = function () { self.openAddOverlayDialog(); }; @@ -36,70 +36,70 @@ function OverlayPanel(params) { OverlayPanel.prototype = Object.create(Panel.prototype); OverlayPanel.prototype.constructor = OverlayPanel; -OverlayPanel.prototype._createOverlayPanelGui = function() { +OverlayPanel.prototype._createOverlayPanelGui = function () { var generalOverlaysDiv = Functions.createElement({ - type : "div", - name : "generalOverlays", - className : "searchPanel" + type: "div", + name: "generalOverlays", + className: "searchPanel" }); this.getElement().appendChild(generalOverlaysDiv); this.setControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_DIV, generalOverlaysDiv); var generalOverlaysTitle = Functions.createElement({ - type : "h5", - content : "GENERAL OVERLAYS:" + type: "h5", + content: "GENERAL OVERLAYS:" }); generalOverlaysDiv.appendChild(generalOverlaysTitle); var generalOverlaysTableDiv = Functions.createElement({ - type : "table", - name : "generalOverlaysTab", - className : "table table-bordered", - style : "width:100%" + type: "table", + name: "generalOverlaysTab", + className: "table table-bordered", + style: "width:100%" }); generalOverlaysDiv.appendChild(generalOverlaysTableDiv); this.setControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE, generalOverlaysTableDiv); var customOverlaysDiv = Functions.createElement({ - type : "div", - name : "customOverlays", - className : "searchPanel" + type: "div", + name: "customOverlays", + className: "searchPanel" }); this.getElement().appendChild(customOverlaysDiv); this.setControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_DIV, customOverlaysDiv); var customOverlaysTitle = Functions.createElement({ - type : "h5", - name : "customOverlaysTitle", - content : "USER-PROVIDED OVERLAYS:" + type: "h5", + name: "customOverlaysTitle", + content: "USER-PROVIDED OVERLAYS:" }); customOverlaysDiv.appendChild(customOverlaysTitle); this.setControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE, customOverlaysTitle); var customOverlaysTableDiv = Functions.createElement({ - type : "table", - name : "customOverlaysTab", - className : "table table-bordered", - style : "width:100%" + type: "table", + name: "customOverlaysTab", + className: "table table-bordered", + style: "width:100%" }); customOverlaysDiv.appendChild(customOverlaysTableDiv); this.setControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE, customOverlaysTableDiv); var centerTag = Functions.createElement({ - type : "center" + type: "center" }); customOverlaysDiv.appendChild(centerTag); var addOverlayButton = Functions.createElement({ - type : "button", - name : "addOverlay", - content : "Add overlay" + type: "button", + name: "addOverlay", + content: "Add overlay" }); centerTag.appendChild(addOverlayButton); this.setControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON, addOverlayButton); }; -OverlayPanel.prototype.clear = function() { +OverlayPanel.prototype.clear = function () { var table = this.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE); while (table.firstChild) { table.removeChild(table.firstChild); @@ -112,7 +112,7 @@ OverlayPanel.prototype.clear = function() { }; -OverlayPanel.prototype.createTableHeader = function(edit) { +OverlayPanel.prototype.createTableHeader = function (edit) { var result = document.createElement("thead"); var row = document.createElement("tr"); @@ -139,7 +139,7 @@ OverlayPanel.prototype.createTableHeader = function(edit) { return result; }; -OverlayPanel.prototype.createOverlayRow = function(overlay, checked) { +OverlayPanel.prototype.createOverlayRow = function (overlay, checked) { var self = this; var guiUtils = self.getGuiUtils(); var result = document.createElement("tr"); @@ -157,7 +157,7 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) { var checkbox = document.createElement("input"); checkbox.type = "checkbox"; checkbox.checked = checked; - checkbox.onclick = function() { + checkbox.onclick = function () { if (this.checked) { return self.getMap().openDataOverlay(overlay.getId()).then(null, GuiConnector.alert); } else { @@ -169,7 +169,7 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) { var img = guiUtils.createIcon("icons/search.png"); var link = document.createElement("a"); link.href = "#"; - link.onclick = function() { + link.onclick = function () { self.getMap().openDataOverlay(overlay.getId()); $(result).addClass('active').siblings().removeClass('active'); }; @@ -182,10 +182,10 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) { if (overlay.getInputDataAvailable()) { var button = document.createElement("button"); button.setAttribute("name", "download-overlay-" + overlay.getId()); - button.onclick = function() { + button.onclick = function () { return ServerConnector.getOverlaySourceDownloadUrl({ - overlayId : overlay.getId() - }).then(function(url) { + overlayId: overlay.getId() + }).then(function (url) { return self.downloadFile(url); }).then(null, GuiConnector.alert); }; @@ -199,7 +199,7 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) { var editTd = document.createElement("td"); var editButton = document.createElement("button"); editButton.setAttribute("name", "editButton"); - editButton.onclick = function() { + editButton.onclick = function () { self.openEditOverlayDialog(overlay); }; editButton.innerHTML = "<span class='ui-icon ui-icon-document'></span>"; @@ -210,72 +210,72 @@ OverlayPanel.prototype.createOverlayRow = function(overlay, checked) { return result; }; -OverlayPanel.prototype.openEditOverlayDialog = function(overlay) { +OverlayPanel.prototype.openEditOverlayDialog = function (overlay) { var self = this; var guiUtils = self.getGuiUtils(); var content = document.createElement("fieldset"); var nameInput = guiUtils.createInputText(overlay.getName()); - var row = guiUtils.createTableRow([ guiUtils.createLabel("Name: "), nameInput ]); + var row = guiUtils.createTableRow([guiUtils.createLabel("Name: "), nameInput]); content.appendChild(row); var descriptionInput = guiUtils.createTextArea(overlay.getDescription()); - row = guiUtils.createTableRow([ guiUtils.createLabel("Description: "), descriptionInput ]); + row = guiUtils.createTableRow([guiUtils.createLabel("Description: "), descriptionInput]); content.appendChild(row); - var buttons = [ { - text : "SAVE", - click : function() { + var buttons = [{ + text: "SAVE", + click: function () { var windowSelf = this; overlay.setName(nameInput.value); overlay.setDescription(descriptionInput.value); return ServerConnector.updateOverlay(overlay).then(function() { return self.refresh(); - }).then(function() { + }).then(function () { $(windowSelf).dialog("close"); }).then(null, GuiConnector.alert); } }, { - text : "REMOVE", - click : function() { + text: "REMOVE", + click: function () { self.getMap().removeSelectedLayout(overlay.getId()); var windowSelf = this; return ServerConnector.removeOverlay({ - overlayId : overlay.getId() - }).then(function() { + overlayId: overlay.getId() + }).then(function () { return self.refresh(); - }).then(function() { + }).then(function () { $(windowSelf).dialog("close"); }).then(null, GuiConnector.alert); } }, { - text : "CANCEL", - click : function() { + text: "CANCEL", + click: function () { $(this).dialog("close"); } - } ]; + }]; self.openDialog(content, { - id : overlay.getId(), - buttons : buttons, - title : "Data overlay: " + overlay.getName(), - className : "minerva-overlay-dialog", + id: overlay.getId(), + buttons: buttons, + title: "Data overlay: " + overlay.getName(), + className: "minerva-overlay-dialog", }); }; -OverlayPanel.prototype.refresh = function() { +OverlayPanel.prototype.refresh = function () { var self = this; var user = null; var overlayTypes = []; var selectedOverlay = []; - return ServerConnector.getOverlayTypes().then(function(types) { + return ServerConnector.getOverlayTypes().then(function (types) { overlayTypes = types; return ServerConnector.getLoggedUser(); - }).then(function(loggedUser) { + }).then(function (loggedUser) { user = loggedUser; return self.getMap().getVisibleDataOverlays(); - }).then(function(visibleDataOverlays) { + }).then(function (visibleDataOverlays) { for (var j = 0; j < visibleDataOverlays.length; j++) { selectedOverlay[visibleDataOverlays[j].getId()] = true; } @@ -285,15 +285,15 @@ OverlayPanel.prototype.refresh = function() { creator : user.getLogin(), }); }).then( - function(customOverlays) { + function (customOverlays) { - var id = self.getMap().getGoogleMap().getMapTypeId().substring(2); - selectedOverlay[id] = true; + var id = self.getMap().getGoogleMap().getMapTypeId().substring(2); + selectedOverlay[id] = true; - self.clear(); + self.clear(); - var generalOverlays = []; - var overlay; + var generalOverlays = []; + var overlay; var overlays = self.getMap().getLayouts(); for (var i = 0; i < overlays.length; i++) { @@ -303,56 +303,55 @@ OverlayPanel.prototype.refresh = function() { } } - var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE); - table.appendChild(self.createTableHeader()); + var table = self.getControlElement(PanelControlElementType.OVERLAY_GENERAL_OVERLAY_TABLE); + table.appendChild(self.createTableHeader()); - var body = document.createElement("tbody"); + var body = document.createElement("tbody"); + table.appendChild(body); + for (i = 0; i < generalOverlays.length; i++) { + overlay = generalOverlays[i]; + body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()])); + } + + var title = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE); + var addButton = self.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON); + if (user.getLogin() === "anonymous") { + title.innerHTML = 'YOU ARE NOT LOGGED IN. PLEASE, <a href="#">LOG IN</a>' + + 'TO UPLOAD AND VIEW CUSTOM OVERLAYS<br/><center><button>LOGIN</button></center>'; + var openLoginDialog = function () { + return self.getParent().getLoginDialog().open(); + }; + $(title).find("a")[0].onclick = openLoginDialog; + $(title).find("button")[0].onclick = openLoginDialog; + addButton.style.display = "none"; + } else { + title.innerHTML = self.getCustomOverlaysMessage(); + addButton.style.display = "block"; + + table = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE); + table.appendChild(self.createTableHeader(true)); + + body = document.createElement("tbody"); table.appendChild(body); - for (i = 0; i < generalOverlays.length; i++) { - overlay = generalOverlays[i]; + for (i = 0; i < customOverlays.length; i++) { + overlay = customOverlays[i]; body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()])); } + } - var title = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TITLE); - var addButton = self.getControlElement(PanelControlElementType.OVERLAY_ADD_OVERLAY_BUTTON); - if (user.getLogin() === "anonymous") { - title.innerHTML = 'YOU ARE NOT LOGGED IN. PLEASE, <a href="#">LOG IN</a>' - + 'TO UPLOAD AND VIEW CUSTOM OVERLAYS<br/><center><button>LOGIN</button></center>'; - var openLoginDialog = function() { - return self.getParent().getLoginDialog().open(); - }; - $(title).find("a")[0].onclick = openLoginDialog; - $(title).find("button")[0].onclick = openLoginDialog; - addButton.style.display = "none"; - } else { - title.innerHTML = self.getCustomOverlaysMessage(); - addButton.style.display = "block"; - - table = self.getControlElement(PanelControlElementType.OVERLAY_CUSTOM_OVERLAY_TABLE); - table.appendChild(self.createTableHeader(true)); - - body = document.createElement("tbody"); - table.appendChild(body); - for (i = 0; i < customOverlays.length; i++) { - overlay = customOverlays[i]; - body.appendChild(self.createOverlayRow(overlay, selectedOverlay[overlay.getId()])); - } - } - - self.onresize(); - }); + self.onresize(); + }); }; -OverlayPanel.prototype.setCustomOverlaysMessage = function(customOverlaysMessage) { +OverlayPanel.prototype.setCustomOverlaysMessage = function (customOverlaysMessage) { this._customOverlaysMessage = customOverlaysMessage; }; -OverlayPanel.prototype.getCustomOverlaysMessage = function() { +OverlayPanel.prototype.getCustomOverlaysMessage = function () { return this._customOverlaysMessage; }; - -OverlayPanel.prototype.openAddOverlayDialog = function() { +OverlayPanel.prototype.openAddOverlayDialog = function () { var self = this; var addOverlayDialog = new AddOverlayDialog({ project : self.getProject(), @@ -368,7 +367,7 @@ OverlayPanel.prototype.openAddOverlayDialog = function() { }); }; -OverlayPanel.prototype.init = function() { +OverlayPanel.prototype.init = function () { return this.refresh(); }; module.exports = OverlayPanel; diff --git a/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js b/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js index c4d3efe8417d17024b75cb34111bce27e98603bc..7de49eae84b03d2ac4391f7ee4a182a65f47880d 100644 --- a/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js +++ b/frontend-js/src/main/js/gui/leftPanel/ProjectInfoPanel.js @@ -21,8 +21,8 @@ function ProjectInfoPanel(params) { self._createUserDataTab(); var logoutButton = self.getControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON); - logoutButton.onclick = function() { - return ServerConnector.logout().then(function() { + logoutButton.onclick = function () { + return ServerConnector.logout().then(function () { window.location.reload(false); }).then(null, GuiConnector.alert); }; @@ -32,292 +32,293 @@ function ProjectInfoPanel(params) { ProjectInfoPanel.prototype = Object.create(Panel.prototype); ProjectInfoPanel.prototype.constructor = ProjectInfoPanel; -ProjectInfoPanel.prototype._createInfoPanelGui = function() { +ProjectInfoPanel.prototype._createInfoPanelGui = function () { var self = this; var guiUtils = self.getGuiUtils(); var projectId = self.getMap().getProject().getProjectId(); var infoDiv = Functions.createElement({ - type : "div", - name : "infoDiv", - className : "searchPanel" + type: "div", + name: "infoDiv", + className: "searchPanel" }); this.getElement().appendChild(infoDiv); this.setControlElement(PanelControlElementType.INFO_DIV, infoDiv); var infoTitle = Functions.createElement({ - type : "h4", - content : "PROJECT INFO:" + type: "h4", + content: "PROJECT INFO:" }); infoDiv.appendChild(infoTitle); var dataTab = Functions.createElement({ - type : "div", - style : "width:100%;display: table;border-spacing: 10px;" + type: "div", + style: "width:100%;display: table;border-spacing: 10px;" }); infoDiv.appendChild(dataTab); var projectNameLabel = Functions.createElement({ - type : "div", - content : "Name:" + type: "div", + content: "Name:" }); var projectNameText = Functions.createElement({ - type : "div", - style : "width:100%", - name : "projectNameText" + type: "div", + style: "width:100%", + name: "projectNameText" }); this.setControlElement(PanelControlElementType.INFO_PROJECT_NAME_TEXT, projectNameText); - dataTab.appendChild(guiUtils.createTableRow([ projectNameLabel, projectNameText ])); + dataTab.appendChild(guiUtils.createTableRow([projectNameLabel, projectNameText])); var projectVersionLabel = Functions.createElement({ - type : "div", - content : "Version:" + type: "div", + content: "Version:" }); var projectVersionText = Functions.createElement({ - type : "div", - style : "width:100%", - name : "projectVersionText" + type: "div", + style: "width:100%", + name: "projectVersionText" }); this.setControlElement(PanelControlElementType.INFO_PROJECT_VERSION_TEXT, projectVersionText); - dataTab.appendChild(guiUtils.createTableRow([ projectVersionLabel, projectVersionText ])); + dataTab.appendChild(guiUtils.createTableRow([projectVersionLabel, projectVersionText])); infoTitle = Functions.createElement({ - type : "h4", - content : "Data:" + type: "h4", + content: "Data:" }); infoDiv.appendChild(infoTitle); var dialogDiv = Functions.createElement({ - type : "div", + type: "div", }); this.publicationListDialog = new PublicationListDialog({ - customMap : self.getMap(), - element : dialogDiv, + customMap: self.getMap(), + element: dialogDiv, }); dataTab = Functions.createElement({ - type : "ul", + type: "ul", }); infoDiv.appendChild(dataTab); var projectPublicationsText = Functions.createElement({ - type : "span", - name : "projectPublicationsText", - style : "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer", + type: "span", + name: "projectPublicationsText", + style: "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer", }); this.setControlElement(PanelControlElementType.INFO_PROJECT_PUBLICATIONS_TEXT, projectPublicationsText); var projectPublicationsButton = Functions.createElement({ - type : "a", - name : "projectPublicationsButton", + type: "a", + name: "projectPublicationsButton", }); projectPublicationsButton.appendChild(Functions.createElement({ - type : "span", - content : "<i class='fa fa-list'> ", + type: "span", + content: "<i class='fa fa-list'> ", })); projectPublicationsButton.appendChild(projectPublicationsText); projectPublicationsButton.appendChild(Functions.createElement({ - type : "span", - style : "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer", - content : " publication(s)", + type: "span", + style: "font-family:FontAwesome; font-weight: normal;font-style: normal;cursor: pointer", + content: " publication(s)", })); this.setControlElement(PanelControlElementType.INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON, projectPublicationsButton); var liElement = Functions.createElement({ - type : "li", - style : "line-height: 30px;", + type: "li", + style: "line-height: 30px;", }); liElement.appendChild(projectPublicationsButton); dataTab.appendChild(liElement); var projectOriginalFileButton = Functions.createElement({ - type : "a", - name : "projectOriginalFileButton", - href : "#", - content : "<i class='fa fa-files-o'> source file", + type: "a", + name: "projectOriginalFileButton", + href: "#", + content: "<i class='fa fa-files-o'> source file", }); this.setControlElement(PanelControlElementType.INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON, projectOriginalFileButton); liElement = Functions.createElement({ - type : "li", - style : "line-height: 30px", + type: "li", + style: "line-height: 30px", }); liElement.appendChild(projectOriginalFileButton); dataTab.appendChild(liElement); var exportButton = Functions.createElement({ - type : "a", - href : ServerConnector.getServerBaseUrl() + "/export.xhtml?id=" + projectId, - content : '<i class="fa fa-mail-forward"> EXPORT', + type: "a", + href: ServerConnector.getServerBaseUrl() + "/export.xhtml?id=" + projectId, + content: '<i class="fa fa-mail-forward"> EXPORT', }); liElement = Functions.createElement({ - type : "li", - style : "line-height: 30px", + type: "li", + style: "line-height: 30px", }); liElement.appendChild(exportButton); dataTab.appendChild(liElement); var manualButton = Functions.createElement({ - type : "a", - name : "manualLink", - content : '<i class="fa fa-file"> MANUAL', + type: "a", + name: "manualLink", + content: '<i class="fa fa-file"> MANUAL', }); manualButton.href = "#"; - manualButton.onclick = function() { - return ServerConnector.getConfigurationParam(ConfigurationType.USER_MANUAL_FILE).then(function(manualFileUrl) { + manualButton.onclick = function () { + return ServerConnector.getConfigurationParam(ConfigurationType.USER_MANUAL_FILE).then(function (manualFileUrl) { var win = window.open(manualFileUrl, '_user_manual_'); win.focus(); }); }; liElement = Functions.createElement({ - type : "li", - style : "line-height: 30px", + type: "li", + style: "line-height: 30px", }); liElement.appendChild(manualButton); dataTab.appendChild(liElement); }; -ProjectInfoPanel.prototype._createInfoPanelLogic = function() { +ProjectInfoPanel.prototype._createInfoPanelLogic = function () { var self = this; var downloadSourceButton = self.getControlElement(PanelControlElementType.INFO_PROJECT_GET_ORIGINAL_FILE_BUTTON); var showPublicationsButton = self.getControlElement(PanelControlElementType.INFO_PROJECT_SHOW_PUBLICATIONS_BUTTON); - downloadSourceButton.onclick = function() { + downloadSourceButton.onclick = function () { return self.downloadSourceFile(); }; - showPublicationsButton.onclick = function() { + showPublicationsButton.onclick = function () { return self.showPublicationListDialog(); }; }; -ProjectInfoPanel.prototype.downloadSourceFile = function() { +ProjectInfoPanel.prototype.downloadSourceFile = function () { var self = this; - return ServerConnector.getProjectSourceDownloadUrl().then(function(url) { + return ServerConnector.getProjectSourceDownloadUrl().then(function (url) { return self.downloadFile(url); }).then(null, GuiConnector.alert); }; -ProjectInfoPanel.prototype.showPublicationListDialog = function() { +ProjectInfoPanel.prototype.showPublicationListDialog = function () { return this.publicationListDialog.show(); }; -ProjectInfoPanel.prototype.refresh = function() { +ProjectInfoPanel.prototype.refresh = function () { var self = this; var projectNameText = self.getControlElement(PanelControlElementType.INFO_PROJECT_NAME_TEXT); var projectVersionText = self.getControlElement(PanelControlElementType.INFO_PROJECT_VERSION_TEXT); var projectPublicationsText = self.getControlElement(PanelControlElementType.INFO_PROJECT_PUBLICATIONS_TEXT); - return ServerConnector.getProject().then(function(project) { + return ServerConnector.getProject().then(function (project) { projectNameText.innerHTML = project.getName(); projectVersionText.innerHTML = project.getVersion(); return ServerConnector.getProjectStatistics(); - }).then(function(statistics) { + }).then(function (statistics) { projectPublicationsText.innerHTML = statistics.getPublicationCount(); return ServerConnector.getLoggedUser(); - }).then(function(user) { + }).then(function (user) { self.showUserProfilePage(user); }); }; -ProjectInfoPanel.prototype._createUserDataTab = function() { +ProjectInfoPanel.prototype._createUserDataTab = function () { var self = this; var guiUtils = self.getGuiUtils(); var userDataDiv = Functions.createElement({ - type : "div", - name : "userDataTab", - className : "searchPanel", - style : "display:none" + type: "div", + name: "userDataTab", + className: "searchPanel", + style: "display:none" }); this.getElement().appendChild(userDataDiv); this.setControlElement(PanelControlElementType.USER_TAB_USER_DIV, userDataDiv); var userDataTitle = Functions.createElement({ - type : "h3", - content : '<img src="./resources/images/profile.png" border="0" align="left"/><br/>User data<br/>' + type: "h3", + content: '<img src="./resources/images/profile.png" border="0" align="left"/><br/>User data<br/>' }); userDataDiv.appendChild(userDataTitle); var userDataFormTab = Functions.createElement({ - type : "div", - style : "width:100%;display: table;border-spacing: 10px;" + type: "div", + style: "width:100%;display: table;border-spacing: 10px;" }); userDataDiv.appendChild(userDataFormTab); var loginLabel = Functions.createElement({ - type : "span", - content : "LOGIN:", - style : "color:#999999" + type: "span", + content: "LOGIN:", + style: "color:#999999" }); var loginText = Functions.createElement({ - type : "span", - name : "loginValue" + type: "span", + name: "loginValue" }); this.setControlElement(PanelControlElementType.USER_TAB_LOGIN_TEXT, loginText); - userDataDiv.appendChild(guiUtils.createTableRow([ loginLabel, loginText ])); + userDataDiv.appendChild(guiUtils.createTableRow([loginLabel, loginText])); var nameLabel = Functions.createElement({ - type : "span", - content : "NAME:", - style : "color:#999999" + type: "span", + content: "NAME:", + style: "color:#999999" }); var nameText = Functions.createElement({ - type : "span", - name : "nameValue" + type: "span", + name: "nameValue" }); this.setControlElement(PanelControlElementType.USER_TAB_NAME_TEXT, nameText); - userDataDiv.appendChild(guiUtils.createTableRow([ nameLabel, nameText ])); + userDataDiv.appendChild(guiUtils.createTableRow([nameLabel, nameText])); var surnameLabel = Functions.createElement({ - type : "span", - content : "SURNAME:", - style : "color:#999999" + type: "span", + content: "SURNAME:", + style: "color:#999999" }); var surnameText = Functions.createElement({ - type : "span", - name : "surnameValue" + type: "span", + name: "surnameValue" }); this.setControlElement(PanelControlElementType.USER_TAB_SURNAME_TEXT, surnameText); - userDataDiv.appendChild(guiUtils.createTableRow([ surnameLabel, surnameText ])); + userDataDiv.appendChild(guiUtils.createTableRow([surnameLabel, surnameText])); var emailLabel = Functions.createElement({ - type : "span", - content : "EMAIL:", - style : "color:#999999" + type: "span", + content: "EMAIL:", + style: "color:#999999" }); var emailText = Functions.createElement({ - type : "span", - name : "emailValue" + type: "span", + name: "emailValue" }); self.setControlElement(PanelControlElementType.USER_TAB_EMAIL_TEXT, emailText); - userDataDiv.appendChild(guiUtils.createTableRow([ emailLabel, emailText ])); + userDataDiv.appendChild(guiUtils.createTableRow([emailLabel, emailText])); var centerTag = Functions.createElement({ - type : "center" + type: "center" }); userDataDiv.appendChild(centerTag); var logoutButton = Functions.createElement({ - type : "button", - name : "logoutButton", - content : "LOGOUT" + type: "button", + name: "logoutButton", + content: "LOGOUT" }); centerTag.appendChild(logoutButton); self.setControlElement(PanelControlElementType.USER_TAB_LOGOUT_BUTTON, logoutButton); self.setControlElement(PanelControlElementType.USER_TAB_USER_DIV, userDataDiv); var loginTabDiv = Functions.createElement({ - type : "div", - name : "userLoginTab", - className : "searchPanel", - style : "display:none", - content : '<h3><img src="./resources/images/profile.png" border="0" align="left"/>' - + '<br/>User data</h3><br/>YOU ARE NOT LOGGED IN.<br/>' + '<center><button>LOGIN</button></center>', - }); - $(loginTabDiv).find("button")[0].onclick = function() { + type: "div", + name: "userLoginTab", + className: "searchPanel", + style: "display:none", + content: '<h3><img src="./resources/images/profile.png" border="0" align="left"/>' + + '<br/>User data</h3><br/>YOU ARE NOT LOGGED IN.<br/>' + '<center><button>LOGIN</button></center>' + + '<br/><a hreg="#" name="requestAccount">Request an account</a>', + }); + $(loginTabDiv).find("button")[0].onclick = function () { return self.getParent().getLoginDialog().open(); }; @@ -326,7 +327,7 @@ ProjectInfoPanel.prototype._createUserDataTab = function() { }; -ProjectInfoPanel.prototype.showUserProfilePage = function(user) { +ProjectInfoPanel.prototype.showUserProfilePage = function (user) { var self = this; var userDataTabDiv = self.getControlElement(PanelControlElementType.USER_TAB_USER_DIV); @@ -351,8 +352,13 @@ ProjectInfoPanel.prototype.showUserProfilePage = function(user) { } }; -ProjectInfoPanel.prototype.init = function() { - return this.refresh(); +ProjectInfoPanel.prototype.init = function () { + var self = this; + return ServerConnector.getConfigurationParam(ConfigurationType.REQUEST_ACCOUNT_EMAIL).then(function (value) { + var link = $("[name=requestAccount]", self.getElement()); + link.attr("href", "mailto:" + value + "?subject=MINERVA account request"); + return self.refresh(); + }); }; module.exports = ProjectInfoPanel; diff --git a/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js b/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js index 39df083d6cec0f4c00860e99358aca836b67c591..eb5ec1203e3a5530fead452e39fc54fbc0b0b6a7 100644 --- a/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js +++ b/frontend-js/src/main/js/gui/leftPanel/PublicationListDialog.js @@ -9,7 +9,7 @@ var Alias = require('../../map/data/Alias'); var IdentifiedElement = require('../../map/data/IdentifiedElement'); var Reaction = require('../../map/data/Reaction'); -var Functions = require('../../functions'); +var Functions = require('../../Functions'); var logger = require('../../logger'); function PublicationListDialog(params) { diff --git a/frontend-js/src/main/js/map/AbstractCustomMap.js b/frontend-js/src/main/js/map/AbstractCustomMap.js index e6129ba9d240428750c9fdb13af7ef9a918c6d6f..06bccc48ba2d14113796d306a09dae71c9f2038b 100644 --- a/frontend-js/src/main/js/map/AbstractCustomMap.js +++ b/frontend-js/src/main/js/map/AbstractCustomMap.js @@ -78,9 +78,9 @@ AbstractCustomMap.prototype.constructor = AbstractCustomMap; /** * Assigns layouts with images to the google map (which set of images should be * used by google maps api for which layout). - * + * */ -AbstractCustomMap.prototype.setupLayouts = function() { +AbstractCustomMap.prototype.setupLayouts = function () { for (var i = 0; i < this.getLayouts().length; i++) { var layout = this.getLayouts()[i]; var typeOptions = this.createTypeOptions(layout); @@ -92,9 +92,9 @@ AbstractCustomMap.prototype.setupLayouts = function() { /** * Creates general google maps options used in this map. - * + * */ -AbstractCustomMap.prototype.creatMapOptions = function() { +AbstractCustomMap.prototype.creatMapOptions = function () { var self = this; var centerPoint = this.getModel().getCenterLatLng(); @@ -106,19 +106,19 @@ AbstractCustomMap.prototype.creatMapOptions = function() { } var result = { - center : centerPoint, - rotateControl : true, - panControl : true, - mapTypeControl : false, - zoom : this.getMinZoom(), - streetViewControl : false, - - panControlOptions : { - position : google.maps.ControlPosition.LEFT_TOP + center: centerPoint, + rotateControl: true, + panControl: true, + mapTypeControl: false, + zoom: this.getMinZoom(), + streetViewControl: false, + + panControlOptions: { + position: google.maps.ControlPosition.LEFT_TOP }, - zoomControlOptions : { - style : google.maps.ZoomControlStyle.LARGE, - position : google.maps.ControlPosition.LEFT_TOP + zoomControlOptions: { + style: google.maps.ZoomControlStyle.LARGE, + position: google.maps.ControlPosition.LEFT_TOP } }; @@ -127,16 +127,16 @@ AbstractCustomMap.prototype.creatMapOptions = function() { /** * Create google maps configuration options object for a specific layout. - * + * * @param param * object with information about layout */ -AbstractCustomMap.prototype.createTypeOptions = function(param) { +AbstractCustomMap.prototype.createTypeOptions = function (param) { var self = this; var result = { // this is a function that will retrieve valid url to png images for // tiles on different zoom levels - getTileUrl : function(coord, zoom) { + getTileUrl: function (coord, zoom) { // we have 1 tile on self.getConfiguration().MIN_ZOOM and // therefore must limit tails according to this /* jshint bitwise: false */ @@ -147,28 +147,28 @@ AbstractCustomMap.prototype.createTypeOptions = function(param) { var addr = "../map_images/" + param.getDirectory() + "/" + zoom + "/" + coord.x + "/" + coord.y + ".PNG"; return addr; }, - tileSize : new google.maps.Size(this.getTileSize(), this.getTileSize()), - maxZoom : this.getMaxZoom(), - minZoom : this.getMinZoom(), - radius : 360, - name : param.name + tileSize: new google.maps.Size(this.getTileSize(), this.getTileSize()), + maxZoom: this.getMaxZoom(), + minZoom: this.getMinZoom(), + radius: 360, + name: param.name }; return result; }; /** * Sets maximum zoom level on google map. - * + * */ -AbstractCustomMap.prototype.setMaxZoomLevel = function() { +AbstractCustomMap.prototype.setMaxZoomLevel = function () { this.getGoogleMap().setZoom(this.getMaxZoom()); }; /** * Returns mouse coordinate on the map in lat,lng system. - * + * */ -AbstractCustomMap.prototype.getMouseLatLng = function() { +AbstractCustomMap.prototype.getMouseLatLng = function () { // this method is tricky, the main problem is how to map mouse coordinate to // google map // to do that we need a point of reference in both systems (x,y and lat,lng) @@ -189,19 +189,19 @@ AbstractCustomMap.prototype.getMouseLatLng = function() { } var offset = { - x : lx, - y : ly + x: lx, + y: ly }; var center = { - x : self.getGoogleMap().getDiv().offsetWidth / 2, - y : self.getGoogleMap().getDiv().offsetHeight / 2 + x: self.getGoogleMap().getDiv().offsetWidth / 2, + y: self.getGoogleMap().getDiv().offsetHeight / 2 }; // and now find how far from center point we are (in pixels) var relativeDist = { - x : (GuiConnector.xPos - offset.x - center.x), - y : (GuiConnector.yPos - offset.y - center.y) + x: (GuiConnector.xPos - offset.x - center.x), + y: (GuiConnector.yPos - offset.y - center.y) }; // transform pixels into x,y distance @@ -219,14 +219,14 @@ AbstractCustomMap.prototype.getMouseLatLng = function() { /** * Transform distance (coordinates) in pixels into x,y distance on the map. - * + * * @param pixels * x,y distance in pixels * @param zoomLevel * at which zoom level this pixels where mesaured - * + * */ -AbstractCustomMap.prototype.fromPixelsToPoint = function(pixels, zoomLevel) { +AbstractCustomMap.prototype.fromPixelsToPoint = function (pixels, zoomLevel) { var zoomScale = this.getPictureSize() / (Math.pow(2, zoomLevel - this.getMinZoom()) * this.getTileSize()); var pointx = pixels.x * zoomScale; var pointy = pixels.y * zoomScale; @@ -236,13 +236,13 @@ AbstractCustomMap.prototype.fromPixelsToPoint = function(pixels, zoomLevel) { /** * Transforms coordinates on the map from google.maps.LatLng to * google.maps.Point - * + * * @param latlng * cooordinates in x,y format * @param coordinates * in lat,lng format */ -AbstractCustomMap.prototype.fromLatLngToPoint = function(latLng) { +AbstractCustomMap.prototype.fromLatLngToPoint = function (latLng) { var me = this; var point = new google.maps.Point(0, 0); var origin = me.pixelOrigin_; @@ -264,12 +264,12 @@ AbstractCustomMap.prototype.fromLatLngToPoint = function(latLng) { /** * Transforms coordinates on the map from google.maps.Point to * google.maps.LatLng - * + * * @param point * coordinates in standard x,y format * @return cooordinates in lat,lng format */ -AbstractCustomMap.prototype.fromPointToLatLng = function(point) { +AbstractCustomMap.prototype.fromPointToLatLng = function (point) { var me = this; // rescale the point (all computations are done assuming that we work on @@ -285,26 +285,26 @@ AbstractCustomMap.prototype.fromPointToLatLng = function(point) { /** * Transforms google.maps.LatLng to tile coordinate (for instance on which tile * mouse clicked). - * - * + * + * * @param latlng * coordinates in latlng format * @param z * zoom level at which we want to find coordinates of tile * @return cooordinates of a tile */ -AbstractCustomMap.prototype.latLngToTile = function(latLng, z) { +AbstractCustomMap.prototype.latLngToTile = function (latLng, z) { var worldCoordinate = this.fromLatLngToPoint(latLng); var pixelCoordinate = new google.maps.Point(worldCoordinate.x * Math.pow(2, z), worldCoordinate.y * Math.pow(2, z)); var tileCoordinate = new google.maps.Point(Math.floor(pixelCoordinate.x / this.getTileSize()), Math - .floor(pixelCoordinate.y / this.getTileSize())); + .floor(pixelCoordinate.y / this.getTileSize())); return tileCoordinate; }; /** * Register events responsible for click events */ -AbstractCustomMap.prototype.registerMapClickEvents = function() { +AbstractCustomMap.prototype.registerMapClickEvents = function () { // find top map (CustomMap) // @@ -313,30 +313,30 @@ AbstractCustomMap.prototype.registerMapClickEvents = function() { var self = this; // search event - google.maps.event.addListener(this.getGoogleMap(), 'click', function(mouseEvent) { + google.maps.event.addListener(this.getGoogleMap(), 'click', function (mouseEvent) { var point = self.fromLatLngToPoint(mouseEvent.latLng); var searchDb = customMap.getOverlayByName('search'); return searchDb.searchByCoordinates({ - modelId : self.getModel().getId(), - coordinates : point, - zoom : self.getGoogleMap().getZoom() + modelId: self.getModel().getId(), + coordinates: point, + zoom: self.getGoogleMap().getZoom() }).then(null, GuiConnector.alert); }); // select last clicked map - google.maps.event.addListener(this.getGoogleMap(), 'click', function(mouseEvent) { + google.maps.event.addListener(this.getGoogleMap(), 'click', function (mouseEvent) { customMap.setActiveSubmapId(self.getId()); customMap.setActiveSubmapClickCoordinates(self.fromLatLngToPoint(mouseEvent.latLng)); }); // select last clicked map - google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function(mouseEvent) { + google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function (mouseEvent) { customMap.setActiveSubmapId(self.getId()); customMap.setActiveSubmapClickCoordinates(self.fromLatLngToPoint(mouseEvent.latLng)); }); // prepare for image export - google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function() { + google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function () { var bounds = self.getGoogleMap().getBounds(); var polygon = ""; @@ -363,7 +363,7 @@ AbstractCustomMap.prototype.registerMapClickEvents = function() { }); // context menu event - google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function() { + google.maps.event.addListener(this.getGoogleMap(), 'rightclick', function () { self.getTopMap().getContextMenu().open(GuiConnector.xPos, GuiConnector.yPos); }); }; @@ -371,9 +371,9 @@ AbstractCustomMap.prototype.registerMapClickEvents = function() { /** * It toggle drawing manager used on the map: if it's on then it will turn it * off, if it's off it will turn it on - * + * */ -AbstractCustomMap.prototype._turnOnOffDrawing = function() { +AbstractCustomMap.prototype._turnOnOffDrawing = function () { if (this.isDrawingOn()) { this.turnOffDrawing(); } else { @@ -383,16 +383,16 @@ AbstractCustomMap.prototype._turnOnOffDrawing = function() { /** * Checks if the drawing manager for the map is on. - * + * */ -AbstractCustomMap.prototype.isDrawingOn = function() { +AbstractCustomMap.prototype.isDrawingOn = function () { return this._drawingManager !== null; }; /** * Turns on drawing manager on the map. */ -AbstractCustomMap.prototype.turnOnDrawing = function() { +AbstractCustomMap.prototype.turnOnDrawing = function () { if (this.isDrawingOn()) { logger.warn("Trying to turn on drawing manager, but it is already available."); return; @@ -400,28 +400,28 @@ AbstractCustomMap.prototype.turnOnDrawing = function() { var customMap = this.getTopMap(); var self = this; this._drawingManager = new google.maps.drawing.DrawingManager({ - drawingMode : google.maps.drawing.OverlayType.MARKER, - drawingControl : true, - drawingControlOptions : { - position : google.maps.ControlPosition.TOP_CENTER, - drawingModes : [ google.maps.drawing.OverlayType.POLYGON, ] + drawingMode: google.maps.drawing.OverlayType.MARKER, + drawingControl: true, + drawingControlOptions: { + position: google.maps.ControlPosition.TOP_CENTER, + drawingModes: [google.maps.drawing.OverlayType.POLYGON,] }, - markerOptions : { - icon : 'images/beachflag.png' + markerOptions: { + icon: 'images/beachflag.png' }, - circleOptions : { - fillColor : '#ffff00', - fillOpacity : 1, - strokeWeight : 5, - clickable : false, - editable : true, - zIndex : 1 + circleOptions: { + fillColor: '#ffff00', + fillOpacity: 1, + strokeWeight: 5, + clickable: false, + editable: true, + zIndex: 1 } }); this._drawingManager.setMap(this.getGoogleMap()); this._drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON); - google.maps.event.addListener(this._drawingManager, 'overlaycomplete', function(e) { + google.maps.event.addListener(this._drawingManager, 'overlaycomplete', function (e) { if (e.type !== google.maps.drawing.OverlayType.MARKER) { // Switch back to non-drawing mode after drawing a shape. self._drawingManager.setDrawingMode(null); @@ -430,7 +430,7 @@ AbstractCustomMap.prototype.turnOnDrawing = function() { // user mouses down on it. var newShape = e.overlay; newShape.type = e.type; - google.maps.event.addListener(newShape, 'rightclick', function(e) { + google.maps.event.addListener(newShape, 'rightclick', function (e) { // select map that was clicked customMap.setActiveSubmapId(self.getId()); @@ -448,25 +448,25 @@ AbstractCustomMap.prototype.turnOnDrawing = function() { /** * Sets selectedArea on this map. - * + * */ -AbstractCustomMap.prototype.setSelectedArea = function(area) { +AbstractCustomMap.prototype.setSelectedArea = function (area) { this._selectedArea = area; }; /** * Returns selectedArea on this map. - * + * */ -AbstractCustomMap.prototype.getSelectedArea = function() { +AbstractCustomMap.prototype.getSelectedArea = function () { return this._selectedArea; }; /** * Transforms google.maps.Polygon into string with coordinates. - * + * */ -AbstractCustomMap.prototype.areaToString = function(area) { +AbstractCustomMap.prototype.areaToString = function (area) { var len = area.getPath().length; var path = area.getPath(); var res = ""; @@ -480,7 +480,7 @@ AbstractCustomMap.prototype.areaToString = function(area) { /** * Removes selected area (polygon) from the map. */ -AbstractCustomMap.prototype._removeSelection = function() { +AbstractCustomMap.prototype._removeSelection = function () { if (this._selectedArea) { this._selectedArea.setMap(null); this._selectedArea = null; @@ -492,7 +492,7 @@ AbstractCustomMap.prototype._removeSelection = function() { /** * Turns off drawing manager on the map. */ -AbstractCustomMap.prototype.turnOffDrawing = function() { +AbstractCustomMap.prototype.turnOffDrawing = function () { if (this.isDrawingOn()) { this._drawingManager.setMap(null); this._drawingManager = null; @@ -505,10 +505,10 @@ AbstractCustomMap.prototype.turnOffDrawing = function() { * Returns top map. TODO implementation of this function should be probably * moved to Submap and CustomMap classes and here only abstract function * definition - * + * * @returns {CustomMap} */ -AbstractCustomMap.prototype.getTopMap = function() { +AbstractCustomMap.prototype.getTopMap = function () { logger.fatal("Not implemented"); }; @@ -518,7 +518,7 @@ AbstractCustomMap.prototype.getTopMap = function() { * visualized at the same time then index contains information where this new * layout is placed in the list (starting from 0) and length contains * information how many layouts we visualize in total. - * + * * @param layoutId * identifier of a layout * @param index @@ -528,9 +528,9 @@ AbstractCustomMap.prototype.getTopMap = function() { * @param length * number of layouts that are currently visualized */ -AbstractCustomMap.prototype._resizeSelectedLayout = function(layoutId, index, length) { +AbstractCustomMap.prototype._resizeSelectedLayout = function (layoutId, index, length) { var self = this; - return new Promise(function(resolve) { + return new Promise(function (resolve) { // if map is not initialized then don't perform this operation if (!self.initialized) { logger.debug("Model " + self.getId() + " not initialized"); @@ -554,7 +554,7 @@ AbstractCustomMap.prototype._resizeSelectedLayout = function(layoutId, index, le * the same time then index contains information where this new layout is placed * in the list (starting from 0) and length contains information how many * layouts we visualize in total. - * + * * @param layoutId * identifier of a layout * @param index @@ -564,10 +564,10 @@ AbstractCustomMap.prototype._resizeSelectedLayout = function(layoutId, index, le * @param length * number of layouts that are currently visualized */ -AbstractCustomMap.prototype._showSelectedLayout = function(layoutId, index, length) { +AbstractCustomMap.prototype._showSelectedLayout = function (layoutId, index, length) { var self = this; // if map is not initialized then don't perform this operation - return new Promise(function(resolve, reject) { + return new Promise(function (resolve, reject) { if (!self.initialized) { logger.debug("Model " + self.getId() + " not initialized"); resolve(); @@ -586,49 +586,64 @@ AbstractCustomMap.prototype._showSelectedLayout = function(layoutId, index, leng var layoutAliases; var layoutReactions; - return self.getTopMap().getModel().getLayoutDataById(layoutId).then(function(layout) { + return self.getTopMap().getModel().getLayoutDataById(layoutId).then(function (layout) { layoutAliases = layout.getAliases(); layoutReactions = layout.getReactions(); - return Promise.each(layoutAliases, function(layoutAlias) { + var identifiedElements = []; + var i; + for (i = 0; i < layoutAliases.length; i++) { + if (layoutAliases[i].getModelId() === self.getId()) { + identifiedElements.push(new IdentifiedElement(layoutAliases[i])); + } + } + var reactionIds = []; + for (i = 0; i < layoutReactions.length; i++) { + if (layoutReactions[i].getModelId() === self.getId()) { + identifiedElements.push(new IdentifiedElement(layoutReactions[i])); + } + } + return self.getModel().getByIdentifiedElements(identifiedElements, false); + }).then(function () { + return Promise.each(layoutAliases, function (layoutAlias) { if (layoutAlias.getModelId() === self.getId()) { var surface; var element; - return self.getModel().getAliasById(layoutAlias.getId()).then(function(aliasData) { + return self.getModel().getAliasById(layoutAlias.getId()).then(function (aliasData) { element = new IdentifiedElement(aliasData); return AliasSurface.create({ - overlayAlias : layoutAlias, - alias : aliasData, - map : self, - startX : startX, - endX : endX, - onClick : [ function() { + overlayAlias: layoutAlias, + alias: aliasData, + map: self, + startX: startX, + endX: endX, + onClick: [function () { return self._openInfoWindowForAlias(aliasData, surface.getGoogleMarker()); - }, function() { + }, function () { return self.getTopMap().callListeners("onBioEntityClick", element); - } ] + }] }); - }).then(function(result) { + }).then(function (result) { surface = result; self.selectedLayoutOverlays[layoutId].push(surface); }); } }); - }).then(function() { - return Promise.each(layoutReactions, function(layoutReaction) { + }).then(function () { + return Promise.each(layoutReactions, function (layoutReaction) { if (layoutReaction.getModelId() === self.getId()) { - return self.getModel().getReactionById(layoutReaction.getId()).then(function(reactionData) { + return self.getModel().getReactionById(layoutReaction.getId()).then(function (reactionData) { var element = new IdentifiedElement(reactionData); var surface = new ReactionSurface({ - layoutReaction : layoutReaction, - reaction : reactionData, - map : self, - onClick : [ function() { + layoutReaction: layoutReaction, + reaction: reactionData, + map: self, + onClick: [function () { return self._openInfoWindowForReaction(reactionData, surface.getGoogleMarker()); - }, function() { + }, function () { return self.getTopMap().callListeners("onBioEntityClick", element); - } ], - customized : (length === 1) + }], + customized: (length === 1) }); self.selectedLayoutOverlays[layoutId].push(surface); @@ -636,7 +651,7 @@ AbstractCustomMap.prototype._showSelectedLayout = function(layoutId, index, leng }); } }); - }).then(function() { + }).then(function () { resolve(); }).then(null, reject); }); @@ -644,11 +659,11 @@ AbstractCustomMap.prototype._showSelectedLayout = function(layoutId, index, leng /** * Hides all elements from layout. - * + * * @param layoutId * identifier of a layout */ -AbstractCustomMap.prototype._hideSelectedLayout = function(layoutId) { +AbstractCustomMap.prototype._hideSelectedLayout = function (layoutId) { // if map is not initialized then don't perform this operation if (!this.initialized) { logger.debug("Model " + this.getId() + " not initialized"); @@ -662,11 +677,11 @@ AbstractCustomMap.prototype._hideSelectedLayout = function(layoutId) { /** * Opens {@link AliasInfoWindow} for given alias. - * + * * @param aliasId * identifier of the alias */ -AbstractCustomMap.prototype._openInfoWindowForAlias = function(alias, googleMarker) { +AbstractCustomMap.prototype._openInfoWindowForAlias = function (alias, googleMarker) { var self = this; var infoWindow = this.getAliasInfoWindowById(alias.getId()); @@ -679,9 +694,9 @@ AbstractCustomMap.prototype._openInfoWindowForAlias = function(alias, googleMark return Promise.resolve(infoWindow); } else { self._aliasInfoWindow[alias.getId()] = new AliasInfoWindow({ - alias : alias, - map : self, - marker : googleMarker, + alias: alias, + map: self, + marker: googleMarker, }); return self._aliasInfoWindow[alias.getId()].init(); } @@ -690,15 +705,15 @@ AbstractCustomMap.prototype._openInfoWindowForAlias = function(alias, googleMark /** * Returns promise of a list of {@link LayoutAlias} information for a given * {@link Alias} in all currently visualized layouts. - * + * * @param aliasId * identifier of the {@link Alias} * @returns promise of an {Array} with list of {@link LayoutAlias} information * for a given {@link Alias} in all currently visualized layouts */ -AbstractCustomMap.prototype.getAliasVisibleLayoutsData = function(aliasId) { +AbstractCustomMap.prototype.getAliasVisibleLayoutsData = function (aliasId) { var self = this; - return self.getTopMap().getVisibleDataOverlays().then(function(visibleDataOverlays) { + return self.getTopMap().getVisibleDataOverlays().then(function (visibleDataOverlays) { var result = []; for (var i = 0; i < visibleDataOverlays.length; i++) { var layout = visibleDataOverlays[i]; @@ -711,16 +726,16 @@ AbstractCustomMap.prototype.getAliasVisibleLayoutsData = function(aliasId) { /** * Refresh content of all {@link AliasInfoWindow} in this map. */ -AbstractCustomMap.prototype._refreshInfoWindows = function() { +AbstractCustomMap.prototype._refreshInfoWindows = function () { var promises = []; - for ( var key in this._pointInfoWindow) { + for (var key in this._pointInfoWindow) { if (this._pointInfoWindow.hasOwnProperty(key)) { if (this._pointInfoWindow[key].isOpened()) { promises.push(this._pointInfoWindow[key].update()); } } } - for ( var aliasKey in this._aliasInfoWindow) { + for (var aliasKey in this._aliasInfoWindow) { if (this._aliasInfoWindow.hasOwnProperty(aliasKey)) { if (this._aliasInfoWindow[aliasKey].isOpened()) { promises.push(this._aliasInfoWindow[aliasKey].update()); @@ -733,11 +748,11 @@ AbstractCustomMap.prototype._refreshInfoWindows = function() { /** * Opens {@link ReactionInfoWindow} for given reaction identifier. - * + * * @param reactionId * reaction identifier */ -AbstractCustomMap.prototype._openInfoWindowForReaction = function(reaction, googleMarker) { +AbstractCustomMap.prototype._openInfoWindowForReaction = function (reaction, googleMarker) { var infoWindow = this.getReactionInfoWindowById(reaction.getId()); var self = this; if (infoWindow !== null && infoWindow !== undefined) { @@ -748,21 +763,21 @@ AbstractCustomMap.prototype._openInfoWindowForReaction = function(reaction, goog } return Promise.resolve(infoWindow); } else { - return self.getModel().getReactionById(reaction.getId()).then(function(reaction) { + return self.getModel().getReactionById(reaction.getId()).then(function (reaction) { infoWindow = new ReactionInfoWindow({ - reaction : reaction, - map : self, - marker : googleMarker, + reaction: reaction, + map: self, + marker: googleMarker, }); self._reactionInfoWindow[reaction.getId()] = infoWindow; return infoWindow.init(); - }).then(function() { + }).then(function () { return infoWindow; }); } }; -AbstractCustomMap.prototype._openInfoWindowForPoint = function(pointData, googleMarker) { +AbstractCustomMap.prototype._openInfoWindowForPoint = function (pointData, googleMarker) { var self = this; var infoWindow = this.getPointInfoWindowById(pointData.getId()); @@ -774,9 +789,9 @@ AbstractCustomMap.prototype._openInfoWindowForPoint = function(pointData, google } } else { infoWindow = new PointInfoWindow({ - point : pointData, - map : self, - marker : googleMarker, + point: pointData, + map: self, + marker: googleMarker, }); this._pointInfoWindow[pointData.getId()] = infoWindow; } @@ -785,11 +800,11 @@ AbstractCustomMap.prototype._openInfoWindowForPoint = function(pointData, google /** * Opens {@link AbstractInfoWindow} for a marker. - * + * * @param marker * marker for which we are opening window */ -AbstractCustomMap.prototype.returnInfoWindowForIdentifiedElement = function(element) { +AbstractCustomMap.prototype.returnInfoWindowForIdentifiedElement = function (element) { var markerId = element.getId(); if (element.getType() === "ALIAS") { return this.getAliasInfoWindowById(markerId); @@ -804,30 +819,30 @@ AbstractCustomMap.prototype.returnInfoWindowForIdentifiedElement = function(elem /** * Returns identifier. - * + * * @returns identifier */ -AbstractCustomMap.prototype.getId = function() { +AbstractCustomMap.prototype.getId = function () { return this.getModel().getId(); }; -AbstractCustomMap.prototype.getConfiguration = function() { +AbstractCustomMap.prototype.getConfiguration = function () { return this._configuration; }; -AbstractCustomMap.prototype.setConfiguration = function(configuration) { +AbstractCustomMap.prototype.setConfiguration = function (configuration) { this._configuration = configuration; }; -AbstractCustomMap.prototype._createMapChangedCallbacks = function() { +AbstractCustomMap.prototype._createMapChangedCallbacks = function () { var self = this; var sessionData = ServerConnector.getSessionData(self.getTopMap().getProject()); // listener for changing zoom level - google.maps.event.addListener(this.getGoogleMap(), 'zoom_changed', function() { + google.maps.event.addListener(this.getGoogleMap(), 'zoom_changed', function () { sessionData.setZoomLevel(self.getModel(), self.getGoogleMap().getZoom()); }); // listener for changing location of the map (moving left/reght/top/bottom - google.maps.event.addListener(this.getGoogleMap(), 'center_changed', function() { + google.maps.event.addListener(this.getGoogleMap(), 'center_changed', function () { var coord = self.getGoogleMap().getCenter(); var point = self.fromLatLngToPoint(coord); sessionData.setCenter(self.getModel(), point); @@ -836,62 +851,62 @@ AbstractCustomMap.prototype._createMapChangedCallbacks = function() { /** * Returns {@link ReactionInfoWindow} for given reaction identifier - * + * * @param reactionId * reaction identifier * @returns {@link ReactionInfoWindow} for given reaction identifier */ -AbstractCustomMap.prototype.getReactionInfoWindowById = function(reactionId) { +AbstractCustomMap.prototype.getReactionInfoWindowById = function (reactionId) { return this._reactionInfoWindow[reactionId]; }; /** * Returns {@link AliasInfoWindow} for given alias identifier - * + * * @param aliasId * alias identifier * @returns {@link AliasInfoWindow} for given alias identifier */ -AbstractCustomMap.prototype.getAliasInfoWindowById = function(aliasId) { +AbstractCustomMap.prototype.getAliasInfoWindowById = function (aliasId) { return this._aliasInfoWindow[aliasId]; }; /** * Returns {@link PointInfoWindow} for given point identifier - * + * * @param pointId * point identifier * @returns {@link PointInfoWindow} for given point identifier */ -AbstractCustomMap.prototype.getPointInfoWindowById = function(pointId) { +AbstractCustomMap.prototype.getPointInfoWindowById = function (pointId) { return this._pointInfoWindow[pointId]; }; -AbstractCustomMap.prototype.getModel = function() { +AbstractCustomMap.prototype.getModel = function () { return this._model; }; -AbstractCustomMap.prototype.setModel = function(model) { +AbstractCustomMap.prototype.setModel = function (model) { this._model = model; }; -AbstractCustomMap.prototype.getTileSize = function() { +AbstractCustomMap.prototype.getTileSize = function () { return this.getModel().getTileSize(); }; -AbstractCustomMap.prototype.getMinZoom = function() { +AbstractCustomMap.prototype.getMinZoom = function () { return this.getModel().getMinZoom(); }; -AbstractCustomMap.prototype.getMaxZoom = function() { +AbstractCustomMap.prototype.getMaxZoom = function () { return this.getModel().getMaxZoom(); }; -AbstractCustomMap.prototype.getLayouts = function() { +AbstractCustomMap.prototype.getLayouts = function () { return this.getModel().getLayouts(); }; -AbstractCustomMap.prototype.getPictureSize = function() { +AbstractCustomMap.prototype.getPictureSize = function () { return this.getModel().getPictureSize(); }; @@ -899,45 +914,45 @@ AbstractCustomMap.prototype.getPictureSize = function() { * Returns array containining elements that are presented on a specific layout * (set of google map objects representing lines/areas that are associated with * layout). - * + * * @returns {Array} containining elements that are presented on a specific * layout (set of google map objects representing lines/areas that are * associated with layout). */ -AbstractCustomMap.prototype.getSelectedLayoutOverlays = function() { +AbstractCustomMap.prototype.getSelectedLayoutOverlays = function () { return this.selectedLayoutOverlays; }; /** * Returns google.maps.map object used to representing data. - * + * * @returns google.maps.map object used to representing data */ -AbstractCustomMap.prototype.getGoogleMap = function() { +AbstractCustomMap.prototype.getGoogleMap = function () { return this._map; }; /** * Sets google.maps.map object used to representing data. - * + * */ -AbstractCustomMap.prototype.setGoogleMap = function(gmap) { +AbstractCustomMap.prototype.setGoogleMap = function (gmap) { this._map = gmap; }; -AbstractCustomMap.prototype.isMarkerOptimization = function() { +AbstractCustomMap.prototype.isMarkerOptimization = function () { return this._markerOptimization; }; -AbstractCustomMap.prototype.isBigLogo = function() { +AbstractCustomMap.prototype.isBigLogo = function () { return this._bigLogo; }; -AbstractCustomMap.prototype.isCustomTouchInterface = function() { +AbstractCustomMap.prototype.isCustomTouchInterface = function () { return this._customTouchInterface; }; -AbstractCustomMap.prototype.setDebug = function(debug) { +AbstractCustomMap.prototype.setDebug = function (debug) { if (debug !== undefined) { if (typeof debug !== "boolean") { logger.warn("param must be boolean"); @@ -946,32 +961,32 @@ AbstractCustomMap.prototype.setDebug = function(debug) { } }; -AbstractCustomMap.prototype.isDebug = function() { +AbstractCustomMap.prototype.isDebug = function () { return this._debug === true; }; -AbstractCustomMap.prototype.getTopLeftLatLng = function() { +AbstractCustomMap.prototype.getTopLeftLatLng = function () { return this.getModel().getTopLeftLatLng(); }; -AbstractCustomMap.prototype.getBottomRightLatLng = function() { +AbstractCustomMap.prototype.getBottomRightLatLng = function () { return this.getModel().getBottomRightLatLng(); }; -AbstractCustomMap.prototype.getElement = function() { +AbstractCustomMap.prototype.getElement = function () { return this._element; }; -AbstractCustomMap.prototype.setElement = function(element) { +AbstractCustomMap.prototype.setElement = function (element) { this._element = element; }; /** * Sets center point for google maps. - * + * * @param coordinates * new center point on map */ -AbstractCustomMap.prototype.setCenter = function(coordinates) { +AbstractCustomMap.prototype.setCenter = function (coordinates) { if (coordinates instanceof google.maps.Point) { coordinates = this.fromPointToLatLng(coordinates); } @@ -985,13 +1000,13 @@ AbstractCustomMap.prototype.setCenter = function(coordinates) { /** * Sets zoom level for google maps. - * + * * @param mapIdentifier * id of the model for which we change zoom level * @param zoom * new zoom level on map */ -AbstractCustomMap.prototype.setZoom = function(zoom) { +AbstractCustomMap.prototype.setZoom = function (zoom) { if (this.initialized) { return Promise.resolve(this.getGoogleMap().setZoom(zoom)); } else { @@ -1000,7 +1015,7 @@ AbstractCustomMap.prototype.setZoom = function(zoom) { } }; -AbstractCustomMap.prototype.fitBounds = function(markers) { +AbstractCustomMap.prototype.fitBounds = function (markers) { var self = this; var map = self.getGoogleMap(); if (map !== undefined) { diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index 0ad9cc8620eaeeb7886d310f8cc178f3ceb9571d..9d55d00fe139b738143d44e2d285dce0ffa644cc 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -28,7 +28,7 @@ var TouchMap = require('./TouchMap'); /** * Default constructor. - * + * * @param options * CustomMapOptions object representing all parameters needed for map * creation @@ -75,12 +75,12 @@ CustomMap.prototype.constructor = CustomMap; /** * This code must be run after the object is created. It requires to download * some data via promises. - * + * * @return promise with empty result */ -CustomMap.prototype.init = function() { +CustomMap.prototype.init = function () { var self = this; - return ServerConnector.getLogoImg().then(function(url) { + return ServerConnector.getLogoImg().then(function (url) { var logo2 = self.getControl(ControlType.LOGO_2_IMG); if (!/^(f|ht)tps?:\/\//i.test(url)) { url = GuiConnector.getImgPrefix() + url; @@ -92,7 +92,7 @@ CustomMap.prototype.init = function() { /** * Create submaps. */ -CustomMap.prototype.createSubmaps = function() { +CustomMap.prototype.createSubmaps = function () { this.submaps = []; for (var i = 0; i < this.getModel().getSubmodels().length; i++) { this.submaps.push(new Submap(this, this.getModel().getSubmodels()[i])); @@ -102,7 +102,7 @@ CustomMap.prototype.createSubmaps = function() { /** * Creates logo and put it on the google map. */ -CustomMap.prototype.createLogo = function() { +CustomMap.prototype.createLogo = function () { var logoControlDiv2 = document.createElement('DIV'); var logo2 = document.createElement('IMG'); logo2.style.cursor = 'pointer'; @@ -111,8 +111,8 @@ CustomMap.prototype.createLogo = function() { this.addControl(logo2); logoControlDiv2.appendChild(logo2); - google.maps.event.addDomListener(logo2, 'click', function() { - return ServerConnector.getLogoLink().then(function(url) { + google.maps.event.addDomListener(logo2, 'click', function () { + return ServerConnector.getLogoLink().then(function (url) { var win = window.open(url, '_blank'); win.focus(); }); @@ -130,7 +130,7 @@ CustomMap.prototype.createLogo = function() { this.addControl(logo); logoControlDiv.appendChild(logo); - google.maps.event.addDomListener(logo, 'click', function() { + google.maps.event.addDomListener(logo, 'click', function () { var win = window.open('http://wwwen.uni.lu/lcsb/', '_blank'); win.focus(); }); @@ -142,9 +142,9 @@ CustomMap.prototype.createLogo = function() { /** * Clear all AbstractDbOverlay. */ -CustomMap.prototype.clearDbOverlays = function() { +CustomMap.prototype.clearDbOverlays = function () { var promises = []; - for ( var overlayName in this.overlayCollections) { + for (var overlayName in this.overlayCollections) { if (this.overlayCollections.hasOwnProperty(overlayName)) { var collection = this.overlayCollections[overlayName]; promises.push(collection.clear()); @@ -155,11 +155,11 @@ CustomMap.prototype.clearDbOverlays = function() { /** * Open data overlay given in the parameter. - * + * * @param param * identifier or LayoutData identifing data overlay to open */ -CustomMap.prototype.openDataOverlay = function(param) { +CustomMap.prototype.openDataOverlay = function (param) { logger.debug("Opening data overlay: " + param); var self = this; @@ -186,14 +186,14 @@ CustomMap.prototype.openDataOverlay = function(param) { if (index === null) { throw new SecurityError("You have no privileges for selected overlay"); } else { - return overlayToOpen.init().then(function() { + return overlayToOpen.init().then(function () { if (overlayToOpen.getInputDataAvailable()) { if (self._selectedOverlays[identifier] === true) { logger.warn("Overlay " + identifier + " already selected"); return Promise.resolve(); } else { self._selectedOverlays[identifier] = true; - return self.getVisibleDataOverlays().then(function(visibleDataOverlays) { + return self.getVisibleDataOverlays().then(function (visibleDataOverlays) { var ids = []; for (var i = 0; i < visibleDataOverlays.length; i++) { ids.push(visibleDataOverlays[i].getId()); @@ -220,7 +220,7 @@ CustomMap.prototype.openDataOverlay = function(param) { /** * Returns data overlay that is used as a background. */ -CustomMap.prototype.getBackgroundDataOverlay = function() { +CustomMap.prototype.getBackgroundDataOverlay = function () { var identifier = parseInt(this.getGoogleMap().getMapTypeId()); for (var i = 0; i < this.getLayouts().length; i++) { var layout = this.getLayouts()[i]; @@ -233,54 +233,54 @@ CustomMap.prototype.getBackgroundDataOverlay = function() { /** * Register AbstractDbOverlay in the map. - * + * * @param dbOverlay * database overlay to be connected to the map */ -CustomMap.prototype.registerDbOverlay = function(dbOverlay) { +CustomMap.prototype.registerDbOverlay = function (dbOverlay) { var self = this; this.overlayCollections[dbOverlay.getName()] = dbOverlay; dbOverlay.markers = { - ALIAS : [], - REACTION : [], - POINT : [] + ALIAS: [], + REACTION: [], + POINT: [] }; dbOverlay.mapOverlays = { - ALIAS : [], - REACTION : [], - POINT : [] + ALIAS: [], + REACTION: [], + POINT: [] }; if (dbOverlay.getName() === "search" || dbOverlay.getName() === "user") { - dbOverlay.addListener("onSearch", function(e) { + dbOverlay.addListener("onSearch", function (e) { return self.renderOverlayCollection({ - overlayCollection : dbOverlay, - fitBounds : e.arg.fitBounds + overlayCollection: dbOverlay, + fitBounds: e.arg.fitBounds }); }); } if (dbOverlay.getName() === "drug" || dbOverlay.getName() === "chemical" || dbOverlay.getName() === "mirna") { - dbOverlay.addListener("onSearch", function(e) { + dbOverlay.addListener("onSearch", function (e) { return self.renderOverlayCollection({ - overlayCollection : dbOverlay, - fitBounds : e.arg.fitBounds + overlayCollection: dbOverlay, + fitBounds: e.arg.fitBounds }); }); - dbOverlay.addListener("onTargetVisibilityChange", function() { + dbOverlay.addListener("onTargetVisibilityChange", function () { return self.renderOverlayCollection({ - overlayCollection : dbOverlay, - fitBounds : false + overlayCollection: dbOverlay, + fitBounds: false }); }); } if (dbOverlay.getName() === "comment") { - var listener = function() { + var listener = function () { return self.renderOverlayCollection({ - overlayCollection : dbOverlay, - fitBounds : false + overlayCollection: dbOverlay, + fitBounds: false }); }; dbOverlay.addListener("onRefresh", listener); @@ -291,10 +291,10 @@ CustomMap.prototype.registerDbOverlay = function(dbOverlay) { /** * Refresh comment list. - * + * * @return promise that is resolved when comment list is refreshed */ -CustomMap.prototype.refreshComments = function() { +CustomMap.prototype.refreshComments = function () { var self = this; var commentDbOverlay = self.getOverlayByName("comment"); @@ -311,7 +311,7 @@ CustomMap.prototype.refreshComments = function() { /** * Turns on/off drawing module on google maps. */ -CustomMap.prototype.turnOnOffDrawing = function() { +CustomMap.prototype.turnOnOffDrawing = function () { var model = this.getSubmapById(this.getActiveSubmapId()); if (model !== undefined) { model._turnOnOffDrawing(); @@ -320,24 +320,24 @@ CustomMap.prototype.turnOnOffDrawing = function() { } }; -CustomMap.prototype.refreshMarkers = function() { +CustomMap.prototype.refreshMarkers = function (force) { logger.debug("Refresh Markers: "); - for ( var overlayName in this.overlayCollections) { + for (var overlayName in this.overlayCollections) { if (this.overlayCollections.hasOwnProperty(overlayName)) { var collection = this.overlayCollections[overlayName]; - this.refreshOverlayMarkers(collection); + this.refreshOverlayMarkers(collection, force); } } }; -CustomMap.prototype.refreshOverlayMarkers = function(overlay) { +CustomMap.prototype.refreshOverlayMarkers = function (overlay, force) { logger.debug("Refresh overlay: " + overlay.name); - if (!this.isMarkerOptimization()) { - for ( var markerType in overlay.markers) { + if (!this.isMarkerOptimization() || force) { + for (var markerType in overlay.markers) { if (overlay.markers.hasOwnProperty(markerType)) { var markers = overlay.markers[markerType]; - for ( var key in markers) { + for (var key in markers) { if (markers.hasOwnProperty(key)) { var marker = markers[key]; marker.hide(); @@ -352,11 +352,11 @@ CustomMap.prototype.refreshOverlayMarkers = function(overlay) { /** * Returns HTML div that is attached to jQuery dialog that should be used for * opening submap. - * + * * @param id * identifier of the submap */ -CustomMap.prototype.getSubmapDialogDiv = function(id) { +CustomMap.prototype.getSubmapDialogDiv = function (id) { var dialogDiv = this._dialogs[id]; if (dialogDiv === undefined) { @@ -366,7 +366,7 @@ CustomMap.prototype.getSubmapDialogDiv = function(id) { this._dialogs[id] = dialogDiv; $(dialogDiv).dialog({ - autoOpen : false + autoOpen: false }); } return dialogDiv; @@ -375,7 +375,7 @@ CustomMap.prototype.getSubmapDialogDiv = function(id) { /** * Opens a dialog with a submodel. */ -CustomMap.prototype.openSubmap = function(id) { +CustomMap.prototype.openSubmap = function (id) { var self = this; var submap = self.getSubmapById(id); if (submap === null) { @@ -388,12 +388,12 @@ CustomMap.prototype.openSubmap = function(id) { submap.open(dialogDiv); // we have to perform it on top map, because on submaps id is different - return this.openDataOverlay(self.getGoogleMap().getMapTypeId()).then(function() { + return this.openDataOverlay(self.getGoogleMap().getMapTypeId()).then(function () { // now we have to visualize layouts var layouts = []; // get list of layouts - for ( var key in self._selectedOverlays) { + for (var key in self._selectedOverlays) { if (self._selectedOverlays.hasOwnProperty(key) && self._selectedOverlays[key] === true) { layouts.push(key); } @@ -405,14 +405,14 @@ CustomMap.prototype.openSubmap = function(id) { submap._showSelectedLayout(layoutId, i, layouts.length); } if (!wasInitialized) { - return self.refreshMarkers(); + return self.refreshMarkers(true); } }); } }; -CustomMap.prototype.customizeGoogleMapView = function(div) { +CustomMap.prototype.customizeGoogleMapView = function (div) { var mapOptions = this.creatMapOptions(); this.setGoogleMap(new google.maps.Map(div, mapOptions)); this.setupLayouts(); @@ -440,7 +440,7 @@ CustomMap.prototype.customizeGoogleMapView = function(div) { * Creates listeners for google.maps.Map object that will actualize the data in * user session. */ -CustomMap.prototype.createMapChangedCallbacks = function() { +CustomMap.prototype.createMapChangedCallbacks = function () { this._createMapChangedCallbacks(); var self = this; var sessionData = ServerConnector.getSessionData(self.getProject()); @@ -455,7 +455,7 @@ CustomMap.prototype.createMapChangedCallbacks = function() { } // listener for changing type of layout - google.maps.event.addListener(self.getGoogleMap(), 'maptypeid_changed', function() { + google.maps.event.addListener(self.getGoogleMap(), 'maptypeid_changed', function () { sessionData.setSelectedBackgroundOverlay(self.getGoogleMap().getMapTypeId()); }); @@ -477,12 +477,12 @@ CustomMap.prototype.createMapChangedCallbacks = function() { /** * Returns submap (or this map) by id. - * + * * @param identifier * identifier of the submap * @returns submap (or this map) with given identfier of the model */ -CustomMap.prototype.getSubmapById = function(identifier) { +CustomMap.prototype.getSubmapById = function (identifier) { identifier = parseInt(identifier); if (this.getId() === identifier) { return this; @@ -496,7 +496,7 @@ CustomMap.prototype.getSubmapById = function(identifier) { return null; }; -CustomMap.prototype.removeSelection = function() { +CustomMap.prototype.removeSelection = function () { var model = this.getSubmapById(this.getActiveSubmapId()); if (model !== null) { model._removeSelection(); @@ -507,12 +507,12 @@ CustomMap.prototype.removeSelection = function() { /** * Removes layout from visualization. - * + * * @param identifier * identifier of layout to remove - * + * */ -CustomMap.prototype.removeSelectedLayout = function(identifier) { +CustomMap.prototype.removeSelectedLayout = function (identifier) { var self = this; logger.debug("Removing layout: " + identifier); @@ -521,9 +521,9 @@ CustomMap.prototype.removeSelectedLayout = function(identifier) { return Promise.resolve(); } else { self._selectedOverlays[identifier] = false; - return self.refreshSelectedLayouts().then(function() { + return self.refreshSelectedLayouts().then(function () { return self.getVisibleDataOverlays(); - }).then(function(visibleDataOverlays) { + }).then(function (visibleDataOverlays) { var ids = []; for (var i = 0; i < visibleDataOverlays.length; i++) { ids.push(visibleDataOverlays[i].getId()); @@ -537,10 +537,10 @@ CustomMap.prototype.removeSelectedLayout = function(identifier) { /** * Refresh visualization of selected layouts. */ -CustomMap.prototype.refreshSelectedLayouts = function() { +CustomMap.prototype.refreshSelectedLayouts = function () { logger.debug("Refreshing layouts"); var self = this; - return self.getVisibleDataOverlays().then(function(visibleDataOverlays) { + return self.getVisibleDataOverlays().then(function (visibleDataOverlays) { // show layouts that should be visualized (resize or show them) var promises = []; for (var i = 0; i < visibleDataOverlays.length; i++) { @@ -552,9 +552,9 @@ CustomMap.prototype.refreshSelectedLayouts = function() { promises.push(self.showSelectedLayout(layoutId, i, visibleDataOverlays.length)); } } - return Promise.all(promises).then(function() { + return Promise.all(promises).then(function () { // remove layouts that were - for ( var key in self.selectedLayoutOverlays) { + for (var key in self.selectedLayoutOverlays) { if (!self._selectedOverlays.hasOwnProperty(key) || self._selectedOverlays[key] === false) { if (self.layoutContainsOverlays(key)) { self.hideSelectedLayout(key); @@ -568,11 +568,11 @@ CustomMap.prototype.refreshSelectedLayouts = function() { /** * Hides layout from the map and all submaps - * + * * @param layoutId * identifier of a layout to hide */ -CustomMap.prototype.hideSelectedLayout = function(layoutId) { +CustomMap.prototype.hideSelectedLayout = function (layoutId) { this._hideSelectedLayout(layoutId); for (var i = 0; i < this.submaps.length; i++) { this.submaps[i]._hideSelectedLayout(layoutId); @@ -582,7 +582,7 @@ CustomMap.prototype.hideSelectedLayout = function(layoutId) { /** * Resize(refresh) layout on the map and all submaps. Resizing should be called * when number of layouts to visualize change. - * + * * @param layoutId * identifier of layout to refresh * @param index @@ -590,7 +590,7 @@ CustomMap.prototype.hideSelectedLayout = function(layoutId) { * @param length * number of layouts that we currently visualize */ -CustomMap.prototype.resizeSelectedLayout = function(layoutId, index, length) { +CustomMap.prototype.resizeSelectedLayout = function (layoutId, index, length) { logger.debug("Resize layout: " + layoutId); var promises = []; promises.push(this._resizeSelectedLayout(layoutId, index, length)); @@ -602,7 +602,7 @@ CustomMap.prototype.resizeSelectedLayout = function(layoutId, index, length) { /** * Show layout on the map and all submaps. - * + * * @param layoutId * identifier of layout to show * @param index @@ -610,7 +610,7 @@ CustomMap.prototype.resizeSelectedLayout = function(layoutId, index, length) { * @param length * number of layouts that we currently visualize */ -CustomMap.prototype.showSelectedLayout = function(layoutId, index, length) { +CustomMap.prototype.showSelectedLayout = function (layoutId, index, length) { logger.debug("Resize layout: " + layoutId); var promises = []; promises.push(this._showSelectedLayout(layoutId, index, length)); @@ -624,13 +624,13 @@ CustomMap.prototype.showSelectedLayout = function(layoutId, index, length) { /** * This method checks if the layout contains any overlays (like AliasSurface or * ReactionSurface) that is currently visible on the map. - * + * * @param layoutId * identifier of the layout * @returns {Boolean}: <code>true</code> if the layout contains overlays to * visualize, <code>false</code> otherwise */ -CustomMap.prototype.layoutContainsOverlays = function(layoutId) { +CustomMap.prototype.layoutContainsOverlays = function (layoutId) { // first, check top map if (this.selectedLayoutOverlays.hasOwnProperty(layoutId) && this.selectedLayoutOverlays[layoutId].length > 0) { @@ -641,7 +641,7 @@ CustomMap.prototype.layoutContainsOverlays = function(layoutId) { for (var i = 0; i < this.submaps.length; i++) { if (this.submaps[i].initialized) { if (this.submaps[i].selectedLayoutOverlays.hasOwnProperty(layoutId) - && this.submaps[i].selectedLayoutOverlays[layoutId].length > 0) { + && this.submaps[i].selectedLayoutOverlays[layoutId].length > 0) { return true; } } @@ -652,7 +652,7 @@ CustomMap.prototype.layoutContainsOverlays = function(layoutId) { /** * Refresh content of all {@link AliasInfoWindow} in this map and all submaps. */ -CustomMap.prototype.refreshInfoWindows = function() { +CustomMap.prototype.refreshInfoWindows = function () { var promises = []; promises.push(this._refreshInfoWindows()); // now check all submaps @@ -664,13 +664,13 @@ CustomMap.prototype.refreshInfoWindows = function() { /** * Opens {@link AliasInfoWindow} for an {@link Alias} in a given model/submodel. - * + * * @param aliasId * identifier of {@link Alias} * @param modelId * identifier of {@link AbstractCustomMap} */ -CustomMap.prototype.openInfoWindowForAlias = function(alias, marker) { +CustomMap.prototype.openInfoWindowForAlias = function (alias, marker) { logger.debug("Opening info window for alias: " + alias.getId() + ", model: " + alias.getModelId()); var submap = this.getSubmapById(alias.getModelId()); return submap._openInfoWindowForAlias(alias, marker); @@ -678,14 +678,14 @@ CustomMap.prototype.openInfoWindowForAlias = function(alias, marker) { /** * Renders markers, lines, etc. for elements highlighted in OverlayCollection. - * + * * @param overlayCollection * {@link OverlayCollection} to be processed * @param fitBounds * <code>true</code> if the borders should fit bounds after creating * all elements */ -CustomMap.prototype.renderOverlayCollection = function(params) { +CustomMap.prototype.renderOverlayCollection = function (params) { var self = this; var fitBounds = params.fitBounds; var overlayCollection = params.overlayCollection; @@ -693,33 +693,52 @@ CustomMap.prototype.renderOverlayCollection = function(params) { var elements; var markers = []; - return overlayCollection.getIdentifiedElements().then(function(identifiedElements) { + return overlayCollection.getIdentifiedElements().then(function (identifiedElements) { elements = identifiedElements; - return Promise.each(elements, function(element) { + var elementsByModelId = []; + var modelId; + + for (var i = 0; i < elements.length; i++) { + var element = elements[i]; + modelId = element.getModelId(); + if (elementsByModelId[modelId] === undefined) { + elementsByModelId[modelId] = []; + } + elementsByModelId[modelId].push(element); + } + var promises = []; + for (modelId in elementsByModelId) { + if (elementsByModelId.hasOwnProperty(modelId)) { + promises.push(self.getModel().getSubmodelById(parseInt(modelId)).getByIdentifiedElements(elementsByModelId[modelId], false)); + } + } + return Promise.all(promises); + }).then(function () { + return Promise.each(elements, function (element) { var icon = element.getIcon(); if (icon !== null && icon !== undefined) { - return self.createMarkerForDbOverlay(element, overlayCollection).then(function(marker) { + return self.createMarkerForDbOverlay(element, overlayCollection).then(function (marker) { markers.push(marker); }); } else { - return self.createSurfaceForDbOverlay(element, overlayCollection).then(function(mapOverlay) { + return self.createSurfaceForDbOverlay(element, overlayCollection).then(function (mapOverlay) { markers.push(mapOverlay); }); } }); - }).then(function() { + }).then(function () { self.removeUnmodifiedMarkersAndSurfaces(markers, overlayCollection); - return Promise.each(elements, function(element) { + return Promise.each(elements, function (element) { var infoWindow = self.getInfoWindowForIdentifiedElement(element); if (infoWindow !== null && infoWindow !== undefined) { - return self.retrieveOverlayDetailDataForElement(element, infoWindow.getOverlayFullViewArray()).then(function() { + return self.retrieveOverlayDetailDataForElement(element, infoWindow.getOverlayFullViewArray()).then(function () { return self.updateInfoWindowForIdentifiedElement(element); }); } }); - }).then(function() { + }).then(function () { if (elements.length > 0 && fitBounds) { self.fitBounds(markers); for (var j = 0; j < self.submaps.length; j++) { @@ -729,16 +748,16 @@ CustomMap.prototype.renderOverlayCollection = function(params) { }); }; -CustomMap.prototype.removeUnmodifiedMarkersAndSurfaces = function(modifiedMarkersAndSurfaces, dbOverlay) { +CustomMap.prototype.removeUnmodifiedMarkersAndSurfaces = function (modifiedMarkersAndSurfaces, dbOverlay) { var modifiedMarkers = { - "ALIAS" : [], - "REACTION" : [], - "POINT" : [], + "ALIAS": [], + "REACTION": [], + "POINT": [], }; var modifiedSurfaces = { - "ALIAS" : [], - "REACTION" : [], - "POINT" : [], + "ALIAS": [], + "REACTION": [], + "POINT": [], }; for (var i = 0; i < modifiedMarkersAndSurfaces.length; i++) { @@ -781,17 +800,17 @@ CustomMap.prototype.removeUnmodifiedMarkersAndSurfaces = function(modifiedMarker /** * Opens {@link AbstractInfoWindow} for a marker. - * + * * @param marker * {@link AbstractMarker} for which info window should be opened */ -CustomMap.prototype.openInfoWindowForIdentifiedElement = function(element, marker) { +CustomMap.prototype.openInfoWindowForIdentifiedElement = function (element, marker) { var self = this; var submap = self.getSubmapById(element.getModelId()); logger.debug(element + ": Opening info window"); // open AliasInfoWindow in a right model - return submap._openInfoWindowForIdentifiedElement(element, marker).then(function() { + return submap._openInfoWindowForIdentifiedElement(element, marker).then(function () { var infoWindow = submap.returnInfoWindowForIdentifiedElement(element); return self.retrieveOverlayDetailDataForElement(element, infoWindow.getOverlayFullViewArray()); }); @@ -801,17 +820,17 @@ CustomMap.prototype.openInfoWindowForIdentifiedElement = function(element, marke /** * Sends requestes to download detailed data about element in all * {@link OverlayCollection}. - * + * * @param element * element for which we want to have detailed information */ -CustomMap.prototype.retrieveOverlayDetailDataForElement = function(element, general) { +CustomMap.prototype.retrieveOverlayDetailDataForElement = function (element, general) { var promises = []; if (general === undefined) { logger.warn("general param is undefined!"); general = []; } - for ( var overlayName in this.overlayCollections) { + for (var overlayName in this.overlayCollections) { if (this.overlayCollections.hasOwnProperty(overlayName)) { var overlay = this.overlayCollections[overlayName]; @@ -830,11 +849,11 @@ CustomMap.prototype.retrieveOverlayDetailDataForElement = function(element, gene /** * Updates info window identified by element given as a parameter. - * + * * @param identifiedElement * element for which info window should be updated */ -CustomMap.prototype.updateInfoWindowForIdentifiedElement = function(identifiedElement) { +CustomMap.prototype.updateInfoWindowForIdentifiedElement = function (identifiedElement) { var infoWindow = this.getInfoWindowForIdentifiedElement(identifiedElement); if (infoWindow === null || infoWindow === undefined) { return Promise.resolve(); @@ -845,7 +864,7 @@ CustomMap.prototype.updateInfoWindowForIdentifiedElement = function(identifiedEl /** * Returns data from all {@link OverlayCollection} for a given alias. - * + * * @param alias * {@link Alias} for which overlay data will be returned * @param general @@ -853,14 +872,14 @@ CustomMap.prototype.updateInfoWindowForIdentifiedElement = function(identifiedEl * availble right now in the overlay * @returns data from all {@link OverlayCollection} for a given alias */ -CustomMap.prototype.getOverlayDataForAlias = function(alias, general) { +CustomMap.prototype.getOverlayDataForAlias = function (alias, general) { var identifiedElement = new IdentifiedElement(alias); return this.getOverlayDataForIdentifiedElement(identifiedElement, general); }; /** * Returns data from all {@link OverlayCollection} for a given reaction. - * + * * @param reaction * {@link Reaction} for which overlay data will be returned * @param general @@ -868,20 +887,20 @@ CustomMap.prototype.getOverlayDataForAlias = function(alias, general) { * availble right now in the overlay * @returns data from all {@link OverlayCollection} for a given alias */ -CustomMap.prototype.getOverlayDataForReaction = function(reaction, general) { +CustomMap.prototype.getOverlayDataForReaction = function (reaction, general) { var identifiedElement = new IdentifiedElement(reaction); return this.getOverlayDataForIdentifiedElement(identifiedElement, general); }; /** * Returns data from all {@link OverlayCollection} for a given {@link PointData} - * + * * @param point * {@link PointData} for which overlay data will be returned * @returns data from all {@link OverlayCollection} for a given * {@link PointData} */ -CustomMap.prototype.getOverlayDataForPoint = function(point, general) { +CustomMap.prototype.getOverlayDataForPoint = function (point, general) { var identifiedElement = new IdentifiedElement(point); return this.getOverlayDataForIdentifiedElement(identifiedElement, general); }; @@ -889,20 +908,20 @@ CustomMap.prototype.getOverlayDataForPoint = function(point, general) { /** * Returns data from all {@link OverlayCollection} for element identified by the * parameter - * + * * @param identifiedElement * {@link IdentifiedElement} for which overlay data will be returned * @returns data from all {@link OverlayCollection} for a given * {@link IdentifiedElement} */ -CustomMap.prototype.getOverlayDataForIdentifiedElement = function(identifiedElement, general) { +CustomMap.prototype.getOverlayDataForIdentifiedElement = function (identifiedElement, general) { if (general === undefined) { logger.warn("general parameter must be defined"); general = []; } var promises = []; var overlays = []; - for ( var overlayName in this.overlayCollections) { + for (var overlayName in this.overlayCollections) { if (this.overlayCollections.hasOwnProperty(overlayName)) { var overlay = this.overlayCollections[overlayName]; if (overlay.allowGeneralSearch() || overlay.allowSearchById()) { @@ -913,29 +932,29 @@ CustomMap.prototype.getOverlayDataForIdentifiedElement = function(identifiedElem } overlays.push(overlay); promises.push(overlay.getDetailDataByIdentifiedElement(identifiedElement, !overlay.allowSearchById() - || generalFlag)); + || generalFlag)); } } } - return Promise.all(promises).then(function(values) { + return Promise.all(promises).then(function (values) { var result = []; for (var i = 0; i < values.length; i++) { result.push({ - overlay : overlays[i], - data : values[i] + overlay: overlays[i], + data: values[i] }); } return result; }); }; -CustomMap.prototype.getOverlayByName = function(name) { +CustomMap.prototype.getOverlayByName = function (name) { return this.overlayCollections[name]; }; -CustomMap.prototype.getDbOverlays = function() { +CustomMap.prototype.getDbOverlays = function () { var result = []; - for ( var overlayName in this.overlayCollections) { + for (var overlayName in this.overlayCollections) { if (this.overlayCollections.hasOwnProperty(overlayName)) { result.push(this.overlayCollections[overlayName]); } @@ -945,13 +964,13 @@ CustomMap.prototype.getDbOverlays = function() { /** * Returns {@link AbstractInfoWindow} for element identified by the parameter. - * + * * @param identifiedElement * {@link IdentifiedElement} that determines for which element we want * {@link AbstractInfoWindow} * @returns {@link AbstractInfoWindow} for element identified by the parameter */ -CustomMap.prototype.getInfoWindowForIdentifiedElement = function(identifiedElement) { +CustomMap.prototype.getInfoWindowForIdentifiedElement = function (identifiedElement) { var model = this.getSubmapById(identifiedElement.modelId); var infoWindow = null; if (identifiedElement.type === "ALIAS") { @@ -966,25 +985,25 @@ CustomMap.prototype.getInfoWindowForIdentifiedElement = function(identifiedEleme return infoWindow; }; -CustomMap.prototype.getActiveSubmapId = function() { +CustomMap.prototype.getActiveSubmapId = function () { return this._activeSubmapId; }; -CustomMap.prototype.setActiveSubmapId = function(submapId) { +CustomMap.prototype.setActiveSubmapId = function (submapId) { this._activeSubmapId = submapId; }; -CustomMap.prototype.setActiveSubmapClickCoordinates = function(coordinates) { +CustomMap.prototype.setActiveSubmapClickCoordinates = function (coordinates) { if (!(coordinates instanceof google.maps.Point)) { throw new Error("Coordinates must be provided as google.maps.Point object, but found: " + coordinates); } this._activeSubmapCoordinates = coordinates; }; -CustomMap.prototype.getActiveSubmapClickCoordinates = function() { +CustomMap.prototype.getActiveSubmapClickCoordinates = function () { return this._activeSubmapCoordinates; }; -CustomMap.prototype.getReferenceGenome = function(type, version) { +CustomMap.prototype.getReferenceGenome = function (type, version) { var self = this; if (self.getProject().getOrganism() === undefined) { return Promise.resolve(new ReferenceGenome(null)); @@ -995,10 +1014,10 @@ CustomMap.prototype.getReferenceGenome = function(type, version) { } if (self._referenceGenome[type][version] === undefined) { return ServerConnector.getReferenceGenome({ - type : type, - version : version, - organism : self.getProject().getOrganism().getResource(), - }).then(function(genome) { + type: type, + version: version, + organism: self.getProject().getOrganism().getResource(), + }).then(function (genome) { self._referenceGenome[type][version] = genome; return genome; }); @@ -1007,22 +1026,22 @@ CustomMap.prototype.getReferenceGenome = function(type, version) { } }; -CustomMap.prototype.getTopMap = function() { +CustomMap.prototype.getTopMap = function () { return this; }; -CustomMap.prototype.setProject = function(project) { +CustomMap.prototype.setProject = function (project) { this._project = project; }; -CustomMap.prototype.getProject = function() { +CustomMap.prototype.getProject = function () { return this._project; }; -CustomMap.prototype.getTopOverviewImage = function() { +CustomMap.prototype.getTopOverviewImage = function () { return this.getProject().getTopOverviewImage(); }; -CustomMap.prototype.addControl = function(element) { +CustomMap.prototype.addControl = function (element) { if (this._controls[element.id] !== undefined) { throw new Error("Element with id " + element.id + " already added to controls"); } @@ -1032,52 +1051,52 @@ CustomMap.prototype.addControl = function(element) { this._controls[element.id] = element; }; -CustomMap.prototype.getControl = function(type) { +CustomMap.prototype.getControl = function (type) { if (ControlType[type] === undefined) { throw new Error("Unknown control type: " + type); } return this._controls[type]; }; -CustomMap.prototype.setCommentDialog = function(commentDialog) { +CustomMap.prototype.setCommentDialog = function (commentDialog) { this._commentDialog = commentDialog; }; -CustomMap.prototype.getCommentDialog = function() { +CustomMap.prototype.getCommentDialog = function () { return this._commentDialog; }; -CustomMap.prototype.setContextMenu = function(contextMenu) { +CustomMap.prototype.setContextMenu = function (contextMenu) { this._contextMenu = contextMenu; }; -CustomMap.prototype.getContextMenu = function() { +CustomMap.prototype.getContextMenu = function () { return this._contextMenu; }; -CustomMap.prototype.setSelectionContextMenu = function(selectionContextMenu) { +CustomMap.prototype.setSelectionContextMenu = function (selectionContextMenu) { this._selectionContextMenu = selectionContextMenu; }; -CustomMap.prototype.getSelectionContextMenu = function() { +CustomMap.prototype.getSelectionContextMenu = function () { return this._selectionContextMenu; }; -CustomMap.prototype.openCommentDialog = function() { +CustomMap.prototype.openCommentDialog = function () { var self = this; return ServerConnector.getClosestElementsByCoordinates({ - modelId : this.getActiveSubmapId(), - coordinates : this.getActiveSubmapClickCoordinates() - }).then(function(elements) { + modelId: this.getActiveSubmapId(), + coordinates: this.getActiveSubmapClickCoordinates() + }).then(function (elements) { var commentDialog = self.getCommentDialog(); if (commentDialog === undefined) { var div = Functions.createElement({ - type : "div" + type: "div" }); self.getElement().appendChild(div); commentDialog = new CommentDialog({ - element : div, - customMap : self + element: div, + customMap: self }); self.setCommentDialog(commentDialog); } @@ -1087,7 +1106,7 @@ CustomMap.prototype.openCommentDialog = function() { }); }; -CustomMap.prototype.fetchIdentifiedElements = function(elements, complete) { +CustomMap.prototype.fetchIdentifiedElements = function (elements, complete) { var modelIds = []; var modelElements = []; var i; @@ -1109,10 +1128,10 @@ CustomMap.prototype.fetchIdentifiedElements = function(elements, complete) { }; -CustomMap.prototype.refreshSearchAutocomplete = function() { +CustomMap.prototype.refreshSearchAutocomplete = function () { var self = this; self._searchAutocomplete = []; - return ServerConnector.getSuggestedQueryList().then(function(queries) { + return ServerConnector.getSuggestedQueryList().then(function (queries) { for (var i = 0; i < queries.length; i++) { var mainString = queries[i]; for (var j = 0; j < mainString.length; j++) { @@ -1137,7 +1156,7 @@ CustomMap.prototype.refreshSearchAutocomplete = function() { }); }; -CustomMap.prototype.getSearchAutocomplete = function(query) { +CustomMap.prototype.getSearchAutocomplete = function (query) { if (this._searchAutocomplete === undefined) { this.refreshSearchAutocomplete(); return []; @@ -1146,15 +1165,15 @@ CustomMap.prototype.getSearchAutocomplete = function(query) { return this._searchAutocomplete[query]; }; -CustomMap.prototype.setSelectedPolygon = function(polygonData) { +CustomMap.prototype.setSelectedPolygon = function (polygonData) { this._selectedPolygon = polygonData; }; -CustomMap.prototype.getSelectedPolygon = function() { +CustomMap.prototype.getSelectedPolygon = function () { return this._selectedPolygon; }; -CustomMap.prototype.getDistance = function(params) { +CustomMap.prototype.getDistance = function (params) { var self = this; var ie = params.element; var model = self.getSubmapById(ie.getModelId()).getModel(); @@ -1164,21 +1183,21 @@ CustomMap.prototype.getDistance = function(params) { var x = params.coordinates.x; var y = params.coordinates.y; var p1 = new google.maps.Point(x, y); - return model.getByIdentifiedElement(ie).then(function(element) { + return model.getByIdentifiedElement(ie).then(function (element) { if (element instanceof Alias) { if (element.getX() <= x && element.getX() + element.getWidth() >= x) { if (element.getY() <= y && element.getY() + element.getHeight() >= y) { return 0; } else { return Math.min( // - Math.abs(element.getY() - y), // - Math.abs(element.getY() + element.getHeight() - y) // + Math.abs(element.getY() - y), // + Math.abs(element.getY() + element.getHeight() - y) // ); } } else if (element.getY() <= y && element.getY() + element.getHeight() >= y) { return Math.min( // - Math.abs(element.getX() - x), // - Math.abs(element.getX() + element.getWidth() - x) // + Math.abs(element.getX() - x), // + Math.abs(element.getX() + element.getWidth() - x) // ); } else { var elementX = element.getX(); @@ -1186,10 +1205,10 @@ CustomMap.prototype.getDistance = function(params) { var elementWidth = element.getWidth(); var elementHeight = element.getHeight(); return Math.min( // - Functions.distance(p1, new google.maps.Point(elementX, y)), // - Functions.distance(p1, new google.maps.Point(elementX + elementWidth, elementY)), // - Functions.distance(p1, new google.maps.Point(elementX, elementY + elementHeight)), // - Functions.distance(p1, new google.maps.Point(elementX + elementWidth, elementY + elementHeight)) // + Functions.distance(p1, new google.maps.Point(elementX, y)), // + Functions.distance(p1, new google.maps.Point(elementX + elementWidth, elementY)), // + Functions.distance(p1, new google.maps.Point(elementX, elementY + elementHeight)), // + Functions.distance(p1, new google.maps.Point(elementX + elementWidth, elementY + elementHeight)) // ); } } else if (element instanceof Reaction) { @@ -1205,7 +1224,7 @@ CustomMap.prototype.getDistance = function(params) { }); }; -CustomMap.prototype.getSubmaps = function() { +CustomMap.prototype.getSubmaps = function () { var submaps = this.submaps; if (submaps === undefined) { submaps = []; @@ -1213,7 +1232,7 @@ CustomMap.prototype.getSubmaps = function() { return submaps; }; -CustomMap.prototype.destroy = function() { +CustomMap.prototype.destroy = function () { var self = this; var commentDialog = self.getCommentDialog(); if (commentDialog !== undefined) { @@ -1221,11 +1240,11 @@ CustomMap.prototype.destroy = function() { } }; -CustomMap.prototype.getVisibleDataOverlays = function() { +CustomMap.prototype.getVisibleDataOverlays = function () { var dataOverlayPromises = []; // get list of layouts - for ( var key in this._selectedOverlays) { + for (var key in this._selectedOverlays) { if (this._selectedOverlays.hasOwnProperty(key) && this._selectedOverlays[key] === true) { dataOverlayPromises.push(this.getModel().getLayoutDataById(key)); } @@ -1234,7 +1253,7 @@ CustomMap.prototype.getVisibleDataOverlays = function() { return Promise.all(dataOverlayPromises); }; -CustomMap.prototype.createMarkerForDbOverlay = function(element, dbOverlay) { +CustomMap.prototype.createMarkerForDbOverlay = function (element, dbOverlay) { var self = this; var result = dbOverlay.markers[element.getType()][element.getId()]; @@ -1255,21 +1274,21 @@ CustomMap.prototype.createMarkerForDbOverlay = function(element, dbOverlay) { throw new Error("Unknown type of the element in overlay: " + element.type); } result = new MarkerConstructor({ - element : element, - map : submap, - onClick : [ function() { + element: element, + map: submap, + onClick: [function () { return self._openInfoWindowForIdentifiedElement(element, result.getGoogleMarker()); - }, function() { + }, function () { return self.callListeners("onBioEntityClick", element); - }, ] + },] }); - return result.init().then(function() { + return result.init().then(function () { dbOverlay.markers[element.getType()][element.getId()] = result; return result; }); }; -CustomMap.prototype.createSurfaceForDbOverlay = function(element, dbOverlay) { +CustomMap.prototype.createSurfaceForDbOverlay = function (element, dbOverlay) { var self = this; var result = dbOverlay.mapOverlays[element.getType()][element.getId()]; @@ -1281,30 +1300,30 @@ CustomMap.prototype.createSurfaceForDbOverlay = function(element, dbOverlay) { var map = self.getSubmapById(element.getModelId()); if (element.getType() === "ALIAS") { return AliasSurface.createFromIdentifiedElement({ - element : element, - map : self, - onClick : [ function() { + element: element, + map: self, + onClick: [function () { return self.openInfoWindowForIdentifiedElement(element, result.getGoogleMarker()); - }, function() { + }, function () { return self.callListeners("onBioEntityClick", element); - } ] - }).then(function(surface) { + }] + }).then(function (surface) { result = surface; dbOverlay.mapOverlays[element.getType()][element.getId()] = result; return result; }); } else if (element.getType() === "REACTION") { - return map.getModel().getReactionById(element.getId()).then(function(reactionData) { + return map.getModel().getReactionById(element.getId()).then(function (reactionData) { var result = new ReactionSurface({ - reaction : reactionData, - map : map, - customized : true, - color : element.getColor(), - onClick : [ function() { + reaction: reactionData, + map: map, + customized: true, + color: element.getColor(), + onClick: [function () { return self.openInfoWindowForIdentifiedElement(element, result.getGoogleMarker()); - }, function() { + }, function () { return self.callListeners("onBioEntityClick", element); - } ] + }] }); result.show(); dbOverlay.mapOverlays[element.getType()][element.getId()] = result; @@ -1319,21 +1338,21 @@ CustomMap.prototype.createSurfaceForDbOverlay = function(element, dbOverlay) { /** * Opens {@link AbstractInfoWindow} for a marker. - * + * * @param marker * marker for which we are opening window */ -CustomMap.prototype._openInfoWindowForIdentifiedElement = function(element, googleMarker) { +CustomMap.prototype._openInfoWindowForIdentifiedElement = function (element, googleMarker) { var self = this; var submap = self.getSubmapById(element.getModelId()); if (element.getType() === "ALIAS") { - return submap.getModel().getByIdentifiedElement(element).then(function(alias) { + return submap.getModel().getByIdentifiedElement(element).then(function (alias) { return submap._openInfoWindowForAlias(alias, googleMarker); }); } else if (element.getType() === "POINT") { return submap._openInfoWindowForPoint(new PointData(element), googleMarker); } else if (element.getType() === "REACTION") { - return submap.getModel().getByIdentifiedElement(element).then(function(reaction) { + return submap.getModel().getByIdentifiedElement(element).then(function (reaction) { return submap._openInfoWindowForReaction(reaction, googleMarker); }); } else { diff --git a/frontend-js/src/main/js/map/data/IdentifiedElement.js b/frontend-js/src/main/js/map/data/IdentifiedElement.js index caa6ef2d22e5905e2006c75bb849dfdc9de85f15..727425d6611892b1f64a0fee59f72e9d816bb65a 100644 --- a/frontend-js/src/main/js/map/data/IdentifiedElement.js +++ b/frontend-js/src/main/js/map/data/IdentifiedElement.js @@ -3,6 +3,7 @@ var Alias = require('./Alias'); var LayoutAlias = require('./LayoutAlias'); var Reaction = require('./Reaction'); +var LayoutReaction = require('./LayoutReaction'); var PointData = require('./PointData'); var logger = require('../../logger'); @@ -32,6 +33,10 @@ function IdentifiedElement(javaObject) { this.setId(javaObject.getId()); this.setModelId(javaObject.getModelId()); this.setType("REACTION"); + } else if (javaObject instanceof LayoutReaction) { + this.setId(javaObject.getId()); + this.setModelId(javaObject.getModelId()); + this.setType("REACTION"); } else if (javaObject instanceof PointData) { this.setId(javaObject.getId()); this.setModelId(javaObject.getModelId()); @@ -77,11 +82,11 @@ function IdentifiedElement(javaObject) { /** * Returns point where it should be visualized when the type of object is * "POINT". - * + * * @returns {@linke google.maps.Point} where it should be visualized when the * type of object is "POINT". */ -IdentifiedElement.prototype.getPoint = function() { +IdentifiedElement.prototype.getPoint = function () { if (this._point === undefined || this._point === null) { logger.warn("No point associated with IdentifiedElement"); return null; @@ -92,15 +97,15 @@ IdentifiedElement.prototype.getPoint = function() { /** * Returns element identifier. - * + * * @returns element identifier */ -IdentifiedElement.prototype.getId = function() { +IdentifiedElement.prototype.getId = function () { return this.id; }; -IdentifiedElement.prototype.setId = function(id) { - // some elements are identfied by id that is not a number (like point on the +IdentifiedElement.prototype.setId = function (id) { + // some elements are identified by id that is not a number (like point on the // map) if (!isNaN(id)) { id = parseInt(id); @@ -108,7 +113,7 @@ IdentifiedElement.prototype.setId = function(id) { this.id = id; }; -IdentifiedElement.prototype.setModelId = function(modelId) { +IdentifiedElement.prototype.setModelId = function (modelId) { if (modelId === undefined || modelId === null) { throw new Error("ModelId is invalid"); } @@ -117,10 +122,10 @@ IdentifiedElement.prototype.setModelId = function(modelId) { /** * Returns model identifier where element is placed. - * + * * @returns model identifier */ -IdentifiedElement.prototype.getModelId = function() { +IdentifiedElement.prototype.getModelId = function () { return this.modelId; }; @@ -132,14 +137,14 @@ IdentifiedElement.prototype.getModelId = function() { * <li>"POINT" - for any point on the map, the data connected to this kind of * objects are stored in {@link PointData}</li> * </ul> - * + * * @returns type of the element */ -IdentifiedElement.prototype.getType = function() { +IdentifiedElement.prototype.getType = function () { return this.type; }; -IdentifiedElement.prototype.setType = function(type) { +IdentifiedElement.prototype.setType = function (type) { if (type === undefined || type === null) { throw new Error("Type not defined"); } @@ -149,77 +154,77 @@ IdentifiedElement.prototype.setType = function(type) { /** * Returns icon that should be used for visualization. - * + * * @returns icon that should be used for visualization */ -IdentifiedElement.prototype.getIcon = function() { +IdentifiedElement.prototype.getIcon = function () { return this._visualizationdata._icon; }; -IdentifiedElement.prototype.setIcon = function(icon) { +IdentifiedElement.prototype.setIcon = function (icon) { this._visualizationdata._icon = icon; }; -IdentifiedElement.prototype.getColor = function() { +IdentifiedElement.prototype.getColor = function () { return this._visualizationdata._color; }; -IdentifiedElement.prototype.setColor = function(color) { +IdentifiedElement.prototype.setColor = function (color) { this._visualizationdata._color = color; }; -IdentifiedElement.prototype.getOpacity = function() { +IdentifiedElement.prototype.getOpacity = function () { return this._visualizationdata._opacity; }; -IdentifiedElement.prototype.setOpacity = function(opacity) { +IdentifiedElement.prototype.setOpacity = function (opacity) { this._visualizationdata._opacity = opacity; }; -IdentifiedElement.prototype.getLineWeight = function() { +IdentifiedElement.prototype.getLineWeight = function () { return this._visualizationdata._lineWeight; }; -IdentifiedElement.prototype.setLineWeight = function(lineWeight) { +IdentifiedElement.prototype.setLineWeight = function (lineWeight) { this._visualizationdata._lineWeight = lineWeight; }; -IdentifiedElement.prototype.getLineOpacity = function() { +IdentifiedElement.prototype.getLineOpacity = function () { return this._visualizationdata._lineOpacity; }; -IdentifiedElement.prototype.setLineOpacity = function(lineOpacity) { +IdentifiedElement.prototype.setLineOpacity = function (lineOpacity) { this._visualizationdata._lineOpacity = lineOpacity; }; -IdentifiedElement.prototype.getLineColor = function() { +IdentifiedElement.prototype.getLineColor = function () { return this._visualizationdata._lineColor; }; -IdentifiedElement.prototype.setLineColor = function(lineColor) { +IdentifiedElement.prototype.setLineColor = function (lineColor) { this._visualizationdata._lineColor = lineColor; }; -IdentifiedElement.prototype.getOnClickHandler = function() { +IdentifiedElement.prototype.getOnClickHandler = function () { return this._visualizationdata._onClickHandler; }; -IdentifiedElement.prototype.setOnClickHandler = function(onClickHandler) { +IdentifiedElement.prototype.setOnClickHandler = function (onClickHandler) { this._visualizationdata._onClickHandler = onClickHandler; }; -IdentifiedElement.prototype.equals = function(argument) { +IdentifiedElement.prototype.equals = function (argument) { if (argument instanceof IdentifiedElement) { return (this.getType() === argument.getType() && // - this.getId() === argument.getId() && // - this.getModelId() === argument.getModelId()); + this.getId() === argument.getId() && // + this.getModelId() === argument.getModelId()); } else { return false; } }; -IdentifiedElement.prototype.toString = function() { +IdentifiedElement.prototype.toString = function () { var self = this; return "[" + IdentifiedElement.prototype.constructor.name + "] " + self.getType() + " " + self.getId() + " (model: " - + self.getModelId() + ")"; + + self.getModelId() + ")"; }; module.exports = IdentifiedElement; diff --git a/frontend-js/src/main/js/map/data/MapModel.js b/frontend-js/src/main/js/map/data/MapModel.js index b649df92467375a69e77ebbc148bfe9967b01334..1e4e53b9f6ff0d03d8c6e9288c8078043b270ec9 100644 --- a/frontend-js/src/main/js/map/data/MapModel.js +++ b/frontend-js/src/main/js/map/data/MapModel.js @@ -276,7 +276,7 @@ MapModel.prototype.getMissingElements = function(elements) { var reactions = layout.getReactions(); for (var k = 0; k < reactions.length; k++) { - var reaction = reactions[j]; + var reaction = reactions[k]; if (this._reactions[reaction.getId()] === undefined && this._missingReactions[reaction.getId()] === undefined) { this._missingReactions[reaction.getId()] = reaction.getId(); reactionIds.push(reaction.getId()); @@ -682,7 +682,7 @@ MapModel.prototype.getByIdentifiedElements = function(identifiedElements, comple return self.getMissingElements({ aliasIds : missingAliases, reactionIds : missingReactions, - complete : true + complete : complete }).then(function() { var promises = []; for (var i = 0; i < identifiedElements.length; i++) { @@ -699,6 +699,14 @@ MapModel.prototype.isAvailable = function(ie, complete) { element = this._aliases[ie.getId()]; } else if (ie.getType() === "REACTION") { element = this._reactions[ie.getId()]; + } else if (ie.getType() === "POINT") { + var id = this._pointToId(ie.getId()); + var result = this._pointsData[id]; + if (result === undefined) { + result = new PointData(ie); + this._pointsData[id] = result; + } + element = this._pointsData[id]; } else { throw new Error("Unknown type: " + ie.getType(), complete); } diff --git a/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js b/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js index 57da91aee6f24955c95bc6ff1bafaa9a017d52af..6aca213bd7a5f8010fcdcc9ba4d2a8213e018402 100644 --- a/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js +++ b/frontend-js/src/main/js/map/overlay/AbstractDbOverlay.js @@ -41,77 +41,84 @@ AbstractDbOverlay.prototype = Object.create(ObjectWithListeners.prototype); AbstractDbOverlay.prototype.constructor = AbstractDbOverlay; AbstractDbOverlay.QueryType = { - SEARCH_BY_COORDINATES : "SEARCH_BY_COORDINATES", - SEARCH_BY_TARGET : "SEARCH_BY_TARGET", - SEARCH_BY_QUERY : "SEARCH_BY_QUERY", + SEARCH_BY_COORDINATES: "SEARCH_BY_COORDINATES", + SEARCH_BY_TARGET: "SEARCH_BY_TARGET", + SEARCH_BY_QUERY: "SEARCH_BY_QUERY", }; -AbstractDbOverlay.prototype.encodeQuery = function(type, arg0, arg1, arg2) { +AbstractDbOverlay.prototype.encodeQuery = function (type, arg0, arg1, arg2) { if (type === AbstractDbOverlay.QueryType.SEARCH_BY_COORDINATES) { var modelId = arg0; var coordinates = arg1; var zoom = arg2; return JSON.stringify({ - type : type, - modelId : modelId, - coordinates : coordinates, - zoom : zoom, + type: type, + modelId: modelId, + coordinates: coordinates, + zoom: zoom, }); } else if (type === AbstractDbOverlay.QueryType.SEARCH_BY_TARGET) { var target = arg0; return JSON.stringify({ - type : type, - target : target, + type: type, + target: target, }); } else if (type === AbstractDbOverlay.QueryType.SEARCH_BY_QUERY) { var query = arg0; var perfect = arg1; return JSON.stringify({ - type : type, - query : query, - perfect : perfect, + type: type, + query: query, + perfect: perfect, }); } else { throw new Error("Unknown query type: " + type); } }; -AbstractDbOverlay.prototype.decodeQuery = function(query) { +AbstractDbOverlay.prototype.decodeQuery = function (query) { return JSON.parse(query); }; -AbstractDbOverlay.prototype.searchByQuery = function(originalQuery, perfect, fitBounds) { +AbstractDbOverlay.prototype.searchByQuery = function (originalQuery, perfect, fitBounds) { var self = this; var query = self.encodeQuery(AbstractDbOverlay.QueryType.SEARCH_BY_QUERY, originalQuery, perfect); ServerConnector.getSessionData().setQuery({ - type : self.getName(), - query : query + type: self.getName(), + query: query }); - var queries = self.splitQuery(originalQuery); - + var res; var encodedQueries = []; - var promises = []; - for (var i = 0; i < queries.length; i++) { - encodedQueries.push(self.encodeQuery(AbstractDbOverlay.QueryType.SEARCH_BY_QUERY, queries[i], perfect)); - promises.push(self.searchBySingleQuery(queries[i], perfect)); - } + return self.searchBySingleQuery(originalQuery, perfect).then(function (results) { + if (results.length > 0) { + encodedQueries.push(query); + return [results]; + } else { + var queries = self.splitQuery(originalQuery); + + var promises = []; + for (var i = 0; i < queries.length; i++) { + encodedQueries.push(self.encodeQuery(AbstractDbOverlay.QueryType.SEARCH_BY_QUERY, queries[i], perfect)); + promises.push(self.searchBySingleQuery(queries[i], perfect)); + } - var res; - return Promise.all(promises).then(function(results) { + return Promise.all(promises); + } + }).then(function (results) { self.setQueries(encodedQueries); res = results; return self.callListeners('onSearch', { - fitBounds : fitBounds, - identifiedElements : res, - type : AbstractDbOverlay.QueryType.SEARCH_BY_QUERY, + fitBounds: fitBounds, + identifiedElements: res, + type: AbstractDbOverlay.QueryType.SEARCH_BY_QUERY, }); - }).then(function() { + }).then(function () { return res; }); }; -AbstractDbOverlay.prototype.searchNamesByTarget = function(element) { +AbstractDbOverlay.prototype.searchNamesByTarget = function (element) { var self = this; var query = self.encodeQuery(AbstractDbOverlay.QueryType.SEARCH_BY_TARGET, element); @@ -119,23 +126,23 @@ AbstractDbOverlay.prototype.searchNamesByTarget = function(element) { return Promise.resolve(self._elementsByQuery[query]); } else { return self.getNamesByTargetFromServer({ - target : element - }).then(function(drugNames) { + target: element + }).then(function (drugNames) { self._elementsByQuery[query] = drugNames; return self._elementsByQuery[query]; }); } }; -AbstractDbOverlay.prototype.setQueries = function(queries) { +AbstractDbOverlay.prototype.setQueries = function (queries) { this._queries = queries; }; -AbstractDbOverlay.prototype.getQueries = function() { +AbstractDbOverlay.prototype.getQueries = function () { return this._queries; }; -AbstractDbOverlay.prototype.createIdentifiedElementsForTargetingClass = function(targetingElement, colourId) { +AbstractDbOverlay.prototype.createIdentifiedElementsForTargetingClass = function (targetingElement, colourId) { var self = this; var result = []; var iconCounter = 1; @@ -160,11 +167,11 @@ AbstractDbOverlay.prototype.createIdentifiedElementsForTargetingClass = function return result; }; -AbstractDbOverlay.prototype.refresh = function() { +AbstractDbOverlay.prototype.refresh = function () { throw new Error("Refreshing shouldn't be called"); }; -AbstractDbOverlay.prototype.searchByEncodedQuery = function(originalQuery, fitBounds) { +AbstractDbOverlay.prototype.searchByEncodedQuery = function (originalQuery, fitBounds) { var query = this.decodeQuery(originalQuery); query.fitBounds = fitBounds; if (query.type === AbstractDbOverlay.QueryType.SEARCH_BY_QUERY) { @@ -179,9 +186,9 @@ AbstractDbOverlay.prototype.searchByEncodedQuery = function(originalQuery, fitBo } }; -AbstractDbOverlay.prototype.clear = function() { +AbstractDbOverlay.prototype.clear = function () { var self = this; - return self.searchByQuery("").then(function() { + return self.searchByQuery("").then(function () { return self.callListeners('onClear'); }); }; @@ -189,38 +196,38 @@ AbstractDbOverlay.prototype.clear = function() { /** * Returns true if overlay allows to get general data for element. */ -AbstractDbOverlay.prototype.allowGeneralSearch = function() { +AbstractDbOverlay.prototype.allowGeneralSearch = function () { return this._allowGeneralSearch; }; -AbstractDbOverlay.prototype.getName = function() { +AbstractDbOverlay.prototype.getName = function () { return this.name; }; /** * Returns true if overlay allows to get data for element by search id. */ -AbstractDbOverlay.prototype.allowSearchById = function() { +AbstractDbOverlay.prototype.allowSearchById = function () { return this._allowSearchById; }; -AbstractDbOverlay.prototype.setMap = function(map) { +AbstractDbOverlay.prototype.setMap = function (map) { this._map = map; }; -AbstractDbOverlay.prototype.getMap = function() { +AbstractDbOverlay.prototype.getMap = function () { return this._map; }; -AbstractDbOverlay.prototype.setName = function(name) { +AbstractDbOverlay.prototype.setName = function (name) { this.name = name; }; -AbstractDbOverlay.prototype.getName = function() { +AbstractDbOverlay.prototype.getName = function () { return this.name; }; -AbstractDbOverlay.prototype.setAllowSearchById = function(allowSearchById) { +AbstractDbOverlay.prototype.setAllowSearchById = function (allowSearchById) { // configure if the overlay can contain detailed data about elements that // should be visualized in detailed mode of the Info Window if (typeof allowSearchById === "boolean") { @@ -232,7 +239,7 @@ AbstractDbOverlay.prototype.setAllowSearchById = function(allowSearchById) { } }; -AbstractDbOverlay.prototype.setAllowGeneralSearch = function(allowGeneralSearch) { +AbstractDbOverlay.prototype.setAllowGeneralSearch = function (allowGeneralSearch) { if (typeof allowGeneralSearch === "boolean") { this._allowGeneralSearch = allowGeneralSearch; } else if (allowGeneralSearch === undefined) { @@ -242,22 +249,22 @@ AbstractDbOverlay.prototype.setAllowGeneralSearch = function(allowGeneralSearch) } }; -AbstractDbOverlay.prototype.setIconType = function(iconType) { +AbstractDbOverlay.prototype.setIconType = function (iconType) { this._iconType = iconType; }; -AbstractDbOverlay.prototype.setIconStart = function(iconStart) { +AbstractDbOverlay.prototype.setIconStart = function (iconStart) { this._iconStart = iconStart; }; -AbstractDbOverlay.IconColors = [ "red", "blue", "green", "purple", "yellow", "pink", "paleblue", "brown", "orange" ]; +AbstractDbOverlay.IconColors = ["red", "blue", "green", "purple", "yellow", "pink", "paleblue", "brown", "orange"]; -AbstractDbOverlay.prototype.getColor = function(colorId) { +AbstractDbOverlay.prototype.getColor = function (colorId) { var id = colorId + this._iconStart; id %= AbstractDbOverlay.IconColors.length; return AbstractDbOverlay.IconColors[id]; }; -AbstractDbOverlay.prototype.getIcon = function(colorId, id) { +AbstractDbOverlay.prototype.getIcon = function (colorId, id) { if (id >= 100) { id = 1; } @@ -265,7 +272,7 @@ AbstractDbOverlay.prototype.getIcon = function(colorId, id) { return "marker/" + this._iconType + "/" + this._iconType + "_" + color + "_" + id + ".png"; }; -AbstractDbOverlay.prototype.splitQuery = function(query, useFullName) { +AbstractDbOverlay.prototype.splitQuery = function (query, useFullName) { var result = []; if (query.indexOf(";") >= 0) { result = query.split(";"); diff --git a/frontend-js/src/test/js/helper.js b/frontend-js/src/test/js/helper.js index caf31be8d1bfd7f3797bc413c4e50db0ab7cd638..947e0cd77818364a27696614efef19a550a9d28b 100644 --- a/frontend-js/src/test/js/helper.js +++ b/frontend-js/src/test/js/helper.js @@ -34,80 +34,81 @@ function Helper(configuration) { } this.setConfiguration(configuration); this.idCounter = 1000000; + this.EPSILON = Helper.EPSILON; } -Helper.prototype.setConfiguration = function(configuration) { +Helper.prototype.setConfiguration = function (configuration) { this._configuration = configuration; }; -Helper.prototype.getConfiguration = function() { +Helper.prototype.getConfiguration = function () { return this._configuration; }; -Helper.prototype.createCommentDbOverlay = function(map) { +Helper.prototype.createCommentDbOverlay = function (map) { var result = new CommentDbOverlay({ - map : map, - name : "comment", - allowGeneralSearch : true + map: map, + name: "comment", + allowGeneralSearch: true }); map.registerDbOverlay(result); return result; }; -Helper.prototype.createSearchDbOverlay = function(map) { +Helper.prototype.createSearchDbOverlay = function (map) { var result = new SearchDbOverlay({ - map : map, - name : "search", + map: map, + name: "search", }); map.registerDbOverlay(result); return result; }; -Helper.prototype.createDbOverlay = function(map) { +Helper.prototype.createDbOverlay = function (map) { var result = new AbstractDbOverlay({ - map : map, - name : "search", + map: map, + name: "search", }); - result.clear = function() { + result.clear = function () { logger.debug("Clear mock"); }; map.registerDbOverlay(result); return result; }; -Helper.prototype.createDrugDbOverlay = function(map) { +Helper.prototype.createDrugDbOverlay = function (map) { var result = new DrugDbOverlay({ - map : map, - name : "drug", - allowGeneralSearch : true, - allowSearchById : true, + map: map, + name: "drug", + allowGeneralSearch: true, + allowSearchById: true, }); map.registerDbOverlay(result); return result; }; -Helper.prototype.createChemicalDbOverlay = function(map) { +Helper.prototype.createChemicalDbOverlay = function (map) { var result = new ChemicalDbOverlay({ - map : map, - name : "chemical", - allowGeneralSearch : true, - allowSearchById : true, + map: map, + name: "chemical", + allowGeneralSearch: true, + allowSearchById: true, }); map.registerDbOverlay(result); return result; }; -Helper.prototype.createMiRnaDbOverlay = function(map) { +Helper.prototype.createMiRnaDbOverlay = function (map) { var result = new MiRnaDbOverlay({ - map : map, - name : "mirna", - allowGeneralSearch : true, - allowSearchById : true, + map: map, + name: "mirna", + allowGeneralSearch: true, + allowSearchById: true, }); map.registerDbOverlay(result); return result; }; -Helper.prototype.createComment = function(element) { +Helper.prototype.createComment = function (element) { var elementType = "ALIAS"; var elementId = this.idCounter++; var id = this.idCounter++; @@ -124,25 +125,25 @@ Helper.prototype.createComment = function(element) { } var result = new Comment({ - elementId : elementId, - type : elementType, - modelId : modelId, - icon : "icons/comment.png", - id : id, - pinned : true, - coord : { - x : 321.5, - y : 289.0 + elementId: elementId, + type: elementType, + modelId: modelId, + icon: "icons/comment.png", + id: id, + pinned: true, + coord: { + x: 321.5, + y: 289.0 }, - removed : false, - title : "title fo comment: " + id, - content : "content of the comment # " + id + removed: false, + title: "title fo comment: " + id, + content: "content of the comment # " + id }); return result; }; -Helper.prototype.createProject = function() { +Helper.prototype.createProject = function () { var result = new Project(); result.setProjectId("testId"); result.setId(this.idCounter++); @@ -150,17 +151,17 @@ Helper.prototype.createProject = function() { return result; }; -Helper.prototype.createUser = function() { +Helper.prototype.createUser = function () { var result = new User({ - login : "testlogin", - id : this.idCounter++, - name : "some name", - surname : "surn", + login: "testlogin", + id: this.idCounter++, + name: "some name", + surname: "surn", }); return result; }; -Helper.prototype.createAlias = function(map) { +Helper.prototype.createAlias = function (map) { var mapId; if (map === undefined) { mapId = this.idCounter++; @@ -168,17 +169,17 @@ Helper.prototype.createAlias = function(map) { mapId = map.getId(); } var result = new Alias({ - idObject : this.idCounter++, - name : "Test element", - type : "RNA", - modelId : mapId, - bounds : { - x : 10.0, - y : 20.0, - width : 30.0, - height : 40.0, + idObject: this.idCounter++, + name: "Test element", + type: "RNA", + modelId: mapId, + bounds: { + x: 10.0, + y: 20.0, + width: 30.0, + height: 40.0, }, - references : [], + references: [], }); if (map !== undefined) { map.getModel().addAlias(result); @@ -186,55 +187,63 @@ Helper.prototype.createAlias = function(map) { return result; }; -Helper.prototype.createLayoutAlias = function(alias) { +Helper.prototype.createLayoutAlias = function (alias) { var id; + var modelId; if (alias instanceof Alias) { id = alias.getId(); + modelId = alias.getModelId(); } else { id = this.idCounter++; + modelId = this.idCounter++; } var result = new LayoutAlias({ - idObject : id, - value : 0.2, - color : { - a : 23 + idObject: id, + value: 0.2, + color: { + a: 23 }, - geneVariations : [ {} ] + modelId: modelId, + geneVariations: [{}] }); return result; }; -Helper.prototype.createLayoutReaction = function(reaction) { +Helper.prototype.createLayoutReaction = function (reaction) { var reactionId; + var modelId; if (reaction instanceof Reaction) { reactionId = reaction.getId(); + modelId = reaction.getModelId(); } else { reactionId = this.idCounter++; + modelId = this.idCounter++; } var result = new LayoutReaction({ - idObject : reactionId, - width : 3.4, - color : { - a : 24, + idObject: reactionId, + modelId: modelId, + width: 3.4, + color: { + a: 24, }, - reverse : true + reverse: true }); return result; }; -Helper.prototype.createIdentifiedElement = function(element) { +Helper.prototype.createIdentifiedElement = function (element) { if (element === undefined) { return new IdentifiedElement({ - type : "ALIAS", - id : this.idCounter++, - modelId : this.idCounter++, + type: "ALIAS", + id: this.idCounter++, + modelId: this.idCounter++, }); } return new IdentifiedElement(element); }; -Helper.prototype.createReaction = function(map) { +Helper.prototype.createReaction = function (map) { var mapId = null; if (map !== undefined) { mapId = map.getId(); @@ -242,49 +251,49 @@ Helper.prototype.createReaction = function(map) { mapId = this.idCounter++; } var result = new Reaction({ - idObject : this.idCounter++, - lines : [ { - start : { - x : 434.8904109589041, - y : 85.0 + idObject: this.idCounter++, + lines: [{ + start: { + x: 434.8904109589041, + y: 85.0 }, - end : { - x : 410.8341500923087, - y : 104.95576185524392 + end: { + x: 410.8341500923087, + y: 104.95576185524392 }, - type : "START" + type: "START" }, { - start : { - x : 404.6769250286157, - y : 110.06345991944379 + start: { + x: 404.6769250286157, + y: 110.06345991944379 }, - end : { - x : 380.62066416202026, - y : 130.0192217746877 + end: { + x: 380.62066416202026, + y: 130.0192217746877 }, - type : "END" - } ], - centerPoint : new google.maps.Point(0, 0), - modelId : mapId, - references : [], + type: "END" + }], + centerPoint: new google.maps.Point(0, 0), + modelId: mapId, + references: [], }); return result; }; -Helper.prototype.createOptions = function(project) { +Helper.prototype.createOptions = function (project) { if (project === undefined) { project = this.createProject(); } var options = { - mapDiv : testDiv, - element : testDiv, - project : project, + mapDiv: testDiv, + element: testDiv, + project: project, }; return options; }; -Helper.prototype.createModel = function() { +Helper.prototype.createModel = function () { var result = new Model(); result.setId(this.idCounter++); result.setTileSize(256); @@ -293,16 +302,16 @@ Helper.prototype.createModel = function() { result.setMaxZoom(8); result.setMinZoom(2); result.setCenterLatLng({ - lat : 10, - lng : 20 + lat: 10, + lng: 20 }); result.setTopLeftLatLng({ - lat : 8, - lng : 8 + lat: 8, + lng: 8 }); result.setBottomRightLatLng({ - lat : 30, - lng : 30 + lat: 30, + lng: 30 }); var layout = this.createLayout(); @@ -310,51 +319,51 @@ Helper.prototype.createModel = function() { return result; }; -Helper.prototype.createLayout = function() { +Helper.prototype.createLayout = function () { var id = this.idCounter++; var layout = new LayoutData({ - idObject : id, - name : "testLayout" + id, + idObject: id, + name: "testLayout" + id, }); return layout; }; -Helper.prototype.createGoogleMap = function() { +Helper.prototype.createGoogleMap = function () { var result = new google.maps.Map(testDiv, { - center : { - lat : -34.397, - lng : 150.644 + center: { + lat: -34.397, + lng: 150.644 }, - scrollwheel : false, - zoom : 8 + scrollwheel: false, + zoom: 8 }); return result; }; -Helper.prototype.createCustomMapOptions = function(project) { +Helper.prototype.createCustomMapOptions = function (project) { if (project === undefined) { project = this.createProject(); } var result = new CustomMapOptions({ - markerOptimization : true, - project : project, - element : testDiv, - mapDiv : testDiv, - configuration : this.getConfiguration(), + markerOptimization: true, + project: project, + element: testDiv, + mapDiv: testDiv, + configuration: this.getConfiguration(), }); return result; }; -Helper.prototype.createAbstractCustomMap = function() { +Helper.prototype.createAbstractCustomMap = function () { var options = this.createCustomMapOptions(); var result = new AbstractCustomMap(options.getProject().getModel(), options); return result; }; -Helper.prototype.createCustomMap = function(project) { +Helper.prototype.createCustomMap = function (project) { if (project === null) { throw new Error("Project cannot be null"); } @@ -366,12 +375,12 @@ Helper.prototype.createCustomMap = function(project) { /** * Changes url but saves the cookies. */ -Helper.prototype.setUrl = function(url) { +Helper.prototype.setUrl = function (url) { var cookies = Cookies.get(); global.dom.reconfigure({ - url : url + url: url }); - for ( var cookie in cookies) { + for (var cookie in cookies) { Cookies.set(cookie, cookies[cookie]); } GuiConnector.init(); diff --git a/frontend-js/src/test/js/map/CustomMap-test.js b/frontend-js/src/test/js/map/CustomMap-test.js index 3c434c3198f62fb471c0981e85acc049982341f4..ccef0aab0a0865668b57ecfe6558b6255ab7d577 100644 --- a/frontend-js/src/test/js/map/CustomMap-test.js +++ b/frontend-js/src/test/js/map/CustomMap-test.js @@ -116,24 +116,19 @@ describe('CustomMap', function() { it("simple", function() { var map = helper.createCustomMap(); - var alias = helper.createAlias(); - alias.setModelId(map.getId()); + var alias = helper.createAlias(map); map.getModel().addAlias(alias); - var reaction = helper.createReaction(); + var reaction = helper.createReaction(map); map.getModel().addReaction(reaction); var layout = helper.createLayout(); layout.setInputDataAvailable(true); layout.setInitialized(true); - var layoutAlias = helper.createLayoutAlias(); - layoutAlias.setId(alias.getId()); - layoutAlias.setModelId(map.getId()); + var layoutAlias = helper.createLayoutAlias(alias); layout.addAlias(layoutAlias); - var layoutReaction = helper.createLayoutReaction(); - layoutReaction.setId(reaction.getId()); - layoutReaction.setModelId(map.getId()); + var layoutReaction = helper.createLayoutReaction(reaction); layout.addReaction(layoutReaction); map.getModel().addLayout(layout); diff --git a/frontend-js/src/test/js/minerva-test.js b/frontend-js/src/test/js/minerva-test.js index 6c14d02b8595aebd12e4ca6bf3d728052006e710..760c1f6b464c67fe5a9eae6b44688c009294512e 100644 --- a/frontend-js/src/test/js/minerva-test.js +++ b/frontend-js/src/test/js/minerva-test.js @@ -1,7 +1,5 @@ "use strict"; -var Helper = require('./helper'); - require("./mocha-config.js"); var Alias = require('../../main/js/map/data/Alias'); @@ -408,8 +406,8 @@ describe('minerva global', function() { var sessionData = ServerConnectorMock.getSessionData(globalResult.getProject()); var center = sessionData.getCenter(globalResult.getProject().getModel()); assert.ok(center instanceof google.maps.Point); - assert.closeTo(parseFloat(center.x), 10, Helper.EPSILON); - assert.closeTo(parseFloat(center.y), 20, Helper.EPSILON); + assert.closeTo(parseFloat(center.x), 10, helper.EPSILON); + assert.closeTo(parseFloat(center.y), 20, helper.EPSILON); }).then(function() { globalResult.destroy(); }); diff --git a/frontend-js/src/test/js/mocha-config.js b/frontend-js/src/test/js/mocha-config.js index b04d4694da8de0eb0f88dfa7cc40a140f3b9fdb4..2386f2d30d9a31862b0f3c8e1843f9e5a9bd10a3 100644 --- a/frontend-js/src/test/js/mocha-config.js +++ b/frontend-js/src/test/js/mocha-config.js @@ -3,7 +3,7 @@ var Promise = require("bluebird"); var Cookies = require('js-cookie'); -var Helper = require('./Helper'); +var Helper = require('./helper'); // GLOBAL configuration global.navigator = { @@ -18,7 +18,7 @@ global.dom = new jsdom.JSDOM(); global.window = global.dom.window; global.document = window.document; -global.$ = require('jQuery'); +global.$ = require('jquery'); global.jQuery = $; global.window.$ = $; diff --git a/frontend-js/testFiles/apiCalls/doLogout b/frontend-js/testFiles/apiCalls/doLogout new file mode 100644 index 0000000000000000000000000000000000000000..1a36cf5fc27a0920a9f3668225f9d7aec239566e --- /dev/null +++ b/frontend-js/testFiles/apiCalls/doLogout @@ -0,0 +1 @@ +{"status":"ok"} \ No newline at end of file diff --git a/frontend-js/testFiles/apiCalls/projects/sample/comments/models/15781/bioEntities/elements/329173/POST_coordinates=2.00%2C12.00&pinned=false&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/sample/comments/models/15781/bioEntities/elements/329173/POST_coordinates=2.00%2C12.00&pinned=true&token=MOCK_TOKEN_ID& similarity index 100% rename from frontend-js/testFiles/apiCalls/projects/sample/comments/models/15781/bioEntities/elements/329173/POST_coordinates=2.00%2C12.00&pinned=false&token=MOCK_TOKEN_ID& rename to frontend-js/testFiles/apiCalls/projects/sample/comments/models/15781/bioEntities/elements/329173/POST_coordinates=2.00%2C12.00&pinned=true&token=MOCK_TOKEN_ID& diff --git a/frontend-js/testFiles/apiCalls/projects/sample/comments/models/15781/points/2.00,12.00/POST_pinned=false&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/sample/comments/models/15781/points/2.00,12.00/POST_pinned=true&token=MOCK_TOKEN_ID& similarity index 100% rename from frontend-js/testFiles/apiCalls/projects/sample/comments/models/15781/points/2.00,12.00/POST_pinned=false&token=MOCK_TOKEN_ID& rename to frontend-js/testFiles/apiCalls/projects/sample/comments/models/15781/points/2.00,12.00/POST_pinned=true&token=MOCK_TOKEN_ID& diff --git a/persist/src/db/11/fix_db_20170616.sql b/persist/src/db/11.0.0/fix_db_20170616.sql similarity index 100% rename from persist/src/db/11/fix_db_20170616.sql rename to persist/src/db/11.0.0/fix_db_20170616.sql diff --git a/persist/src/db/11/fix_db_20170627.sql b/persist/src/db/11.0.0/fix_db_20170627.sql similarity index 100% rename from persist/src/db/11/fix_db_20170627.sql rename to persist/src/db/11.0.0/fix_db_20170627.sql diff --git a/persist/src/db/11/fix_db_20170628.sql b/persist/src/db/11.0.0/fix_db_20170628.sql similarity index 100% rename from persist/src/db/11/fix_db_20170628.sql rename to persist/src/db/11.0.0/fix_db_20170628.sql diff --git a/persist/src/db/11/fix_db_20170629.sql b/persist/src/db/11.0.0/fix_db_20170629.sql similarity index 100% rename from persist/src/db/11/fix_db_20170629.sql rename to persist/src/db/11.0.0/fix_db_20170629.sql diff --git a/persist/src/db/11/fix_db_20170705.sql b/persist/src/db/11.0.0/fix_db_20170705.sql similarity index 100% rename from persist/src/db/11/fix_db_20170705.sql rename to persist/src/db/11.0.0/fix_db_20170705.sql diff --git a/persist/src/db/11/fix_db_20170714.sql b/persist/src/db/11.0.0/fix_db_20170714.sql similarity index 100% rename from persist/src/db/11/fix_db_20170714.sql rename to persist/src/db/11.0.0/fix_db_20170714.sql diff --git a/persist/src/db/11/fix_db_20170725.sql b/persist/src/db/11.0.0/fix_db_20170725.sql similarity index 100% rename from persist/src/db/11/fix_db_20170725.sql rename to persist/src/db/11.0.0/fix_db_20170725.sql diff --git a/persist/src/db/11/fix_db_20170731.sql b/persist/src/db/11.0.0/fix_db_20170731.sql similarity index 100% rename from persist/src/db/11/fix_db_20170731.sql rename to persist/src/db/11.0.0/fix_db_20170731.sql diff --git a/persist/src/db/11.0.1/fix_db_20170908.sql b/persist/src/db/11.0.1/fix_db_20170908.sql new file mode 100644 index 0000000000000000000000000000000000000000..a33b6ad89d4881c84fb355b8c56d309760e66b70 --- /dev/null +++ b/persist/src/db/11.0.1/fix_db_20170908.sql @@ -0,0 +1 @@ +-- empty file to force directory to be commited to git repo diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/users/UserController.java b/rest-api/src/main/java/lcsb/mapviewer/api/users/UserController.java index 621a0dd6d64839e716e89d2742381313bec10858..f35425bd3b5820f29dfe956e03c341f7434278e7 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/users/UserController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/users/UserController.java @@ -103,11 +103,27 @@ public class UserController extends BaseController { } @RequestMapping(value = "/doLogout", method = { RequestMethod.GET, RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE }) - public Map<String, String> logout(@CookieValue(value = Configuration.AUTH_TOKEN) String token) throws SecurityException { + public Map<String, String> logout(@CookieValue(value = Configuration.AUTH_TOKEN) String token, + HttpServletResponse response // + ) throws SecurityException, IOException { userService.logout(token); - Map<String, String> response = new HashMap<>(); - response.put("status", "OK"); - return response; + Map<String, String> result = new HashMap<>(); + result.put("status", "OK"); + + final Boolean useSecureCookie = false; + final String cookiePath = "/"; + + Cookie cookie = new Cookie("MINERVA_AUTH_TOKEN", token); + + cookie.setSecure(useSecureCookie); + cookie.setMaxAge(0); + cookie.setPath(cookiePath); + + response.addCookie(cookie); + response.getWriter().write("{\"status\":\"OK\"}"); + response.getWriter().flush(); + response.getWriter().close(); + return result; } /**