updates
This commit is contained in:
@@ -13,9 +13,11 @@ angular.module('app.frontend')
|
||||
scope.$on("sync:updated_token", function(){
|
||||
ctrl.syncUpdated();
|
||||
ctrl.findErrors();
|
||||
ctrl.updateOfflineStatus();
|
||||
})
|
||||
scope.$on("sync:error", function(){
|
||||
ctrl.findErrors();
|
||||
ctrl.updateOfflineStatus();
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -23,7 +25,11 @@ angular.module('app.frontend')
|
||||
.controller('HeaderCtrl', function (apiController, modelManager, $timeout, dbManager, syncManager) {
|
||||
|
||||
this.user = apiController.user;
|
||||
this.offline = syncManager.offline;
|
||||
|
||||
this.updateOfflineStatus = function() {
|
||||
this.offline = syncManager.offline;
|
||||
}
|
||||
this.updateOfflineStatus();
|
||||
|
||||
this.findErrors = function() {
|
||||
this.error = syncManager.syncProviders.filter(function(provider){return provider.error}).length > 0 ? true : false;
|
||||
|
||||
@@ -59,14 +59,14 @@ class AccountNewAccountSection {
|
||||
console.log("logging in with url", $scope.formData.url);
|
||||
$timeout(function(){
|
||||
apiController.login($scope.formData.url, $scope.formData.email, $scope.formData.user_password, function(response){
|
||||
$scope.formData.status = null;
|
||||
if(!response || response.error) {
|
||||
var error = response ? response.error : {message: "An unknown error occured."}
|
||||
$scope.formData.status = null;
|
||||
if(!response || (response && !response.didDisplayAlert)) {
|
||||
alert(error.message);
|
||||
}
|
||||
} else {
|
||||
$scope.onAuthSuccess(response.user);
|
||||
$scope.showForm = false;
|
||||
}
|
||||
});
|
||||
})
|
||||
@@ -77,12 +77,12 @@ class AccountNewAccountSection {
|
||||
|
||||
$timeout(function(){
|
||||
apiController.register($scope.formData.url, $scope.formData.email, $scope.formData.user_password, function(response){
|
||||
$scope.formData.status = null;
|
||||
if(!response || response.error) {
|
||||
var error = response ? response.error : {message: "An unknown error occured."}
|
||||
$scope.formData.status = null;
|
||||
alert(error.message);
|
||||
} else {
|
||||
$scope.onAuthSuccess(response.user);
|
||||
$scope.showForm = false;
|
||||
}
|
||||
});
|
||||
})
|
||||
@@ -93,22 +93,6 @@ class AccountNewAccountSection {
|
||||
return allNotes.length + "/" + allNotes.length + " notes encrypted";
|
||||
}
|
||||
|
||||
$scope.onAuthSuccess = function(user) {
|
||||
var block = function(){
|
||||
window.location.reload();
|
||||
$scope.showLogin = false;
|
||||
$scope.showRegistration = false;
|
||||
};
|
||||
|
||||
if(!$scope.formData.mergeLocal) {
|
||||
dbManager.clearAllItems(function(){
|
||||
block();
|
||||
});
|
||||
} else {
|
||||
block();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,10 @@ class AccountSyncSection {
|
||||
controller($scope, modelManager, keyManager, syncManager) {
|
||||
'ngInject';
|
||||
|
||||
$scope.syncManager = syncManager;
|
||||
$scope.syncProviders = syncManager.syncProviders;
|
||||
$scope.keys = keyManager.keys;
|
||||
$scope.showSection = $scope.syncProviders.length > 0;
|
||||
// $scope.showSection = syncManager.syncProviders.length > 0;
|
||||
|
||||
$scope.enableSyncProvider = function(provider, primary) {
|
||||
if(!provider.keyName) {
|
||||
|
||||
@@ -17,7 +17,8 @@ class SyncManager {
|
||||
}
|
||||
|
||||
defaultServerURL() {
|
||||
return "https://n3.standardnotes.org";
|
||||
// return "https://n3.standardnotes.org";
|
||||
return "http://localhost:3000";
|
||||
}
|
||||
|
||||
get enabledProviders() {
|
||||
@@ -122,9 +123,7 @@ class SyncManager {
|
||||
|
||||
this.keyManager.addKey(provider.keyName, ek);
|
||||
|
||||
if(this.syncProviders.length == 0) {
|
||||
this.enableSyncProvider(provider, true);
|
||||
}
|
||||
this.enableSyncProvider(provider, this.enabledProviders == 0);
|
||||
|
||||
return provider;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ class SyncProvider {
|
||||
return this.keyName == SNKeyName;
|
||||
}
|
||||
|
||||
get secondary() {
|
||||
return this.status == "secondary";
|
||||
}
|
||||
|
||||
get status() {
|
||||
if(!this.enabled) {
|
||||
return null;
|
||||
|
||||
@@ -110,7 +110,6 @@ class SyncRunner {
|
||||
provider.syncStatus.current = 0;
|
||||
}
|
||||
|
||||
console.log("Syncing with provider:", provider.url, "items:", subItems.length);
|
||||
|
||||
// Remove dirty items now. If this operation fails, we'll re-add them.
|
||||
// This allows us to queue changes on the same item
|
||||
@@ -124,16 +123,15 @@ class SyncRunner {
|
||||
return itemParams.paramsForSync();
|
||||
}.bind(this));
|
||||
|
||||
request.sync_token = provider.syncToken;
|
||||
// request.sync_token = provider.syncToken;
|
||||
request.cursor_token = provider.cursorToken;
|
||||
console.log("Syncing with provider:", provider, "items:", subItems.length, "token", request.sync_token);
|
||||
|
||||
var headers = provider.jwt ? {Authorization: "Bearer " + provider.jwt} : {};
|
||||
request.post("", undefined, undefined, headers).then(function(response) {
|
||||
provider.error = null;
|
||||
|
||||
if(!provider.primary) {
|
||||
console.log("Completed sync for provider:", provider.url, "Response:", response);
|
||||
}
|
||||
console.log("Completed sync for provider:", provider.url, "Response:", response.plain());
|
||||
|
||||
provider.syncToken = response.sync_token;
|
||||
|
||||
@@ -155,9 +153,6 @@ class SyncRunner {
|
||||
}
|
||||
|
||||
provider.syncOpInProgress = false;
|
||||
if(!provider.primary) {
|
||||
console.log("Adding", subItems.length, "to", provider.syncStatus.current);
|
||||
}
|
||||
provider.syncStatus.current += subItems.length;
|
||||
|
||||
if(provider.cursorToken || provider.repeatOnCompletion == true) {
|
||||
|
||||
Reference in New Issue
Block a user