Skip to content

Commit 3606122

Browse files
committed
Add version text to the menu, add format & location to export page
1 parent 9f9561e commit 3606122

File tree

9 files changed

+67
-9
lines changed

9 files changed

+67
-9
lines changed

app.go

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package main
22

33
import (
44
"context"
5+
_ "embed"
6+
"encoding/json"
57
"rm-exporter/backend"
68
"slices"
79
"time"
@@ -20,6 +22,9 @@ type App struct {
2022
export_from int
2123
}
2224

25+
//go:embed wails.json
26+
var wailsJSON string
27+
2328
// NewApp creates a new App application struct
2429
func NewApp() *App {
2530
return &App{}
@@ -32,6 +37,15 @@ func (a *App) startup(ctx context.Context) {
3237
a.export_from = -1
3338
}
3439

40+
func (a *App) GetAppVersion() string {
41+
m := make(map[string]interface{})
42+
err := json.Unmarshal([]byte(wailsJSON), &m)
43+
if err != nil {
44+
return "0.0.0"
45+
}
46+
return m["info"].(map[string]interface{})["productVersion"].(string)
47+
}
48+
3549
func (a *App) ReadTabletDocs(tablet_addr string) error {
3650
a.tablet_addr = tablet_addr
3751

@@ -60,6 +74,10 @@ func (a *App) SetExportOptions(export backend.RmExport) {
6074
a.rm_export = export
6175
}
6276

77+
func (a *App) GetExportOptions() backend.RmExport {
78+
return a.rm_export
79+
}
80+
6381
func (a *App) Export() {
6482
files := a.GetCheckedFiles()
6583
if a.export_from == -1 {

frontend/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "frontend",
33
"private": true,
4-
"version": "0.0.0",
4+
"version": "0.1.0",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

frontend/package.json.md5

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6f70e2e44a9cfb36d4078361ae189b46
1+
9eb8833ac8cf20917d1b6079bf98b5ff

frontend/src/pages/Export.svelte

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<script lang="ts">
22
import { Alert, Button, Listgroup, Navbar, P, Spinner } from "flowbite-svelte";
3-
import { Export, GetCheckedFiles} from '../../wailsjs/go/main/App.js';
3+
import { Export, GetCheckedFiles, GetExportOptions } from '../../wailsjs/go/main/App.js';
44
import { CheckOutline, ExclamationCircleOutline, FileLinesSolid, InfoCircleSolid } from "flowbite-svelte-icons";
55
import { EventsOn } from "../../wailsjs/runtime/runtime.js";
66
import { backend } from "../../wailsjs/go/models.js";
77
type DocInfo = backend.DocInfo;
88
99
let exportItems: DocInfo[] = $state([]);
1010
let exportItemState: {[key: string]: string;} = $state({});
11+
let exportOptions: backend.RmExport = $state({});
1112
1213
let errorMessage: string = $state("hello");
1314
let showError: boolean = $state(false);
@@ -18,6 +19,11 @@
1819
exportItems = result;
1920
});
2021
22+
GetExportOptions()
23+
.then((result: backend.RmExport) => {
24+
exportOptions = result;
25+
});
26+
2127
Export();
2228
2329
const onRetry = () => {
@@ -64,9 +70,13 @@
6470
<Navbar color="blue" class="sticky top-0">
6571
<h1 class="font-bold m-auto">{finishedAllItems() ? "Success!" : "Export"}</h1>
6672
</Navbar>
67-
73+
6874
<main class="pr-7 pl-7 mt-3 w-full">
69-
{#if exportItems.length > 0}
75+
76+
<h2 class="text-md">Format: {exportOptions["Format"]}</h2>
77+
<h2 class="text-md mb-3">Location: {exportOptions["Location"]}</h2>
78+
79+
{#if exportItems.length > 0}
7080
<Listgroup items={exportItems} let:item active={false}>
7181
<div class="flex flex-row justify-start items-center w-full">
7282
<FileLinesSolid class="mr-1" size="lg" />

frontend/src/pages/Menu.svelte

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
<script lang="ts">
2-
import { Alert, Button, P, Input, Label, Spinner} from 'flowbite-svelte';
2+
import { Alert, Button, P, Input, Label, Spinner, Footer, A} from 'flowbite-svelte';
33
import { ArrowRightOutline, InfoCircleSolid, TabletSolid, CloseOutline } from 'flowbite-svelte-icons';
4-
import { ReadTabletDocs, IsIpValid} from '../../wailsjs/go/main/App.js';
4+
import { ReadTabletDocs, IsIpValid, GetAppVersion } from '../../wailsjs/go/main/App.js';
55
import { push } from 'svelte-spa-router';
6+
import { BrowserOpenURL } from '../../wailsjs/runtime/runtime.js';
67
8+
const source = "https://github.com/chopikus/rm-exporter";
9+
let version = $state("");
10+
11+
GetAppVersion().then((v: string) => {
12+
version = v;
13+
});
14+
715
let rmIp: string = $state("10.11.99.1");
816
let isRmIpValid: boolean = $state(true);
917
let loading: boolean = $state(false);
@@ -34,6 +42,10 @@
3442
});
3543
}
3644
45+
const onSourceClick = () => {
46+
BrowserOpenURL(source)
47+
};
48+
3749
</script>
3850

3951
{#key show_error}
@@ -68,3 +80,6 @@
6880
</Button>
6981
</div>
7082
</main>
83+
<Footer class="absolute bottom-0">
84+
<P size="sm">Version {version}. Source available at <A onclick={onSourceClick}>{source}</A></P>
85+
</Footer>

frontend/wailsjs/go/main/App.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ export function DirectoryDialog():Promise<string>;
66

77
export function Export():Promise<void>;
88

9+
export function GetAppVersion():Promise<string>;
10+
911
export function GetCheckedFiles():Promise<Array<backend.DocInfo>>;
1012

1113
export function GetCheckedFilesCount():Promise<number>;
1214

15+
export function GetExportOptions():Promise<backend.RmExport>;
16+
1317
export function GetPaths(arg1:Array<string>):Promise<Array<string>>;
1418

1519
export function GetTabletFolder(arg1:string):Promise<Array<backend.DocInfo>>;

frontend/wailsjs/go/main/App.js

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export function Export() {
1010
return window['go']['main']['App']['Export']();
1111
}
1212

13+
export function GetAppVersion() {
14+
return window['go']['main']['App']['GetAppVersion']();
15+
}
16+
1317
export function GetCheckedFiles() {
1418
return window['go']['main']['App']['GetCheckedFiles']();
1519
}
@@ -18,6 +22,10 @@ export function GetCheckedFilesCount() {
1822
return window['go']['main']['App']['GetCheckedFilesCount']();
1923
}
2024

25+
export function GetExportOptions() {
26+
return window['go']['main']['App']['GetExportOptions']();
27+
}
28+
2129
export function GetPaths(arg1) {
2230
return window['go']['main']['App']['GetPaths'](arg1);
2331
}

wails.json

+3
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
"frontend:dev:serverUrl": "auto",
99
"author": {
1010
"name": "Igor Chovpan"
11+
},
12+
"info": {
13+
"productVersion": "0.1.0"
1114
}
1215
}

0 commit comments

Comments
 (0)