Skip to content

Commit 7a2a746

Browse files
committed
Add: dekstop-app: First aproach
1 parent 5e7ca20 commit 7a2a746

36 files changed

+355
-0
lines changed

ping-viewer-next-desktop/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

ping-viewer-next-desktop/README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Ping Viewer Next DesktopApp
2+
3+
Ping Viewer Next Desktop is a standalone version of the **Ping Viewer Next** core server. This application allows you to interface with **ping devices** attached directly to your computer or connected to a remotely one.
4+
5+
## Key Features
6+
7+
- **Local and Remote Connections**: Connect to ping devices on your local network or to remote Ping Viewer Next servers.
8+
- **Cross-Platform Support**: Available for macOS, Linux, and Windows.
9+
- **Standalone App**: Just install and use directly on your favorite OS.
10+
11+
### Download
12+
13+
You can download the latest version from the [releases page](https://github.com/bluerobotics/ping-viewer-next/releases).
14+
15+
## How It Works
16+
17+
Ping Viewer Next Desktop integrates the core Ping Viewer Next server with an embedded GUI, using Tauri to create a native experience across platforms.

ping-viewer-next-desktop/bun.lockb

38.5 KB
Binary file not shown.

ping-viewer-next-desktop/index.html

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Tauri + Vue + Typescript App</title>
8+
</head>
9+
10+
<body>
11+
<div id="app"></div>
12+
<script type="module" src="/src/main.ts"></script>
13+
</body>
14+
</html>

ping-viewer-next-desktop/package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "ping-viewer-next-desktop",
3+
"private": true,
4+
"version": "0.1.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vue-tsc --noEmit && vite build",
9+
"preview": "vite preview",
10+
"tauri": "tauri"
11+
},
12+
"dependencies": {
13+
"vue": "^3.3.4",
14+
"@tauri-apps/api": "^1"
15+
},
16+
"devDependencies": {
17+
"@vitejs/plugin-vue": "^5.0.5",
18+
"typescript": "^5.2.2",
19+
"vite": "^5.3.1",
20+
"vue-tsc": "^2.0.22",
21+
"@tauri-apps/cli": "^1"
22+
}
23+
}
Loading
+1
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
/target/
4+
5+
# Generated by Tauri
6+
# will have schema files for capabilities auto-completion
7+
/gen/schemas
8+
9+
/Cargo.lock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "ping-viewer-next-desktop"
3+
version = "0.1.0"
4+
description = "A Tauri App"
5+
authors = ["you"]
6+
edition = "2021"
7+
8+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9+
10+
[build-dependencies]
11+
tauri-build = { version = "1.5.4", features = [] }
12+
13+
[dependencies]
14+
tauri = { version = "1.7.2", features = ["shell-open"] }
15+
serde = { version = "1", features = ["derive"] }
16+
serde_json = "1"
17+
ping-viewer-next = { path = "./../../", features = ["desktop-app"] }
18+
tokio = { version = "1.40.0", features = ["full"] }
19+
actix-web = "4.6.0"
20+
21+
[features]
22+
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
23+
custom-protocol = ["tauri/custom-protocol"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
tauri_build::build()
3+
}
Loading
Loading
974 Bytes
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Binary file not shown.
Binary file not shown.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
2+
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
3+
4+
use ping_viewer_next::{cli, device, logger, server};
5+
use tauri::Manager;
6+
7+
#[tokio::main]
8+
async fn main() {
9+
cli::manager::init();
10+
11+
logger::manager::init();
12+
13+
let (manager, handler) = device::manager::DeviceManager::new(10);
14+
15+
tokio::spawn(async move { manager.run().await });
16+
17+
run_tauri_app(handler).await;
18+
}
19+
20+
async fn run_tauri_app(handler: device::manager::ManagerActorHandler) {
21+
tauri::Builder::default()
22+
.setup(|app: &mut tauri::App| {
23+
let window = app.get_window("main").unwrap();
24+
25+
std::thread::spawn(move || {
26+
run_from_tauri(&cli::manager::server_address(), handler).unwrap();
27+
});
28+
29+
std::thread::spawn(move || {
30+
std::thread::sleep(std::time::Duration::from_secs(6));
31+
window.eval("window.location.replace('http://0.0.0.0:8080')").unwrap();
32+
});
33+
34+
Ok(())
35+
})
36+
.run(tauri::generate_context!())
37+
.expect("error while running tauri application");
38+
}
39+
40+
#[actix_web::main]
41+
pub async fn run_from_tauri(
42+
server_address: &str,
43+
handler: device::manager::ManagerActorHandler,
44+
) -> std::io::Result<()> {
45+
server::manager::run(server_address, handler).await
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"build": {
3+
"beforeDevCommand": "bun run dev",
4+
"beforeBuildCommand": "bun run build",
5+
"devPath": "http://localhost:1420",
6+
"distDir": "../dist"
7+
},
8+
"package": {
9+
"productName": "ping-viewer-next-desktop",
10+
"version": "0.1.0"
11+
},
12+
"tauri": {
13+
"allowlist": {
14+
"all": false,
15+
"shell": {
16+
"all": false,
17+
"open": true
18+
}
19+
},
20+
"windows": [
21+
{
22+
"title": "ping-viewer-next-desktop",
23+
"width": 800,
24+
"height": 600
25+
}
26+
],
27+
"security": {
28+
"csp": null
29+
},
30+
"bundle": {
31+
"active": true,
32+
"targets": "all",
33+
"identifier": "com.ping-viewer-next-desktop.app",
34+
"icon": [
35+
"icons/32x32.png",
36+
"icons/128x128.png",
37+
38+
"icons/icon.icns",
39+
"icons/icon.ico"
40+
]
41+
}
42+
}
43+
}

