fixed flags and images showing up in Modify Contest

main
Alex 5 months ago
parent 51521d9a4a
commit 81d5cc966d

@ -78,7 +78,7 @@
<br> <br>
Some <span style="color:white;">Flags</span> may show up with <span style="color: red;">NONE</span> Some <span style="color:white;">Flags</span> may show up with <span style="color: red;">NONE</span>
but be in different <span style="color:white;">Contests</span> but be in different <span style="color:white;">Contests</span>
you can select <span style="color:white;">Flags</span> to delete or change by <i>clicking</i> on them. you can select <span style="color:white;">Flags</span> to delete by <i>clicking</i> on them.
</span> </span>
</div> </div>
<br> <br>

@ -51,6 +51,7 @@ handlePopupMessage(event: MessageEvent): void {
this.modifyContestService.loadFlagsForContest(event.data.contestId) this.modifyContestService.loadFlagsForContest(event.data.contestId)
.then(flags => this.flagsForContest = flags) .then(flags => this.flagsForContest = flags)
.catch(err => console.error('Error reloading flags:', err)); .catch(err => console.error('Error reloading flags:', err));
this.getImages();
} }
} }
@ -70,7 +71,7 @@ handlePopupMessage(event: MessageEvent): void {
this.activeContest = await this.modifyContestService.getActiveContest(this.getEmail()); this.activeContest = await this.modifyContestService.getActiveContest(this.getEmail());
} }
async getImages(): Promise<void>{ async getImages(): Promise<void> {
const email = this.getEmail(); const email = this.getEmail();
try{ try{
const imageData = await this.modifyContestService.getImages(email); const imageData = await this.modifyContestService.getImages(email);
@ -79,13 +80,18 @@ handlePopupMessage(event: MessageEvent): void {
// get all of the images that are not linked to a flag // get all of the images that are not linked to a flag
let images : Image[] = []; let images : Image[] = [];
for (let i=0; i < this.flagsForContest.length; i++) { for (let i=0; i < this.flagsForContest.length; i++) {
// if the image for the flag is Ubuntu so no image
if (this.allImages[i] === undefined) {
continue;
}
if (this.flagsForContest[i].Image === this.allImages[i].Name) { if (this.flagsForContest[i].Image === this.allImages[i].Name) {
images.push(this.allImages[i]); // images that are connected to a flag images.push(this.allImages[i]); // images that are connected to a flag
} }
} }
this.allImages = this.allImages.filter(item => !images.includes(item)); // change allImages to just have the ones that are not in images this.allImages = this.allImages.filter(item => !images.includes(item)); // change allImages to just have the ones that are not in images
}catch(error){ }catch(error){
console.error('Error loading images'); console.error(error);
} }
} }
@ -203,6 +209,7 @@ handlePopupMessage(event: MessageEvent): void {
this.isDialogVisible = false; this.isDialogVisible = false;
this.selectedFlag = null; this.selectedFlag = null;
this.selectedFlagImage = null; this.selectedFlagImage = null;
this.getImages();
} }
async DeleteImage(): Promise<void> { async DeleteImage(): Promise<void> {
@ -217,7 +224,7 @@ handlePopupMessage(event: MessageEvent): void {
this.allImages = await this.modifyContestService.getImages(this.getEmail()); this.allImages = await this.modifyContestService.getImages(this.getEmail());
} }
catch(err) { catch(err) {
console.error("Filed deleting image"); console.error("Failed deleting image");
} }
console.log("Deleted Image"); console.log("Deleted Image");
@ -225,6 +232,8 @@ handlePopupMessage(event: MessageEvent): void {
this.isDialogVisible = false; this.isDialogVisible = false;
this.selectedFlag = null; this.selectedFlag = null;
this.selectedFlagImage = null; this.selectedFlagImage = null;
console.log(this.allImages);
this.selectContest(this.selectedContestId);
} }
async TestImage(): Promise<void>{ async TestImage(): Promise<void>{

Loading…
Cancel
Save