Current File : //usr/local/jetapps/var/www/jetbackup5/docroot/app/controllers_enduser/restore/full.js |
define([
'app',
], function(app) {
app.controller("restore_full_enduser",
["$rootScope", "$scope", "$routeParams", "$location", "$timeout", "$interval", "api", "meta", "lang", "consts", "permissions", "alert",
function($rootScope, $scope, $routeParams, $location, $timeout, $interval, api, meta, lang, consts, permissions, alert) {
$scope.backups = [];
$scope.selected = '';
meta = meta.new("enduser_full_backups");
$scope.meta = meta;
$scope.metaData = meta.getData();
meta.setSortReverse(false);
if(!meta.getSortBy()) meta.setSortBy("created");
if(!meta.getSortDirection()) meta.setSortDirection("desc");
meta.setPageSizes([10,25,50,100]);
meta.setPageSize(10);
meta.setSortFields(["username", "owner"]);
meta.setTotalItems($scope.backups.length);
$scope.selectedBackup = function(backup) {
if($scope.selected === backup.parent_id) $scope.selected = '';
else $scope.selected = backup.parent_id;
};
$scope.prepareSummary = function (type) {
api.getBackupItems({
data: {
_id: $scope.selected,
limit: 999999
},
success: function (data) {
$scope.showSummary(type, data.backups);
},
failed: function (message) {
alert.error(message);
}
})
};
$scope.fetch = function () {
$scope.backups = [];
$scope.selected = '';
var apiParams = {
name: $scope.loggedAccount.username,
type: consts.BACKUP_TYPE_ACCOUNT,
contains: consts.BACKUP_TYPE_ACCOUNT_FULL,
account_id: $scope.loggedAccount._id,
skip: meta.getSkip(),
limit: meta.getPageSize(),
filter: meta.getFilter(),
sort: {},
find: {}
};
apiParams.sort[meta.getSortBy()] = meta.getSortDirectionInt();
api.listBackupForTypeName({
data: apiParams,
success: function (data) {
meta.setTotalItems(data.total);
meta.calculate(data.backups);
for(var i = 0; i < data.backups.length; i++) {
var names = [];
for(var j = 0; j < data.backups[i].schedules.length; j++) names.push(consts.SCHEDULE_TYPES[data.backups[i].schedules[j]]);
data.backups[i].schedules_names = names.join(",");
$scope.backups.push(data.backups[i]);
}
}
});
};
$timeout($scope.fetch);
}
]
);
});