From d0aa50456d0d278ae6376e3372c0ce9729f4db32 Mon Sep 17 00:00:00 2001 From: andy Date: Sat, 20 Mar 2021 18:48:07 +0000 Subject: [PATCH] removed maths tab in front-end --- admin.py | 4 + pyproject.toml | 1 + src/js/Maths/Count.js | 265 ----------------------------------- src/js/Maths/MathsRouter.js | 15 -- src/js/MusicTools.js | 6 - src/js/Playlist/View/Edit.js | 1 + 6 files changed, 6 insertions(+), 286 deletions(-) delete mode 100644 src/js/Maths/Count.js delete mode 100644 src/js/Maths/MathsRouter.js diff --git a/admin.py b/admin.py index f5d9124..6199e85 100755 --- a/admin.py +++ b/admin.py @@ -245,6 +245,10 @@ def test(): os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'service.json' subprocess.check_call("python -u -m unittest discover -s tests", shell=True) +def run(): + os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'service.json' + subprocess.check_call("python main.api.py", shell=True) + if __name__ == '__main__': console = Admin() if len(sys.argv) > 1: diff --git a/pyproject.toml b/pyproject.toml index efa4a39..09332a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ repository = "https://github.com/Sarsoo/Music-Tools" [tool.poetry.scripts] test = 'admin:test' +start = 'admin:run' [tool.poetry.dependencies] python = "^3.8" diff --git a/src/js/Maths/Count.js b/src/js/Maths/Count.js deleted file mode 100644 index f3118d0..0000000 --- a/src/js/Maths/Count.js +++ /dev/null @@ -1,265 +0,0 @@ -import React, { Component } from "react"; -const axios = require('axios'); - -import showMessage from "../Toast.js"; -import BarChart from "./BarChart.js"; -import PieChart from "./PieChart.js"; - -class Count extends Component { - - constructor(props){ - super(props); - this.state = { - playlists: [], - isLoading: true, - - chartPlaylists: [] - } - this.getPlaylists(); - - this.handleCheckbox = this.handleCheckbox.bind(this); - } - - getPlaylists(){ - axios.get('/api/playlists') - .then((response) => { - - var playlists = []; - - var playlist_in; - for(playlist_in of response.data.playlists) { - if(playlist_in['lastfm_stat_last_refresh'] != undefined){ - playlists.push(playlist_in); - } - } - - playlists.sort(function(a, b){ - return b['lastfm_stat_count'] - a['lastfm_stat_count']; - }); - - this.setState({ - playlists: playlists, - isLoading: false - }); - }) - .catch((error) => { - console.log(error); - showMessage(`error getting playlists (${error.response.status})`); - }); - } - - handleCheckbox(event) { - if(event.target.checked == true){ - var playlists = this.state.chartPlaylists.slice(); - playlists.push(event.target.name); - - this.setState({chartPlaylists: playlists}); - }else{ - var playlists = this.state.chartPlaylists.slice(); - playlists.splice(playlists.indexOf(event.target.name), 1); - - this.setState({chartPlaylists: playlists}); - } - } - - getPieChartTrackData(){ - var playlists = this.state.chartPlaylists; - - if(playlists.length > 0){ - - var data = playlists.map((entry) => { - - var i; - for(i = 0; i < this.state.playlists.length; i++){ - var playlist = this.state.playlists[i]; - if(playlist.name == entry){ - - return { - "label": playlist.name, - "value": playlist.lastfm_stat_percent - } - } - } - - console.log(`${entry} not found`); - }); - - var total = data.reduce((total, value) => { - return total + value.value; - }, 0); - - data.sort((a, b) => { - if(a.value > b.value) { return -1; } - if(a.value < b.value) { return 1; } - return 0; - }) - - if(total > 100){ - return [{ - 'label': 'over 100%', - 'value': 100 - }]; - }else{ - data.push({ - 'label': 'other', - 'value': 100 - total - }) - } - return data; - }else{ - return [{ - 'label': 'no selection', - 'value': 100 - }]; - } - } - - getPieChartAlbumData(){ - var playlists = this.state.chartPlaylists; - - if(playlists.length > 0){ - - var data = playlists.map((entry) => { - - var i; - for(i = 0; i < this.state.playlists.length; i++){ - var playlist = this.state.playlists[i]; - if(playlist.name == entry){ - - return { - "label": playlist.name, - "value": playlist.lastfm_stat_album_percent - } - } - } - - console.log(`${entry} not found`); - }); - - var total = data.reduce((total, value) => { - return total + value.value; - }, 0); - - data.sort((a, b) => { - if(a.value > b.value) { return -1; } - if(a.value < b.value) { return 1; } - return 0; - }) - - if(total > 100){ - return [{ - 'label': 'over 100%', - 'value': 100 - }]; - }else{ - data.push({ - 'label': 'other', - 'value': 100 - total - }) - } - return data; - }else{ - return [{ - 'label': 'no selection', - 'value': 100 - }]; - } - } - - getPieChartArtistData(){ - var playlists = this.state.chartPlaylists; - - if(playlists.length > 0){ - - var data = playlists.map((entry) => { - - var i; - for(i = 0; i < this.state.playlists.length; i++){ - var playlist = this.state.playlists[i]; - if(playlist.name == entry){ - - return { - "label": playlist.name, - "value": playlist.lastfm_stat_artist_percent - } - } - } - - console.log(`${entry} not found`); - }); - - var total = data.reduce((total, value) => { - return total + value.value; - }, 0); - - data.sort((a, b) => { - if(a.value > b.value) { return -1; } - if(a.value < b.value) { return 1; } - return 0; - }) - - if(total > 100){ - return [{ - 'label': 'over 100%', - 'value': 100 - }]; - }else{ - data.push({ - 'label': 'other', - 'value': 100 - total - }) - } - return data; - }else{ - return [{ - 'label': 'no selection', - 'value': 100 - }]; - } - } - - render() { - - var data = this.state.playlists.map((entry) => { - return { - "label": entry.name, - "value": entry.lastfm_stat_count - }; - }) - - var table =
- - - - - - - - {this.state.playlists.map((entry) => )} - -
-

scrobble counts

-
- - - - - - -
; - - const loadingMessage =

loading...

; - - return this.state.isLoading ? loadingMessage : table; - } -} - -function Row(props){ - return - {props.name} - {props.count.toLocaleString()} / {props.percent}% - - ; -} - -export default Count; \ No newline at end of file diff --git a/src/js/Maths/MathsRouter.js b/src/js/Maths/MathsRouter.js deleted file mode 100644 index 52fedcd..0000000 --- a/src/js/Maths/MathsRouter.js +++ /dev/null @@ -1,15 +0,0 @@ -import React, { Component } from "react"; -import { BrowserRouter as Route} from "react-router-dom"; - -import Count from "./Count.js"; - -class Maths extends Component { - - render() { - return } />; - } -} - - - -export default Maths; \ No newline at end of file diff --git a/src/js/MusicTools.js b/src/js/MusicTools.js index 1d34192..a9f4026 100644 --- a/src/js/MusicTools.js +++ b/src/js/MusicTools.js @@ -27,7 +27,6 @@ import { Build, PieChart, QueueMusic, ExitToApp, AccountCircle, KeyboardBackspac const axios = require('axios'); const LazyIndex = React.lazy(() => import("./Index/Index")) -const LazyMaths = React.lazy(() => import("./Maths/MathsRouter")) const LazyPlaylists = React.lazy(() => import("./Playlist/AllPlaylistsRouter")) const LazyPlaylistView = React.lazy(() => import("./Playlist/View/PlaylistRouter")) const LazySettings = React.lazy(() => import("./Settings/SettingsRouter")) @@ -123,10 +122,6 @@ class MusicTools extends Component { - - - - @@ -155,7 +150,6 @@ class MusicTools extends Component { - { this.state.type == 'admin' && } diff --git a/src/js/Playlist/View/Edit.js b/src/js/Playlist/View/Edit.js index 11f3ba7..94d0593 100644 --- a/src/js/Playlist/View/Edit.js +++ b/src/js/Playlist/View/Edit.js @@ -305,6 +305,7 @@ export class Edit extends Component{ render(){ var date = new Date(); + console.log("hello from edit"); const table = (
-- 2.45.2