Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Dekstop-app #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ jobs:
# Note: Required by vergen (https://crates.io/crates/vergen)
run: git config --global --add safe.directory $GITHUB_WORKSPACE

- name: install dependencies (desktop-app)
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf

- name: Install build dependencies - Rustup
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable -y
Expand Down Expand Up @@ -92,3 +97,77 @@ jobs:
tag: ${{ github.ref }}
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
overwrite: true

build-tauri:
needs: quick-tests
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest'
args: '--target aarch64-apple-darwin'
label: 'Mac-M1'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Apple Silicon

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label?

- platform: 'macos-latest'
args: '--target x86_64-apple-darwin'
label: 'Mac-x86'
- platform: 'ubuntu-22.04'
args: ''
label: 'Linux'
- platform: 'windows-latest'
args: ''
label: 'Windows'

runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- name: install dependencies (ubuntu only)
if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.

- name: setup node
uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}

- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'

- name: Install dependencies
run: |
cd ping-viewer-next-desktop
bun install

- name: Build the app
id: tauri-build
uses: tauri-apps/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
projectPath: './ping-viewer-next-desktop'
args: ${{ matrix.args }}

- name: Upload artifacts
uses: actions/[email protected]
with:
name: 'ping-viewer_${{steps.tauri-build.outputs.appVersion}}_${{ matrix.label }}'
path: "${{ join(fromJSON(steps.tauri-build.outputs.artifactPaths), '\n') }}"
retention-days: 5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing EOL

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ validator = "0.18.1"
thiserror = "1.0.63"
shellexpand = "3.1"

tauri = { version = "1.7.2", optional = true, features = ["shell-open"] }


[build-dependencies]
vergen-gix = { version = "1.0.1", default-features = false, features = ["build", "cargo"] }

Expand All @@ -44,3 +47,7 @@ path = "src/lib.rs"
[[bin]]
name = "ping-viewer-next"
path = "src/main.rs"

[features]
default = []
desktop-app = ["tauri"]
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary, can we clean it up ?

Copy link
Member Author

@RaulTrombin RaulTrombin Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the Logs default folder when we execute the desktop app with logger module with cargo run, would suggest to keep it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just saying to remove the unnecessary stuff, .idea, .dist-ssr, .sln

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"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing authors

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.
Loading