Skip to content

Commit

Permalink
added select version component
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Gadorek committed Oct 2, 2024
1 parent 5232f37 commit 31b6d69
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ async fn get_available_targets() -> Vec<String> {
available_targets
}

#[tauri::command]
async fn get_idf_versions() -> Vec<String> {
let target = "all".to_string(); //todo: get from state or user
let mut available_versions = if target == "all" {
//todo process vector of targets
idf_im_lib::idf_versions::get_idf_names().await
} else {
idf_im_lib::idf_versions::get_idf_name_by_target(&target.to_string().to_lowercase()).await
};
available_versions.push("master".to_string());
available_versions
}

use tauri::Manager;

#[cfg_attr(mobile, tauri::mobile_entry_point)]
Expand All @@ -121,11 +134,13 @@ pub fn run() {
greet,
get_settings,
check_prequisites,
install_prerequisites,
get_prequisites,
get_operating_system,
python_sanity_check,
python_install,
get_available_targets
get_available_targets,
get_idf_versions
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
Expand Down
4 changes: 3 additions & 1 deletion src/components/WizardStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PrerequisitiesCheck :nextstep=nextStep v-if="currentStep === 1" />
<PythonSanitycheck :nextstep=nextStep v-if="currentStep === 2" />
<TargetSelect :nextstep=nextStep v-if="currentStep === 3" />
<VersionSelect :nextstep=nextStep v-if="currentStep === 4" />
<div>
<!-- <n-button @click="previousStep" :disabled="currentStep === 1">Previous</n-button>
<n-button @click="nextStep" :disabled="currentStep === totalSteps" type="primary">
Expand All @@ -21,9 +22,10 @@ import Greet from './Greet.vue';
import PrerequisitiesCheck from './wizard_steps/PrerequisitiesCheck.vue';
import PythonSanitycheck from './wizard_steps/PythonSanitycheck.vue';
import TargetSelect from './wizard_steps/TargetSelect.vue';
import VersionSelect from './wizard_steps/VersionSelect.vue';
export default {
components: { NButton, NCheckbox, Greet, PrerequisitiesCheck, PythonSanitycheck, TargetSelect },
components: { NButton, NCheckbox, Greet, PrerequisitiesCheck, PythonSanitycheck, TargetSelect, VersionSelect },
setup() {
const store = useWizardStore()
Expand Down
2 changes: 1 addition & 1 deletion src/components/wizard_steps/TargetSelect.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<p>Wizard will now check your Python instalation...</p>
<p>Please select chips you want to develop for:</p>
<n-space vertical>
<n-spin :show="loading">
<template #default>
Expand Down
61 changes: 61 additions & 0 deletions src/components/wizard_steps/VersionSelect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<template>
<p>Please select IDF versions you want to install:</p>
<n-space vertical>
<n-spin :show="loading">
<template #default>
<ul>
<li v-for="version in versions" :key="version">
<n-checkbox v-model:checked="version.selected">
{{ version.name }}
</n-checkbox>
</li>
</ul>
</template>
<template #description>
loading avalible IDF versions...
</template>
</n-spin>

<n-button @click="processVersions" type="primary">Next</n-button>
</n-space>
</template>

<script>
import { ref, version } from "vue";
import { invoke } from "@tauri-apps/api/core";
import { NButton, NSpin } from 'naive-ui'
import loading from "naive-ui/es/_internal/loading";
export default {
name: 'VersionSelect',
props: {
nextstep: Function
},
components: { NButton, NSpin },
data: () => ({
loading: true,
versions: [],
}),
methods: {
get_avalible_versions: async function () {
const versions = await invoke("get_idf_versions", {});
this.versions = versions.sort().reverse().map((version, index) => {
return {
name: version,
selected: index === 0,
}
});
this.loading = false;
return false;
},
processVersions: function () {
const selected_versions = this.versions.filter(version => version.selected);
// todo: send to backend
this.nextstep();
}
},
mounted() {
this.get_avalible_versions();
}
}
</script>

0 comments on commit 31b6d69

Please sign in to comment.