-
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.
Integrate Tracey's Robocritter certificate changes.
- Loading branch information
Showing
10 changed files
with
801 additions
and
489 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Controller from '@ember/controller'; | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
|
||
export default class RobocritterCertificateController extends Controller { | ||
@tracked minutes: number = 0; | ||
@tracked seconds: number = 0; | ||
@tracked player: string = ''; | ||
@tracked robot: string = ''; | ||
|
||
@action | ||
async downloadCertificate() { | ||
const response = await fetch( | ||
'http://127.0.0.1:5000/api/generate-certificate', | ||
{ | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
player: this.player, | ||
robot: this.robot, | ||
minutes: this.minutes, | ||
seconds: this.seconds, | ||
}), | ||
}, | ||
); | ||
|
||
if (response.ok) { | ||
const blob = await response.blob(); | ||
const url = window.URL.createObjectURL(blob); | ||
const a = document.createElement('a'); | ||
a.href = url; | ||
a.download = this.player + '_' + this.robot + '_certificate.odg'; | ||
document.body.appendChild(a); | ||
a.click(); | ||
a.remove(); | ||
window.URL.revokeObjectURL(url); | ||
} else { | ||
alert('Failed to generate the certificate'); | ||
} | ||
} | ||
} |
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,23 @@ | ||
<!-- app/templates/robocritter-certificate.hbs --> | ||
<div> | ||
<label for="player">Player Name:</label> | ||
<input type="text" id="player" value={{this.player}} oninput={{action (mut this.player) value="target.value"}} autocomplete="off" required> | ||
</div> | ||
|
||
<div> | ||
<label for="robot">Robot Name:</label> | ||
<input type="text" id="robot" value={{this.robot}} oninput={{action (mut this.robot) value="target.value"}} autocomplete="off" required> | ||
</div> | ||
|
||
<div> | ||
<label for="minutes">Minutes:</label> | ||
<input type="number" id="minutes" value={{this.minutes}} oninput={{action (mut this.minutes) value="target.value"}} autocomplete="off" required> | ||
</div> | ||
|
||
<div> | ||
<label for="seconds">Seconds:</label> | ||
<input type="number" id="seconds" value={{this.seconds}} oninput={{action (mut this.seconds) value="target.value"}} autocomplete="off" required> | ||
</div> | ||
|
||
<div><button {{on "click" this.downloadCertificate}}>Download Certificate</button></div> | ||
|
Oops, something went wrong.