mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-08-28 13:00:15 +03:00
2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{b as V,d as A,e as z,l as $,m as R,p as L,q as G,r as W,s as Y,t as X,u as U,v as q,x as H}from"./chunk-EZEP55N7.js";import{Dc as O,Gb as _,Ib as f,Kb as s,Pa as l,Wb as v,Xc as F,Yb as a,Zb as x,_ as w,_a as M,a as b,bc as k,cc as T,dc as D,ia as C,j as S,ma as p,mf as B,na as u,nf as N,ob as j,pb as m,rb as d,ub as E,vb as I,wb as h,xb as e,ya as g,yb as n,zb as P}from"./chunk-6QUQX5EO.js";function J(o,c){if(o&1){let t=_();e(0,"div",3)(1,"mat-icon",6),a(2,"warning"),n(),e(3,"p",7),a(4,"Ready to inject a network fault?"),n(),e(5,"div",8)(6,"p",9),a(7,"Number of faults to inject"),n(),e(8,"mat-button-toggle-group",10),D("valueChange",function(i){p(t);let y=s();return T(y.faultType,i)||(y.faultType=i),u(i)}),e(9,"mat-button-toggle",11),a(10,"1"),n(),e(11,"mat-button-toggle",11),a(12,"2"),n(),e(13,"mat-button-toggle",11),a(14,"3"),n(),e(15,"mat-button-toggle",11),a(16,"Random"),n()()(),e(17,"p",12),a(18," This will inject a simulated network fault into your topology for troubleshooting practice. Make sure you have saved your current work. "),n(),e(19,"p",12),a(20," The fault injection process will analyze your topology, select an appropriate fault, and apply it automatically. You'll be able to see the details in AI Chat. "),n()()}if(o&2){let t=s();l(8),k("value",t.faultType),l(),h("value",1),l(2),h("value",2),l(2),h("value",3),l(2),h("value","random")}}function K(o,c){if(o&1&&(e(0,"p",17),a(1),n(),e(2,"p",18),a(3,"Agent is working"),n()),o&2){let t=s(2);l(),x(t.currentStep()||"Injecting fault...")}}function Q(o,c){if(o&1&&(e(0,"div",19)(1,"mat-icon",20),a(2),n(),e(3,"div",21)(4,"p",22),a(5),n(),e(6,"p",23),a(7,"Check the AI Chat panel for detailed execution history and tool results."),n()()()),o&2){let t=s(2);v("success",t.completionStatus()==="success")("error",t.completionStatus()==="error")("aborted",t.completionStatus()==="aborted"),l(2),x(t.completionStatus()==="success"?"check_circle":t.completionStatus()==="aborted"?"cancel":"error"),l(3),x(t.completionTitle())}}function Z(o,c){if(o&1&&(e(0,"div",26)(1,"mat-icon"),a(2),n(),e(3,"div",27)(4,"p",28),a(5),n()()()),o&2){let t=c.$implicit,r=s(3);v("success",t.type==="success")("error",t.type==="error"),l(2),x(r.getEventIcon(t.type)),l(3),x(t.message)}}function tt(o,c){if(o&1&&(e(0,"div",16)(1,"h3"),a(2,"Progress"),n(),e(3,"div",24),E(4,Z,6,6,"div",25,j().trackByEventId,!0),n()()),o&2){let t=s(2);l(4),I(t.displayedEvents())}}function et(o,c){if(o&1&&(e(0,"div",13),P(1,"img",14),n(),m(2,K,4,1),m(3,Q,8,8,"div",15),m(4,tt,6,0,"div",16)),o&2){let t=s();v("injecting",t.isInjecting()),l(2),d(t.isInjecting()?2:-1),l(),d(t.completed()&&!t.isInjecting()?3:-1),l(),d(t.isInjecting()&&t.displayedEvents().length>0?4:-1)}}function nt(o,c){if(o&1){let t=_();e(0,"button",29),f("click",function(){p(t);let i=s();return u(i.onCancelConfirm())}),a(1,"Cancel"),n(),e(2,"button",30),f("click",function(){p(t);let i=s();return u(i.onConfirmInject())}),e(3,"mat-icon"),a(4,"bug_report"),n(),e(5,"span"),a(6,"Confirm & Inject"),n()()}}function it(o,c){if(o&1){let t=_();e(0,"button",29),f("click",function(){p(t);let i=s();return u(i.onAbort())}),a(1,"Abort"),n()}}function ot(o,c){if(o&1){let t=_();e(0,"button",29),f("click",function(){p(t);let i=s();return u(i.onCancel())}),a(1,"Cancel"),n(),e(2,"button",30),f("click",function(){p(t);let i=s();return u(i.onInject())}),e(3,"mat-icon"),a(4,"bug_report"),n(),e(5,"span"),a(6,"Inject Fault"),n()()}}function at(o,c){if(o&1){let t=_();e(0,"button",29),f("click",function(){p(t);let i=s();return u(i.onViewDetails())}),e(1,"mat-icon"),a(2,"chat"),n(),e(3,"span"),a(4,"View in AI Chat"),n()(),e(5,"button",31),f("click",function(){p(t);let i=s();return u(i.onClose())}),e(6,"mat-icon"),a(7,"check"),n(),e(8,"span"),a(9,"Done"),n()()}}var bt=(()=>{class o{dialogRef=C($);data=C(R);aiChatService=C(H);controller=this.data.controller;project=this.data.project;isInjecting=g(!1);completed=g(!1);showConfirm=g(!1);faultType=O(1);faceState=g("idle");completionStatus=g("success");completionTitle=g("");currentStep=g("");eventsBuffer=[];displayedEvents=g([]);firstToolCallProcessed=!1;destroy$=new S;static MAX_DISPLAYED_EVENTS=3;ngOnInit(){this.faceState.set("idle")}ngOnDestroy(){this.destroy$.next(),this.destroy$.complete()}onInject(){this.showConfirm.set(!0)}onCancelConfirm(){this.showConfirm.set(!1)}onConfirmInject(){if(this.isInjecting())return;this.showConfirm.set(!1),this.isInjecting.set(!0),this.completed.set(!1),this.faceState.set("injecting"),this.eventsBuffer=[],this.displayedEvents.set([]),this.firstToolCallProcessed=!1;let r=`Inject ${this.faultType()==="random"?"random":String(this.faultType())} network fault(s) for troubleshooting practice`;this.aiChatService.injectFault(this.controller,this.project.project_id,r).pipe(w(this.destroy$)).subscribe({next:i=>{this.handleFaultEvent(i)},error:i=>{this.handleError(i)},complete:()=>{}})}handleFaultEvent(t){if(console.log("Fault injection event:",t),!(t.type==="heartbeat"||t.type==="content"))switch(t.type){case"tool_call":if(t.tool_call&&!this.firstToolCallProcessed){let r=t.tool_call.function.name;this.currentStep.set(`Preparing: ${r}`),this.addEvent({type:"tool_call",message:`Preparing: ${r}`}),this.firstToolCallProcessed=!0}break;case"tool_start":t.tool_name&&(this.currentStep.set(`Executing: ${t.tool_name}`),this.addEvent({type:"info",message:`Executing: ${t.tool_name}`}));break;case"tool_end":t.tool_name&&this.addEvent({type:"success",message:`Completed: ${t.tool_name}`});break;case"error":this.handleError(t);break;case"done":this.isInjecting.set(!1),this.completed.set(!0),this.faceState.set("success"),this.completionStatus.set("success"),this.completionTitle.set("Fault injected successfully!"),this.currentStep.set("");break}}handleError(t){console.error("Fault injection error:",t);let r=t?.error?.message||t?.message||t?.error||"Failed to inject fault";this.addEvent({type:"error",message:"Error injecting fault",details:r}),this.isInjecting.set(!1),this.completed.set(!0),this.faceState.set("error"),this.completionStatus.set("error"),this.completionTitle.set("Failed to inject fault"),this.currentStep.set("")}addEvent(t){let r=b({id:`event_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,timestamp:new Date().toISOString()},t);this.eventsBuffer.push(r),this.eventsBuffer.length>o.MAX_DISPLAYED_EVENTS&&this.eventsBuffer.shift(),this.displayedEvents.set([...this.eventsBuffer])}getEventIcon(t){switch(t){case"info":return"info";case"tool_call":return"build";case"success":return"check_circle";case"error":return"error";default:return"info"}}onAbort(){this.isInjecting.set(!1),this.completed.set(!0),this.faceState.set("aborted"),this.completionStatus.set("aborted"),this.completionTitle.set("Fault injection aborted"),this.currentStep.set(""),this.destroy$.next(),this.addEvent({type:"info",message:"Fault injection aborted by user"})}onViewDetails(){this.dialogRef.close({success:this.completionStatus()==="success",openAIChat:!0})}onCancel(){this.isInjecting()||this.dialogRef.close(null)}onClose(){this.dialogRef.close({success:this.completionStatus()==="success",events:this.displayedEvents()})}trackByEventId(t,r){return r.id}static \u0275fac=function(r){return new(r||o)};static \u0275cmp=M({type:o,selectors:[["app-fault-injection-dialog"]],inputs:{faultType:[1,"faultType"]},outputs:{faultType:"faultTypeChange"},decls:13,vars:6,consts:[["mat-dialog-title","",1,"fault-injection-title"],[1,"fault-injection-icon"],["mat-dialog-content","",1,"fault-injection-content"],[1,"confirm-panel"],["mat-dialog-actions","","align","end"],["mat-button",""],[1,"confirm-panel__icon"],[1,"confirm-panel__title"],[1,"fault-type-selector"],[1,"fault-type-selector__label"],["hideSingleSelectionIndicator","true",1,"fault-type-selector__group",3,"valueChange","value"],[1,"fault-type-btn",3,"value"],[1,"confirm-panel__desc"],[1,"animation-area"],["src","assets/gns3_icon.svg","alt","GNS3",1,"gns3-logo"],[1,"completion-message",3,"success","error","aborted"],[1,"events-section"],[1,"status-main"],[1,"status-sub"],[1,"completion-message"],[1,"completion-icon"],[1,"completion-content"],[1,"completion-title"],[1,"completion-text"],[1,"events-list"],[1,"event",3,"success","error"],[1,"event"],[1,"event-content"],[1,"event-msg"],["mat-button","",3,"click"],["mat-raised-button","","color","warn",3,"click"],["mat-raised-button","","color","primary",3,"click"]],template:function(r,i){r&1&&(e(0,"h2",0)(1,"mat-icon",1),a(2,"bug_report"),n(),e(3,"span"),a(4,"Fault Injection"),n()(),e(5,"div",2),m(6,J,21,5,"div",3),m(7,et,5,5),n(),e(8,"div",4),m(9,nt,7,0),m(10,it,2,0,"button",5),m(11,ot,7,0),m(12,at,10,0),n()),r&2&&(l(6),d(i.showConfirm()?6:-1),l(),d(!i.showConfirm()||i.isInjecting()||i.completed()?7:-1),l(2),d(i.showConfirm()?9:-1),l(),d(i.isInjecting()?10:-1),l(),d(!i.showConfirm()&&!i.isInjecting()&&!i.completed()?11:-1),l(),d(i.completed()&&!i.isInjecting()?12:-1))},dependencies:[F,Y,L,W,G,N,B,z,A,V,q,X,U],styles:[".fault-injection-title[_ngcontent-%COMP%]{display:flex;align-items:center;gap:12px}.fault-injection-icon[_ngcontent-%COMP%]{font-size:24px;width:24px;height:24px;color:var(--mat-sys-error)}.fault-injection-content[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:24px}.confirm-panel[_ngcontent-%COMP%]{display:flex;flex-direction:column;align-items:center;gap:16px;padding:32px 24px;text-align:center}.confirm-panel__icon[_ngcontent-%COMP%]{font-size:48px;width:48px;height:48px;color:var(--mat-sys-error)}.confirm-panel__title[_ngcontent-%COMP%]{font-size:20px;font-weight:500;margin:0;color:var(--mat-sys-on-surface)}.confirm-panel__desc[_ngcontent-%COMP%]{font-size:14px;margin:0;color:var(--mat-sys-on-surface-variant);line-height:1.6;text-align:left;width:100%}.fault-type-selector[_ngcontent-%COMP%]{width:100%;max-width:360px}.fault-type-selector__label[_ngcontent-%COMP%]{font-size:12px;font-weight:500;margin:0 0 8px;text-align:left;color:var(--mat-sys-on-surface-variant)}.fault-type-selector__group[_ngcontent-%COMP%]{display:flex;gap:6px;width:100%;border:none;border-radius:0}.fault-type-btn[_ngcontent-%COMP%]{flex:1;min-width:0;height:36px;font-size:13px;font-weight:500;border:1px solid var(--mat-sys-outline-variant);border-radius:8px;color:var(--mat-sys-on-surface);display:flex;align-items:center;justify-content:center}.fault-type-btn.mat-button-toggle-checked[_ngcontent-%COMP%]{border-color:var(--mat-sys-primary);background:var(--mat-sys-primary-container);color:var(--mat-sys-on-primary-container);font-weight:600}.animation-area[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center;justify-content:center;padding:32px;background:var(--mat-sys-surface-container-low);border-radius:12px;min-height:200px}.animation-area.injecting[_ngcontent-%COMP%]{background:color-mix(in srgb,var(--mat-sys-error-container) 30%,var(--mat-sys-surface-container-low))}.gns3-logo[_ngcontent-%COMP%]{width:120px;height:120px}.status-main[_ngcontent-%COMP%]{font-size:18px;font-weight:500;margin:0;text-align:center;color:var(--mat-sys-on-surface)}.status-sub[_ngcontent-%COMP%]{font-size:14px;margin:0;text-align:center;color:var(--mat-sys-on-surface-variant)}.completion-message[_ngcontent-%COMP%]{display:flex;gap:16px;padding:20px;background:var(--mat-sys-surface-container-low);border-radius:12px;border-left:4px solid var(--mat-sys-primary)}.completion-message.success[_ngcontent-%COMP%]{border-left-color:var(--mat-sys-primary);background:var(--mat-sys-primary-container-low)}.completion-message.error[_ngcontent-%COMP%]{border-left-color:var(--mat-sys-error);background:var(--mat-sys-error-container-low)}.completion-message.aborted[_ngcontent-%COMP%]{border-left-color:var(--mat-sys-outline);background:var(--mat-sys-surface-container-high)}.completion-icon[_ngcontent-%COMP%]{font-size:32px;width:32px;height:32px;flex-shrink:0;color:var(--mat-sys-primary)}.completion-message.error[_ngcontent-%COMP%] .completion-icon[_ngcontent-%COMP%]{color:var(--mat-sys-error)}.completion-message.aborted[_ngcontent-%COMP%] .completion-icon[_ngcontent-%COMP%]{color:var(--mat-sys-on-surface-variant)}.completion-content[_ngcontent-%COMP%]{flex:1}.completion-title[_ngcontent-%COMP%]{font-size:18px;font-weight:500;margin:0 0 8px;color:var(--mat-sys-on-surface)}.completion-text[_ngcontent-%COMP%]{font-size:14px;margin:0;color:var(--mat-sys-on-surface-variant);line-height:1.5}.events-section[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:12px}.events-section[_ngcontent-%COMP%] h3[_ngcontent-%COMP%]{font-size:16px;font-weight:500;margin:0;color:var(--mat-sys-on-surface)}.events-list[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:8px}.event[_ngcontent-%COMP%]{display:flex;gap:12px;padding:12px 16px;background:var(--mat-sys-surface-container-low);border-radius:8px;border-left:3px solid var(--mat-sys-outline)}.event.success[_ngcontent-%COMP%]{border-left-color:var(--mat-sys-primary);background:var(--mat-sys-primary-container-low)}.event.error[_ngcontent-%COMP%]{border-left-color:var(--mat-sys-error);background:var(--mat-sys-error-container-low)}.event[_ngcontent-%COMP%] mat-icon[_ngcontent-%COMP%]{font-size:20px;width:20px;height:20px;flex-shrink:0;color:var(--mat-sys-on-surface-variant)}.event-content[_ngcontent-%COMP%]{flex:1;min-width:0}.event-msg[_ngcontent-%COMP%]{font-size:14px;font-weight:500;margin:0 0 4px;color:var(--mat-sys-on-surface);word-wrap:break-word}.event-details[_ngcontent-%COMP%]{font-size:12px;margin:0;color:var(--mat-sys-on-surface-variant);word-wrap:break-word}"],changeDetection:0})}return o})();export{bt as FaultInjectionDialogComponent};
|