Enable propellerads

This commit is contained in:
2020-11-26 11:13:27 +01:00
parent fd2a9234ad
commit 99568f2da3
9 changed files with 70 additions and 6877 deletions

View File

@@ -1,36 +1,34 @@
<script context="module">
export const fs_create_directory = (bucket, path, dir_name) => {
export const fs_create_directory = async (bucket, path, dir_name) => {
if (!path.startsWith("/")) {
path = "/" + path
}
let form = new FormData()
const form = new FormData()
form.append("type", "dir")
return fetch(
window.api_endpoint + "/filesystem/" + bucket + encodeURIComponent(path + "/" + dir_name),
{method: "POST", body: form},
).then(resp => {
if (resp.status >= 400) {
throw new Error(resp.text())
}
})
const resp=await fetch(
window.api_endpoint+"/filesystem/"+bucket+encodeURIComponent(path+"/"+dir_name),
{ method: "POST", body: form }
);
if(resp.status >= 400) {
throw new Error(resp.text());
}
}
export const fs_get_node = (bucket, path) => {
export const fs_get_node = async (bucket, path) => {
if (!path.startsWith("/")) {
path = "/" + path
}
return fetch(
window.api_endpoint + "/filesystem/" + bucket + encodeURIComponent(path) + "?stat",
).then(resp => {
if (resp.status >= 400) {
throw new Error(resp.text())
}
return resp.json()
})
const resp = await fetch(
window.api_endpoint+"/filesystem/"+bucket+encodeURIComponent(path)+"?stat"
);
if(resp.status >= 400) {
throw new Error(resp.text());
}
return resp.json();
}
export const fs_get_file_url = (bucket, path) => {
@@ -40,19 +38,18 @@ export const fs_get_file_url = (bucket, path) => {
return window.api_endpoint + "/filesystem/" + bucket + encodeURIComponent(path)
}
export const fs_delete_node = (bucket, path) => {
export const fs_delete_node = async (bucket, path) => {
if (!path.startsWith("/")) {
path = "/" + path
}
return fetch(
window.api_endpoint + "/filesystem/" + bucket + encodeURIComponent(path),
{method: "DELETE"},
).then(resp => {
if (resp.status >= 400) {
throw new Error(resp.text())
}
})
const resp = await fetch(
window.api_endpoint+"/filesystem/"+bucket+encodeURIComponent(path),
{ method: "DELETE" }
);
if(resp.status >= 400) {
throw new Error(resp.text());
}
}
</script>