mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-12 12:04:16 +00:00
fix uploads
This commit is contained in:
parent
16eb7eb437
commit
b10f29fc5e
@ -20,8 +20,6 @@ const UploadHint = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FileListItem = React.memo((props) => {
|
const FileListItem = React.memo((props) => {
|
||||||
console.log(props)
|
|
||||||
|
|
||||||
const isUploading = props.track.status === "uploading"
|
const isUploading = props.track.status === "uploading"
|
||||||
|
|
||||||
return <Draggable key={props.track.uid} draggableId={props.track.uid} index={props.index}>
|
return <Draggable key={props.track.uid} draggableId={props.track.uid} index={props.index}>
|
||||||
@ -46,6 +44,10 @@ const FileListItem = React.memo((props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
<div className="fileListItem_cover">
|
<div className="fileListItem_cover">
|
||||||
|
<div className="fileListItem_cover_mask">
|
||||||
|
<Icons.MdEdit />
|
||||||
|
</div>
|
||||||
|
|
||||||
<img
|
<img
|
||||||
src={props.track?.thumbnail}
|
src={props.track?.thumbnail}
|
||||||
alt="Track cover"
|
alt="Track cover"
|
||||||
@ -160,13 +162,6 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTrackRemove = (uid) => {
|
|
||||||
this.setState({
|
|
||||||
fileList: this.state.fileList.filter((file) => file.uid !== uid),
|
|
||||||
trackList: this.state.trackList.filter((file) => file.uid !== uid)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
handleTrackCoverChange = (uid) => {
|
handleTrackCoverChange = (uid) => {
|
||||||
// open a file dialog
|
// open a file dialog
|
||||||
const fileInput = document.createElement("input")
|
const fileInput = document.createElement("input")
|
||||||
@ -201,7 +196,7 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
fileList: this.state.fileList.filter((file) => file.uid !== uid),
|
fileList: this.state.fileList.filter((file) => file.uid !== uid),
|
||||||
trackList: this.state.trackList.filter((file) => file.uid !== uid),
|
trackList: this.state.trackList.filter((file) => file.uid !== uid),
|
||||||
pendingUploads: this.state.pendingUploads.filter((uid) => uid !== uid)
|
pendingUploads: this.state.pendingUploads.filter((file_uid) => file_uid !== uid)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,9 +247,7 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
}
|
}
|
||||||
case "error": {
|
case "error": {
|
||||||
// remove pending file
|
// remove pending file
|
||||||
this.setState({
|
this.removeTrack(change.file.uid)
|
||||||
pendingUploads: this.state.pendingUploads.filter(uid => uid !== change.file.uid)
|
|
||||||
})
|
|
||||||
|
|
||||||
// open a dialog to show the error and ask user to retry
|
// open a dialog to show the error and ask user to retry
|
||||||
antd.Modal.error({
|
antd.Modal.error({
|
||||||
@ -271,7 +264,6 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
case "removed": {
|
case "removed": {
|
||||||
// remove from file list and if it's pending, remove from pending list
|
|
||||||
this.removeTrack(change.file.uid)
|
this.removeTrack(change.file.uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +274,9 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleUpload = async (req) => {
|
handleUpload = async (req) => {
|
||||||
const response = await FilesModel.uploadFile(req.file).catch((error) => {
|
const response = await FilesModel.uploadFile(req.file, {
|
||||||
|
timeout: 2000
|
||||||
|
}).catch((error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
antd.message.error(error)
|
antd.message.error(error)
|
||||||
|
|
||||||
@ -383,12 +377,12 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
|
|
||||||
let playlistPublishResponse = null
|
let playlistPublishResponse = null
|
||||||
|
|
||||||
if (this.props.query.playlist_id) {
|
if (this.props.playlist_id) {
|
||||||
console.log(`Playlist ${this.props.query.playlist_id} is already published. Updating...`)
|
console.log(`Playlist ${this.props.playlist_id} is already published. Updating...`)
|
||||||
|
|
||||||
// update the playlist
|
// update the playlist
|
||||||
playlistPublishResponse = await PlaylistModel.updatePlaylist({
|
playlistPublishResponse = await PlaylistModel.updatePlaylist({
|
||||||
_id: this.props.query.playlist_id,
|
_id: this.props.playlist_id,
|
||||||
title: playlistName,
|
title: playlistName,
|
||||||
description: playlistDescription,
|
description: playlistDescription,
|
||||||
thumbnail: playlistThumbnail,
|
thumbnail: playlistThumbnail,
|
||||||
@ -434,7 +428,7 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
loading: true
|
loading: true
|
||||||
})
|
})
|
||||||
|
|
||||||
const deleteResponse = await PlaylistModel.deletePlaylist(this.props.query.playlist_id).catch((error) => {
|
const deleteResponse = await PlaylistModel.deletePlaylist(this.props.playlist_id).catch((error) => {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
antd.message.error(error)
|
antd.message.error(error)
|
||||||
|
|
||||||
@ -519,10 +513,10 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
console.log(this.props.query.playlist_id)
|
console.log(this.props.playlist_id)
|
||||||
|
|
||||||
if (this.props.query.playlist_id) {
|
if (this.props.playlist_id) {
|
||||||
this.loadData(this.props.query.playlist_id)
|
this.loadData(this.props.playlist_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
window._hacks = {
|
window._hacks = {
|
||||||
@ -537,25 +531,6 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <div className="playlistCreator">
|
return <div className="playlistCreator">
|
||||||
<div className="header">
|
|
||||||
<h1>
|
|
||||||
<Icons.MdOutlineQueueMusic />
|
|
||||||
Creator
|
|
||||||
</h1>
|
|
||||||
|
|
||||||
<div className="actions">
|
|
||||||
{
|
|
||||||
this.props.query.playlist_id && <antd.Button
|
|
||||||
type="primary"
|
|
||||||
onClick={this.handleDeletePlaylist}
|
|
||||||
danger
|
|
||||||
>
|
|
||||||
Delete Playlist
|
|
||||||
</antd.Button>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="inputField">
|
<div className="inputField">
|
||||||
<Icons.MdOutlineMusicNote />
|
<Icons.MdOutlineMusicNote />
|
||||||
<antd.Input
|
<antd.Input
|
||||||
@ -570,17 +545,20 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
<div className="inputField">
|
<div className="inputField">
|
||||||
<Icons.MdOutlineDescription />
|
<Icons.MdOutlineDescription />
|
||||||
<antd.Input
|
|
||||||
|
<antd.Input.TextArea
|
||||||
className="inputText"
|
className="inputText"
|
||||||
placeholder="Description"
|
placeholder="Description (Support Markdown)"
|
||||||
bordered={false}
|
bordered={false}
|
||||||
|
value={this.state.playlistDescription}
|
||||||
onChange={this.handleDescriptionOnChange}
|
onChange={this.handleDescriptionOnChange}
|
||||||
maxLength={2500}
|
maxLength={2500}
|
||||||
value={this.state.playlistDescription}
|
rows={4}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="inputField">
|
<div className="inputField">
|
||||||
<Icons.MdImage />
|
<Icons.MdImage />
|
||||||
|
|
||||||
{
|
{
|
||||||
this.state.playlistThumbnail && <div className="coverPreview">
|
this.state.playlistThumbnail && <div className="coverPreview">
|
||||||
<img src={this.state.playlistThumbnail} alt="cover" />
|
<img src={this.state.playlistThumbnail} alt="cover" />
|
||||||
@ -598,6 +576,7 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
</antd.Button>
|
</antd.Button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
!this.state.playlistThumbnail && <UploadButton
|
!this.state.playlistThumbnail && <UploadButton
|
||||||
onUploadDone={(file) => {
|
onUploadDone={(file) => {
|
||||||
@ -607,7 +586,6 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
}}
|
}}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
icon={<Icons.MdImage />}
|
|
||||||
>
|
>
|
||||||
Upload cover
|
Upload cover
|
||||||
</UploadButton>
|
</UploadButton>
|
||||||
@ -651,7 +629,7 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
return this.handleTrackTitleOnChange(event, track.uid)
|
return this.handleTrackTitleOnChange(event, track.uid)
|
||||||
}}
|
}}
|
||||||
onClickRemove={() => {
|
onClickRemove={() => {
|
||||||
return this.handleTrackRemove(track.uid)
|
return this.removeTrack(track.uid)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
})
|
})
|
||||||
@ -676,7 +654,7 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div className="actions">
|
||||||
<antd.Button
|
<antd.Button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="large"
|
size="large"
|
||||||
@ -687,6 +665,16 @@ export default class PlaylistCreator extends React.Component {
|
|||||||
>
|
>
|
||||||
Publish
|
Publish
|
||||||
</antd.Button>
|
</antd.Button>
|
||||||
|
|
||||||
|
{
|
||||||
|
this.props.playlist_id && <antd.Button
|
||||||
|
type="link"
|
||||||
|
onClick={this.handleDeletePlaylist}
|
||||||
|
danger
|
||||||
|
>
|
||||||
|
Delete Playlist
|
||||||
|
</antd.Button>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="footer">
|
<div className="footer">
|
||||||
|
@ -9,34 +9,14 @@
|
|||||||
|
|
||||||
transition: all 0.3s ease-in-out;
|
transition: all 0.3s ease-in-out;
|
||||||
|
|
||||||
.header {
|
.actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: flex-end;
|
||||||
|
|
||||||
font-size: 1rem;
|
gap: 20px;
|
||||||
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
margin-bottom: 10px;
|
|
||||||
|
|
||||||
.actions {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
|
|
||||||
.ant-btn {
|
|
||||||
margin-left: 10px;
|
|
||||||
|
|
||||||
&:first-child {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.inputField {
|
.inputField {
|
||||||
@ -154,6 +134,8 @@
|
|||||||
img {
|
img {
|
||||||
filter: blur(3px);
|
filter: blur(3px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,6 +179,17 @@
|
|||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fileListItem_cover_mask {
|
||||||
|
opacity: 0;
|
||||||
|
backdrop-filter: blur(3px);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
.fileListItem_cover_mask {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.fileListItem_details {
|
.fileListItem_details {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user