- Timestamp:
- 04/13/16 17:11:07 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager
- Property svn:ignore
-
old new 1 node_modules 1 2 project.lock.json
-
- Property svn:ignore
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/CalendarHubber.js
r13754 r13758 1 1 2 angular.module('wjm', ['ui.bootstrap', 'ui.calendar', 'angularTreeview' ]).3 4 controller('resourceCtrl', function ($scope, uiCalendarConfig, $compile, $timeout) {2 angular.module('wjm', ['ui.bootstrap', 'ui.calendar', 'angularTreeview', 'ngDialog']). 3 4 controller('resourceCtrl', function ($scope, uiCalendarConfig, $compile, ngDialog , $timeout) { 5 5 var vm = $scope; 6 6 … … 33 33 hubber.client.processDowntime = function (id, down) { 34 34 var json = JSON.parse(down); 35 var downtype = ["Unavailable", "Shutdown command"];36 35 var arrdown = []; 37 console.log(json); 36 var str = ""; 37 var col = ""; 38 38 for (var i = 0; i < json.length; i++) { 39 if (json[i].DowntimeType === 0) { 40 str = "Unavailable"; 41 col = "#006080"; 42 } 43 else { 44 str = "Shutdown"; 45 col = "#993300"; 46 } 39 47 arrdown.push({ 40 48 id: json[i].Id, 41 title: 'offline', 42 start: json[i].StartDate, 43 end: json[i].EndDate, 44 allDay: json[i].AllDayEvent 49 title: str, 50 start: new Date(json[i].StartDate), 51 end: new Date(json[i].EndDate), 52 allDay: json[i].AllDayEvent, 53 color: col 45 54 }); 46 55 } 47 56 var dat = { 'id': id, 'down': [arrdown] }; 48 57 $scope.treeview.currentNode.calendar = dat; 58 49 59 $scope.currentcal = $scope.treeview.currentNode.calendar; 50 60 $scope.$apply(); … … 53 63 $scope.$watch("treeview.currentNode", function (newValue, oldValue) { 54 64 $scope.currentcal = []; 65 $(".selected.ng-binding").addClass('loaded'); 55 66 $scope.selectedEventId = -1; 56 67 if ($scope.treeview.currentNode != null) { 57 68 if ($scope.treeview.currentNode.calendar.length === 0) { 58 69 hubber.server.requestDownTime(vm.treeview.currentNode.Id); 70 59 71 } 60 72 else { 61 73 $timeout(function () { 62 74 $scope.currentcal = $scope.treeview.currentNode.calendar; 63 $scope.$apply(); 75 64 76 }, 0); 65 66 } 67 } 68 69 }); 70 } 77 78 } 79 } 80 81 }); 82 } 83 $scope.saveCurrentCalendar = function () { 84 console.log("Save Current cal"); 85 } 86 $scope.saveAllCalendars = function () { 87 console.log("Save all"); 88 } 89 $scope.clearCurrentCalendar = function () { 90 91 $scope.selectedEventId = -1; 92 $scope.treeview.currentNode.calendar = null; 93 $scope.currentcal = []; 94 hubber.server.requestDownTime(vm.treeview.currentNode.Id); 95 $(".selected.ng-binding").removeClass('changed'); 96 } 97 $scope.clearAllCalendars = function () { 98 ngDialog.openConfirm({ 99 template: 100 '<p>Are you sure you want to delete all calendar changes?</p>' + 101 '<div>' + 102 '<button type="button" class="btn btn-default" ng-click="closeThisDialog(0)">No </button> ' + 103 '<button type="button" class="btn btn-primary" ng-click="confirm(1)">Yes' + 104 '</button></div>', 105 plain: true 106 }).then(function (success) { 107 $(".ng-binding.changed").removeClass('changed'); 108 $(".ng-binding.loaded").removeClass('loaded'); 109 $scope.selectedEventId = -1; 110 $scope.treeview.currentNode.calendar = null; 111 $scope.currentcal = []; 112 for (var i = 0; i < $scope.tree.length; i++) 113 removeCalendarsRecurse($scope.tree[i]); 114 hubber.server.requestDownTime(vm.treeview.currentNode.Id); 115 $(".selected.ng-binding").addClass('loaded'); 116 }); 117 118 } 119 function removeCalendarsRecurse(node) { 120 121 node.calendar = []; 122 node.todelete = []; 123 124 for (var i = 0; i < node.children.length; i++) { 125 removeCalendarsRecurse(node.children[i]); 126 } 127 } 128 71 129 $scope.buildTree = function () { 72 130 vm.tree = []; … … 84 142 } 85 143 } 144 86 145 }; 87 146 … … 89 148 current.calendar = []; 90 149 current.children = []; 150 current.todelete = []; 91 151 current.collapsed = true; 92 152 for (var t = 0; t < vm.temptree.length;) { … … 112 172 return current; 113 173 } 114 115 /* alert on eventClick */ 116 $scope.alertOnEventClick = function (date, jsEvent, view) { 117 vm.selectedEventId = date._id; 118 }; 119 /* alert on Drop */ 120 $scope.alertOnDrop = function (event, delta, revertFunc, jsEvent, ui, view) { 121 vm.treeview.currentNode.calendar.down[0][event._id - 1].start = event.start; 122 if (vm.treeview.currentNode.calendar.down[0][event._id - 1].end != null) 123 vm.treeview.currentNode.calendar.down[0][event._id - 1].end = event.end; 124 }; 125 /* alert on Resize */ 126 $scope.alertOnResize = function (event, delta, revertFunc, jsEvent, ui, view) { 127 vm.treeview.currentNode.calendar.down[0][event._id - 1].start = event.start; 128 vm.treeview.currentNode.calendar.down[0][event._id - 1].end = event.end; 129 }; 130 131 /* add custom event*/ 132 $scope.addEvent = function () { 133 134 }; 135 $scope.calendarClick = function(date, jsEvent, view) { 136 console.log(date); 174 function checkId(id) { 175 for (var i = 0; i < vm.treeview.currentNode.calendar.down[0].length ; i++) { 176 if (vm.treeview.currentNode.calendar.down[0][i]._id === id) 177 return i; 178 } 179 return -1; 180 } 181 $scope.setChanged = function () { 182 if (vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].title === "Unavailable") 183 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].color = '#0099cc'; 184 else 185 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].color = '#ff5500'; 186 vm.treeview.currentNode.changes = true; 187 $(".selected.ng-binding").addClass('changed'); 188 } 189 //*Add event by click 190 $scope.calendarClick = function (date, jsEvent, view) { 191 var newid = 0; 192 if (vm.treeview.currentNode.calendar.down[0].length != 0) 193 newid = vm.treeview.currentNode.calendar.down[0][(vm.treeview.currentNode.calendar.down[0].length - 1)]._id + 1; 137 194 vm.treeview.currentNode.calendar.down[0].push({ 138 195 id: '00000000-0000-0000-0000-000000000000', 139 title: ' offline',196 title: 'Unavailable', 140 197 start: date.toDate(), 141 198 end: null, 142 199 allDay: date._ambigTime, 143 color: '#378006', 144 _id: (vm.treeview.currentNode.calendar.down[0].length +1) 145 }); 146 147 148 } 200 _id: (newid) 201 }); 202 203 vm.selectedEventId = vm.treeview.currentNode.calendar.down[0].length - 1; 204 vm.setChanged(); 205 206 } 207 /* alert on eventClick */ 208 $scope.alertOnEventClick = function (date, jsEvent, view) { 209 vm.selectedEventId = checkId(date._id); 210 }; 211 /* alert on Drop */ 212 $scope.alertOnDrop = function (event, delta, revertFunc, jsEvent, ui, view) { 213 vm.selectedEventId = checkId(event._id); 214 vm.setChanged(); 215 if (vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].allDay && event.start._ambigTime == false) { 216 event.allDay = false; 217 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].allDay = false; 218 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].end = null; 219 } 220 else if (!vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].allDay && event.start._ambigTime == true) { 221 event.allDay = true; 222 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].allDay = true; 223 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].end = null; 224 } 225 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].start = new Date(event.start); 226 if (vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].end != null) 227 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].end = new Date(event.end); 228 }; 229 /* alert on Resize */ 230 $scope.alertOnResize = function (event, delta, revertFunc, jsEvent, ui, view) { 231 vm.selectedEventId = checkId(event._id); 232 vm.setChanged(); 233 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].start = new Date(event.start); 234 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].end = new Date(event.end); 235 }; 236 237 /* add custom event*/ 238 $scope.addEvent = function () { 239 240 }; 241 149 242 /* remove event */ 150 243 $scope.remove = function (index) { 151 $scope.events.splice(index, 1); 244 vm.selectedEventId = -1; 245 if (vm.treeview.currentNode.calendar.down[0][index].id != "00000000-0000-0000-0000-000000000000") { 246 vm.treeview.currentNode.todelete.push(vm.treeview.currentNode.calendar.down[0][index - 1].id); 247 } 248 vm.treeview.currentNode.calendar.down[0].splice(index, 1); 249 250 152 251 }; 153 252 /* Render Tooltip */ … … 162 261 $scope.uiConfig = { 163 262 calendar: { 164 height: 600,263 height: 500, 165 264 editable: true, 166 defaultView:'agendaWeek', 265 defaultView: 'agendaWeek', 266 firstDay: 1, 167 267 header: { 168 268 left: 'title', … … 178 278 dayClick: $scope.calendarClick 179 279 180 280 181 281 } 182 282 };
Note: See TracChangeset
for help on using the changeset viewer.