diff options
author | Kenneth Skovhede <kenneth@hexad.dk> | 2015-12-06 17:35:59 +0300 |
---|---|---|
committer | Kenneth Skovhede <kenneth@hexad.dk> | 2015-12-06 17:36:33 +0300 |
commit | a0115cb741d279f7e153e5029b0c6fdf2ca79e57 (patch) | |
tree | 3f48d84d04f454b9eb3fcf5a06548ed74e1914bb /Duplicati/Server | |
parent | 6f33f8dc5348f4706c782267089a189d88e2475b (diff) |
Added Mega.co.nz backend as requested in issue #806
Diffstat (limited to 'Duplicati/Server')
6 files changed, 116 insertions, 3 deletions
diff --git a/Duplicati/Server/Duplicati.Server.csproj b/Duplicati/Server/Duplicati.Server.csproj index 8393cebb0..c43fd6cbb 100644 --- a/Duplicati/Server/Duplicati.Server.csproj +++ b/Duplicati/Server/Duplicati.Server.csproj @@ -260,6 +260,10 @@ <Project>{61C43D61-4368-4942-84A3-1EB623F4EF2A}</Project>
<Name>Duplicati.Library.Backend.Backblaze</Name>
</ProjectReference>
+ <ProjectReference Include="..\Library\Backend\Mega\Duplicati.Library.Backend.Mega.csproj">
+ <Project>{6643A5AE-AB38-453F-ADCE-408E35A81A83}</Project>
+ <Name>Duplicati.Library.Backend.Mega</Name>
+ </ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="webroot\" />
diff --git a/Duplicati/Server/webroot/greeno/scripts/edituri.js b/Duplicati/Server/webroot/greeno/scripts/edituri.js index b4f20e5ef..975a8a6ee 100644 --- a/Duplicati/Server/webroot/greeno/scripts/edituri.js +++ b/Duplicati/Server/webroot/greeno/scripts/edituri.js @@ -364,7 +364,7 @@ $(document).ready(function() { } } - for (var i in { 's3': 0, 'azure': 0, 'googledrive': 0, 'onedrive': 0, 'cloudfiles': 0, 'gcs': 0, 'openstack': 0, 'hubic': 0, 'amzcd': 0, 'b2': 0 }) { + for (var i in { 's3': 0, 'azure': 0, 'googledrive': 0, 'onedrive': 0, 'cloudfiles': 0, 'gcs': 0, 'openstack': 0, 'hubic': 0, 'amzcd': 0, 'b2': 0, 'mega': 0 }) { if (BACKEND_STATE.module_lookup[i]) { used[i] = true; group_prop.append($("<option></option>").attr("value", i).text(BACKEND_STATE.module_lookup[i].DisplayName)); diff --git a/Duplicati/Server/webroot/greeno/scripts/plugins.js b/Duplicati/Server/webroot/greeno/scripts/plugins.js index f064fc9d8..d593c8ad3 100644 --- a/Duplicati/Server/webroot/greeno/scripts/plugins.js +++ b/Duplicati/Server/webroot/greeno/scripts/plugins.js @@ -761,4 +761,70 @@ $(document).ready(function() { 'b2-bucket': 'server-path' } } + + APP_DATA.plugins.backend['mega'] = { + + PLUGIN_MEGA_LINK: 'https://mega.co.nz', + + hasssl: false, + hideserverandport: true, + usernamelabel: 'Username', + passwordlabel: 'Password', + usernamewatermark: 'Username', + passwordwatermark: 'Password', + path_field: null, + + setup: function (dlg, div) { + $('#server-path-label').hide(); + $('#server-path').hide(); + + $('#server-username').attr('placeholder', this.usernamewatermark); + $('#server-password').attr('placeholder', this.passwordwatermark); + + var pathfield = EDIT_URI.createFieldset({ label: 'Path', name: 'mega-path', after: $('#server-username-and-password'), title: 'Path', watermark: 'Enter path' }); + this.path_field = pathfield.field; + + var signuplink = EDIT_URI.createFieldset({ 'label': ' ', href: this.PLUGIN_MEGA_LINK, type: 'link', before: $('#server-options-label'), 'title': 'Click here to sign in or register' }); + signuplink.outer.css('margin-bottom', '10px'); + + }, + + cleanup: function (dlg, div) { + $('#server-path-label').show(); + $('#server-path').show(); + this.path_field = null; + }, + + validate: function (dlg, values) { + if (!EDIT_URI.validate_input(values, true)) + return false; + + values['server-path'] = values["mega-path"].toLowerCase(); + this.path_field.val(values['server-path']); + + return true; + }, + + fill_form_map: { + 'server-path': function(dict, key, el, cfgel) { + var p = []; + if (dict['server-name'] && dict['server-name'] != '') + p.push(dict['server-name']); + if (dict['server-path'] && dict['server-path'] != '') + p.push(dict['server-path']); + + p = p.join('/'); + + $('#mega-path').val(p); + } + }, + + fill_dict_map: { + 'mega-path': function(dict, key, el, cfgel) { + var p = $(el).val(); + dict['server-path'] = p; + dict['server-name'] = ''; + } + } + } });
\ No newline at end of file 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 diff --git a/Duplicati/Server/webroot/ngax/scripts/services/SystemInfo.js b/Duplicati/Server/webroot/ngax/scripts/services/SystemInfo.js index f441c38e8..32e82d831 100644 --- a/Duplicati/Server/webroot/ngax/scripts/services/SystemInfo.js +++ b/Duplicati/Server/webroot/ngax/scripts/services/SystemInfo.js @@ -6,7 +6,7 @@ backupApp.service('SystemInfo', function($rootScope, $timeout, AppService, AppUt var backendgroups = { std: {'ftp': null, 'ssh': null, 'webdav': null, 'openstack': 'OpenStack Object Storage / Swift', 's3': 'S3 Compatible'}, local: {'file': null}, - prop: { 's3': null, 'azure': null, 'googledrive': null, 'onedrive': null, 'cloudfiles': null, 'gcs': null, 'openstack': null, 'hubic': null, 'amzcd': null, 'b2': null } + prop: { 's3': null, 'azure': null, 'googledrive': null, 'onedrive': null, 'cloudfiles': null, 'gcs': null, 'openstack': null, 'hubic': null, 'amzcd': null, 'b2': null, 'mega': null } } this.backendgroups = backendgroups; @@ -59,7 +59,6 @@ backupApp.service('SystemInfo', function($rootScope, $timeout, AppService, AppUt push_with_type(m, 'Others', 3); } - $rootScope.$broadcast('systeminfochanged'); }, AppUtils.connectionError) diff --git a/Duplicati/Server/webroot/ngax/templates/backends/mega.html b/Duplicati/Server/webroot/ngax/templates/backends/mega.html new file mode 100644 index 000000000..fc7a87542 --- /dev/null +++ b/Duplicati/Server/webroot/ngax/templates/backends/mega.html @@ -0,0 +1,13 @@ +<div class="input text"> + <label for="mega_path">Folder path</label> + <input type="text" name="mega_path" id="mega_path" ng-model="$parent.Path" placeholder="Enter folder path name" /> +</div> + +<div class="input text"> + <label for="mega_username">Username</label> + <input type="text" name="mega_username" id="mega_username" ng-model="$parent.Username" placeholder="Username" /> +</div> +<div class="input password"> + <label for="mega_password">Password</label> + <input type="password" name="mega_password" id="mega_password" ng-model="$parent.Password" placeholder="Password" /> +</div>
\ No newline at end of file |