2016-03-18 21:26:17 -07:00
|
|
|
|
define(['jQuery'], function ($) {
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2014-01-29 22:20:18 -07:00
|
|
|
|
var currentConfig;
|
|
|
|
|
|
|
|
|
|
function remove(page, index) {
|
|
|
|
|
|
2016-02-22 12:12:06 -07:00
|
|
|
|
require(['confirm'], function (confirm) {
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
2016-02-22 12:12:06 -07:00
|
|
|
|
confirm(Globalize.translate('MessageConfirmPathSubstitutionDeletion'), Globalize.translate('HeaderConfirmDeletion')).then(function () {
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
|
|
|
|
config.PathSubstitutions.splice(index, 1);
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateServerConfiguration(config).then(function () {
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
});
|
2016-02-22 12:12:06 -07:00
|
|
|
|
});
|
2014-01-29 22:20:18 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addSubstitution(page, config) {
|
|
|
|
|
|
|
|
|
|
config.PathSubstitutions.push({
|
|
|
|
|
From: $('#txtFrom', page).val(),
|
|
|
|
|
To: $('#txtTo', page).val()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reloadPathMappings(page, config) {
|
|
|
|
|
|
|
|
|
|
var index = 0;
|
|
|
|
|
|
|
|
|
|
var html = config.PathSubstitutions.map(function (map) {
|
|
|
|
|
|
2016-02-08 11:05:29 -07:00
|
|
|
|
var mapHtml = '';
|
|
|
|
|
mapHtml += '<paper-icon-item>';
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
2016-02-08 11:05:29 -07:00
|
|
|
|
mapHtml += '<paper-fab mini icon="folder" class="blue" item-icon></paper-fab>';
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
2016-02-08 11:05:29 -07:00
|
|
|
|
mapHtml += '<paper-item-body three-line>';
|
|
|
|
|
|
|
|
|
|
mapHtml += "<div>" + map.From + "</div>";
|
|
|
|
|
mapHtml += "<div secondary><b>" + Globalize.translate('HeaderTo') + "</b></div>";
|
|
|
|
|
mapHtml += "<div secondary>" + map.To + "</div>";
|
|
|
|
|
|
|
|
|
|
mapHtml += '</paper-item-body>';
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
2015-09-06 12:09:36 -07:00
|
|
|
|
mapHtml += '<paper-icon-button data-index="' + index + '" icon="delete" class="btnDeletePath"></paper-icon-button>';
|
|
|
|
|
|
2016-02-08 11:05:29 -07:00
|
|
|
|
mapHtml += '</paper-icon-item>';
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
return mapHtml;
|
|
|
|
|
|
2016-02-08 11:05:29 -07:00
|
|
|
|
}).join('');
|
|
|
|
|
|
|
|
|
|
if (config.PathSubstitutions.length) {
|
|
|
|
|
html = '<div class="paperList">' + html + '</div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var elem = $('.pathSubstitutions', page).html(html);
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
|
|
|
|
$('.btnDeletePath', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
remove(page, parseInt(this.getAttribute('data-index')));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 13:57:17 -07:00
|
|
|
|
function loadPage(page, config) {
|
|
|
|
|
|
2014-01-29 22:20:18 -07:00
|
|
|
|
currentConfig = config;
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2016-02-08 11:05:29 -07:00
|
|
|
|
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
|
|
|
|
|
reloadPathMappings(page, config);
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
2014-01-29 13:57:17 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-29 22:20:18 -07:00
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
$('#txtFrom', page).val('');
|
|
|
|
|
$('#txtTo', page).val('');
|
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
|
|
|
|
loadPage(page, config);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
function onSubmit() {
|
2014-01-29 13:57:17 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
var form = this;
|
|
|
|
|
var page = $(form).parents('.page');
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
addSubstitution(page, config);
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.updateServerConfiguration(config).then(function () {
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
reload(page);
|
|
|
|
|
});
|
2014-01-29 13:57:17 -07:00
|
|
|
|
});
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-01-29 22:20:18 -07:00
|
|
|
|
|
2016-04-14 09:30:37 -07:00
|
|
|
|
function getTabs() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
href: 'library.html',
|
|
|
|
|
name: Globalize.translate('TabFolders')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: 'librarypathmapping.html',
|
|
|
|
|
name: Globalize.translate('TabPathSubstitution')
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 07:01:59 -07:00
|
|
|
|
$(document).on('pageinit', "#libraryPathMappingPage", function () {
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2016-01-05 09:46:01 -07:00
|
|
|
|
var page = this;
|
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
$('.libraryPathMappingForm').off('submit', onSubmit).on('submit', onSubmit);
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2016-01-05 09:46:01 -07:00
|
|
|
|
page.querySelector('.labelFromHelp').innerHTML = Globalize.translate('LabelFromHelp', 'D:\\Movies');
|
|
|
|
|
|
2015-09-24 10:08:10 -07:00
|
|
|
|
}).on('pageshow', "#libraryPathMappingPage", function () {
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2016-04-14 09:30:37 -07:00
|
|
|
|
LibraryMenu.setTabs('librarysetup', 1, getTabs);
|
2015-06-08 14:32:20 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
var page = this;
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-12-14 08:43:03 -07:00
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
loadPage(page, config);
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
});
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-06-20 17:49:42 -07:00
|
|
|
|
}).on('pagebeforehide', "#libraryPathMappingPage", function () {
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
currentConfig = null;
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2015-06-08 14:32:20 -07:00
|
|
|
|
});
|
2014-01-29 13:57:17 -07:00
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|