Mini Shell
define([
'app',
], function(app) {
app.controller("dashboard_enduser",
["$rootScope", "$scope", "$location", "$timeout", "$interval", "api", "meta", "lang", "consts", "permissions", "alert", "confirm",
function($rootScope, $scope, $location, $timeout, $interval, api, meta, lang, consts, permissions, alert, confirm) {
$rootScope.$emit('menuItem', 'Dashboard');
$scope.stats = {
alerts: 0,
accounts: 0,
jobs: 0,
backups: 0,
over_quota: 0,
jobs_running: 0
};
$scope.loadingStatistics = true;
$scope.createBackupOnDemand = function () {
confirm.open({
message: lang.t("Are you sure you want to create backup on demand?"),
confirm: function () {
api.createBackupOnDemand({
data: { account_id: $scope.loggedAccount._id },
success: function(data, message) {
alert.success(message);
},
failed: function(message) {
alert.error(message);
}
});
},
cancel: function () {}
});
};
$scope.fetch = function(callback) {
if(callback === undefined | typeof callback !== 'function') callback = function() {};
api.getDashboardDetails({
success: function(data) {
$scope.stats.alerts = data.statistics.total_new_alerts;
$scope.stats.accounts = data.statistics.total_accounts;
$scope.stats.backups = data.statistics.total_account_backups;
$scope.stats.disk_usage = data.statistics.total_disk_usage;
$scope.loadingStatistics = false;
callback();
},
failed: function (message) {
alert.error(message);
$scope.loadingStatistics = false;
callback();
}
});
};
$timeout($scope.fetch);
}
]
);
});
Zerion Mini Shell 1.0