mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
simplify repository save and add attribute
This commit is contained in:
parent
03b4976237
commit
bfc3e20df4
2 changed files with 7 additions and 20 deletions
|
@ -12,17 +12,6 @@ let repositories = [];
|
||||||
|
|
||||||
function reloadList(page) {
|
function reloadList(page) {
|
||||||
loading.show();
|
loading.show();
|
||||||
|
|
||||||
if (repositories.length) {
|
|
||||||
populateList({
|
|
||||||
listElement: page.querySelector('#repositories'),
|
|
||||||
noneElement: page.querySelector('#none'),
|
|
||||||
repositories: repositories
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(list => {
|
ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(list => {
|
||||||
repositories = list;
|
repositories = list;
|
||||||
populateList({
|
populateList({
|
||||||
|
@ -37,13 +26,15 @@ function reloadList(page) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveList() {
|
function saveList(page) {
|
||||||
loading.show();
|
loading.show();
|
||||||
ApiClient.ajax({
|
ApiClient.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: ApiClient.getUrl('Repositories'),
|
url: ApiClient.getUrl('Repositories'),
|
||||||
data: JSON.stringify(repositories),
|
data: JSON.stringify(repositories),
|
||||||
contentType: 'application/json'
|
contentType: 'application/json'
|
||||||
|
}).then(response => {
|
||||||
|
reloadList(page);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
console.error('error saving repositories');
|
console.error('error saving repositories');
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
@ -109,8 +100,7 @@ export default function(view, params) {
|
||||||
return r.Url !== button.id;
|
return r.Url !== button.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
saveList();
|
saveList(save);
|
||||||
reloadList(save);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -130,11 +120,11 @@ export default function(view, params) {
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<form class="newPluginForm" style="margin:4em">';
|
html += '<form class="newPluginForm" style="margin:4em">';
|
||||||
html += '<div class="inputContainer">';
|
html += '<div class="inputContainer">';
|
||||||
html += `<input is="emby-input" type="text" id="txtRepositoryName" label="${globalize.translate('LabelRepositoryName')}" />`;
|
html += `<input is="emby-input" id="txtRepositoryName" label="${globalize.translate('LabelRepositoryName')}" type="text" required />`;
|
||||||
html += `<div class="fieldDescription">${globalize.translate('LabelRepositoryNameHelp')}</div>`;
|
html += `<div class="fieldDescription">${globalize.translate('LabelRepositoryNameHelp')}</div>`;
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += '<div class="inputContainer">';
|
html += '<div class="inputContainer">';
|
||||||
html += `<input is="emby-input" type="url" id="txtRepositoryUrl" label="${globalize.translate('LabelRepositoryUrl')}" />`;
|
html += `<input is="emby-input" id="txtRepositoryUrl" label="${globalize.translate('LabelRepositoryUrl')}" type="url" required />`;
|
||||||
html += `<div class="fieldDescription">${globalize.translate('LabelRepositoryUrlHelp')}</div>`;
|
html += `<div class="fieldDescription">${globalize.translate('LabelRepositoryUrlHelp')}</div>`;
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
html += `<button is="emby-button" type="submit" class="raised button-submit block"><span>${globalize.translate('ButtonSave')}</span></button>`;
|
html += `<button is="emby-button" type="submit" class="raised button-submit block"><span>${globalize.translate('ButtonSave')}</span></button>`;
|
||||||
|
@ -153,8 +143,7 @@ export default function(view, params) {
|
||||||
Enabled: true
|
Enabled: true
|
||||||
});
|
});
|
||||||
|
|
||||||
saveList();
|
saveList(view);
|
||||||
reloadList(view);
|
|
||||||
dialogHelper.close(dialog);
|
dialogHelper.close(dialog);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -109,9 +109,7 @@ define(['layoutManager', 'browser', 'dom', 'css!./emby-input', 'registerElement'
|
||||||
}
|
}
|
||||||
|
|
||||||
EmbyInputPrototype.attachedCallback = function () {
|
EmbyInputPrototype.attachedCallback = function () {
|
||||||
|
|
||||||
this.labelElement.htmlFor = this.id;
|
this.labelElement.htmlFor = this.id;
|
||||||
|
|
||||||
onChange.call(this);
|
onChange.call(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue