- Timestamp:
- 04/27/16 16:48:35 (9 years ago)
- Location:
- branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/CalendarHubber.js
r13795 r13805 12 12 var hubber = $.connection.calendarHub; 13 13 14 vm. alertMessage = "No alerts";15 vm.currentcal = [];16 $scope. permission = false;17 vm.selectedEventId = -1; 18 vm.groups = []; 19 vm.clients = []; 14 vm.currentcal = [];//Reference to current calendar (treeview.currentNode.calendar) 15 $scope.permissionview = false;//Show permissions or not 16 $scope.resaddview = false;//Show add resources or not 17 vm.selectedEventId = -1;//Selected downtime (-1 for none) 18 vm.groups = []; //All resource groups 19 vm.clients = []; //All resources 20 20 vm.init = function () { 21 22 // $.connection.hub.logging = true;23 24 21 25 22 var v = document.getElementById("userId").innerHTML; 26 23 $.connection.hub.qs = { 'userid': v }; 24 //Connection string set to identify the unique session ID for the user 27 25 $.connection.hub.start().done(function () { 28 hubber.server.requestInfo(); 29 }); 26 hubber.server.requestInfo();//initial data request 27 }); 28 29 //Process all initial data needed (heavy load) 30 30 hubber.client.processData = function (data, users, groups) { 31 31 vm.data = JSON.parse(data); … … 36 36 $scope.$apply(); 37 37 }; 38 39 //Saving from current graph is done -> refresh it 38 40 hubber.client.savingCurrentDone = function () { 39 41 vm.calendarSaver = false; … … 41 43 $scope.$apply(); 42 44 }; 45 46 //Saving all graphs done -> clear everything 43 47 hubber.client.savingAllDone = function () { 44 48 vm.calendarSaver = false; … … 46 50 $scope.$apply(); 47 51 }; 52 53 //Dispose toggle refresh for current 48 54 hubber.client.processDispose = function (disp) { 49 55 vm.treeview.currentNode.IsDisposable = disp; … … 51 57 $scope.$apply(); 52 58 } 59 60 //Permissions refresh for specific resource 53 61 hubber.client.processPermissions = function (id, perm) { 54 62 var json = JSON.parse(perm); … … 59 67 $scope.$apply(); 60 68 } 69 70 //Process downtimes for a resource. Data conversion 61 71 hubber.client.processDowntime = function (id, down) { 62 72 var json = JSON.parse(down); … … 98 108 } 99 109 110 //Initial function to build the resource tree 111 $scope.buildTree = function () { 112 vm.tree = []; 113 vm.temptree = []; 114 vm.top = false; 115 var ungrouped = { 116 children: [], 117 Name: 'Ungrouped' 118 } 119 for (; vm.data.length > 0;) { 120 121 if (vm.data[0].ParentResourceId == null && vm.data[0].IsDisposable !== undefined) { 122 var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]); 123 vm.clients.push(curr); 124 ungrouped.children.push(curr); 125 } 126 else if (vm.data[0].ParentResourceId == null) { 127 var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]); 128 vm.groups.push(curr); 129 vm.tree.push(curr); 130 } 131 else { 132 var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]); 133 if (curr.IsDisposable !== undefined) 134 vm.clients.push(curr); 135 else 136 vm.groups.push(curr); 137 vm.temptree.push(curr); 138 } 139 } 140 vm.tree.push(ungrouped); 141 142 };//End for hubber init 143 144 //menu navigation 145 $scope.menuchange = function (i) { 146 switch (i) { 147 case 0: 148 $scope.permissionview = false; 149 $scope.resaddview = false; 150 break; 151 case 1: 152 $scope.permissionview = true; 153 $scope.resaddview = false; 154 break; 155 case 2: 156 $scope.permissionview = false; 157 $scope.resaddview = true; 158 break; 159 } 160 } 161 162 //Seeks for children, used recursively for building the treeview 163 $scope.seekChildren = function (current) { 164 current.calendar = []; 165 current.children = []; 166 current.todelete = []; 167 current.changes = false; 168 current.collapsed = true; 169 for (var t = 0; t < vm.temptree.length;) { 170 if (current.Id == vm.temptree[t].ParentResourceId) { 171 current.children.push(vm.temptree.splice(t, 1)[0]); 172 } 173 else { 174 t++; 175 } 176 } 177 var childc = current.children.length;//Remembers count of children received from temp tree; 178 for (var t = 0; t < vm.data.length;) { 179 if (current.Id == vm.data[t].ParentResourceId) { 180 if (vm.data[t].IsDisposable !== undefined) 181 vm.clients.push(vm.data[t]); 182 else 183 vm.groups.push(vm.data[t]); 184 current.children.push(vm.data.splice(t, 1)[0]); 185 } 186 else { 187 t++; 188 } 189 } 190 for (var t = childc; t < current.children.length; t++) { 191 current.children[t] = $scope.seekChildren(current.children[t]); 192 } 193 return current; 194 } 195 196 //Change to another resource 100 197 $scope.$watch("treeview.currentNode", function (newValue, oldValue) { 101 198 $scope.currentcal = []; 199 $scope.resaddview = false; 102 200 $(".selected.ng-binding").addClass('loaded'); 103 201 $scope.selectedEventId = -1; 104 202 203 //Check if resource already has downtime data loaded 105 204 if ($scope.treeview.currentNode != null && $scope.treeview.currentNode.Id != undefined) { 106 205 if ($scope.treeview.currentNode.calendar.length === 0) { 206 //Reach out to server to receive resource data 107 207 hubber.server.requestPermissions(vm.treeview.currentNode.Id); 108 208 hubber.server.requestDownTime(vm.treeview.currentNode.Id); … … 112 212 $timeout(function () { 113 213 refreshPermissions(); 214 //set previously loaded data 114 215 $scope.currentcal = $scope.treeview.currentNode.calendar; 115 216 }, 0); 116 217 117 218 } 118 } 119 120 }); 121 } 219 $scope.refreshAdds(); 220 } 221 222 }); 223 } 224 225 //Resets the add resources menu 226 $scope.refreshAdds = function() { 227 for (var i = 0; i < $scope.clients.length; i++) { 228 $scope.clients[i].add = false; 229 for (var j = 0; j < $scope.treeview.currentNode.children.length; j++) { 230 if ($scope.clients[i].Id === $scope.treeview.currentNode.children[j].Id) 231 $scope.clients[i].add = true; 232 } 233 } 234 } 235 236 //Resets the permissions menu 122 237 function refreshPermissions() { 123 238 for (var i = 0; i < $scope.permUsers.length; i++){ … … 136 251 } 137 252 } 253 254 //Add resource group show by clearing the tree 138 255 $scope.clearTreeSelect = function () { 139 256 if (vm.treeview.currentNode != undefined) { … … 143 260 } 144 261 } 145 $scope.buildTree = function () { 146 vm.tree = []; 147 vm.temptree = []; 148 vm.top = false; 149 var ungrouped = { 150 children: [], 151 Name: 'Ungrouped' 152 } 153 for (; vm.data.length > 0;) { 154 155 if (vm.data[0].ParentResourceId == null && vm.data[0].IsDisposable !== undefined) { 156 var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]); 157 vm.clients.push(curr); 158 ungrouped.children.push(curr); 159 } 160 else if (vm.data[0].ParentResourceId == null) { 161 var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]); 162 vm.groups.push(curr); 163 vm.tree.push(curr); 164 } 165 else { 166 var curr = $scope.seekChildren(vm.data.splice(0, 1)[0]); 167 if (curr.IsDisposable !== undefined) 168 vm.clients.push(curr); 169 else 170 vm.groups.push(curr); 171 vm.temptree.push(curr); 172 } 173 } 174 vm.tree.push(ungrouped); 175 176 }; 177 178 $scope.seekChildren = function (current) { 179 current.calendar = []; 180 current.children = []; 181 current.todelete = []; 182 current.changes = false; 183 current.collapsed = true; 184 for (var t = 0; t < vm.temptree.length;) { 185 if (current.Id == vm.temptree[t].ParentResourceId) { 186 current.children.push(vm.temptree.splice(t, 1)[0]); 187 } 188 else { 189 t++; 190 } 191 } 192 var childc = current.children.length;//Remembers count of children received from temp tree; 193 for (var t = 0; t < vm.data.length;) { 194 if (current.Id == vm.data[t].ParentResourceId) { 195 if (vm.data[t].IsDisposable !== undefined) 196 vm.clients.push(vm.data[t]); 197 else 198 vm.groups.push(vm.data[t]); 199 current.children.push(vm.data.splice(t, 1)[0]); 200 } 201 else { 202 t++; 203 } 204 } 205 for (var t = childc; t < current.children.length; t++) { 206 current.children[t] = $scope.seekChildren(current.children[t]); 207 } 208 return current; 209 } 262 263 //Reach out to server to toggle disposable for current calendar 210 264 $scope.toggleDisposable = function () { 211 265 $scope.calendarDispose = true; 212 266 hubber.server.toggleDisposable(vm.treeview.currentNode.Id); 213 267 } 268 269 //Pushes permissions to server 214 270 $scope.pushPermissions = function () { 215 271 var perms = []; … … 226 282 hubber.server.changePermissions(perms, node.Id); 227 283 } 284 285 //Collects all data from a single resource to save to the server 228 286 function collectInfoToSave(node, refresh, last) { 229 287 var arr = node.calendar.down[0]; … … 233 291 for (var i = 0; i < arr.length; i++) { 234 292 if (arr[i].id === '00000000-0000-0000-0000-000000000000') { 293 //NEW DOWNTIME 235 294 var t = arr[i].allDay.toString(); 236 295 toadd.push([ … … 250 309 } 251 310 else if (arr[i].changed === true) { 311 //EDIT EXISTING DOWNTIME 252 312 var t = arr[i].allDay.toString(); 253 313 toupd.push([ … … 269 329 hubber.server.saveCalendar(node.Id, todel, toadd, toupd, refresh, last); 270 330 } 331 332 //Save current calendar 271 333 $scope.saveCurrentCalendar = function () { 272 334 vm.calendarSaver = true; 273 collectInfoToSave(vm.treeview.currentNode, true, false); 335 collectInfoToSave(vm.treeview.currentNode, true, false);//true for refresh, false for save all 274 336 //true for refresh, false for showing it's only one calendar saved. 275 337 } 338 339 //Save all changed calendars 276 340 $scope.saveAllCalendars = function () { 277 341 … … 289 353 }).then(function (success) { 290 354 vm.calendarSaver = true; 355 291 356 for (var i = 0; i < $scope.allSave.length; i++) { 292 357 if (i >= $scope.allSave.length - 1) … … 299 364 300 365 } 366 367 //Checks treeview for edits and builds new array containing these (recurse for children) 301 368 function createSaveRequests(node) { 302 369 if (node.changes === true) … … 306 373 } 307 374 } 375 376 //Clears and refreshes calendar for current resource (delete current changes) 308 377 $scope.clearCurrentCalendar = function () { 309 378 … … 319 388 320 389 } 390 391 //Clears all calendars and refreshes current (Deletes all changes) 321 392 $scope.clearAllCalendars = function () { 322 393 ngDialog.openConfirm({ … … 333 404 334 405 } 406 407 //Function that clears all calendar (separate so dialog is not called when saveAll is finished) 335 408 function clearAllCalendarsFunc() { 336 409 $(".ng-binding.changed").removeClass('changed'); … … 347 420 $(".selected.ng-scope").addClass('loaded'); 348 421 } 422 423 //Recurse trough tree view 349 424 function clearCalendarsRecurse(node) { 350 425 … … 356 431 } 357 432 } 433 434 //Delete all downtimes from current resource 358 435 $scope.deleteAllEvents = function () { 359 436 vm.calendarDeleter = true; … … 373 450 }); 374 451 } 452 453 //Delete all past events 375 454 $scope.deleteAllPreviousEvents = function () { 376 455 vm.calendarDeleter = true; … … 395 474 } 396 475 397 476 //Sets the status of a downtime AND the current resource to changed 398 477 $scope.setChanged = function (id) { 399 478 if (id != -1) { … … 408 487 $(".selected").addClass('changed'); 409 488 } 410 //*Add event by click 489 490 //Adds event by click on empty space 411 491 $scope.calendarClick = function (date, jsEvent, view) { 412 492 … … 418 498 end.setHours(dat.getHours() + 2); 419 499 vm.treeview.currentNode.calendar.down[0].push({ 420 id: '00000000-0000-0000-0000-000000000000', 500 id: '00000000-0000-0000-0000-000000000000',//Makes it recognizable as new for the server 421 501 title: 'Unavailable', 422 502 start: dat, … … 440 520 441 521 } 522 523 //Finds array index for specific _id 442 524 function checkId(id) { 443 525 for (var i = 0; i < vm.treeview.currentNode.calendar.down[0].length ; i++) { … … 447 529 return -1; 448 530 } 449 / * alert on eventClick */531 //Set selected downtime 450 532 $scope.eventClick = function (date, jsEvent, view) { 451 533 vm.selectedEventId = checkId(date._id); 452 534 }; 535 //Sets selected downtime by clicking on the button at bottom on the page, moves to date 453 536 $scope.eventClickBtn = function (id) { 454 537 vm.selectedEventId = checkId(id); 455 538 vm.goToDate(); 456 539 }; 457 /* alert on Drop */ 540 541 //Drag and drop downtime 458 542 $scope.dragandDrop = function (event, delta, revertFunc, jsEvent, ui, view) { 459 543 vm.selectedEventId = checkId(event._id); … … 474 558 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].end = new Date(event.end); 475 559 }; 476 / * alert on Resize */560 //Resize downtime 477 561 $scope.resizeEvent = function (event, delta, revertFunc, jsEvent, ui, view) { 478 562 vm.selectedEventId = checkId(event._id); … … 482 566 }; 483 567 484 / * remove event */568 //Removes a downtime from client (existing downtime gets referenced in todelete 485 569 $scope.remove = function (index) { 486 570 vm.selectedEventId = -1; … … 493 577 494 578 }; 579 //Remove trough list view at bottom 495 580 $scope.removeList = function (id) { 496 581 var index = checkId(id); … … 504 589 505 590 }; 506 591 //Check if start is before end AND start is after now (recursion) 507 592 $scope.checkDateStartEnd = function () { 508 593 if ($scope.currentcal.down[0][vm.selectedEventId].rec.start > $scope.currentcal.down[0][vm.selectedEventId].rec.end || … … 515 600 $scope.currentcal.down[0][vm.selectedEventId].rec.start = new Date(); 516 601 } 517 //pushes all changes to other recurs602 //pushes all changes to other existing recurs and creates new downtimes where needed 518 603 $scope.pushRecurChanges = function (recid) { 519 604 ngDialog.openConfirm({ … … 526 611 plain: true 527 612 }).then(function (success) { 613 528 614 var arr = vm.treeview.currentNode.calendar.down[0]; 615 //Deep copy of downtime for referencing 529 616 var ob = $.extend(true, {}, arr[vm.selectedEventId]); 530 for (var i = 0; i < arr.length;) { 617 618 for (var i = 0; i < arr.length;) {//Go trough downtimes and find all recurrences 531 619 if (arr[i].rec.recid === recid) { 532 620 if (new Date(arr[i].start) < new Date(ob.rec.start) || 533 621 new Date(arr[i].end) > new Date(ob.rec.end) || 534 622 !ob.rec.days[new Date(arr[i].start).getDay()]) { 535 vm.remove(i); 623 //Downtime is out of recurrence boundaries 624 //Before start date OR After end date OR Not on right day of the week 625 vm.remove(i);//NO I++ -> REMOVE SPLICES ARRAY 536 626 vm.selectedEventId = -1; 537 627 538 628 } 539 629 else { 540 630 //Edit downtime when it is within the bounds 541 631 arr[i].start.setHours(ob.start.getHours(), ob.start.getMinutes()); 542 632 arr[i].end.setHours(ob.end.getHours(), ob.end.getMinutes()); … … 551 641 i++; 552 642 } 643 //init for new downtimes. 553 644 var start = new Date(ob.rec.start); 554 start.setHours(2, 0, 0, 0); 645 start.setHours(2, 0, 0, 0);//Beginning of the day + time conversion +02 555 646 var end = new Date(ob.rec.end); 556 end = new Date(end.setHours(24, 0, 0, 0) + 1000 * 3600 * 2); 557 558 loop1: 647 end = new Date(end.setHours(24, 0, 0, 0) + 1000 * 3600 * 2);//End of the day + time conversion +02 648 649 loop1: //Loop start to end with single day increment 559 650 for (var d = (start.getTime()) ; d < (end.getTime()) ;) { 560 651 var tog = ob.rec.days[new Date(d).getDay()]; 652 //Check if day of the week is included in recursion 561 653 if (tog) { 562 loop2: 654 loop2://Loop checking existing downtime array to see if day is already filled or not 563 655 for (var i = 0; i < arr.length; i++) { 564 656 … … 567 659 if (arr[i].start.getTime() >= d && 568 660 arr[i].end.getTime() <= dend) { 569 d += (1000 * 3600 * 24); 570 continue loop1; 661 d += (1000 * 3600 * 24);//add day to loop 1 662 continue loop1;//breaks out of loop2 and skips to next day 571 663 } 572 664 } 573 665 } 574 666 //Made it here = new event needed: init 575 667 var ts = new Date(d); 576 668 ts.setHours(new Date(ob.start).getHours(), new Date(ob.start).getMinutes()); … … 589 681 } 590 682 591 d += (1000 * 3600 * 24);// 1 day 592 593 } 594 }); 595 } 683 d += (1000 * 3600 * 24);// adds one day 684 685 } 686 }); 687 } 688 689 //Delete all bound recurrences 596 690 $scope.deleteAllRecurrences = function (recid) { 597 691 ngDialog.openConfirm({ … … 614 708 } 615 709 710 //Moves calendar to selected date 616 711 $scope.goToDate = function () { 617 712 $("#resourcecalendar").fullCalendar('gotoDate', vm.currentcal.down[0][vm.selectedEventId].start); 618 713 } 619 /* Render Tooltip */714 /* Renders Tooltip */ 620 715 $scope.eventRender = function (event, element, view) { 621 716 element.attr({ … … 625 720 //$compile(element)($scope); 626 721 }; 627 / * config object */722 //Calendar configuration 628 723 $scope.uiConfig = { 629 724 calendar: { … … 650 745 }; 651 746 747 748 652 749 653 750 654 751 }).filter('disp', function () { 655 return function (input) { 752 return function (input) {//Filter boolean to string 656 753 return input ? 'Disposable' : 'Not disposable'; 657 754 } 658 755 }).directive('animateOnChange', function ($timeout) { 659 return function (scope, element, attr) { 756 return function (scope, element, attr) {//Animation on downtime info to show change 660 757 scope.$watch(attr.animateOnChange, function (nv, ov) { 661 758 … … 665 762 $timeout(function () { 666 763 element.removeClass('changed'); 667 }, 250); // Could be enhanced to take duration as a parameter764 }, 250); 668 765 } 669 766 else { … … 671 768 $timeout(function () { 672 769 element.removeClass('changedshut'); 673 }, 250); // Could be enhanced to take duration as a parameter770 }, 250); 674 771 } 675 772 } -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/UserInfoHubber.js
r13754 r13805 2 2 3 3 $(function () { 4 $.connection.hub.logging = true;4 //$.connection.hub.logging = true; 5 5 var v = document.getElementById("userId").innerHTML; 6 6 console.log(v); … … 8 8 $.connection.hub.start(); 9 9 hubber.client.showNewPass = function (pass) { 10 $("#inppassreset").html("<label class=' control-label' style='text-align:left'>New pass word: " + pass + "</label>");10 $("#inppassreset").html("<label class=' control-label' style='text-align:left'>New pass: " + pass + ". An email has been sent to the user containing the new password</label>"); 11 11 12 12 }; -
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Styling/angular.treeview.css
r13795 r13805 61 61 62 62 div[data-tree-model] li.selected { 63 box-shadow: 2px 3px 5px rgba(0,0,0,0.6), inset 1px 10px 300px 51px rgba(143,201,58,1)!important;63 box-shadow: 2px 3px 5px rgba(0,0,0,0.6), inset 1px 10px 300px 51px #5cb85c!important; 64 64 } 65 65 div[data-tree-model] span.selected {
Note: See TracChangeset
for help on using the changeset viewer.