New launch browser component

- Now possible to click links that launch the browser from the backend
- Version scheme change to account for different methods with desktop applications
This commit is contained in:
Tony Bark 2024-09-19 00:18:24 -04:00
parent 858762d54e
commit 80210156bb
28 changed files with 253 additions and 40 deletions

23
changelog.md Normal file
View file

@ -0,0 +1,23 @@
# Change Log
## 0.104.2
- Clickable links that open the default broswer.
### Version sceheme change
Three digits in the version were moved from the patch to the minor section (i.e., `0.Y.100` to `0.100.Z`) due to the difference in ways of desktop applications are developed, which I never needed to account for until now. It was easier to get away with putting it in the patch for CLI tools and libraries because the core user experience never changed, despite frequent internal changes.
## 0.104.0 (0.1.104)
- New buttons for major terminals and rail cams.
- Version displayed above credits.
## 0.102.0 (0.1.102)
- Redesigned icons
- Added banner above form
## 0.100.0 (0.1.101)
- First public prototype

143
src-tauri/Cargo.lock generated
View file

@ -55,6 +55,7 @@ dependencies = [
"serde_json",
"tauri",
"tauri-build",
"webbrowser",
]
[[package]]
@ -168,6 +169,15 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block2"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
dependencies = [
"objc2",
]
[[package]]
name = "brotli"
version = "6.0.0"
@ -330,7 +340,7 @@ dependencies = [
"bitflags 1.3.2",
"block",
"cocoa-foundation",
"core-foundation",
"core-foundation 0.9.4",
"core-graphics",
"foreign-types",
"libc",
@ -345,7 +355,7 @@ checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7"
dependencies = [
"bitflags 1.3.2",
"block",
"core-foundation",
"core-foundation 0.9.4",
"core-graphics-types",
"libc",
"objc",
@ -383,6 +393,16 @@ dependencies = [
"libc",
]
[[package]]
name = "core-foundation"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
@ -396,7 +416,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-foundation 0.9.4",
"core-graphics-types",
"foreign-types",
"libc",
@ -409,7 +429,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-foundation 0.9.4",
"libc",
]
@ -1177,6 +1197,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "home"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "html5ever"
version = "0.26.0"
@ -1374,6 +1403,22 @@ dependencies = [
"walkdir",
]
[[package]]
name = "jni"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
dependencies = [
"cesu8",
"cfg-if",
"combine",
"jni-sys",
"log",
"thiserror",
"walkdir",
"windows-sys 0.45.0",
]
[[package]]
name = "jni-sys"
version = "0.3.0"
@ -1659,6 +1704,40 @@ dependencies = [
"objc_exception",
]
[[package]]
name = "objc-sys"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310"
[[package]]
name = "objc2"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804"
dependencies = [
"objc-sys",
"objc2-encode",
]
[[package]]
name = "objc2-encode"
version = "4.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7891e71393cd1f227313c9379a26a584ff3d7e6e7159e988851f0934c993f0f8"
[[package]]
name = "objc2-foundation"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8"
dependencies = [
"bitflags 2.6.0",
"block2",
"libc",
"objc2",
]
[[package]]
name = "objc_exception"
version = "0.1.2"
@ -2576,7 +2655,7 @@ dependencies = [
"cairo-rs",
"cc",
"cocoa",
"core-foundation",
"core-foundation 0.9.4",
"core-graphics",
"crossbeam-channel",
"dispatch",
@ -2591,7 +2670,7 @@ dependencies = [
"gtk",
"image",
"instant",
"jni",
"jni 0.20.0",
"lazy_static",
"libc",
"log",
@ -3257,6 +3336,34 @@ version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
[[package]]
name = "web-sys"
version = "0.3.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "webbrowser"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e5f07fb9bc8de2ddfe6b24a71a75430673fd679e568c48b52716cef1cfae923"
dependencies = [
"block2",
"core-foundation 0.10.0",
"home",
"jni 0.21.1",
"log",
"ndk-context",
"objc2",
"objc2-foundation",
"url",
"web-sys",
]
[[package]]
name = "webkit2gtk"
version = "0.18.2"
@ -3446,6 +3553,15 @@ dependencies = [
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets 0.42.2",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
@ -3473,6 +3589,21 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-targets"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm 0.42.2",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm 0.42.2",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-targets"
version = "0.48.5"

View file

@ -14,6 +14,7 @@ tauri-build = { version = "1", features = [] }
tauri = { version = "1", features = ["shell-open"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
webbrowser = "1.0.2"
[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1,006 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View file

@ -1,18 +1,15 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use webbrowser;
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
#[tauri::command]
fn station(name: &str) -> String {
format!(
"https://dixielandsoftware.net/cgi-bin/solari_relay.pl?data={}",
name
)
fn open_browser(address: &str) {
webbrowser::open(address).expect("Failed to open defualt browser.");
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![station])
.invoke_handler(tauri::generate_handler![open_browser])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View file

@ -8,7 +8,7 @@
},
"package": {
"productName": "AMTK Status",
"version": "0.105.10"
"version": "0.104.2"
},
"tauri": {
"allowlist": {

View file

@ -0,0 +1,18 @@
@inject IJSRuntime JsRuntime
<a @onclick="OpenBrowserAsync">@Text</a>
@code {
[Parameter]
[Required]
public string? Text { get; set; }
[Parameter]
[Required]
public string? Address { get; set; }
private async Task OpenBrowserAsync()
{
await JsRuntime.InvokeAsync<string>("__TAURI__.tauri.invoke", "open_browser", new { address = Address });
}
}

View file

@ -1,17 +1,21 @@
@inject IJSRuntime JsRuntime
@inject NavigationManager NavigationManager
<button @onclick="RedirectToStat">@Name</button>
<button @onclick="AddrRedirect">@Name</button>
@code
{
[Parameter] public string? Name { get; set; }
[Parameter]
[Required]
public string? Name { get; set; }
[Parameter] public string? Code { get; set; }
[Parameter]
[Required]
public string? Code { get; set; }
private async Task RedirectToStat()
private void AddrRedirect()
{
var address = await JsRuntime.InvokeAsync<string>("__TAURI__.tauri.invoke", "station", new { name = Code });
var address = $"https://dixielandsoftware.net/cgi-bin/solari_relay.pl?data={Code}";
NavigationManager.NavigateTo(address);
}

View file

@ -1,19 +1,19 @@
@inject IJSRuntime JsRuntime
@inject NavigationManager NavigationManager
<form class="row" @onsubmit="AddrRedirectAsync" @onsubmit:preventDefault="true">
<input id="greet-input" placeholder="3-character Station Code" @bind="CodeInput" />
<form class="row" @onsubmit="AddrRedirect" @onsubmit:preventDefault="true">
<input id="greet-input" placeholder="3-character Station Code" @bind="Code" />
<button type="submit">Submit</button>
</form>
@code
{
private string? CodeInput { get; set; }
private string? Code { get; set; }
private async Task AddrRedirectAsync()
private void AddrRedirect()
{
var address = await JsRuntime.InvokeAsync<string>("__TAURI__.tauri.invoke", "station", new { name = CodeInput });
var address = $"https://dixielandsoftware.net/cgi-bin/solari_relay.pl?data={Code}";
NavigationManager.NavigateTo(address);
}
}
}

View file

@ -1 +1 @@
0.105.10
0.104.2

View file

@ -3,6 +3,9 @@
<div class="container">
<img src="img/amtkstat.svg" class="logo" alt="Amtrak Status" />
<StationInput />
<p>Search
<LaunchBrowser Text="Station Codes" Address="https://dixielandsoftware.net/Amtrak/solari/StationSearch.html" />
</p>
<div class="row">
<div class="container">
<StationBtn Code="NYP" Name="NY Penn Station" />
@ -32,9 +35,9 @@
<sub>
<i>
<p>
<GitVersion /><br>Status Boards by Dixieland Software
<GitVersion /><br>Status Boards by
<LaunchBrowser Text="Dixieland Software" Address="https://dixielandsoftware.net/" />
</p>
</i>
</sub>
</footer>

View file

@ -33,6 +33,40 @@ footer {
bottom: 0;
}
/* The sidebar menu */
.sidenav {
height: 100%;
/* Full-height: remove this if you want "auto" height */
width: 160px;
/* Set the width of the sidebar */
position: fixed;
/* Fixed Sidebar (stay in place on scroll) */
z-index: 1;
/* Stay on top */
top: 0;
/* Stay at the top */
left: 0;
background-color: #111;
/* Black */
overflow-x: hidden;
/* Disable horizontal scroll */
padding-top: 20px;
}
/* The navigation menu links */
.sidenav a {
padding: 6px 8px 6px 16px;
text-decoration: none;
font-size: 25px;
color: #818181;
display: block;
}
/* When you mouse over the navigation links, change their color */
.sidenav a:hover {
color: #f1f1f1;
}
.logo {
height: 6em;
padding: 1.5em;

View file

@ -1,15 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + Blazor</title>
<base href="/" />
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<div id="app"></div>
<script src="_framework/blazor.webassembly.js"></script>
</body>
</html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + Blazor</title>
<base href="/" />
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<div id="app"></div>
<script src="_framework/blazor.webassembly.js"></script>
</body>
</html>