ping-viewer-next-desktop/src/App.vue

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<script setup lang="ts">
2+
import { ref, onMounted } from "vue";
3+
4+
const loading = ref(true);
5+
6+
const checkServerReady = () => {
7+
setTimeout(() => {
8+
loading.value = false;
9+
}, 2000);
10+
};
11+
12+
onMounted(() => {
13+
checkServerReady();
14+
});
15+
</script>
16+
17+
<template>
18+
<div v-if="loading" class="preloader">
19+
<h1>Ping Viewer Next</h1>
20+
<p>Creating a local server...</p>
21+
</div>
22+
23+
<div v-else class="container">
24+
<h1>Ping Viewer Next</h1>
25+
<p>Server is ready!</p>
26+
</div>
27+
</template>
28+
29+
<style scoped>
30+
.preloader, .container {
31+
display: flex;
32+
flex-direction: column;
33+
justify-content: center;
34+
align-items: center;
35+
width: 100vw;
36+
height: 100vh;
37+
margin: 0;
38+
padding: 0;
39+
background-color: #f0f0f0;
40+
}
41+
42+
h1 {
43+
font-size: 3rem;
44+
margin-bottom: 1rem;
45+
}
46+
47+
p {
48+
font-size: 1.5rem;
49+
color: #666;
50+
}
51+
52+
html, body {
53+
margin: 0;
54+
padding: 0;
55+
overflow: hidden;
56+
}
57+
</style>
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script setup lang="ts">
2+
import { ref } from "vue";
3+
import { invoke } from "@tauri-apps/api/tauri";
4+
5+
const greetMsg = ref("");
6+
const name = ref("");
7+
8+
async function greet() {
9+
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
10+
greetMsg.value = await invoke("greet", { name: name.value });
11+
}
12+
</script>
13+
14+
<template>
15+
<form class="row" @submit.prevent="greet">
16+
<input id="greet-input" v-model="name" placeholder="Enter a name..." />
17+
<button type="submit">Greet</button>
18+
</form>
19+
20+
<p>{{ greetMsg }}</p>
21+
</template>

ping-viewer-next-desktop/src/main.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createApp } from "vue";
2+
import App from "./App.vue";
3+
4+
createApp(App).mount("#app");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference types="vite/client" />
2+
3+
declare module "*.vue" {
4+
import type { DefineComponent } from "vue";
5+
const component: DefineComponent<{}, {}, any>;
6+
export default component;
7+
}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"module": "ESNext",
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "bundler",
11+
"allowImportingTsExtensions": true,
12+
"resolveJsonModule": true,
13+
"isolatedModules": true,
14+
"noEmit": true,
15+
"jsx": "preserve",
16+
17+
/* Linting */
18+
"strict": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true,
21+
"noFallthroughCasesInSwitch": true
22+
},
23+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
24+
"references": [{ "path": "./tsconfig.node.json" }]
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"allowSyntheticDefaultImports": true
8+
},
9+
"include": ["vite.config.ts"]
10+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineConfig } from "vite";
2+
import vue from "@vitejs/plugin-vue";
3+
4+
// https://vitejs.dev/config/
5+
export default defineConfig(async () => ({
6+
plugins: [vue()],
7+
8+
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
9+
//
10+
// 1. prevent vite from obscuring rust errors
11+
clearScreen: false,
12+
// 2. tauri expects a fixed port, fail if that port is not available
13+
server: {
14+
port: 1420,
15+
strictPort: true,
16+
watch: {
17+
// 3. tell vite to ignore watching `src-tauri`
18+
ignored: ["**/src-tauri/**"],
19+
},
20+
},
21+
}));

0 commit comments

Comments
 (0)