mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
1 line
13 KiB
JSON
1 line
13 KiB
JSON
{"ast":null,"code":"var _jsxFileName = \"/app/src/Pages/Profile.js\",\n _s = $RefreshSig$();\n\nimport React, { useState, useEffect } from 'react';\nimport '../App.css';\nimport './Profile.css';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport { getProfile, getTopTracks, getTopArtists } from '../Api/index';\nimport ScrobbleTable from '../Components/ScrobbleTable';\nimport TopTable from '../Components/TopTable';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst profileDateRanges = {\n 'All time': false,\n 'Last year': '365',\n 'Last month': '30',\n 'Last week': '7'\n};\nconst defaultDateRange = 'Last month';\nlet activeStyle = {\n color: '#FFFFFF'\n};\n\nconst Profile = route => {\n _s();\n\n const [loading, setLoading] = useState(true);\n const [tableLoading, setTableLoading] = useState(false);\n const [active, setActive] = useState(defaultDateRange);\n const [profile, setProfile] = useState({});\n const [topTracks, setTopTracks] = useState({});\n const [topArtists, setTopArtists] = useState({});\n let username = false;\n\n if (route && route.match && route.match.params && route.match.params.uuid) {\n username = route.match.params.uuid;\n } else {\n username = false;\n }\n\n useEffect(() => {\n if (!username) {\n return false;\n }\n\n getProfile(username).then(data => {\n setProfile(data); // Fetch top tracks\n\n getTopTracks(data.uuid, profileDateRanges[defaultDateRange]).then(data => {\n setTopTracks(data.tracks);\n }); // Fetch top artists\n\n getTopArtists(data.uuid, profileDateRanges[defaultDateRange]).then(data => {\n setTopArtists(data.artists);\n });\n setLoading(false);\n });\n }, [username]);\n\n const reloadScrobblesForDate = (username, days, name) => {\n setActive(name);\n setTableLoading(true);\n getProfile(username).then(data => {\n setProfile(data); // Fetch top tracks\n\n getTopTracks(data.uuid, days).then(data => {\n setTopTracks(data.tracks);\n }); // Fetch top artists\n\n getTopArtists(data.uuid, days).then(data => {\n setTopArtists(data.artists);\n });\n setTableLoading(false);\n });\n };\n\n if (loading) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: /*#__PURE__*/_jsxDEV(ScaleLoader, {\n color: \"#6AD7E5\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 86,\n columnNumber: 9\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 85,\n columnNumber: 7\n }, this);\n }\n\n if (!username || !profile.username) {\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: \"Unable to fetch user\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 93,\n columnNumber: 7\n }, this);\n }\n\n return /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageWrapper\",\n children: [/*#__PURE__*/_jsxDEV(\"h1\", {\n children: [profile.username, \"'s Profile\"]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 101,\n columnNumber: 7\n }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n className: \"pageBody\",\n children: [/*#__PURE__*/_jsxDEV(\"div\", {\n className: \"profileDateRange\",\n children: Object.entries(profileDateRanges).map((t, k) => /*#__PURE__*/_jsxDEV(\"span\", {\n children: /*#__PURE__*/_jsxDEV(\"span\", {\n onClick: () => reloadScrobblesForDate(username, t[1], t[0]),\n style: active === t[0] ? activeStyle : {},\n className: \"profileDateRangeText\",\n children: t[0]\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 108,\n columnNumber: 15\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 107,\n columnNumber: 60\n }, this))\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 105,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(TopTable, {\n type: \"track\",\n items: topTracks,\n loading: tableLoading\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 116,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 117,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(TopTable, {\n type: \"artist\",\n items: topArtists,\n loading: tableLoading\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 118,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 119,\n columnNumber: 9\n }, this), \"Last 10 scrobbles\", /*#__PURE__*/_jsxDEV(\"br\", {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 120,\n columnNumber: 26\n }, this), /*#__PURE__*/_jsxDEV(ScrobbleTable, {\n data: profile.scrobbles\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 121,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 104,\n columnNumber: 7\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 100,\n columnNumber: 5\n }, this);\n};\n\n_s(Profile, \"p1rb9lNZ+90ykeZQZKM6+K78diE=\");\n\n_c = Profile;\nexport default Profile;\n\nvar _c;\n\n$RefreshReg$(_c, \"Profile\");","map":{"version":3,"sources":["/app/src/Pages/Profile.js"],"names":["React","useState","useEffect","ScaleLoader","getProfile","getTopTracks","getTopArtists","ScrobbleTable","TopTable","profileDateRanges","defaultDateRange","activeStyle","color","Profile","route","loading","setLoading","tableLoading","setTableLoading","active","setActive","profile","setProfile","topTracks","setTopTracks","topArtists","setTopArtists","username","match","params","uuid","then","data","tracks","artists","reloadScrobblesForDate","days","name","Object","entries","map","t","k","scrobbles"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,OAAO,YAAP;AACA,OAAO,eAAP;AACA,OAAOC,WAAP,MAAwB,4BAAxB;AACA,SAASC,UAAT,EAAqBC,YAArB,EAAmCC,aAAnC,QAAwD,cAAxD;AACA,OAAOC,aAAP,MAA0B,6BAA1B;AACA,OAAOC,QAAP,MAAqB,wBAArB;;AAE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ER;AAApD;AAAA;AAAA;AAAA;AAAA,cAdF,eAeE;AAAA;AAAA;AAAA;AAAA,cAfF,oCAgBmB;AAAA;AAAA;AAAA;AAAA,cAhBnB,eAiBE,QAAC,aAAD;AAAe,QAAA,IAAI,EAAEI,OAAO,CAACsB;AAA7B;AAAA;AAAA;AAAA;AAAA,cAjBF;AAAA;AAAA;AAAA;AAAA;AAAA,YAJF;AAAA;AAAA;AAAA;AAAA;AAAA,UADF;AA0BD,CA1GD;;GAAM9B,O;;KAAAA,O;AA4GN,eAAeA,OAAf","sourcesContent":["import React, { useState, useEffect } from 'react';\nimport '../App.css';\nimport './Profile.css';\nimport ScaleLoader from 'react-spinners/ScaleLoader';\nimport { getProfile, getTopTracks, getTopArtists } from '../Api/index'\nimport ScrobbleTable from '../Components/ScrobbleTable'\nimport TopTable from '../Components/TopTable'\n\nconst profileDateRanges = {\n 'All time': false,\n 'Last year': '365',\n 'Last month': '30',\n 'Last week': '7',\n};\n\nconst defaultDateRange = 'Last month';\nlet activeStyle = { color: '#FFFFFF' };\n\nconst Profile = (route) => {\n const [loading, setLoading] = useState(true);\n const [tableLoading, setTableLoading] = useState(false);\n const [active, setActive] = useState(defaultDateRange);\n const [profile, setProfile] = useState({});\n const [topTracks, setTopTracks] = useState({})\n const [topArtists, setTopArtists] = useState({})\n \n let username = false;\n if (route && route.match && route.match.params && route.match.params.uuid) {\n username = route.match.params.uuid;\n } else {\n username = false;\n }\n\n useEffect(() => {\n if (!username) {\n return false;\n }\n\n getProfile(username)\n .then(data => {\n setProfile(data);\n\n // Fetch top tracks\n getTopTracks(data.uuid, profileDateRanges[defaultDateRange])\n .then(data => {\n setTopTracks(data.tracks)\n })\n\n // Fetch top artists\n getTopArtists(data.uuid, profileDateRanges[defaultDateRange])\n .then(data => {\n setTopArtists(data.artists)\n })\n\n setLoading(false);\n })\n\n }, [username])\n\n const reloadScrobblesForDate = (username, days, name) => {\n setActive(name);\n setTableLoading(true);\n getProfile(username)\n .then(data => {\n setProfile(data);\n\n // Fetch top tracks\n getTopTracks(data.uuid, days)\n .then(data => {\n setTopTracks(data.tracks);\n })\n\n // Fetch top artists\n getTopArtists(data.uuid, days)\n .then(data => {\n setTopArtists(data.artists);\n })\n\n setTableLoading(false)\n })\n };\n\n if (loading) {\n return (\n <div className=\"pageWrapper\">\n <ScaleLoader color=\"#6AD7E5\" />\n </div>\n )\n }\n\n if (!username || !profile.username) {\n return (\n <div className=\"pageWrapper\">\n Unable to fetch user\n </div>\n )\n }\n\n return (\n <div className=\"pageWrapper\">\n <h1>\n {profile.username}'s Profile\n </h1>\n <div className=\"pageBody\">\n <div className=\"profileDateRange\">\n {\n Object.entries(profileDateRanges).map((t,k) => <span>\n <span onClick={() => reloadScrobblesForDate(username,t[1], t[0])}\n style={active === t[0] ? activeStyle : {}}\n className=\"profileDateRangeText\">\n {t[0]}\n </span>\n </span>)\n }\n </div>\n <TopTable type=\"track\" items={topTracks} loading={tableLoading} />\n <br/>\n <TopTable type=\"artist\" items={topArtists} loading={tableLoading} />\n <br/>\n Last 10 scrobbles<br/>\n <ScrobbleTable data={profile.scrobbles}/>\n </div>\n </div>\n );\n}\n\nexport default Profile;"]},"metadata":{},"sourceType":"module"} |