Merge pull request #282 from Chroma-Case/feature/adc/retour-utilisateur

Feature/adc/retour utilisateur
This commit is contained in:
Arthur Jamet
2023-09-26 07:31:19 +02:00
committed by GitHub
6 changed files with 61 additions and 26 deletions

View File

@@ -4,6 +4,7 @@ import sys
import os
import requests
import glob
from mido import MidiFile
from configparser import ConfigParser
url = os.environ.get("API_URL")
@@ -20,16 +21,16 @@ def getOrCreateAlbum(name, artistId):
return out["id"]
def getOrCreateGenre(names):
ids = []
for name in names.split(","):
res = requests.post(f"{url}/genre", json={
"name": name,
})
out = res.json()
print(out)
ids += [out["id"]]
#TODO handle multiple genres
return ids[0]
ids = []
for name in names.split(","):
res = requests.post(f"{url}/genre", json={
"name": name,
})
out = res.json()
print(out)
ids += [out["id"]]
#TODO handle multiple genres
return ids[0]
def getOrCreateArtist(name):
res = requests.post(f"{url}/artist", json={
@@ -42,8 +43,10 @@ def getOrCreateArtist(name):
def populateFile(path, midi, mxl):
config = ConfigParser()
config.read(path)
mid = MidiFile(midi)
metadata = config["Metadata"];
difficulties = dict(config["Difficulties"])
difficulties["length"] = round((mid.length), 2)
artistId = getOrCreateArtist(metadata["Artist"])
print(f"Populating {metadata['Name']}")
res = requests.post(f"{url}/song", json={
@@ -58,7 +61,6 @@ def populateFile(path, midi, mxl):
})
print(res.json())
def main():
global url
if url == None:

View File

@@ -0,0 +1,35 @@
import { HStack, Icon, Text } from 'native-base';
import { MaterialIcons } from '@expo/vector-icons';
type DurationComponentProps = {
length: number | undefined;
};
const DurationComponent = ({ length }: DurationComponentProps) => {
const minutes = Math.floor((length ?? 0) / 60);
const seconds = Math.round((length ?? 0) - minutes * 60);
return (
<HStack space={3}>
<Icon
as={MaterialIcons}
name="timer"
size={'20px'}
color="coolGray.800"
_dark={{
color: 'warmGray.50',
}}
/>
<Text
style={{
flexShrink: 0,
}}
fontSize={'16px'}
>
{length ? `${minutes}'${seconds}` : "--'--"}
</Text>
</HStack>
);
};
export default DurationComponent;

View File

@@ -4,6 +4,7 @@ import TextButton from './TextButton';
import { LikedSongWithDetails } from '../models/LikedSong';
import { MaterialIcons } from '@expo/vector-icons';
import API from '../API';
import DurationComponent from './DurationComponent';
type FavSongRowProps = {
FavSong: LikedSongWithDetails; // TODO: remove Song
@@ -54,6 +55,7 @@ const FavSongRow = ({ FavSong, onPress }: FavSongRowProps) => {
>
{FavSong.addedDate.toLocaleDateString()}
</Text>
<DurationComponent length={FavSong.details.details.length} />
</HStack>
<IconButton
colorScheme="primary"

View File

@@ -3,6 +3,7 @@ import Song, { SongWithArtist } from '../models/Song';
import RowCustom from './RowCustom';
import TextButton from './TextButton';
import { MaterialIcons } from '@expo/vector-icons';
import DurationComponent from './DurationComponent';
type SongRowProps = {
song: Song | SongWithArtist; // TODO: remove Song
@@ -55,6 +56,8 @@ const SongRow = ({ song, onPress, handleLike, isLiked }: SongRowProps) => {
>
{song.artistId ?? 'artist'}
</Text>
{/* <DurationInfo length={song.details.length} /> */}
<DurationComponent length={song.details.length} />
</HStack>
<IconButton
colorScheme="rose"

View File

@@ -7,6 +7,7 @@ import API from '../API';
import TextButton from '../components/TextButton';
import { RouteProps, useNavigation } from '../Navigation';
import ScoreGraph from '../components/ScoreGraph';
import DurationComponent from '../components/DurationComponent';
interface SongLobbyProps {
// The unique identifier to find a song
@@ -66,6 +67,7 @@ const SongLobbyView = (props: RouteProps<SongLobbyProps>) => {
}
/>
</Text>
<DurationComponent length={songQuery.data?.details.length} />
<TextButton
translate={{ translationKey: 'playBtn' }}
width="auto"

View File

@@ -4755,7 +4755,7 @@
dependencies:
"@types/react" "*"
"@types/react-native@~0.70.6":
"@types/react-native@~0.70.5":
version "0.70.14"
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.70.14.tgz#8619b8c94296f6456c5362d74a3d1b4fad3f54ab"
integrity sha512-Kwc+BYBrnDqvacNxKp1UtcZJnJJnTih2NYmi/ieAKlHdxEPN6sYMwmIwgHdoLHggvml6bf3DYRaH2jt+gzaLjw==
@@ -4783,7 +4783,7 @@
dependencies:
"@types/react" "*"
"@types/react@*":
"@types/react@*", "@types/react@~18.2.0":
version "18.2.22"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.22.tgz#abe778a1c95a07fa70df40a52d7300a40b949ccb"
integrity sha512-60fLTOLqzarLED2O3UQImc/lsNRgG0jE/a1mPW9KjMemY0LMITWEsbS4VvZ4p6rorEHd5YKxxmMKSDK505GHpA==
@@ -4792,15 +4792,6 @@
"@types/scheduler" "*"
csstype "^3.0.2"
"@types/react@~18.0.24":
version "18.0.38"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.38.tgz#02a23bef8848b360a0d1dceef4432c15c21c600c"
integrity sha512-ExsidLLSzYj4cvaQjGnQCk4HFfVT9+EZ9XZsQ8Hsrcn8QNgXtpZ3m9vSIC2MWtx7jHictK6wYhQgGh6ic58oOw==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
csstype "^3.0.2"
"@types/scheduler@*":
version "0.16.3"
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.3.tgz#cef09e3ec9af1d63d2a6cc5b383a737e24e6dcf5"
@@ -15713,10 +15704,10 @@ react-use-precision-timer@^3.3.1:
dependencies:
react-sub-unsub "^2.1.6"
react@18.1.0:
version "18.1.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.1.0.tgz#6f8620382decb17fdc5cc223a115e2adbf104890"
integrity sha512-4oL8ivCz5ZEPyclFQXaNksK3adutVS8l2xzZU0cqEFrE9Sb7fC0EFK5uEk74wIreL1DERyjvsU915j1pcT2uEQ==
react@18.2.0:
version "18.2.0"
resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==
dependencies:
loose-envify "^1.1.0"