OSDN Git Service

Add admin page
authorhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Fri, 31 Jul 2015 18:55:09 +0000 (03:55 +0900)
committerhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Fri, 31 Jul 2015 18:55:09 +0000 (03:55 +0900)
client/app/components/admin/admin.controller.js [new file with mode: 0644]
client/app/components/admin/admin.html [new file with mode: 0644]
client/app/components/admin/admin.js [new file with mode: 0644]
client/app/components/board/board.html
client/app/components/login/login.controller.js
client/app/components/login/login.html
client/index.html

diff --git a/client/app/components/admin/admin.controller.js b/client/app/components/admin/admin.controller.js
new file mode 100644 (file)
index 0000000..a271c04
--- /dev/null
@@ -0,0 +1,83 @@
+'use strict';
+
+angular.module('zephyrApp')
+.controller('AdminController', function ($scope, $modal, Restangular, $state, user) {
+
+    // Login check
+    if(user.getID() !== $state.params.userID) {
+        user.setID(null)
+        $state.go('login')
+    }
+
+    /*
+    $scope.commandDirectives = []
+
+    // Add new my-command directive
+    $scope.openCommandModal = function() {
+        var modalInstance = $modal.open({
+            templateUrl: '/client/app/components/commandModal/commandModal.html',
+            controller: 'CommandModalController',
+            backdrop: true,
+            size: 'lg'
+        })
+        modalInstance.result.then(function(command) {
+            (function addCommandDirective() {
+                var obj = {
+                    name: command,
+                    isCompleted: false
+                }
+                $scope.commandDirectives.push(obj)
+            })()
+        })
+    }
+
+    // Remove my-command directive
+    $scope.removeCommandDirective= function(index) {
+        $scope.commandDirectives.splice(index, 1)
+    }
+
+    // 
+    $scope.save = function() {
+        $modal.open({
+            templateUrl: '/client/app/components/saveFileModal/saveFileModal.html',
+            controller: 'SaveFileModalController',
+            backdrop: true,
+            scope: $scope
+        })
+    }
+    $scope.$on('updateParams', function(event, index, params) {
+        $scope.commandDirectives[index].params = params
+        $scope.commandDirectives[index].isCompleted = true
+    })
+
+    // restore executeion log
+    var note = $state.params.noteID
+
+    if(note !== undefined) {
+        var baseNoteInfo = Restangular.all('/api/noteInfo/')
+        $scope.noteName = note
+
+        var params = {
+            note: note,
+            email: user.email
+        }
+
+        baseNoteInfo.post(params).then(function(commands) {
+            $scope.commands = commands 
+            commands.forEach(function(params) {
+                var obj = {
+                    name: params.command,
+                    isCompleted: false,
+                }
+                $scope.commandDirectives.push(obj)
+            })
+        })
+
+        $scope.$on('requestParams', function(event, i) {
+            $scope.$broadcast('sendParams'+i, $scope.commands[i])
+        })
+    } else {
+        $scope.noteName = 'new note' 
+    }
+*/
+});
diff --git a/client/app/components/admin/admin.html b/client/app/components/admin/admin.html
new file mode 100644 (file)
index 0000000..a5d911c
--- /dev/null
@@ -0,0 +1,8 @@
+<navbar></navbar>
+<div class="container">
+    <div class="row">
+        <div class="page-header">
+            <h1>Admin Page</h1>
+        </div>
+    </div>
+</div>
diff --git a/client/app/components/admin/admin.js b/client/app/components/admin/admin.js
new file mode 100644 (file)
index 0000000..dc0d2b7
--- /dev/null
@@ -0,0 +1,11 @@
+'use strict';
+
+angular.module('zephyrApp')
+.config(function($stateProvider) {
+    $stateProvider
+    .state('admin', {
+        url:'/admin/:userID?',
+        templateUrl:'/client/app/components/admin/admin.html',
+        controller: 'AdminController'
+    })
+});
index c1ef991..707a88a 100644 (file)
@@ -1,7 +1,6 @@
 <navbar></navbar>
 <div class="container">
 <div class="row">
-    <menubar></menubar>
     <div class="page-header">
         <h1>Board: {{noteName}}</h1>
         <button class="btn btn-default"
index a41e296..effe927 100644 (file)
@@ -28,14 +28,11 @@ angular.module('zephyrApp')
     $scope.submit = function() {
         var params = {
            email: $scope.email,
+           password: $scope.password || 'secret'
         }
 
-        params.password = $scope.password || 'secret'
-        
-        console.log(params)
-
         baseLogin.post(JSON.stringify(params)).then(function(userID) {
-            user.email($scope.email)
+            user.setEmail($scope.email)
             user.setID(userID)
             $state.go('board', { userID: userID })
         })
index 8822317..26916d4 100644 (file)
@@ -8,12 +8,6 @@
     <input type="text" class="form-control" ng-model="email" placeholder="email" required autofocus>
     <label class="sr-only">Password</label>
     <input type="password" name="password" class="form-control" ng-show="admin" ng-disabled="!admin" ng-model="password" placeholder="Password" required>
-    <div class="checkbox">
-        <label>
-            <input type="checkbox"
-                   ng-model="admin">login as admin 
-        </label>
-    </div>
     <button class="btn btn-lg btn-primary btn-block" type="submit">Signin</button>
     <div class="pull-right">
         <p>or
index 8f4617c..62c4834 100644 (file)
         <script src="/client/app/shared/user/user.service.js"></script>
         <!-- endinject -->
         <!-- components:js -->
+        <script src="/client/app/components/admin/admin.controller.js"></script>
+        <script src="/client/app/components/admin/admin.js"></script>
         <script src="/client/app/components/board/board.controller.js"></script>
         <script src="/client/app/components/board/board.js"></script>
         <script src="/client/app/components/commandModal/commandModal.controller.js"></script>
         <script src="/client/app/components/login/login.controller.js"></script>
         <script src="/client/app/components/login/login.js"></script>
+        <script src="/client/app/components/previewModal/previewModal.controller.js"></script>
         <script src="/client/app/components/notes/notes.controller.js"></script>
         <script src="/client/app/components/notes/notes.js"></script>
-        <script src="/client/app/components/previewModal/previewModal.controller.js"></script>
         <script src="/client/app/components/saveFileModal/saveFileModal.controller.js"></script>
         <script src="/client/app/components/signup/signup.controller.js"></script>
         <script src="/client/app/components/signup/signup.js"></script>