angular.module('topologyManager').controller('IndexCtrl', function($scope,VIRLRestangular,CustomSimRestangular,$interval) { console.log("IndexCtrl initialized"); $scope.repeat = "none"; $scope.plannedSims = []; $scope.topology = {sessionName: "",filecontent: "",repeat:"none",datetime: new Date()}; $scope.removePlannedSim = function(id){ console.log(id); CustomSimRestangular.one('plannedsims',id).remove(); } $scope.stopSim = function(key){ console.log(key); VIRLRestangular.one('/simengine/rest/stop',key).get().then(function(response){ console.log(response); }); } $scope.updater = function(){ stop = $interval(function() { $scope.getScheduledSims(); $scope.getRunningSims(); }, 1000); }; $scope.updater(); $scope.getScheduledSims = function (){ CustomSimRestangular.all("plannedsims").getList().then(function(response){ // console.log(response); $scope.plannedSims = response; }); }; $scope.getRunningSims = function(){ VIRLRestangular.one('/simengine/rest/list').get().then(function(response){ // console.log(response); $scope.runningSims = response.data.simulations; }); }; $scope.send = function () { var topology = $scope.topology; var unix_timestamp = new moment(topology.datetime).unix(); CustomSimRestangular.one('plannedsims/new').customPOST(topology.filecontent,undefined,{session:topology.sessionName,timestamp:unix_timestamp,token:$scope.credentials.token,username:$scope.credentials.username,repeat:$scope.topology.repeat}, { 'Content-Type': "text/xml;charset=UTF-8"} ) .then(function(response) { // returns a list of users $scope.addAlert(response.statusText,"success"); }, function(response) { console.log(response); $scope.addAlert(response.data.statusText,"danger"); }); }; $scope.popup1 = { opened: false }; $scope.dateOptions = { dateDisabled: false, formatYear: 'yy', maxDate: new Date(2020, 5, 22), minDate: new Date(), startingDay: 1 }; $scope.openDatePicker = function() { console.log("h"); $scope.popup1.opened = true; }; });