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

Eim 46 styling gui #16

Merged
merged 14 commits into from
Dec 3, 2024
10 changes: 5 additions & 5 deletions .github/workflows/build_tauri.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
include:
- platform: "macos-latest" # for Arm based macs (M1 and above).
args: "--target aarch64-apple-darwin"
- platform: "macos-12" # for Intel based macs.
- platform: "macos-13" # for Intel based macs.
args: "--target x86_64-apple-darwin"
- platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
args: ""
Expand Down Expand Up @@ -156,13 +156,13 @@ jobs:
if-no-files-found: error

- name: Add +x permission to the binary
if: matrix.platform == 'macos-12'
if: matrix.platform == 'macos-13'
run: |
chmod +x src-tauri/target/x86_64-apple-darwin/release/eim

- name: Upload MacOs intel app binary
uses: actions/upload-artifact@v4
if: matrix.platform == 'macos-12'
if: matrix.platform == 'macos-13'
with:
name: eim-macos-x86_64-binary
path: |
Expand All @@ -171,7 +171,7 @@ jobs:

- name: Upload app MacOs
uses: actions/upload-artifact@v4
if: matrix.platform == 'macos-12'
if: matrix.platform == 'macos-13'
with:
name: eim-macos-x86_64-dmg
path: |
Expand All @@ -180,7 +180,7 @@ jobs:

- name: Upload app MacOs
uses: actions/upload-artifact@v4
if: matrix.platform == 'macos-12'
if: matrix.platform == 'macos-13'
with:
name: eim-macos-x86_64-app
path: |
Expand Down
85 changes: 78 additions & 7 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ fn send_install_progress_message(app_handle: &AppHandle, version: String, state:
);
}

fn send_simple_setup_message(app_handle: &AppHandle, message_code: i32, message: String) {
let _ = emit_to_fe(
app_handle,
"simple-setup-message",
json!({ "code": message_code, "message": message }),
);
}

