Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

freeroom.controller.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * Created by robin on 11/1/15.
  3. */
  4. angular.module('app')
  5. .controller('FreeRoomController', ['$scope', 'DataShareBusiness', 'RoomsBusiness',
  6. function($scope, DataShareBusiness, RoomsBusiness) {
  7. $scope.dateFormat = DataShareBusiness.DateFormat;
  8. $scope.timeFormat = DataShareBusiness.TimeFormat;
  9. $scope.dateTimeFormat = DataShareBusiness.DateTimeFormat;
  10. $scope.rootRooms = null;
  11. $scope.rootRoom = null;
  12. $scope.freeRooms = [];
  13. $scope.Search = {
  14. Begin: new Date(),
  15. End: new Date()
  16. };
  17. $scope.Search.End.setTime($scope.Search.End.getTime() + (60*60*1000));
  18. var promiseLoadRooms = {
  19. id: "promiseLoadRooms",
  20. groups: ["freerooms-root"]
  21. };
  22. RoomsBusiness.getRootRooms(promiseLoadRooms).then(function(data)
  23. {
  24. $scope.rootRooms = data;
  25. $scope.rootRoom = $scope.rootRooms.find(function(room)
  26. {
  27. return room.Name.toLowerCase() == "kb";
  28. });
  29. if ($scope.rootRoom == null) {
  30. $scope.rootRoom = $scope.rootRooms[0];
  31. }
  32. });
  33. $scope.openMenu = function($mdOpenMenu, ev) {
  34. $mdOpenMenu(ev);
  35. };
  36. $scope.setRootRoom = function(room)
  37. {
  38. $scope.rootRoom = room;
  39. };
  40. $scope.search = function()
  41. {
  42. var promiseLoadFreeRooms = {
  43. id: "promiseLoadFreeRooms",
  44. errorGroups: ["freerooms"],
  45. loaderGroups: ["freerooms-root"]
  46. };
  47. RoomsBusiness.getFreeRooms({
  48. begin: Math.floor($scope.Search.Begin.getTime() / 1000),
  49. end: Math.floor($scope.Search.End.getTime() / 1000),
  50. root_room: $scope.rootRoom.Id
  51. }, promiseLoadFreeRooms).then(function(data)
  52. {
  53. $scope.freeRooms = data;
  54. });
  55. };
  56. }]);