From d7533bac5767df6ffa61756ac12887be2a9eeca7 Mon Sep 17 00:00:00 2001 From: LASER-Yi Date: Mon, 16 Aug 2021 00:10:38 +0800 Subject: [PATCH] Add a new notification center to the UI --- bazarr/get_episodes.py | 6 - bazarr/get_movies.py | 8 +- bazarr/get_series.py | 6 - bazarr/get_subtitle.py | 38 ---- bazarr/list_subtitles.py | 12 -- frontend/src/@redux/actions/site.ts | 9 +- frontend/src/@redux/reducers/site.ts | 4 +- frontend/src/@socketio/reducer.ts | 4 +- frontend/src/App/Header.tsx | 6 +- frontend/src/App/Notification.tsx | 225 ++++++++++++++++++++++ frontend/src/App/index.tsx | 2 - frontend/src/App/notification.scss | 43 +++++ frontend/src/App/notifications/index.tsx | 118 ------------ frontend/src/App/notifications/style.scss | 46 ----- frontend/src/utilites/hooks.ts | 15 +- 15 files changed, 295 insertions(+), 247 deletions(-) create mode 100644 frontend/src/App/Notification.tsx create mode 100644 frontend/src/App/notification.scss delete mode 100644 frontend/src/App/notifications/index.tsx delete mode 100644 frontend/src/App/notifications/style.scss diff --git a/bazarr/get_episodes.py b/bazarr/get_episodes.py index f26c2f545..48d570a35 100644 --- a/bazarr/get_episodes.py +++ b/bazarr/get_episodes.py @@ -85,12 +85,6 @@ def sync_episodes(series_id=None, send_event=True): episodes_to_add.append(episodeParser(episode)) if send_event: - show_progress(id='episodes_progress', - header='Syncing episodes...', - name='Completed successfully', - value=series_count, - count=series_count) - hide_progress(id='episodes_progress') # Remove old episodes from DB diff --git a/bazarr/get_movies.py b/bazarr/get_movies.py index 322a948a5..95ff5b60d 100644 --- a/bazarr/get_movies.py +++ b/bazarr/get_movies.py @@ -88,14 +88,8 @@ def update_movies(send_event=True): tags_dict=tagsDict, movie_default_profile=movie_default_profile, audio_profiles=audio_profiles)) - + if send_event: - show_progress(id='movies_progress', - header='Syncing movies...', - name='Completed successfully', - value=movies_count, - count=movies_count) - hide_progress(id='movies_progress') # Remove old movies from DB diff --git a/bazarr/get_series.py b/bazarr/get_series.py index 0f3165dfa..9af7bb49b 100644 --- a/bazarr/get_series.py +++ b/bazarr/get_series.py @@ -72,12 +72,6 @@ def update_series(send_event=True): audio_profiles=audio_profiles)) if send_event: - show_progress(id='series_progress', - header='Syncing series...', - name='Completed successfully', - value=series_count, - count=series_count) - hide_progress(id='series_progress') # Remove old series from DB diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 07363606d..ceac880b6 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -796,13 +796,6 @@ def series_download_subtitles(no): logging.info("BAZARR All providers are throttled") break - if count_episodes_details: - show_progress(id='series_search_progress_{}'.format(no), - header='Searching missing subtitles...', - name='Completed successfully', - value=count_episodes_details, - count=count_episodes_details) - hide_progress(id='series_search_progress_{}'.format(no)) @@ -975,13 +968,6 @@ def movies_download_subtitles(no): logging.info("BAZARR All providers are throttled") break - if count_movie: - show_progress(id='movie_search_progress_{}'.format(no), - header='Searching missing subtitles...', - name='Completed successfully', - value=count_movie, - count=count_movie) - hide_progress(id='movie_search_progress_{}'.format(no)) @@ -1189,12 +1175,6 @@ def wanted_search_missing_subtitles_series(): logging.info("BAZARR All providers are throttled") return - show_progress(id='wanted_episodes_progress', - header='Searching subtitles...', - name='Completed successfully', - value=count_episodes, - count=count_episodes) - hide_progress(id='wanted_episodes_progress') logging.info('BAZARR Finished searching for missing Series Subtitles. Check History for more information.') @@ -1226,12 +1206,6 @@ def wanted_search_missing_subtitles_movies(): logging.info("BAZARR All providers are throttled") return - show_progress(id='wanted_movies_progress', - header='Searching subtitles...', - name='Completed successfully', - value=count_movies, - count=count_movies) - hide_progress(id='wanted_movies_progress') logging.info('BAZARR Finished searching for missing Movies Subtitles. Check History for more information.') @@ -1559,12 +1533,6 @@ def upgrade_subtitles(): language_code, provider, score, subs_id, subs_path) send_notifications(episode['sonarrSeriesId'], episode['sonarrEpisodeId'], message) - show_progress(id='upgrade_episodes_progress', - header='Upgrading episodes subtitles...', - name='Completed successfully', - value=count_episode_to_upgrade, - count=count_episode_to_upgrade) - hide_progress(id='upgrade_episodes_progress') if settings.general.getboolean('use_radarr'): @@ -1632,12 +1600,6 @@ def upgrade_subtitles(): history_log_movie(3, movie['radarrId'], message, path, language_code, provider, score, subs_id, subs_path) send_notifications_movie(movie['radarrId'], message) - show_progress(id='upgrade_movies_progress', - header='Upgrading movies subtitles...', - name='Completed successfully', - value=count_movie_to_upgrade, - count=count_movie_to_upgrade) - hide_progress(id='upgrade_movies_progress') logging.info('BAZARR Finished searching for Subtitles to upgrade. Check History for more information.') diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index 1c09ee56b..7d4c31e81 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -458,12 +458,6 @@ def series_full_scan_subtitles(): count=count_episodes) store_subtitles(episode['path'], path_mappings.path_replace(episode['path'])) - show_progress(id='episodes_disk_scan', - header='Full disk scan...', - name='Completed successfully', - value=count_episodes, - count=count_episodes) - hide_progress(id='episodes_disk_scan') gc.collect() @@ -482,12 +476,6 @@ def movies_full_scan_subtitles(): count=count_movies) store_subtitles_movie(movie['path'], path_mappings.path_replace_movie(movie['path'])) - show_progress(id='movies_disk_scan', - header='Full disk scan...', - name='Completed successfully', - value=count_movies, - count=count_movies) - hide_progress(id='movies_disk_scan') gc.collect() diff --git a/frontend/src/@redux/actions/site.ts b/frontend/src/@redux/actions/site.ts index 1830db391..8fa4cd077 100644 --- a/frontend/src/@redux/actions/site.ts +++ b/frontend/src/@redux/actions/site.ts @@ -26,11 +26,12 @@ export const siteRemoveNotifications = createAction( "site/notifications/remove" ); -export const siteAddProgress = createAction( - "site/progress/add" -); +export const siteAddProgress = + createAction("site/progress/add"); -export const siteRemoveProgress = createAction("site/progress/remove"); +export const siteRemoveProgress = createAction( + "site/progress/remove" +); export const siteChangeSidebar = createAction("site/sidebar/update"); diff --git a/frontend/src/@redux/reducers/site.ts b/frontend/src/@redux/reducers/site.ts index a5dd99f53..54aedc3d0 100644 --- a/frontend/src/@redux/reducers/site.ts +++ b/frontend/src/@redux/reducers/site.ts @@ -1,5 +1,5 @@ import { createReducer } from "@reduxjs/toolkit"; -import { remove, uniqBy } from "lodash"; +import { pullAllWith, remove, uniqBy } from "lodash"; import apis from "../../apis"; import { siteAddNotifications, @@ -73,7 +73,7 @@ const reducer = createReducer(defaultSite, (builder) => { ); }) .addCase(siteRemoveProgress, (state, action) => { - remove(state.progress, (n) => n.id === action.payload); + pullAllWith(state.progress, action.payload, (l, r) => l.id === r); }) .addCase(siteChangeSidebar, (state, action) => { state.sidebar = action.payload; diff --git a/frontend/src/@socketio/reducer.ts b/frontend/src/@socketio/reducer.ts index a2519166d..8ed251a97 100644 --- a/frontend/src/@socketio/reducer.ts +++ b/frontend/src/@socketio/reducer.ts @@ -87,9 +87,7 @@ export function createDefaultReducer(): SocketIO.Reducer[] { update: bindReduxAction(siteAddProgress), delete: (ids) => { setTimeout(() => { - ids.forEach((id) => { - reduxStore.dispatch(siteRemoveProgress(id)); - }); + reduxStore.dispatch(siteRemoveProgress(ids)); }, 3 * 1000); }, }, diff --git a/frontend/src/App/Header.tsx b/frontend/src/App/Header.tsx index f0b1aacc8..06e50f9b7 100644 --- a/frontend/src/App/Header.tsx +++ b/frontend/src/App/Header.tsx @@ -25,6 +25,7 @@ import { SystemApi } from "../apis"; import { ActionButton, SearchBar, SearchResult } from "../components"; import { useGotoHomepage } from "../utilites"; import "./header.scss"; +import NotificationCenter from "./Notification"; async function SearchItem(text: string) { const results = await SystemApi.search(text); @@ -58,7 +59,7 @@ const Header: FunctionComponent = () => { const offline = useIsOffline(); - const dropdown = useMemo( + const serverActions = useMemo( () => ( @@ -117,6 +118,7 @@ const Header: FunctionComponent = () => { +