126 lines
4.4 KiB
JavaScript
126 lines
4.4 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
/**
|
|
* MODULE DESCRIPTION:
|
|
*
|
|
* TODO: Write description here.
|
|
*/
|
|
angular.module('portal.dashboard.logBank', ['ui.router'])
|
|
.controller('LogBankCtrl', LogBankCtrlController);
|
|
|
|
function LogBankCtrlController($scope, cache, appLogStores, uiGridConstants, $timeout, $mdDialog, Constants) {
|
|
|
|
$scope.logs = [];
|
|
|
|
$scope.Constants = Constants;
|
|
|
|
$scope.mCache = cache.request([new appLogStores.Logs()]).then(function(){
|
|
$scope.logs = $scope.mCache.logs.data.values;
|
|
for (var i = 0; i < $scope.logs.length; i++) {
|
|
$scope.logs[i].formattedTime = moment($scope.logs[i].timestamp).format('MM/DD/Y HH:mm:ss');
|
|
}
|
|
});
|
|
|
|
$scope.logGrid = {
|
|
data: 'logs',
|
|
paginationPageSizes: [25, 50, 75, 100, 125, 150, 175, 200],
|
|
paginationPageSize: 25,
|
|
enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER,
|
|
toggleModifierKeysToMultiSelect : true,
|
|
enableRowHeaderSelection: true,
|
|
enableColumnMenus: true,
|
|
enableGridMenu: true,
|
|
exporterCsvFilename: 'RepoLogs.csv',
|
|
exporterMenuCsv: true,
|
|
multiSelect: true,
|
|
noUnselect: false,
|
|
onRegisterApi: function (gridApi) {
|
|
gridApi.selection.setModifierKeysToMultiSelect(true);
|
|
$scope.logGridApi = gridApi;
|
|
},
|
|
columnDefs: [
|
|
{field: 'loggedBy', displayName: 'Logged By', width: '*'},
|
|
{field: 'eventName', displayName: 'Event Type'},
|
|
{field: 'event', displayName: 'Event', width: '*****'},
|
|
{field: 'severity', displayName: 'Severity'},
|
|
{field: 'ipAddress', displayName: 'IP Address', width: '*' },
|
|
{field: 'formattedTime', displayName: 'Timestamp', width: '*' },
|
|
],
|
|
};
|
|
|
|
$scope.$on('$destroy', function () {
|
|
$scope.mCache.unlisten();
|
|
});
|
|
|
|
$scope.toggleFiltering = function() {
|
|
$scope.logGridApi.enableFiltering = !$scope.logGridApi.enableFiltering;
|
|
$scope.logGridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
|
|
};
|
|
|
|
var originatorEv;
|
|
$scope.openMenu = function($mdOpenMenu, ev) {
|
|
originatorEv = ev;
|
|
$mdOpenMenu(ev);
|
|
};
|
|
|
|
$scope.purge = function() {
|
|
$mdDialog.show({
|
|
templateUrl: 'common/partials/templates/purge-logs.tmpl.html',
|
|
multipe: true,
|
|
skipHide: true,
|
|
locals: {
|
|
modalInstance: {
|
|
'title': 'Purge Logs',
|
|
'message': 'Select the date to purge logs before'
|
|
}
|
|
},
|
|
controller: ['$scope', 'modalInstance', '$mdDialog', 'portalUtils', 'appLogProvider',
|
|
function($scope, modalInstance, $mdDialog, portalUtils, appLogProvider) {
|
|
$scope.title = modalInstance.title;
|
|
$scope.message = modalInstance.message;
|
|
$scope.loadingBlock = false;
|
|
|
|
$scope.model = {};
|
|
|
|
$scope.confirm = function() {
|
|
$scope.error = '';
|
|
if ($scope.model.purgeStartDate === undefined) {
|
|
$scope.error = 'Purge start date is required';
|
|
return;
|
|
}
|
|
if ($scope.model.purgeEndDate === undefined) {
|
|
$scope.error = 'Purge end date is required';
|
|
return;
|
|
}
|
|
portalUtils.confirmBox('purgeConfirm', 'Confirm Purge',
|
|
['Are you sure you want to purge files between',
|
|
moment($scope.model.purgeStartDate).format('MMMM Do, Y')
|
|
+ ' and ' + moment($scope.model.purgeEndDate).format('MMMM Do, Y')], false,
|
|
function(value) {
|
|
if (value.confirm) {
|
|
$scope.loadingBlock = true;
|
|
appLogProvider.purgeLogs($scope.model).then(function(value) {
|
|
$scope.loadingBlock = false;
|
|
portalUtils.toast('Successfully purged ' + value + ' logs', ['top', 'left'], 2000);
|
|
$mdDialog.hide();
|
|
}).catch(function(err) {
|
|
$scope.loadingBlock = false;
|
|
portalUtils.toast('Unable to purge logs: ' + err.message, ['top', 'left'], 4000);
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
$scope.cancel = function() {
|
|
$mdDialog.cancel();
|
|
};
|
|
}]
|
|
}).then(function() {
|
|
new appLogStores.Logs().refresh();
|
|
});
|
|
};
|
|
|
|
} //end LogBankCtrlController function
|
|
|
|
})(); |