Added connections. Added url redirect for login.
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
<section [class.twitch]="connection().type == 'twitch'"
|
||||
[class.spotify]="connection().type == 'spotify'">
|
||||
{{connection().name}}
|
||||
|
||||
<article class="right">
|
||||
<button mat-button
|
||||
class="neutral"
|
||||
(click)="renew(connection())">
|
||||
<mat-icon>refresh</mat-icon>
|
||||
Renew
|
||||
</button>
|
||||
<button mat-button
|
||||
class="danger"
|
||||
(click)="delete(connection())">
|
||||
<mat-icon>delete</mat-icon>
|
||||
Delete
|
||||
</button>
|
||||
</article>
|
||||
</section>
|
@ -0,0 +1,11 @@
|
||||
section {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
.right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
button {
|
||||
margin: 0 0.5em;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ConnectionItemComponent } from './connection-item.component';
|
||||
|
||||
describe('ConnectionItemComponent', () => {
|
||||
let component: ConnectionItemComponent;
|
||||
let fixture: ComponentFixture<ConnectionItemComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ConnectionItemComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ConnectionItemComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -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