Commit 09f1d2c2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

admin panel is not associated with a project

parent 7525b9a2
......@@ -5,7 +5,6 @@
var Promise = require("bluebird");
var CustomMapOptions = require('./map/CustomMapOptions');
var Header = require('./gui/Header');
var GuiUtils = require('./gui/leftPanel/GuiUtils');
var ObjectWithListeners = require('./ObjectWithListeners');
......@@ -45,16 +44,6 @@ Admin.prototype.constructor = ObjectWithListeners;
Admin.prototype._createGui = function () {
var self = this;
self.getElement().innerHTML = "";
var headerDiv = Functions.createElement({
type: "div"
});
self.setHeader(new Header({
element: headerDiv,
customMap: null,
project: self.getProject(),
adminLink: false
}));
self.getElement().appendChild(headerDiv);
var panels = [{
name: "PROJECTS",
......@@ -150,7 +139,6 @@ Admin.prototype.init = function () {
for (var i = 0; i < this._panels.length; i++) {
promises.push(this._panels[i].init());
}
promises.push(this.getHeader().init());
return Promise.all(promises).then(function () {
$(window).trigger('resize');
});
......@@ -164,14 +152,6 @@ Admin.prototype.getConfiguration = function () {
return this._configuration;
};
Admin.prototype.setHeader = function (header) {
this._header = header;
};
Admin.prototype.getHeader = function () {
return this._header;
};
Admin.prototype.setGuiUtils = function (guiUtils) {
this._guiUtils = guiUtils;
};
......@@ -183,7 +163,6 @@ Admin.prototype.getGuiUtils = function () {
Admin.prototype.destroy = function () {
var self = this;
var promises = [];
promises.push(self.getHeader().destroy());
for (var i = 0; i < self._panels.length; i++) {
promises.push(self._panels[i].destroy());
}
......
......@@ -154,7 +154,6 @@ UsersAdminPanel.prototype.getDialog = function (user) {
type: "div"
}),
user: user,
project: self.getProject(),
customMap: null
});
self._dialogs[user.getLogin()] = dialog;
......
......@@ -563,9 +563,6 @@ function createAdmin(params) {
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 () {
......
......@@ -11,7 +11,7 @@ var assert = require('assert');
describe('Admin', function () {
describe('constructor', function () {
it('default', function () {
var admin = new Admin(helper.createCustomMapOptions());
var admin = new Admin(helper.createCustomMapOptions(null));
assert.ok(admin);
admin.destroy();
});
......@@ -19,7 +19,7 @@ describe('Admin', function () {
describe('logout', function () {
it('default', function () {
var admin = new Admin(helper.createCustomMapOptions());
var admin = new Admin(helper.createCustomMapOptions(null));
helper.loginAsAdmin();
var token = ServerConnector.getSessionData().getToken();
return admin.init().then(function () {
......
......@@ -13,14 +13,9 @@ describe('ConfigurationAdminPanel', function () {
it('init', function () {
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new ConfigurationAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
......@@ -31,14 +26,9 @@ describe('ConfigurationAdminPanel', function () {
});
it('saveOption', function () {
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new ConfigurationAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
......
......@@ -12,14 +12,9 @@ describe('MapsAdminPanel', function () {
it('refresh', function () {
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new MapsAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
......@@ -32,19 +27,14 @@ describe('MapsAdminPanel', function () {
});
it('showLogs', function () {
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new MapsAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
}).then(function () {
return mapTab.showLogs(project.getProjectId(), 'error');
return mapTab.showLogs("sample", 'error');
}).then(function () {
assert.equal(0, logger.getWarnings().length);
return mapTab.destroy();
......@@ -54,18 +44,15 @@ describe('MapsAdminPanel', function () {
it('getDialog', function () {
helper.loginAsAdmin();
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new MapsAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
}).then(function () {
return ServerConnector.getProject();
}).then(function (project) {
return mapTab.getDialog(project);
}).then(function (dialog) {
assert.ok(dialog.getListeners("onSave").length > 0);
......@@ -77,14 +64,9 @@ describe('MapsAdminPanel', function () {
describe('onAddClicked', function () {
it('default', function () {
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new MapsAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
......@@ -96,14 +78,9 @@ describe('MapsAdminPanel', function () {
});
it('close and reopen', function () {
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new MapsAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
......
......@@ -17,14 +17,9 @@ describe('UsersAdminPanel', function () {
it('default', function () {
helper.loginAsAdmin();
var usersTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
usersTab = new UsersAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return usersTab.init();
......@@ -35,18 +30,13 @@ describe('UsersAdminPanel', function () {
});
it('user without access', function () {
var usersTab;
var project;
var oldFun = ServerConnector.getUsers;
ServerConnector.getUsers = function () {
return Promise.reject(new SecurityError("Access denied."));
};
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
usersTab = new UsersAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return usersTab.init();
......@@ -63,14 +53,9 @@ describe('UsersAdminPanel', function () {
it('refresh', function () {
helper.loginAsAdmin();
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new UsersAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
......@@ -84,14 +69,9 @@ describe('UsersAdminPanel', function () {
it('showEditDialog', function () {
helper.loginAsAdmin();
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new UsersAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
......@@ -104,14 +84,9 @@ describe('UsersAdminPanel', function () {
it('onAddClicked', function () {
helper.loginAsAdmin();
var mapTab;
var project;
return ServerConnector.getProject().then(function (result) {
project = result;
return ServerConnector.getConfiguration();
}).then(function (configuration) {
return ServerConnector.getConfiguration().then(function (configuration) {
mapTab = new UsersAdminPanel({
element: testDiv,
project: project,
configuration: configuration
});
return mapTab.init();
......
......@@ -270,13 +270,10 @@ describe('minerva global', function () {
describe('createAdmin', function () {
it('as admin', function () {
helper.loginAsAdmin();
var options = null;
var options = helper.createCustomMapOptions(null);
var url = window.location.href;
return ServerConnectorMock.getProject().then(function (project) {
options = helper.createCustomMapOptions(project);
return minerva.createAdmin(options);
}).then(function (result) {
return minerva.createAdmin(options).then(function (result) {
assert.ok(result);
assert.equal(logger.getWarnings().length, 0);
assert.equal(url, window.location.href);
......
......@@ -40,7 +40,6 @@ function initMap(){
}).then(function(result){
if (result!==undefined) {
customMap = result;
document.title = result.getProject().getName();
}
}).catch(function(rejectReason){
minerva.GuiConnector.alert(rejectReason);
......
Supports Markdown
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