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.
2016-09-03 16:30:05 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('warehost')
|
|
|
|
.controller('MenuWebCtrl',function(session,config,alert,$scope,$rootScope,$http,$stateParams){
|
|
|
|
alert.set({});
|
|
|
|
$scope.list = {};
|
|
|
|
$scope.website = {};
|
|
|
|
function load(){
|
|
|
|
$http.get(config.api+'/web/involve').then(function(res){
|
|
|
|
session.set(res);
|
|
|
|
alert.set(res);
|
2016-09-06 18:19:08 +02:00
|
|
|
$scope.list = res.data.data;
|
2016-09-03 16:30:05 +02:00
|
|
|
for(var key in res.data.data){
|
|
|
|
var item = res.data.data[key];
|
2016-09-11 23:03:41 +02:00
|
|
|
if(item.website.ID+'' === $stateParams.websiteid){
|
2016-09-03 16:30:05 +02:00
|
|
|
$scope.website = item.website;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
load();
|
2016-10-17 23:43:14 +02:00
|
|
|
$rootScope.$on('warehost.session',load);
|
2016-09-03 16:30:05 +02:00
|
|
|
$rootScope.$on('warehost.web.website.update',load);
|
|
|
|
$scope.add = function(){
|
2016-09-06 18:19:08 +02:00
|
|
|
$http.post(config.api+'/web/website',{name:window.prompt('Name:')}).then(function(res){
|
2016-09-03 16:30:05 +02:00
|
|
|
session.set(res);
|
|
|
|
$rootScope.$broadcast('warehost.web.website.update');
|
|
|
|
});
|
|
|
|
};
|
|
|
|
});
|