$httpProvider.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
// Debug
- //$urlRouterProvider.otherwise('/board/504d41f91d2f81f02561b93a0e9ccde4')
+ $urlRouterProvider.otherwise('/notes/504d41f91d2f81f02561b93a0e9ccde4')
})
.run(function($rootScope, $state, Restangular, user) {
// 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 = {
$scope.commandDirectives.push(obj)
})
})
+
$scope.$on('requestParams', function(event, i) {
$scope.$broadcast('sendParams'+i, $scope.commands[i])
})
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;
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