Skip to content

Commit

Permalink
Added vATIS warning
Browse files Browse the repository at this point in the history
  • Loading branch information
EMcNugget committed Aug 8, 2024
1 parent fa712f2 commit bd32494
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "d-atis-to-vatis",
"private": true,
"version": "1.5.0",
"version": "1.5.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
71 changes: 70 additions & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "D-ATIS-to-vATIS"
version = "1.5.0"
version = "1.5.1"
description = "Converts real world FAA D-ATIS's to vATIS profiles"
authors = ["you"]
license = "MIT"
Expand All @@ -22,6 +22,7 @@ tauri = { version = "2.0.0-rc.0", features = [] }
tauri-plugin-dialog = "2.0.0-rc.0"
tauri-plugin-log = "2.0.0-rc.0"
tauri-plugin-process = "2.0.0-rc"
sysinfo = "0.31.2"
log = "0.4"


Expand Down
4 changes: 3 additions & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use log::info;
use settings::{create_settings_file, read_settings, write_settings};
use tauri::AppHandle;
use tauri_plugin_log::{Target, TargetKind};
use util::is_vatis_running;

fn setup(app_handle: AppHandle) {
info!(
Expand Down Expand Up @@ -39,7 +40,8 @@ fn main() {
.invoke_handler(tauri::generate_handler![
write_settings,
read_settings,
write_atis
write_atis,
is_vatis_running
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
Expand Down
7 changes: 7 additions & 0 deletions src-tauri/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::{
fs::File,
io::{BufReader, Write},
};
use sysinfo::System;
use tauri::{path::BaseDirectory, AppHandle, Manager};

pub fn read_json_file(file_path: &str) -> Result<Value, String> {
Expand Down Expand Up @@ -48,3 +49,9 @@ pub fn get_resource(app_handle: &AppHandle, file_name: &str) -> Result<Value, St

json
}
#[tauri::command]
pub fn is_vatis_running() -> bool {
let s = System::new_all();
let is_running = s.processes().values().any(|p| p.name() == "vatis");
is_running
}
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
},
"productName": "D-ATIStovATIS",
"version": "1.5.0",
"version": "1.5.1",
"identifier": "D-ATIStovATIS",
"plugins": {
"updater": {
Expand Down
49 changes: 31 additions & 18 deletions src/views/Atis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const validateICAO = (value: string) => {
tooltip.value =
"Please select the path to your vATIS installation in settings";
return false;
} else return true;
} else {
tooltip.value = "";
return true;
}
};
const get_atis_code = (atis: vATIS[]): TATISCode[] => {
Expand Down Expand Up @@ -60,23 +63,33 @@ const get_atis_code = (atis: vATIS[]): TATISCode[] => {
const fetch = async () => {
try {
await fetch_atis(facility.value).then((atis) => {
store.set_atis(atis);
invoke("write_atis", {
facility: facility.value,
atis: atis,
}).then((k) => {
const v = k as TAlert;
const success = v.alert_type === "success";
v.message = v.message.concat(
success
? ` | ${get_atis_code(atis)
.map((k) => `${k.type}: ${k.code}`)
.join(", ")}`
: ""
);
message.value = v;
});
invoke("is_vatis_running").then(async (k) => {
if (k) {
message.value = {
alert_type: "error",
message: "Close vATIS before fetching ATIS",
};
return;
} else {
await fetch_atis(facility.value).then((atis) => {
store.set_atis(atis);
invoke("write_atis", {
facility: facility.value,
atis: atis,
}).then((k) => {
const v = k as TAlert;
const success = v.alert_type === "success";
v.message = v.message.concat(
success
? ` | ${get_atis_code(atis)
.map((k) => `${k.type}: ${k.code}`)
.join(", ")}`
: ""
);
message.value = v;
});
});
}
});
} catch (e) {
message.value = e as TAlert;
Expand Down

0 comments on commit bd32494

Please sign in to comment.