Skip to content

Commit 12e65f5

Browse files
authored
Fix UI (#157)
2 parents 9714213 + 7236f06 commit 12e65f5

File tree

8 files changed

+80
-19
lines changed

8 files changed

+80
-19
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ target*
5252

5353
result*
5454

55-
src-tauri/opencv_world4110.dll
55+
src-tauri/*.dll
5656

5757
.venv*
5858
.env

src-tauri/libleptonica-6.dll

-2.64 MB
Binary file not shown.

src-tauri/libtesseract-5.5.dll

-4.02 MB
Binary file not shown.

src-tauri/src/commands.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ pub fn enter_database_information(app: AppHandle, uri: String, name: String) {
134134
}
135135

136136
#[tauri::command]
137-
pub async fn login(username: String, password: String) -> Result<bool, String> {
137+
pub async fn login(app: AppHandle, username: String, password: String) -> Result<(), String> {
138138
let client = Client::new();
139139
let res = client
140140
.post("http://localhost:5000/login")
@@ -144,7 +144,36 @@ pub async fn login(username: String, password: String) -> Result<bool, String> {
144144
.map_err(|e| e.to_string())?;
145145

146146
let body: LoginResponse = res.json().await.map_err(|e| e.to_string())?;
147-
Ok(body.success)
147+
if body.success {
148+
info!("Authentication Passed!");
149+
WebviewWindowBuilder::from_config(
150+
&app,
151+
app.config()
152+
.app
153+
.windows
154+
.first()
155+
.ok_or("the main window is not present in the config".to_string())?,
156+
)
157+
.map_err(|e| {
158+
err_log!(&e);
159+
"cannot create main window".to_string()
160+
})?
161+
.build()
162+
.map_err(|e| {
163+
err_log!(&e);
164+
"cannot create main window".to_string()
165+
})?;
166+
app.webview_windows()
167+
.get("auth")
168+
.ok_or("missing auth window".to_string())?
169+
.close()
170+
.map_err(|e| {
171+
err_log!(&e);
172+
"cannot close auth window".to_string()
173+
})
174+
} else {
175+
Err("Invalid username or password".to_string())
176+
}
148177
}
149178

150179
#[tauri::command]

src-tauri/src/image.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,13 +505,18 @@ impl AnswerSheet {
505505
let subject_id_written = roi_range_frac(&subject_id_mat, 0.0..=1.0, 0.0..=0.128205)?;
506506
let student_id_written =
507507
roi_range_frac(&student_id_mat, 0.112..=1.0, 0.0..=0.12565445)?;
508-
let (written_subject_id, written_student_id) =
508+
let (_written_subject_id, written_student_id) =
509509
extract_subject_student_from_written_field(
510510
subject_id_written,
511511
student_id_written,
512512
ocr,
513513
)?;
514-
if subject_id != written_subject_id || student_id != written_student_id {
514+
515+
if student_id.len() == 9 && student_id.starts_with('1') {
516+
student_id.remove(0);
517+
}
518+
519+
if student_id != written_student_id {
515520
//warn!("{} != {} && {} != {}", written_student_id, student_id, written_subject_id, subject_id);
516521
if student_id.len() != 8 && written_student_id.len() == 8 {
517522
student_id = written_student_id;
@@ -661,7 +666,10 @@ fn extract_user_information(
661666
// safe_imwrite("temp/debug_exam_seat.png", &exam_seat)?;
662667

663668
let name_string = image_to_string(&name, ocr)?;
664-
let subject_string = image_to_string(&subject_name, ocr)?;
669+
let subject_string = image_to_string(&subject_name, ocr)?
670+
.chars()
671+
.filter(|c| c.is_alphabetic() || *c == ' ')
672+
.collect::<String>();
665673
let exam_room_string = image_to_string(&exam_room, ocr)?
666674
.chars()
667675
.filter_map(|c| match c {

src-tauri/tauri.conf.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
"windows": [
1414
{
1515
"title": "Quikscore",
16-
"width": 800,
17-
"height": 600,
16+
"width": 1280,
17+
"height": 720,
1818
"create": false
1919
},
2020
{
2121
"title": "Quikscore Authentication",
2222
"url": "auth.html",
2323
"label": "auth",
24-
"width": 380,
25-
"height": 480,
24+
"width": 540,
25+
"height": 640,
2626
"create": true,
2727
"resizable": false
2828
}

src/App.vue

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,14 @@ function avgMinMax(result: BlobbedAnswerScoreResult[]): { avg: number, min: numb
369369
<div class="form_group">
370370
<div class="form_wrapper">
371371
<label for="mongo_db_uri">MongoDB URI: </label>
372-
<input type="text" id="mongo_db_uri" v-model="mongoDbUri" placeholder="URI...." />
372+
<input type="text" id="mongo_db_uri" class="text-box" v-model="mongoDbUri" placeholder="URI...."/>
373373
</div>
374374
<div class="form_wrapper">
375375
<label for="mongo_db_name">MongoDB Name: </label>
376-
<input type="text" id="mongo_db_name" v-model="mongoDbName" placeholder="Name...." />
376+
<input type="text" id="mongo_db_name" class="text-box" v-model="mongoDbName" placeholder="Name...."/>
377377
</div>
378+
<button class="mongo_db_enter" @click="enterDatabaseInfo">Enter</button>
378379
</div>
379-
<button class="mongo_db_enter" @click="enterDatabaseInfo">Enter</button>
380380
</div>
381381

382382

@@ -609,6 +609,35 @@ p.credits {
609609
gap: 0.5rem;
610610
}
611611
612+
.text-box {
613+
padding: 0.5rem;
614+
border-radius: 25px;
615+
border: 1px solid #1e293b;
616+
width: 300px;
617+
background-color: #1e293b;
618+
color: #ffffff;
619+
}
620+
621+
.mongo_db_enter {
622+
border-radius: 20px;
623+
border: 1px solid transparent;
624+
padding: 1.0em 1.2em;
625+
padding: 1vh;
626+
margin-right: 1vh;
627+
font-size: 1em;
628+
font-weight: 500;
629+
font-family: inherit;
630+
transition: border-color 0.25s;
631+
transition: all 0.2s ease;
632+
box-shadow: 0 2px 2px rgba(2, 59, 98, 0.2);
633+
background-color: #5d98f6;
634+
color: #ffffff;
635+
}
636+
637+
.mongo_db_enter:hover {
638+
background-color: #2563eb;
639+
border-color: #45475a;
640+
}
612641
613642
.result {
614643
display: flex;

src/Authen.vue

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,9 @@ const username = ref("")
146146
const password = ref("")
147147
148148
async function handleLogin() {
149-
let success = await invoke("login", {
149+
await invoke("login", {
150150
username: username.value,
151151
password: password.value
152152
});
153-
if(success) {
154-
window.location.href = "/#/"
155-
} else {
156-
alert("Invalid username or password")
157-
}
158153
}
159154
</script>

0 commit comments

Comments
 (0)