Bläddra i källkod

free room controller

tags/1.0.0
Robin Thoni 8 år sedan
förälder
incheckning
150db485a1

+ 49
- 2
app/controllers/freeroom.controller.js Visa fil

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

Binär
app/img/location.png Visa fil


+ 2
- 1
app/index.html Visa fil

@@ -64,6 +64,8 @@
64 64
     <script src="../sdk/Business/GroupsBusiness.js"></script>
65 65
     <script src="../sdk/DataAccess/WeeksDataAccess.js"></script>
66 66
     <script src="../sdk/Business/WeeksBusiness.js"></script>
67
+    <script src="../sdk/DataAccess/RoomsDataAccess.js"></script>
68
+    <script src="../sdk/Business/RoomsBusiness.js"></script>
67 69
 
68 70
     <!-- Directives -->
69 71
 
@@ -79,7 +81,6 @@
79 81
 
80 82
         <md-content flex layout-padding class="md-main-content" >
81 83
             <div ui-view layout="column" layout-fill layout-align="top center"></div>
82
-            <div flex></div>
83 84
         </md-content>
84 85
 
85 86
         <ng-include src="'views/footer.html'"></ng-include>

+ 0
- 4
app/less/app.less Visa fil

@@ -1,7 +1,3 @@
1
-footer {
2
-  margin: 50px 0;
3
-}
4
-
5 1
 .text-center() {
6 2
   text-align: center;
7 3
 }

+ 33
- 5
app/views/freeroom.html Visa fil

@@ -1,12 +1,40 @@
1
-<div layout="column" layout-fill layout-align="top center">
1
+<div layout="column" layout-fill layout-align="top center" class="col-xs-12" lu-busy="freerooms-root">
2
+
2 3
     <div>
3 4
         <md-input-container class="md-input-has-placeholder">
4
-            <input mdc-datetime-picker="" date="true" time="true" type="text" id="datetime"
5
-                   placeholder="From" min-date="date" ng-model="Search.Begin" class=" md-input">
5
+            <input mdc-datetime-picker="" date="true" time="true" type="text" id="datetimeBegin"
6
+                   format="{{dateTimeFormat}}" placeholder="From" ng-model="Search.Begin" class="md-input">
6 7
         </md-input-container>
8
+
7 9
         <md-input-container class="md-input-has-placeholder">
8
-            <input mdc-datetime-picker="" date="true" time="true" type="text" id="datetime"
9
-                   placeholder="To" min-date="date" ng-model="Search.End" class=" md-input">
10
+            <input mdc-datetime-picker="" date="true" time="true" type="text" id="datetimeEnd"
11
+                   format="{{dateTimeFormat}}" placeholder="To" ng-model="Search.End" class="md-input">
10 12
         </md-input-container>
13
+
14
+        <md-menu>
15
+            <md-button aria-label="Open location menu" class="md-button" ng-click="openMenu($mdOpenMenu, $event)">
16
+                <img src="img/location.png" /> {{rootRoom.Name}}
17
+            </md-button>
18
+            <md-menu-content width="4">
19
+                <md-menu-item ng-repeat="room in rootRooms">
20
+                    <md-button ng-click="setRootRoom(room)">
21
+                        {{room.Name}}
22
+                    </md-button>
23
+                </md-menu-item>
24
+            </md-menu-content>
25
+        </md-menu>
26
+
27
+        <md-button ng-click="search()">
28
+            Go!
29
+        </md-button>
11 30
     </div>
31
+
32
+    <div class="clearfix"></div>
33
+
34
+    <div class="col-xs-offset-2 col-xs-8" lu-busy="freerooms">
35
+        <div class="col-xs-4" ng-repeat="room in freeRooms">
36
+            {{room.Name}}
37
+        </div>
38
+    </div>
39
+
12 40
 </div>

+ 1
- 1
sdk/Business/DataShareBusiness.js Visa fil

@@ -14,7 +14,7 @@
14 14
 
15 15
                 TimeFormat: "HH'h'mm",
16 16
 
17
-                DateTimeFormat: "dd MMM yyyy HH'h'mm",
17
+                DateTimeFormat: "DD MMM YYYY HH[h]mm",
18 18
 
19 19
                 goToGroup: function(group)
20 20
                 {

+ 14
- 0
sdk/Business/RoomsBusiness.js Visa fil

@@ -0,0 +1,14 @@
1
+(function()
2
+{
3
+    angular.module('appSdk')
4
+        .factory('RoomsBusiness', ['RoomsDataAccess', '$q', function (RoomsDataAccess, $q) {
5
+
6
+            var Business = {};
7
+
8
+            Business.getRootRooms = RoomsDataAccess.getRootRooms;
9
+
10
+            Business.getFreeRooms = RoomsDataAccess.getFreeRooms;
11
+
12
+            return Business;
13
+        }]);
14
+})();

+ 21
- 0
sdk/DataAccess/RoomsDataAccess.js Visa fil

@@ -0,0 +1,21 @@
1
+(function()
2
+{
3
+    angular.module('appSdk')
4
+        .factory('RoomsDataAccess', ['$q', 'RequestDataAccess', function ($q, RequestDataAccess) {
5
+
6
+            var DataAccess = {};
7
+
8
+            DataAccess.getRootRooms = function(promise)
9
+            {
10
+                return RequestDataAccess.get("/api/room/getrootrooms", null, promise);
11
+            };
12
+
13
+            DataAccess.getFreeRooms = function(data, promise)
14
+            {
15
+                return RequestDataAccess.get("/api/room/getfree/" + data.begin + "/" +
16
+                    data.end + "/" + data.root_room, null, promise);
17
+            };
18
+
19
+            return DataAccess;
20
+        }]);
21
+})();

Laddar…
Avbryt
Spara