-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from linomp/feat/leaderboard
Add leaderboard functionality
- Loading branch information
Showing
32 changed files
with
662 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ venv | |
.idea | ||
*.xml | ||
*.iml | ||
*.pyc | ||
*.pyc | ||
**/data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,46 @@ | ||
<script lang="ts"> | ||
import { onMount } from "svelte"; | ||
import { Route, Router } from "svelte-navigator"; | ||
import { GameParametersService, OpenAPI } from "./api/generated/"; | ||
import { globalSettings } from "src/stores/stores"; | ||
import { isUndefinedOrNull } from "src/shared/utils"; | ||
import HomePage from "src/pages/HomePage.svelte"; | ||
import Spinner from "src/components/graphical/Spinner.svelte"; | ||
import Preloader from "src/components/Preloader.svelte"; | ||
import {onMount} from "svelte"; | ||
import {Route, Router} from "svelte-navigator"; | ||
import {GameParametersService} from "./api/generated/"; | ||
import {globalSettings} from "src/stores/stores"; | ||
import {isUndefinedOrNull} from "src/shared/utils"; | ||
import HomePage from "src/pages/HomePage.svelte"; | ||
import Spinner from "src/components/graphical/Spinner.svelte"; | ||
import Preloader from "src/components/Preloader.svelte"; | ||
OpenAPI.BASE = import.meta.env.VITE_API_BASE; | ||
onMount(async () => { | ||
try { | ||
globalSettings.set( | ||
await GameParametersService.getParametersGameParametersGet(), | ||
); | ||
} catch (error) { | ||
alert( | ||
"Error fetching game settings or connecting to MQTT broker. Please refresh the page.", | ||
); | ||
} | ||
}); | ||
onMount(() => { | ||
GameParametersService.getParametersGameParametersGet() | ||
.then((response) => { | ||
globalSettings.set(response); | ||
}) | ||
.catch((error) => { | ||
alert( | ||
"Error fetching game settings or connecting to MQTT broker. Please refresh the page.", | ||
); | ||
}); | ||
}); | ||
</script> | ||
|
||
<svelte:head> | ||
<title>The Predictive Maintenance Game</title> | ||
<title>The Predictive Maintenance Game</title> | ||
</svelte:head> | ||
|
||
<Router primary={false}> | ||
<Preloader /> | ||
{#if isUndefinedOrNull($globalSettings)} | ||
<div class="spinner-container"> | ||
<Spinner /> | ||
</div> | ||
{:else} | ||
<div> | ||
<Route path="/" component={HomePage} /> | ||
</div> | ||
{/if} | ||
<Preloader/> | ||
{#if isUndefinedOrNull($globalSettings)} | ||
<div class="spinner-container"> | ||
<Spinner/> | ||
</div> | ||
{:else} | ||
<div> | ||
<Route path="/" component={HomePage}/> | ||
</div> | ||
{/if} | ||
</Router> | ||
|
||
<style> | ||
.spinner-container { | ||
width: 5%; | ||
margin: 0 auto; | ||
} | ||
.spinner-container { | ||
width: 5%; | ||
margin: 0 auto; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* generated using openapi-typescript-codegen -- do no edit */ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
export type HighScoreDTO = { | ||
nickname: string; | ||
score: number; | ||
timestamp: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* generated using openapi-typescript-codegen -- do no edit */ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
|
||
export type ScoreCreateRequest = { | ||
nickname: string; | ||
}; |
85 changes: 85 additions & 0 deletions
85
mvp/client/ui/src/api/generated/services/LeaderboardService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* generated using openapi-typescript-codegen -- do no edit */ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import type { HighScoreDTO } from '../models/HighScoreDTO'; | ||
import type { ScoreCreateRequest } from '../models/ScoreCreateRequest'; | ||
|
||
import type { CancelablePromise } from '../core/CancelablePromise'; | ||
import { OpenAPI } from '../core/OpenAPI'; | ||
import { request as __request } from '../core/request'; | ||
|
||
export class LeaderboardService { | ||
|
||
/** | ||
* Get Leaderboard | ||
* @returns HighScoreDTO Successful Response | ||
* @throws ApiError | ||
*/ | ||
public static getLeaderboardLeaderboardGet(): CancelablePromise<Array<HighScoreDTO>> { | ||
return __request(OpenAPI, { | ||
method: 'GET', | ||
url: '/leaderboard/', | ||
errors: { | ||
404: `Not found`, | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* Post Score | ||
* @param sessionId | ||
* @param requestBody | ||
* @returns any Successful Response | ||
* @throws ApiError | ||
*/ | ||
public static postScoreLeaderboardScorePost( | ||
sessionId: string, | ||
requestBody: ScoreCreateRequest, | ||
): CancelablePromise<any> { | ||
return __request(OpenAPI, { | ||
method: 'POST', | ||
url: '/leaderboard/score', | ||
query: { | ||
'session_id': sessionId, | ||
}, | ||
body: requestBody, | ||
mediaType: 'application/json', | ||
errors: { | ||
404: `Not found`, | ||
422: `Validation Error`, | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* Test Leaderboard Post | ||
* @returns any Successful Response | ||
* @throws ApiError | ||
*/ | ||
public static testLeaderboardPostLeaderboardTestPost(): CancelablePromise<any> { | ||
return __request(OpenAPI, { | ||
method: 'POST', | ||
url: '/leaderboard/test', | ||
errors: { | ||
404: `Not found`, | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* Test Leaderboard Delete | ||
* @returns any Successful Response | ||
* @throws ApiError | ||
*/ | ||
public static testLeaderboardDeleteLeaderboardTestDelete(): CancelablePromise<any> { | ||
return __request(OpenAPI, { | ||
method: 'DELETE', | ||
url: '/leaderboard/test', | ||
errors: { | ||
404: `Not found`, | ||
}, | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.