Added new cloud fixes

This commit is contained in:
frikky
2023-07-06 17:58:35 +02:00
parent 9a0441813a
commit 4f38eecaa5
7 changed files with 169 additions and 151 deletions
+157 -80
View File
@@ -41,18 +41,38 @@ import {
Visibility as VisibilityIcon,
VisibilityOff as VisibilityOffIcon,
} from "@material-ui/icons";
import data from "./frameworkStyle.jsx";
const scrollStyle1 = {
height: 100,
width: 225,
overflow: "hidden",
position: "relative",
}
const scrollStyle2 = {
position: "absolute",
top: 0,
left: 0,
bottom: "-20px",
right: "-20px",
overflow: "scroll",
}
const CacheView = (props) => {
const { globalUrl, userdata, serverside, orgId } = props;
const [orgCache, setOrgCache] = React.useState("");
const [listCache, setListCache] = React.useState([]);
const [addCache, setAddCache] = React.useState("");
const [editedCache, setEditedCache] = React.useState("");
const [modalOpen, setModalOpen] = React.useState(false);
const [key, setKey]= React.useState("");
const [value, setValue]= React.useState("");
const [cacheInput, setCacheInput]= React.useState("");
const [cacheCursor, setCacheCursor]= React.useState("");
const [key, setKey] = React.useState("");
const [value, setValue] = React.useState("");
const [cacheInput, setCacheInput] = React.useState("");
const [cacheCursor, setCacheCursor] = React.useState("");
const [dataValue, setDataValue] = React.useState({});
const [editCache, setEditCache] = React.useState(false);
const [show, setShow] = useState({});
const alert = useAlert();
useEffect(() => {
listOrgCache(orgId);
@@ -68,26 +88,26 @@ const CacheView = (props) => {
},
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for apps :O!");
return;
}
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for apps :O!");
return;
}
return response.json();
})
.then((responseJson) => {
if (responseJson.success === true) {
setListCache(responseJson.keys);
}
return response.json();
})
.then((responseJson) => {
if (responseJson.success === true) {
setListCache(responseJson.keys);
}
if (responseJson.cursor !== undefined && responseJson.cursor !== null && responseJson.cursor !== "") {
setCacheCursor(responseJson.cursor);
}
})
.catch((error) => {
alert.error(error.toString());
});
if (responseJson.cursor !== undefined && responseJson.cursor !== null && responseJson.cursor !== "") {
setCacheCursor(responseJson.cursor);
}
})
.catch((error) => {
alert.error(error.toString());
});
};
// const getCacheList = (orgId) => {
@@ -103,8 +123,8 @@ const CacheView = (props) => {
// if (response.status !== 200) {
// console.log("Status not 200 for WORKFLOW EXECUTION :O!");
// }
// return response.json();
// })
// .then((responseJson) => {
@@ -126,37 +146,72 @@ const CacheView = (props) => {
// console.log("Get userprofile error: ", error);
// })
// }
const deleteCache = (orgId, key) => {
alert.info("Attempting to delete Cache");
fetch(globalUrl + `/api/v1/orgs/${orgId}/cache/${key}`, {
method: "DELETE",
headers: {
Accept: "application/json",
},
credentials: "include",
method: "DELETE",
headers: {
Accept: "application/json",
},
credentials: "include",
})
.then((response) => {
if (response.status === 200) {
alert.success("Successfully deleted Cache");
setTimeout(() => {
.then((response) => {
if (response.status === 200) {
alert.success("Successfully deleted Cache");
setTimeout(() => {
listOrgCache(orgId);
}, 1000);
} else {
alert.error("Failed deleting Cache. Does it still exist?");
}
})
.catch((error) => {
alert.error(error.toString());
});
};
const editOrgCache = (orgId) => {
const cache = { key: dataValue.key , value: value };
setCacheInput([cache]);
console.log("cache:", cache)
console.log("cache input: ", cacheInput)
fetch(globalUrl + `/api/v1/orgs/${orgId}/set_cache`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
credentials: "include",
body: JSON.stringify(cache),
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for Cache :O!");
return;
}
return response.json();
})
.then((responseJson) => {
setAddCache(responseJson);
alert.success("Cache Edited Successfully!");
listOrgCache(orgId);
}, 1000);
} else {
alert.error("Failed deleting Cache. Does it still exist?");
}
})
.catch((error) => {
alert.error(error.toString());
});
};
setModalOpen(false);
})
.catch((error) => {
alert.error(error.toString());
});
};
const addOrgCache = (orgId) => {
const cache={key:key,value:value};
setCacheInput([cache]);
console.log("cache input:",cacheInput)
const cache = { key: key, value: value };
setCacheInput([cache]);
console.log("cache input:", cacheInput)
fetch(globalUrl + `/api/v1/orgs/${orgId}/set_cache`, {
method: "POST",
@@ -187,6 +242,8 @@ const CacheView = (props) => {
};
const modalView = (
// console.log("key:", dataValue.key),
//console.log("value:",dataValue.value),
<Dialog
open={modalOpen}
onClose={() => {
@@ -203,10 +260,10 @@ const CacheView = (props) => {
>
<DialogTitle>
<span style={{ color: "white" }}>
Add Cache
{ editCache ? "Edit Cache" : "Add Cache" }
</span>
</DialogTitle>
<div style={{paddingLeft: "30px", paddingRight: '30px'}}>
<div style={{ paddingLeft: "30px", paddingRight: '30px' }}>
Key
<TextField
color="primary"
@@ -223,14 +280,14 @@ const CacheView = (props) => {
fullWidth={true}
autoComplete="Key"
placeholder="abc"
id="keyfield"
id="keyfield"
margin="normal"
variant="outlined"
value={key}
onChange={(e)=>setKey(e.target.value)}
value={editCache ? dataValue.key : key}
onChange={(e) => setKey(e.target.value)}
/>
</div>
<div style={{paddingLeft: "30px", paddingRight: '30px'}}>
<div style={{ paddingLeft: "30px", paddingRight: '30px' }}>
Value
<TextField
color="primary"
@@ -249,11 +306,11 @@ const CacheView = (props) => {
id="Valuefield"
margin="normal"
variant="outlined"
value={value}
onChange={(e)=>setValue(e.target.value)}
defaultValue={editCache ? dataValue.value : ""}
onChange={(e) => setValue(e.target.value)}
/>
</div>
<DialogActions style={{paddingLeft: "30px", paddingRight: '30px'}}>
<DialogActions style={{ paddingLeft: "30px", paddingRight: '30px' }}>
<Button
style={{ borderRadius: "0px" }}
onClick={() => setModalOpen(false)}
@@ -265,11 +322,11 @@ const CacheView = (props) => {
variant="contained"
style={{ borderRadius: "0px" }}
onClick={() => {
addOrgCache(orgId)
{editCache ? editOrgCache(orgId) : addOrgCache(orgId)}
}}
color="primary"
>
Submit
{editCache ? "Edit":"Submit"}
</Button>
</DialogActions>
</Dialog>
@@ -282,7 +339,7 @@ const CacheView = (props) => {
<div style={{ marginTop: 20, marginBottom: 20 }}>
<h2 style={{ display: "inline" }}>Shuffle Datastore</h2>
<span style={{ marginLeft: 25 }}>
Datastore is a key-value store for storing data that can be used cross-workflow.&nbsp;
Datastore is a key-value store for storing data that can be used cross-workflow.&nbsp;
<a
target="_blank"
rel="noopener noreferrer"
@@ -297,7 +354,11 @@ const CacheView = (props) => {
style={{}}
variant="contained"
color="primary"
onClick={() => setModalOpen(true)}
onClick={() =>{
setEditCache(false)
setModalOpen(true)
}
}
>
Add Cache
</Button>
@@ -319,19 +380,19 @@ const CacheView = (props) => {
<ListItem>
<ListItemText
primary="Key"
// style={{ minWidth: 150, maxWidth: 150 }}
// style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
primary="value"
// style={{ minWidth: 150, maxWidth: 150 }}
// style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
primary="Updated"
// style={{ minWidth: 150, maxWidth: 150 }}
// style={{ minWidth: 150, maxWidth: 150 }}
/>
<ListItemText
primary="Actions"
// style={{ minWidth: 150, maxWidth: 150 }}
// style={{ minWidth: 150, maxWidth: 150 }}
/>
</ListItem>
{listCache === undefined || listCache === null
@@ -345,27 +406,41 @@ const CacheView = (props) => {
return (
<ListItem key={index} style={{ backgroundColor: bgColor }}>
<ListItemText
style={{
maxWidth: 225,
minWidth: 225,
overflow: "hidden",
}}
style={{
maxWidth: 225,
minWidth: 225,
overflow: "hidden",
}}
primary={data.key}
/>
<div style={scrollStyle1}>
<ListItemText
style={{
maxWidth: 225,
minWidth: 225,
overflow: "hidden",
paddingLeft: "52px",
}}
// style={{
// maxWidth: 225,
// maxHeight: 150,
// // overflow: "hidden",
// paddingLeft: "52px",
// overflow: "scroll",
// }}
style={scrollStyle2}
// style={{ maxWidth: 100, minWidth: 100 }}
primary={data.value} />
// onMouseOver={() =>
// setShow((prevState) => ({ ...prevState, [data.value]: true }))
// }
// onMouseLeave={() =>
// setShow((prevState) => ({ ...prevState, [data.value]: false }))
// }
//primary={show[data.value] ? data.value : `${data.value.substring(0, 5)}...`}
primary={data.value}
/>
</div>
<ListItemText
style={{
maxWidth: 225,
minWidth: 225,
overflow: "hidden",
marginLeft: "42px",
}}
primary={new Date(data.edited * 1000).toISOString()}
/>
@@ -377,7 +452,7 @@ const CacheView = (props) => {
paddingLeft: "155px",
}}
primary=<span style={{ display: "inline" }}>
{/* <Tooltip
<Tooltip
title="Edit"
style={{}}
aria-label={"Edit"}
@@ -386,7 +461,9 @@ const CacheView = (props) => {
<IconButton
style={{ padding: "6px" }}
onClick={() => {
setEditCache(true)
setDataValue({"key":data.key,"value":data.value})
setModalOpen(true)
}}
>
<EditIcon
@@ -394,7 +471,7 @@ const CacheView = (props) => {
/>
</IconButton>
</span>
</Tooltip> */}
</Tooltip>
<Tooltip
title={"Delete Cache"}
style={{ marginLeft: 15, }}