diff --git a/client/src/components/MainWindow.tsx b/client/src/components/MainWindow.tsx index d3b73f1..539b2ed 100644 --- a/client/src/components/MainWindow.tsx +++ b/client/src/components/MainWindow.tsx @@ -9,6 +9,7 @@ import ArtistWindow from './windows/ArtistWindow'; import AlbumWindow from './windows/AlbumWindow'; import TagWindow from './windows/TagWindow'; import SongWindow from './windows/SongWindow'; +import ManageWindow from './windows/ManageWindow'; var _ = require('lodash'); const darkTheme = createMuiTheme({ @@ -76,6 +77,7 @@ export default function MainWindow(props: any) { newWindowState[WindowType.Album](), newWindowState[WindowType.Artist](), newWindowState[WindowType.Tag](), + newWindowState[WindowType.Manage](), ], tabReducers: [ newWindowReducer[WindowType.Query], @@ -83,6 +85,7 @@ export default function MainWindow(props: any) { newWindowReducer[WindowType.Album], newWindowReducer[WindowType.Artist], newWindowReducer[WindowType.Tag], + newWindowReducer[WindowType.Manage], ], tabTypes: [ WindowType.Query, @@ -90,6 +93,7 @@ export default function MainWindow(props: any) { WindowType.Album, WindowType.Artist, WindowType.Tag, + WindowType.Manage, ], activeTab: 0 }) @@ -134,6 +138,12 @@ export default function MainWindow(props: any) { dispatch={tabDispatch} mainDispatch={dispatch} /> + case WindowType.Manage: + return default: throw new Error("Unimplemented window type"); } diff --git a/client/src/components/windows/ManageWindow.tsx b/client/src/components/windows/ManageWindow.tsx new file mode 100644 index 0000000..5b96980 --- /dev/null +++ b/client/src/components/windows/ManageWindow.tsx @@ -0,0 +1,96 @@ +import React from 'react'; +import * as serverApi from '../../api'; +import { WindowState } from './Windows'; +import { Box, Button, Dialog, DialogTitle, DialogContent, CircularProgress } from '@material-ui/core'; +var _ = require('lodash'); + +export enum ClearDBState { + None = 0, + Confirming, + Executing, +} + +export interface ManageWindowState extends WindowState { + clearDBState: ClearDBState, +} + +export enum ManageWindowStateActions { + SetClearDBState = "SetClearDBState", +} + +export function ManageWindowReducer(state: ManageWindowState, action: any) { + switch (action.type) { + case ManageWindowStateActions.SetClearDBState: + return { ...state, clearDBState: action.value } + default: + throw new Error("Unimplemented ManageWindow state update.") + } +} + +export interface IProps { + state: ManageWindowState, + dispatch: (action: any) => void, + mainDispatch: (action: any) => void, +} + +export default function ManageWindow(props: IProps) { + const startClearDB = () => { + props.dispatch({ + type: ManageWindowStateActions.SetClearDBState, + value: ClearDBState.Executing, + }) + } + + return <> + + + + + + + Are you sure? + + + Clearing the database cannot be undone. All music information will be lost. + + + + + + + + + + + + + Clearing Database + + + + + +} diff --git a/client/src/components/windows/Windows.tsx b/client/src/components/windows/Windows.tsx index d5840e5..70cf4d7 100644 --- a/client/src/components/windows/Windows.tsx +++ b/client/src/components/windows/Windows.tsx @@ -6,10 +6,12 @@ import PersonIcon from '@material-ui/icons/Person'; import AlbumIcon from '@material-ui/icons/Album'; import LocalOfferIcon from '@material-ui/icons/LocalOffer'; import AudiotrackIcon from '@material-ui/icons/Audiotrack'; +import SettingsIcon from '@material-ui/icons/Settings'; import { SongWindowReducer } from './SongWindow'; import { AlbumWindowReducer } from './AlbumWindow'; import { TagWindowReducer } from './TagWindow'; import { songGetters } from '../../lib/songGetters'; +import { ManageWindowReducer, ClearDBState } from './ManageWindow'; export enum WindowType { Query = "Query", @@ -17,6 +19,7 @@ export enum WindowType { Album = "Album", Tag = "Tag", Song = "Song", + Manage = "Manage", } export interface WindowState { @@ -29,6 +32,7 @@ export const newWindowReducer = { [WindowType.Album]: AlbumWindowReducer, [WindowType.Song]: SongWindowReducer, [WindowType.Tag]: TagWindowReducer, + [WindowType.Manage]: ManageWindowReducer, } export const newWindowState = { @@ -78,4 +82,10 @@ export const newWindowState = { songsWithTag: null, } }, + [WindowType.Manage]: () => { + return { + tabLabel: <>Manage, + clearDBState: ClearDBState.None, + } + } } \ No newline at end of file