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) {
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
margin-top: 15px !important;
|
||||
}
|
||||
|
||||
.mb-10 {
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
|
||||
.faded {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
@@ -3,30 +3,35 @@
|
||||
%div{"ng-if" => "showForm"}
|
||||
%p Enter your <a href="https://standardnotes.org" target="_blank">Standard File</a> account information.
|
||||
.small-v-space
|
||||
|
||||
%form.account-form{'name' => "loginForm"}
|
||||
%input.form-control{:name => 'server', :placeholder => 'Server URL', :required => true, :type => 'text', 'ng-model' => 'formData.url'}
|
||||
%input.form-control{:autofocus => 'autofocus', :name => 'email', :placeholder => 'Email', :required => true, :type => 'email', 'ng-model' => 'formData.email'}
|
||||
%input.form-control{:placeholder => 'Password', :name => 'password', :required => true, :type => 'password', 'ng-model' => 'formData.user_password'}
|
||||
.checkbox{"ng-if" => "localNotesCount() > 0"}
|
||||
%label
|
||||
%input{"type" => "checkbox", "ng-model" => "formData.mergeLocal", "ng-bind" => "true", "ng-change" => "mergeLocalChanged()"}
|
||||
Merge local notes ({{localNotesCount()}} notes)
|
||||
%button.btn.dark-button.half-button{"ng-click" => "loginSubmitPressed()", "data-style" => "expand-right", "data-size" => "s", "state" => "buttonState"}
|
||||
%span Sign In
|
||||
%button.btn.dark-button.half-button{"ng-click" => "submitRegistrationForm()", "data-style" => "expand-right", "data-size" => "s", "state" => "buttonState"}
|
||||
%span Register
|
||||
%br
|
||||
.block{"style" => "margin-top: 10px; font-size: 14px; font-weight: bold; text-align: center;"}
|
||||
%a.btn{"ng-click" => "showResetForm = !showResetForm"} Passwords cannot be forgotten.
|
||||
%em{"ng-if" => "formData.status", "style" => "font-size: 14px;"} {{formData.status}}
|
||||
|
||||
%label.center-align.block.faded — OR —
|
||||
%a.block.center-align.medium-text{"ng-if" => "!formData.showAddLinkForm", "ng-click" => "formData.showAddLinkForm = true"} Add sync using secret link
|
||||
%form{"ng-if" => "formData.showAddLinkForm"}
|
||||
%input.form-control{:autofocus => 'autofocus', :name => 'url', :placeholder => 'Secret URL', :required => true, :type => 'url', 'ng-model' => 'formData.secretUrl'}
|
||||
%button.btn.dark-button.btn-block{"ng-click" => "submitExternalSyncURL()"}
|
||||
Add Sync Account
|
||||
%a.block.center-align.mt-5{"ng-click" => "formData.showAddLinkForm = false"} Cancel
|
||||
%div{"ng-if" => "!formData.status"}
|
||||
.checkbox{"ng-if" => "localNotesCount() > 0"}
|
||||
%label
|
||||
%input{"type" => "checkbox", "ng-model" => "formData.mergeLocal", "ng-bind" => "true", "ng-change" => "mergeLocalChanged()"}
|
||||
Merge local notes ({{localNotesCount()}} notes)
|
||||
%button.btn.dark-button.half-button{"ng-click" => "loginSubmitPressed()", "data-style" => "expand-right", "data-size" => "s", "state" => "buttonState"}
|
||||
%span Sign In
|
||||
%button.btn.dark-button.half-button{"ng-click" => "submitRegistrationForm()", "data-style" => "expand-right", "data-size" => "s", "state" => "buttonState"}
|
||||
%span Register
|
||||
%br
|
||||
.block{"style" => "margin-top: 10px; font-size: 14px; font-weight: bold; text-align: center;"}
|
||||
%a.btn{"ng-click" => "showResetForm = !showResetForm"} Passwords cannot be forgotten.
|
||||
|
||||
%div{"ng-if" => "!formData.status"}
|
||||
%label.center-align.block.faded — OR —
|
||||
%a.block.center-align.medium-text{"ng-if" => "!formData.showAddLinkForm", "ng-click" => "formData.showAddLinkForm = true"} Add sync using secret link
|
||||
%form{"ng-if" => "formData.showAddLinkForm"}
|
||||
%input.form-control{:autofocus => 'autofocus', :name => 'url', :placeholder => 'Secret URL', :required => true, :type => 'url', 'ng-model' => 'formData.secretUrl'}
|
||||
%button.btn.dark-button.btn-block{"ng-click" => "submitExternalSyncURL()"}
|
||||
Add Sync Account
|
||||
%a.block.center-align.mt-5{"ng-click" => "formData.showAddLinkForm = false"} Cancel
|
||||
|
||||
%em.block.center-align.mt-10{"ng-if" => "formData.status", "style" => "font-size: 14px;"} {{formData.status}}
|
||||
|
||||
%div{"ng-if" => "showResetForm"}
|
||||
%p{"style" => "font-size: 13px; text-align: center;"}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
%h3{"ng-click" => "showSection = !showSection"}
|
||||
%a Your sync accounts ({{syncProviders.length}})
|
||||
|
||||
%div{"ng-if" => "showSection"}
|
||||
%div{"ng-if" => "showSection || syncManager.syncProviders.length > 0"}
|
||||
.small-v-space
|
||||
%section.white-bg.medium-padding{"ng-repeat" => "provider in syncProviders"}
|
||||
%label {{!provider.enabled ? 'Not enabled' : (provider.primary ? 'Main' : 'Secondary')}}
|
||||
@@ -17,7 +17,7 @@
|
||||
%button{"ng-click" => "saveKey(provider)"} Set
|
||||
|
||||
%button.light{"ng-if" => "!provider.enabled || !provider.primary", "ng-click" => "enableSyncProvider(provider, true)"} Set as Main
|
||||
%button.light{"ng-if" => "syncProviders.length > 1 && (provider.primary || !provider.enabled)", "ng-click" => "enableSyncProvider(provider, false)"} Add as Secondary
|
||||
%button.light{"ng-if" => "syncProviders.length > 1 && !provider.secondary && (!provider.primary || !provider.enabled)", "ng-click" => "enableSyncProvider(provider, false)"} Add as Secondary
|
||||
|
||||
%button.light{"ng-if" => "provider.keyName", "ng-click" => "changeEncryptionKey(provider)"} Change Encryption Key
|
||||
%button.light{"ng-click" => "removeSyncProvider(provider)"} Remove Account
|
||||
|
||||
Reference in New Issue
Block a user