123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- /**
- * Created by robin on 11/1/15.
- */
-
- angular.module('app')
- .controller('FreeRoomController', ['$scope', 'DataShareBusiness', 'RoomsBusiness',
- function($scope, DataShareBusiness, RoomsBusiness) {
-
- $scope.dateFormat = DataShareBusiness.DateFormat;
- $scope.timeFormat = DataShareBusiness.TimeFormat;
- $scope.dateTimeFormat = DataShareBusiness.DateTimeFormat;
- $scope.rootRooms = null;
- $scope.rootRoom = null;
- $scope.freeRooms = [];
-
- $scope.Search = {
- Begin: new Date(),
- End: new Date()
- };
- $scope.Search.End.setTime($scope.Search.End.getTime() + (60*60*1000));
-
- var promiseLoadRooms = {
- id: "promiseLoadRooms",
- groups: ["freerooms-root"]
- };
- RoomsBusiness.getRootRooms(promiseLoadRooms).then(function(data)
- {
- $scope.rootRooms = data;
- $scope.rootRoom = $scope.rootRooms.find(function(room)
- {
- return room.Name.toLowerCase() == "kb";
- });
- if ($scope.rootRoom == null) {
- $scope.rootRoom = $scope.rootRooms[0];
- }
- });
-
- $scope.openMenu = function($mdOpenMenu, ev) {
- $mdOpenMenu(ev);
- };
-
- $scope.setRootRoom = function(room)
- {
- $scope.rootRoom = room;
- };
-
- $scope.search = function()
- {
- var promiseLoadFreeRooms = {
- id: "promiseLoadFreeRooms",
- errorGroups: ["freerooms"],
- loaderGroups: ["freerooms-root"]
- };
- RoomsBusiness.getFreeRooms({
- begin: Math.floor($scope.Search.Begin.getTime() / 1000),
- end: Math.floor($scope.Search.End.getTime() / 1000),
- root_room: $scope.rootRoom.Id
- }, promiseLoadFreeRooms).then(function(data)
- {
- $scope.freeRooms = data;
- });
- };
- }]);
|