35 lines
927 B
JavaScript
35 lines
927 B
JavaScript
|
'use strict';
|
||
|
|
||
|
angular.module('warehost')
|
||
|
.controller('DatabaseAdminHostCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http){
|
||
|
$scope.tableParams = new NgTableParams({
|
||
|
sorting: { 'ID': 'asc' },
|
||
|
total: 0,
|
||
|
count: config.table.count
|
||
|
}, { dataset: [] });
|
||
|
alert.set({});
|
||
|
|
||
|
function load(){
|
||
|
$http.get(config.api+'/host/database?filter=all').then(function(res){
|
||
|
session.set(res);
|
||
|
$scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length});
|
||
|
});
|
||
|
}
|
||
|
function submitresult(res){
|
||
|
session.set(res);
|
||
|
alert.set(res);
|
||
|
if(res.data.data){
|
||
|
load();
|
||
|
}
|
||
|
}
|
||
|
load();
|
||
|
$rootScope.$on('warehost.session',load);
|
||
|
|
||
|
$scope.edit = function(obj){
|
||
|
$http.patch(config.api+'/host/database/'+obj.ID,obj).then(submitresult);
|
||
|
};
|
||
|
$scope.delete = function(obj){
|
||
|
$http.delete(config.api+'/host/database/'+obj.ID).then(submitresult);
|
||
|
};
|
||
|
});
|