anthtrigger
Version:
Trigger events via http service
85 lines (82 loc) • 3.05 kB
JavaScript
(function() {
angular.module('anthTrigger').controller('manageDataController', function($scope, $http, notify, $modal) {
var _st;
$scope._st = _st = {};
$scope.exportZip = function() {
_st["export"] = 'loading';
return $http.put('/settings/export_scripts').success(function(result) {
_st["export"] = null;
return notify('脚本备份文件已经生成到:' + result.file);
}).error(function() {
_st["export"] = null;
return notify('脚本文件导出失败..');
});
};
$scope.clearScriptLogs = function(days) {
_st.clearScriptLogs = 'loading';
return $http.put('/settings/clear_scriptLogs', {
days: days
}).success(function(result) {
_st.clearScriptLogs = null;
return notify('清理成功! 共清除' + (result.count || 0) + "条数据!");
}).error(function() {
_st.clearScriptLogs = null;
return notify('清理失败..');
});
};
$scope.clearEventLogs = function(days) {
_st.clearEventLogs = 'loading';
return $http.put('/settings/clear_eventLogs', {
days: days
}).success(function(result) {
_st.clearEventLogs = null;
return notify('清理成功! 共清除' + (result.count || 0) + "条数据!");
}).error(function() {
_st.clearEventLogs = null;
return notify('清理失败..');
});
};
$scope.dumpDatabase = function() {
_st.dumpDatabase = 'loading';
return $http.put('/settings/dump_database').success(function(result) {
_st.dumpDatabase = null;
return notify('数据库备份成功!备份文件:' + result.file);
}).error(function() {
_st.dumpDatabase = null;
return notify('数据库备份失败。');
});
};
return $scope.restoreDatabase = function() {
return $modal.open({
backdrop: 'static',
keyboard: false,
templateUrl: "/page/settings/restoreDatabaseModal.html",
controller: [
'$scope', '$modalInstance', function(scope, $modalInstance) {
scope._st = _st = {};
_st.list = 'loading';
$http.get('/settings/database_bak/list').success(function(resp) {
scope.list = resp.list;
return _st.list = null;
}).error(function() {
notify('查询数据库备份文件出错!');
return $modalInstance.dismiss();
});
return scope.restore = function(file) {
return $http.put('/settings/restore_database', {
file: file
}).success(function(result) {
notify('恢复数据库成功 !');
return $modalInstance.dismiss();
}).error(function() {
notify('恢复失败!');
return $modalInstance.dismiss();
});
};
}
]
});
};
});
}).call(this);
//# sourceMappingURL=manageDataController.js.map