Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Add info modal (#95)
Browse files Browse the repository at this point in the history
* added info modal

* Update App.tsx

* changed to neutral
  • Loading branch information
JensvandeWiel authored Nov 8, 2023
1 parent c27d915 commit 56d6a46
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 9 deletions.
52 changes: 46 additions & 6 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import {
Alert,
Alert, AspectRatio,
Button,
Card,
DialogActions,
DialogTitle, Divider,
Drawer, IconButton, List, ListItem,
ListItemButton,
ModalClose, Tooltip,
ListItemButton, Modal,
ModalClose, ModalDialog, Tooltip, Typography,
} from "@mui/joy";
import {ThemeSwitcher} from "./components/ThemeSwitcher";
import {HomeButton} from "./components/HomeButton";
import { ServerList } from "./components/ServerList";
import {useEffect, useState} from "react";
import React, {useEffect, useState} from "react";
import {Server} from "./pages/Server";
import {IconArrowLeft, IconExternalLink, IconPlus, IconRefresh} from "@tabler/icons-react";
import {IconArrowLeft, IconExternalLink, IconHome, IconInfoCircle, IconPlus, IconRefresh} from "@tabler/icons-react";
import {CreateServer, GetAllServers, GetAllServersFromDir, GetServerDir} from "../wailsjs/go/server/ServerController";
import {server} from "../wailsjs/go/models";
import {BrowserOpenURL, EventsOff, EventsOn, LogDebug} from "../wailsjs/runtime";
import {AlertProvider} from "./components/AlertProvider";
import banner from "./assets/AASM_V3_banner2.png"
import {GetVersion} from "../wailsjs/go/helpers/HelpersController";

enum ServerListType {
CARD,
Expand All @@ -28,7 +30,8 @@ function App() {
const [activeServer, setActiveServer] = useState<number | undefined>(undefined)
const [drawerOpen, setDrawerOpen] = useState(false);
const [servers, setServers] = useState<{[key: number]: server.Server}|null>(null);

const [infoModalOpen, setInfoModalOpen] = useState(false);
const [appVersion, setAppVersion] = useState("");



Expand Down Expand Up @@ -67,6 +70,7 @@ function App() {

useEffect(() => {
getServers()
GetVersion().then(version => setAppVersion(version))

}, []);

Expand Down Expand Up @@ -96,6 +100,7 @@ function App() {
<DialogActions>
<List>
<ListItem>

<Tooltip title={'Reload servers from disk'}><IconButton color={'danger'} variant={"solid"} onClick={() => {getServersFromDir(); setActiveServer(undefined)}}><IconRefresh/></IconButton></Tooltip>
<Tooltip title={'Refresh server list from cache'}><IconButton onClick={() => {getServers(); setActiveServer(undefined)}}><IconRefresh/></IconButton></Tooltip>
<Tooltip title={'Open servers folder'}><IconButton onClick={() => {GetServerDir().then((dir: string) => BrowserOpenURL("file:///" + dir))}}><IconExternalLink/></IconButton></Tooltip>
Expand Down Expand Up @@ -147,6 +152,41 @@ function App() {
<div className={'ml-auto my-auto mr-8 gap-2 flex'}>
<ThemeSwitcher/>
<HomeButton setServ={setActiveServer}/>
<IconButton
variant="soft"
color="neutral"
onClick={() => setInfoModalOpen(true)}
>
<IconInfoCircle/>
</IconButton>
<Modal open={infoModalOpen} onClose={() => setInfoModalOpen(false)}>
<ModalDialog>
<ModalClose/>
<AspectRatio minHeight="120px" sx={{margin: 2}} maxHeight="200px">
<img

src={banner}
loading="lazy"
alt=""
/>
</AspectRatio>
<Divider/>
<div className={"p-4"}>
<Typography level={"title-lg"}>
Info:
</Typography>
<Typography level={"body-sm"} className={"flex-grow"}>
Version: {appVersion}
</Typography>
<div style={{height: 200}}></div>
<Button color={"neutral"} sx={{margin: 1}} onClick={() => BrowserOpenURL("https://github.com/JensvandeWiel/ArkAscendedServerManager")}>GitHub</Button>
<Button color={"neutral"} sx={{margin: 1}} onClick={() => BrowserOpenURL("https://discord.gg/RmesnZ8FWf")}>Discord</Button>
<Button color={"neutral"} sx={{margin: 1}} onClick={() => BrowserOpenURL("https://github.com/sponsors/JensvandeWiel")}>Sponsor me</Button>


</div>
</ModalDialog>
</Modal>
</div>
</div>
{mainUi}
Expand Down
Binary file added frontend/src/assets/AASM_V3_banner2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 15 additions & 2 deletions helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,34 @@ package helpers

import (
"context"
"encoding/json"
"fmt"
"github.com/wailsapp/wails/v2/pkg/runtime"
)

type HelpersController struct {
ctx context.Context
ctx context.Context
WailsCfg *Env
}

func NewHelpersController() *HelpersController {
return &HelpersController{}
}

func (c *HelpersController) Startup(ctx context.Context) {
func (c *HelpersController) Startup(ctx context.Context, wailsCfgFile []byte) {
c.ctx = ctx
err := json.Unmarshal(wailsCfgFile, &c.WailsCfg)
if err != nil {
fmt.Printf("Error: Could not parse wails.json: %s\n", err)
println("Skipping update check")
return
}
}

func (c *HelpersController) OpenDirectoryDialog() (string, error) {
return runtime.OpenDirectoryDialog(c.ctx, runtime.OpenDialogOptions{})
}

func (c *HelpersController) GetVersion() string {
return c.WailsCfg.Version
}
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func main() {
c.Startup(ctx)
s.Startup(ctx)
i.Startup(ctx)
h.Startup(ctx)
h.Startup(ctx, WailsConfigFile)
},
Logger: l,
LogLevel: wailsLogger.TRACE,
Expand Down

0 comments on commit 56d6a46

Please sign in to comment.