-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support page greeting and config form.
- Loading branch information
1 parent
3e7292c
commit b9aa277
Showing
10 changed files
with
108 additions
and
14 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
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
19 changes: 19 additions & 0 deletions
19
...ts/gameboard-ui/src/app/admin/components/support-settings/support-settings.component.html
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,19 @@ | ||
<h1> | ||
Support Settings | ||
</h1> | ||
|
||
<div class="settings-section mt-4 mb-4" *ngIf="settings; else loading"> | ||
<h2>Greeting</h2> | ||
<p> | ||
This text appears as a banner on the Support page to welcome players. Edit it below | ||
to customize it to your needs. | ||
</p> | ||
|
||
<label for="supportPageGreeting">Enter a greeting (allows markdown)</label> | ||
<textarea id="supportPageGreeting" rows="8" [placeholder]="'Welcome to **' + appName + '** Support!'" | ||
class="form-control" [(ngModel)]="settings.supportPageGreeting" (input)="handleSettingsChanged()"></textarea> | ||
</div> | ||
|
||
<ng-template #loading> | ||
<app-spinner></app-spinner> | ||
</ng-template> |
Empty file.
44 changes: 44 additions & 0 deletions
44
...ects/gameboard-ui/src/app/admin/components/support-settings/support-settings.component.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,44 @@ | ||
import { SupportSettings } from '@/api/support-models'; | ||
import { SupportService } from '@/api/support.service'; | ||
import { UnsubscriberService } from '@/services/unsubscriber.service'; | ||
import { ConfigService } from '@/utility/config.service'; | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Subject, debounceTime, firstValueFrom } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-support-settings', | ||
templateUrl: './support-settings.component.html', | ||
styleUrls: ['./support-settings.component.scss'], | ||
providers: [UnsubscriberService] | ||
}) | ||
export class SupportSettingsComponent implements OnInit { | ||
protected appName: string; | ||
protected settings?: SupportSettings; | ||
private update$ = new Subject<SupportSettings>(); | ||
|
||
constructor( | ||
config: ConfigService, | ||
private supportService: SupportService, | ||
private unsub: UnsubscriberService) { | ||
// use the app name to personalize the placeholder | ||
this.appName = config.appName; | ||
|
||
// debounce input on the big textboxes | ||
this.unsub.add( | ||
this.update$.pipe( | ||
debounceTime(500) | ||
).subscribe(async update => { | ||
await firstValueFrom(this.supportService.updateSettings(update)); | ||
}) | ||
); | ||
} | ||
|
||
async ngOnInit(): Promise<void> { | ||
this.settings = await firstValueFrom(this.supportService.getSettings()); | ||
} | ||
|
||
protected async handleSettingsChanged() { | ||
if (this.settings) | ||
this.update$.next(this.settings); | ||
} | ||
} |
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
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 |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
padding-top: 1rem; | ||
padding-left: 2rem; | ||
} | ||
|
||
hr { | ||
border: solid 1px #eee; | ||
} |
26 changes: 14 additions & 12 deletions
26
projects/gameboard-ui/src/app/support/support-page/support-page.component.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 |
---|---|---|
@@ -1,35 +1,37 @@ | ||
import { Component, OnDestroy, OnInit } from '@angular/core'; | ||
import { Subscription } from 'rxjs'; | ||
import { filter, tap } from 'rxjs/operators'; | ||
import { ConfigService } from '../../utility/config.service'; | ||
import { NotificationService } from '../../services/notification.service'; | ||
import { UserService } from '../../utility/user.service'; | ||
import { UnsubscriberService } from '@/services/unsubscriber.service'; | ||
import { SupportSettings } from '@/api/support-models'; | ||
import { SupportService } from '@/api/support.service'; | ||
import { firstValueFrom } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-support-page', | ||
templateUrl: './support-page.component.html', | ||
styleUrls: ['./support-page.component.scss'] | ||
styleUrls: ['./support-page.component.scss'], | ||
providers: [UnsubscriberService] | ||
}) | ||
export class SupportPageComponent implements OnInit, OnDestroy { | ||
s: Subscription[] = []; | ||
export class SupportPageComponent implements OnInit { | ||
protected settings?: SupportSettings; | ||
|
||
constructor( | ||
private config: ConfigService, | ||
private supportService: SupportService, | ||
private unsub: UnsubscriberService, | ||
hub: NotificationService, | ||
user: UserService | ||
) { | ||
this.s.push( | ||
// join the hub to get ticket notifications | ||
this.unsub.add( | ||
user.user$.pipe( | ||
filter(u => !!u), | ||
tap(u => hub.init(u!.id)) | ||
).subscribe() | ||
); | ||
} | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.s.forEach(s => s.unsubscribe()); | ||
async ngOnInit(): Promise<void> { | ||
this.settings = await firstValueFrom(this.supportService.getSettings()); | ||
} | ||
} |