- Timestamp:
- 04/19/16 17:11:50 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/wwwroot/js/hubs/calendarhubber.js
r13768 r13775 11 11 var y = date.getFullYear(); 12 12 var hubber = $.connection.calendarHub; 13 13 14 vm.alertMessage = "No alerts"; 14 15 vm.currentcal = []; … … 43 44 var arrdown = []; 44 45 var str = ""; 45 var col = "";46 46 for (var i = 0; i < json.length; i++) { 47 47 if (json[i].DowntimeType === 0) { … … 60 60 allDay: json[i].AllDayEvent, 61 61 color: col, 62 rec: { 63 recurrence: json[i].Recurring, 64 recid: json[i].RecurringId, 65 days: [false, false, false, false, false, false, false], 66 start: new Date(json[i].StartDate), 67 end: new Date(json[i].EndDate) 68 69 }, 62 70 changed: false 63 71 }); … … 67 75 68 76 $scope.currentcal = $scope.treeview.currentNode.calendar; 77 $("#resourcecalendar").fullCalendar('refresh'); 69 78 $scope.$apply(); 70 79 } … … 145 154 var t = arr[i].allDay.toString(); 146 155 toadd.push([ 147 arr[i].title, 148 "" + Date.parse(arr[i].start), 149 "" + Date.parse(arr[i].end), 150 t, 151 node.Id 156 arr[i].title,//status 157 "" + Date.parse(arr[i].start),//start 158 "" + Date.parse(arr[i].end),//end 159 t,// allday 160 node.Id, //resource id 161 arr[i].rec.recurrence.toString(),//true on recur 162 arr[i].rec.recid,//recur id 163 "" + Date.parse(arr[i].rec.start), 164 "" + Date.parse(arr[i].rec.end), 165 arr[i].rec.days.join(",") 166 167 152 168 ]); 153 169 } … … 155 171 var t = arr[i].allDay.toString(); 156 172 toupd.push([ 157 arr[i].id, 158 arr[i].title, 159 "" + Date.parse(arr[i].start), 160 "" + Date.parse(arr[i].end), 161 t 173 arr[i].id,//id to update 174 arr[i].title,//status 175 "" + Date.parse(arr[i].start),//start 176 "" + Date.parse(arr[i].end),//end 177 t,//allday 178 arr[i].rec.recurrence.toString(),//true on recur 179 arr[i].rec.recid,//recur id 180 "" + Date.parse(arr[i].rec.start), 181 "" + Date.parse(arr[i].rec.end), 182 arr[i].rec.days.join(",") 183 162 184 ]); 163 185 } 164 186 } 165 vm.sendtoserv = [to add, toupd, todel];187 vm.sendtoserv = [todel, toadd, toupd]; 166 188 hubber.server.saveCalendar(node.Id, todel, toadd, toupd, refresh, last); 167 189 } … … 190 212 } 191 213 }); 192 193 214 215 194 216 } 195 217 function createSaveRequests(node) { … … 201 223 } 202 224 $scope.clearCurrentCalendar = function () { 203 225 204 226 $scope.selectedEventId = -1; 205 227 $scope.treeview.currentNode.calendar = null; … … 253 275 if (node[i].end < Date.now()) { 254 276 if (node[i].id != '00000000-0000-0000-0000-000000000000') 255 vm.treeview.currentNode.todelete.push(node[i].id);256 $scope.setChanged( );277 vm.treeview.currentNode.todelete.push(node[i].id); 278 $scope.setChanged(vm.selectedEventId); 257 279 node.splice(i, 1); 258 280 } … … 268 290 269 291 270 $scope.setChanged = function ( ) {271 if ( vm.selectedEventId != -1) {272 if (vm.treeview.currentNode.calendar.down[0][ vm.selectedEventId].title === "Unavailable")273 vm.treeview.currentNode.calendar.down[0][ vm.selectedEventId].color = '#0099cc';292 $scope.setChanged = function (id) { 293 if (id != -1) { 294 if (vm.treeview.currentNode.calendar.down[0][id].title === "Unavailable") 295 vm.treeview.currentNode.calendar.down[0][id].color = '#0099cc'; 274 296 else 275 vm.treeview.currentNode.calendar.down[0][ vm.selectedEventId].color = '#ff5500';276 277 vm.treeview.currentNode.calendar.down[0][ vm.selectedEventId].changed = true;297 vm.treeview.currentNode.calendar.down[0][id].color = '#ff5500'; 298 299 vm.treeview.currentNode.calendar.down[0][id].changed = true; 278 300 } 279 301 vm.treeview.currentNode.changes = true; … … 289 311 var end = new Date(dat); 290 312 end.setHours(dat.getHours() + 2); 291 console.log(end);292 313 vm.treeview.currentNode.calendar.down[0].push({ 293 314 id: '00000000-0000-0000-0000-000000000000', … … 296 317 end: end, 297 318 allDay: date._ambigTime, 319 rec: { 320 recurrence: false, 321 recid: '0', 322 days: [false, false, false, false, false, false, false], 323 start: dat, 324 end: end 325 326 }, 298 327 _id: (newid) 299 328 }); 300 329 vm.selectedEventId = vm.treeview.currentNode.calendar.down[0].length - 1; 301 vm.setChanged( );330 vm.setChanged(vm.selectedEventId); 302 331 // $("#resourcecalendar").fullCalendar('refetchEvents'); 303 332 … … 317 346 $scope.dragandDrop = function (event, delta, revertFunc, jsEvent, ui, view) { 318 347 vm.selectedEventId = checkId(event._id); 319 vm.setChanged( );348 vm.setChanged(vm.selectedEventId); 320 349 if (event.end == null) { 321 350 event.end = moment(event.start).add(2, 'hours'); … … 336 365 $scope.resizeEvent = function (event, delta, revertFunc, jsEvent, ui, view) { 337 366 vm.selectedEventId = checkId(event._id); 338 vm.setChanged( );367 vm.setChanged(vm.selectedEventId); 339 368 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].start = new Date(event.start); 340 369 vm.treeview.currentNode.calendar.down[0][vm.selectedEventId].end = new Date(event.end); … … 344 373 $scope.remove = function (index) { 345 374 vm.selectedEventId = -1; 346 vm.setChanged( );375 vm.setChanged(vm.selectedEventId); 347 376 if (vm.treeview.currentNode.calendar.down[0][index].id != "00000000-0000-0000-0000-000000000000") { 348 377 vm.treeview.currentNode.todelete.push(vm.treeview.currentNode.calendar.down[0][index].id); … … 352 381 353 382 }; 383 384 $scope.checkDateStartEnd = function () { 385 if ($scope.currentcal.down[0][vm.selectedEventId].rec.start > $scope.currentcal.down[0][vm.selectedEventId].rec.end || 386 $scope.currentcal.down[0][vm.selectedEventId].rec.end === undefined) { 387 388 $scope.currentcal.down[0][vm.selectedEventId].rec.end = new Date($scope.currentcal.down[0][vm.selectedEventId].rec.start); 389 390 } 391 if ($scope.currentcal.down[0][vm.selectedEventId].rec.start < Date.now()) 392 $scope.currentcal.down[0][vm.selectedEventId].rec.start = new Date(); 393 } 394 //pushes all changes to other recurs 395 $scope.pushRecurChanges = function (recid) { 396 ngDialog.openConfirm({ 397 template: 398 '<p>This will change all existing recurrences and create new recurrences where needed. Are you sure?</p>' + 399 '<div>' + 400 '<button type="button" class="btn btn-default" ng-click="closeThisDialog(0)">No </button> ' + 401 '<button type="button" class="btn btn-primary" ng-click="confirm(1)">Yes' + 402 '</button></div>', 403 plain: true 404 }).then(function (success) { 405 var arr = vm.treeview.currentNode.calendar.down[0]; 406 var ob = $.extend(true, {}, arr[vm.selectedEventId]); 407 for (var i = 0; i < arr.length;) { 408 if (arr[i].rec.recid === recid) { 409 if (new Date(arr[i].start) < new Date(ob.rec.start) || 410 new Date(arr[i].end) > new Date(ob.rec.end) || 411 !ob.rec.days[new Date(arr[i].start).getDay()]) { 412 vm.remove(i); 413 vm.selectedEventId = -1; 414 415 } 416 else { 417 418 arr[i].start.setHours(ob.start.getHours(), ob.start.getMinutes()); 419 arr[i].end.setHours(ob.end.getHours(), ob.end.getMinutes()); 420 arr[i].title = ob.title; 421 arr[i].rec = ob.rec; 422 arr[i].allDay = ob.allDay; 423 vm.setChanged(i); 424 i++; 425 } 426 } 427 else 428 i++; 429 } 430 var start = new Date(ob.rec.start); 431 start.setHours(2, 0, 0, 0); 432 var end = new Date(ob.rec.end); 433 end = new Date(end.setHours(24, 0, 0, 0) + 1000 * 3600 * 2); 434 435 loop1: 436 for (var d = (start.getTime()) ; d < (end.getTime()) ;) { 437 var tog = ob.rec.days[new Date(d).getDay()]; 438 if (tog) { 439 loop2: 440 for (var i = 0; i < arr.length; i++) { 441 442 if (arr[i].rec.recid === recid) { 443 var dend = (d+1000 * 3600 * 24); 444 if (arr[i].start.getTime() >= d && 445 arr[i].end.getTime() <= dend) { 446 d += (1000 * 3600 * 24); 447 continue loop1; 448 } 449 } 450 } 451 452 var ts = new Date(d); 453 ts.setHours(new Date(ob.start).getHours(), new Date(ob.start).getMinutes()); 454 var te = new Date(d); 455 te.setHours(new Date(ob.end).getHours(), new Date(ob.end).getMinutes()); 456 arr.push({ 457 id: '00000000-0000-0000-0000-000000000000', 458 title: ob.title, 459 start: ts, 460 end: te, 461 allDay: ob.allDay, 462 rec: ob.rec 463 }); 464 vm.setChanged(arr.length - 1); 465 466 } 467 468 d += (1000 * 3600 * 24);// 1 day 469 470 } 471 }); 472 } 473 $scope.deleteAllRecurrences = function (recid) { 474 ngDialog.openConfirm({ 475 template: 476 '<p>This will delete every found recurrence. Are you sure?</p>' + 477 '<div>' + 478 '<button type="button" class="btn btn-default" ng-click="closeThisDialog(0)">No </button> ' + 479 '<button type="button" class="btn btn-primary" ng-click="confirm(1)">Yes' + 480 '</button></div>', 481 plain: true 482 }).then(function (success) { 483 var arr = vm.treeview.currentNode.calendar.down[0]; 484 for (var i = 0; i < arr.length;) { 485 if (arr[i].rec.recid === recid) 486 vm.remove(i); 487 else 488 i++; 489 } 490 }); 491 } 492 354 493 /* Render Tooltip */ 355 494 $scope.eventRender = function (event, element, view) { … … 383 522 } 384 523 }; 385 $rootScope.$on('$locationChangeStart', function (event, newUrl, oldUrl) { 386 console.log($(".changed").length); 387 if ($(".changed").length != 0) { 388 ngDialog.openConfirm({ 389 template: 390 '<p>You have unsaved changes. Are you sure you want to leave this page? All changes will be lost. </p>' + 391 '<div>' + 392 '<button type="button" class="btn btn-primary" ng-click="confirm(1)">Yes' + 393 '<button type="button" class="btn btn-default" ng-click="closeThisDialog(0)">No </button> ' + 394 '</button></div>', 395 plain: true 396 }).then(function (success) { 397 $rootScope.allowNavigation(); 398 }); 399 } 400 401 event.preventDefault(); // This prevents the navigation from happening 402 } 403 ); 524 525 404 526 405 527 });
Note: See TracChangeset
for help on using the changeset viewer.