Skip to content

Commit

Permalink
add upload button to client log
Browse files Browse the repository at this point in the history
  • Loading branch information
SenkJu authored Dec 11, 2023
1 parent a457890 commit 4e0e5d4
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/lib/main/log/ClientLog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,41 @@
import VirtualList from "./VirtualList.svelte";
import { createEventDispatcher } from "svelte";
import ToggleSetting from "../../settings/ToggleSetting.svelte";
import ButtonSetting from "../../settings/ButtonSetting.svelte"
import LogMessage from "./LogMessage.svelte";
export let messages;
let autoScroll = true;
const dispatch = createEventDispatcher();
async function handleUploadSetting(e) {
const log = messages.join("");
if (await confirm("The entire log of this session will be uploaded. It may contain sensitive information like private chat messages. Are you sure you want to proceed?") !== true) {
return;
}
console.log("ok");
const response = await fetch("https://paste.ccbluex.net/api.php", {
body: `content=${log}`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
method: "POST"
});
const responseData = await response.text();
if (response.status !== 200) {
alert(`Failed to upload log: ${responseData}`);
return;
}
prompt("Your log is available at the following URL: ", responseData);
}
</script>

<div class="log" transition:fly={{ y: -10, duration: 200 }}>
Expand All @@ -26,7 +54,10 @@
</VirtualList>
</div>

<ToggleSetting title="Auto scroll" bind:value={autoScroll} />
<div class="settings">
<ButtonSetting text="Upload log" color="#4677FF" on:click={handleUploadSetting}></ButtonSetting>
<ToggleSetting title="Auto scroll" bind:value={autoScroll} />
</div>
</div>

<style>
Expand All @@ -46,6 +77,12 @@
flex-direction: column;
}
.settings {
display: flex;
gap: 20px;
align-items: center;
}
.output {
flex: 1;
overflow: hidden;
Expand All @@ -70,4 +107,3 @@
cursor: pointer;
}
</style>

0 comments on commit 4e0e5d4

Please sign in to comment.