From 7b168608a06d4fe48171b8b054d008518bce70ea Mon Sep 17 00:00:00 2001 From: dkanada Date: Mon, 12 Oct 2020 12:29:57 +0900 Subject: [PATCH] add library scan button to dashboard --- src/controllers/dashboard/dashboard.html | 3 +++ src/controllers/dashboard/dashboard.js | 15 +++++++++++++++ src/scripts/taskbutton.js | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/controllers/dashboard/dashboard.html b/src/controllers/dashboard/dashboard.html index ec0d60a74d..4c20da8de5 100644 --- a/src/controllers/dashboard/dashboard.html +++ b/src/controllers/dashboard/dashboard.html @@ -22,6 +22,9 @@ +
diff --git a/src/controllers/dashboard/dashboard.js b/src/controllers/dashboard/dashboard.js index 2078e0af8f..855ce3ff03 100644 --- a/src/controllers/dashboard/dashboard.js +++ b/src/controllers/dashboard/dashboard.js @@ -3,6 +3,7 @@ import events from 'events'; import itemHelper from 'itemHelper'; import serverNotifications from 'serverNotifications'; import dom from 'dom'; +import taskButton from 'scripts/taskbutton'; import globalize from 'globalize'; import * as datefns from 'date-fns'; import dfnshelper from 'dfnshelper'; @@ -827,9 +828,17 @@ import 'emby-itemscontainer'; refreshActiveRecordings(view, apiClient); loading.hide(); } + + taskButton({ + mode: 'on', + taskKey: 'RefreshLibrary', + button: page.querySelector('.btnRefresh') + }); }); view.addEventListener('viewbeforehide', function () { const apiClient = ApiClient; + const page = this; + events.off(serverNotifications, 'RestartRequired', onRestartRequired); events.off(serverNotifications, 'ServerShuttingDown', onServerShuttingDown); events.off(serverNotifications, 'ServerRestarting', onServerRestarting); @@ -841,6 +850,12 @@ import 'emby-itemscontainer'; if (apiClient) { DashboardPage.stopInterval(apiClient); } + + taskButton({ + mode: 'off', + taskKey: 'RefreshLibrary', + button: page.querySelector('.btnRefresh') + }); }); view.addEventListener('viewdestroy', function () { const page = this; diff --git a/src/scripts/taskbutton.js b/src/scripts/taskbutton.js index 163bcb5a1c..43a46301aa 100644 --- a/src/scripts/taskbutton.js +++ b/src/scripts/taskbutton.js @@ -13,7 +13,7 @@ export default function (options) { function updateTasks(tasks) { const task = tasks.filter(function (t) { - return t.ScheduledTask.Key == options.taskKey; + return t.Key == options.taskKey; })[0]; if (options.panel) {