Fixed issues with impersonation. Show warning or error depending on connection's remaining time before expiry. Replaced use of /api/... in urls.
This commit is contained in:
@ -2,6 +2,14 @@
|
||||
[class.nightbot]="connection().type == 'nightbot'">
|
||||
{{connection().name}}
|
||||
|
||||
@if (isExpired) {
|
||||
<mat-icon matTooltip="Connection has expired."
|
||||
class="danger">error</mat-icon>
|
||||
} @else if (isExpiringSoon) {
|
||||
<mat-icon matTooltip="Connection is soon going to expire."
|
||||
class="warning">warning</mat-icon>
|
||||
}
|
||||
|
||||
<article class="right">
|
||||
<button mat-button
|
||||
class="neutral"
|
||||
|
@ -3,10 +3,13 @@ import { Connection } from '../../shared/models/connection';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import {MatTooltipModule} from '@angular/material/tooltip';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { HermesClientService } from '../../hermes-client.service';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import moment from 'moment';
|
||||
|
||||
@Component({
|
||||
selector: 'connection-item',
|
||||
@ -14,6 +17,7 @@ import { HermesClientService } from '../../hermes-client.service';
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatFormFieldModule,
|
||||
MatTooltipModule,
|
||||
ReactiveFormsModule,
|
||||
],
|
||||
templateUrl: './connection-item.component.html',
|
||||
@ -27,13 +31,25 @@ export class ConnectionItemComponent {
|
||||
|
||||
constructor(@Inject(DOCUMENT) private document: Document) { }
|
||||
|
||||
ngOnInit() {
|
||||
console.log('coonnn', this.connection())
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.client.deleteConnection(this.connection().name);
|
||||
}
|
||||
|
||||
get isExpired() {
|
||||
return moment(this.connection().expires_at).toDate().getTime() < new Date().getTime();
|
||||
}
|
||||
|
||||
get isExpiringSoon() {
|
||||
return moment(this.connection().expires_at).toDate().getTime() < moment.now() + moment.duration(7, 'd').asMilliseconds();
|
||||
}
|
||||
|
||||
renew() {
|
||||
const conn = this.connection();
|
||||
this.http.post('/api/auth/connections', {
|
||||
this.http.post(environment.API_HOST + '/auth/connections', {
|
||||
name: conn.name,
|
||||
type: conn.type,
|
||||
client_id: conn.client_id,
|
||||
|
Reference in New Issue
Block a user