Commit 2f766f5c by kevalbhatt

ATLAS-3943: UI: Show Import/Export operations in administration audit.

parent 24bb6b08
...@@ -137,6 +137,10 @@ ...@@ -137,6 +137,10 @@
overflow: auto; overflow: auto;
} }
.admin-details .attributeResultContainer {
float: left;
}
.tab-pane { .tab-pane {
.business-metadata-attr-page { .business-metadata-attr-page {
position: absolute; position: absolute;
......
...@@ -481,6 +481,10 @@ div.columnmanager-dropdown-container { ...@@ -481,6 +481,10 @@ div.columnmanager-dropdown-container {
font-size: large; font-size: large;
font-weight: bold; font-weight: bold;
} }
.noToggle {
color: $gray;
}
} }
.backgrid-internal-table { .backgrid-internal-table {
......
...@@ -44,7 +44,15 @@ define(["require", "backbone"], function(require) { ...@@ -44,7 +44,15 @@ define(["require", "backbone"], function(require) {
BUSINESS_ATTRIBUTE_DELETE: "Business Attribute(s) Deleted", BUSINESS_ATTRIBUTE_DELETE: "Business Attribute(s) Deleted",
TYPE_DEF_UPDATE: "Type Updated", TYPE_DEF_UPDATE: "Type Updated",
TYPE_DEF_CREATE: "Type Created", TYPE_DEF_CREATE: "Type Created",
TYPE_DEF_DELETE: "Type Deleted" TYPE_DEF_DELETE: "Type Deleted",
IMPORT: "Import",
EXPORT: "Export"
}
Enums.serverAudits = {
SERVER_START: "Server Start",
SERVER_STOP: "Server End",
SERVER_STATE_ACTIVE: "Server State Active",
SERVER_STATE_PASSIVE: "Server Statae Passive"
} }
Enums.category = { Enums.category = {
...@@ -58,7 +66,9 @@ define(["require", "backbone"], function(require) { ...@@ -58,7 +66,9 @@ define(["require", "backbone"], function(require) {
MAP: "Map", MAP: "Map",
RELATIONSHIP: "Relationship", RELATIONSHIP: "Relationship",
BUSINESS_METADATA: "Business Metadata", BUSINESS_METADATA: "Business Metadata",
PURGE: "Purge Entities" PURGE: "Purge Entities",
IMPORT: "Import Entities",
EXPORT: "Export Entities"
} }
Enums.entityStateReadOnly = { Enums.entityStateReadOnly = {
...@@ -261,7 +271,7 @@ define(["require", "backbone"], function(require) { ...@@ -261,7 +271,7 @@ define(["require", "backbone"], function(require) {
"This Month": "THIS_MONTH", "This Month": "THIS_MONTH",
"Last Month": "LAST_MONTH", "Last Month": "LAST_MONTH",
"This Quarter": "THIS_QUARTER", "This Quarter": "THIS_QUARTER",
"Last Quarter":"LAST_QUARTER", "Last Quarter": "LAST_QUARTER",
"This Year": "THIS_YEAR", "This Year": "THIS_YEAR",
"Last Year": "LAST_YEAR", "Last Year": "LAST_YEAR",
"Last 3 Months": "LAST_3_MONTHS", "Last 3 Months": "LAST_3_MONTHS",
......
...@@ -211,8 +211,12 @@ define(['require', 'utils/Utils', 'lossless-json', 'marionette', 'backgrid', 'as ...@@ -211,8 +211,12 @@ define(['require', 'utils/Utils', 'lossless-json', 'marionette', 'backgrid', 'as
render: function() { render: function() {
/* follow along with the original render really... */ /* follow along with the original render really... */
this.$el.empty(); this.$el.empty();
var isExpand = true;
if (this.column.get('isExpandVisible')) {
isExpand = this.column.get('isExpandVisible')(this.$el, this.model);
}
this.$toggleEl = $(this.toggle).addClass(this.toggleClass).addClass(this.toggleCollapsedClass); this.$toggleEl = $(this.toggle).addClass(this.toggleClass).addClass(this.toggleCollapsedClass);
this.$toggleEl = isExpand ? this.$toggleEl : this.$toggleEl.addClass("noToggle");
this.$el.append(this.$toggleEl); this.$el.append(this.$toggleEl);
...@@ -224,6 +228,10 @@ define(['require', 'utils/Utils', 'lossless-json', 'marionette', 'backgrid', 'as ...@@ -224,6 +228,10 @@ define(['require', 'utils/Utils', 'lossless-json', 'marionette', 'backgrid', 'as
setToggle: function() { setToggle: function() {
var detailsRow = this.$el.data('details'); var detailsRow = this.$el.data('details');
var toggle = this.$toggleEl; var toggle = this.$toggleEl;
/* if there's details data is not there/undefined and $toggleEl having noToggle class, no need to expand */
if (!detailsRow && this.$toggleEl.hasClass('noToggle')) {
return false;
}
/* if there's details data already stored, then we'll remove it */ /* if there's details data already stored, then we'll remove it */
if (detailsRow) { if (detailsRow) {
......
...@@ -23,8 +23,9 @@ define(['require', ...@@ -23,8 +23,9 @@ define(['require',
'utils/Utils', 'utils/Utils',
'utils/UrlLinks', 'utils/UrlLinks',
'utils/CommonViewFunction', 'utils/CommonViewFunction',
'utils/Enums' 'utils/Enums',
], function(require, Backbone, AdminAuditTableLayoutView_tmpl, VEntityList, Utils, UrlLinks, CommonViewFunction, Enums) { 'moment'
], function(require, Backbone, AdminAuditTableLayoutView_tmpl, VEntityList, Utils, UrlLinks, CommonViewFunction, Enums, moment) {
'use strict'; 'use strict';
var AdminAuditTableLayoutView = Backbone.Marionette.LayoutView.extend( var AdminAuditTableLayoutView = Backbone.Marionette.LayoutView.extend(
...@@ -87,12 +88,22 @@ define(['require', ...@@ -87,12 +88,22 @@ define(['require',
includePagination: false, includePagination: false,
includeAtlasPagination: true, includeAtlasPagination: true,
includeFooterRecords: false, includeFooterRecords: false,
includeColumnManager: false, includeColumnManager: true,
includeOrderAbleColumns: false, includeOrderAbleColumns: false,
includeSizeAbleColumns: false, includeSizeAbleColumns: false,
includeTableLoader: true, includeTableLoader: true,
includeAtlasPageSize: true, includeAtlasPageSize: true,
includeAtlasTableSorting: true, includeAtlasTableSorting: true,
columnOpts: {
opts: {
initialColumnsVisible: null,
saveState: false
},
visibilityControlOpts: {
buttonTemplate: _.template("<button class='btn btn-action btn-sm pull-right'>Columns&nbsp<i class='fa fa-caret-down'></i></button>")
},
el: this.ui.colManager
},
atlasPaginationOpts: { atlasPaginationOpts: {
limit: this.limit, limit: this.limit,
offset: this.offset, offset: this.offset,
...@@ -186,8 +197,15 @@ define(['require', ...@@ -186,8 +197,15 @@ define(['require',
createTableWithValues: function(tableDetails, isAdminAudit) { createTableWithValues: function(tableDetails, isAdminAudit) {
var attrTable = CommonViewFunction.propertyTable({ var attrTable = CommonViewFunction.propertyTable({
scope: this, scope: this,
getValue: function(val, key) {
if (key && key.toLowerCase().indexOf("time") > 0) {
return Utils.formatDate({ date: val });
} else {
return val;
}
},
valueObject: tableDetails, valueObject: tableDetails,
fromAdminAudit: isAdminAudit guidHyperLink: !isAdminAudit
}); });
return attrTable; return attrTable;
}, },
...@@ -203,48 +221,35 @@ define(['require', ...@@ -203,48 +221,35 @@ define(['require',
fixWidth: "20", fixWidth: "20",
accordion: false, accordion: false,
alwaysVisible: true, alwaysVisible: true,
renderable: true,
isExpandVisible: function(el, model) {
if (Enums.serverAudits[model.get('operation')]) {
return false;
} else {
return true;
}
},
expand: function(el, model) { expand: function(el, model) {
var operation = model.get('operation'), var operation = model.get('operation'),
results = model.get('result') || null, results = model.get('result') || null,
adminText = 'No records found', adminText = 'No records found',
adminTypDetails = null; adminTypDetails = null,
el.attr('colspan', '7'); auditData = {
operation: operation,
model: model,
results: results,
adminText: adminText,
adminTypDetails: adminTypDetails
};
el.attr('colspan', '8');
if (results) { if (results) {
var adminValues = null; var adminValues = null;
if (operation == "PURGE") { if (operation == "PURGE") {
adminValues = '<ul class="col-sm-6">'; adminText = that.displayPurgeAndImportAudits(auditData);
var guids = results.replace('[', '').replace(']', '').split(','); } else if (operation == "EXPORT" || operation == "IMPORT") {
adminTypDetails = Enums.category[operation]; adminText = that.displayExportAudits(auditData);
_.each(guids, function(adminGuid, index) {
if (index % 5 == 0 && index != 0) {
adminValues += '</ul><ul class="col-sm-6">';
}
adminValues += '<li class="blue-link" data-id="adminPurgedEntity" >' + adminGuid.trim() + '</li>';
})
adminValues += '</ul>';
adminText = '<div class="row"><div class="attr-details"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>' + adminValues + '</div></div>';
} else { } else {
var resultData = JSON.parse(results), adminText = that.displayCreateUpdateAudits(auditData);
typeName = model.get('params').split(','),
typeContainer = '';
_.each(typeName, function(name) {
var typeData = resultData[name],
adminValues = (typeName.length == 1) ? '<ul class="col-sm-4">' : '<ul>';
adminTypDetails = Enums.category[name] + " " + Enums.auditAction[operation];
typeContainer += '<div class="attr-type-container"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>';
_.each(typeData, function(typeDefObj, index) {
if (index % 5 == 0 && index != 0 && typeName.length == 1) {
adminValues += '</ul><ul class="col-sm-4">';
}
var panelId = typeDefObj.name.split(" ").join("") + model.get('startTime');
that.adminAuditEntityData[panelId] = typeDefObj;
adminValues += '<li class="blue-link" data-id="adminAuditEntityDetails" data-auditEntityId=' + panelId + '>' + typeDefObj.name + '</li>';
});
adminValues += '</ul>';
typeContainer += adminValues + '</div>';
})
var typeClass = (typeName.length == 1) ? null : "admin-audit-details";
adminText = '<div class="row"><div class="attr-details ' + typeClass + '">' + typeContainer + '</div></div>';
} }
} }
$(el).append($('<div>').html(adminText)); $(el).append($('<div>').html(adminText));
...@@ -253,40 +258,73 @@ define(['require', ...@@ -253,40 +258,73 @@ define(['require',
userName: { userName: {
label: "Users", label: "Users",
cell: "html", cell: "html",
renderable: true,
editable: false editable: false
}, },
operation: { operation: {
label: "Operation", label: "Operation",
cell: "String", cell: "String",
renderable: true,
editable: false editable: false
}, },
clientId: { clientId: {
label: "Client ID", label: "Client ID",
cell: "String", cell: "String",
renderable: true,
editable: false editable: false
}, },
resultCount: { resultCount: {
label: "Result Count", label: "Result Count",
cell: "String", cell: "String",
editable: false renderable: true,
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
if (Enums.serverAudits[model.get('operation')]) {
return "N/A"
} else {
return rawValue;
}
}
})
}, },
startTime: { startTime: {
label: "Start Time", label: "Start Time",
cell: "html", cell: "html",
renderable: true,
editable: false, editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, { formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) { fromRaw: function(rawValue, model) {
return new Date(rawValue); return Utils.formatDate({ date: rawValue });
} }
}) })
}, },
endTime: { endTime: {
label: "End Time", label: "End Time",
cell: "html", cell: "html",
renderable: true,
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
return Utils.formatDate({ date: rawValue });
}
})
},
duration: {
label: "Duration",
cell: "html",
renderable: false,
editable: false, editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, { formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) { fromRaw: function(rawValue, model) {
return new Date(rawValue); var startTime = model.get('startTime') ? parseInt(model.get('startTime')) : null,
endTime = model.get('endTime') ? parseInt(model.get('endTime')) : null;
if (_.isNumber(startTime) && _.isNumber(endTime)) {
var duration = moment.duration(moment(endTime).diff(moment(startTime)));
return Utils.millisecondsToTime(duration);
} else {
return "N/A";
}
} }
}) })
} }
...@@ -310,14 +348,91 @@ define(['require', ...@@ -310,14 +348,91 @@ define(['require',
}; };
this.showModal(modalData); this.showModal(modalData);
}, },
displayPurgeAndImportAudits: function(obj) {
var adminValues = '<ul class="col-sm-6">',
guids = null,
adminTypDetails = Enums.category[obj.operation];
if (obj.operation == "PURGE") {
guids = obj.results ? obj.results.replace('[', '').replace(']', '').split(',') : guids;
} else {
guids = obj.model.get('params') ? obj.model.get('params').split(',') : guids;
}
_.each(guids, function(adminGuid, index) {
if (index % 5 == 0 && index != 0) {
adminValues += '</ul><ul class="col-sm-6">';
}
adminValues += '<li class="blue-link" data-id="adminPurgedEntity" data-operation=' + obj.operation + '>' + adminGuid.trim() + '</li>';
})
adminValues += '</ul>';
return '<div class="row"><div class="attr-details"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>' + adminValues + '</div></div>';
},
displayExportAudits: function(obj) {
var adminValues = "",
adminTypDetails = (obj.operation === 'IMPORT') ? Enums.category[obj.operation] : Enums.category[obj.operation] + " And Options",
resultData = obj.results ? JSON.parse(obj.results) : null,
paramsData = (obj.model && obj.model.get('params')) ? { params: [obj.model.get('params')] } : null;
if (resultData) {
adminValues += this.showImportExportTable(resultData, obj.operation);
}
if (paramsData) {
adminValues += this.showImportExportTable(paramsData);
}
adminValues = adminValues ? adminValues : obj.adminText;
return '<div class="row"><div class="attr-details"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>' + adminValues + '</div></div>';
},
showImportExportTable: function(obj, operations) {
var that = this,
typeDetails = "",
view = '<ul class="col-sm-5 import-export"><table class="table admin-audit-details bold-key" ><tbody >';
if (operations && operations === "IMPORT") {
var importKeys = Object.keys(obj);
_.each(importKeys, function(key, index) {
var newObj = {};
newObj[key] = obj[key];
if (index % 5 === 0 && index != 0) {
view += '</tbody></table></ul><ul class="col-sm-5 import-export"><table class="table admin-audit-details bold-key" ><tbody >';
}
view += that.createTableWithValues(newObj, true);
})
} else {
view += this.createTableWithValues(obj, true);
}
return view += '</tbody></table></ul>';;
},
displayCreateUpdateAudits: function(obj) {
var that = this,
resultData = JSON.parse(obj.results),
typeName = obj.model ? obj.model.get('params').split(',') : null,
typeContainer = '';
_.each(typeName, function(name) {
var typeData = resultData[name],
adminValues = (typeName.length == 1) ? '<ul class="col-sm-4">' : '<ul>',
adminTypDetails = Enums.category[name] + " " + Enums.auditAction[obj.operation];
typeContainer += '<div class="attr-type-container"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>';
_.each(typeData, function(typeDefObj, index) {
if (index % 5 == 0 && index != 0 && typeName.length == 1) {
adminValues += '</ul><ul class="col-sm-4">';
}
var panelId = typeDefObj.name.split(" ").join("") + obj.model.get('startTime');
that.adminAuditEntityData[panelId] = typeDefObj;
adminValues += '<li class="blue-link" data-id="adminAuditEntityDetails" data-auditEntityId=' + panelId + '>' + typeDefObj.name + '</li>';
});
adminValues += '</ul>';
typeContainer += adminValues + '</div>';
})
var typeClass = (typeName.length == 1) ? null : "admin-audit-details";
return '<div class="row"><div class="attr-details ' + typeClass + '">' + typeContainer + '</div></div>';
},
onClickAdminPurgedEntity: function(e) { onClickAdminPurgedEntity: function(e) {
var that = this; var that = this;
require(['views/audit/AuditTableLayoutView'], function(AuditTableLayoutView) { require(['views/audit/AuditTableLayoutView'], function(AuditTableLayoutView) {
var obj = { var obj = {
guid: $(e.target).text(), guid: $(e.target).text(),
titleText: (e.target.dataset.operation == "PURGE") ? "Purged Entity Details: " : "Import Details: "
}, },
modalData = { modalData = {
title: "Purged Entity Details: " + obj.guid, title: obj.titleText + obj.guid,
content: new AuditTableLayoutView(obj), content: new AuditTableLayoutView(obj),
mainClass: "modal-full-screen", mainClass: "modal-full-screen",
okCloses: true, okCloses: true,
......
...@@ -192,7 +192,6 @@ define(['require', ...@@ -192,7 +192,6 @@ define(['require',
require([ require([
'views/audit/CreateAuditTableLayoutView', 'views/audit/CreateAuditTableLayoutView',
], function(CreateAuditTableLayoutView) { ], function(CreateAuditTableLayoutView) {
that.action = model.get('action'); that.action = model.get('action');
// $(el.target).attr('disabled', true); // $(el.target).attr('disabled', true);
var eventModel = that.entityCollection.fullCollection.findWhere({ 'eventKey': model.get('eventKey') }).toJSON(), var eventModel = that.entityCollection.fullCollection.findWhere({ 'eventKey': model.get('eventKey') }).toJSON(),
......
...@@ -137,6 +137,10 @@ ...@@ -137,6 +137,10 @@
overflow: auto; overflow: auto;
} }
.admin-details .attributeResultContainer {
float: left;
}
.tab-pane { .tab-pane {
.business-metadata-attr-page { .business-metadata-attr-page {
position: absolute; position: absolute;
......
...@@ -485,6 +485,10 @@ div.columnmanager-dropdown-container { ...@@ -485,6 +485,10 @@ div.columnmanager-dropdown-container {
font-size: large; font-size: large;
font-weight: bold; font-weight: bold;
} }
.noToggle {
color: $gray;
}
} }
.backgrid-internal-table { .backgrid-internal-table {
......
...@@ -44,7 +44,15 @@ define(["require", "backbone"], function(require) { ...@@ -44,7 +44,15 @@ define(["require", "backbone"], function(require) {
BUSINESS_ATTRIBUTE_DELETE: "Business Attribute(s) Deleted", BUSINESS_ATTRIBUTE_DELETE: "Business Attribute(s) Deleted",
TYPE_DEF_UPDATE: "Type Updated", TYPE_DEF_UPDATE: "Type Updated",
TYPE_DEF_CREATE: "Type Created", TYPE_DEF_CREATE: "Type Created",
TYPE_DEF_DELETE: "Type Deleted" TYPE_DEF_DELETE: "Type Deleted",
IMPORT: "Import",
EXPORT: "Export"
}
Enums.serverAudits = {
SERVER_START: "Server Start",
SERVER_STOP: "Server End",
SERVER_STATE_ACTIVE: "Server State Active",
SERVER_STATE_PASSIVE: "Server Statae Passive"
} }
Enums.category = { Enums.category = {
...@@ -58,7 +66,9 @@ define(["require", "backbone"], function(require) { ...@@ -58,7 +66,9 @@ define(["require", "backbone"], function(require) {
MAP: "Map", MAP: "Map",
RELATIONSHIP: "Relationship", RELATIONSHIP: "Relationship",
BUSINESS_METADATA: "Business Metadata", BUSINESS_METADATA: "Business Metadata",
PURGE: "Purge Entities" PURGE: "Purge Entities",
IMPORT: "Import Entities",
EXPORT: "Export Entities"
} }
Enums.entityStateReadOnly = { Enums.entityStateReadOnly = {
...@@ -261,7 +271,7 @@ define(["require", "backbone"], function(require) { ...@@ -261,7 +271,7 @@ define(["require", "backbone"], function(require) {
"This Month": "THIS_MONTH", "This Month": "THIS_MONTH",
"Last Month": "LAST_MONTH", "Last Month": "LAST_MONTH",
"This Quarter": "THIS_QUARTER", "This Quarter": "THIS_QUARTER",
"Last Quarter":"LAST_QUARTER", "Last Quarter": "LAST_QUARTER",
"This Year": "THIS_YEAR", "This Year": "THIS_YEAR",
"Last Year": "LAST_YEAR", "Last Year": "LAST_YEAR",
"Last 3 Months": "LAST_3_MONTHS", "Last 3 Months": "LAST_3_MONTHS",
......
...@@ -211,8 +211,12 @@ define(['require', 'utils/Utils', 'lossless-json', 'marionette', 'backgrid', 'as ...@@ -211,8 +211,12 @@ define(['require', 'utils/Utils', 'lossless-json', 'marionette', 'backgrid', 'as
render: function() { render: function() {
/* follow along with the original render really... */ /* follow along with the original render really... */
this.$el.empty(); this.$el.empty();
var isExpand = true;
if (this.column.get('isExpandVisible')) {
isExpand = this.column.get('isExpandVisible')(this.$el, this.model);
}
this.$toggleEl = $(this.toggle).addClass(this.toggleClass).addClass(this.toggleCollapsedClass); this.$toggleEl = $(this.toggle).addClass(this.toggleClass).addClass(this.toggleCollapsedClass);
this.$toggleEl = isExpand ? this.$toggleEl : this.$toggleEl.addClass("noToggle");
this.$el.append(this.$toggleEl); this.$el.append(this.$toggleEl);
...@@ -224,6 +228,10 @@ define(['require', 'utils/Utils', 'lossless-json', 'marionette', 'backgrid', 'as ...@@ -224,6 +228,10 @@ define(['require', 'utils/Utils', 'lossless-json', 'marionette', 'backgrid', 'as
setToggle: function() { setToggle: function() {
var detailsRow = this.$el.data('details'); var detailsRow = this.$el.data('details');
var toggle = this.$toggleEl; var toggle = this.$toggleEl;
/* if there's details data is not there/undefined and $toggleEl having noToggle class, no need to expand */
if (!detailsRow && this.$toggleEl.hasClass('noToggle')) {
return false;
}
/* if there's details data already stored, then we'll remove it */ /* if there's details data already stored, then we'll remove it */
if (detailsRow) { if (detailsRow) {
......
...@@ -23,8 +23,9 @@ define(['require', ...@@ -23,8 +23,9 @@ define(['require',
'utils/Utils', 'utils/Utils',
'utils/UrlLinks', 'utils/UrlLinks',
'utils/CommonViewFunction', 'utils/CommonViewFunction',
'utils/Enums' 'utils/Enums',
], function(require, Backbone, AdminAuditTableLayoutView_tmpl, VEntityList, Utils, UrlLinks, CommonViewFunction, Enums) { 'moment'
], function(require, Backbone, AdminAuditTableLayoutView_tmpl, VEntityList, Utils, UrlLinks, CommonViewFunction, Enums, moment) {
'use strict'; 'use strict';
var AdminAuditTableLayoutView = Backbone.Marionette.LayoutView.extend( var AdminAuditTableLayoutView = Backbone.Marionette.LayoutView.extend(
...@@ -87,12 +88,22 @@ define(['require', ...@@ -87,12 +88,22 @@ define(['require',
includePagination: false, includePagination: false,
includeAtlasPagination: true, includeAtlasPagination: true,
includeFooterRecords: false, includeFooterRecords: false,
includeColumnManager: false, includeColumnManager: true,
includeOrderAbleColumns: false, includeOrderAbleColumns: false,
includeSizeAbleColumns: false, includeSizeAbleColumns: false,
includeTableLoader: true, includeTableLoader: true,
includeAtlasPageSize: true, includeAtlasPageSize: true,
includeAtlasTableSorting: true, includeAtlasTableSorting: true,
columnOpts: {
opts: {
initialColumnsVisible: null,
saveState: false
},
visibilityControlOpts: {
buttonTemplate: _.template("<button class='btn btn-action btn-sm pull-right'>Columns&nbsp<i class='fa fa-caret-down'></i></button>")
},
el: this.ui.colManager
},
atlasPaginationOpts: { atlasPaginationOpts: {
limit: this.limit, limit: this.limit,
offset: this.offset, offset: this.offset,
...@@ -186,8 +197,15 @@ define(['require', ...@@ -186,8 +197,15 @@ define(['require',
createTableWithValues: function(tableDetails, isAdminAudit) { createTableWithValues: function(tableDetails, isAdminAudit) {
var attrTable = CommonViewFunction.propertyTable({ var attrTable = CommonViewFunction.propertyTable({
scope: this, scope: this,
getValue: function(val, key) {
if (key && key.toLowerCase().indexOf("time") > 0) {
return Utils.formatDate({ date: val });
} else {
return val;
}
},
valueObject: tableDetails, valueObject: tableDetails,
fromAdminAudit: isAdminAudit guidHyperLink: !isAdminAudit
}); });
return attrTable; return attrTable;
}, },
...@@ -203,48 +221,35 @@ define(['require', ...@@ -203,48 +221,35 @@ define(['require',
fixWidth: "20", fixWidth: "20",
accordion: false, accordion: false,
alwaysVisible: true, alwaysVisible: true,
renderable: true,
isExpandVisible: function(el, model) {
if (Enums.serverAudits[model.get('operation')]) {
return false;
} else {
return true;
}
},
expand: function(el, model) { expand: function(el, model) {
var operation = model.get('operation'), var operation = model.get('operation'),
results = model.get('result') || null, results = model.get('result') || null,
adminText = 'No records found', adminText = 'No records found',
adminTypDetails = null; adminTypDetails = null,
el.attr('colspan', '7'); auditData = {
operation: operation,
model: model,
results: results,
adminText: adminText,
adminTypDetails: adminTypDetails
};
el.attr('colspan', '8');
if (results) { if (results) {
var adminValues = null; var adminValues = null;
if (operation == "PURGE") { if (operation == "PURGE") {
adminValues = '<ul class="col-sm-6">'; adminText = that.displayPurgeAndImportAudits(auditData);
var guids = results.replace('[', '').replace(']', '').split(','); } else if (operation == "EXPORT" || operation == "IMPORT") {
adminTypDetails = Enums.category[operation]; adminText = that.displayExportAudits(auditData);
_.each(guids, function(adminGuid, index) {
if (index % 5 == 0 && index != 0) {
adminValues += '</ul><ul class="col-sm-6">';
}
adminValues += '<li class="blue-link" data-id="adminPurgedEntity" >' + adminGuid.trim() + '</li>';
})
adminValues += '</ul>';
adminText = '<div class="row"><div class="attr-details"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>' + adminValues + '</div></div>';
} else { } else {
var resultData = JSON.parse(results), adminText = that.displayCreateUpdateAudits(auditData);
typeName = model.get('params').split(','),
typeContainer = '';
_.each(typeName, function(name) {
var typeData = resultData[name],
adminValues = (typeName.length == 1) ? '<ul class="col-sm-4">' : '<ul>';
adminTypDetails = Enums.category[name] + " " + Enums.auditAction[operation];
typeContainer += '<div class="attr-type-container"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>';
_.each(typeData, function(typeDefObj, index) {
if (index % 5 == 0 && index != 0 && typeName.length == 1) {
adminValues += '</ul><ul class="col-sm-4">';
}
var panelId = typeDefObj.name.split(" ").join("") + model.get('startTime');
that.adminAuditEntityData[panelId] = typeDefObj;
adminValues += '<li class="blue-link" data-id="adminAuditEntityDetails" data-auditEntityId=' + panelId + '>' + typeDefObj.name + '</li>';
});
adminValues += '</ul>';
typeContainer += adminValues + '</div>';
})
var typeClass = (typeName.length == 1) ? null : "admin-audit-details";
adminText = '<div class="row"><div class="attr-details ' + typeClass + '">' + typeContainer + '</div></div>';
} }
} }
$(el).append($('<div>').html(adminText)); $(el).append($('<div>').html(adminText));
...@@ -253,40 +258,73 @@ define(['require', ...@@ -253,40 +258,73 @@ define(['require',
userName: { userName: {
label: "Users", label: "Users",
cell: "html", cell: "html",
renderable: true,
editable: false editable: false
}, },
operation: { operation: {
label: "Operation", label: "Operation",
cell: "String", cell: "String",
renderable: true,
editable: false editable: false
}, },
clientId: { clientId: {
label: "Client ID", label: "Client ID",
cell: "String", cell: "String",
renderable: true,
editable: false editable: false
}, },
resultCount: { resultCount: {
label: "Result Count", label: "Result Count",
cell: "String", cell: "String",
editable: false renderable: true,
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
if (Enums.serverAudits[model.get('operation')]) {
return "N/A"
} else {
return rawValue;
}
}
})
}, },
startTime: { startTime: {
label: "Start Time", label: "Start Time",
cell: "html", cell: "html",
renderable: true,
editable: false, editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, { formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) { fromRaw: function(rawValue, model) {
return new Date(rawValue); return Utils.formatDate({ date: rawValue });
} }
}) })
}, },
endTime: { endTime: {
label: "End Time", label: "End Time",
cell: "html", cell: "html",
renderable: true,
editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
return Utils.formatDate({ date: rawValue });
}
})
},
duration: {
label: "Duration",
cell: "html",
renderable: false,
editable: false, editable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, { formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) { fromRaw: function(rawValue, model) {
return new Date(rawValue); var startTime = model.get('startTime') ? parseInt(model.get('startTime')) : null,
endTime = model.get('endTime') ? parseInt(model.get('endTime')) : null;
if (_.isNumber(startTime) && _.isNumber(endTime)) {
var duration = moment.duration(moment(endTime).diff(moment(startTime)));
return Utils.millisecondsToTime(duration);
} else {
return "N/A";
}
} }
}) })
} }
...@@ -310,14 +348,91 @@ define(['require', ...@@ -310,14 +348,91 @@ define(['require',
}; };
this.showModal(modalData); this.showModal(modalData);
}, },
displayPurgeAndImportAudits: function(obj) {
var adminValues = '<ul class="col-sm-6">',
guids = null,
adminTypDetails = Enums.category[obj.operation];
if (obj.operation == "PURGE") {
guids = obj.results ? obj.results.replace('[', '').replace(']', '').split(',') : guids;
} else {
guids = obj.model.get('params') ? obj.model.get('params').split(',') : guids;
}
_.each(guids, function(adminGuid, index) {
if (index % 5 == 0 && index != 0) {
adminValues += '</ul><ul class="col-sm-6">';
}
adminValues += '<li class="blue-link" data-id="adminPurgedEntity" data-operation=' + obj.operation + '>' + adminGuid.trim() + '</li>';
})
adminValues += '</ul>';
return '<div class="row"><div class="attr-details"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>' + adminValues + '</div></div>';
},
displayExportAudits: function(obj) {
var adminValues = "",
adminTypDetails = (obj.operation === 'IMPORT') ? Enums.category[obj.operation] : Enums.category[obj.operation] + " And Options",
resultData = obj.results ? JSON.parse(obj.results) : null,
paramsData = (obj.model && obj.model.get('params')) ? { params: [obj.model.get('params')] } : null;
if (resultData) {
adminValues += this.showImportExportTable(resultData, obj.operation);
}
if (paramsData) {
adminValues += this.showImportExportTable(paramsData);
}
adminValues = adminValues ? adminValues : obj.adminText;
return '<div class="row"><div class="attr-details"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>' + adminValues + '</div></div>';
},
showImportExportTable: function(obj, operations) {
var that = this,
typeDetails = "",
view = '<ul class="col-sm-5 import-export"><table class="table admin-audit-details bold-key" ><tbody >';
if (operations && operations === "IMPORT") {
var importKeys = Object.keys(obj);
_.each(importKeys, function(key, index) {
var newObj = {};
newObj[key] = obj[key];
if (index % 5 === 0 && index != 0) {
view += '</tbody></table></ul><ul class="col-sm-5 import-export"><table class="table admin-audit-details bold-key" ><tbody >';
}
view += that.createTableWithValues(newObj, true);
})
} else {
view += this.createTableWithValues(obj, true);
}
return view += '</tbody></table></ul>';;
},
displayCreateUpdateAudits: function(obj) {
var that = this,
resultData = JSON.parse(obj.results),
typeName = obj.model ? obj.model.get('params').split(',') : null,
typeContainer = '';
_.each(typeName, function(name) {
var typeData = resultData[name],
adminValues = (typeName.length == 1) ? '<ul class="col-sm-4">' : '<ul>',
adminTypDetails = Enums.category[name] + " " + Enums.auditAction[obj.operation];
typeContainer += '<div class="attr-type-container"><h4 style="word-break: break-word;">' + adminTypDetails + '</h4>';
_.each(typeData, function(typeDefObj, index) {
if (index % 5 == 0 && index != 0 && typeName.length == 1) {
adminValues += '</ul><ul class="col-sm-4">';
}
var panelId = typeDefObj.name.split(" ").join("") + obj.model.get('startTime');
that.adminAuditEntityData[panelId] = typeDefObj;
adminValues += '<li class="blue-link" data-id="adminAuditEntityDetails" data-auditEntityId=' + panelId + '>' + typeDefObj.name + '</li>';
});
adminValues += '</ul>';
typeContainer += adminValues + '</div>';
})
var typeClass = (typeName.length == 1) ? null : "admin-audit-details";
return '<div class="row"><div class="attr-details ' + typeClass + '">' + typeContainer + '</div></div>';
},
onClickAdminPurgedEntity: function(e) { onClickAdminPurgedEntity: function(e) {
var that = this; var that = this;
require(['views/audit/AuditTableLayoutView'], function(AuditTableLayoutView) { require(['views/audit/AuditTableLayoutView'], function(AuditTableLayoutView) {
var obj = { var obj = {
guid: $(e.target).text(), guid: $(e.target).text(),
titleText: (e.target.dataset.operation == "PURGE") ? "Purged Entity Details: " : "Import Details: "
}, },
modalData = { modalData = {
title: "Purged Entity Details: " + obj.guid, title: obj.titleText + obj.guid,
content: new AuditTableLayoutView(obj), content: new AuditTableLayoutView(obj),
mainClass: "modal-full-screen", mainClass: "modal-full-screen",
okCloses: true, okCloses: true,
......
...@@ -192,7 +192,6 @@ define(['require', ...@@ -192,7 +192,6 @@ define(['require',
require([ require([
'views/audit/CreateAuditTableLayoutView', 'views/audit/CreateAuditTableLayoutView',
], function(CreateAuditTableLayoutView) { ], function(CreateAuditTableLayoutView) {
that.action = model.get('action'); that.action = model.get('action');
// $(el.target).attr('disabled', true); // $(el.target).attr('disabled', true);
var eventModel = that.entityCollection.fullCollection.findWhere({ 'eventKey': model.get('eventKey') }).toJSON(), var eventModel = that.entityCollection.fullCollection.findWhere({ 'eventKey': model.get('eventKey') }).toJSON(),
......
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