Add settings section for options syncing. Fix #7.

This commit is contained in:
FelisCatus 2015-01-23 00:03:50 +08:00
parent 29bebd458c
commit 9291123f8f
7 changed files with 182 additions and 7 deletions

View File

@ -259,6 +259,36 @@
"options_restoreOnlineSubmit": {
"message": "Restore"
},
"options_group_syncing": {
"message": "Syncing (Experimental)"
},
"options_syncEnable": {
"message": "Enable Syncing"
},
"options_syncEnableForce": {
"message": "Download from Syncing"
},
"options_syncDisable": {
"message": "Disable syncing"
},
"options_syncPristineHelp": {
"message": "You can now automatically synchroize your settings and profiles across all your desktop devices running Chrome browser."
},
"options_syncSyncAlert": {
"message": "Your options are automatically synchroized with your other devices."
},
"options_syncSyncHelp": {
"message": "Please note that you must sign in to Chrome on each of your devices (including this one) for the syncing to actually work. <br> You may check this section on other devices to ensure that it is working."
},
"options_syncConflictAlert": {
"message": "You have uploaded a copy of your options on another device via syncing."
},
"options_syncConflictHelp": {
"message": "You may download the remote copy to your device if you like. <br>However, doing so would <b>overwrite your existing settings and profiles</b> on this device."
},
"options_syncUnsupportedHelp": {
"message": "Options syncing is not supported on your platform or browser. For now, only Chrome browser on desktop is supported."
},
"options_profileTabPrefix": {
"message": "Profile :: "
},

View File

@ -259,6 +259,36 @@
"options_restoreOnlineSubmit": {
"message": "恢复"
},
"options_group_syncing": {
"message": "选项同步 (测试中)"
},
"options_syncEnable": {
"message": "启用同步"
},
"options_syncEnableForce": {
"message": "下载云端版本"
},
"options_syncDisable": {
"message": "禁用同步"
},
"options_syncPristineHelp": {
"message": "您可以将设置和情景模式同步到所有使用Chrome浏览器的桌面设备。"
},
"options_syncSyncAlert": {
"message": "您的设置将会自动与其他设备进行同步。"
},
"options_syncSyncHelp": {
"message": "请注意您需要在所有设备上包括此设备的Chrome浏览器中登录这样同步的选项才能正常使用。<br>可以在其他设备上查看此页面,来检查同步是否生效。"
},
"options_syncConflictAlert": {
"message": "您已经通过其他设备上传了一份选项用于同步。"
},
"options_syncConflictHelp": {
"message": "您可以将云端的选项下载到此设备使用。<br>一旦选择下载,<b>此设备上的设置和情景模式将会被覆盖</b>。"
},
"options_syncUnsupportedHelp": {
"message": "选项同步暂不支持您的平台或浏览器。目前只支持桌面版Chrome的浏览器的同步请谅解。"
},
"options_profileTabPrefix": {
"message": "情景模式: "
},

View File

@ -259,6 +259,36 @@
"options_restoreOnlineSubmit": {
"message": "恢復"
},
"options_group_syncing": {
"message": "選項同步 (測試中)"
},
"options_syncEnable": {
"message": "啟用同步"
},
"options_syncEnableForce": {
"message": "下載雲端版本"
},
"options_syncDisable": {
"message": "禁用同步"
},
"options_syncPristineHelp": {
"message": "您可以將設定和情景模式同步到所有使用Chrome瀏覽器的桌面裝置。"
},
"options_syncSyncAlert": {
"message": "您的設定將會自動與其他裝置進行同步。"
},
"options_syncSyncHelp": {
"message": "請注意您需要在所有裝置上包括此裝置的Chrome瀏覽器中登入這樣同步的選項才能正常使用。<br>可以在其他裝置上檢視此頁面,來檢查同步是否生效。"
},
"options_syncConflictAlert": {
"message": "您已經通過其他裝置上傳了一份選項用於同步。"
},
"options_syncConflictHelp": {
"message": "您可以將雲端的選項下載到此裝置使用。<br>一旦選擇下載,<b>此裝置上的設定和情景模式將會被覆蓋</b>。"
},
"options_syncUnsupportedHelp": {
"message": "選項同步暫不支援您的平臺或瀏覽器。目前只支援桌面版Chrome的瀏覽器的同步請諒解。"
},
"options_profileTabPrefix": {
"message": "情景模式: "
},

View File

@ -259,6 +259,36 @@
"options_restoreOnlineSubmit": {
"message": "恢復"
},
"options_group_syncing": {
"message": "選項同步 (測試中)"
},
"options_syncEnable": {
"message": "啟用同步"
},
"options_syncEnableForce": {
"message": "下載雲端版本"
},
"options_syncDisable": {
"message": "禁用同步"
},
"options_syncPristineHelp": {
"message": "您可以將設定和情景模式同步到所有使用Chrome瀏覽器的桌面裝置。"
},
"options_syncSyncAlert": {
"message": "您的設定將會自動與其他裝置進行同步。"
},
"options_syncSyncHelp": {
"message": "請注意您需要在所有裝置上包括此裝置的Chrome瀏覽器中登入這樣同步的選項才能正常使用。<br>可以在其他裝置上檢視此頁面,來檢查同步是否生效。"
},
"options_syncConflictAlert": {
"message": "您已經通過其他裝置上傳了一份選項用於同步。"
},
"options_syncConflictHelp": {
"message": "您可以將雲端的選項下載到此裝置使用。<br>一旦選擇下載,<b>此裝置上的設定和情景模式將會被覆蓋</b>。"
},
"options_syncUnsupportedHelp": {
"message": "選項同步暫不支援您的平臺或瀏覽器。目前只支援桌面版Chrome的瀏覽器的同步請諒解。"
},
"options_profileTabPrefix": {
"message": "情景模式: "
},

View File

@ -1,4 +1,6 @@
angular.module('omega').controller 'IoCtrl', ($scope, $rootScope) ->
angular.module('omega').controller 'IoCtrl', ($scope, $rootScope,
$window, omegaTarget) ->
$scope.exportOptions = ->
$rootScope.applyOptionsConfirm().then ->
plainOptions = angular.fromJson(angular.toJson($rootScope.options))
@ -14,11 +16,11 @@ angular.module('omega').controller 'IoCtrl', ($scope, $rootScope) ->
)
$scope.restoreLocal = (content) ->
$rootScope.resetOptions(content).then ( ->
$scope.restoringLocal = true
$rootScope.resetOptions(content).then(( ->
$scope.importSuccess()
$rootScope.updateProfile().finally ->
$scope.importSuccess()
), -> $scope.restoreLocalError()
), -> $scope.restoreLocalError()).finally ->
$scope.restoringLocal = false
$scope.restoreLocalError = ->
$rootScope.showAlert(
type: 'error'
@ -44,3 +46,17 @@ angular.module('omega').controller 'IoCtrl', ($scope, $rootScope) ->
cache: false,
timeout: 10000
)
$scope.enableOptionsSync = (args) ->
enable = ->
omegaTarget.setOptionsSync(true, args).finally ->
$window.location.reload()
if args?.force
enable()
else
$rootScope.applyOptionsConfirm().then enable
$scope.disableOptionsSync = ->
omegaTarget.setOptionsSync(false).then ->
$rootScope.applyOptionsConfirm().then ->
$window.location.reload()

View File

@ -10,6 +10,10 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window,
omegaTarget.addOptionsChangeCallback (newOptions) ->
$rootScope.options = angular.copy(newOptions)
$rootScope.optionsOld = angular.copy(newOptions)
omegaTarget.state('syncOptions').then (syncOptions) ->
$scope.syncOptions = syncOptions
$timeout ->
$rootScope.optionsDirty = false

View File

@ -17,8 +17,10 @@ section.settings-group
| {{'options_makeBackup' | tr}}
span.help-inline {{'options_makeBackupHelp' | tr}}
p
input#restore-local-file(type='file' omega-upload='restoreLocal($content)' omega-error='restoreLocalError($error)')
button.btn.btn-default(ng-click='triggerFileInput()')
input#restore-local-file(type='file' omega-upload='restoreLocal($content)'
omega-error='restoreLocalError($error)')
button.btn.btn-default(ng-click='triggerFileInput()'
ladda='restoringLocal' data-spinner-color="#000000")
span.glyphicon.glyphicon-folder-open
= ' '
| {{'options_restoreLocal' | tr}}
@ -29,3 +31,36 @@ section.settings-group
input.form-control(type='url' ng-model='restoreOnlineUrl' placeholder="{{'options_restoreOnlinePlaceholder' | tr}}")
span.input-group-btn
button.btn.btn-default(ng-click='restoreOnline()') {{'options_restoreOnlineSubmit' | tr}}
section.settings-group
h3 {{'options_group_syncing' | tr}}
div(ng-show='syncOptions == "pristine" || syncOptions == "disabled"')
p.help-block(omega-html='"options_syncPristineHelp" | tr')
p
button.btn.btn-default(ng-click='enableOptionsSync()')
span.glyphicon.glyphicon-cloud-upload
= ' '
| {{'options_syncEnable' | tr}}
div(ng-show='syncOptions == "sync"')
p.alert.alert-success.width-limit
span.glyphicon.glyphicon-ok
= ' '
| {{"options_syncSyncAlert" | tr}}
p.help-block(omega-html='"options_syncSyncHelp" | tr')
p
button.btn.btn-warning(ng-click='disableOptionsSync()')
span.glyphicon.glyphicon-remove-sign
= ' '
| {{'options_syncDisable' | tr}}
div(ng-show='syncOptions == "conflict"')
p.alert.alert-info.width-limit
span.glyphicon.glyphicon-info-sign
= ' '
| {{"options_syncConflictAlert" | tr}}
p.help-block(omega-html='"options_syncConflictHelp" | tr')
p
button.btn.btn-danger(ng-click='enableOptionsSync({force: true})')
span.glyphicon.glyphicon-cloud-download
= ' '
| {{'options_syncEnableForce' | tr}}
div(ng-show='syncOptions == "unsupported"')
p.help-block(omega-html='"options_syncUnsupportedHelp" | tr')