OSDN Git Service

modified noteInfo api to returning user own notes
authorhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Fri, 31 Jul 2015 09:50:06 +0000 (18:50 +0900)
committerhimetani_cafe <fumifumi@yasunaga-lab.bio.kyutech.ac.jp>
Fri, 31 Jul 2015 09:50:06 +0000 (18:50 +0900)
auth [deleted file]
client/app/app.js
client/app/components/board/board.controller.js
client/app/shared/user/user.service.js
server/api/noteInfo/index.js
server/auth/signup/index.js
server/jb.js

diff --git a/auth b/auth
deleted file mode 100644 (file)
index e69de29..0000000
index 0043f0b..ed48dc2 100644 (file)
@@ -10,7 +10,7 @@ angular.module('zephyrApp', ['ui.bootstrap', 'ui.router', 'restangular','ngRoute
     $httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
 
     // Debug
-    //$urlRouterProvider.otherwise('/board/504d41f91d2f81f02561b93a0e9ccde4')
+    $urlRouterProvider.otherwise('/notes/504d41f91d2f81f02561b93a0e9ccde4')
 
 })
 .run(function($rootScope, $state, Restangular, user) {
index 8ec0e17..7449f35 100644 (file)
@@ -52,10 +52,17 @@ angular.module('zephyrApp')
 
     // restore executeion log
     var note = $state.params.noteID
-    if(!note) {
+
+    if(note !== undefined) {
+        var baseNoteInfo = Restangular.all('/api/noteInfo/')
         $scope.noteName = note
-        var baseNoteInfo = Restangular.all('/api/noteInfo/'+note)
-        baseNoteInfo.getList().then(function(commands) {
+
+        var params = {
+            note: note,
+            email: user.email
+        }
+
+        baseNoteInfo.post(params).then(function(commands) {
             $scope.commands = commands 
             commands.forEach(function(params) {
                 var obj = {
@@ -65,6 +72,7 @@ angular.module('zephyrApp')
                 $scope.commandDirectives.push(obj)
             })
         })
+
         $scope.$on('requestParams', function(event, i) {
             $scope.$broadcast('sendParams'+i, $scope.commands[i])
         })
index 02ef761..0d462d6 100644 (file)
@@ -12,7 +12,7 @@ angular.module('zephyrApp')
             return userID
         },
         setEmail: function(addr) {
-            email: addr
+            email = addr
         },
         getEmail: function() {
             return email
index 669ea7f..a54d4da 100644 (file)
@@ -3,30 +3,48 @@
 var express = require('express'),
     router  = express.Router(),
     path    = require('path'),
-    fs      = require('fs')
+    fs      = require('fs'),
+    jb      = require('../../jb')
 
-router.get('/:note', function(req, res) {
-    var note = req.params.note
-    var dirPath
+router.post('/', function(req, res) {
+    var note = req.body.note,
+        email = req.body.email,
+        dirPath
+
+
+    // Return file list at /note/*
     if(note === 'root') {
-        dirPath = path.normalize(__dirname+'/../../../notes/')
-        var filesInfo = fs.readdirSync(dirPath).filter(function(file) {
-            return file.substring(0,1) !== '.' && file !== 'preview' 
-        })
-        .map(function(file) {
-            var stat = fs.statSync(dirPath+'/'+file)
-            stat.name = file
-            return stat
-        })
-        .map(function(stat) {
-            stat.name = stat.name.split('.')[0]
-            return stat
+        jb.findOne('user', function(err, documents) {
+            var filesInfo = documents.notes.map(function(note) { 
+                var notePath = path.normalize(__dirname+'/../../../notes/'+note)
+                var stat = fs.statSync(notePath)
+                stat.name = note.split('.')[0]
+
+                return stat
+            })
+            res.send(filesInfo)
         })
-        res.send(filesInfo)
+
+
+        /*
+           var filesInfo = fs.readdirSync(dirPath).filter(function(file) {
+           return file.substring(0,1) !== '.' && file !== 'preview' 
+           })
+           .map(function(file) {
+           stat.name = file
+           return stat
+           })
+           .map(function(stat) {
+           stat.name = stat.name.split('.')[0]
+           return stat
+           })
+           res.send(filesInfo)
+           */
+        // Return content of the note
     } else {
         var noteJSON = require(path.normalize(__dirname+'/../../../notes/'+note+'.json'))
-        res.json(noteJSON)
+            res.json(noteJSON)
     }
 })
 
-module.exports = router;
+        module.exports = router;
index b9a6cda..28f2ac1 100644 (file)
@@ -15,7 +15,7 @@ router.post('/', function(req, res) {
                     var newuser = {
                         email: email,
                         password: password,
-                        role : [],
+                        role : [], // superuser | expert | amature
                         notes: [],
                         workspaces:[]
                     }
index bfc238d..a51fb3c 100644 (file)
@@ -6,9 +6,17 @@ var express = require('express'),
     jb = EJDB.open("db/user.db")
 
 if(process.env.DB_ZEPHYR === 'drop') {
-    jb.dropCollection('user',
-                      { prune: true },
-                     function() {})
+    jb.dropCollection('user',{ prune: true }, function() {})
+
+    var user1 = {
+        email: 'fumifumi@yasunaga-lab.bio.kyutech.ac.jp',
+        password: 'secret',
+        role: ['expert'],
+        notes: ['namae.json', 'sample_1.json']
+    }
+
+    var users = [user1]
+    jb.save('user', users, function() {} ) 
 }
 
 module.exports = jb