import { Component, Inject, inject, input } from '@angular/core'; 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 { ReactiveFormsModule } from '@angular/forms'; import { HttpClient } from '@angular/common/http'; import { DOCUMENT } from '@angular/common'; import { HermesClientService } from '../../hermes-client.service'; @Component({ selector: 'connection-item', imports: [ MatButtonModule, MatIconModule, MatFormFieldModule, ReactiveFormsModule, ], templateUrl: './connection-item.component.html', styleUrl: './connection-item.component.scss' }) export class ConnectionItemComponent { private readonly http = inject(HttpClient); private readonly client = inject(HermesClientService); connection = input.required(); constructor(@Inject(DOCUMENT) private document: Document) { } delete() { this.client.deleteConnection(this.connection().name); } renew() { const conn = this.connection(); this.http.post('/api/auth/connections', { name: conn.name, type: conn.type, client_id: conn.client_id, grant_type: conn.grant_type, }, { headers: { 'Authorization': 'Bearer ' + localStorage.getItem('jwt') } }).subscribe(async (d: any) => this.document.location.href = d.data); } }