Commit 2fdcef3d authored by Piotr Gawron's avatar Piotr Gawron
Browse files

stub of new admin panel

parent a6bcd928
"use strict";
/* exported logger */
var Promise = require("bluebird");
var CustomMapOptions = require('./map/CustomMapOptions');
var Header = require('./gui/Header');
var ObjectWithListeners = require('./ObjectWithListeners');
var CommentsAdminPanel = require('./gui/admin/CommentsAdminPanel');
var ConfigurationAdminPanel = require('./gui/admin/ConfigurationAdminPanel');
var MapsAdminPanel = require('./gui/admin/MapsAdminPanel');
var ServicesAdminPanel = require('./gui/admin/ServicesAdminPanel');
var UsersAdminPanel = require('./gui/admin/UsersAdminPanel');
var logger = require('./logger');
var Functions = require('./Functions');
/**
* Default constructor.
*
* @param options
* CustomMapOptions object representing all parameters needed for map
* creation
*/
function Admin(options) {
var self = this;
self._panels = [];
self._tabIdCount = 0;
if (!(options instanceof CustomMapOptions)) {
options = new CustomMapOptions(options);
}
self.setProject(options.getProject());
self.setElement(options.getElement());
self.setConfiguration(options.getConfiguration());
self._createGui();
}
Admin.prototype = Object.create(ObjectWithListeners.prototype);
Admin.prototype.constructor = ObjectWithListeners;
Admin.prototype._createGui = function() {
var self = this;
self.getElement().innerHTML = "";
var headerDiv = Functions.createElement({
type : "div"
});
new Header({
element : headerDiv,
customMap : null,
project : self.getProject(),
});
self.getElement().appendChild(headerDiv);
var panels = [ {
name : "COMMENTS",
panelClass : CommentsAdminPanel,
}, {
name : "MAPS",
panelClass : MapsAdminPanel,
}, {
name : "USERS",
panelClass : UsersAdminPanel,
}, {
name : "SERVICES",
panelClass : ServicesAdminPanel,
}, {
name : "CONFIGURATION",
panelClass : ConfigurationAdminPanel,
} ];
var tabDiv = Functions.createElement({
type : "div",
name : "tabView",
className : "tabbable boxed parentTabs"
});
self.getElement().appendChild(tabDiv);
var tabMenuDiv = Functions.createElement({
type : "ul",
className : "nav nav-tabs"
});
tabDiv.appendChild(tabMenuDiv);
var tabContentDiv = Functions.createElement({
type : "div",
className : "tab-content"
});
tabDiv.appendChild(tabContentDiv);
for (var i = 0; i < panels.length; i++) {
self.addTab(panels[i], tabMenuDiv, tabContentDiv);
}
};
Admin.prototype.addTab = function(params, navElement, contentElement) {
var self = this;
var name = params.name;
var tabId = "export_panel_tab_" + this._tabIdCount;
self._tabIdCount++;
var navClass = '';
var contentClass = 'tab-pane';
if (navElement.children.length === 0) {
navClass = "active";
contentClass = "tab-pane active";
}
var navLi = document.createElement("li");
navLi.className = navClass;
var navLink = document.createElement("a");
navLink.href = "#" + tabId;
if (name !== undefined) {
if (name.length > 12) {
name = name.substring(0, 10) + "...";
}
navLink.innerHTML = name;
}
navLink.onclick = function() {
$(this).tab('show');
};
navLi.appendChild(navLink);
if (name !== undefined) {
navLink.innerHTML = name;
}
navElement.appendChild(navLi);
var contentDiv = document.createElement("div");
contentDiv.style.height = "100%";
contentDiv.className = contentClass;
contentDiv.id = tabId;
contentElement.appendChild(contentDiv);
this._panels.push(new params.panelClass({
element : contentDiv,
project : self.getProject(),
configuration : self.getConfiguration(),
}));
};
Admin.prototype.setProject = function(project) {
this._project = project;
};
Admin.prototype.getProject = function() {
return this._project;
};
Admin.prototype.setElement = function(element) {
this._element = element;
};
Admin.prototype.getElement = function() {
return this._element;
};
Admin.prototype.init = function() {
var promises = [];
for (var i = 0; i < this._panels.length; i++) {
promises.push(this._panels[i].init());
}
return Promise.all(promises);
};
Admin.prototype.setConfiguration = function(configuration) {
this._configuration = configuration;
};
Admin.prototype.getConfiguration = function() {
return this._configuration;
};
module.exports = Admin;
"use strict";
/* exported logger */
var Panel = require('../Panel');
var Promise = require("bluebird");
function CommentsAdminPanel(params) {
params.scrollable = true;
Panel.call(this, params);
}
CommentsAdminPanel.prototype = Object.create(Panel.prototype);
CommentsAdminPanel.prototype.constructor = CommentsAdminPanel;
CommentsAdminPanel.prototype.init = function() {
};
module.exports = CommentsAdminPanel;
"use strict";
/* exported logger */
var Panel = require('../Panel');
var Promise = require("bluebird");
function ConfigurationAdminPanel(params) {
params.scrollable = true;
Panel.call(this, params);
}
ConfigurationAdminPanel.prototype = Object.create(Panel.prototype);
ConfigurationAdminPanel.prototype.constructor = ConfigurationAdminPanel;
ConfigurationAdminPanel.prototype.init = function() {
};
module.exports = ConfigurationAdminPanel;
"use strict";
/* exported logger */
var Panel = require('../Panel');
var Promise = require("bluebird");
function MapsAdminPanel(params) {
params.scrollable = true;
Panel.call(this, params);
}
MapsAdminPanel.prototype = Object.create(Panel.prototype);
MapsAdminPanel.prototype.constructor = MapsAdminPanel;
MapsAdminPanel.prototype.init = function() {
};
module.exports = MapsAdminPanel;
"use strict";
/* exported logger */
var Panel = require('../Panel');
var Promise = require("bluebird");
function ServicesAdminPanel(params) {
params.scrollable = true;
Panel.call(this, params);
}
ServicesAdminPanel.prototype = Object.create(Panel.prototype);
ServicesAdminPanel.prototype.constructor = ServicesAdminPanel;
ServicesAdminPanel.prototype.init = function() {
};
module.exports = ServicesAdminPanel;
"use strict";
/* exported logger */
var Panel = require('../Panel');
var Promise = require("bluebird");
function UsersAdminPanel(params) {
params.scrollable = true;
Panel.call(this, params);
}
UsersAdminPanel.prototype = Object.create(Panel.prototype);
UsersAdminPanel.prototype.constructor = UsersAdminPanel;
UsersAdminPanel.prototype.init = function() {
};
module.exports = UsersAdminPanel;
......@@ -5,6 +5,7 @@ var functions = require('./Functions');
var IdentifiedElement = require('./map/data/IdentifiedElement');
var AbstractDbOverlay = require('./map/overlay/AbstractDbOverlay');
var Admin = require('./Admin');
var DbOverlayCollection = require('./map/overlay/DbOverlayCollection');
var ConfigurationType = require('./ConfigurationType');
var CustomMap = require('./map/CustomMap');
......@@ -586,9 +587,36 @@ function createExport(params) {
});
}
function createAdmin(params) {
params = modifyParamsForTouchInterface(params);
if (!(params instanceof CustomMapOptions)) {
params = new CustomMapOptions(params);
}
initGlobals(params);
params.getElement().style.display = "table";
params.getElement().innerHTML = "<div style='vertical-align:middle;display:table-cell;text-align: center'>"
+ "<img src='resources/images/icons/ajax-loader.gif'/>" + "</div>";
var result;
// make sure that we are logged in
return ServerConnector.getToken().then(function() {
return ServerConnector.getConfiguration();
}).then(function(configuration) {
params.setConfiguration(configuration);
return getProject(params);
}).then(function(project) {
params.setProject(project);
result = new Admin(params);
return result.init();
}).then(function() {
return result;
});
}
var minerva = {
create : create,
createExport : createExport,
createAdmin: createAdmin,
ServerConnector : OriginalServerConnector,
GuiConnector : OriginalGuiConnector,
DualListbox : require('dual-listbox').DualListbox,
......
......@@ -496,4 +496,16 @@ describe('minerva global', function() {
});
});
it('create Admin', function() {
var options = null;
return ServerConnectorMock.getProject().then(function(project) {
options = helper.createCustomMapOptions(project);
return minerva.createAdmin(options);
}).then(function(result) {
assert.ok(result);
assert.equal(logger.getWarnings().length, 0);
});
});
});
......@@ -23,9 +23,7 @@
<security:intercept-url pattern="/login**" access="permitAll"/>
<security:intercept-url pattern="/index**" access="permitAll"/>
<security:intercept-url pattern="/miriam**" access="permitAll"/>
<security:intercept-url pattern="/export**" access="permitAll"/>
<security:intercept-url pattern="/expire**" access="permitAll"/>
<security:intercept-url pattern="/galaxy**" access="permitAll"/>
<security:intercept-url pattern="/map**" access="permitAll"/>
<security:intercept-url pattern="/map/**" access="permitAll"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
<h:head>
<script src="https://maps.google.com/maps/api/js?libraries=drawing&amp;v=3.26" type="text/javascript"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" type="text/javascript"/>
<script src="https://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.min.js" type="text/javascript"/>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css"/>
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
<link rel="shortcut icon" href="./resources/images/favicon.png" type="image/png" />
<h:outputScript library="js" name="minerva.js" />
<script type="text/javascript">
//<![CDATA[
function initMap(){
var element = document.getElementById('minervaAppDiv');
return minerva.createAdmin({
element : element,
}).then(function(result){
customMap = result;
document.title = result.getProject().getName();
}).catch(function(rejectReason){
minerva.GuiConnector.alert(rejectReason);
});
}
//]]>
</script>
</h:head>
<h:body onload="initMap();" >
<h:outputStylesheet library="css" name="style.css"/>
<h:outputStylesheet library="css" name="minerva.css" />
<h:outputStylesheet library="css" name="pileup.css"/>
<h:outputStylesheet library="css" name="bootstrap.min.css"/>
<h:outputScript library="primefaces" name="jquery/jquery.js" target="head" />
<div id="minervaAppDiv" style="height: 100%;width: 100%;margin: 0;"/>
</h:body>
</f:view>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment