'[% l('Delete content for key "[_1]"?', '{{deleteKey}}') %]';
s.DEFAULT_WS_LABEL = '[% l('[_1] (Default)', '{{ws}}') %]';
s.WS_EXISTS = '[% l("Workstation name already exists. Use it anyway?") %]';
+ s.WS_USED = '[% l("Workstation is already registered") %]';
+ s.PRINT_TEMPLATES_FAIL_EXPORT = "[% l('There are no customized print template to export') %]";
+ s.PRINT_TEMPLATES_SUCCESS_IMPORT = "[% l('Imported one or more print template(s)') %]";
+ s.PRINT_TEMPLATES_FAIL_IMPORT = "[% l('Failed to import any print template(s)') %]";
+ s.HATCH_SETTINGS_MIGRATION_SUCCESS = "[% l('Settings successfully migrated') %]";
+ s.HATCH_SETTINGS_MIGRATION_FAILURE = "[% l('Settings migration failed') %]";
}]);
</script>
[% END %]
}])
.controller('HatchCtrl',
- ['$scope','egCore',
-function($scope , egCore) {
+ ['$scope','egCore','ngToast',
+function($scope , egCore , ngToast) {
var hatch = egCore.hatch; // convenience
$scope.hatch_available = hatch.hatchAvailable;
hatch.setLocalItem('eg.hatch.enable.offline', newval);
});
+ $scope.copy_to_hatch = function() {
+ hatch.copySettingsToHatch().then(
+ function() {
+ ngToast.create(egCore.strings.HATCH_SETTINGS_MIGRATION_SUCCESS)},
+ function() {
+ ngToast.warning(egCore.strings.HATCH_SETTINGS_MIGRATION_FAILURE)}
+ );
+ }
+
+ $scope.copy_to_local = function() {
+ hatch.copySettingsToLocal().then(
+ function() {
+ ngToast.create(egCore.strings.HATCH_SETTINGS_MIGRATION_SUCCESS)},
+ function() {
+ ngToast.warning(egCore.strings.HATCH_SETTINGS_MIGRATION_FAILURE)}
+ );
+ }
+
}])
* tmp values are removed during logout or browser close.
*/
service.setItem = function(key, value) {
- if (service.useSettings())
+ if (!service.useSettings())
return $q.when(service.setLocalItem(key, value));
if (service.hatchAvailable)
service.setLocalItem('eg.hatch.login_keys', keys);
}
+ // Copy all stored settings from localStorage to Hatch.
+ // If 'move' is true, delete the local settings once cloned.
+ service.copySettingsToHatch = function(move) {
+ var deferred = $q.defer();
+ var keys = service.getLocalKeys();
+
+ angular.forEach(keys, function(key) {
+
+ // Hatch keys are local-only
+ if (key.match(/^eg.hatch/)) return;
+
+ console.debug("Copying to Hatch Storage: " + key);
+ service.setRemoteItem(key, service.getLocalItem(key))
+ .then(function() { // key successfully cloned.
+
+ // delete the local copy if requested.
+ if (move) service.removeLocalItem(key);
+
+ // resolve the promise after processing the last key.
+ if (key == keys[keys.length-1])
+ deferred.resolve();
+ });
+ });
+
+ return deferred.promise;
+ }
+
+ // Copy all stored settings from Hatch to localStorage.
+ // If 'move' is true, delete the Hatch settings once cloned.
+ service.copySettingsToLocal = function(move) {
+ var deferred = $q.defer();
+
+ service.getRemoteKeys().then(function(keys) {
+ angular.forEach(keys, function(key) {
+ service.getRemoteItem(key).then(function(val) {
+
+ console.debug("Copying to Local Storage: " + key);
+ service.setLocalItem(key, val);
+
+ // delete the remote copy if requested.
+ if (move) service.removeRemoteItem(key);
+
+ // resolve the promise after processing the last key.
+ if (key == keys[keys.length-1])
+ deferred.resolve();
+ });
+ });
+ });
+
+ return deferred.promise;
+ }
+
// The only requirement for opening Hatch is that the DOM be loaded.
// Open the connection now so its state will be immediately available.
service.openHatch();