Commit bd6f29a0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

frontend uses new api

parent 31163db5
......@@ -2843,6 +2843,18 @@ ServerConnector.uploadFile = function (params) {
};
/**
*
* @param {Object} [params]
* @param {number} [params.start]
* @param {number} [params.length]
* @param {string} [params.sortColumn]
* @param {string} [params.sortOrder]
* @param {string} [params.search]
* @param {string} [params.level]
* @param {string} [params.projectId]
* @return {Promise}
*/
ServerConnector.getProjectLogs = function (params) {
var self = this;
if (params === undefined) {
......
......@@ -18,7 +18,8 @@ var GuiConnector = require('../../GuiConnector');
* @param {CustomMap} [params.customMap]
* @param {Configuration} params.configuration
* @param {Project} [params.project]
* @param {ServerConnector} [params.serverConnector]
* @param {string} params.projectId
* @param {ServerConnector} params.serverConnector
*
* @constructor
* @extends AbstractGuiElement
......@@ -27,7 +28,11 @@ function LogListDialog(params) {
AbstractGuiElement.call(this, params);
var self = this;
self.createLogListDialogGui();
self._level = params.level;
/**
* @type {string}
* @private
*/
self._projectId = params.projectId;
}
......@@ -41,9 +46,10 @@ LogListDialog.prototype.createLogListDialogGui = function () {
var self = this;
var head = Functions.createElement({
type: "thead",
content: "<tr>" + "<th>ID</th>" +
"<th>Content</th>" +
"</tr>"
content: "<tr>" +
"<th>ID</th>" +
"<th>Content</th>" +
"</tr>"
});
var body = Functions.createElement({
type: "tbody"
......@@ -95,20 +101,24 @@ LogListDialog.prototype.createLogListDialogGui = function () {
/**
*
* @param {Object} data
* @param {number} data.start
* @param {number} data.length
* @param {Object} data.search
* @param {Object} data.draw
* @param {Array} data.order
* @param {function} callback
* @returns {Promise}
* @private
*/
LogListDialog.prototype._dataTableAjaxCall = function (data, callback) {
var self = this;
return ServerConnector.getProjectLogs({
return self.getServerConnector().getProjectLogs({
start: data.start,
length: data.length,
sortColumn: self.getColumnsDefinition()[data.order[0].column].name,
sortOrder: data.order[0].dir,
search: data.search.value,
projectId: self._projectId,
level: self._level
projectId: self._projectId
}).then(function (logEntries) {
var out = [];
for (var i = 0; i < logEntries.data.length; i++) {
......@@ -130,16 +140,13 @@ LogListDialog.prototype._dataTableAjaxCall = function (data, callback) {
/**
*
* @param {Object} data
* @param {function} callback
* @returns {Promise}
*/
LogListDialog.prototype.downloadAll = function (data, callback) {
LogListDialog.prototype.downloadAll = function () {
var self = this;
return ServerConnector.getProjectLogs({
return self.getServerConnector().getProjectLogs({
length: 2147483646,
projectId: self._projectId,
level: self._level
projectId: self._projectId
}).then(function (logEntries) {
var tmp = [];
for (var i = 0; i < logEntries.data.length; i++) {
......@@ -170,8 +177,8 @@ LogListDialog.prototype.open = function () {
serverSide: true,
ordering: true,
searching: true,
ajax: function (data, callback, settings) {
resolve(self._dataTableAjaxCall(data, callback, settings));
ajax: function (data, callback) {
resolve(self._dataTableAjaxCall(data, callback));
},
columns: self.getColumnsDefinition()
});
......
......@@ -174,15 +174,11 @@ MapsAdminPanel.prototype._createProjectTableRow = function () {
$(projectsTable).on("click", "[name='showEditDialog']", function () {
var button = this;
return self.showEditDialog($(button).attr("data")).then(null, GuiConnector.alert);
return self.showEditDialog($(button).attr("data")).catch(GuiConnector.alert);
});
$(projectsTable).on("click", "[name='showErrors']", function () {
$(projectsTable).on("click", "[name='showLogEntries']", function () {
var button = this;
return self.showLogs($(button).attr("data"), 'error').then(null, GuiConnector.alert);
});
$(projectsTable).on("click", "[name='showWarnings']", function () {
var button = this;
return self.showLogs($(button).attr("data"), 'warning').then(null, GuiConnector.alert);
return self.showLogs($(button).attr("data")).catch(GuiConnector.alert);
});
return projectsRow;
......@@ -237,18 +233,10 @@ MapsAdminPanel.prototype.projectToTableRow = function (project, row, user) {
user.hasPrivilege(self.getConfiguration().getPrivilegeType(PrivilegeType.IS_CURATOR));
var icon;
if (project.hasErrors()) {
icon = "<i class='fa fa-exclamation-triangle' style='font-size:18px; font-weight:400; padding-right:10px;color:red'></i>";
if (isAdmin) {
status += "<a name='showErrors' href='#' data='" + project.getProjectId() + "'>" + icon + "</a>";
} else {
status += icon;
}
}
if (project.hasWarnings()) {
if (project.hasLogEntries()) {
icon = "<i class='fa fa-exclamation-triangle' style='font-size:18px; font-weight:400; padding-right:10px;color:black'></i>";
if (isAdmin) {
status += "<a name='showWarnings' href='#' data='" + project.getProjectId() + "'>" + icon + "</a>";
status += "<a name='showLogEntries' href='#' data='" + project.getProjectId() + "'>" + icon + "</a>";
} else {
status += icon;
}
......@@ -502,15 +490,14 @@ MapsAdminPanel.prototype.getDialog = function (project) {
/**
*
* @param {string} projectId
* @param {string} level
* @returns {Promise<LogListDialog>}
*/
MapsAdminPanel.prototype.getLogDialog = function (projectId, level) {
MapsAdminPanel.prototype.getLogDialog = function (projectId) {
var self = this;
if (self._logDialogs === undefined) {
self._logDialogs = [];
}
var dialog = self._logDialogs[projectId + "-" + level];
var dialog = self._logDialogs[projectId];
if (dialog === undefined) {
dialog = new LogListDialog({
element: Functions.createElement({
......@@ -518,10 +505,10 @@ MapsAdminPanel.prototype.getLogDialog = function (projectId, level) {
}),
configuration: self.getConfiguration(),
projectId: projectId,
customMap: null,
level: level
serverConnector: self.getServerConnector(),
customMap: null
});
self._logDialogs[projectId + "-" + level] = dialog;
self._logDialogs[projectId] = dialog;
return dialog.init().then(function () {
return dialog;
});
......@@ -550,13 +537,12 @@ MapsAdminPanel.prototype.showEditDialog = function (id) {
/**
*
* @param {string} id projectId
* @param {string} level
* @returns {Promise<LogListDialog>}
*/
MapsAdminPanel.prototype.showLogs = function (id, level) {
MapsAdminPanel.prototype.showLogs = function (id) {
var self = this;
GuiConnector.showProcessing();
return self.getLogDialog(id, level).then(function (dialog) {
return self.getLogDialog(id).then(function (dialog) {
return dialog.open();
}).finally(function () {
GuiConnector.hideProcessing();
......
......@@ -78,8 +78,7 @@ Project.prototype.loadFromData = function (data) {
self.setStatus(data.status);
self.setNotifyEmail(data.notifyEmail);
self.setProgress(data.progress);
self.setHasWarnings(data.warnings);
self.setHasErrors(data.errors);
self.setHasLogEntries(data.logEntries);
self.setMapCanvasType(data.mapCanvasType);
}
};
......@@ -114,8 +113,7 @@ Project.prototype._update = function (data) {
self.setStatus(data.getStatus());
self.setProgress(data.getProgress());
self.setNotifyEmail(data.getNotifyEmail());
self.setHasWarnings(data.hasWarnings());
self.setHasErrors(data.hasErrors());
self.setHasLogEntries(data.hasLogEntries());
self.setMapCanvasType(data.getMapCanvasType());
if (data.getModels() !== undefined) {
......@@ -146,33 +144,18 @@ Project.prototype.setId = function (id) {
*
* @returns {boolean}
*/
Project.prototype.hasErrors = function () {
return this._hasErrors === true;
Project.prototype.hasLogEntries = function () {
return this._hasLogEntries === true;
};
/**
*
* @param {boolean} hasErrors
* @param {boolean} hasLogEntries
*/
Project.prototype.setHasErrors = function (hasErrors) {
this._hasErrors = hasErrors;
Project.prototype.setHasLogEntries = function (hasLogEntries) {
this._hasLogEntries = hasLogEntries;
};
/**
*
* @returns {boolean}
*/
Project.prototype.hasWarnings = function () {
return this._hasWarnings === true;
};
/**
*
* @param {boolean} hasWarnings
*/
Project.prototype.setHasWarnings = function (hasWarnings) {
this._hasWarnings = hasWarnings;
};
/**
*
......
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