fn emit_to_fe(app_handle: &AppHandle, event_name: &str, json_data: Value) {
debug!("emit_to_fe: {} {:?}", event_name, json_data);
let _ = app_handle.emit(event_name, json_data);
Expand Down Expand Up @@ -149,19 +157,16 @@ fn get_settings(app_handle: tauri::AppHandle) -> Settings {

#[tauri::command]
fn get_prequisites() -> Vec<&'static str> {
log::info!("Get prerequisites called"); // todo remove debug statement
idf_im_lib::system_dependencies::get_prequisites()
}

#[tauri::command]
fn get_operating_system() -> String {
log::info!("Get operating system called"); // todo remove debug statement
std::env::consts::OS.to_string()
}
// ----
#[tauri::command]
fn install_prerequisites(app_handle: AppHandle) -> bool {
log::info!("Install prerequisites called"); // todo remove debug statement
let unsatisfied_prerequisites = idf_im_lib::system_dependencies::check_prerequisites()
.unwrap()
.into_iter()
Expand All @@ -186,10 +191,8 @@ fn check_prequisites(app_handle: AppHandle) -> Vec<String> {
match idf_im_lib::system_dependencies::check_prerequisites() {
Ok(prerequisites) => {
if prerequisites.is_empty() {
// debug!("{}", t!("prerequisites.ok"));
vec![]
} else {
// info!("{} {:?}", t!("prerequisites.missing"), prerequisites);
prerequisites.into_iter().map(|p| p.to_string()).collect()
}
}
Expand All @@ -199,7 +202,7 @@ fn check_prequisites(app_handle: AppHandle) -> Vec<String> {
format!("Error checking prerequisites: {}", err),
"error".to_string(),
);
log::error!("Error checking prerequisites: {}", err); //TODO: emit message
log::error!("Error checking prerequisites: {}", err);
vec![]
}
}
Expand Down Expand Up @@ -539,7 +542,6 @@ fn prepare_installation_directories(
) -> Result<PathBuf, Box<dyn std::error::Error>> {
let mut version_path = expand_tilde(settings.path.as_ref().unwrap().as_path());
version_path.push(version);
// version_path.push("esp-idf");

ensure_path(version_path.to_str().unwrap())?;
send_message(
Expand Down Expand Up @@ -613,6 +615,7 @@ async fn download_idf(
format!("Failed to install IDF {}. Reason: {}", version, e),
"error".to_string(),
);
progress.finish();
return Err(e.into());
}
}
Expand Down Expand Up @@ -1014,6 +1017,73 @@ fn save_config(app_handle: tauri::AppHandle, path: String) {
let _ = settings.save();
}

#[tauri::command]
async fn start_simple_setup(app_handle: tauri::AppHandle) {
let mut settings = get_locked_settings(&app_handle).unwrap();
let state_settings = app_handle.state::<AppState>();
send_simple_setup_message(&app_handle, 1, "started".to_string());
// prerequisities check
let mut prerequisities = check_prequisites(app_handle.clone());
let os = get_operating_system().to_lowercase();
if prerequisities.len() > 0 && os == "windows" {
send_simple_setup_message(&app_handle, 2, "installing prerequisites".to_string());
prerequisities = check_prequisites(app_handle.clone());
if !install_prerequisites(app_handle.clone()) {
send_simple_setup_message(&app_handle, 3, prerequisities.join(", "));
return;
}
prerequisities = check_prequisites(app_handle.clone());
}
if prerequisities.len() > 0 {
send_simple_setup_message(&app_handle, 4, prerequisities.join(", "));
return;
}
// python check
let mut python_found = python_sanity_check(app_handle.clone(), None);
if !python_found && os == "windows" {
send_simple_setup_message(&app_handle, 5, "Installing Python".to_string());
if !python_install(app_handle.clone()) {
send_simple_setup_message(&app_handle, 6, "Failed to install Python".to_string());
return;
}
}
python_found = python_sanity_check(app_handle.clone(), None);
if !python_found {
send_simple_setup_message(
&app_handle,
7,
"Python not found. Please install it manually".to_string(),
);
return;
}
// version check get_idf_versions
if settings.idf_versions.is_none() {
send_simple_setup_message(&app_handle, 8, "Getting IDF versions".to_string());
let versions = get_idf_versions(app_handle.clone()).await;
let version = versions[0]["name"]
.clone()
.to_string()
.trim_matches('"')
.to_string();
if set_versions(app_handle.clone(), vec![version]).is_err() {
send_simple_setup_message(&app_handle, 9, "Failed to set IDF versions".to_string());
return;
}
}
settings = get_locked_settings(&app_handle).unwrap();
// install
send_simple_setup_message(&app_handle, 10, "Installing IDF".to_string());
let res = start_installation(app_handle.clone()).await;
match res {
Ok(_) => {
send_simple_setup_message(&app_handle, 11, "Installation completed".to_string());
}
Err(e) => {
send_simple_setup_message(&app_handle, 12, "Failed to install IDF".to_string());
}
}
}

use tauri::Emitter;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
Expand Down Expand Up @@ -1061,6 +1131,7 @@ pub fn run() {
get_installation_path,
set_installation_path,
start_installation,
start_simple_setup,
quit_app,
save_config
])
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"title": "ESP-IDF Installation Manager(EIM)",
"width": 1200,
"height": 1200
"height": 1000
}
],
"security": {
Expand Down
33 changes: 21 additions & 12 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
<template>
<n-config-provider :theme="theme">
<n-layout>
<n-layout-header>ESP-IDF Installation Manager(EIM)</n-layout-header>
<n-layout-content>
<router-view></router-view>
</n-layout-content>
<message-display />
<global-progress />
</n-layout>
</n-config-provider>
<div class="installer">
<!-- Header -->
<header class="header">
<h2>ESP-IDF Installation Manager</h2>
<img src="./assets/espressif_logo_white.svg" alt="ESP-IDF Logo" />
</header>
<router-view></router-view>
<message-display />
<global-progress />
<!-- Footer -->
<footer class="footer">
ESP-IDF Installation Manager {{ appVersion }}
</footer>
</div>
</template>

<script setup>
import { NConfigProvider, NLayout, NLayoutHeader, NLayoutContent, useOsTheme } from 'naive-ui'
import { darkTheme } from 'naive-ui'
import { computed, onMounted } from 'vue'
import { ref, onMounted } from 'vue'
import MessageDisplay from './components/MessageDisplay.vue'
import GlobalProgress from './components/GlobalProgress.vue'
import { attachConsole } from '@tauri-apps/plugin-log'
import { getVersion } from '@tauri-apps/api/app';


const osTheme = useOsTheme()
const theme = null // computed(() => (osTheme.value === 'dark' ? darkTheme : null))
const appVersion = ref('');

onMounted(async () => {
const detach = await attachConsole()
const detach = await attachConsole();
appVersion.value = await getVersion();
})
</script>
58 changes: 58 additions & 0 deletions src/assets/espressif_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions src/assets/espressif_logo_white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading