From 092ae07b84ed8c64e44a962f6e6e5bfa2b856346 Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Sat, 18 Oct 2014 21:09:49 -0700 Subject: [PATCH 01/40] Fixed invert styling --- OpenNote/openNote/openNote.js | 10 ++++++---- OpenNote/openNote/style/invert/style.less | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenNote/openNote/openNote.js b/OpenNote/openNote/openNote.js index 7694e3f..17037c0 100644 --- a/OpenNote/openNote/openNote.js +++ b/OpenNote/openNote/openNote.js @@ -20,6 +20,9 @@ openNote.run(function ( $rootScope, config, serverConfigService, $http){ + + $rootScope.helpContent=config.getHelpContent(); + $rootScope.$on("$routeChangeStart", function (event) { //server config values serverConfigService.getConfig().then(function(config){ @@ -72,8 +75,6 @@ openNote.run(function ( $rootScope, $rootScope.showSideBar=true; //options for humans - $rootScope.helpContent=config.getHelpContent(); - $rootScope.showHelpButton = config.showHelpButton(); $rootScope.showLogOutButton = config.showLogOutButton(); @@ -89,8 +90,9 @@ openNote.run(function ( $rootScope, function(response){//Successful if(response.data.version!=config.getVersion()) alertify.log(""+response.data.updateText+"", "", 0); - }); - }); + } + ); + }); /** * Handle logOut event diff --git a/OpenNote/openNote/style/invert/style.less b/OpenNote/openNote/style/invert/style.less index 665016a..26a5074 100644 --- a/OpenNote/openNote/style/invert/style.less +++ b/OpenNote/openNote/style/invert/style.less @@ -406,4 +406,7 @@ img { color: @copyRightColor; } + .loginPartial form input{ + width: 250px; + } \ No newline at end of file From c8916ea54a6f77fa2285428c573dc7c88e7d4bed Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Sun, 19 Oct 2014 08:55:24 -0700 Subject: [PATCH 02/40] Fixed firefox issue --- OpenNote/openNote/services/userService.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenNote/openNote/services/userService.js b/OpenNote/openNote/services/userService.js index 0188cc4..51eaf0d 100644 --- a/OpenNote/openNote/services/userService.js +++ b/OpenNote/openNote/services/userService.js @@ -36,8 +36,8 @@ openNote.service("userService", function ($http, $q, config) { this.hasValidToken = function(){ var tokenObject = this.getAPITokenObject(); if(tokenObject!=null){ - var tokenTime = tokenObject.expires.replace(" ","T");//convert to ISO-8601 date and time - return new Date().getTime()< Date.parse(tokenTime);//UTC time + var tokenTime = tokenObject.expires.replace(" ","T")+"Z";//convert to ISO-8601 date and time in UTC + return new Date().getTime()< new Date(tokenTime);//UTC time } return false; From ba4e272bba76caab1671128f345a111eeb460cc4 Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Sun, 19 Oct 2014 18:52:52 -0700 Subject: [PATCH 03/40] Fav Icon --- OpenNote/index.html | 6 ++++-- OpenNote/openNote/style/OpenNote.png | Bin 0 -> 35078 bytes 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 OpenNote/openNote/style/OpenNote.png diff --git a/OpenNote/index.html b/OpenNote/index.html index 1b66faa..b220c16 100644 --- a/OpenNote/index.html +++ b/OpenNote/index.html @@ -5,8 +5,10 @@ - - + + + + OpenNote + + + + + + + + image/svg+xml + + + + + + + + O + From 8583740351684828dd4f4a438f3919332e2fa676 Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Mon, 1 Dec 2014 20:12:00 -0700 Subject: [PATCH 06/40] Updated build --- Doc/Build.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Doc/Build.md b/Doc/Build.md index 4dfefcc..f65f012 100644 --- a/Doc/Build.md +++ b/Doc/Build.md @@ -5,9 +5,23 @@ You will need to clone the front end and the backend https://github.com/FoxUSA/OpenNote https://github.com/FoxUSA/OpenNoteService-PHP -Most of the buid tasks require the OpenNote and OpenNoteService-PHP to be in the same folder +Most of the buid tasks require the OpenNote and OpenNoteService-PHP to be in the same folder + +For example +In the folder `OpenNote` we expect `openNote`, and `Service` to be sister folder. + +I normally have `Service` folder as a symbolic link to `OpenNoteService-PHP/Service`; + +Once the `OpenNote` and `OpenNoteService-PHP` project have been cloned you need to build the projects +To do so for the front end project +- Run `npm install` to install all the needed development dependencies. +- Then, you need to run `grunt build` in `OpenNote/`(This runs bower install and builds the less css) + +In the PHP service you will need too +- You need to run `php ./composer.phar install -v` to install all the php dependencies and build the projects autoloading structure ## Build Requirments +- npm - Bower - Grunt - Composer From e03aa09c8649dcf45d5c87d836033707bcf1ebca Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Mon, 1 Dec 2014 21:03:07 -0700 Subject: [PATCH 07/40] Added better build instructions --- Doc/Build.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/Build.md b/Doc/Build.md index f65f012..afe9b46 100644 --- a/Doc/Build.md +++ b/Doc/Build.md @@ -14,16 +14,16 @@ I normally have `Service` folder as a symbolic link to `OpenNoteService-PHP/Serv Once the `OpenNote` and `OpenNoteService-PHP` project have been cloned you need to build the projects To do so for the front end project -- Run `npm install` to install all the needed development dependencies. -- Then, you need to run `grunt build` in `OpenNote/`(This runs bower install and builds the less css) +- Run `npm install` to get the dev dependencies +- Then, you need to run `grunt build` in `OpenNote/`(This runs bower install and builds the less CSS) In the PHP service you will need too -- You need to run `php ./composer.phar install -v` to install all the php dependencies and build the projects autoloading structure +- You need to run `php ./composer.phar install -v` to install all the PHP dependencies and build the projects autoloading structure -## Build Requirments +## Build Requirements - npm -- Bower -- Grunt +- Bower `npm install -g bower` +- Grunt `npm install -g grunt-cli` - Composer ## Build From ae729b51c39410beebf3ebc25d509172fe22f7ad Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Mon, 1 Dec 2014 21:07:33 -0700 Subject: [PATCH 08/40] typo --- Doc/Build.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/Build.md b/Doc/Build.md index afe9b46..77b193a 100644 --- a/Doc/Build.md +++ b/Doc/Build.md @@ -8,11 +8,12 @@ https://github.com/FoxUSA/OpenNoteService-PHP Most of the buid tasks require the OpenNote and OpenNoteService-PHP to be in the same folder For example -In the folder `OpenNote` we expect `openNote`, and `Service` to be sister folder. +In the folder `OpenNote` we expect `openNote`, and `Service` to be sister folders. I normally have `Service` folder as a symbolic link to `OpenNoteService-PHP/Service`; Once the `OpenNote` and `OpenNoteService-PHP` project have been cloned you need to build the projects + To do so for the front end project - Run `npm install` to get the dev dependencies - Then, you need to run `grunt build` in `OpenNote/`(This runs bower install and builds the less CSS) From da80f87e0e1b84456584b19ba515ce24080181ac Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Mon, 1 Dec 2014 21:15:35 -0700 Subject: [PATCH 09/40] https://github.com/FoxUSA/OpenNote/issues/108 fixes --- OpenNote/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenNote/index.html b/OpenNote/index.html index b220c16..ced1481 100644 --- a/OpenNote/index.html +++ b/OpenNote/index.html @@ -5,7 +5,7 @@ - + From feb516e26ced9f80e0e66245f3484435b407534b Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Mon, 1 Dec 2014 21:15:35 -0700 Subject: [PATCH 10/40] https://github.com/FoxUSA/OpenNote/issues/108 fixes --- OpenNote/index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenNote/index.html b/OpenNote/index.html index b220c16..2c67a89 100644 --- a/OpenNote/index.html +++ b/OpenNote/index.html @@ -4,8 +4,7 @@ - - + From 086ef34b0a8ec55838807dfad5a4f4563c24549a Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Sat, 13 Dec 2014 20:24:03 -0700 Subject: [PATCH 11/40] Fixes https://github.com/FoxUSA/OpenNote/issues/103 --- OpenNote/openNote/style/invert/style.less | 2 +- OpenNote/openNote/style/simplicity/style.less | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenNote/openNote/style/invert/style.less b/OpenNote/openNote/style/invert/style.less index 26a5074..a53efb4 100644 --- a/OpenNote/openNote/style/invert/style.less +++ b/OpenNote/openNote/style/invert/style.less @@ -211,7 +211,7 @@ img { background: lighten(@folderColor, 10%); } - .search, .search:hover{ + .search, .search:hover, .search option{ background-color: negation(@folderColor, #FFFFFF); } diff --git a/OpenNote/openNote/style/simplicity/style.less b/OpenNote/openNote/style/simplicity/style.less index 831ae68..9df3997 100644 --- a/OpenNote/openNote/style/simplicity/style.less +++ b/OpenNote/openNote/style/simplicity/style.less @@ -220,6 +220,10 @@ img { border-color: negation(@folderColor, #FFFFFF); } + .search option{ + background-color: @pageBackground; + } + .searchPartial{ margin-bottom: 30px; } From a5f42dea10d93666787fe276d2fdf4246fe00d91 Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Mon, 29 Dec 2014 18:48:02 -0700 Subject: [PATCH 12/40] Fixed spell check --- OpenNote/openNote/openNote.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenNote/openNote/openNote.config.js b/OpenNote/openNote/openNote.config.js index 91185f1..9f0c730 100644 --- a/OpenNote/openNote/openNote.config.js +++ b/OpenNote/openNote/openNote.config.js @@ -25,14 +25,14 @@ openNote.value("config", { }, /** - * Used to compute randome short fade speed + * Used to compute random short fade speed */ fadeSpeedShort: function(){ return 250*Math.random()+200; }, /** - * Used to compute randome long fade speed + * Used to compute random long fade speed */ fadeSpeedLong: function(){ return 2000*Math.random()+200; From 8f504f6118800a745211d390d7634505e3e015f2 Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Fri, 6 Mar 2015 21:56:36 -0700 Subject: [PATCH 13/40] Up a folder --- .../openNote/controllers/folderController.js | 12 +++++++++++ .../openNote/controllers/noteController.js | 21 ++++++++++++++++--- OpenNote/openNote/partials/folderPartial.html | 5 +++-- README.md | 1 + 4 files changed, 34 insertions(+), 5 deletions(-) diff --git a/OpenNote/openNote/controllers/folderController.js b/OpenNote/openNote/controllers/folderController.js index a0f8ad1..5716790 100644 --- a/OpenNote/openNote/controllers/folderController.js +++ b/OpenNote/openNote/controllers/folderController.js @@ -113,6 +113,18 @@ openNote.controller("folderController", function( $scope, }); }; + /** + * Load parent folder + */ + $scope.loadParentFolder = function(){ + $scope.fadeOutFoldersAndNotes(function(){ + if($scope.currentFolder.parrentFolderID!=null) + $location.url("/folder/"+$scope.currentFolder.parrentFolderID); + else + $location.url("/folder/"); + }); + }; + /** * Load a note * @param note - load a note diff --git a/OpenNote/openNote/controllers/noteController.js b/OpenNote/openNote/controllers/noteController.js index 64557d1..6c43684 100644 --- a/OpenNote/openNote/controllers/noteController.js +++ b/OpenNote/openNote/controllers/noteController.js @@ -4,10 +4,17 @@ */ /** - * controller for note creation, editing and maintance + * controller for note creation, editing and maintenance */ -openNote.controller("noteController", function( $scope, $rootScope, $routeParams, $location, $routeParams, - noteFactory, config, serverConfigService, $sce) { +openNote.controller("noteController", function( $scope, + $rootScope, + $routeParams, + $location, + $routeParams, + noteFactory, + config, + serverConfigService, + $sce) { $rootScope.buttons=[]; $scope.note = new noteFactory(); $scope.editMode = false; @@ -78,6 +85,14 @@ openNote.controller("noteController", function( $scope, $rootScope, $routeParams }); //Add buttons + $rootScope.buttons.push({ + text: "Go up a folder", + action: function(){ + $location.url("/folder/"+$scope.note.folderID); + }, + helpText: $rootScope.helpContent.editButton + }); + $rootScope.buttons.push({ text: "Edit", action: function(){ diff --git a/OpenNote/openNote/partials/folderPartial.html b/OpenNote/openNote/partials/folderPartial.html index 0600c52..26796cf 100644 --- a/OpenNote/openNote/partials/folderPartial.html +++ b/OpenNote/openNote/partials/folderPartial.html @@ -2,8 +2,9 @@
{{currentFolder.name}}
- - + + +
diff --git a/README.md b/README.md index 2041935..a4f5f6d 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ http://stardrive.us/OpenNote/ ![][topLevel] Features -------- +- BYOS(Bring Your Own Server) - Full WYSIWYG editor - Touch friendly and mouse friendly ui - Upload manager (not enabled in demo :) ) From 7a7e0863fed415d5674214d93d1ad97bcfcbbf5e Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Tue, 14 Apr 2015 20:50:11 -0700 Subject: [PATCH 14/40] PouchDB --- OpenNote/bower.json | 3 +- OpenNote/index.html | 6 +- .../openNote/controllers/folderController.js | 164 +++++++++++++----- .../openNote/controllers/listController.js | 6 +- .../openNote/controllers/noteController.js | 69 +++++--- OpenNote/openNote/factories/folderFactory.js | 21 --- OpenNote/openNote/factories/noteFactory.js | 16 -- OpenNote/openNote/openNote.js | 32 +--- OpenNote/openNote/partials/folderPartial.html | 8 +- OpenNote/openNote/partials/loginPartial.html | 46 ----- OpenNote/openNote/router.js | 7 +- .../openNote/services/serverConfigService.js | 2 +- 12 files changed, 181 insertions(+), 199 deletions(-) delete mode 100644 OpenNote/openNote/factories/folderFactory.js delete mode 100644 OpenNote/openNote/factories/noteFactory.js delete mode 100644 OpenNote/openNote/partials/loginPartial.html diff --git a/OpenNote/bower.json b/OpenNote/bower.json index 149688a..6ff6659 100644 --- a/OpenNote/bower.json +++ b/OpenNote/bower.json @@ -17,6 +17,7 @@ "ckeditor": "ckeditor/ckeditor-releases#full/4.4.x", "angular-ui-tree": "2.1.2", "alertify": "0.3.10", - "intro.js": "0.8.0" + "intro.js": "0.8.0", + "pouchdb": "3.4.0" } } diff --git a/OpenNote/index.html b/OpenNote/index.html index ced1481..3adacb5 100644 --- a/OpenNote/index.html +++ b/OpenNote/index.html @@ -29,6 +29,7 @@ + @@ -52,14 +53,11 @@ + - - - - diff --git a/OpenNote/openNote/controllers/folderController.js b/OpenNote/openNote/controllers/folderController.js index 5716790..1f212dd 100644 --- a/OpenNote/openNote/controllers/folderController.js +++ b/OpenNote/openNote/controllers/folderController.js @@ -3,12 +3,12 @@ openNote.controller("folderController", function( $scope, $rootScope, $location, $routeParams, - folderFactory, + storageService, config, $timeout) { $rootScope.buttons = []; $scope.folderEditMode = false; - $scope.currentFolder = new folderFactory(); + $scope.currentFolder = {}; //add buttons if($routeParams.id!=null) @@ -16,38 +16,38 @@ openNote.controller("folderController", function( $scope, text: "New note", action: function(){ $scope.fadeOutFoldersAndNotes(function(){ - $location.url("/note/").search("folderID",$scope.currentFolder.id); + $location.url("/note/").search("folderID",$scope.currentFolder._id); }); }, helpText: $rootScope.helpContent.newNoteButton }); - $rootScope.buttons.push({ - text: "New folder", - action: function(){ - var prompt = "Please enter a name for the new folder"; - - if($scope.currentFolder.name!=null) - prompt += "that will be created in "+$scope.currentFolder.name; - - alertify.prompt( - prompt, - function(confirm,data){ - if(!confirm) - return; - - var folder = new folderFactory(); - folder.name=data; - folder.parrentFolderID=$scope.currentFolder.id; - folder.$save({levels: null}).then(function(data){ - $rootScope.$emit("reloadListView", {}); - $location.url("/folder/"+folder.id); - }); - }, - ""); - }, - helpText: $rootScope.helpContent.newFolderButton - }); + //Create a folder + $rootScope.buttons.push({ + text: "New folder", + action: function(){ + var prompt = "Please enter a name for the new folder"; + + if($scope.currentFolder.name!=null) + prompt += "that will be created in "+$scope.currentFolder.name; + + alertify.prompt( + prompt, + function(confirm,data){ + if(!confirm) + return; + + var folder = { + parentFolderID:$scope.currentFolder._id, + name:data + }; + + createFolder(folder); + }, + ""); + }, + helpText: $rootScope.helpContent.newFolderButton + }); $rootScope.buttons.push({ text: "Search", @@ -58,23 +58,29 @@ openNote.controller("folderController", function( $scope, }); /** - * Load folder contents + * Load current folder contents */ $timeout(function(){ - $scope.currentFolder.$get({id:$routeParams.id}).then(function(data){ - //Do they have anything to display? - if($scope.currentFolder.id==null && $scope.currentFolder.foldersInside.length==0){ - $scope.currentFolder.name=null;//resets title - alertify.alert("It looks like you dont have any folders. You can create one using the \"New Folder\" button in the top right of the page."); - } - }); + //Load the folder + if($routeParams.id==null){ + $scope.currentFolder={ + _id:null, + name:"Home"}; + loadCurrentFolderContents(); + } + else{ + storageService.database().get($routeParams.id).then(function(doc){ + $scope.currentFolder=doc; + loadCurrentFolderContents(); + }); + } }); /** * Activate folder edit mode if we are not in the home folder */ $scope.activateFolderEditMode = function(){ - if($scope.currentFolder.id != null) + if($scope.currentFolder._id != null) $scope.folderEditMode = !$scope.folderEditMode; }; @@ -109,17 +115,17 @@ openNote.controller("folderController", function( $scope, */ $scope.loadFolder = function(folder){ $scope.fadeOutFoldersAndNotes(function(){ - $location.url("/folder/"+folder.id); + $location.url("/folder/"+folder.doc._id); }); }; /** * Load parent folder */ - $scope.loadParentFolder = function(){ + $scope.loadParentFolder = function(){//FIXME $scope.fadeOutFoldersAndNotes(function(){ - if($scope.currentFolder.parrentFolderID!=null) - $location.url("/folder/"+$scope.currentFolder.parrentFolderID); + if($scope.currentFolder.parentFolderID!=null) + $location.url("/folder/"+$scope.currentFolder.parentFolderID); else $location.url("/folder/"); }); @@ -145,9 +151,12 @@ openNote.controller("folderController", function( $scope, return; $scope.currentFolder.name=data; - $scope.currentFolder.$update({levels: null}).then(function(data){ - $scope.currentFolder.$get({id: $scope.currentFolder.id}); + storageService.database().put($scope.currentFolder).then(function(result){ $rootScope.$emit("reloadListView", {}); + $scope.$apply(); + }).catch(function(error){ + console.log(error); + //FIXME }); }, $scope.currentFolder.name//show the current folder name @@ -157,20 +166,25 @@ openNote.controller("folderController", function( $scope, /** * Remove this folder and all sub items */ - $scope.removeFolder = function(){ + $scope.removeFolder = function(){//FIXME Clear orphans alertify.confirm("Are you sure you want to delete "+$scope.currentFolder.name+" and all subfolders and notes it contains?", function(confirm) { if(!confirm) return; var parrentFolderID = $scope.currentFolder.parrentFolderID; - $scope.currentFolder.$remove({id: $scope.currentFolder.id}).then(function(data){ + storageService.database().remove($scope.currentFolder).then(function(result){ $rootScope.$emit("reloadListView", {}); if(parrentFolderID==null) $location.url("/folder/"); else $location.url("/folder/"+parrentFolderID); + + $scope.$apply(); + }).catch(function(error){ + console.log(error); + //FIXME }); }); } @@ -183,4 +197,62 @@ openNote.controller("folderController", function( $scope, $scope.currentFolder.$get({id:$scope.currentFolder.id});//reload } }); + + /** + * Create a folder object + */ + var createFolder = function(folder){ + folder.type="folder"; + storageService.database().post(folder).then(function(response){ + if(!response.ok) + throw "//FIXME"; + $rootScope.$emit("reloadListView", {}); + $location.url("/folder/"+response.id); + $scope.$apply(); + + }).catch(function(error){ + console.log(error);//FIXME + }); + } + + /** + * Load the current folders contents + */ + var loadCurrentFolderContents = function(){ + storageService.database().query(function (doc, emit) { + emit(doc.parentFolderID); + }, {key: $scope.currentFolder._id, include_docs: true}).then(function (results) { + $scope.currentFolderContents=results.rows; + + //Do they have anything to display? + if($scope.currentFolder._id==null && $scope.currentFolderContents.length==0){ + alertify.alert("It looks like you dont have any folders. You can create one using the \"New Folder\" button in the top right of the page."); + }; + + $scope.$apply(); + }).catch(function (err) { + console.log(err); + }); + } + + /** + * Filter out everything but a given type + */ + var typeFilter = function(object,type){ + return object.doc.type==type; + } + + /** + * Filter out everything but type folder + */ + $scope.folderFilter=function(object){ + return typeFilter(object,"folder"); + }; + + /** + * Filter out everything but type note + */ + $scope.noteFilter=function(object){ + return typeFilter(object,"note"); + } }); \ No newline at end of file diff --git a/OpenNote/openNote/controllers/listController.js b/OpenNote/openNote/controllers/listController.js index 1d00177..bc89a8d 100644 --- a/OpenNote/openNote/controllers/listController.js +++ b/OpenNote/openNote/controllers/listController.js @@ -8,10 +8,10 @@ */ openNote.controller("listController", function( $scope, $rootScope, - folderFactory, $timeout, + storageService, userService) { - $scope.data = new folderFactory(); + $scope.data = {}; /** * Toggle collapse @@ -46,7 +46,7 @@ openNote.controller("listController", function( $scope, /** * Load list view */ - $rootScope.$on("reloadListView", function(event, args) { + $rootScope.$on("reloadListView//FIXME", function(event, args) {//FIXME $scope.data.$get({levels:100, includeNotes: false}).then(function(result){ $scope.treeBuffer = 0; $scope.data=result; diff --git a/OpenNote/openNote/controllers/noteController.js b/OpenNote/openNote/controllers/noteController.js index 6c43684..4d51f97 100644 --- a/OpenNote/openNote/controllers/noteController.js +++ b/OpenNote/openNote/controllers/noteController.js @@ -11,12 +11,12 @@ openNote.controller("noteController", function( $scope, $routeParams, $location, $routeParams, - noteFactory, + storageService, config, serverConfigService, $sce) { $rootScope.buttons=[]; - $scope.note = new noteFactory(); + $scope.note = {}; $scope.editMode = false; $scope.showDeleteButton = false; @@ -53,7 +53,7 @@ openNote.controller("noteController", function( $scope, serverConfigService.getEditorConfig().then(function(config){ $scope.editMode=true; - if($scope.note.id !=null) + if($scope.note._id !=null) $scope.showDeleteButton = true; CKEDITOR.replace("note", config); @@ -69,8 +69,8 @@ openNote.controller("noteController", function( $scope, //Load or new if($routeParams.id==null){//new - $scope.note.id = null; - $scope.note.folderID = $location.search().folderID; + $scope.note._id = null; + $scope.note.parentFolderID = $location.search().folderID; $scope.note.title = "Note Title"; activateEditMode(); @@ -78,11 +78,13 @@ openNote.controller("noteController", function( $scope, } else{ /** - * Load folder contents + * Load note */ - $scope.note.$get({id:$routeParams.id}).then(function(note){ + storageService.database().get($routeParams.id).then(function(doc){ + $scope.note=doc; $(".notePartial").fadeIn(config.fadeSpeedLong()); - }); + $scope.$apply(); + }); //Add buttons $rootScope.buttons.push({ @@ -108,16 +110,8 @@ openNote.controller("noteController", function( $scope, $scope.save = function(){ $scope.note.note = CKEDITOR.instances["note"].getData(); - //Insert only logic - if($scope.note.originNoteID == null) - $scope.note.originNoteID=$scope.note.id;//Make this not a child of the one we opened - $(".notePartial").fadeOut(config.fadeSpeedShort()); - $scope.note.$save().then(function(){ - detachWindowUnload(); - $location.url("/note/"+$scope.note.id) - alertify.success("Note Saved"); //all done. close the notify dialog - }); + createNote($scope.note); } @@ -130,12 +124,13 @@ openNote.controller("noteController", function( $scope, if(!confirm) return; - var folderID = $scope.note.folderID;//need to keep track of this because we are about to delete it + var folderID = $scope.note.parentFolderID;//need to keep track of this because we are about to delete it $(".notePartial").fadeOut(config.fadeSpeedShort()); - $scope.note.$remove({id: $scope.note.id}).then(function(){ + storageService.database().remove($scope.note).then(function(){ detachWindowUnload(); alertify.success("Note Deleted",5); //all done. close the notify dialog $location.url("/folder/"+folderID); + $scope.$apply(); }); } ); @@ -164,7 +159,7 @@ openNote.controller("noteController", function( $scope, */ $scope.trustHTML = function(html) { return $sce.trustAsHtml(html); - } + }; /** * Attach window on-load listener @@ -173,12 +168,42 @@ openNote.controller("noteController", function( $scope, window.onbeforeunload = function() { return "Are you sure you want to navigate away?";//Keep the page from closing }; - } + }; /** * Remove window on-load listener */ var detachWindowUnload = function(){ window.onbeforeunload = null; - } + }; + + /** + * Create a note object + */ + var createNote = function(note){ + note.type="note"; + + /** + * Callback after successful save to reload note + */ + var saveCallback = function(response){ + if(!response.ok) + throw "//FIXME"; + $rootScope.$emit("reloadListView", {}); + detachWindowUnload(); + $location.url("/note/"+response.id+"?reload"); + alertify.success("Note Saved"); //all done. close the notify dialog + $scope.$apply(); + } + + //Upsert + if(note._id==null) + storageService.database().post(note).then(saveCallback).catch(function(error){ + console.log(error);//FIXME + }); + else + storageService.database().put(note).then(saveCallback).catch(function(error){ + console.log(error);//FIXME + }); + }; }); \ No newline at end of file diff --git a/OpenNote/openNote/factories/folderFactory.js b/OpenNote/openNote/factories/folderFactory.js deleted file mode 100644 index 21350e6..0000000 --- a/OpenNote/openNote/factories/folderFactory.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - *Folder factory - */ -openNote.factory("folderFactory", function($resource, userService, config) { - return $resource(config.servicePath()+"/folder/:id", {}, {//{} default params - get: { - method: "GET", - params:{levels: 1, includeNotes: true, includeNotesHTML: false},//override default params - url: config.servicePath()+"/folder/"//override - }, - save: { - method: "POST" - }, - update: { - method: "PUT" - }, - remove: { - method: "DELETE" - } - }); - }); \ No newline at end of file diff --git a/OpenNote/openNote/factories/noteFactory.js b/OpenNote/openNote/factories/noteFactory.js deleted file mode 100644 index e2afea2..0000000 --- a/OpenNote/openNote/factories/noteFactory.js +++ /dev/null @@ -1,16 +0,0 @@ -/** - *Note factory - */ -openNote.factory("noteFactory", function($resource, userService, config) { - return $resource(config.servicePath()+"/note/:id", { }, { - get: { - method: "GET" - }, - save: { - method: "POST" - }, - remove: { - method: "DELETE" - } - }); - }); \ No newline at end of file diff --git a/OpenNote/openNote/openNote.js b/OpenNote/openNote/openNote.js index a16877d..a36133a 100644 --- a/OpenNote/openNote/openNote.js +++ b/OpenNote/openNote/openNote.js @@ -32,38 +32,12 @@ openNote.run(function ( $rootScope, $rootScope.serverConfig=config; }); //attach server config to root scope - //Authentication and authorization enforcer - if (isLoggedInOrIsOnLoginScreen())//Initial entry if not logged in - forceLogin(event, $location.url()); - else//Initial entry after if logged in - if($location.path()!="/" && !$rootScope.showMenu && !$rootScope.showSideBar)//make sure we only fade in/run once - $rootScope.$emit("init"); + //Initial entry after if logged in + if(!$rootScope.showMenu && !$rootScope.showSideBar)//make sure we only fade in/run once + $rootScope.$emit("init"); }); - /** - * Check to see if user is logged in or on the login screen - */ - var isLoggedInOrIsOnLoginScreen = function(){ - return !userService.hasValidToken()&&$location.path()!="/"; - } - - /** - * Force user to login - * @param event - the event this was called - * @param url - the url the user tried to get - */ - var forceLogin = function(event, url){ - if(event!=null) - event.preventDefault(); - - if(url!=null && url.trim()!="" && url.trim()!="/"&& url.trim()!="#/") - $rootScope.entryURL=url; - else - $rootScope.entryURL=null; - - $location.path("/"); - } /** * Initialize app and start fade in diff --git a/OpenNote/openNote/partials/folderPartial.html b/OpenNote/openNote/partials/folderPartial.html index 26796cf..19878fd 100644 --- a/OpenNote/openNote/partials/folderPartial.html +++ b/OpenNote/openNote/partials/folderPartial.html @@ -8,9 +8,9 @@ -
+

- {{folder.name}} + {{folder.doc.name}}

@@ -18,9 +18,9 @@

-
+

- {{note.title}} + {{note.doc.title}}

diff --git a/OpenNote/openNote/partials/loginPartial.html b/OpenNote/openNote/partials/loginPartial.html deleted file mode 100644 index 0c79a1d..0000000 --- a/OpenNote/openNote/partials/loginPartial.html +++ /dev/null @@ -1,46 +0,0 @@ -

-

OpenNote

-
-
Login
-
Register
-
-
-
-
-

- - -

- -

- - -

- -

- -

-
-
- -
-
-

- - {{isAvailable}} -

- -

- - -

- -

- -

-
-
-
- -
- \ No newline at end of file diff --git a/OpenNote/openNote/router.js b/OpenNote/openNote/router.js index f7d76f3..8af23f5 100644 --- a/OpenNote/openNote/router.js +++ b/OpenNote/openNote/router.js @@ -1,11 +1,6 @@ //Router openNote.config(function($routeProvider){ $routeProvider - .when("/", - { - controller: "loginController", - templateUrl: "openNote/partials/loginPartial.html" - }) .when("/folder/:id?", { controller: "folderController", @@ -21,5 +16,5 @@ openNote.config(function($routeProvider){ controller: "searchController", templateUrl: "openNote/partials/searchPartial.html" }) - .otherwise({ redirectTo: "/" }); + .otherwise({ redirectTo: "/folder" }); }); \ No newline at end of file diff --git a/OpenNote/openNote/services/serverConfigService.js b/OpenNote/openNote/services/serverConfigService.js index 94a9b77..1ad0451 100644 --- a/OpenNote/openNote/services/serverConfigService.js +++ b/OpenNote/openNote/services/serverConfigService.js @@ -72,7 +72,7 @@ openNote.service("serverConfigService", function ($http, $q, config, userService //configure the upload path if uploads are enabled if(data.uploadEnabled){ - temp.filebrowserUploadUrl = config.servicePath()+"/file/"+"?token="+userService.getAPITokenObject().token; + //temp.filebrowserUploadUrl = config.servicePath()+"/file/"+"?token="+userService.getAPITokenObject().token;//FIXME temp.filebrowserImageUploadUrl = temp.filebrowserUploadUrl; }; return temp; From f540a788ebec95157e8ad149351f591dd058290a Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Tue, 14 Apr 2015 22:03:08 -0700 Subject: [PATCH 15/40] Breadcrumbs https://github.com/FoxUSA/OpenNote/issues/55 --- .../openNote/controllers/folderController.js | 21 ++++++++---------- OpenNote/openNote/partials/folderPartial.html | 18 ++++++++++----- OpenNote/openNote/services/storageService.js | 22 +++++++++++++++++++ OpenNote/openNote/style/invert/style.less | 14 ++++++++++++ OpenNote/openNote/style/simplicity/style.less | 16 +++++++++++++- 5 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 OpenNote/openNote/services/storageService.js diff --git a/OpenNote/openNote/controllers/folderController.js b/OpenNote/openNote/controllers/folderController.js index 1f212dd..c97852e 100644 --- a/OpenNote/openNote/controllers/folderController.js +++ b/OpenNote/openNote/controllers/folderController.js @@ -9,6 +9,7 @@ openNote.controller("folderController", function( $scope, $rootScope.buttons = []; $scope.folderEditMode = false; $scope.currentFolder = {}; + $scope.parentFolder = null //add buttons if($routeParams.id!=null) @@ -72,6 +73,14 @@ openNote.controller("folderController", function( $scope, storageService.database().get($routeParams.id).then(function(doc){ $scope.currentFolder=doc; loadCurrentFolderContents(); + + if($scope.currentFolder.parentFolderID==null) + $scope.parentFolder={name:"Home"}; + else + storageService.database().get($scope.currentFolder.parentFolderID).then(function(doc){ + $scope.parentFolder=doc; + $scope.$apply(); + }); }); } }); @@ -119,18 +128,6 @@ openNote.controller("folderController", function( $scope, }); }; - /** - * Load parent folder - */ - $scope.loadParentFolder = function(){//FIXME - $scope.fadeOutFoldersAndNotes(function(){ - if($scope.currentFolder.parentFolderID!=null) - $location.url("/folder/"+$scope.currentFolder.parentFolderID); - else - $location.url("/folder/"); - }); - }; - /** * Load a note * @param note - load a note diff --git a/OpenNote/openNote/partials/folderPartial.html b/OpenNote/openNote/partials/folderPartial.html index 19878fd..8c7396b 100644 --- a/OpenNote/openNote/partials/folderPartial.html +++ b/OpenNote/openNote/partials/folderPartial.html @@ -1,11 +1,19 @@
-
{{currentFolder.name}}
+
- - - -
+ + + +
+
diff --git a/OpenNote/openNote/services/storageService.js b/OpenNote/openNote/services/storageService.js new file mode 100644 index 0000000..d2423c2 --- /dev/null +++ b/OpenNote/openNote/services/storageService.js @@ -0,0 +1,22 @@ +/** + * @author - Jake Liscom + * @project - OpenNote + */ + +/** + * Storage service + */ +openNote.service("storageService", function () { + + var localDatabase = new PouchDB("openNote"); + + /** + * Get a document from the database + */ + this.database = function(){ + return localDatabase; + }; + + + +}); \ No newline at end of file diff --git a/OpenNote/openNote/style/invert/style.less b/OpenNote/openNote/style/invert/style.less index a53efb4..0727646 100644 --- a/OpenNote/openNote/style/invert/style.less +++ b/OpenNote/openNote/style/invert/style.less @@ -98,6 +98,20 @@ input:focus, select:focus, textarea:focus, button:focus { padding: 15px 0px; overflow: hidden; font-size: 18px; + + .breadcrumb{ + margin-bottom:0; + padding: 0 15px 0 0; + background: none; + + >.active{ + color:inherit; + } + + li{ + font-size: 20px; + } + } } #folderTitle{ diff --git a/OpenNote/openNote/style/simplicity/style.less b/OpenNote/openNote/style/simplicity/style.less index 9df3997..3c0a925 100644 --- a/OpenNote/openNote/style/simplicity/style.less +++ b/OpenNote/openNote/style/simplicity/style.less @@ -97,13 +97,27 @@ input:focus, select:focus, textarea:focus, button:focus { padding: 15px 0px; overflow: hidden; font-size: 18px; + + .breadcrumb{ + margin-bottom:0; + padding: 0 15px 0 0; + background: none; + + >.active{ + color:inherit; + } + + li{ + font-size: 20px; + } + } } #folderTitle{ float:left; padding-right:15px; font-size: 20px; - } + } .customButton{ /*custom button class that removes all browser formating*/ border: none; From e937ecfda3afc4a98d03011179f508d47200f19e Mon Sep 17 00:00:00 2001 From: FoxUSA Date: Thu, 16 Apr 2015 20:49:07 -0700 Subject: [PATCH 16/40] List view converted. Folder controller. --- .../openNote/controllers/folderController.js | 6 +- .../openNote/controllers/listController.js | 73 +++++++++++++------ OpenNote/openNote/openNote.js | 1 - OpenNote/openNote/partials/listPartial.html | 10 ++- OpenNote/openNote/partials/treePartial.html | 2 +- OpenNote/openNote/services/storageService.js | 22 ++++++ 6 files changed, 81 insertions(+), 33 deletions(-) diff --git a/OpenNote/openNote/controllers/folderController.js b/OpenNote/openNote/controllers/folderController.js index c97852e..6910d33 100644 --- a/OpenNote/openNote/controllers/folderController.js +++ b/OpenNote/openNote/controllers/folderController.js @@ -216,9 +216,7 @@ openNote.controller("folderController", function( $scope, * Load the current folders contents */ var loadCurrentFolderContents = function(){ - storageService.database().query(function (doc, emit) { - emit(doc.parentFolderID); - }, {key: $scope.currentFolder._id, include_docs: true}).then(function (results) { + storageService.database().query("folder/parentFolderID", {key: $scope.currentFolder._id, include_docs: true}).then(function (results) { $scope.currentFolderContents=results.rows; //Do they have anything to display? @@ -228,7 +226,7 @@ openNote.controller("folderController", function( $scope, $scope.$apply(); }).catch(function (err) { - console.log(err); + console.log(err);//FIXME }); } diff --git a/OpenNote/openNote/controllers/listController.js b/OpenNote/openNote/controllers/listController.js index bc89a8d..e1cce7b 100644 --- a/OpenNote/openNote/controllers/listController.js +++ b/OpenNote/openNote/controllers/listController.js @@ -10,7 +10,9 @@ openNote.controller("listController", function( $scope, $rootScope, $timeout, storageService, - userService) { + userService, + $timeout, + config) { $scope.data = {}; /** @@ -46,14 +48,40 @@ openNote.controller("listController", function( $scope, /** * Load list view */ - $rootScope.$on("reloadListView//FIXME", function(event, args) {//FIXME - $scope.data.$get({levels:100, includeNotes: false}).then(function(result){ - $scope.treeBuffer = 0; - $scope.data=result; - increaseTreeBuffer(); - }); + $rootScope.$on("reloadListView", function(event, args) {//FIXME + storageService.database().query("folder/parentFolderID", {key: null, include_docs: true}).then(function (results) { + $scope.data=results.rows.filter(folderFilter); + $scope.data.forEach(loadFolderContents); + + $scope.treeBuffer = 0; + $timeout(increaseTreeBuffer,config.fadeSpeedLong()); + $scope.$apply(); + }).catch(function (err) { + console.log(err); + }); }); + /** + * @param item - the item the filter + */ + var folderFilter = function(item){ + return item.doc.type=="folder"; + } + + /** + * Load the current folders contents + * @param folder - the folder to pull the content from + */ + var loadFolderContents = function(folder){ + storageService.database().query("folder/parentFolderID", {key: folder.doc._id, include_docs: true}).then(function (results) { + folder.foldersInside=results.rows.filter(folderFilter); + folder.foldersInside.forEach(loadFolderContents); + $scope.$apply(); + }).catch(function (err) { + console.log(err); + }); + } + /** * List Config object */ @@ -71,27 +99,25 @@ openNote.controller("listController", function( $scope, var destName="Home"; var destID = null if(destFolder!=null){//is dest the home folder? - destName=destFolder.name;//Set defaults - destID = destFolder.id; + destName=destFolder.doc.name;//Set defaults + destID = destFolder.doc._id; } - if(sourceFolder.parrentFolderID!=destID){ + if(sourceFolder.doc.parentFolderID!=destID){ //Confirm action - alertify.confirm("Are you sure you want to move "+sourceFolder.name+" into "+ destName+"?" , function (confirm) { + alertify.confirm("Are you sure you want to move "+sourceFolder.doc.name+" into "+ destName+"?" , function (confirm) { if (confirm) { - var folderType = new folderFactory(); - var origParrentFolderID=sourceFolder.parrentFolderID; - - sourceFolder.__proto__=folderType.__proto__;//Cast this object as a resources + var origParrentFolderID=sourceFolder.parentFolderID; - sourceFolder.parrentFolderID=destID; - sourceFolder.$update().then(function(){//wait for a response - //fire off an event to tell everyone we just modified a folder - $rootScope.$emit("changedFolder", { - folder: sourceFolder, - oldParrentFolderID: origParrentFolderID - }); - }); + sourceFolder.doc.parentFolderID=destID; + storageService.database().put(sourceFolder.doc).then(function(result){ + $rootScope.$emit("changedFolder", {//fire off an event to tell everyone we just modified a folder + folder: sourceFolder, + oldParrentFolderID: origParrentFolderID + }); + }).catch(function(error){ + console.log(error);//FIXME + }); } else $rootScope.$emit("reloadListView", {}); //refresh either way @@ -115,6 +141,5 @@ openNote.controller("listController", function( $scope, } //Load the lists initially - if(userService.hasValidToken()) $rootScope.$emit("reloadListView"); }); \ No newline at end of file diff --git a/OpenNote/openNote/openNote.js b/OpenNote/openNote/openNote.js index a36133a..5731dfd 100644 --- a/OpenNote/openNote/openNote.js +++ b/OpenNote/openNote/openNote.js @@ -35,7 +35,6 @@ openNote.run(function ( $rootScope, //Initial entry after if logged in if(!$rootScope.showMenu && !$rootScope.showSideBar)//make sure we only fade in/run once $rootScope.$emit("init"); - }); diff --git a/OpenNote/openNote/partials/listPartial.html b/OpenNote/openNote/partials/listPartial.html index e4ff452..a61e6f2 100644 --- a/OpenNote/openNote/partials/listPartial.html +++ b/OpenNote/openNote/partials/listPartial.html @@ -1,8 +1,12 @@ -