diff --git a/gui/tauri-gui/.yarn/install-state.gz b/gui/tauri-gui/.yarn/install-state.gz index 1f2c4fa..f4cd70b 100644 Binary files a/gui/tauri-gui/.yarn/install-state.gz and b/gui/tauri-gui/.yarn/install-state.gz differ diff --git a/gui/tauri-gui/components.d.ts b/gui/tauri-gui/components.d.ts index 1d5438c..8d702b8 100644 --- a/gui/tauri-gui/components.d.ts +++ b/gui/tauri-gui/components.d.ts @@ -7,22 +7,19 @@ export {} declare module 'vue' { export interface GlobalComponents { + BAlert: typeof import('bootstrap-vue-next')['BAlert'] BButton: typeof import('bootstrap-vue-next')['BButton'] + BCard: typeof import('bootstrap-vue-next')['BCard'] BCollapse: typeof import('bootstrap-vue-next')['BCollapse'] - BContainer: typeof import('bootstrap-vue-next')['BContainer'] - BDropdownItem: typeof import('bootstrap-vue-next')['BDropdownItem'] BForm: typeof import('bootstrap-vue-next')['BForm'] BFormCheckbox: typeof import('bootstrap-vue-next')['BFormCheckbox'] BFormGroup: typeof import('bootstrap-vue-next')['BFormGroup'] BFormInput: typeof import('bootstrap-vue-next')['BFormInput'] BInputGroup: typeof import('bootstrap-vue-next')['BInputGroup'] - BInputGroupAppend: typeof import('bootstrap-vue-next')['BInputGroupAppend'] BNavbarBrand: typeof import('bootstrap-vue-next')['BNavbarBrand'] BNavbarNav: typeof import('bootstrap-vue-next')['BNavbarNav'] - BNavbarToggle: typeof import('bootstrap-vue-next')['BNavbarToggle'] - BNavForm: typeof import('bootstrap-vue-next')['BNavForm'] BNavItem: typeof import('bootstrap-vue-next')['BNavItem'] - BNavItemDropdown: typeof import('bootstrap-vue-next')['BNavItemDropdown'] + BProgress: typeof import('bootstrap-vue-next')['BProgress'] BTable: typeof import('bootstrap-vue-next')['BTable'] BTableSimple: typeof import('bootstrap-vue-next')['BTableSimple'] BTbody: typeof import('bootstrap-vue-next')['BTbody'] diff --git a/gui/tauri-gui/index.html b/gui/tauri-gui/index.html index 9603f1d..49cb3d4 100644 --- a/gui/tauri-gui/index.html +++ b/gui/tauri-gui/index.html @@ -7,6 +7,7 @@ RiSM GUI +
diff --git a/gui/tauri-gui/logo.png b/gui/tauri-gui/logo.png new file mode 100644 index 0000000..5e0e442 Binary files /dev/null and b/gui/tauri-gui/logo.png differ diff --git a/gui/tauri-gui/logo.svg b/gui/tauri-gui/logo.svg new file mode 100644 index 0000000..520cd72 --- /dev/null +++ b/gui/tauri-gui/logo.svg @@ -0,0 +1,52 @@ + + + + + + + + iSM + + + diff --git a/gui/tauri-gui/package.json b/gui/tauri-gui/package.json index dc56cc3..e1a4c87 100644 --- a/gui/tauri-gui/package.json +++ b/gui/tauri-gui/package.json @@ -16,6 +16,7 @@ "@tauri-apps/api": "^1.5.4", "bootstrap": "^5.3.3", "bootstrap-vue-next": "^0.17.2", + "bootswatch": "^5.3.3", "pinia": "^2.1.7", "vue": "^3.4.21", "vue-router": "^4.3.0" diff --git a/gui/tauri-gui/src-tauri/icons/128x128.png b/gui/tauri-gui/src-tauri/icons/128x128.png index 77e7d23..b1ad3c8 100644 Binary files a/gui/tauri-gui/src-tauri/icons/128x128.png and b/gui/tauri-gui/src-tauri/icons/128x128.png differ diff --git a/gui/tauri-gui/src-tauri/icons/128x128@2x.png b/gui/tauri-gui/src-tauri/icons/128x128@2x.png index 0f7976f..db7c6c3 100644 Binary files a/gui/tauri-gui/src-tauri/icons/128x128@2x.png and b/gui/tauri-gui/src-tauri/icons/128x128@2x.png differ diff --git a/gui/tauri-gui/src-tauri/icons/32x32.png b/gui/tauri-gui/src-tauri/icons/32x32.png index 98fda06..2bf7fba 100644 Binary files a/gui/tauri-gui/src-tauri/icons/32x32.png and b/gui/tauri-gui/src-tauri/icons/32x32.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square107x107Logo.png b/gui/tauri-gui/src-tauri/icons/Square107x107Logo.png index f35d84f..d51e39d 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square107x107Logo.png and b/gui/tauri-gui/src-tauri/icons/Square107x107Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square142x142Logo.png b/gui/tauri-gui/src-tauri/icons/Square142x142Logo.png index 1823bb2..36757f9 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square142x142Logo.png and b/gui/tauri-gui/src-tauri/icons/Square142x142Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square150x150Logo.png b/gui/tauri-gui/src-tauri/icons/Square150x150Logo.png index dc2b22c..e5965f5 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square150x150Logo.png and b/gui/tauri-gui/src-tauri/icons/Square150x150Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square284x284Logo.png b/gui/tauri-gui/src-tauri/icons/Square284x284Logo.png index 0ed3984..9d0c933 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square284x284Logo.png and b/gui/tauri-gui/src-tauri/icons/Square284x284Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square30x30Logo.png b/gui/tauri-gui/src-tauri/icons/Square30x30Logo.png index 60bf0ea..4221a96 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square30x30Logo.png and b/gui/tauri-gui/src-tauri/icons/Square30x30Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square310x310Logo.png b/gui/tauri-gui/src-tauri/icons/Square310x310Logo.png index c8ca0ad..6b2e038 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square310x310Logo.png and b/gui/tauri-gui/src-tauri/icons/Square310x310Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square44x44Logo.png b/gui/tauri-gui/src-tauri/icons/Square44x44Logo.png index 8756459..77c3ae4 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square44x44Logo.png and b/gui/tauri-gui/src-tauri/icons/Square44x44Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square71x71Logo.png b/gui/tauri-gui/src-tauri/icons/Square71x71Logo.png index 2c8023c..6b32c7b 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square71x71Logo.png and b/gui/tauri-gui/src-tauri/icons/Square71x71Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/Square89x89Logo.png b/gui/tauri-gui/src-tauri/icons/Square89x89Logo.png index 2c5e603..4ee56e0 100644 Binary files a/gui/tauri-gui/src-tauri/icons/Square89x89Logo.png and b/gui/tauri-gui/src-tauri/icons/Square89x89Logo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/StoreLogo.png b/gui/tauri-gui/src-tauri/icons/StoreLogo.png index 17d142c..cdde052 100644 Binary files a/gui/tauri-gui/src-tauri/icons/StoreLogo.png and b/gui/tauri-gui/src-tauri/icons/StoreLogo.png differ diff --git a/gui/tauri-gui/src-tauri/icons/icon.icns b/gui/tauri-gui/src-tauri/icons/icon.icns index a2993ad..76be693 100644 Binary files a/gui/tauri-gui/src-tauri/icons/icon.icns and b/gui/tauri-gui/src-tauri/icons/icon.icns differ diff --git a/gui/tauri-gui/src-tauri/icons/icon.ico b/gui/tauri-gui/src-tauri/icons/icon.ico index 06c23c8..c9c4f46 100644 Binary files a/gui/tauri-gui/src-tauri/icons/icon.ico and b/gui/tauri-gui/src-tauri/icons/icon.ico differ diff --git a/gui/tauri-gui/src-tauri/icons/icon.png b/gui/tauri-gui/src-tauri/icons/icon.png index d1756ce..5c6393f 100644 Binary files a/gui/tauri-gui/src-tauri/icons/icon.png and b/gui/tauri-gui/src-tauri/icons/icon.png differ diff --git a/gui/tauri-gui/src-tauri/src/main.rs b/gui/tauri-gui/src-tauri/src/main.rs index 744dd04..39f9e75 100644 --- a/gui/tauri-gui/src-tauri/src/main.rs +++ b/gui/tauri-gui/src-tauri/src/main.rs @@ -1,27 +1,79 @@ // Prevents additional console window on Windows in release, DO NOT REMOVE!! #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] +use std::hash::{DefaultHasher, Hash, Hasher}; +use std::sync::OnceLock; +use std::thread::ThreadId; +use rism::constants::{Points}; +use rism::io::{import_seminars, import_students}; +use rism::rism_classic::run; +use rism::rism_model_checking::run_model_check; +use serde_json::to_string; +use tauri::{ Manager, Window}; + const VERSION: &str = env!("CARGO_PKG_VERSION"); +static WINDOW: OnceLock = OnceLock::new(); + #[tauri::command] fn get_version() -> String { - return String::from(VERSION); + return String::from(VERSION); } #[tauri::command] fn uses_system_z3() -> bool { - #[cfg(feature = "bundle_z3")] - return false; + #[cfg(feature = "bundle_z3")] + return false; + + #[cfg(not(feature = "bundle_z3"))] + return true; +} + +#[tauri::command] +async fn run_normal(votes: String, seminars: String, iterations: u32, threads: u16) -> String { + let seminars = import_seminars(&*seminars); + let students = import_students(&*votes, &seminars); + + let best_iteration = run(&students, &seminars, iterations, Points::default(), threads, send_progress); + println!("Done"); + to_string(&best_iteration).unwrap() +} + +#[tauri::command] +async fn run_model_checking(votes: String, seminars: String) -> String { + let seminars = import_seminars(&*seminars); + let students = import_students(&*votes, &seminars); - #[cfg(not(feature = "bundle_z3"))] - return true; + let best_iteration = run_model_check(&students, &seminars, Points::default()); + println!("Done"); + to_string(&best_iteration).unwrap() } +#[derive(Clone, serde::Serialize)] +struct ProgressPayload { + thread_id: u64, + progress: u32, + total: u32, +} + +fn send_progress(t_id: ThreadId, p: u32, t: u32) { + if p % 10000 == 0 { + let mut hasher = DefaultHasher::new(); + t_id.hash(&mut hasher); + WINDOW.get().expect("window is available").emit("progress", ProgressPayload { thread_id: hasher.finish(), progress: p, total: t }).expect("Send message"); + } +} fn main() { - tauri::Builder::default() - .invoke_handler(tauri::generate_handler![get_version,uses_system_z3]) - .run(tauri::generate_context!()) - .expect("error while running tauri application"); + tauri::Builder::default() + .setup(|app| { + let window = app.get_window("main").unwrap(); + + _ = WINDOW.set(window); + Ok(()) + }) + .invoke_handler(tauri::generate_handler![get_version,uses_system_z3,run_normal,run_model_checking]) + .run(tauri::generate_context!()) + .expect("error while running tauri application"); } diff --git a/gui/tauri-gui/src-tauri/tauri.conf.json b/gui/tauri-gui/src-tauri/tauri.conf.json index 363f308..f124279 100644 --- a/gui/tauri-gui/src-tauri/tauri.conf.json +++ b/gui/tauri-gui/src-tauri/tauri.conf.json @@ -59,8 +59,8 @@ "windows": [ { "fullscreen": false, - "height": 650, - "resizable": false, + "height": 700, + "resizable": true, "title": "RiSM", "width": 1000 } diff --git a/gui/tauri-gui/src/App.vue b/gui/tauri-gui/src/App.vue index e99ef41..83d12d3 100644 --- a/gui/tauri-gui/src/App.vue +++ b/gui/tauri-gui/src/App.vue @@ -4,24 +4,35 @@ import {BNavbar} from "bootstrap-vue-next"; \ No newline at end of file diff --git a/gui/tauri-gui/src/views/NormalRun.vue b/gui/tauri-gui/src/views/NormalRun.vue new file mode 100644 index 0000000..f93ee32 --- /dev/null +++ b/gui/tauri-gui/src/views/NormalRun.vue @@ -0,0 +1,44 @@ + + + + + \ No newline at end of file diff --git a/gui/tauri-gui/src/views/Results.vue b/gui/tauri-gui/src/views/Results.vue new file mode 100644 index 0000000..d7bfaf6 --- /dev/null +++ b/gui/tauri-gui/src/views/Results.vue @@ -0,0 +1,33 @@ + + + + + \ No newline at end of file diff --git a/gui/tauri-gui/yarn.lock b/gui/tauri-gui/yarn.lock index 8c0fda4..36591aa 100644 --- a/gui/tauri-gui/yarn.lock +++ b/gui/tauri-gui/yarn.lock @@ -922,6 +922,13 @@ __metadata: languageName: node linkType: hard +"bootswatch@npm:^5.3.3": + version: 5.3.3 + resolution: "bootswatch@npm:5.3.3" + checksum: 10c0/f32187686f1a2ca200267335d32ad95692b16af7de862c537bc0ffb8371947114bf556867eeef3de3d5ef0197ab6efabad34096b0a260d8b44700811cd72adf6 + languageName: node + linkType: hard + "brace-expansion@npm:^2.0.1": version: 2.0.1 resolution: "brace-expansion@npm:2.0.1" @@ -2181,6 +2188,7 @@ __metadata: "@vue/tsconfig": "npm:^0.5.1" bootstrap: "npm:^5.3.3" bootstrap-vue-next: "npm:^0.17.2" + bootswatch: "npm:^5.3.3" npm-run-all2: "npm:^6.1.2" pinia: "npm:^2.1.7" typescript: "npm:~5.4.0" diff --git a/rust/src/constants.rs b/rust/src/constants.rs index a5d2c4e..441a464 100644 --- a/rust/src/constants.rs +++ b/rust/src/constants.rs @@ -3,14 +3,16 @@ pub struct Points { pub first_selection: u16, pub second_selection: u16, pub third_selection: u16, - pub no_selection: u16 + pub no_selection: u16, } -pub fn get_default_points() -> Points { - Points { - first_selection: 0, - second_selection: 5, - third_selection: 10, - no_selection: 30, +impl Points { + pub fn default() -> Points { + return Points { + first_selection: 0, + second_selection: 5, + third_selection: 10, + no_selection: 30, + }; } } \ No newline at end of file diff --git a/rust/src/main.rs b/rust/src/main.rs index d49bdb6..071be16 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -3,7 +3,6 @@ use std::thread::ThreadId; use clap::Parser; use serde::Serialize; use rism::rism_classic::run; -use rism::constants::get_default_points; use rism::io::{import_students, import_seminars}; #[cfg(feature = "model-checking")] use rism::rism_model_checking::run_model_check; @@ -12,6 +11,7 @@ use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; use once_cell::sync::Lazy; use tabled::{Table, Tabled}; use tabled::settings::Style; +use rism::constants::Points; #[derive( clap::ValueEnum, Clone, Default, Debug, Serialize, PartialEq @@ -86,9 +86,9 @@ fn main() { let students = import_students(&args.students_path, &seminars); let best_iteration = match args.variant { - ExecutionVariants::Classic => Some(run(&students, &seminars, args.iterations, get_default_points(), args.threads, update_progress)), + ExecutionVariants::Classic => Some(run(&students, &seminars, args.iterations, Points::default(), args.threads, update_progress)), #[cfg(feature = "model-checking")] - ExecutionVariants::ModelChecking => run_model_check(&students, &seminars, get_default_points()) + ExecutionVariants::ModelChecking => run_model_check(&students, &seminars, Points::default()) }; unsafe { PROGRESS_BARS.iter().for_each(|(_, p)| p.finish_and_clear()); } diff --git a/rust/src/types/assignment.rs b/rust/src/types/assignment.rs index 1468b4b..f63217d 100644 --- a/rust/src/types/assignment.rs +++ b/rust/src/types/assignment.rs @@ -1,7 +1,8 @@ use std::cmp::Ordering; +use serde::Serialize; use crate::types::{Seminar, Student, SeminarType}; -#[derive(Debug, Eq, Clone)] +#[derive(Debug, Eq, Clone, Serialize)] pub struct Assignment<'a> { pub student: &'a Student, pub w_seminar: Option<&'a Seminar>, diff --git a/rust/src/types/results.rs b/rust/src/types/results.rs index 97a177f..c28e347 100644 --- a/rust/src/types/results.rs +++ b/rust/src/types/results.rs @@ -1,7 +1,8 @@ use std::cmp::Ordering; +use serde::Serialize; use crate::types::{Assignment, Seminar, Student}; -#[derive(Debug, PartialEq, Eq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone, Serialize)] pub struct RismResult<'a> { points: Option, pub assignments: Vec>, diff --git a/rust/src/types/seminar.rs b/rust/src/types/seminar.rs index 814c639..e6e167f 100644 --- a/rust/src/types/seminar.rs +++ b/rust/src/types/seminar.rs @@ -1,7 +1,8 @@ use std::cmp::Ordering; use std::fmt::Display; +use serde::Serialize; -#[derive(PartialEq, Debug, Clone, Eq)] +#[derive(PartialEq, Debug, Clone, Eq, Serialize)] pub enum SeminarType { Scientific, Practical @@ -17,7 +18,7 @@ impl Display for SeminarType{ } } -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Debug, Clone, Eq, PartialEq, Serialize)] pub struct Seminar { pub name: String, pub capacity: u16, diff --git a/rust/src/types/student.rs b/rust/src/types/student.rs index 330888e..195b7cd 100644 --- a/rust/src/types/student.rs +++ b/rust/src/types/student.rs @@ -1,7 +1,8 @@ use std::cmp::Ordering; +use serde::Serialize; use crate::types::Seminar; -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone, Eq, Serialize)] pub struct Student { pub id: u16, pub name: String,