Browse Source

added web services call

tags/1.0.0
Robin Thoni 8 years ago
parent
commit
4bbd08638d

+ 16
- 5
app/app.js View File

@@ -37,16 +37,27 @@ app.config(['$stateProvider', '$urlRouterProvider',
37 37
             }
38 38
         };
39 39
     }])
40
-    .run(['$rootScope', '$state', 'DataShareBusiness', 'GroupsBusiness', '$mdDateLocale', '$filter',
41
-        function ($rootScope, $state, DataShareBusiness, GroupsBusiness, $mdDateLocale, $filter) {
40
+    .run(['$rootScope', '$state', 'DataShareBusiness', 'GroupsBusiness', 'StaffsBusiness', 'RoomsBusiness', '$mdDateLocale', '$filter',
41
+        function ($rootScope, $state, DataShareBusiness, GroupsBusiness, StaffsBusiness, RoomsBusiness, $mdDateLocale, $filter) {
42 42
 
43 43
 
44
-            var promiseLoadGroups = {
45
-                id: "promiseLoadGroups",
44
+            var promiseLoadEntities = {
45
+                id: "promiseLoadEntities",
46 46
                 loaderGroups: ["toolbar"],
47 47
                 groups: ["sidebar"]
48 48
             };
49
-            GroupsBusiness.loadAll(promiseLoadGroups);
49
+            GroupsBusiness.getAll(promiseLoadEntities).then(function(groups)
50
+            {
51
+                StaffsBusiness.getAll(promiseLoadEntities).then(function(staffs)
52
+                {
53
+                    RoomsBusiness.getAll(promiseLoadEntities).then(function(rooms)
54
+                    {
55
+                        DataShareBusiness.Groups = groups;
56
+                        DataShareBusiness.Staffs = staffs;
57
+                        DataShareBusiness.Rooms = rooms;
58
+                    });
59
+                });
60
+            });
50 61
 
51 62
             $mdDateLocale.firstDayOfWeek = 1;
52 63
             $mdDateLocale.formatDate = function(date) {

+ 3
- 3
app/controllers/home.controller.js View File

@@ -10,9 +10,9 @@ angular.module('app')
10 10
                 id: null,
11 11
                 date: null
12 12
             };
13
-            $scope.days = [{day:"Monday", date: null}, {day:"Tuesday", date: null}, {day:"Wednesday", date: null},
14
-                {day:"Thursday", date: null}, {day:"Friday", date: null}, {day:"Saturday", date: null},
15
-                {day:"Sunday", date: null}];
13
+            $scope.days = [{day: "Monday", date: null}, {day: "Tuesday", date: null}, {day: "Wednesday", date: null},
14
+                {day: "Thursday", date: null}, {day: "Friday", date: null}, {day: "Saturday", date: null},
15
+                {day: "Sunday", date: null}];
16 16
             $scope.hours = [];
17 17
 
18 18
             $scope.selectedDate = new Date();

+ 2
- 0
app/index.html View File

@@ -66,6 +66,8 @@
66 66
     <script src="../sdk/Business/WeeksBusiness.js"></script>
67 67
     <script src="../sdk/DataAccess/RoomsDataAccess.js"></script>
68 68
     <script src="../sdk/Business/RoomsBusiness.js"></script>
69
+    <script src="../sdk/DataAccess/StaffsDataAccess.js"></script>
70
+    <script src="../sdk/Business/StaffsBusiness.js"></script>
69 71
 
70 72
     <!-- Directives -->
71 73
 

+ 14
- 0
sdk/Business/DataShareBusiness.js View File

@@ -6,6 +6,10 @@
6 6
             var data = {
7 7
                 Groups: null,
8 8
 
9
+                Staffs: null,
10
+
11
+                Rooms: null,
12
+
9 13
                 SearchSeparator: "~",
10 14
 
11 15
                 CurrentGroups: [],
@@ -16,6 +20,16 @@
16 20
 
17 21
                 DateTimeFormat: "DD MMM YYYY HH[h]mm",
18 22
 
23
+                makeParents: function(group)
24
+                {
25
+                    if (group.Groups != null) {
26
+                        group.Groups.forEach(function (g) {
27
+                            g.Parent = group;
28
+                            data.makeParents(g);
29
+                        });
30
+                    }
31
+                },
32
+
19 33
                 goToGroup: function(group)
20 34
                 {
21 35
                     var search = data.getSearchString(group);

+ 3
- 25
sdk/Business/GroupsBusiness.js View File

@@ -1,20 +1,11 @@
1 1
 (function()
2 2
 {
3 3
     angular.module('appSdk')
4
-        .factory('GroupsBusiness', ['GroupsDataAccess', '$q', 'DataShareBusiness', function (GroupsDataAccess, $q, DataShareBusiness) {
4
+        .factory('GroupsBusiness', ['GroupsDataAccess', '$q', 'DataShareBusiness',
5
+            function (GroupsDataAccess, $q, DataShareBusiness) {
5 6
 
6 7
             var Business = {};
7 8
 
8
-            Business.makeParents = function(group)
9
-            {
10
-                if (group.Groups != null) {
11
-                    group.Groups.forEach(function (g) {
12
-                        g.Parent = group;
13
-                        Business.makeParents(g);
14
-                    });
15
-                }
16
-            };
17
-
18 9
             Business.getAll = function(promise)
19 10
             {
20 11
                 var defer = $q.defer();
@@ -23,7 +14,7 @@
23 14
                 {
24 15
                     data.forEach(function(group)
25 16
                     {
26
-                        Business.makeParents(group);
17
+                        DataShareBusiness.makeParents(group);
27 18
                         group.parent = null;
28 19
                     });
29 20
                     defer.resolve(data);
@@ -32,19 +23,6 @@
32 23
                 return defer.promise;
33 24
             };
34 25
 
35
-            Business.loadAll = function(promise)
36
-            {
37
-                var defer = $q.defer();
38
-
39
-                Business.getAll(promise).then(function(data)
40
-                {
41
-                    DataShareBusiness.Groups = data;
42
-                    defer.resolve(data);
43
-                }, defer.reject);
44
-
45
-                return defer.promise;
46
-            };
47
-
48 26
             return Business;
49 27
         }]);
50 28
 })();

+ 18
- 1
sdk/Business/RoomsBusiness.js View File

@@ -1,7 +1,7 @@
1 1
 (function()
2 2
 {
3 3
     angular.module('appSdk')
4
-        .factory('RoomsBusiness', ['RoomsDataAccess', '$q', function (RoomsDataAccess, $q) {
4
+        .factory('RoomsBusiness', ['RoomsDataAccess', '$q', 'DataShareBusiness', function(RoomsDataAccess, $q, DataShareBusiness) {
5 5
 
6 6
             var Business = {};
7 7
 
@@ -9,6 +9,23 @@
9 9
 
10 10
             Business.getFreeRooms = RoomsDataAccess.getFreeRooms;
11 11
 
12
+            Business.getAll = function(promise)
13
+            {
14
+                var defer = $q.defer();
15
+
16
+                RoomsDataAccess.getAll(promise).then(function(data)
17
+                {
18
+                    data.forEach(function(group)
19
+                    {
20
+                        DataShareBusiness.makeParents(group);
21
+                        group.parent = null;
22
+                    });
23
+                    defer.resolve(data);
24
+                }, defer.reject);
25
+
26
+                return defer.promise;
27
+            };
28
+
12 29
             return Business;
13 30
         }]);
14 31
 })();

+ 27
- 0
sdk/Business/StaffsBusiness.js View File

@@ -0,0 +1,27 @@
1
+(function()
2
+{
3
+    angular.module('appSdk')
4
+        .factory('StaffsBusiness', ['StaffsDataAccess', '$q', 'DataShareBusiness', function (StaffsDataAccess, $q, DataShareBusiness) {
5
+
6
+            var Business = {};
7
+
8
+            Business.getAll = function(promise)
9
+            {
10
+                var defer = $q.defer();
11
+
12
+                StaffsDataAccess.getAll(promise).then(function(data)
13
+                {
14
+                    data.forEach(function(group)
15
+                    {
16
+                        DataShareBusiness.makeParents(group);
17
+                        group.parent = null;
18
+                    });
19
+                    defer.resolve(data);
20
+                }, defer.reject);
21
+
22
+                return defer.promise;
23
+            };
24
+
25
+            return Business;
26
+        }]);
27
+})();

+ 5
- 0
sdk/DataAccess/RoomsDataAccess.js View File

@@ -16,6 +16,11 @@
16 16
                     data.end + "/" + data.root_room, null, promise);
17 17
             };
18 18
 
19
+            DataAccess.getAll = function(promise)
20
+            {
21
+                return RequestDataAccess.get("/api/room/getrooms", null, promise);
22
+            };
23
+
19 24
             return DataAccess;
20 25
         }]);
21 26
 })();

+ 15
- 0
sdk/DataAccess/StaffsDataAccess.js View File

@@ -0,0 +1,15 @@
1
+(function()
2
+{
3
+    angular.module('appSdk')
4
+        .factory('StaffsDataAccess', ['$q', 'RequestDataAccess', function ($q, RequestDataAccess) {
5
+
6
+            var DataAccess = {};
7
+
8
+            DataAccess.getAll = function(promise)
9
+            {
10
+                return RequestDataAccess.get("/api/staff/getstaff", null, promise);
11
+            };
12
+
13
+            return DataAccess;
14
+        }]);
15
+})();

Loading…
Cancel
Save