(("undefined"!==typeof self?self:this)["webpackChunkharvester_1_10_0_dev"]=("undefined"!==typeof self?self:this)["webpackChunkharvester_1_10_0_dev"]||[]).push([[895],{40505:function(e,t,r){"use strict";r.d(t,{A:function(){return j}});var a=r(9274);const n={class:"graph-options mb-10"},o={class:"info"};function i(e,t,r,i,l,s){const c=(0,a.resolveComponent)("DashboardOptions"),d=(0,a.resolveComponent)("GrafanaDashboard");return(0,a.openBlock)(),(0,a.createElementBlock)("div",{class:(0,a.normalizeClass)(["dashboard-metrics",!r.hasSummaryAndDetail&&"external-link-pull-left"])},[(0,a.createElementVNode)("div",n,[(0,a.createVNode)(c,{value:l.graphOptions,"onUpdate:value":t[0]||(t[0]=e=>l.graphOptions=e),"has-summary-and-detail":r.hasSummaryAndDetail},null,8,["value","has-summary-and-detail"])]),(0,a.createElementVNode)("div",o,[(0,a.renderSlot)(e.$slots,"default",{},void 0,!0)]),(0,a.createElementVNode)("div",{class:"graphs",style:(0,a.normalizeStyle)({height:r.graphHeight})},["detail"===l.graphOptions.type?((0,a.openBlock)(),(0,a.createBlock)(d,{key:"'detail'",class:"col span-12 detail","background-color":s.graphBackgroundColor,theme:s.theme,"refresh-rate":l.graphOptions.refreshRate,range:l.graphOptions.range,url:r.detailUrl,vars:r.vars,"modify-prefix":r.modifyPrefix},null,8,["background-color","theme","refresh-rate","range","url","vars","modify-prefix"])):((0,a.openBlock)(),(0,a.createBlock)(d,{key:"'summary'",class:"col span-12 summary","background-color":s.graphBackgroundColor,theme:s.theme,"refresh-rate":l.graphOptions.refreshRate,range:l.graphOptions.range,url:r.summaryUrl,vars:r.vars,"modify-prefix":r.modifyPrefix},null,8,["background-color","theme","refresh-rate","range","url","vars","modify-prefix"]))],4)],2)}const l={class:"graph-options"},s={key:0},c={key:1},d={class:"range-refresh"};function u(e,t,r,n,o,i){const u=(0,a.resolveComponent)("ButtonGroup"),h=(0,a.resolveComponent)("LabeledSelect");return(0,a.openBlock)(),(0,a.createElementBlock)("div",l,[r.hasSummaryAndDetail?((0,a.openBlock)(),(0,a.createElementBlock)("div",s,[(0,a.createVNode)(u,{value:r.value.type,"onUpdate:value":t[0]||(t[0]=e=>r.value.type=e),options:o.detailSummaryOptions},null,8,["value","options"])])):((0,a.openBlock)(),(0,a.createElementBlock)("div",c,[...t[3]||(t[3]=[(0,a.createElementVNode)("div",null,null,-1)])])),(0,a.createElementVNode)("div",d,[(0,a.createVNode)(h,{value:r.value.range,"onUpdate:value":t[1]||(t[1]=e=>r.value.range=e),options:o.rangeOptions,label:e.t("graphOptions.range")},null,8,["value","options","label"]),(0,a.createVNode)(h,{value:r.value.refreshRate,"onUpdate:value":t[2]||(t[2]=e=>r.value.refreshRate=e),options:o.refreshOptions,label:e.t("graphOptions.refresh")},null,8,["value","options","label"])])])}var h=r(25375),p=r(62065),f={components:{ButtonGroup:h.A,LabeledSelect:p.A},props:{value:{type:Object,required:!0},hasSummaryAndDetail:{type:Boolean,default:!0}},data(){return{range:null,rangeOptions:[{label:this.t("generic.units.time.5m"),value:"5m"},{label:this.t("generic.units.time.1h"),value:"1h"},{label:this.t("generic.units.time.6h"),value:"6h"},{label:this.t("generic.units.time.1d"),value:"1d"},{label:this.t("generic.units.time.7d"),value:"7d"},{label:this.t("generic.units.time.30d"),value:"30d"}],refreshOptions:[{label:this.t("generic.units.time.5s"),value:"5s"},{label:this.t("generic.units.time.10s"),value:"10s"},{label:this.t("generic.units.time.30s"),value:"30s"},{label:this.t("generic.units.time.1m"),value:"1m"},{label:this.t("generic.units.time.5m"),value:"5m"},{label:this.t("generic.units.time.15m"),value:"15m"},{label:this.t("generic.units.time.30m"),value:"30m"},{label:this.t("generic.units.time.1h"),value:"1h"},{label:this.t("generic.units.time.2h"),value:"2h"},{label:this.t("generic.units.time.1d"),value:"1d"}],detailSummaryOptions:[{label:this.t("graphOptions.detail"),value:"detail"},{label:this.t("graphOptions.summary"),value:"summary"}]}}},m=(r(76142),r(47433));const g=(0,m.A)(f,[["render",u],["__scopeId","data-v-f155ff46"]]);var v=g;const y={class:"grafana-graph"},b={class:"text-center"},k=["src"],w={key:1},x={key:2,class:"external-link"},B=["href"];function _(e,t,r,n,o,i){const l=(0,a.resolveComponent)("Banner"),s=(0,a.resolveComponent)("Loading");return(0,a.openBlock)(),(0,a.createElementBlock)("div",y,[o.error?((0,a.openBlock)(),(0,a.createBlock)(l,{key:0,color:"error",style:{"z-index":"1000"}},{default:(0,a.withCtx)(()=>[(0,a.createElementVNode)("div",b,[(0,a.createTextVNode)((0,a.toDisplayString)(e.t("grafanaDashboard.failedToLoad"))+" ",1),(0,a.createElementVNode)("a",{href:"#",onClick:t[0]||(t[0]=(...e)=>i.reload&&i.reload(...e))},(0,a.toDisplayString)(e.t("grafanaDashboard.reload")),1)])]),_:1})):(0,a.createCommentVNode)("",!0),(0,a.withDirectives)((0,a.createElementVNode)("iframe",{ref:"frame",class:(0,a.normalizeClass)({loading:o.loading,frame:!0}),src:i.currentUrl,frameborder:"0",scrolling:"no"},null,10,k),[[a.vShow,!o.error]]),o.loading?((0,a.openBlock)(),(0,a.createElementBlock)("div",w,[(0,a.createVNode)(s)])):(0,a.createCommentVNode)("",!0),o.loading||o.error?(0,a.createCommentVNode)("",!0):((0,a.openBlock)(),(0,a.createElementBlock)("div",x,[(0,a.createElementVNode)("a",{href:i.grafanaUrl,target:"_blank",rel:"noopener nofollow"},[(0,a.createTextVNode)((0,a.toDisplayString)(e.t("grafanaDashboard.grafana"))+" ",1),t[1]||(t[1]=(0,a.createElementVNode)("i",{class:"icon icon-external-link"},null,-1))],8,B)]))])}var S=r(87619),$=r(9980),C=r(97348),O=r(83416),E={components:{Banner:$.l,Loading:S.A},props:{url:{type:String,required:!0},vars:{type:Object,default:()=>({})},range:{type:String,default:null},refreshRate:{type:String,default:null},modifyPrefix:{type:Boolean,default:!0},backgroundColor:{type:String,default:"#1b1c21"},theme:{type:String,default:"dark"}},async fetch(){const e=this.$store.getters["currentProduct"].inStore;this.monitoringVersion=await(0,O.Xg)(this.$store,e)},data(){return{loading:!1,error:!1,interval:null,errorTimer:null,monitoringVersion:""}},computed:{currentUrl(){return this.computeUrl()},grafanaUrl(){return this.currentUrl.replace("&kiosk","")},graphWindow(){return this.$refs.frame?.contentWindow},graphHistory(){return this.graphWindow?.history},graphDocument(){return this.graphWindow?.document}},watch:{currentUrl(e){this.graphHistory&&this.graphWindow?.angular&&this.graphWindow.location.replace(e)},error(e){e?this.errorTimer=setInterval(()=>{this.reload()},45e3):(clearInterval(this.errorTimer),this.errorTimer=null)}},mounted(){this.$refs.frame.onload=this.inject,this.poll()},beforeUnmount(){this.interval&&clearInterval(this.interval),this.errorTimer&&clearInterval(this.errorTimer)},methods:{poll(){this.interval&&(clearInterval(this.interval),this.interval=null),this.interval=setInterval(()=>{try{const e=this.$refs.frame?.contentWindow,t=e.document.querySelectorAll('[class$="alert-error'),r=e.document.querySelectorAll('[class$="panel-info-corner--error'),a=e.document.querySelectorAll('[class$="panel-in-fullscreen'),n=e.document.querySelectorAll('[class$="panel-container'),o=t.length>0||r.length>0,i=a.length>0||n.length>0,l=e.document.getElementsByTagName("pre"),s=l.length>0?l[0].innerText:"",c=s.includes('"status": "Failure"');if(o)throw new Error("An error was detected in the iframe");this["loading"]=!i,this["error"]=c}catch(e){this["error"]=!0,this["loading"]=!1,clearInterval(this.interval),this.interval=null}},100)},computeFromTo(){return{from:`now-${this.range}`,to:"now"}},computeUrl(){const e=this.url,t=this.$store.getters["currentCluster"].id,r=this.computeParams();return(0,C.l9)(this.monitoringVersion,e,t,r,this.modifyPrefix)},computeParams(){const e={},t=this.computeFromTo();return t.from&&(e.from=t.from),t.to&&(e.to=t.to),this.refreshRate&&(e.refresh=this.refreshRate),Object.keys(this.vars).length>0&&Object.entries(this.vars).forEach(t=>{const r=`var-${t[0]}`;e[r]=t[1]}),e.theme=this.theme,e},reload(e){e&&e.preventDefault(),this.$refs.frame.contentWindow.location.reload(),this.poll()},injectCss(){const e=document.createElement("style");e.innerHTML=`\n body .grafana-app .dashboard-content {\n background: ${this.backgroundColor};\n padding: 0;\n }\n\n body .grafana-app .layout {\n background: ${this.backgroundColor};\n }\n\n\n body .grafana-app .dashboard-content .panel-container {\n background-color: initial;\n border: none;\n }\n\n body .grafana-app .dashboard-content .panel-wrapper {\n height: 100%;\n }\n\n body .grafana-app .panel-menu-container {\n display: none;\n }\n\n body .grafana-app .panel-title {\n cursor: default;\n }\n\n body .grafana-app .panel-title .panel-title-text div {\n display: none;\n }\n `;const t=this.$refs.frame?.contentWindow,r=t?.document;r.head&&r.head.appendChild(e)},inject(){this.injectCss()}}};r(9895);const N=(0,m.A)(E,[["render",_],["__scopeId","data-v-1e07bf92"]]);var I=N,V=r(65359),A={components:{DashboardOptions:v,GrafanaDashboard:I},props:{detailUrl:{type:String,required:!0},summaryUrl:{type:String,default:""},vars:{type:Object,default:()=>({})},graphHeight:{type:String,required:!0},hasSummaryAndDetail:{type:Boolean,default:!0},modifyPrefix:{type:Boolean,default:!0}},data(){return{graphOptions:{range:"5m",refreshRate:"30s",type:"detail"}}},computed:{...(0,V.L8)(["prefs/theme"]),graphBackgroundColor(){return"dark"===this.theme?"#2e3035":"#f3f4f9"},theme(){return this["prefs/theme"]}}};r(35493);const P=(0,m.A)(A,[["render",i],["__scopeId","data-v-5cdbd67f"]]);var j=P},60037:function(e,t,r){"use strict";r.r(t);var a=r(36758),n=r.n(a),o=r(40935),i=r.n(o),l=i()(n());l.push([e.id,".dashboard-metrics[data-v-5cdbd67f] .external-link{position:absolute;left:200px;top:-45px}.dashboard-metrics[data-v-5cdbd67f] .frame{top:0}.dashboard-metrics.external-link-pull-left[data-v-5cdbd67f] .external-link{position:absolute;left:10px;top:-47px}",""]),t["default"]=l},80097:function(e,t,r){"use strict";r.r(t);var a=r(36758),n=r.n(a),o=r(40935),i=r.n(o),l=i()(n());l.push([e.id,".graph-options[data-v-f155ff46],.graph-options .range-refresh[data-v-f155ff46]{display:flex;flex-direction:row;justify-content:flex-end}.graph-options[data-v-f155ff46]{justify-content:space-between;align-items:center}.graph-options .labeled-select[data-v-f155ff46]{width:100px;margin-left:10px}",""]),t["default"]=l},32615:function(e,t,r){"use strict";r.r(t);var a=r(36758),n=r.n(a),o=r(40935),i=r.n(o),l=i()(n());l.push([e.id,".grafana-graph[data-v-1e07bf92]{position:relative;min-height:100%;min-width:100%}.grafana-graph[data-v-1e07bf92] .content{position:relative;display:flex;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;padding:0}.grafana-graph[data-v-1e07bf92] .overlay{position:static;background-color:initial}.grafana-graph iframe[data-v-1e07bf92]{position:absolute;left:0;right:0;top:20px;bottom:0;width:100%;height:100%;overflow:hidden}.grafana-graph iframe.loading[data-v-1e07bf92]{visibility:hidden}",""]),t["default"]=l},52799:function(e,t,r){"use strict";r.d(t,{A:function(){return d}});var a=r(4364);function n(e,t,r){return(t=o(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e){var t=i(e,"string");return"symbol"==typeof t?t:t+""}function i(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}class l{constructor(e,t,r=Number.POSITIVE_INFINITY){n(this,"fn",void 0),n(this,"pollRateMs",void 0),n(this,"maxRetries",void 0),n(this,"intervalId",void 0),n(this,"tryCount",0),this.fn=e||(()=>{}),this.pollRateMs=t,this.maxRetries=r}start(){this.stop(),this._intervalMethod(),this.intervalId=setInterval(()=>this._intervalMethod(),this.pollRateMs)}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=void 0)}async _intervalMethod(){try{await this.fn(),this.tryCount=0}catch(e){a.error("Error encountered while polling",e),++this.tryCount>=this.maxRetries&&this.stop()}}}const s=3e4,c=2;var d={data(){return{metricPoller:null}},mounted(){this.metricPoller=new l(this.loadMetrics,s,c),this.metricPoller.start()},beforeUnmount(){this.metricPoller.stop()}}},97348:function(e,t,r){"use strict";r.d(t,{Qr:function(){return c},l9:function(){return l}});var a=r(83416),n=r(50667);const o=["100.2.0+up40.1.2","102.0.0+up40.1.2"];function i(e,t){return o.includes(e)?`/k8s/clusters/${t}`:"local"===t?"":`/k8s/clusters/${t}`}function l(e,t,r,a,o=!0){const l=(0,n.qg)(t);let s=o?`${i(e,r)}${l.path}`:l.path;return l.query.viewPanel&&(s=(0,n.R_)(s,"viewPanel",l.query.viewPanel)),s=(0,n.R_)(s,"orgId",l.query.orgId),s=(0,n.R_)(s,"kiosk",null),s=(0,n.R_)(s,"_dash.hideTimePicker","true"),Object.entries(a).forEach(e=>{s=(0,n.R_)(s,e[0],e[1])}),s}async function s(e,t,r,o,l="cluster",s=null){if(!(0,a.de)(t.getters))return!1;const c=(0,n.qg)(o);let d=`${i(e,r)}/api/v1/namespaces/cattle-monitoring-system/services/http:rancher-monitoring-grafana:80/proxy/`,u="http:rancher-monitoring-grafana:80/proxy/";s&&(d=`${i(e,r)}/api/v1/namespaces/cattle-project-${s}-monitoring/services/http:cattle-project-${s}-monitoring-grafana:80/proxy/`,u=`http:cattle-project-${s}-monitoring-grafana:80/proxy/`);const h=c.path.split(u)[1],p=h.split("/")[1],f=`${d}api/dashboards/uid/${p}`;try{return await t.dispatch(`${l}/request`,{url:f,redirectUnauthorized:!1}),!0}catch(m){return!1}}async function c(e,t,r,n="cluster",o=null){const i=o?"":await(0,a.Xg)(e,n),l=r.map(r=>s(i,e,t,r,n,o));return(await Promise.all(l)).every(e=>e)}},35493:function(e,t,r){var a=r(60037);a.__esModule&&(a=a.default),"string"===typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals);var n=r(74825).A;n("5bc3db34",a,!0,{sourceMap:!1,shadowMode:!1})},76142:function(e,t,r){var a=r(80097);a.__esModule&&(a=a.default),"string"===typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals);var n=r(74825).A;n("0fc0e1d4",a,!0,{sourceMap:!1,shadowMode:!1})},9895:function(e,t,r){var a=r(32615);a.__esModule&&(a=a.default),"string"===typeof a&&(a=[[e.id,a,""]]),a.locals&&(e.exports=a.locals);var n=r(74825).A;n("09508dc2",a,!0,{sourceMap:!1,shadowMode:!1})}}]); //# sourceMappingURL=harvester-1.10.0-dev.umd.min.895.js.map