Browse Source

get/del domains

develop
Robin Thoni 8 years ago
parent
commit
7d06db259d

+ 1
- 3
README.md View File

@@ -1,6 +1,4 @@
1
-# Starter kit for AngularJS
2
-
3
-Here is an angular material starter kit to use with Luticate (https://git.rthoni.com/luticate/)
1
+# Local network manager
4 2
 
5 3
 ## Usage
6 4
 ```shell

+ 15
- 4
app/app.js View File

@@ -30,17 +30,25 @@ app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationP
30 30
         $stateProvider.state('login',{
31 31
             url:'/',
32 32
             parent: 'root',
33
+            title: "Login",
33 34
             templateUrl:'views/login.html',
34
-            controller:'LoginController',
35
-            resolve:{}
35
+            controller:'LoginController'
36 36
         });
37 37
 
38 38
         $stateProvider.state('home',{
39 39
             url:'/home',
40 40
             parent: 'root',
41
+            title: "Home",
41 42
             templateUrl:'views/home.html',
42
-            controller:'HomeController',
43
-            revolve:{}
43
+            controller:'HomeController'
44
+        });
45
+
46
+        $stateProvider.state('dns',{
47
+            url:'/dns',
48
+            parent: 'root',
49
+            title: "DNS",
50
+            templateUrl:'views/dns.html',
51
+            controller:'DnsController'
44 52
         });
45 53
 
46 54
         $urlRouterProvider.otherwise('/');
@@ -71,6 +79,9 @@ app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationP
71 79
         };
72 80
     }])
73 81
     .run(['$rootScope', '$state',function ($rootScope, $state) {
82
+        $rootScope.$on('$stateChangeSuccess', function (event, current, previous) {
83
+            $rootScope.title = current.title + " - App";
84
+        });
74 85
         $rootScope.$on('$stateChangeError', function (e, curr, prev) {
75 86
             //$state.go('login');
76 87
         });

+ 49
- 0
app/controllers/dns.controller.js View File

@@ -0,0 +1,49 @@
1
+angular.module('app')
2
+    .controller('DnsController', ['$scope', '$state', 'DnsBusiness',
3
+        function($scope, $state, DnsBusiness) {
4
+            $scope.luTable = {
5
+                columns: [
6
+                    {
7
+                        name: "Name",
8
+                        width: 4,
9
+                        getValue: function (item) {
10
+                            return item.Name;
11
+                        }
12
+                    },
13
+                    {
14
+                        name: "Type",
15
+                        width: 8,
16
+                        getValue: function (item) {
17
+                            return item.Type;
18
+                        }
19
+                    }
20
+                ],
21
+
22
+                canAdd: function()
23
+                {
24
+                    return true;
25
+                },
26
+
27
+                canDel: function()
28
+                {
29
+                    return true;
30
+                },
31
+
32
+                canEdit: function()
33
+                {
34
+                    return true;
35
+                },
36
+
37
+                getLoadPagePromise: function (page, perPage, query, promise) {
38
+                    return DnsBusiness.getAll({page: page, perPage: perPage, query: query}, promise);
39
+                },
40
+
41
+                getDelPromise: function (id, promise) {
42
+                    return DnsBusiness.del({domain_id: id}, promise);
43
+                },
44
+
45
+                getEditController: function () {
46
+                    return "CameraEdit";
47
+                }
48
+            };
49
+    }]);

+ 1
- 0
app/controllers/home.controller.js View File

@@ -2,5 +2,6 @@ angular.module('app')
2 2
     .controller('HomeController', ['$scope', '$state',
3 3
         function($scope, $state) {
4 4
 
5
+            $state.go("dns");
5 6
 
6 7
     }]);

+ 1
- 2
app/controllers/navbar.controller.js View File

@@ -39,8 +39,7 @@ angular.module('app')
39 39
                 return luticateAuthCache.hasOneEffectivePermission([
40 40
                     "LU_USER_GET",
41 41
                     "LU_GROUP_GET",
42
-                    "LU_PERM_GET",
43
-                    "ADMIN_PERMISSION"
42
+                    "LU_PERM_GET"
44 43
                 ]);
45 44
             };
46 45
         }]);

+ 4
- 1
app/index.html View File

@@ -3,7 +3,7 @@
3 3
 <head>
4 4
     <base href="/app/">
5 5
     <meta charset="utf-8">
6
-    <title>App</title>
6
+    <title ng-bind="title">Lunet</title>
7 7
 
8 8
     <!-- build:css css/globals.css -->
9 9
     <link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css">
@@ -47,11 +47,14 @@
47 47
     <script src="controllers/navbar.controller.js"></script>
48 48
     <script src="controllers/login.controller.js"></script>
49 49
     <script src="controllers/home.controller.js"></script>
50
+    <script src="controllers/dns.controller.js"></script>
50 51
 
51 52
     <!-- Modal Controller -->
52 53
 
53 54
     <!-- SDK -->
54 55
     <script src="../sdk/sdk.js"></script>
56
+    <script src="../sdk/DataAccess/dns.js"></script>
57
+    <script src="../sdk/Business/dns.js"></script>
55 58
 
56 59
     <!-- Directives -->
57 60
 

+ 8
- 0
app/views/dns.html View File

@@ -0,0 +1,8 @@
1
+<!-- Page Content -->
2
+<div class="container">
3
+    <div class="row">
4
+        <div class="col-md-12">
5
+            <lu-edit-table options="luTable"></lu-edit-table>
6
+        </div>
7
+    </div>
8
+</div>

+ 0
- 2
app/views/home.html View File

@@ -1,8 +1,6 @@
1 1
 <!-- Page Content -->
2 2
 <div class="container">
3
-
4 3
     <div class="row">
5
-
6 4
         <div class="col-md-12">
7 5
         </div>
8 6
     </div>

+ 3
- 3
app/views/navbar.html View File

@@ -14,12 +14,12 @@
14 14
         <!-- Collect the nav links, forms, and other content for toggling -->
15 15
         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
16 16
             <ul class="nav navbar-nav navbar-left">
17
-                <li ui-sref-active="active"><a ui-sref="item" lu-show-permission="PERMISSION">Item</a></li>
18
-                <li><a href="/admin" target="_blank" ng-show="canSeeAdmin()">Administration</a></li>
17
+                <li ui-sref-active="active"><a ui-sref="dns" >DNS</a></li>
18
+                <li><a href="/luticate" target="_blank" ng-show="canSeeAdmin()">Luticate</a></li>
19 19
             </ul>
20 20
             <ul class="nav navbar-nav navbar-right">
21 21
                 <ul class="nav navbar-nav navbar-right">
22
-                    <li ng-show="isLogged()"><a ui-sref="cameras">{{ getUsername() }}</a></li>
22
+                    <li ng-show="isLogged()"><a ui-sref="home">{{ getUsername() }}</a></li>
23 23
                     <li ng-show="isLogged()"><a href="" ng-click="logout()">Logout</a></li>
24 24
                     <li ng-show="!isLogged()"><a href="" ng-click="logout()">Login</a></li>
25 25
                 </ul>

+ 25
- 0
sdk/Business/dns.js View File

@@ -0,0 +1,25 @@
1
+/**
2
+ * Created by robin on 3/17/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('DnsBusiness', ['DnsDataAccess', '$q', function (DnsDataAccess, $q) {
10
+
11
+            var Business = {};
12
+
13
+            Business.add = DnsDataAccess.add;
14
+
15
+            Business.getAll = DnsDataAccess.getAll;
16
+
17
+            Business.get = DnsDataAccess.get;
18
+
19
+            Business.edit = DnsDataAccess.edit;
20
+
21
+            Business.del = DnsDataAccess.del;
22
+
23
+            return Business;
24
+        }]);
25
+})();

+ 42
- 0
sdk/DataAccess/dns.js View File

@@ -0,0 +1,42 @@
1
+/**
2
+ * Created by robin on 3/17/16.
3
+ */
4
+
5
+(function () {
6
+    'use strict';
7
+
8
+    angular.module('appSdk')
9
+        .factory('DnsDataAccess', ['luticateRequest', function (luticateRequest) {
10
+
11
+            var DataAccess = {};
12
+
13
+            var entry_point = "/api/dns/";
14
+
15
+            DataAccess.add = function(data, promise)
16
+            {
17
+                return luticateRequest.post(entry_point + "add", {domain: JSON.stringify(data)}, null, promise);
18
+            };
19
+
20
+            DataAccess.getAll = function(data, promise)
21
+            {
22
+                return luticateRequest.get(entry_point, data, promise);
23
+            };
24
+
25
+            DataAccess.get = function(data, promise)
26
+            {
27
+                return luticateRequest.get(entry_point + data.domain_id , null, promise);
28
+            };
29
+
30
+            DataAccess.edit = function(data, promise)
31
+            {
32
+                return luticateRequest.post(entry_point + data.domain_id + "/edit", {domain: JSON.stringify(data)}, null, promise);
33
+            };
34
+
35
+            DataAccess.del = function(data, promise)
36
+            {
37
+                return luticateRequest.post(entry_point + data.domain_id + "/del", null, null, promise);
38
+            };
39
+
40
+            return DataAccess;
41
+        }]);
42
+})();

Loading…
Cancel
Save