Reset link support

This commit is contained in:
piotrpekala7 2020-08-10 14:30:11 +02:00
parent 72418a1a9f
commit bf4f2dcdb7
6 changed files with 37 additions and 1 deletions

View File

@ -278,6 +278,7 @@ import { DataSourceFilter } from './filters/dataSourceFilter';
import { ChangeHostnameActionComponent } from './components/project-map/context-menu/actions/change-hostname/change-hostname-action.component';
import { ChangeHostnameDialogComponent } from './components/project-map/change-hostname-dialog/change-hostname-dialog.component';
import { ApplianceInfoDialogComponent } from './components/project-map/new-template-dialog/appliance-info-dialog/appliance-info-dialog.component';
import { ResetLinkActionComponent } from './components/project-map/context-menu/actions/reset-link/reset-link-action.component';
@NgModule({
declarations: [
@ -309,6 +310,7 @@ import { ApplianceInfoDialogComponent } from './components/project-map/new-templ
StopCaptureActionComponent,
ResumeLinkActionComponent,
SuspendLinkActionComponent,
ResetLinkActionComponent,
ProjectMapShortcutsComponent,
SettingsComponent,
PreferencesComponent,

View File

@ -5,7 +5,7 @@ import { SentryErrorHandler } from './sentry-error-handler';
@Injectable()
export class ToasterErrorHandler extends SentryErrorHandler {
handleError(err: any): void {
if (err.error && err.error.status && !(err.error.status === 403 || err.error.status === 404)) {
if (err.error && err.error.status && !(err.error.status === 403 || err.error.status === 404 || err.error.status === 405)) {
super.handleError(err);
}

View File

@ -0,0 +1,4 @@
<button mat-menu-item (click)="resetLink()">
<mat-icon>settings_backup_restore</mat-icon>
<span>Reset link</span>
</button>

View File

@ -0,0 +1,21 @@
import { Component, Input } from '@angular/core';
import { Server } from '../../../../../models/server';
import { Link } from '../../../../../models/link';
import { LinkService } from '../../../../../services/link.service';
@Component({
selector: 'app-reset-link-action',
templateUrl: './reset-link-action.component.html'
})
export class ResetLinkActionComponent {
@Input() server: Server;
@Input() link: Link;
constructor(
private linkService: LinkService
) {}
resetLink() {
this.linkService.resetLink(this.server, this.link).subscribe(() => {});
}
}

View File

@ -141,6 +141,11 @@
[server]="server"
[link]="links[0]"
></app-suspend-link-action>
<app-reset-link-action
*ngIf="!projectService.isReadOnly(project) && drawings.length===0 && nodes.length===0 && links.length===1 && linkNodes.length === 0"
[server]="server"
[link]="links[0]"
></app-reset-link-action>
<app-lock-action
*ngIf="!projectService.isReadOnly(project) && (drawings.length>0 || nodes.length>0)"
[server]="server"

View File

@ -92,6 +92,10 @@ export class LinkService {
return this.httpServer.post(server, `/projects/${link.project_id}/links/${link.link_id}/stop_capture`, {});
}
resetLink(server: Server, link: Link) {
return this.httpServer.post(server, `/projects/${link.project_id}/links/${link.link_id}/reset`, {});
}
streamPcap(server: Server, link: Link) {
return this.httpServer.get(server, `/projects/${link.project_id}/links/${link.link_id}/pcap`)
}