noauthprobe-detail
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { NoAuthProbeListComponent } from './noauth-probe-list.component';
|
||||
import { NoAuthProbeDetailComponent } from './noauth-probe-detail.component';
|
||||
import { NoAuthProbeGeneralComponent } from './noauth-probe-general.component';
|
||||
|
||||
export const COMPONENTS = [
|
||||
NoAuthProbeListComponent,
|
||||
NoAuthProbeDetailComponent
|
||||
NoAuthProbeDetailComponent,
|
||||
NoAuthProbeGeneralComponent,
|
||||
];
|
||||
|
||||
@@ -1,11 +1,18 @@
|
||||
noauthprobe_detail
|
||||
<!-- <p-panel *ngIf="probeHost" #content [showHeader]="false" class="block-panel">
|
||||
<of-probe-general [probe]="probeHost.probe" (modified)="modifiedGeneral($event)"></of-probe-general>
|
||||
<of-probe-host [infraHost]="probeHost.infraHost"></of-probe-host>
|
||||
<of-error-message [error]="error$ | async" [closable]="false"></of-error-message>
|
||||
<of-block-progressbar [target]="content" [pending]="pending$ | async"></of-block-progressbar>
|
||||
|
||||
<p-panel *ngIf="noAuthProbe" #content [showHeader]="false" class="block-panel">
|
||||
<of-noauth-probe-general [noAuthProbe]="noAuthProbe"></of-noauth-probe-general>
|
||||
<!-- <<of-infra-host-machine></of-infra-host-machine> -->
|
||||
<of-infra-host-os [infraHostOS]="noAuthProbe.infraHost.infraHostOS"></of-infra-host-os>
|
||||
<of-infra-host-ips [infraHostIPs]="noAuthProbe.infraHost.infraHostIPs" (select)="onNICSelect($event)"></of-infra-host-ips>
|
||||
|
||||
|
||||
<div class="ui-g" dir="rtl">
|
||||
<button class="ui-button-danger ui-button-width-fit" [disabled]="true" type="button" label="Remove this Probe" icon="ui-icon-close"
|
||||
pButton (click)="remove(probeHost)"></button>
|
||||
<button class="ui-button-width-fit" type="button" label="Discovery" icon="ui-icon-search" pButton (click)="discovery.emit(probeHost.id)"></button>
|
||||
<button class="ui-button-width-fit" [disabled]="!selectedNIC" type="button" label="Accept" icon="ui-icon-check" pButton (click)="accept()"></button>
|
||||
<button class="ui-button-danger ui-button-width-fit" [disabled]="!selectedNIC" type="button" label="Deny" icon="ui-icon-close"
|
||||
pButton (click)="deny()"></button>
|
||||
</div>
|
||||
</p-panel> -->
|
||||
</p-panel>
|
||||
|
||||
<p-confirmDialog header="Confirmation" icon="fa ui-icon-warning" width="425"></p-confirmDialog>
|
||||
@@ -4,42 +4,86 @@ import { Store, select } from '@ngrx/store';
|
||||
import { Observable, of, Subscription } from 'rxjs';
|
||||
import { catchError, exhaustMap, map, tap, take } from 'rxjs/operators';
|
||||
import { NoAuthProbeService } from '../service/noauth-probe.service';
|
||||
import { NoAuthProbe, InfraHostIP } from '@overflow/commons-typescript';
|
||||
import { ConfirmationService } from 'primeng/primeng';
|
||||
|
||||
@Component({
|
||||
selector: 'of-noauth-probe-detail',
|
||||
templateUrl: './noauth-probe-detail.component.html',
|
||||
providers: [ConfirmationService]
|
||||
})
|
||||
export class NoAuthProbeDetailComponent implements OnInit {
|
||||
|
||||
// @Input() probeHostID;
|
||||
@Input() id: number;
|
||||
pending$: Observable<boolean>;
|
||||
noAuthProbe: NoAuthProbe;
|
||||
error$: Observable<any>;
|
||||
|
||||
@Output() discovery = new EventEmitter<number>();
|
||||
selectedNIC: InfraHostIP;
|
||||
@Output() back = new EventEmitter();
|
||||
|
||||
constructor(
|
||||
private noAuthProbeService: NoAuthProbeService,
|
||||
private confirmationService: ConfirmationService,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
// this.noAuthProbeService.read(1)
|
||||
// .pipe(
|
||||
// tap(() => {
|
||||
// this.pending$ = of(true);
|
||||
// }),
|
||||
// map((probeHost: ProbeHost) => {
|
||||
// this.probeHost = probeHost;
|
||||
// }),
|
||||
// catchError(error => {
|
||||
// this.error$ = of(error);
|
||||
// return of();
|
||||
// }),
|
||||
// tap(() => {
|
||||
// this.pending$ = of(false);
|
||||
// }),
|
||||
// take(1),
|
||||
// ).subscribe();
|
||||
this.noAuthProbeService.read(this.id)
|
||||
.pipe(
|
||||
tap(() => {
|
||||
this.pending$ = of(true);
|
||||
}),
|
||||
map((noauthProbe: NoAuthProbe) => {
|
||||
noauthProbe.infraHost = JSON.parse(noauthProbe.infraHostMeta);
|
||||
this.noAuthProbe = noauthProbe;
|
||||
}),
|
||||
catchError(error => {
|
||||
this.error$ = of(error);
|
||||
return of();
|
||||
}),
|
||||
tap(() => {
|
||||
this.pending$ = of(false);
|
||||
}),
|
||||
take(1),
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
onNICSelect(infraHostIP: InfraHostIP) {
|
||||
this.selectedNIC = infraHostIP;
|
||||
console.log(this.selectedNIC);
|
||||
}
|
||||
|
||||
accept() {
|
||||
this.confirmationService.confirm({
|
||||
header: 'Are you sure to accept this Probe?',
|
||||
message: 'Start collecting data as a Probe.',
|
||||
icon: 'fa-check',
|
||||
accept: () => {
|
||||
this.noAuthProbeService.acceptNoAuthProbe(this.id, this.selectedNIC.address)
|
||||
.pipe(
|
||||
tap(() => {
|
||||
this.pending$ = of(true);
|
||||
}),
|
||||
map((noauthProbes: NoAuthProbe[]) => {
|
||||
this.back.emit();
|
||||
}),
|
||||
catchError(error => {
|
||||
this.error$ = of(error);
|
||||
return of();
|
||||
}),
|
||||
tap(() => {
|
||||
this.pending$ = of(false);
|
||||
}),
|
||||
take(1),
|
||||
).subscribe();
|
||||
},
|
||||
reject: () => {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deny() {
|
||||
alert('609호에 있는 강아지 deny');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<div class="ui-g">
|
||||
<div class="ui-g-6 ui-nopad">
|
||||
<h3>General</h3>
|
||||
</div>
|
||||
|
||||
<!-- info -->
|
||||
<div class="ui-g ui-bottom-space-10">
|
||||
<div class="ui-g-12 ui-nopad">
|
||||
<p-panel [showHeader]="false">
|
||||
<div *ngIf="noAuthProbe">
|
||||
<div class="ui-g">
|
||||
<div class="ui-g-12 ui-md-6 ui-key-value">
|
||||
<of-key-value [key]="'API Key'" [value]="noAuthProbe.apiKey"></of-key-value>
|
||||
</div>
|
||||
<div class="ui-g-12 ui-md-6 ui-key-value">
|
||||
<of-key-value [key]="'Created at'" [value]="noAuthProbe.createDate | date: 'dd/MM/yyyy'"></of-key-value>
|
||||
</div>
|
||||
<div class="ui-g-12 ui-md-6 ui-key-value">
|
||||
<ng-container [ngSwitch]="noAuthProbe.connectDate">
|
||||
<ng-container *ngSwitchCase="undefined">
|
||||
<of-key-value [key]="'Connection'" [value]="'Not connected.'"></of-key-value>
|
||||
</ng-container>
|
||||
<ng-container *ngSwitchDefault>
|
||||
<of-key-value [key]="'Connection'" [value]="noAuthProbe.connectDate | date: 'dd/MM/yyyy' (noAuthProbe.connectAddress)"></of-key-value>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
<div class="ui-g-12 ui-md-6 ui-key-value">
|
||||
<of-key-value [key]="'Uptime'" [value]="'TODO'"></of-key-value>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</p-panel>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { NoAuthProbe } from '@overflow/commons-typescript';
|
||||
|
||||
@Component({
|
||||
selector: 'of-noauth-probe-general',
|
||||
templateUrl: './noauth-probe-general.component.html',
|
||||
})
|
||||
export class NoAuthProbeGeneralComponent implements OnInit {
|
||||
|
||||
@Input() noAuthProbe: NoAuthProbe;
|
||||
|
||||
constructor(
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { NoAuthProbeLoggerModule } from './noauth-probe-logger.module';
|
||||
import { COMPONENTS } from './component';
|
||||
|
||||
import { SERVICES } from './service';
|
||||
import { InfraModule } from '../infra/infra.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -15,6 +16,7 @@ import { SERVICES } from './service';
|
||||
NoAuthProbeRPCModule,
|
||||
NoAuthProbeLoggerModule,
|
||||
UIModule,
|
||||
InfraModule
|
||||
],
|
||||
declarations: [
|
||||
COMPONENTS,
|
||||
|
||||
@@ -28,4 +28,8 @@ export class NoAuthProbeService {
|
||||
public denyNoauthProbe(id: number): Observable<NoAuthProbe[]> {
|
||||
return this.rpcService.call<NoAuthProbe[]>('NoAuthProbeService.denyNoauthProbe', id);
|
||||
}
|
||||
|
||||
public read(id: number): Observable<NoAuthProbe> {
|
||||
return this.rpcService.call<NoAuthProbe>('NoAuthProbeService.read', id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user