sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0
This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
warehost-frontend/public/app/web/list.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-09-03 16:30:05 +02:00
'use strict';
angular.module('warehost')
2016-09-06 18:19:08 +02:00
.controller('ListWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http){
2016-09-03 16:30:05 +02:00
$scope.tableParams = new NgTableParams({
2016-10-17 12:50:31 +02:00
sorting: { 'website.name': 'asc' },
2016-09-03 16:30:05 +02:00
total: 0,
count: config.table.count
}, { dataset: [] });
alert.set({});
$scope.obj = {};
function resetObj(){
$scope.obj = {};
}
function load(){
$http.get(config.api+'/web/involve').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){
$rootScope.$broadcast('warehost.web.website.update');
resetObj();
$scope.isAdding = false;
}
}
resetObj();
load();
$rootScope.$on('warehost.session',load);
2016-09-03 16:30:05 +02:00
$rootScope.$on('warehost.web.website.update',load);
$scope.edit = function(a){
$http.patch(config.api+'/web/website/'+a.website.ID,a.website).then(submitresult);
2016-09-03 16:30:05 +02:00
};
$scope.delete = function(a){
$http.delete(config.api+'/web/website/'+a.website.ID).then(submitresult);
};
$scope.add = function(){
$http.post(config.api+'/web/website',$scope.obj).then(submitresult);
};
});