diff --git a/src/app/api/client.service.ts b/src/app/api/client.service.ts index b160464..703d990 100644 --- a/src/app/api/client.service.ts +++ b/src/app/api/client.service.ts @@ -14,6 +14,7 @@ import {Params} from "@angular/router"; import {ApiImplementation} from "./api-implementation"; import {Contest} from "./types/contests/contest"; import {Score} from "./types/levels/score"; +import { LevelRelations } from './types/levels/level-relations'; export const defaultPageSize: number = 40; @@ -108,4 +109,28 @@ export class ClientService extends ApiImplementation { getPhotoById(id: number) { return this.http.get(`/photos/id/${id}`); } + + getLevelRelations(id: number) { + return this.http.get(`/levels/id/${id}/relations`); + } + + setLevelAsHearted(id: number) { + return this.http.post(`/levels/id/${id}/heart`, null); + } + + setLevelAsUnhearted(id: number) { + return this.http.post(`/levels/id/${id}/unheart`, null); + } + + setLevelAsQueued(id: number) { + return this.http.post(`/levels/id/${id}/queue`, null); + } + + setLevelAsDequeued(id: number) { + return this.http.post(`/levels/id/${id}/dequeue`, null); + } + + setLevelAsOverride(id: number) { + return this.http.post(`/levels/id/${id}/setAsOverride`, null); + } } diff --git a/src/app/api/types/levels/level-relations.ts b/src/app/api/types/levels/level-relations.ts new file mode 100644 index 0000000..f13db7f --- /dev/null +++ b/src/app/api/types/levels/level-relations.ts @@ -0,0 +1,5 @@ +export interface LevelRelations { + isHearted: boolean; + isQueued: boolean; + myPlaysCount: number; +} \ No newline at end of file diff --git a/src/app/api/types/levels/level.ts b/src/app/api/types/levels/level.ts index 8f9e512..22b2c3e 100644 --- a/src/app/api/types/levels/level.ts +++ b/src/app/api/types/levels/level.ts @@ -16,4 +16,5 @@ export interface Level { teamPicked: boolean; gameVersion: number; score: number; + slotType: number; } diff --git a/src/app/components/ui/form/button-or-navitem.component.ts b/src/app/components/ui/form/button-or-navitem.component.ts new file mode 100644 index 0000000..6139eed --- /dev/null +++ b/src/app/components/ui/form/button-or-navitem.component.ts @@ -0,0 +1,105 @@ +import { Component, Input } from "@angular/core"; +import { IconProp } from "@fortawesome/fontawesome-svg-core"; +import { NavbarItemComponent } from "../header/navbar-item.component"; +import { NavbarItemTwoStateComponent } from "../header/navbar-item-two-state.component"; +import { ButtonComponent } from "./button.component"; +import { ButtonTwoStateComponent } from "./button-two-state.component"; + +@Component({ + selector: 'app-button-or-navitem', + standalone: true, + imports: [ + NavbarItemComponent, + NavbarItemTwoStateComponent, + ButtonComponent, + ButtonTwoStateComponent + ], + template: ` + + @if (isNavItem) { + @if (state != undefined) { + + + } + @else { + + + } + } + + @else { + @if (state != undefined) { + + + } + @else { + + + } + } + `, + styles: `` +}) + +export class ButtonOrNavItemComponent { + @Input() text: string = "" + @Input() textAlt: string = "" + + @Input() icon: IconProp | undefined; + @Input() iconAlt: IconProp | undefined; + + @Input() color: string = "" + @Input() colorAlt: string = "" + + @Input() state: boolean | undefined; + @Input() route: string | undefined; + @Input() hasText: boolean = true; + @Input() isNavItem: boolean = false; + + @Input() labelClass: string = "text-lg"; + @Input() iconClass: string = "w-4 text-[1.1rem]"; + + finalText: string = ""; + finalTextAlt: string = ""; + + + ngOnInit() { + this.initText(); + } + + initText() { + if (this.hasText) { + this.finalText = this.text; + if (this.state != undefined) { + this.finalTextAlt = this.textAlt; + } + } + } +} \ No newline at end of file diff --git a/src/app/components/ui/form/button-two-state.component.ts b/src/app/components/ui/form/button-two-state.component.ts new file mode 100644 index 0000000..2666ef1 --- /dev/null +++ b/src/app/components/ui/form/button-two-state.component.ts @@ -0,0 +1,34 @@ +import {Component, Input} from '@angular/core'; +import {ButtonComponent} from "./button.component"; +import {IconProp} from "@fortawesome/fontawesome-svg-core"; + +@Component({ + selector: 'app-button-two-state', + standalone: true, + imports: [ + ButtonComponent + ], + template: ` + @if (state) { + + } + @else { + + } + `, + styles: `` +}) +export class ButtonTwoStateComponent { + @Input({required: true}) state: boolean = false; + + @Input({required: true}) text: string = "Activate"; + @Input({required: true}) textAlternative: string = "Deactivate"; + + @Input() icon: IconProp | undefined; + @Input() iconAlternative: IconProp | undefined; + + @Input() color: string = "bg-primary"; + @Input() colorAlternative: string = "bg-secondary"; + + @Input() enabled: boolean = true; +} \ No newline at end of file diff --git a/src/app/components/ui/form/button.component.ts b/src/app/components/ui/form/button.component.ts index 7211ae3..5ff9d8f 100644 --- a/src/app/components/ui/form/button.component.ts +++ b/src/app/components/ui/form/button.component.ts @@ -11,7 +11,8 @@ import { NgClass } from "@angular/common"; NgClass ], template: ` -