Skip to content

Commit

Permalink
Merge pull request #281 from computas/develop
Browse files Browse the repository at this point in the history
merge v2.1.2 into release
  • Loading branch information
ellenyuX authored Oct 7, 2024
2 parents 44eb543 + f8544b5 commit 494898c
Show file tree
Hide file tree
Showing 45 changed files with 297 additions and 272 deletions.
15 changes: 0 additions & 15 deletions src/app/admin/dialog-template/dialog-template.component.html

This file was deleted.

23 changes: 0 additions & 23 deletions src/app/admin/dialog-template/dialog-template.component.scss

This file was deleted.

11 changes: 11 additions & 0 deletions src/app/admin/dialog/dialog.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div mat-dialog-content class="dialog-content">
<h1 align="center" class="dialog-title" mat-dialog-title>Informasjon</h1>

<div class="dialog-body">
<p><b>Navn på iterasjon:</b> {{ data.iterationName }}</p>
<p><b>Tidspunktet iterasjonen ble lagd:</b> {{ data.timeCreated }}</p>
<p><b>Antall (nye) bilder i treningssettet:</b> {{ data.imageCount }}</p>
</div>

<p class="dialog-footer">(Trykk utenfor boksen for å lukke)</p>
</div>
29 changes: 29 additions & 0 deletions src/app/admin/dialog/dialog.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.dialog-content {
text-align: center;
padding: 20px;
max-width: 400px;
margin: auto;
}

.dialog-title {
font-size: 24px;
font-weight: bold;
margin-bottom: 20px;
}

.dialog-body p {
font-size: 16px;
margin: 10px 0;
font-weight: 500;
}

.dialog-body b {
font-weight: 900;
}

.dialog-footer {
font-size: 14px;
color: grey;
margin-top: 20px;
font-style: italic;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { DialogData } from '@/app/shared/models/interfaces';

@Component({
selector: 'app-dialog-template',
templateUrl: './dialog-template.component.html',
styleUrls: ['./dialog-template.component.scss'],
templateUrl: './dialog.component.html',
styleUrls: ['./dialog.component.scss'],
standalone: true,
imports: [CdkScrollable, MatDialogContent, MatDialogTitle],
})
export class DialogTemplateComponent {
export class DialogComponent {
constructor(@Inject(MAT_DIALOG_DATA) public data: DialogData) {}
}
16 changes: 9 additions & 7 deletions src/app/admin/info-dialog/info-dialog.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { DialogTemplateComponent } from './../dialog-template/dialog-template.component';
import { DialogComponent } from '../dialog/dialog.component';
import { ErrorLogDialogComponent } from '../error-dialog/error-dialog.component';
import { LogData } from '@/app/shared/models/backend-interfaces';

Expand All @@ -14,7 +14,7 @@ export class InfoDialogComponent {
constructor(public dialog: MatDialog) {}

openDialog(iterName: string, time: string, imgCount: string) {
this.dialog.open(DialogTemplateComponent, {
this.dialog.open(DialogComponent, {
data: {
iterationName: iterName,
timeCreated: time,
Expand All @@ -23,10 +23,12 @@ export class InfoDialogComponent {
});
}

openErrorLog(logDataArray: LogData[]) {
openErrorLog(logDataArray: LogData[]) {

this.dialog.open(ErrorLogDialogComponent, {
data: logDataArray,
});
}
this.dialog.open(ErrorLogDialogComponent, {
data: logDataArray,
});
}

}

16 changes: 16 additions & 0 deletions src/app/admin/info-page/info-page.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1 align="center" class="info-title">Administrative handlinger</h1>
<br/>
<div class="btn-group" align="center">
<button class="btn btn-lg btn-outline-primary" (click)="getInformation()">Vis informasjon</button>
<p></p>
<button (click)="clearHighScore()">{{ this.highScoreString }}</button>
<p></p>
<button (click)="getLogger()">Hent feilmeldingsloggen (backend)</button>
<p></p>
<button (click)="getLoggerFrontend()">Hent feilmeldingsloggen (frontend)</button>
</div>
<br />

<div align="center">
<button mat-button class="sign-out-btn" (click)="signOut()">Logg ut</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ p {
}

.btn-group button:first-child {
background-color: #c78bde;
background-color: #734f81;
margin-top: 2vh;
border: 1px solid #96a7b1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { LoginService } from '../login.service';
import { MatSnackBar } from '@angular/material/snack-bar';
import { InfoDialogComponent } from './../info-dialog/info-dialog.component';
import { InfoDialogComponent } from '../info-dialog/info-dialog.component';
import { PairingService } from '../../game/services/pairing.service';
import { MatButton } from '@angular/material/button';
import { LogData, StatusData } from '@/app/shared/models/backend-interfaces';
import { LoggingService } from '../../game/services/logging.service';

@Component({
selector: 'app-info',
templateUrl: './info.component.html',
styleUrls: ['./info.component.scss'],
templateUrl: './info-page.component.html',
styleUrls: ['./info-page.component.scss'],
standalone: true,
imports: [MatButton],
})
export class InfoComponent {
export class InfoPageComponent {
datasetString = 'Nullstill treningssett til originalen';
datasetBool = false;
retrainString = 'Tren maskinlæringsmodellen';
Expand All @@ -34,49 +34,7 @@ export class InfoComponent {
private pairing: PairingService,
private loggingService: LoggingService
) {}

revertDataset() {
let msg = '';
if (this.datasetBool) {
this.resetDatasetValues();
this.loginService.revertDataset().subscribe(
() => {
this.openSnackBar('Suksess! Treningssett tilbakestilles (dette kan ta noen minutter)');
},
() => {
msg = this.errorMsg;
this.openSnackBar(msg);
}
);
this.resetDatasetValues();
} else {
this.resetHighScoreValues();
this.resetRetrainValues();
this.setDatasetValues();
}
}

retrain() {
let msg = '';
if (this.retrainBool) {
this.resetDatasetValues();
this.loginService.retrain().subscribe(
() => {
this.openSnackBar('Suksess! Modellen blir trent (dette kan ta noen minutter)');
},
() => {
msg = this.errorMsg;
this.openSnackBar(msg);
}
);
this.resetRetrainValues();
} else {
this.resetDatasetValues();
this.resetHighScoreValues();
this.setRetrainValues();
}
}


clearHighScore() {
let msg = '';
if (this.highScoreBool) {
Expand All @@ -93,7 +51,6 @@ export class InfoComponent {
this.resetHighScoreValues();
} else {
this.resetDatasetValues();
this.resetRetrainValues();
this.setHighScoreValues();
}
}
Expand All @@ -103,37 +60,16 @@ export class InfoComponent {
this.highScoreBool = false;
}

resetRetrainValues() {
this.retrainString = 'Tren maskinlæringsmodellen';
this.retrainBool = false;
}

resetDatasetValues() {
this.datasetString = 'Nullstill treningssett til originalen';
this.datasetBool = false;
}

resetAll() {
this.resetHighScoreValues();
this.resetRetrainValues();
this.resetDatasetValues();
}

setHighScoreValues() {
this.highScoreString = this.secondMsg;
this.highScoreBool = true;
}

setRetrainValues() {
this.retrainString = this.secondMsg;
this.retrainBool = true;
}

setDatasetValues() {
this.datasetString = this.secondMsg;
this.datasetBool = true;
}

signOut() {
this.loginService.signOut().subscribe(
() => {
Expand All @@ -148,7 +84,6 @@ export class InfoComponent {
}

getInformation() {
this.resetAll();
this.loginService.getStatus().subscribe(
(res: StatusData) => {
const name = res.CV_iteration_name;
Expand Down Expand Up @@ -192,12 +127,4 @@ export class InfoComponent {
duration: 6000,
});
}

pair(id: string) {
this.pairing.setPairID(id);
}

getPairID() {
return this.pairing.getPairID();
}
}
29 changes: 0 additions & 29 deletions src/app/admin/info/info.component.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Subject } from 'rxjs';
import { Router } from '@angular/router';
import { MatDialog } from '@angular/material/dialog';
import { RouterOutlet } from '@angular/router';
import { IdleTimeoutComponent } from './game/idle-timeout/idle-timeout.component';
import { IdleTimeoutComponent } from './game/shared-components/idle-timeout/idle-timeout.component';
import { routeTransitionAnimations } from './route-transition-animations';
import { environment } from '../environments/environment';
import { GameStateService } from './game/services/game-state-service';
Expand Down
11 changes: 8 additions & 3 deletions src/app/game/game-draw/game-draw.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { TranslationService } from '@/app/core/translation.service';
import { TranslatePipe } from '@/app/core/translation.pipe';
import { GameStateService } from '../services/game-state-service';
import { CustomColorsIO } from '@/app/shared/customColors';
import { SpeechBubbleComponent } from '../speech-bubble/speech-bubble.component';
import { SpeechBubbleComponent } from '../shared-components/speech-bubble/speech-bubble.component';
import { OAvatarComponent } from '@/assets/avatars/o-avatar/o-avatar.component';
import { IAvatarComponent } from '@/assets/avatars/i-avatar/i-avatar.component';
import { ViewChild } from '@angular/core';
Expand Down Expand Up @@ -250,6 +250,11 @@ export class GameDrawComponent implements OnInit, OnDestroy {
if (this.gameStateService.isSingleplayer() && !this.drawingService.hasAddedSingleplayerResult) {
let res;
let hasWon = false;

if (this.isBlankImage) {
return;
}

if (!this.drawingService.pred) {
res = this.drawingService.createDefaultResult();
} else {
Expand Down Expand Up @@ -338,12 +343,13 @@ export class GameDrawComponent implements OnInit, OnDestroy {
if (sortedCertaintyArr && sortedCertaintyArr.length > 1) {
const guess = sortedCertaintyArr[0].label;
this.AI_GUESS = guess === this.guessWord ? sortedCertaintyArr[1].label : guess;
} else if (sortedCertaintyArr[0].label === "blank") {
this.AI_GUESS = "";
}
}

handleSinglePlayerClassification(dataUrl: string, croppedCoordinates: number[]) {
const formData: FormData = this.createFormData(dataUrl);

this.drawingService.classify(formData).subscribe((res) => {
const sortedCertaintyArr = this.sortOnCertainty(res);
this.updateAiGuess(sortedCertaintyArr);
Expand Down Expand Up @@ -375,7 +381,6 @@ export class GameDrawComponent implements OnInit, OnDestroy {
}

classify(isMultiplayer = false) {
//TODO: rename?
this.drawnPixelsAtLastGuess = this.drawnPixels;
const b64Image = this.canvas.nativeElement.toDataURL('image/png');
const croppedCoordinates: number[] = this.imageService.crop(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TranslatePipe } from '@/app/core/translation.pipe';
import { SpeechBubbleComponent } from '../../speech-bubble/speech-bubble.component';
import { SpeechBubbleComponent } from '../../shared-components/speech-bubble/speech-bubble.component';
import { Component, OnInit } from '@angular/core';
import { ArrowAlignment, PointerSide } from '@/app/shared/models/interfaces';
import { CustomColorsIO } from '../../../shared/customColors';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { SpeechBubbleComponent } from '@/app/game/speech-bubble/speech-bubble.component';
import { SpeechBubbleComponent } from '@/app/game/shared-components/speech-bubble/speech-bubble.component';
import { OAvatarComponent } from '@/assets/avatars/o-avatar/o-avatar.component';
import { ArrowAlignment, PointerSide } from '@/app/shared/models/interfaces';
import { CustomColorsIO } from '@/app/shared/customColors';
Expand Down
Loading

0 comments on commit 494898c

Please sign in to comment.