Skip to content

Commit

Permalink
Add: dekstop-app: First aproach
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin committed Sep 19, 2024
1 parent 5e7ca20 commit 7a2a746
Show file tree
Hide file tree
Showing 36 changed files with 355 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ping-viewer-next-desktop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
17 changes: 17 additions & 0 deletions ping-viewer-next-desktop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Ping Viewer Next DesktopApp

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.

## Key Features

- **Local and Remote Connections**: Connect to ping devices on your local network or to remote Ping Viewer Next servers.
- **Cross-Platform Support**: Available for macOS, Linux, and Windows.
- **Standalone App**: Just install and use directly on your favorite OS.

### Download

You can download the latest version from the [releases page](https://github.com/bluerobotics/ping-viewer-next/releases).

## How It Works

Ping Viewer Next Desktop integrates the core Ping Viewer Next server with an embedded GUI, using Tauri to create a native experience across platforms.
Binary file added ping-viewer-next-desktop/bun.lockb
Binary file not shown.
14 changes: 14 additions & 0 deletions ping-viewer-next-desktop/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + Vue + Typescript App</title>
</head>

<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions ping-viewer-next-desktop/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "ping-viewer-next-desktop",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"vue": "^3.3.4",
"@tauri-apps/api": "^1"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
"typescript": "^5.2.2",
"vite": "^5.3.1",
"vue-tsc": "^2.0.22",
"@tauri-apps/cli": "^1"
}
}
6 changes: 6 additions & 0 deletions ping-viewer-next-desktop/public/tauri.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions ping-viewer-next-desktop/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions ping-viewer-next-desktop/src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Generated by Cargo
# will have compiled files and executables
/target/

# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas

/Cargo.lock
23 changes: 23 additions & 0 deletions ping-viewer-next-desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "ping-viewer-next-desktop"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "1.5.4", features = [] }

[dependencies]
tauri = { version = "1.7.2", features = ["shell-open"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
ping-viewer-next = { path = "./../../", features = ["desktop-app"] }
tokio = { version = "1.40.0", features = ["full"] }
actix-web = "4.6.0"

[features]
# This feature is used for production builds or when a dev server is not specified, DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
3 changes: 3 additions & 0 deletions ping-viewer-next-desktop/src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ping-viewer-next-desktop/src-tauri/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added ping-viewer-next-desktop/src-tauri/icons/icon.ico
Binary file not shown.
Binary file added ping-viewer-next-desktop/src-tauri/icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions ping-viewer-next-desktop/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

use ping_viewer_next::{cli, device, logger, server};
use tauri::Manager;

#[tokio::main]
async fn main() {
cli::manager::init();

logger::manager::init();

let (manager, handler) = device::manager::DeviceManager::new(10);

tokio::spawn(async move { manager.run().await });

run_tauri_app(handler).await;
}

async fn run_tauri_app(handler: device::manager::ManagerActorHandler) {
tauri::Builder::default()
.setup(|app: &mut tauri::App| {
let window = app.get_window("main").unwrap();

std::thread::spawn(move || {
run_from_tauri(&cli::manager::server_address(), handler).unwrap();
});

std::thread::spawn(move || {
std::thread::sleep(std::time::Duration::from_secs(6));
window.eval("window.location.replace('http://0.0.0.0:8080')").unwrap();
});

Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

#[actix_web::main]
pub async fn run_from_tauri(
server_address: &str,
handler: device::manager::ManagerActorHandler,
) -> std::io::Result<()> {
server::manager::run(server_address, handler).await
}
43 changes: 43 additions & 0 deletions ping-viewer-next-desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"build": {
"beforeDevCommand": "bun run dev",
"beforeBuildCommand": "bun run build",
"devPath": "http://localhost:1420",
"distDir": "../dist"
},
"package": {
"productName": "ping-viewer-next-desktop",
"version": "0.1.0"
},
"tauri": {
"allowlist": {
"all": false,
"shell": {
"all": false,
"open": true
}
},
"windows": [
{
"title": "ping-viewer-next-desktop",
"width": 800,
"height": 600
}
],
"security": {
"csp": null
},
"bundle": {
"active": true,
"targets": "all",
"identifier": "com.ping-viewer-next-desktop.app",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/[email protected]",
"icons/icon.icns",
"icons/icon.ico"
]
}
}
}
57 changes: 57 additions & 0 deletions ping-viewer-next-desktop/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
const loading = ref(true);
const checkServerReady = () => {
setTimeout(() => {
loading.value = false;
}, 2000);
};
onMounted(() => {
checkServerReady();
});
</script>

<template>
<div v-if="loading" class="preloader">
<h1>Ping Viewer Next</h1>
<p>Creating a local server...</p>
</div>

<div v-else class="container">
<h1>Ping Viewer Next</h1>
<p>Server is ready!</p>
</div>
</template>

<style scoped>
.preloader, .container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}
h1 {
font-size: 3rem;
margin-bottom: 1rem;
}
p {
font-size: 1.5rem;
color: #666;
}
html, body {
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
1 change: 1 addition & 0 deletions ping-viewer-next-desktop/src/assets/vue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions ping-viewer-next-desktop/src/components/Greet.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup lang="ts">
import { ref } from "vue";
import { invoke } from "@tauri-apps/api/tauri";
const greetMsg = ref("");
const name = ref("");
async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
greetMsg.value = await invoke("greet", { name: name.value });
}
</script>

<template>
<form class="row" @submit.prevent="greet">
<input id="greet-input" v-model="name" placeholder="Enter a name..." />
<button type="submit">Greet</button>
</form>

<p>{{ greetMsg }}</p>
</template>
4 changes: 4 additions & 0 deletions ping-viewer-next-desktop/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createApp } from "vue";
import App from "./App.vue";

createApp(App).mount("#app");
7 changes: 7 additions & 0 deletions ping-viewer-next-desktop/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="vite/client" />

declare module "*.vue" {
import type { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}
25 changes: 25 additions & 0 deletions ping-viewer-next-desktop/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions ping-viewer-next-desktop/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
21 changes: 21 additions & 0 deletions ping-viewer-next-desktop/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";

// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [vue()],

// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));

0 comments on commit 7a2a746

Please sign in to comment.