Skip to content

Commit

Permalink
ui functional
Browse files Browse the repository at this point in the history
  • Loading branch information
neferin12 committed Apr 29, 2024
1 parent 8cec8a5 commit 7762e73
Show file tree
Hide file tree
Showing 42 changed files with 401 additions and 97 deletions.
Binary file modified gui/tauri-gui/.yarn/install-state.gz
Binary file not shown.
9 changes: 3 additions & 6 deletions gui/tauri-gui/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
1 change: 1 addition & 0 deletions gui/tauri-gui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<title>RiSM GUI</title>
</head>
<body data-bs-theme="dark">
<!-- <body>-->
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
Expand Down
Binary file added gui/tauri-gui/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 52 additions & 0 deletions gui/tauri-gui/logo.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 gui/tauri-gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Binary file modified gui/tauri-gui/src-tauri/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/128x128@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/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.
Binary file modified gui/tauri-gui/src-tauri/icons/Square107x107Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/Square142x142Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/Square150x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/Square284x284Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/Square30x30Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/Square310x310Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/Square44x44Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/Square71x71Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/Square89x89Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gui/tauri-gui/src-tauri/icons/icon.icns
Binary file not shown.
Binary file modified gui/tauri-gui/src-tauri/icons/icon.ico
Binary file not shown.
Binary file modified gui/tauri-gui/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.
70 changes: 61 additions & 9 deletions gui/tauri-gui/src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -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<Window> = 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");
}

4 changes: 2 additions & 2 deletions gui/tauri-gui/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"windows": [
{
"fullscreen": false,
"height": 650,
"resizable": false,
"height": 700,
"resizable": true,
"title": "RiSM",
"width": 1000
}
Expand Down
35 changes: 23 additions & 12 deletions gui/tauri-gui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,35 @@ import {BNavbar} from "bootstrap-vue-next";
</script>

<template>
<BNavbar data-tauri-drag-region id="navbar" variant="primary-subtle" v-b-color-mode="'dark'">
<BNavbarBrand tag="h1" class="mb-0">RiSM GUI</BNavbarBrand>
<BCollapse id="nav-collapse" is-nav>
<BNavbarNav>
<BNavItem to="/">New calculation</BNavItem>
<BNavItem to="about">About</BNavItem>
</BNavbarNav>
</BCollapse>
<BNavbar data-tauri-drag-region id="navbar" variant="primary" v-b-color-mode="'dark'">
<BNavbarBrand tag="h1" class="mb-0">RiSM GUI</BNavbarBrand>
<BCollapse id="nav-collapse" is-nav>
<BNavbarNav>
<BNavItem to="/">New calculation</BNavItem>
<BNavItem to="/about">About</BNavItem>
</BNavbarNav>
</BCollapse>

</BNavbar>
<main class="content">
<RouterView/>
</main>
</BNavbar>
<main class="content">
<div>
<b-card>
<RouterView/>
</b-card>
</div>
</main>
</template>

<style scoped>
.content {
padding: 20px;
display: flex;
justify-content: center;
}
.content > div {
max-width: 100%;
width: 900px
}
#navbar {
Expand Down
1 change: 0 additions & 1 deletion gui/tauri-gui/src/assets/logo.svg

This file was deleted.

1 change: 1 addition & 0 deletions gui/tauri-gui/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'bootstrap/dist/css/bootstrap.css'
// import "bootswatch/dist/cyborg/bootstrap.min.css";
import 'bootstrap-vue-next/dist/bootstrap-vue-next.css'

import { createApp } from 'vue'
Expand Down
49 changes: 32 additions & 17 deletions gui/tauri-gui/src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
import { createRouter, createWebHistory } from 'vue-router'
import {createRouter, createWebHistory} from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (About.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import('../views/AboutView.vue')
}
]
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/results',
name: 'results',
component: () => import('../views/Results.vue')
},
{
path: '/run/normal',
name: 'run-normal',
component: () => import('../views/NormalRun.vue')
},
{
path: '/run/model-checking',
name: 'run-model-checking',
component: () => import('../views/ModelCheckingRun.vue')
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (About.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import('../views/AboutView.vue')
}
]
})

export default router
12 changes: 0 additions & 12 deletions gui/tauri-gui/src/stores/counter.ts

This file was deleted.

14 changes: 14 additions & 0 deletions gui/tauri-gui/src/stores/data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {defineStore} from "pinia";
import {type Ref, ref} from "vue";

export const useDataStore = defineStore('data', () => {
const votes = ref('');
const seminars = ref('');
const modelChecking = ref(false);
const iterations = ref(1000000);
const threads = ref(4);

const result: Ref<Result | null> = ref(null);

return {votes, seminars, modelChecking, iterations, threads, result}
})
29 changes: 29 additions & 0 deletions gui/tauri-gui/src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Defines a seminar, whether it's a wish or an assigned seminar
interface Seminar {
name: string;
capacity: number;
id: number;
seminar_type: 'Scientific' | 'Practical';
}

// Defines the structure for a student, including their wishes for scientific and practical seminars
interface Student {
id: number;
name: string;
w_wishes: Seminar[]; // Wishes for scientific seminars
p_wishes?: Seminar[]; // Wishes for practical seminars (optional as your JSON sample has a student missing this field)
}

// Represents an assignment of a student to seminars, including points for the assignment
interface Assignment {
student: Student;
w_seminar?: Seminar; // Assigned scientific seminar
p_seminar?: Seminar; // Assigned practical seminar
points: number;
}

// The root structure of your JSON data
interface Result {
points: number;
assignments: Assignment[];
}
Loading

0 comments on commit 7762e73

Please sign in to comment.