chore: Add loadAutoServerBackup button to UserSettings page
This commit is contained in:
@@ -653,4 +653,5 @@ export const languageEnglish = {
|
||||
successApplyModule: "Module is successfully applied",
|
||||
font: "Font",
|
||||
lineHeight: "Line Height",
|
||||
loadAutoServerBackup: "Load Auto Server Backup",
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { language } from "src/lang";
|
||||
import { hubURL } from "src/ts/characterCards";
|
||||
import { loadRisuAccountData, saveRisuAccountData } from "src/ts/drive/accounter";
|
||||
import { loadRisuAccountBackup, loadRisuAccountData, saveRisuAccountData } from "src/ts/drive/accounter";
|
||||
import { DataBase } from "src/ts/storage/database";
|
||||
import Check from "src/lib/UI/GUI/CheckInput.svelte";
|
||||
import { alertConfirm, alertNormal } from "src/ts/alert";
|
||||
@@ -43,18 +43,6 @@
|
||||
|
||||
<h2 class="mb-2 text-2xl font-bold mt-2">{language.account} & {language.files}</h2>
|
||||
|
||||
{#await persistantStorageRecommended() then a}
|
||||
{#if a}
|
||||
<button
|
||||
class="flex justify-center p-3 text-left items-start border-red-300 cursor-pointer hover:border-red-700 border-solid mt-2 border-2 hover:bg-red-600 text-textcolor hover:text-white transition-colors rounded-md flex-col"
|
||||
on:click={requestPersistantStorage}
|
||||
>
|
||||
<h3 class="text-xl">{language.persistentStorageRecommended}</h3>
|
||||
<span class="text-gray-200">{language.persistentStorageDesc}</span>
|
||||
</button>
|
||||
{/if}
|
||||
{/await}
|
||||
|
||||
<Button
|
||||
on:click={async () => {
|
||||
if(await alertConfirm(language.backupConfirm)){
|
||||
@@ -73,6 +61,17 @@
|
||||
{language.loadBackupLocal}
|
||||
</Button>
|
||||
|
||||
<!-- {#if $DataBase.account}
|
||||
<Button
|
||||
on:click={async () => {
|
||||
if((await alertConfirm(language.backupLoadConfirm)) && (await alertConfirm(language.backupLoadConfirm2))){
|
||||
loadRisuAccountBackup()
|
||||
}
|
||||
}} className="mt-2">
|
||||
{language.loadAutoServerBackup}
|
||||
</Button>
|
||||
{/if} -->
|
||||
|
||||
<Button
|
||||
on:click={async () => {
|
||||
if(await alertConfirm(language.backupConfirm)){
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { get } from "svelte/store"
|
||||
import { hubURL } from "../characterCards"
|
||||
import { DataBase } from "../storage/database"
|
||||
import { alertError } from "../alert"
|
||||
import { alertError, alertSelect } from "../alert"
|
||||
|
||||
export async function risuLogin() {
|
||||
const win = window.open(hubURL + '/hub/login')
|
||||
@@ -49,4 +49,34 @@ export async function loadRisuAccountData() {
|
||||
return
|
||||
}
|
||||
db.account.data = await s.json()
|
||||
}
|
||||
|
||||
export async function loadRisuAccountBackup() {
|
||||
const db = get(DataBase)
|
||||
if(!db.account){
|
||||
alertError("Not logged in error")
|
||||
return
|
||||
}
|
||||
const s = await fetch(hubURL + '/hub/backup/list', {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"x-risu-auth": db.account.token
|
||||
}
|
||||
})
|
||||
if(s.status !== 200){
|
||||
alertError(await s.text())
|
||||
return
|
||||
}
|
||||
const backups = await s.json()
|
||||
if(!backups.length){
|
||||
alertError("No backups found")
|
||||
return
|
||||
}
|
||||
const backupIdStr = await alertSelect(backups)
|
||||
const backupIdNum = parseInt(backupIdStr)
|
||||
if(isNaN(backupIdNum)){
|
||||
alertError("Invalid backup id")
|
||||
return
|
||||
}
|
||||
const backupId = backups[backupIdNum]
|
||||
}
|
||||
Reference in New Issue
Block a user