refresh button
This commit is contained in:
@@ -69,6 +69,16 @@ angular.module('app.frontend')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.getLastRefreshDate = function() {
|
||||||
|
return apiController.lastRefreshDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.refreshData = function() {
|
||||||
|
apiController.refreshItems(function(items){
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
this.loginSubmitPressed = function() {
|
this.loginSubmitPressed = function() {
|
||||||
this.loginData.status = "Generating Login Keys...";
|
this.loginData.status = "Generating Login Keys...";
|
||||||
$timeout(function(){
|
$timeout(function(){
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ angular.module('app.frontend')
|
|||||||
$scope.allTag = new Tag({all: true});
|
$scope.allTag = new Tag({all: true});
|
||||||
$scope.allTag.content.title = "All";
|
$scope.allTag.content.title = "All";
|
||||||
$scope.tags = modelManager.tags;
|
$scope.tags = modelManager.tags;
|
||||||
|
$scope.allTag.notes = modelManager.notes;
|
||||||
|
|
||||||
|
// setInterval(function () {
|
||||||
|
// apiController.refreshItems(null);
|
||||||
|
// }, 1000);
|
||||||
|
|
||||||
// apiController.verifyEncryptionStatusOfAllItems($scope.defaultUser, function(success){});
|
// apiController.verifyEncryptionStatusOfAllItems($scope.defaultUser, function(success){});
|
||||||
}
|
}
|
||||||
@@ -28,7 +33,7 @@ angular.module('app.frontend')
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$scope.updateAllTag = function() {
|
$scope.updateAllTag = function() {
|
||||||
$scope.allTag.notes = modelManager.filteredNotes;
|
// $scope.allTag.notes = modelManager.notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.tagsWillMakeSelection = function(tag) {
|
$scope.tagsWillMakeSelection = function(tag) {
|
||||||
@@ -94,10 +99,7 @@ angular.module('app.frontend')
|
|||||||
if(!$scope.selectedTag.all) {
|
if(!$scope.selectedTag.all) {
|
||||||
modelManager.addTagToNote($scope.selectedTag, note);
|
modelManager.addTagToNote($scope.selectedTag, note);
|
||||||
$scope.updateAllTag();
|
$scope.updateAllTag();
|
||||||
} else {
|
|
||||||
$scope.selectedTag.notes.unshift(note);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -108,7 +110,6 @@ angular.module('app.frontend')
|
|||||||
modelManager.addDirtyItems(note);
|
modelManager.addDirtyItems(note);
|
||||||
|
|
||||||
apiController.saveDirtyItems(function(){
|
apiController.saveDirtyItems(function(){
|
||||||
modelManager.addNote(note);
|
|
||||||
note.hasChanges = false;
|
note.hasChanges = false;
|
||||||
|
|
||||||
if(callback) {
|
if(callback) {
|
||||||
|
|||||||
@@ -236,10 +236,11 @@ angular.module('app.frontend')
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
this.refreshItems = function(updatedAfter, callback) {
|
this.refreshItems = function(callback) {
|
||||||
var request = Restangular.one("users", this.user.uuid).one("items");
|
var request = Restangular.one("users", this.user.uuid).one("items");
|
||||||
request.get(updatedAfter ? {"updated_after" : updatedAfter.toString()} : {})
|
request.get(this.lastRefreshDate ? {"updated_after" : this.lastRefreshDate.toString()} : {})
|
||||||
.then(function(response){
|
.then(function(response){
|
||||||
|
this.lastRefreshDate = new Date();
|
||||||
var items = this.handleItemsResponse(response.items, null);
|
var items = this.handleItemsResponse(response.items, null);
|
||||||
callback(items);
|
callback(items);
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class ItemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mapResponseItemsToLocalModelsOmittingFields(items, omitFields) {
|
mapResponseItemsToLocalModelsOmittingFields(items, omitFields) {
|
||||||
|
console.log("map response items", items);
|
||||||
var models = []
|
var models = []
|
||||||
for (var json_obj of items) {
|
for (var json_obj of items) {
|
||||||
json_obj = _.omit(json_obj, omitFields || [])
|
json_obj = _.omit(json_obj, omitFields || [])
|
||||||
@@ -75,7 +76,9 @@ class ItemManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addItem(item) {
|
addItem(item) {
|
||||||
this.items.push(item);
|
if(!this.findItem(item.uuid)) {
|
||||||
|
this.items.push(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns dirty item references that need saving
|
// returns dirty item references that need saving
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class ModelManager extends ItemManager {
|
|||||||
super.resolveReferences()
|
super.resolveReferences()
|
||||||
|
|
||||||
this.notes.push.apply(this.notes, _.difference(this.itemsForContentType("Note"), this.notes));
|
this.notes.push.apply(this.notes, _.difference(this.itemsForContentType("Note"), this.notes));
|
||||||
|
Item.sortItemsByDate(this.notes);
|
||||||
this.notes.forEach(function(note){
|
this.notes.forEach(function(note){
|
||||||
note.updateReferencesLocalMapping();
|
note.updateReferencesLocalMapping();
|
||||||
})
|
})
|
||||||
@@ -48,7 +49,6 @@ class ModelManager extends ItemManager {
|
|||||||
addTag(tag) {
|
addTag(tag) {
|
||||||
this.tags.unshift(tag);
|
this.tags.unshift(tag);
|
||||||
this.addItem(tag);
|
this.addItem(tag);
|
||||||
console.log("adding tag", tag, "tags", this.tags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addTagToNote(tag, note) {
|
addTagToNote(tag, note) {
|
||||||
@@ -84,9 +84,6 @@ class ModelManager extends ItemManager {
|
|||||||
this.addDirtyItems(dirty);
|
this.addDirtyItems(dirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredNotes() {
|
|
||||||
return Note.filterDummyNotes(this.notes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module('app.frontend').service('modelManager', ModelManager);
|
angular.module('app.frontend').service('modelManager', ModelManager);
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.menu {
|
.menu {
|
||||||
// float: right;
|
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
@@ -39,6 +38,15 @@
|
|||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
|
||||||
|
&.left {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.right {
|
||||||
|
float: right;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.login-panel .login-input {
|
.login-panel .login-input {
|
||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
}
|
}
|
||||||
@@ -96,6 +104,11 @@
|
|||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.item.last-refreshed {
|
||||||
|
font-weight: normal !important;
|
||||||
|
cursor: default !important;
|
||||||
|
}
|
||||||
|
|
||||||
.item.account {
|
.item.account {
|
||||||
|
|
||||||
.email {
|
.email {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.header
|
.header
|
||||||
.header-content
|
.header-content
|
||||||
.menu
|
.menu.left
|
||||||
.items
|
.items
|
||||||
.item.account
|
.item.account
|
||||||
%div{"ng-click" => "ctrl.accountMenuPressed()"}
|
%div{"ng-click" => "ctrl.accountMenuPressed()"}
|
||||||
@@ -90,3 +90,10 @@
|
|||||||
.item
|
.item
|
||||||
%a{"href" => "https://standardnotes.org", "target" => "_blank"}
|
%a{"href" => "https://standardnotes.org", "target" => "_blank"}
|
||||||
Help
|
Help
|
||||||
|
|
||||||
|
.menu.right
|
||||||
|
.items
|
||||||
|
.item.last-refreshed{"ng-if" => "ctrl.getLastRefreshDate()"}
|
||||||
|
Last refreshed {{ctrl.getLastRefreshDate() | appDateTime}}
|
||||||
|
.item{"ng-click" => "ctrl.refreshData()"}
|
||||||
|
Refresh
|
||||||
|
|||||||
35
vendor/assets/javascripts/transpiled.js
vendored
35
vendor/assets/javascripts/transpiled.js
vendored
@@ -760,6 +760,14 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.getLastRefreshDate = function () {
|
||||||
|
return apiController.lastRefreshDate;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.refreshData = function () {
|
||||||
|
apiController.refreshItems(function (items) {});
|
||||||
|
};
|
||||||
|
|
||||||
this.loginSubmitPressed = function () {
|
this.loginSubmitPressed = function () {
|
||||||
this.loginData.status = "Generating Login Keys...";
|
this.loginData.status = "Generating Login Keys...";
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
@@ -861,6 +869,11 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
$scope.allTag = new Tag({ all: true });
|
$scope.allTag = new Tag({ all: true });
|
||||||
$scope.allTag.content.title = "All";
|
$scope.allTag.content.title = "All";
|
||||||
$scope.tags = modelManager.tags;
|
$scope.tags = modelManager.tags;
|
||||||
|
$scope.allTag.notes = modelManager.notes;
|
||||||
|
|
||||||
|
// setInterval(function () {
|
||||||
|
// apiController.refreshItems(null);
|
||||||
|
// }, 1000);
|
||||||
|
|
||||||
// apiController.verifyEncryptionStatusOfAllItems($scope.defaultUser, function(success){});
|
// apiController.verifyEncryptionStatusOfAllItems($scope.defaultUser, function(success){});
|
||||||
};
|
};
|
||||||
@@ -882,7 +895,7 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$scope.updateAllTag = function () {
|
$scope.updateAllTag = function () {
|
||||||
$scope.allTag.notes = modelManager.filteredNotes;
|
// $scope.allTag.notes = modelManager.notes;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.tagsWillMakeSelection = function (tag) {
|
$scope.tagsWillMakeSelection = function (tag) {
|
||||||
@@ -948,8 +961,6 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
if (!$scope.selectedTag.all) {
|
if (!$scope.selectedTag.all) {
|
||||||
modelManager.addTagToNote($scope.selectedTag, note);
|
modelManager.addTagToNote($scope.selectedTag, note);
|
||||||
$scope.updateAllTag();
|
$scope.updateAllTag();
|
||||||
} else {
|
|
||||||
$scope.selectedTag.notes.unshift(note);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -961,7 +972,6 @@ angular.module('app.frontend').controller('BaseCtrl', BaseCtrl);
|
|||||||
modelManager.addDirtyItems(note);
|
modelManager.addDirtyItems(note);
|
||||||
|
|
||||||
apiController.saveDirtyItems(function () {
|
apiController.saveDirtyItems(function () {
|
||||||
modelManager.addNote(note);
|
|
||||||
note.hasChanges = false;
|
note.hasChanges = false;
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
@@ -1745,9 +1755,10 @@ var User = function User(json_obj) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.refreshItems = function (updatedAfter, callback) {
|
this.refreshItems = function (callback) {
|
||||||
var request = Restangular.one("users", this.user.uuid).one("items");
|
var request = Restangular.one("users", this.user.uuid).one("items");
|
||||||
request.get(updatedAfter ? { "updated_after": updatedAfter.toString() } : {}).then(function (response) {
|
request.get(this.lastRefreshDate ? { "updated_after": this.lastRefreshDate.toString() } : {}).then(function (response) {
|
||||||
|
this.lastRefreshDate = new Date();
|
||||||
var items = this.handleItemsResponse(response.items, null);
|
var items = this.handleItemsResponse(response.items, null);
|
||||||
callback(items);
|
callback(items);
|
||||||
}.bind(this)).catch(function (response) {
|
}.bind(this)).catch(function (response) {
|
||||||
@@ -2457,6 +2468,7 @@ var ItemManager = function () {
|
|||||||
}, {
|
}, {
|
||||||
key: 'mapResponseItemsToLocalModelsOmittingFields',
|
key: 'mapResponseItemsToLocalModelsOmittingFields',
|
||||||
value: function mapResponseItemsToLocalModelsOmittingFields(items, omitFields) {
|
value: function mapResponseItemsToLocalModelsOmittingFields(items, omitFields) {
|
||||||
|
console.log("map response items", items);
|
||||||
var models = [];
|
var models = [];
|
||||||
var _iteratorNormalCompletion3 = true;
|
var _iteratorNormalCompletion3 = true;
|
||||||
var _didIteratorError3 = false;
|
var _didIteratorError3 = false;
|
||||||
@@ -2537,7 +2549,9 @@ var ItemManager = function () {
|
|||||||
}, {
|
}, {
|
||||||
key: 'addItem',
|
key: 'addItem',
|
||||||
value: function addItem(item) {
|
value: function addItem(item) {
|
||||||
this.items.push(item);
|
if (!this.findItem(item.uuid)) {
|
||||||
|
this.items.push(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns dirty item references that need saving
|
// returns dirty item references that need saving
|
||||||
@@ -2622,6 +2636,7 @@ var ModelManager = function (_ItemManager) {
|
|||||||
_get(ModelManager.prototype.__proto__ || Object.getPrototypeOf(ModelManager.prototype), 'resolveReferences', this).call(this);
|
_get(ModelManager.prototype.__proto__ || Object.getPrototypeOf(ModelManager.prototype), 'resolveReferences', this).call(this);
|
||||||
|
|
||||||
this.notes.push.apply(this.notes, _.difference(this.itemsForContentType("Note"), this.notes));
|
this.notes.push.apply(this.notes, _.difference(this.itemsForContentType("Note"), this.notes));
|
||||||
|
Item.sortItemsByDate(this.notes);
|
||||||
this.notes.forEach(function (note) {
|
this.notes.forEach(function (note) {
|
||||||
note.updateReferencesLocalMapping();
|
note.updateReferencesLocalMapping();
|
||||||
});
|
});
|
||||||
@@ -2659,7 +2674,6 @@ var ModelManager = function (_ItemManager) {
|
|||||||
value: function addTag(tag) {
|
value: function addTag(tag) {
|
||||||
this.tags.unshift(tag);
|
this.tags.unshift(tag);
|
||||||
this.addItem(tag);
|
this.addItem(tag);
|
||||||
console.log("adding tag", tag, "tags", this.tags);
|
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'addTagToNote',
|
key: 'addTagToNote',
|
||||||
@@ -2700,11 +2714,6 @@ var ModelManager = function (_ItemManager) {
|
|||||||
_.remove(this.tags, tag);
|
_.remove(this.tags, tag);
|
||||||
this.addDirtyItems(dirty);
|
this.addDirtyItems(dirty);
|
||||||
}
|
}
|
||||||
}, {
|
|
||||||
key: 'filteredNotes',
|
|
||||||
value: function filteredNotes() {
|
|
||||||
return Note.filterDummyNotes(this.notes);
|
|
||||||
}
|
|
||||||
}, {
|
}, {
|
||||||
key: 'filteredNotes',
|
key: 'filteredNotes',
|
||||||
get: function get() {
|
get: function get() {
|
||||||
|
|||||||
2
vendor/assets/javascripts/transpiled.js.map
vendored
2
vendor/assets/javascripts/transpiled.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user