Added connections. Added url redirect for login.
This commit is contained in:
@ -0,0 +1,49 @@
|
||||
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 { Router } from '@angular/router';
|
||||
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 {
|
||||
router = inject(Router);
|
||||
http = inject(HttpClient);
|
||||
client = inject(HermesClientService);
|
||||
|
||||
connection = input.required<Connection>();
|
||||
|
||||
constructor(@Inject(DOCUMENT) private document: Document) { }
|
||||
|
||||
delete(conn: Connection) {
|
||||
this.client.deleteConnection(conn.name);
|
||||
}
|
||||
|
||||
renew(conn: 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user