Added redemptions page. Fixed some issues. Removed some instances of console.log().

This commit is contained in:
Tom
2025-01-13 23:37:31 +00:00
parent 7a7fb832a0
commit 04a50f6db0
39 changed files with 2342 additions and 1564 deletions

View File

@ -10,72 +10,72 @@ import { HermesClientService } from '../../hermes-client.service';
import { Router } from '@angular/router';
@Component({
selector: 'impersonation',
standalone: true,
imports: [MatCardModule, MatSelectModule],
templateUrl: './impersonation.component.html',
styleUrl: './impersonation.component.scss'
selector: 'impersonation',
standalone: true,
imports: [MatCardModule, MatSelectModule],
templateUrl: './impersonation.component.html',
styleUrl: './impersonation.component.scss'
})
export class ImpersonationComponent implements OnInit {
impersonated: string | undefined;
users: { id: string, name: string }[];
impersonated: string | undefined;
users: { id: string, name: string }[];
constructor(private hermes: HermesClientService, private auth: ApiAuthenticationService, private router: Router, private events: EventService, private http: HttpClient, @Inject(PLATFORM_ID) private platformId: Object) {
this.users = []
constructor(private hermes: HermesClientService, private auth: ApiAuthenticationService, private router: Router, private events: EventService, private http: HttpClient, @Inject(PLATFORM_ID) private platformId: Object) {
this.users = []
}
ngOnInit(): void {
if (!isPlatformBrowser(this.platformId)) {
return;
}
ngOnInit(): void {
if (!isPlatformBrowser(this.platformId)) {
return;
this.http.get(environment.API_HOST + '/admin/users', {
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('jwt')
}
}).subscribe((data: any) => {
this.users = data.filter((d: any) => d.name != this.auth.getUsername());
const id = this.auth.getImpersonatedId();
if (id && this.users.find(u => u.id == id)) {
this.impersonated = id;
}
});
}
public isAdmin() {
return this.auth.isAdmin();
}
public getUsername() {
return this.auth.getUsername();
}
public onChange(e: any) {
if (!e.value) {
this.http.delete(environment.API_HOST + '/admin/impersonate', {
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('jwt')
},
body: {
impersonation: e.value
}
this.http.get(environment.API_HOST + '/admin/users', {
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('jwt')
}
}).subscribe((data: any) => {
this.users = data.filter((d: any) => d.name != this.auth.getUsername());
const id = this.auth.getImpersonatedId();
if (id && this.users.find(u => u.id == id)) {
this.impersonated = id;
}
});
}
public isAdmin() {
return this.auth.isAdmin();
}
public getUsername() {
return this.auth.getUsername();
}
public onChange(e: any) {
if (!e.value) {
this.http.delete(environment.API_HOST + '/admin/impersonate', {
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('jwt')
},
body: {
impersonation: e.value
}
}).subscribe(async (data: any) => {
this.hermes.disconnect();
this.events.emit('impersonation', e.value);
await this.router.navigate(['tts-login']);
});
} else {
this.http.put(environment.API_HOST + '/admin/impersonate', {
impersonation: e.value
}, {
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('jwt')
}
}).subscribe(async (data: any) => {
this.hermes.disconnect();
this.events.emit('impersonation', e.value);
await this.router.navigate(['tts-login']);
});
}).subscribe(async (data: any) => {
this.hermes.disconnect();
this.events.emit('impersonation', e.value);
await this.router.navigate(['tts-login']);
});
} else {
this.http.put(environment.API_HOST + '/admin/impersonate', {
impersonation: e.value
}, {
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('jwt')
}
}).subscribe(async (data: any) => {
this.hermes.disconnect();
this.events.emit('impersonation', e.value);
await this.router.navigate(['tts-login']);
});
}
}
}