You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.5 KiB

7 years ago
7 years ago
  1. angular.module('topologyManager').controller('IndexCtrl', function($scope,VIRLRestangular,CustomSimRestangular,$interval) {
  2. console.log("IndexCtrl initialized");
  3. $scope.repeat = "none";
  4. $scope.plannedSims = [];
  5. $scope.topology = {sessionName: "",filecontent: "",repeat:"none",datetime: new Date()};
  6. $scope.removePlannedSim = function(id){
  7. console.log(id);
  8. CustomSimRestangular.one('plannedsims',id).remove();
  9. }
  10. $scope.stopSim = function(key){
  11. console.log(key);
  12. VIRLRestangular.one('/simengine/rest/stop',key).get().then(function(response){
  13. console.log(response);
  14. });
  15. }
  16. $scope.updater = function(){
  17. stop = $interval(function() {
  18. $scope.getScheduledSims();
  19. $scope.getRunningSims();
  20. }, 1000);
  21. };
  22. $scope.updater();
  23. $scope.getScheduledSims = function (){
  24. CustomSimRestangular.all("plannedsims").getList().then(function(response){
  25. // console.log(response);
  26. $scope.plannedSims = response;
  27. });
  28. };
  29. $scope.getRunningSims = function(){
  30. VIRLRestangular.one('/simengine/rest/list').get().then(function(response){
  31. // console.log(response);
  32. $scope.runningSims = response.data.simulations;
  33. });
  34. };
  35. $scope.send = function () {
  36. var topology = $scope.topology;
  37. var unix_timestamp = new moment(topology.datetime).unix();
  38. 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},
  39. { 'Content-Type': "text/xml;charset=UTF-8"}
  40. )
  41. .then(function(response) {
  42. // returns a list of users
  43. $scope.addAlert(response.statusText,"success");
  44. }, function(response) {
  45. console.log(response);
  46. $scope.addAlert(response.data.statusText,"danger");
  47. });
  48. };
  49. $scope.popup1 = {
  50. opened: false
  51. };
  52. $scope.dateOptions = {
  53. dateDisabled: false,
  54. formatYear: 'yy',
  55. maxDate: new Date(2020, 5, 22),
  56. minDate: new Date(),
  57. startingDay: 1
  58. };
  59. $scope.openDatePicker = function() {
  60. console.log("h");
  61. $scope.popup1.opened = true;
  62. };
  63. });