From a4c3cefe43ffd8d4cb7301a2fad1056774aa797b Mon Sep 17 00:00:00 2001 From: Kenneth Skovhede Date: Wed, 16 Jul 2014 23:21:04 +0200 Subject: [PATCH] Added grouping of backends --- Duplicati/Server/webroot/scripts/edituri.js | 51 ++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/Duplicati/Server/webroot/scripts/edituri.js b/Duplicati/Server/webroot/scripts/edituri.js index feef6993d..ad92499b8 100644 --- a/Duplicati/Server/webroot/scripts/edituri.js +++ b/Duplicati/Server/webroot/scripts/edituri.js @@ -318,11 +318,60 @@ $(document).ready(function() { BACKEND_STATE.modules = serverdata['BackendModules']; BACKEND_STATE.module_lookup = {}; + var group_basic = $(''); + var group_local = $(''); + var group_prop = $(''); + var group_others = $(''); + for (var i = 0; i < BACKEND_STATE.modules.length; i++) { - drop.append($("").attr("value", BACKEND_STATE.modules[i].Key).text(BACKEND_STATE.modules[i].DisplayName)); BACKEND_STATE.module_lookup[BACKEND_STATE.modules[i].Key] = BACKEND_STATE.modules[i]; } + var used = {}; + + for(var i in {'ftp':0, 'ssh':0, 'webdav':0}) { + if (BACKEND_STATE.module_lookup[i]) { + used[i] = true; + group_basic.append($("").attr("value", i).text(BACKEND_STATE.module_lookup[i].DisplayName)); + } + } + + if (BACKEND_STATE.module_lookup['s3']) { + used['s3'] = true; + group_basic.append($("").attr("value", 's3').text('S3 compatible')); + } + + for(var i in {'file':0}) { + if (BACKEND_STATE.module_lookup[i]) { + used[i] = true; + group_local.append($("").attr("value", i).text(BACKEND_STATE.module_lookup[i].DisplayName)); + } + } + + for(var i in {'s3':0, 'googledocs':0, 'onedrive':0, 'cloudfiles':0}) { + if (BACKEND_STATE.module_lookup[i]) { + used[i] = true; + group_prop.append($("").attr("value", i).text(BACKEND_STATE.module_lookup[i].DisplayName)); + } + } + + for (var i = 0; i < BACKEND_STATE.modules.length; i++) { + var k = BACKEND_STATE.modules[i].Key; + if (!used[k]) { + group_others.append($("").attr("value", k).text(BACKEND_STATE.module_lookup[k].DisplayName)); + } + } + + if (group_basic.children().length > 0) + drop.append(group_basic); + if (group_local.children().length > 0) + drop.append(group_local); + if (group_prop.children().length > 0) + drop.append(group_prop); + if (group_others.children().length > 0) + drop.append(group_others); + + BACKEND_STATE.orig_uri = $('#backup-uri').val(); BACKEND_STATE.orig_cfg = EDIT_URI.decode_uri(BACKEND_STATE.orig_uri); var scheme = BACKEND_STATE.orig_cfg['backend-type'];