Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jul 21, 2022
1 parent 377da7d commit 35538b8
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 24 deletions.
42 changes: 42 additions & 0 deletions interface/windows/settings/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { resetState } from "../../stores/state"
import { resetSettings } from "../../stores/settings"
import build from "../../../build.json"
import { fs, path, invoke, os, dialog, app } from "@tauri-apps/api"
import { UAParser } from "ua-parser-js"
import { navigate } from "../../libraries/navigate"

export const about = async () => {
const appVersion = await app.getVersion()
const tauriVersion = await app.getTauriVersion()
const osType = await os.type()
const osArch = await os.arch()
const osVersion = await os.version()
const chromeVersion = new UAParser().getBrowser().version

let hardware: any = await invoke("system_info")

hardware = hardware.split("+")

const cpu = hardware[0]
.split("@")[0]
.replaceAll("(R)", "")
.replaceAll("(TM)", "")
.replace(/ +(?= )/g, "")
const memory = `${Math.round(hardware[1] / 1024 / 1024)}GB`

dialog.message(`Authme: ${appVersion} \n\nTauri: ${tauriVersion}\nChrome: ${chromeVersion}\n\nOS version: ${osType} ${osArch.replace("x86_64", "x64")} ${osVersion}\nHardware info: ${cpu}${memory} RAM\n\nRelease date: ${build.date}\nBuild number: ${build.number}\n\nCreated by: Lőrik Levente`)
}

export const clearData = async () => {
localStorage.clear()
sessionStorage.clear()

const folderPath = await path.join(await path.configDir(), "Levminer", "Authme 4")
await fs.removeDir(folderPath, { recursive: true })

resetState()
resetSettings()

navigate("/")
location.reload()
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>Close to tray</h2>
<h3>When closing Authme the app will not quit. You can open Authme from the system tray.</h3>
<h2>Mimimize to tray</h2>
<h3>When closeing the app Authme will not quit. You can open Authme from the system tray.</h3>
</div>
<div class="ml-20 flex gap-3">
<Toggle />
Expand All @@ -40,7 +40,6 @@
<div class="ml-20 flex gap-3">
<button class="button" on:click={clearData}>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<!-- svelte-ignore component-name-lowercase -->
<path stroke-linecap="round" stroke-linejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
Clear data
Expand Down Expand Up @@ -96,30 +95,64 @@
</div>
</div>

<script>
import Dropdown from "../components/dropdown.svelte"
import { navigate } from "../libraries/navigate"
import { resetState } from "../stores/state"
import { resetSettings } from "../stores/settings"
import Toggle from "../components/toggle.svelte"
import { fs, path } from "@tauri-apps/api"
const handleMessage = (event) => {
console.log(event.detail.value)
}
<div class="transparent-900 m-auto my-20 w-4/5 rounded-2xl p-10 text-left">
<h1 class="px-10">About</h1>

const clearData = async () => {
localStorage.clear()
sessionStorage.clear()
<div class="mx-auto flex flex-col items-center justify-center rounded-2xl p-10">
<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>Licenses</h2>
<h3>Authme is an open source software. You can view the licenses.</h3>
</div>
<div class="ml-20 flex gap-3">
<button class="button" on:click={about}>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
<circle cx="12" cy="12" r="9" />
<path d="M14.5 9a3.5 4 0 1 0 0 6" />
</svg>
View licenses
</button>
</div>
</div>
<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>Logs</h2>
<h3>You can view the logs for debugging. You can view all the logs in the settings folder.</h3>
</div>
<div class="ml-20 flex gap-3">
<button class="button" on:click={about}>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
Show logs
</button>
</div>
</div>

const folderPath = await path.join(await path.configDir(), "Levminer", "Authme 4")
await fs.removeDir(folderPath, { recursive: true })
<div class="transparent-800 mb-5 flex w-full flex-row items-center justify-between rounded-xl p-5 text-left">
<div>
<h2>About Authme</h2>
<h3>Information about your Authme build.</h3>
</div>
<div class="ml-20 flex gap-3">
<button class="button" on:click={about}>
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
About Authme
</button>
</div>
</div>
</div>
</div>

resetState()
resetSettings()
<script>
import Dropdown from "../../components/dropdown.svelte"
import Toggle from "../../components/toggle.svelte"
import { about, clearData } from "./index"
navigate("/")
location.reload()
const handleMessage = (event) => {
console.log(event.detail.value)
}
</script>

0 comments on commit 35538b8

Please sign in to comment.