D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
usr
/
share
/
grafana
/
public
/
build
/
Filename :
3069.c3a514d280a9f89eecde.js
back
Copy
"use strict";(self.webpackChunkgrafana=self.webpackChunkgrafana||[]).push([[3069],{31279:(B,P,s)=>{s.d(P,{b:()=>u});var E=s(27702),l=s(69966),p=s(75340);class u{constructor(a){this._subject=new l.x,this._state=a}useState(){return g(this)}get state(){return this._state}setState(a){this._state={...this._state,...a},this._subject.next(this._state)}subscribeToState(a){return this._subject.subscribe(a)}}function g(h){const a=(0,p.N)();return(0,E.useEffect)(()=>{const v=h.subscribeToState({next:a});return()=>v.unsubscribe()},[h,a]),h.state}},523:(B,P,s)=>{s.d(P,{W:()=>S});var E=s(94469),l=s(3935),p=s(26129),u=s(80734),g=s(5933),h=s(42844),a=s(27702),v=s(7662),M=s(38192),x=s(66310),T=s(29372),w=s(44644),m=s(66670),C=s(75443),D=s(80557),N=s(78474);const I=a.memo(({dashboard:c})=>{const{actions:r=[],isEditing:d,viewPanelKey:y,isDirty:e,uid:t}=c.useState(),n=(r??[]).map(o=>a.createElement(o.Component,{key:o.state.key,model:o}));return t&&n.push(a.createElement(N.u,{key:"button-scenes",tooltip:"View as dashboard",icon:"apps",onClick:()=>p.E1.push(`/d/${t}`)})),n.push(a.createElement(D.M,{leftActionsSeparator:!0,key:"separator"})),y?(n.push(a.createElement(m.zx,{onClick:()=>p.E1.partial({viewPanel:null}),tooltip:"",key:"back",variant:"primary",fill:"text"},"Back to dashboard")),a.createElement(C.A,{actions:n})):(d?(n.push(a.createElement(m.zx,{onClick:c.onEnterEditMode,tooltip:"Save as copy",fill:"text",key:"save-as"},"Save as")),n.push(a.createElement(m.zx,{onClick:c.onDiscard,tooltip:"Save changes",fill:"text",key:"discard",variant:"destructive"},"Discard")),n.push(a.createElement(m.zx,{onClick:c.onEnterEditMode,tooltip:"Save changes",key:"save",disabled:!e},"Save"))):n.push(a.createElement(m.zx,{onClick:c.onEnterEditMode,tooltip:"Enter edit mode",key:"edit",variant:"primary",icon:"pen",fill:"text"},"Edit")),a.createElement(C.A,{actions:n}))});I.displayName="NavToolbarActions";var b=s(14574);const A=a.memo(({panel:c,dashboard:r})=>a.createElement(b.d,{title:`Inspect: ${c.state.title}`,scrollableContent:!0,onClose:r.onCloseInspectDrawer,size:"md"},"Magic content"));A.displayName="ScenePanelInspector";function U({model:c}){const{body:r,controls:d,inspectPanelKey:y,viewPanelKey:e}=c.useState(),t=(0,x.wW)(V),n=c.findPanel(y),o=c.findPanel(e),i=(0,v.TH)(),f=c.getPageNav(i);return a.createElement(w.T,{navId:"scenes",pageNav:f,layout:M.Q.Custom},a.createElement(T.$,{autoHeightMin:"100%"},a.createElement("div",{className:t.canvasContent},a.createElement(I,{dashboard:c}),d&&a.createElement("div",{className:t.controls},d.map(O=>a.createElement(O.Component,{key:O.state.key,model:O}))),o?a.createElement("div",{className:t.viewPanel},a.createElement(o.Component,{model:o})):a.createElement("div",{className:t.body},a.createElement(r.Component,{model:r})))),n&&a.createElement(A,{panel:n,dashboard:c}))}function V(c){return{canvasContent:(0,h.css)({label:"canvas-content",display:"flex",flexDirection:"column",padding:c.spacing(0,2),flexBasis:"100%",flexGrow:1}),body:(0,h.css)({label:"body",flexGrow:1,display:"flex",gap:"8px"}),viewPanel:(0,h.css)({display:"flex",position:"relative",flexGrow:1,marginBottom:c.spacing(2)}),controls:(0,h.css)({display:"flex",flexWrap:"wrap",alignItems:"center",gap:c.spacing(1),position:"sticky",top:0,background:c.colors.background.canvas,zIndex:1,padding:c.spacing(2,0)})}}class S extends u.wx{constructor(r){super(r),this._urlSync=new K(this),this.onChildStateChanged=d=>{d.payload.changedObject instanceof u.bO&&this.setState({isDirty:!0})},this.onEnterEditMode=()=>{this.setState({isEditing:!0})},this.onDiscard=()=>{this.setState({isEditing:!1})},this.onCloseInspectDrawer=()=>{p.E1.partial({inspect:null})},this.addActivationHandler(()=>()=>{(0,u.oo)().cleanUp(this)}),this.subscribeToEvent(u.QI,this.onChildStateChanged)}findPanel(r){if(!r)return null;const d=u.ep.findObject(this,y=>y.state.key===r);return d instanceof u.Z?d:null}initUrlSync(){(0,u.oo)().initSync(this)}getPageNav(r){let d={text:this.state.title,url:E.u.getUrlForPartial(r,{viewPanel:null,inspect:null})};return this.state.viewPanelKey&&(d={text:"View panel",parentItem:d}),d}}S.Component=U;class K{constructor(r){this._scene=r}getKeys(){return["inspect","viewPanel"]}getUrlState(){const r=this._scene.state;return{inspect:r.inspectPanelKey,viewPanel:r.viewPanelKey}}updateFromUrl(r){const{inspectPanelKey:d,viewPanelKey:y}=this._scene.state,e={};if(typeof r.inspect=="string"){if(!this._scene.findPanel(r.inspect)){g.Z.emit(l.SI.alertError,["Panel not found"]),p.E1.partial({inspect:null});return}e.inspectPanelKey=r.inspect}else d&&(e.inspectPanelKey=void 0);if(typeof r.viewPanel=="string"){if(!this._scene.findPanel(r.viewPanel)){g.Z.emit(l.SI.alertError,["Panel not found"]),p.E1.partial({viewPanel:null});return}e.viewPanelKey=r.viewPanel}else y&&(e.viewPanelKey=void 0);Object.keys(e).length>0&&this._scene.setState(e)}}},53069:(B,P,s)=>{s.d(P,{Yz:()=>b,bC:()=>K});var E=s(34667),l=s(80734),p=s(31279),u=s(46823),g=s(73170),h=s(5264),a=s(523),v=s(94469),M=s(26129),x=s(65322);function T(e){const t=e.parent,n=M.E1.getLocation(),o=[];o.push({text:(0,x.t)("panel.header-menu.view","View"),iconClassName:"eye",shortcut:"v",href:v.u.getUrlForPartial(n,{viewPanel:t.state.key})}),o.push({text:(0,x.t)("panel.header-menu.inspect","Inspect"),iconClassName:"info-circle",shortcut:"i",href:v.u.getUrlForPartial(n,{inspect:t.state.key})}),e.setState({items:o})}function w(e){return`panel-${e}`}function m(e){const t=[];return e.forEachChild(n=>{t.push(m(n))}),t.push(e.activate()),()=>{for(const n of t)n()}}class C extends l.wx{constructor(t){super(t),this.addActivationHandler(()=>(this._subscribeToSource(),()=>{this._querySub&&this._querySub.unsubscribe(),this._sourceDataDeactivationHandler&&this._sourceDataDeactivationHandler()}))}_subscribeToSource(){const{query:t}=this.state;if(this._querySub&&this._querySub.unsubscribe(),!t.panelId)return;const n=w(t.panelId),o=D(this.getRoot(),f=>f.state.key===n);if(!o){console.log("Shared dashboard query refers to a panel that does not exist in the scene");return}let i=o.state.$data;if(!i){console.log("No source data found for shared dashboard query");return}if(this._sourceDataDeactivationHandler=i.activate(),i instanceof l.bM&&!t.withTransforms){if(!i.state.$data)throw new Error("No source inner query runner found in data transformer");i=i.state.$data}this._querySub=i.subscribeToState(f=>this.setState({data:f.data})),this.setState({data:i.state.data})}}function D(e,t){if(t(e))return e;let n=null;return e.forEachChild(o=>{let i=D(o,t);i&&(n=i)}),n}class N extends p.b{constructor(){super(...arguments),this.cache={}}async loadAndInit(t){try{const n=await this.loadScene(t);n.initUrlSync(),this.cache[t]=n,this.setState({dashboard:n,isLoading:!1})}catch(n){this.setState({isLoading:!1,loadError:String(n)})}}async loadScene(t){const n=this.cache[t];if(n)return n;this.setState({isLoading:!0});const o=await u.pD.loadDashboard("db","",t);if(o.dashboard){const i=new g.f(o.dashboard,o.meta,{autoMigrateOldPanels:!0});return b(i)}throw new Error("Dashboard not found")}clearState(){this.setState({dashboard:void 0,loadError:void 0,isLoading:!1})}}function I(e){const t=[];let n=null,o=[];for(const i of e)if(i.type==="row")n?n.id!==i.id&&(t.push(new l.I_({title:n.title,y:n.gridPos.y,children:o})),n=i,o=[]):i.collapsed?t.push(new l.I_({title:i.title,isCollapsed:!0,y:i.gridPos.y,children:i.panels?i.panels.map(U):[]})):n=i;else{const f=U(i);n?o.push(f):t.push(f)}return n&&t.push(new l.I_({title:n.title,y:n.gridPos.y,children:o})),t}function b(e){let t;if(e.templating?.list?.length){const o=e.templating.list.map(i=>{try{return A(i)}catch(f){return console.error(f),null}}).filter(i=>!!i);t=new l.hT({variables:o})}const n=[new l.dn({}),new l.o$,new l.n7({}),new l.vf({refresh:e.refresh,intervals:e.timepicker.refresh_intervals})];return new a.W({title:e.title,uid:e.uid,body:new l.Qh({children:I(e.panels)}),$timeRange:new l.gg(e.time),$variables:t,controls:n})}function A(e){const t={name:e.name,label:e.label};if(c(e))return new l.eO({...t,value:e.current.value,text:e.current.text,description:e.description,query:e.query,isMulti:e.multi,allValue:e.allValue||void 0,includeAll:e.includeAll,defaultToAll:!!e.includeAll,skipUrlSync:e.skipUrlSync,hide:e.hide});if(r(e))return new l.$1({...t,value:e.current.value,text:e.current.text,description:e.description,query:e.query,datasource:e.datasource,sort:e.sort,refresh:e.refresh,regex:e.regex,allValue:e.allValue||void 0,includeAll:e.includeAll,defaultToAll:!!e.includeAll,isMulti:e.multi,skipUrlSync:e.skipUrlSync,hide:e.hide});if(d(e))return new l.l3({...t,value:e.current.value,text:e.current.text,description:e.description,regex:e.regex,pluginId:e.query,allValue:e.allValue||void 0,includeAll:e.includeAll,defaultToAll:!!e.includeAll,skipUrlSync:e.skipUrlSync,isMulti:e.multi,hide:e.hide});if(y(e))return new l.M6({...t,description:e.description,value:e.query,skipUrlSync:e.skipUrlSync,hide:e.hide});throw new Error(`Scenes: Unsupported variable type ${e.type}`)}function U(e){return new l.bO({x:e.gridPos.x,y:e.gridPos.y,width:e.gridPos.w,height:e.gridPos.h,body:new l.Z({key:w(e.id),title:e.title,pluginId:e.type,options:e.options??{},fieldConfig:e.fieldConfig,pluginVersion:e.pluginVersion,displayMode:e.transparent?"transparent":void 0,hoverHeader:!e.title&&!e.timeFrom&&!e.timeShift,$data:V(e),menu:new l.e0({$behaviors:[T]})})})}function V(e){if(!e.targets?.length||E.config.panels[e.type]?.skipDataQuery)return;let t;return e.datasource?.uid===h.o?t=new C({query:e.targets[0]}):t=new l.uq({queries:e.targets,maxDataPoints:e.maxDataPoints??void 0}),e.transformations?.length&&(t=new l.bM({$data:t,transformations:e.transformations})),t}let S=null;function K(){return S||(S=new N({})),S}const c=e=>e.type==="custom",r=e=>e.type==="query",d=e=>e.type==="datasource",y=e=>e.type==="constant"}}]); //# sourceMappingURL=3069.c3a514d280a9f89eecde.js.map