Browse Source

error dialog; courses load

tags/1.0.0
Robin Thoni 8 years ago
parent
commit
9865b35bb9

+ 2
- 1
app/app.js View File

@@ -48,7 +48,8 @@ app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationP
48 48
 
49 49
             var promiseLoadGroups = {
50 50
                 id: "promiseLoadGroups",
51
-                loaderGroups: ["sidebar", "toolbar"]
51
+                loaderGroups: ["toolbar"],
52
+                groups: ["sidebar"]
52 53
             };
53 54
             GroupsBusiness.loadAll(promiseLoadGroups).then(function(data)
54 55
             {

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

@@ -1,7 +1,41 @@
1 1
 angular.module('app')
2
-    .controller('HomeController', ['$scope', '$state', 'DataShareBusiness',
3
-        function($scope, $state, DataShareBusiness) {
4
-            $scope.clicked = function()
2
+    .controller('HomeController', ['$scope', '$state', 'DataShareBusiness', 'WeeksBusiness',
3
+        function($scope, $state, DataShareBusiness, WeeksBusiness) {
4
+
5
+            $scope.DataShareBusiness = DataShareBusiness;
6
+            $scope.courses = null;
7
+
8
+            $scope.getSheetCount = function()
5 9
             {
10
+                var sheetCount = function(group)
11
+                {
12
+                    var c = (group.Groups == null || group.Groups.length == 0) ? 1 : 0;
13
+                    if (group.Groups != null) {
14
+                        group.Groups.forEach(function (group) {
15
+                            c += sheetCount(group);
16
+                        });
17
+                    }
18
+                    return c;
19
+                };
20
+                return sheetCount(DataShareBusiness.getCurrentGroupOrRoot())
6 21
             };
22
+
23
+            $scope.$watch(function(){return DataShareBusiness.CurrentGroups}, function()
24
+            {
25
+                var group = DataShareBusiness.getCurrentGroup();
26
+                if (group != null && $scope.getSheetCount() < 5) {
27
+                    var promiseLoadCourses = {
28
+                        id: "promiseLoadCourses",
29
+                        groups: ["coursesView"]
30
+                    };
31
+                    WeeksBusiness.getCurrentWeek({group_id: group.Id, type_id: group.Type}, promiseLoadCourses)
32
+                        .then(function(data)
33
+                        {
34
+                            $scope.courses = data;
35
+                        });
36
+                }
37
+                else {
38
+                    $scope.courses = null;
39
+                }
40
+            });
7 41
     }]);

+ 2
- 0
app/index.html View File

@@ -57,6 +57,8 @@
57 57
     <script src="../sdk/DataAccess/RequestDataAccess.js"></script>
58 58
     <script src="../sdk/DataAccess/GroupsDataAccess.js"></script>
59 59
     <script src="../sdk/Business/GroupsBusiness.js"></script>
60
+    <script src="../sdk/DataAccess/WeeksDataAccess.js"></script>
61
+    <script src="../sdk/Business/WeeksBusiness.js"></script>
60 62
 
61 63
     <!-- Directives -->
62 64
 

+ 4
- 0
app/less/app.less View File

@@ -34,4 +34,8 @@ footer {
34 34
 .md-sidebar {
35 35
   height: 100%;
36 36
   min-height: 150px;
37
+}
38
+
39
+.welcome-message {
40
+  font-size: large;
37 41
 }

+ 10
- 9
app/views/home.html View File

@@ -1,14 +1,15 @@
1 1
 <div layout="column" layout-fill layout-align="top center">
2
-    <p>
3
-        The left sidenav will 'lock open' on a medium (>=960px wide) device.
2
+
3
+    <p ng-show="DataShareBusiness.CurrentGroups.length == 0" class="welcome-message">
4
+        Welcome to Chronos !
4 5
     </p>
5
-    <p>
6
-        The right sidenav will focus on a specific child element.
6
+
7
+    <p ng-show="getSheetCount() > 5">
8
+        Too many elements to display, please select a sub group.
7 9
     </p>
8
-    <div>
9
-        <md-button ng-click="clicked()"
10
-                   class="md-primary">
11
-            Click me
12
-        </md-button>
10
+
11
+    <div lu-busy="coursesView" class="col-xs-12">
12
+        {{ courses }}
13 13
     </div>
14
+
14 15
 </div>

+ 4
- 3
app/views/sidebar.html View File

@@ -1,6 +1,6 @@
1 1
 <md-sidenav class="md-sidenav-left md-whiteframe-z2 md-sidebar" md-component-id="left" md-is-locked-open="$mdMedia('gt-md')">
2 2
     <md-toolbar class="md-theme-indigo">
3
-        <h1 class="md-toolbar-tools">Groupes</h1>
3
+        <h1 class="md-toolbar-tools">Chronos</h1>
4 4
     </md-toolbar>
5 5
     <md-content layout-padding ng-controller="SideBarController">
6 6
         <!--<md-button ng-click="close()" class="md-primary" hide-gt-md>
@@ -11,14 +11,15 @@
11 11
             narrow your display.
12 12
         </p>-->
13 13
         <ul class="col-sm-12" lu-busy="sidebar">
14
-            <li ng-show="DataShareBusiness.CurrentGroups.length != 0">
14
+            <li ng-show="DataShareBusiness.CurrentGroups.length != 0" class="col-xs-12">
15 15
                 <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
16 16
                            ng-href="{{DataShareBusiness.getGroupUrl(DataShareBusiness.getCurrentGroup().Parent)}}">
17 17
                     ..
18 18
                 </md-button>
19 19
             </li>
20
-            <li ng-repeat="group in getCurrentGroups()">
20
+            <li ng-repeat="group in getCurrentGroups()" class="col-xs-12">
21 21
                 <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
22
+                           ng-class="{'md-focused': DataShareBusiness.getCurrentGroup().Id == group.Id}"
22 23
                            ng-href="{{DataShareBusiness.getGroupUrl(group)}}">
23 24
                     {{ group.Name }}
24 25
                 </md-button>

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

@@ -30,6 +30,21 @@
30 30
                     return data.CurrentGroups[data.CurrentGroups.length - 1];
31 31
                 },
32 32
 
33
+                getCurrentGroupOrRoot: function()
34
+                {
35
+                    var group = data.getCurrentGroup();
36
+                    if (group == null) {
37
+                        return {
38
+                            Id: null,
39
+                            Groups: data.Groups,
40
+                            Name: "Root",
41
+                            Type: 1,
42
+                            ParentId: -1
43
+                        }
44
+                    }
45
+                    return group;
46
+                },
47
+
33 48
                 getSearchString: function(group)
34 49
                 {
35 50
                     if (group == -1 && data.CurrentGroups.length != 0) {

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

@@ -0,0 +1,14 @@
1
+(function()
2
+{
3
+    angular.module('appSdk')
4
+        .factory('WeeksBusiness', ['WeeksDataAccess', function (WeeksDataAccess) {
5
+
6
+            var Business = {};
7
+
8
+            Business.getWeek = WeeksDataAccess.getWeek;
9
+
10
+            Business.getCurrentWeek = WeeksDataAccess.getCurrentWeek;
11
+
12
+            return Business;
13
+        }]);
14
+})();

+ 11
- 3
sdk/Business/lubusy.js View File

@@ -3,8 +3,8 @@
3 3
  */
4 4
 
5 5
 angular.module('appSdk')
6
-    .directive('luBusy', ['$compile', '$http', 'PromisesDataAccess', '$templateCache',
7
-        function($compile, $http, PromisesDataAccess, $templateCache){
6
+    .directive('luBusy', ['$compile', '$http', 'PromisesDataAccess', '$templateCache', '$mdDialog',
7
+        function($compile, $http, PromisesDataAccess, $templateCache, $mdDialog){
8 8
         return {
9 9
             restrict: 'A',
10 10
             scope: {
@@ -73,7 +73,15 @@ angular.module('appSdk')
73 73
                         });
74 74
                     }
75 75
                     if (error != null) {
76
-                        //luticateDialogErrorHelper.errorDialog(error.value);
76
+                        $mdDialog.show(
77
+                            $mdDialog.alert()
78
+                                .parent(angular.element(document.querySelector('#popupContainer')))
79
+                                .clickOutsideToClose(true)
80
+                                .title('Oops, an error has occurred')
81
+                                .textContent(error.value.Data.Message || error.value)
82
+                                .ariaLabel('Oops, an error has occurred')
83
+                                .ok('Ok')
84
+                        );
77 85
                     }
78 86
                 };
79 87
 

+ 20
- 0
sdk/DataAccess/WeeksDataAccess.js View File

@@ -0,0 +1,20 @@
1
+(function()
2
+{
3
+    angular.module('appSdk')
4
+        .factory('WeeksDataAccess', ['$q', 'RequestDataAccess', function ($q, RequestDataAccess) {
5
+
6
+            var DataAccess = {};
7
+
8
+            DataAccess.getWeek = function(data, promise)
9
+            {
10
+                return RequestDataAccess.get("/api/week/getweek/" + data.week_id + "/" + data.group_id + "/" + data.type_id, null, promise);
11
+            };
12
+
13
+            DataAccess.getCurrentWeek = function(data, promise)
14
+            {
15
+                return RequestDataAccess.get("/api/week/getcurrentweek/" + data.group_id + "/" + data.type_id, null, promise);
16
+            };
17
+
18
+            return DataAccess;
19
+        }]);
20
+})();

Loading…
Cancel
Save