From a0115cb741d279f7e153e5029b0c6fdf2ca79e57 Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Sun, 6 Dec 2015 15:35:59 +0100 Subject: Added Mega.co.nz backend as requested in issue #806 --- .../ngax/scripts/services/EditUriBuiltins.js | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Duplicati/Server/webroot/ngax/scripts/services/EditUriBuiltins.js') diff --git a/Duplicati/Server/webroot/ngax/scripts/services/EditUriBuiltins.js b/Duplicati/Server/webroot/ngax/scripts/services/EditUriBuiltins.js index 127dd2219..3726b470f 100644 --- a/Duplicati/Server/webroot/ngax/scripts/services/EditUriBuiltins.js +++ b/Duplicati/Server/webroot/ngax/scripts/services/EditUriBuiltins.js @@ -22,6 +22,7 @@ backupApp.service('EditUriBuiltins', function(AppService, AppUtils, SystemInfo, EditUriBackendConfig.templates['azure'] = 'templates/backends/azure.html'; EditUriBackendConfig.templates['gcs'] = 'templates/backends/gcs.html'; EditUriBackendConfig.templates['b2'] = 'templates/backends/b2.html'; + EditUriBackendConfig.templates['mega'] = 'templates/backends/mega.html'; // Loaders are a way for backends to request extra data from the server EditUriBackendConfig.loaders['s3'] = function(scope) { @@ -256,6 +257,10 @@ backupApp.service('EditUriBuiltins', function(AppService, AppUtils, SystemInfo, delete options[nukeopts[x]]; }; + EditUriBackendConfig.parsers['mega'] = function(scope, module, server, port, path, options) { + EditUriBackendConfig.mergeServerAndPath(scope); + }; + // Builders take the scope and produce the uri output EditUriBackendConfig.builders['s3'] = function(scope) { var opts = { @@ -380,6 +385,23 @@ backupApp.service('EditUriBuiltins', function(AppService, AppUtils, SystemInfo, return url; }; + EditUriBackendConfig.builders['mega'] = function(scope) { + var opts = { }; + + EditUriBackendConfig.merge_in_advanced_options(scope, opts); + + // Slightly better error message + scope.Folder = scope.Path; + + var url = AppUtils.format('{0}://{1}{2}', + 'mega', + scope.Path, + AppUtils.encodeDictAsUrl(opts) + ); + + return url; + }; + EditUriBackendConfig.validaters['file'] = function(scope) { return EditUriBackendConfig.require_path(scope); }; @@ -489,5 +511,14 @@ backupApp.service('EditUriBuiltins', function(AppService, AppUtils, SystemInfo, return res; }; + EditUriBackendConfig.validaters['mega'] = function(scope) { + scope.Path = scope.Path || ''; + var res = + EditUriBackendConfig.require_field(scope, 'Username', 'Username') && + EditUriBackendConfig.require_field(scope, 'Password', 'Password'); + + return res; + }; + }); \ No newline at end of file -- cgit v1.2.3