#631: Added delete button to file UI
This commit is contained in:
@@ -2,7 +2,7 @@ module main
|
|||||||
|
|
||||||
go 1.15
|
go 1.15
|
||||||
|
|
||||||
replace github.com/shuffle/shuffle-shared => ../../../../git/shuffle-shared
|
//replace github.com/shuffle/shuffle-shared => ../../../../git/shuffle-shared
|
||||||
|
|
||||||
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
|
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
|
||||||
//replace github.com/frikky/go-elasticsearch => ../../../../git/go-elasticsearch
|
//replace github.com/frikky/go-elasticsearch => ../../../../git/go-elasticsearch
|
||||||
@@ -22,7 +22,7 @@ require (
|
|||||||
github.com/gorilla/mux v1.8.0
|
github.com/gorilla/mux v1.8.0
|
||||||
github.com/h2non/filetype v1.1.1
|
github.com/h2non/filetype v1.1.1
|
||||||
github.com/satori/go.uuid v1.2.0
|
github.com/satori/go.uuid v1.2.0
|
||||||
github.com/shuffle/shuffle-shared v0.1.60
|
github.com/shuffle/shuffle-shared v0.1.61
|
||||||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
|
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
|
||||||
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
|
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
#build: ./frontend
|
build: ./frontend
|
||||||
image: ghcr.io/frikky/shuffle-frontend:nightly
|
image: ghcr.io/frikky/shuffle-frontend:nightly
|
||||||
container_name: shuffle-frontend
|
container_name: shuffle-frontend
|
||||||
hostname: shuffle-frontend
|
hostname: shuffle-frontend
|
||||||
|
|||||||
@@ -1094,6 +1094,41 @@ const Admin = (props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deleteFile = (file) => {
|
||||||
|
fetch(globalUrl + "/api/v1/files/" + file.id, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Accept: "application/json",
|
||||||
|
},
|
||||||
|
credentials: "include",
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
if (response.status !== 200) {
|
||||||
|
console.log("Status not 200 for file delete :O!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.json();
|
||||||
|
})
|
||||||
|
.then((responseJson) => {
|
||||||
|
if (responseJson.success) {
|
||||||
|
alert.info("Successfully deleted file "+file.name)
|
||||||
|
|
||||||
|
} else if (responseJson.reason !== undefined && responseJson.reason !== null) {
|
||||||
|
alert.error("Failed to delete file: " + responseJson.reason)
|
||||||
|
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
getFiles();
|
||||||
|
}, 1500);
|
||||||
|
|
||||||
|
console.log(responseJson)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
alert.error(error.toString());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const downloadFile = (file) => {
|
const downloadFile = (file) => {
|
||||||
fetch(globalUrl + "/api/v1/files/" + file.id + "/content", {
|
fetch(globalUrl + "/api/v1/files/" + file.id + "/content", {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@@ -3118,7 +3153,6 @@ const Admin = (props) => {
|
|||||||
style={{ minWidth: 125, maxWidth: 125 }}
|
style={{ minWidth: 125, maxWidth: 125 }}
|
||||||
/>
|
/>
|
||||||
<ListItemText primary="Actions" />
|
<ListItemText primary="Actions" />
|
||||||
<ListItemText primary="File ID" />
|
|
||||||
</ListItem>
|
</ListItem>
|
||||||
{files === undefined || files === null || files.length === 0
|
{files === undefined || files === null || files.length === 0
|
||||||
? null
|
? null
|
||||||
@@ -3235,7 +3269,9 @@ const Admin = (props) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
primary=<Tooltip
|
primary=
|
||||||
|
<span style={{display: "flex"}}>
|
||||||
|
<Tooltip
|
||||||
title={"Download file"}
|
title={"Download file"}
|
||||||
style={{}}
|
style={{}}
|
||||||
aria-label={"Download"}
|
aria-label={"Download"}
|
||||||
@@ -3256,27 +3292,33 @@ const Admin = (props) => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
<Tooltip
|
||||||
|
title={"Delete file"}
|
||||||
|
style={{}}
|
||||||
|
aria-label={"Delete"}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<IconButton
|
||||||
|
disabled={file.status !== "active"}
|
||||||
|
onClick={() => {
|
||||||
|
deleteFile(file);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DeleteIcon
|
||||||
style={{
|
style={{
|
||||||
minWidth: 75,
|
color:
|
||||||
maxWidth: 75,
|
file.status === "active" ? "white" : "grey",
|
||||||
overflow: "hidden",
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/*
|
</IconButton>
|
||||||
<ListItemText>
|
</span>
|
||||||
<Button
|
</Tooltip>
|
||||||
|
<Tooltip
|
||||||
|
title={"Copy file ID"}
|
||||||
style={{}}
|
style={{}}
|
||||||
variant="contained"
|
aria-label={"copy"}
|
||||||
color="primary"
|
|
||||||
disabled
|
|
||||||
onClick={() => deleteSchedule(file)}
|
|
||||||
>
|
>
|
||||||
Stop schedule
|
<IconButton
|
||||||
</Button>
|
|
||||||
</ListItemText>
|
|
||||||
*/}
|
|
||||||
<ListItemText
|
|
||||||
primary=<IconButton
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const elementName = "copy_element_shuffle";
|
const elementName = "copy_element_shuffle";
|
||||||
var copyText = document.getElementById(elementName);
|
var copyText = document.getElementById(elementName);
|
||||||
@@ -3305,6 +3347,13 @@ const Admin = (props) => {
|
|||||||
>
|
>
|
||||||
<FileCopyIcon style={{ color: "white" }} />
|
<FileCopyIcon style={{ color: "white" }} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
</span>
|
||||||
|
style={{
|
||||||
|
minWidth: 150,
|
||||||
|
maxWidth: 150,
|
||||||
|
overflow: "hidden",
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
);
|
||||||
@@ -4095,7 +4144,7 @@ const Admin = (props) => {
|
|||||||
<Tabs
|
<Tabs
|
||||||
value={curTab}
|
value={curTab}
|
||||||
indicatorColor="primary"
|
indicatorColor="primary"
|
||||||
textColor="primary"
|
textColor="secondary"
|
||||||
onChange={setConfig}
|
onChange={setConfig}
|
||||||
aria-label="disabled tabs example"
|
aria-label="disabled tabs example"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -3501,6 +3501,9 @@ const AppCreator = (props) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Found that dashes in the URL doesn't work
|
||||||
|
parsedurl = parsedurl.replace("-", "_")
|
||||||
|
|
||||||
if (event.target.value !== parsedurl) {
|
if (event.target.value !== parsedurl) {
|
||||||
setUrlPath(parsedurl);
|
setUrlPath(parsedurl);
|
||||||
setActionField("url", parsedurl);
|
setActionField("url", parsedurl);
|
||||||
|
|||||||
Reference in New Issue
Block a user