Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
256564ad
Commit
256564ad
authored
Jan 02, 2017
by
Piotr Gawron
Browse files
comments are retrieved via API
parent
0cd1a515
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
frontend-js/src/main/js/ServerConnector.js
View file @
256564ad
...
...
@@ -15,6 +15,7 @@ var LayoutData = require('./map/data/LayoutData');
var
LayoutReaction
=
require
(
'
./map/data/LayoutReaction
'
);
var
Project
=
require
(
'
./map/data/Project
'
);
var
Reaction
=
require
(
'
./map/data/Reaction
'
);
var
SessionData
=
require
(
'
./SessionData
'
);
/**
* This object contains methods that will communicate with server.
...
...
@@ -238,7 +239,11 @@ ServerConnector.addOverlayCollection = function(overlay) {
logger
.
warn
(
"
Cannot initialize overlay:
"
+
overlay
);
}
}
else
{
logger
.
warn
(
"
Unknown overlay:
"
,
overlay
);
if
(
overlay
.
constructor
.
name
===
"
OverlayCollection
"
)
{
throw
new
Error
(
"
Unknown overlay:
"
,
overlay
);
}
else
{
logger
.
warn
(
"
Adding collection that shouldn't be added:
"
+
overlay
.
getName
());
}
}
};
...
...
@@ -515,7 +520,7 @@ ServerConnector.sendClearRequest = function(overlayName) {
logger
.
warn
(
"
Clear function for
"
+
overlayName
+
"
doesn't exist
"
);
}
}
else
{
logger
.
warn
(
"
[Clear function] Unknown overlay:
"
,
overlayName
);
throw
new
Error
(
"
[Clear function] Unknown overlay:
"
,
overlayName
);
}
};
...
...
@@ -531,8 +536,7 @@ ServerConnector.setOverlayResultIds = function(overlayName, ids) {
ServerConnector
.
sendOverlayDetailDataRequest
=
function
(
overlayName
,
identifiedElement
,
general
)
{
var
overlay
=
ServerConnector
.
_overlays
[
overlayName
];
if
(
overlay
===
undefined
)
{
logger
.
warn
(
"
Unknown overlay:
"
+
overlayName
);
return
;
throw
new
Overlay
(
"
Unknown overlay:
"
+
overlayName
);
}
var
functions
=
ServerConnector
.
_overlayMethods
[
overlayName
];
if
(
functions
!==
undefined
)
{
...
...
@@ -550,7 +554,7 @@ ServerConnector.sendOverlayDetailDataRequest = function(overlayName, identifiedE
logger
.
warn
(
"
Request detail data function for
"
+
overlayName
+
"
doesn't exist
"
);
}
}
else
{
logger
.
warn
(
"
[Clear function] Unknown overlay:
"
,
overlayName
);
throw
new
Error
(
"
[Clear function] Unknown overlay:
"
,
overlayName
);
}
};
...
...
@@ -1068,4 +1072,10 @@ ServerConnector.getLightAliases = function(aliasIds, projectId) {
return
this
.
getAliases
(
aliasIds
,
projectId
,
"
id,bounds,modelId
"
);
};
ServerConnector
.
getSessionData
=
function
(
aliasIds
,
projectId
)
{
if
(
this
.
_sessionData
===
undefined
)
{
this
.
_sessionData
=
new
SessionData
();
}
return
this
.
_sessionData
;
};
module
.
exports
=
ServerConnector
;
frontend-js/src/main/js/SessionData.js
0 → 100644
View file @
256564ad
"
use strict
"
;
var
SessionObjectType
=
require
(
'
./SessionObjectType
'
);
var
Cookies
=
require
(
'
js-cookie
'
);
function
SessionData
()
{
}
SessionData
.
prototype
.
getShowComments
=
function
()
{
return
Cookies
.
get
(
SessionObjectType
.
SHOW_COMMENT
)
===
"
true
"
;
};
SessionData
.
prototype
.
setShowComments
=
function
(
value
)
{
return
Cookies
.
set
(
SessionObjectType
.
SHOW_COMMENT
,
value
+
""
);
};
module
.
exports
=
SessionData
;
frontend-js/src/main/js/SessionObjectType.js
0 → 100644
View file @
256564ad
"
use strict
"
;
var
SessionObjectType
=
{
SHOW_COMMENT
:
"
SHOW_COMMENT
"
,
};
module
.
exports
=
SessionObjectType
;
frontend-js/src/main/js/map/ControlType.js
0 → 100644
View file @
256564ad
"
use strict
"
;
var
ControlType
=
{
COMMENT_CHECKBOX
:
"
COMMENT_CHECKBOX
"
,
};
module
.
exports
=
ControlType
;
frontend-js/src/main/js/map/CustomMap.js
View file @
256564ad
...
...
@@ -7,6 +7,7 @@ var functions = require('../Functions');
var
AbstractCustomMap
=
require
(
'
./AbstractCustomMap
'
);
var
AliasMarker
=
require
(
'
./marker/AliasMarker
'
);
var
ControlType
=
require
(
'
./ControlType
'
);
var
CustomMapOptions
=
require
(
'
./CustomMapOptions
'
);
var
IdentifiedElement
=
require
(
'
./data/IdentifiedElement
'
);
var
OverlayCollection
=
require
(
'
./overlay/OverlayCollection
'
);
...
...
@@ -31,6 +32,8 @@ var TouchMap = require('./TouchMap');
*
*/
function
CustomMap
(
options
)
{
this
.
_controls
=
[];
if
(
!
(
options
instanceof
CustomMapOptions
))
{
options
=
new
CustomMapOptions
(
options
);
}
...
...
@@ -79,12 +82,12 @@ function CustomMap(options) {
// list of reference genomes
this
.
_referenceGenome
=
[];
ServerConnector
.
actualizeSessionData
();
}
CustomMap
.
prototype
=
Object
.
create
(
AbstractCustomMap
.
prototype
);
CustomMap
.
prototype
.
constructor
=
CustomMap
;
CustomMap
.
prototype
.
createSubmaps
=
function
()
{
...
...
@@ -252,7 +255,7 @@ CustomMap.prototype.clearOverlayCollection = function(collection) {
*/
CustomMap
.
prototype
.
updateOverlayCollection
=
function
(
overlayCollection
,
fitBounds
)
{
this
.
clearOverlayCollection
(
overlayCollection
);
this
.
renderOverlayCollection
({
overlayCollection
:
overlayCollection
,
fitBounds
:
fitBounds
});
return
this
.
renderOverlayCollection
({
overlayCollection
:
overlayCollection
,
fitBounds
:
fitBounds
});
};
/**
...
...
@@ -350,28 +353,27 @@ CustomMap.prototype.createMapMenu = function() {
rightHeaderMenu
.
className
=
"
rightHeaderMenu
"
;
var
submenuDiv
=
document
.
createElement
(
'
div
'
);
submenuDiv
.
className
=
"
div4checkboxes
"
;
var
submenuButtonDiv3
=
document
.
createElement
(
'
input
'
);
submenuButtonDiv3
.
type
=
"
checkbox
"
;
submenuButtonDiv3
.
name
=
"
Comments
"
;
submenuButtonDiv3
.
id
=
"
comment_checkbox
"
;
submenuButtonDiv3
.
onclick
=
(
function
()
{
var
selfButton
=
submenuButtonDiv3
;
var
commentCheckbox
=
document
.
createElement
(
'
input
'
);
commentCheckbox
.
type
=
"
checkbox
"
;
commentCheckbox
.
name
=
"
Comments
"
;
commentCheckbox
.
id
=
ControlType
.
COMMENT_CHECKBOX
;
commentCheckbox
.
onclick
=
(
function
()
{
var
selfButton
=
commentCheckbox
;
return
function
()
{
selfMap
.
showComments
=
selfButton
.
checked
;
ServerConnector
.
setShowComments
(
selfButton
.
checked
);
ServerConnector
.
getSessionData
().
setShowComments
(
selfButton
.
checked
);
if
(
selfButton
.
checked
)
{
document
.
getElementById
(
'
refresh_comments_button
'
).
style
.
display
=
'
inline
'
;
}
else
{
document
.
getElementById
(
'
refresh_comments_button
'
).
style
.
display
=
'
none
'
;
}
selfMap
.
refreshComments
();
};
})();
this
.
addControl
(
commentCheckbox
);
var
element
=
document
.
createElement
(
'
label
'
);
element
.
innerHTML
=
"
COMMENTS
"
;
element
.
setAttribute
(
"
for
"
,
"
comment_checkbox
"
);
submenuDiv
.
appendChild
(
submenuButtonDiv3
);
element
.
setAttribute
(
"
for
"
,
ControlType
.
COMMENT_CHECKBOX
);
submenuDiv
.
appendChild
(
commentCheckbox
);
submenuDiv
.
appendChild
(
element
);
var
submenuButtonDiv
=
document
.
createElement
(
'
input
'
);
...
...
@@ -434,14 +436,21 @@ CustomMap.prototype.registerSource = function(overlayCollection) {
};
CustomMap
.
prototype
.
refreshComments
=
function
()
{
var
self
=
this
;
for
(
var
overlayName
in
this
.
overlayCollections
)
{
if
(
this
.
overlayCollections
.
hasOwnProperty
(
overlayName
)
&&
overlayName
===
"
comment
"
)
{
var
collection
=
this
.
overlayCollections
[
overlayName
];
collection
.
refresh
();
return
;
self
.
clearOverlayCollection
(
collection
)
if
(
ServerConnector
.
getSessionData
().
getShowComments
())
{
return
collection
.
refresh
().
then
(
function
(){
return
self
.
renderOverlayCollection
({
overlayCollection
:
collection
});
});
}
else
{
return
collection
.
clear
();
}
}
}
throw
"
comment OverlayCollection not found
"
;
throw
new
Error
(
"
comment OverlayCollection not found
"
)
;
};
CustomMap
.
prototype
.
turnOnOffDrawing
=
function
()
{
...
...
@@ -1708,8 +1717,26 @@ CustomMap.prototype.setProject = function(project) {
CustomMap
.
prototype
.
getProject
=
function
()
{
return
this
.
_project
;
};
CustomMap
.
prototype
.
getTopOverviewImage
=
function
()
{
return
this
.
getProject
().
getTopOverviewImage
();
};
CustomMap
.
prototype
.
addControl
=
function
(
element
)
{
if
(
this
.
_controls
[
element
.
id
]
!==
undefined
)
{
throw
new
Error
(
"
Element with id
"
+
element
.
id
+
"
already added to controls
"
);
};
if
(
ControlType
[
element
.
id
]
===
undefined
)
{
throw
new
Error
(
"
Unknown control type:
"
+
element
.
id
);
}
this
.
_controls
[
element
.
id
]
=
element
;
};
CustomMap
.
prototype
.
getControl
=
function
(
type
)
{
if
(
ControlType
[
type
]
===
undefined
)
{
throw
new
Error
(
"
Unknown control type:
"
+
type
);
}
return
this
.
_controls
[
type
];
};
module
.
exports
=
CustomMap
;
frontend-js/src/main/js/map/marker/AbstractMarker.js
View file @
256564ad
...
...
@@ -41,7 +41,7 @@ AbstractMarker.prototype.show = function() {
&&
this
.
getGoogleMarker
().
getMap
()
!==
null
)
{
logger
.
warn
(
"
Marker is already shown
"
);
}
else
{
this
.
getGoogleMarker
().
setMap
(
this
.
_map
.
map
);
this
.
getGoogleMarker
().
setMap
(
this
.
getCustomMap
().
getGoogleMap
()
);
return
;
}
};
...
...
frontend-js/src/main/js/map/overlay/CommentDbOverlay.js
View file @
256564ad
"
use strict
"
;
var
Promise
=
require
(
"
bluebird
"
);
var
OverlayCollection
=
require
(
'
./OverlayCollection
'
);
var
IdentifiedElement
=
require
(
'
../data/IdentifiedElement
'
);
...
...
@@ -21,11 +23,15 @@ CommentDbOverlay.prototype.refresh = function() {
for
(
var
i
=
0
;
i
<
comments
.
length
;
i
++
)
{
self
.
elements
.
push
(
new
IdentifiedElement
(
comments
[
i
]));
}
return
self
.
getMap
().
updateOverlayCollection
(
self
);
}).
then
(
function
()
{
resolve
(
self
.
elements
);
}).
catch
(
reject
);
});
};
CommentDbOverlay
.
prototype
.
clear
=
function
()
{
this
.
elements
=
[];
return
new
Promise
.
resolve
();
};
module
.
exports
=
CommentDbOverlay
;
frontend-js/src/test/js/SessionData-test.js
0 → 100644
View file @
256564ad
"
use strict
"
;
var
Helper
=
require
(
'
./helper
'
);
require
(
"
./mocha-config.js
"
);
var
SessionData
=
require
(
'
../../main/js/SessionData
'
);
var
chai
=
require
(
'
chai
'
);
var
assert
=
chai
.
assert
;
var
logger
=
require
(
'
./logger
'
);
describe
(
'
SessionData
'
,
function
()
{
var
helper
;
before
(
function
()
{
helper
=
new
Helper
();
});
it
(
'
setShowComments
'
,
function
()
{
var
session
=
new
SessionData
();
session
.
setShowComments
(
true
);
assert
.
ok
(
session
.
getShowComments
());
session
.
setShowComments
(
false
);
assert
.
notOk
(
session
.
getShowComments
());
});
});
frontend-js/src/test/js/map/CustomMap-test.js
View file @
256564ad
...
...
@@ -6,9 +6,12 @@ require("../mocha-config.js");
var
AliasMarker
=
require
(
'
../../../main/js/map/marker/AliasMarker
'
);
var
AliasOverlay
=
require
(
'
../../../main/js/map/overlay/AliasOverlay
'
);
var
CommentDbOverlay
=
require
(
'
../../../main/js/map/overlay/CommentDbOverlay
'
);
var
ControlType
=
require
(
'
../../../main/js/map/ControlType
'
);
var
CustomMap
=
require
(
'
../../../main/js/map/CustomMap
'
);
var
IdentifiedElement
=
require
(
'
../../../main/js/map/data/IdentifiedElement
'
);
var
OverlayCollection
=
require
(
'
../../../main/js/map/overlay/OverlayCollection
'
);
var
ReactionOverlay
=
require
(
'
../../../main/js/map/overlay/ReactionOverlay
'
);
var
logger
=
require
(
'
./../logger
'
);
...
...
@@ -50,11 +53,6 @@ describe('CustomMap', function() {
assert
.
ok
(
map
.
getSubmodelById
(
map
.
getId
()
+
""
));
});
it
(
"
customizeGoogleMapView 2
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
map
.
customizeGoogleMapView
(
true
);
});
it
(
"
openLayoutById (not existing)
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
try
{
...
...
@@ -591,4 +589,41 @@ describe('CustomMap', function() {
});
});
it
(
"
showComments
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
map
.
getControl
(
ControlType
.
COMMENT_CHECKBOX
).
click
();
assert
.
ok
(
ServerConnector
.
getSessionData
().
getShowComments
());
});
it
(
"
refreshComments
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
map
.
getModel
().
setId
(
15781
);
var
commentsOverlay
=
new
CommentDbOverlay
({
map
:
map
,
name
:
'
comment
'
});
ServerConnector
.
getSessionData
().
setShowComments
(
true
);
return
map
.
refreshComments
().
then
(
function
()
{
assert
.
ok
(
commentsOverlay
.
pointMarkers
[
'
(241.01, 372.35)
'
]);
assert
.
ok
(
commentsOverlay
.
pointMarkers
[
'
(643.96, 144.09)
'
]);
assert
.
notOk
(
commentsOverlay
.
pointMarkers
[
'
unkId
'
]);
});
});
it
(
"
hide comments
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
map
.
getModel
().
setId
(
15781
);
var
commentsOverlay
=
new
CommentDbOverlay
({
map
:
map
,
name
:
'
comment
'
});
ServerConnector
.
getSessionData
().
setShowComments
(
true
);
return
map
.
refreshComments
().
then
(
function
()
{
ServerConnector
.
getSessionData
().
setShowComments
(
false
);
return
map
.
refreshComments
();
}).
then
(
function
(){
assert
.
notOk
(
commentsOverlay
.
pointMarkers
[
'
(241.01, 372.35)
'
]);
});
});
});
frontend-js/src/test/js/map/overlay/CommentDbOverlay-test.js
0 → 100644
View file @
256564ad
"
use strict
"
;
var
Helper
=
require
(
'
../../Helper
'
);
var
logger
=
require
(
'
../../logger
'
);
var
CommentDbOverlay
=
require
(
'
../../../../main/js/map/overlay/CommentDbOverlay
'
);
var
OverlayCollection
=
require
(
'
../../../../main/js/map/overlay/OverlayCollection
'
);
var
assert
=
require
(
'
assert
'
);
describe
(
'
CommentDbOverlay
'
,
function
()
{
var
helper
;
before
(
function
()
{
helper
=
new
Helper
();
});
it
(
"
constructor 1
"
,
function
()
{
var
map
=
helper
.
createCustomMap
();
var
oc
=
new
CommentDbOverlay
({
map
:
map
,
name
:
'
test name
'
});
assert
.
ok
(
oc
);
assert
.
equal
(
oc
.
getName
(),
'
test name
'
);
});
});
web/src/main/webapp/index.xhtml
View file @
256564ad
...
...
@@ -32,7 +32,7 @@ function initMap(){
minerva
.
ServerConnector
.
getProject
(
minerva
.
GuiConnector
.
getParams
[
'
id
'
]).
then
(
function
(
project
){
var
windowsTouchInterface
=
((
navigator
.
appVersion
.
indexOf
(
"
Win
"
)
!=-
1
)
&&
(
'
ontouchstart
'
in
document
.
documentElement
));
var
overviewDiv
=
document
.
getElementById
(
"
overviewDiv
"
);
customMap
=
minerva
.
create
({
return
minerva
.
create
({
map
:
mapElement
,
project
:
project
,
hideDiv
:
document
.
getElementById
(
'
leftPanel
'
),
...
...
@@ -51,7 +51,9 @@ function initMap(){
{
name
:
"
comment
"
,
allowSearchById
:
false
,
allowGeneralSearch
:
true
},
],
});
},
function
(
rejectReason
){
}).
then
(
function
(
result
){
customMap
=
result
;
}).
catch
(
function
(
rejectReason
){
minerva
.
GuiConnector
.
alert
(
rejectReason
);
});
}
...
...
web/src/main/webapp/resources/js/minerva.js
View file @
256564ad
This diff is collapsed.
Click to expand it.
web/src/main/webapp/resources/js/minerva.js.map
View file @
256564ad
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment