From 75504ec8e489aa7c02b094beb903a0dc21333a3c Mon Sep 17 00:00:00 2001 From: dkanada Date: Wed, 10 Jun 2020 21:33:08 +0900 Subject: [PATCH 1/7] initial work for repository configuration --- package.json | 1 + .../dashboard/plugins/available.js | 3 + .../dashboard/plugins/installed.js | 3 + .../dashboard/plugins/repositories.js | 135 ++++++++++++++++++ src/repositories.html | 19 +++ src/scripts/routes.js | 6 + src/strings/en-us.json | 7 + 7 files changed, 174 insertions(+) create mode 100644 src/controllers/dashboard/plugins/repositories.js create mode 100644 src/repositories.html diff --git a/package.json b/package.json index 91d070e04d..33735f46df 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "src/components/syncPlay/syncPlayManager.js", "src/components/syncPlay/timeSyncManager.js", "src/controllers/dashboard/logs.js", + "src/controllers/dashboard/plugins/repositories.js", "src/plugins/bookPlayer/plugin.js", "src/plugins/bookPlayer/tableOfContents.js", "src/plugins/photoPlayer/plugin.js", diff --git a/src/controllers/dashboard/plugins/available.js b/src/controllers/dashboard/plugins/available.js index 82fea00b58..37df8801b5 100644 --- a/src/controllers/dashboard/plugins/available.js +++ b/src/controllers/dashboard/plugins/available.js @@ -123,6 +123,9 @@ define(['loading', 'libraryMenu', 'globalize', 'cardStyle', 'emby-button', 'emby }, { href: 'availableplugins.html', name: globalize.translate('TabCatalog') + }, { + href: 'repositories.html', + name: globalize.translate('TabRepositories') }]; } diff --git a/src/controllers/dashboard/plugins/installed.js b/src/controllers/dashboard/plugins/installed.js index 87e9428cc6..f03312b422 100644 --- a/src/controllers/dashboard/plugins/installed.js +++ b/src/controllers/dashboard/plugins/installed.js @@ -153,6 +153,9 @@ define(['loading', 'libraryMenu', 'dom', 'globalize', 'cardStyle', 'emby-button' }, { href: 'availableplugins.html', name: globalize.translate('TabCatalog') + }, { + href: 'repositories.html', + name: globalize.translate('TabRepositories') }]; } diff --git a/src/controllers/dashboard/plugins/repositories.js b/src/controllers/dashboard/plugins/repositories.js new file mode 100644 index 0000000000..7e8b711b37 --- /dev/null +++ b/src/controllers/dashboard/plugins/repositories.js @@ -0,0 +1,135 @@ +import loading from 'loading'; +import libraryMenu from 'libraryMenu'; +import globalize from 'globalize'; +import dialogHelper from 'dialogHelper'; +import 'emby-button'; +import 'emby-checkbox'; +import 'emby-select'; +import 'cardStyle'; +import 'formDialogStyle'; + +let repositories = []; + +function reloadList(page) { + loading.show(); + ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(repositories => { + this.repositories = repositories; + populateList({ + listElement: page.querySelector('#repositories'), + noneElement: page.querySelector('#none'), + repositories: this.repositories + }); + }).catch(error => { + page.querySelector('#none').classList.remove('hide'); + loading.hide(); + }); +} + +function saveList() { + loading.show(); + ApiClient.ajax({ + type: 'POST', + url: ApiClient.getUrl('Repositories'), + data: JSON.stringify(repositories), + contentType: 'application/json' + }).catch(error => { + loading.hide(); + }); +} + +function populateList(options) { + var html = ''; + + html += '
'; + for (var i = 0; i < options.repositories.length; i++) { + html += getRepositoryHtml(options.repositories[i]); + } + + html += '
'; + if (!options.repositories.length) { + options.noneElement.classList.remove('hide'); + } + + options.listElement.innerHTML = html; + loading.hide(); +} + +function getRepositoryHtml(repository) { + var html = ''; + + html += ``; + html += '
'; + html += `

${repository.Name}

`; + html += `
${repository.Url}
`; + html += '
'; + html += '
'; + + return html; +} + +function getTabs() { + return [{ + href: 'installedplugins.html', + name: globalize.translate('TabMyPlugins') + }, { + href: 'availableplugins.html', + name: globalize.translate('TabCatalog') + }, { + href: 'repositories.html', + name: globalize.translate('TabRepositories') + }]; +} + +export default function(view, params) { + view.addEventListener('viewshow', function () { + libraryMenu.setTabs('plugins', 2, getTabs); + reloadList(this); + }); + + view.querySelector('.btnNewRepository').addEventListener('click', () => { + let dialog = dialogHelper.createDialog({ + scrollY: false, + size: 'large', + modal: false, + removeOnClose: true + }); + + let html = ''; + + html += '
'; + html += ''; + html += `

${globalize.translate('HeaderNewRepository')}

`; + html += '
'; + html += '
'; + html += '
'; + html += ``; + html += `
${globalize.translate('LabelRepositoryNameHelp')}
`; + html += '
'; + html += '
'; + html += ``; + html += `
${globalize.translate('LabelRepositoryUrlHelp')}
`; + html += '
'; + html += ``; + html += ''; + html += '
'; + + dialog.innerHTML = html; + dialog.querySelector('.btnCancel').addEventListener('click', () => { + dialogHelper.close(dialog); + }); + + dialog.querySelector('.button-submit').addEventListener('click', () => { + repositories.push({ + Name: dialog.querySelector('#txtRepositoryName').value, + Url: dialog.querySelector('#txtRepositoryUrl').value, + Enabled: true + }); + + saveList(); + reloadList(view); + dialogHelper.close(dialog); + }); + + dialogHelper.open(dialog); + }); +} diff --git a/src/repositories.html b/src/repositories.html new file mode 100644 index 0000000000..e119e753dc --- /dev/null +++ b/src/repositories.html @@ -0,0 +1,19 @@ +
+
+
+
+

${TabRepositories}

+ +
+ +
+ +
+

${MessageNoRepositories}

+

${MessagePleaseEnsureInternetMetadata}

+
+
+
+
diff --git a/src/scripts/routes.js b/src/scripts/routes.js index 6f13711b66..b5bb04683b 100644 --- a/src/scripts/routes.js +++ b/src/scripts/routes.js @@ -215,6 +215,12 @@ define([ roles: 'admin', controller: 'dashboard/plugins/available' }); + defineRoute({ + path: '/repositories.html', + autoFocus: false, + roles: 'admin', + controller: 'dashboard/plugins/repositories' + }); defineRoute({ path: '/home.html', diff --git a/src/strings/en-us.json b/src/strings/en-us.json index b8e081a588..0a6fc9aa9e 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1023,6 +1023,12 @@ "MessageItemsAdded": "Items added.", "MessageLeaveEmptyToInherit": "Leave empty to inherit settings from a parent item or the global default value.", "MessageNoAvailablePlugins": "No available plugins.", + "MessageNoRepositories": "No repositories.", + "HeaderNewRepository": "New Repository", + "LabelRepositoryUrl": "Repository URL", + "LabelRepositoryUrlHelp": "The location of the repository manifest you want to include.", + "LabelRepositoryName": "Repository Name", + "LabelRepositoryNameHelp": "A custom name to distinguish this repository from any others added to your server.", "MessageNoCollectionsAvailable": "Collections allow you to enjoy personalized groupings of Movies, Series, and Albums. Click the + button to start creating collections.", "MessageNoGenresAvailable": "Enable some metadata providers to pull genres from the internet.", "MessageNoMovieSuggestionsAvailable": "No movie suggestions are currently available. Start watching and rating your movies, and then come back to view your recommendations.", @@ -1415,6 +1421,7 @@ "TabAlbums": "Albums", "TabArtists": "Artists", "TabCatalog": "Catalog", + "TabRepositories": "Repositories", "TabChannels": "Channels", "TabCodecs": "Codecs", "TabCollections": "Collections", From 9e2e2a3438efaac1f4b332eb2735849520719679 Mon Sep 17 00:00:00 2001 From: dkanada Date: Thu, 11 Jun 2020 03:02:38 +0900 Subject: [PATCH 2/7] add delete button and fix some variable issues --- .../dashboard/plugins/repositories.js | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/controllers/dashboard/plugins/repositories.js b/src/controllers/dashboard/plugins/repositories.js index 7e8b711b37..cfb71284b6 100644 --- a/src/controllers/dashboard/plugins/repositories.js +++ b/src/controllers/dashboard/plugins/repositories.js @@ -5,19 +5,19 @@ import dialogHelper from 'dialogHelper'; import 'emby-button'; import 'emby-checkbox'; import 'emby-select'; -import 'cardStyle'; import 'formDialogStyle'; +import 'listViewStyle'; let repositories = []; function reloadList(page) { loading.show(); - ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(repositories => { - this.repositories = repositories; + ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(list => { + repositories = list; populateList({ listElement: page.querySelector('#repositories'), noneElement: page.querySelector('#none'), - repositories: this.repositories + repositories: repositories }); }).catch(error => { page.querySelector('#none').classList.remove('hide'); @@ -57,12 +57,15 @@ function populateList(options) { function getRepositoryHtml(repository) { var html = ''; - html += ``; + html += ''; + html += ``; + html += ''; return html; } @@ -84,6 +87,13 @@ export default function(view, params) { view.addEventListener('viewshow', function () { libraryMenu.setTabs('plugins', 2, getTabs); reloadList(this); + + var save = this; + $('#repositories', view).on('click', '.btnDelete', function() { + repositories = repositories.splice(repositories.indexOf(this.id), 1); + saveList(); + reloadList(save); + }); }); view.querySelector('.btnNewRepository').addEventListener('click', () => { @@ -100,7 +110,7 @@ export default function(view, params) { html += ''; html += `

${globalize.translate('HeaderNewRepository')}

`; html += ''; - html += '
'; + html += ''; html += '
'; html += ``; html += `
${globalize.translate('LabelRepositoryNameHelp')}
`; @@ -118,7 +128,7 @@ export default function(view, params) { dialogHelper.close(dialog); }); - dialog.querySelector('.button-submit').addEventListener('click', () => { + dialog.querySelector('.newPluginForm').addEventListener('submit', () => { repositories.push({ Name: dialog.querySelector('#txtRepositoryName').value, Url: dialog.querySelector('#txtRepositoryUrl').value, From 08fb42155d0fbba9989cfb98a447eb5ef35eb03b Mon Sep 17 00:00:00 2001 From: dkanada Date: Thu, 11 Jun 2020 19:34:06 +0900 Subject: [PATCH 3/7] fix repository deletion and some css issues --- src/components/dialog/dialog.template.html | 8 ++---- src/components/formdialog.css | 2 +- .../metadataEditor/personEditor.template.html | 3 +-- src/components/prompt/prompt.template.html | 3 +-- .../dashboard/plugins/installed.js | 2 +- .../dashboard/plugins/repositories.js | 25 ++++++++++++++++--- src/repositories.html | 2 +- src/strings/en-us.json | 1 + 8 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/components/dialog/dialog.template.html b/src/components/dialog/dialog.template.html index bee0ef7f73..6d4310c0f4 100644 --- a/src/components/dialog/dialog.template.html +++ b/src/components/dialog/dialog.template.html @@ -4,12 +4,8 @@
- -
- -
+
-
-
+
diff --git a/src/components/formdialog.css b/src/components/formdialog.css index 94695f4865..d7cb162e8c 100644 --- a/src/components/formdialog.css +++ b/src/components/formdialog.css @@ -55,7 +55,7 @@ /* Without this emby-checkbox is able to appear on top */ z-index: 1; align-items: flex-end; - justify-content: flex-end; + justify-content: center; flex-wrap: wrap; } diff --git a/src/components/metadataEditor/personEditor.template.html b/src/components/metadataEditor/personEditor.template.html index 40b29767fa..d2ad6a78d2 100644 --- a/src/components/metadataEditor/personEditor.template.html +++ b/src/components/metadataEditor/personEditor.template.html @@ -7,7 +7,6 @@
-
@@ -23,6 +22,7 @@
+
${LabelPersonRoleHelp}
@@ -33,6 +33,5 @@ ${Save}
-
diff --git a/src/components/prompt/prompt.template.html b/src/components/prompt/prompt.template.html index 981fa9f102..a07629ae7e 100644 --- a/src/components/prompt/prompt.template.html +++ b/src/components/prompt/prompt.template.html @@ -2,12 +2,12 @@ +

-
@@ -19,7 +19,6 @@
-
diff --git a/src/controllers/dashboard/plugins/installed.js b/src/controllers/dashboard/plugins/installed.js index f03312b422..eb521c2fd6 100644 --- a/src/controllers/dashboard/plugins/installed.js +++ b/src/controllers/dashboard/plugins/installed.js @@ -41,7 +41,7 @@ define(['loading', 'libraryMenu', 'dom', 'globalize', 'cardStyle', 'emby-button' html += '
'; html += '
'; html += '
'; - html += configPageUrl ? '' : ''; diff --git a/src/controllers/dashboard/plugins/repositories.js b/src/controllers/dashboard/plugins/repositories.js index cfb71284b6..3b87dc17ce 100644 --- a/src/controllers/dashboard/plugins/repositories.js +++ b/src/controllers/dashboard/plugins/repositories.js @@ -12,6 +12,17 @@ let repositories = []; function reloadList(page) { loading.show(); + + if (repositories.length) { + populateList({ + listElement: page.querySelector('#repositories'), + noneElement: page.querySelector('#none'), + repositories: repositories + }); + + return; + } + ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(list => { repositories = list; populateList({ @@ -20,6 +31,7 @@ function reloadList(page) { repositories: repositories }); }).catch(error => { + console.error('error loading repositories'); page.querySelector('#none').classList.remove('hide'); loading.hide(); }); @@ -33,6 +45,7 @@ function saveList() { data: JSON.stringify(repositories), contentType: 'application/json' }).catch(error => { + console.error('error saving repositories'); loading.hide(); }); } @@ -58,11 +71,12 @@ function getRepositoryHtml(repository) { var html = ''; html += '
'; + html += ``; + html += ''; + html += ''; html += ''; html += ``; html += '
'; @@ -90,7 +104,11 @@ export default function(view, params) { var save = this; $('#repositories', view).on('click', '.btnDelete', function() { - repositories = repositories.splice(repositories.indexOf(this.id), 1); + var button = this; + repositories = repositories.filter(function (r) { + return r.Url !== button.id; + }); + saveList(); reloadList(save); }); @@ -138,6 +156,7 @@ export default function(view, params) { saveList(); reloadList(view); dialogHelper.close(dialog); + return false; }); dialogHelper.open(dialog); diff --git a/src/repositories.html b/src/repositories.html index e119e753dc..ff3406fb95 100644 --- a/src/repositories.html +++ b/src/repositories.html @@ -12,7 +12,7 @@

${MessageNoRepositories}

-

${MessagePleaseEnsureInternetMetadata}

+

${MessageAddRepository}

diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 0a6fc9aa9e..06f66051dc 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1029,6 +1029,7 @@ "LabelRepositoryUrlHelp": "The location of the repository manifest you want to include.", "LabelRepositoryName": "Repository Name", "LabelRepositoryNameHelp": "A custom name to distinguish this repository from any others added to your server.", + "MessageAddRepository": "If you wish to add a repository, click the button next to the header and fill out the requested information.", "MessageNoCollectionsAvailable": "Collections allow you to enjoy personalized groupings of Movies, Series, and Albums. Click the + button to start creating collections.", "MessageNoGenresAvailable": "Enable some metadata providers to pull genres from the internet.", "MessageNoMovieSuggestionsAvailable": "No movie suggestions are currently available. Start watching and rating your movies, and then come back to view your recommendations.", From d822bc12b60fbd1bc0565665e677381cc310263f Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 16 Jun 2020 00:32:23 +0900 Subject: [PATCH 4/7] minor style improvements --- src/assets/css/site.css | 5 +++++ src/controllers/itemDetails.js | 17 ++++++++--------- src/itemdetails.html | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/assets/css/site.css b/src/assets/css/site.css index d489f77f01..9fbd8a4fca 100644 --- a/src/assets/css/site.css +++ b/src/assets/css/site.css @@ -121,6 +121,11 @@ div[data-role=page] { transform: translateY(-100%); } +.drawerContent { + /* make sure the bottom of the drawer is visible when music is playing */ + padding-bottom: 4em; +} + .force-scroll { overflow-y: scroll; } diff --git a/src/controllers/itemDetails.js b/src/controllers/itemDetails.js index cbb8a1b43e..a73515746f 100644 --- a/src/controllers/itemDetails.js +++ b/src/controllers/itemDetails.js @@ -400,6 +400,7 @@ define(['loading', 'appRouter', 'layoutManager', 'connectionManager', 'userSetti } else if (item.Album) { parentNameHtml.push(item.Album); } + // FIXME: This whole section needs some refactoring, so it becames easier to scale across all form factors. See GH #1022 var html = ''; var tvShowHtml = parentNameHtml[0]; @@ -415,9 +416,9 @@ define(['loading', 'appRouter', 'layoutManager', 'connectionManager', 'userSetti } } else { if (layoutManager.mobile) { - html = '

' + parentNameHtml.join('
') + '

'; + html = '

' + parentNameHtml.join('
') + '

'; } else { - html = '

' + tvShowHtml + '

'; + html = '

' + tvShowHtml + '

'; } } } @@ -425,20 +426,19 @@ define(['loading', 'appRouter', 'layoutManager', 'connectionManager', 'userSetti var name = itemHelper.getDisplayName(item, { includeParentInfo: false }); - var offset = parentNameLast ? '.25em' : '.5em'; if (html && !parentNameLast) { if (!layoutManager.mobile && tvSeasonHtml) { - html += '

' + tvSeasonHtml + ' - ' + name + '

'; + html += '

' + tvSeasonHtml + ' - ' + name + '

'; } else { - html += '

' + name + '

'; + html += '

' + name + '

'; } } else { - html = '

' + name + '

' + html; + html = '

' + name + '

' + html; } if (item.OriginalTitle && item.OriginalTitle != item.Name) { - html += '

' + item.OriginalTitle + '

'; + html += '

' + item.OriginalTitle + '

'; } container.innerHTML = html; @@ -1106,10 +1106,10 @@ define(['loading', 'appRouter', 'layoutManager', 'connectionManager', 'userSetti var externalLinksElem = page.querySelector('.itemExternalLinks'); renderOverview([overview], item); + var i; var itemMiscInfo; itemMiscInfo = page.querySelectorAll('.itemMiscInfo-primary'); - for (i = 0; i < itemMiscInfo.length; i++) { mediaInfo.fillPrimaryMediaInfo(itemMiscInfo[i], item, { interactive: true, @@ -1125,7 +1125,6 @@ define(['loading', 'appRouter', 'layoutManager', 'connectionManager', 'userSetti } itemMiscInfo = page.querySelectorAll('.itemMiscInfo-secondary'); - for (i = 0; i < itemMiscInfo.length; i++) { mediaInfo.fillSecondaryMediaInfo(itemMiscInfo[i], item, { interactive: true diff --git a/src/itemdetails.html b/src/itemdetails.html index 18de25845c..acfc6044b4 100644 --- a/src/itemdetails.html +++ b/src/itemdetails.html @@ -10,8 +10,8 @@
-
-
+
+
From 03b497623712d769654a9fb42f4cba4f79fcbe08 Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 16 Jun 2020 14:58:08 +0900 Subject: [PATCH 5/7] fix error with margin property --- src/itemdetails.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/itemdetails.html b/src/itemdetails.html index acfc6044b4..44ca561d40 100644 --- a/src/itemdetails.html +++ b/src/itemdetails.html @@ -11,7 +11,7 @@
-
+
From bfc3e20df4c023b1aa1cda6a218224284dcd1598 Mon Sep 17 00:00:00 2001 From: dkanada Date: Tue, 16 Jun 2020 21:13:07 +0900 Subject: [PATCH 6/7] simplify repository save and add attribute --- .../dashboard/plugins/repositories.js | 25 ++++++------------- src/elements/emby-input/emby-input.js | 2 -- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/controllers/dashboard/plugins/repositories.js b/src/controllers/dashboard/plugins/repositories.js index 3b87dc17ce..a4d6d886e0 100644 --- a/src/controllers/dashboard/plugins/repositories.js +++ b/src/controllers/dashboard/plugins/repositories.js @@ -12,17 +12,6 @@ let repositories = []; function reloadList(page) { loading.show(); - - if (repositories.length) { - populateList({ - listElement: page.querySelector('#repositories'), - noneElement: page.querySelector('#none'), - repositories: repositories - }); - - return; - } - ApiClient.getJSON(ApiClient.getUrl('Repositories')).then(list => { repositories = list; populateList({ @@ -37,13 +26,15 @@ function reloadList(page) { }); } -function saveList() { +function saveList(page) { loading.show(); ApiClient.ajax({ type: 'POST', url: ApiClient.getUrl('Repositories'), data: JSON.stringify(repositories), contentType: 'application/json' + }).then(response => { + reloadList(page); }).catch(error => { console.error('error saving repositories'); loading.hide(); @@ -109,8 +100,7 @@ export default function(view, params) { return r.Url !== button.id; }); - saveList(); - reloadList(save); + saveList(save); }); }); @@ -130,11 +120,11 @@ export default function(view, params) { html += '
'; html += '
'; html += '
'; - html += ``; + html += ``; html += `
${globalize.translate('LabelRepositoryNameHelp')}
`; html += '
'; html += '
'; - html += ``; + html += ``; html += `
${globalize.translate('LabelRepositoryUrlHelp')}
`; html += '
'; html += ``; @@ -153,8 +143,7 @@ export default function(view, params) { Enabled: true }); - saveList(); - reloadList(view); + saveList(view); dialogHelper.close(dialog); return false; }); diff --git a/src/elements/emby-input/emby-input.js b/src/elements/emby-input/emby-input.js index 03ba2b93aa..1cef349bf0 100644 --- a/src/elements/emby-input/emby-input.js +++ b/src/elements/emby-input/emby-input.js @@ -109,9 +109,7 @@ define(['layoutManager', 'browser', 'dom', 'css!./emby-input', 'registerElement' } EmbyInputPrototype.attachedCallback = function () { - this.labelElement.htmlFor = this.id; - onChange.call(this); }; From ce6708781166265dad2a7bf86cba2bf016d9276a Mon Sep 17 00:00:00 2001 From: dkanada Date: Wed, 17 Jun 2020 02:15:05 +0900 Subject: [PATCH 7/7] fix quotes in repository controller --- src/controllers/dashboard/plugins/repositories.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/dashboard/plugins/repositories.js b/src/controllers/dashboard/plugins/repositories.js index a4d6d886e0..3087cdd927 100644 --- a/src/controllers/dashboard/plugins/repositories.js +++ b/src/controllers/dashboard/plugins/repositories.js @@ -66,7 +66,7 @@ function getRepositoryHtml(repository) { html += ''; html += ''; html += '
'; - html += `

${repository.Name}

`; + html += `

${repository.Name}

`; html += `
${repository.Url}
`; html += '
'; html += ``;