UNPKG

graphdb-workbench

Version:
2 lines 5.38 kB
export const __webpack_esm_id__=72720;export const __webpack_esm_ids__=[8642,72720];export const __webpack_esm_modules__={8642:(t,e,a)=>{a.d(e,{h:()=>r});var s=a(18301);class r{static get DEFAULT_MULTIPLIER(){return 1.2}static get MAXIMUM_DIVISIONS(){return 10}static get COLORS(){return[r.cssVar("--gw-secondary-base"),r.cssVar("--gw-primary-base"),r.cssVar("--gw-tertiary-base"),r.cssVar("--gw-neutral-base")]}static get AREA_BAR_OPACITY(){return.5}static cssVar(t){return getComputedStyle(document.documentElement).getPropertyValue(t)}constructor(t,e,a,s){this.filter=s,this.disableRangeUpdate=e,this.disableOldDataRemoval=a,this.translateService=t,this.refreshHandlers=[],this.initialChartSetup()}registerRefreshHandler(t){this.refreshHandlers.push(t)}unregisterRefreshHandler(t){const e=this.refreshHandlers.indexOf(t);e>-1&&this.refreshHandlers.splice(e,1)}initialChartSetup(t=!0){this.range=150,this.chartOptions=this.getDefaultChartOptions(this.translateService),t&&(this.dataHolder=this.createDataHolder(),this.chartOptions.series=this.dataHolder,this.firstLoad=!0),this.chartSetup(this.chartOptions)}refresh(t=!1){t||(this.chartSetup(this.chartOptions),this.updateRange(this.dataHolder)),this.refreshHandlers.forEach(t=>t(this.chartOptions))}setSubTitle(t,e=0){this.chartOptions.title.show=!0;let a="";t.forEach((s,r)=>{if(Array.isArray(s.value)&&!s.value.length)return;const i=Array.isArray(s.value)?s.value.join("/"):s.value;a+=`{a|${s.label}}`,void 0!==i&&(a+=`{b|${i}}`),r+1<t.length&&(a+=e>0&&(r+1)%e===0?"\n":"{a| · }")}),this.chartOptions.title.text=a}chartSetup(t){}createDataHolder(){throw new Error("Must implement data holder creation")}addData(t,e){this.removeOldData(this.dataHolder,this.range),this.addNewData(this.dataHolder,t,e,this.isFirstLoad()),this.hasSelectedSeries()&&(this.updateRange(this.dataHolder),this.firstLoad&&(this.firstLoad=!1),this.refresh(!0))}hasSelectedSeries(){return!this.selectedSeries||Object.values(this.selectedSeries).some(t=>!0===t)}removeOldData(t,e){this.disableOldDataRemoval||t[0].data.length>e&&t.forEach(t=>t.data.shift())}addNewData(t,e,a,s){}setSelectedSeries(t){this.selectedSeries=t}updateRange(t,e){if(this.disableRangeUpdate)return;const[a]=r.calculateMaxChartValueAndDivisions(t,e,this.selectedSeries);this.chartOptions.yAxis.max=a}isFirstLoad(){return this.firstLoad}getDefaultChartOptions(){return{title:{show:!1,text:"",left:"center",textStyle:{overflow:"breakAll",rich:{a:{fontWeight:400,fontSize:14},b:{color:r.cssVar("--gw-secondary-base"),fontWeight:400,fontSize:14}}}},animation:!1,color:r.COLORS,legend:{right:"15%",top:"6%",textStyle:{overflow:"truncate"},icon:"circle"},tooltip:{trigger:"axis",axisPointer:{animation:!1,label:{formatter:function(t){return s.kB.format(t.value,"{HH}:{mm}:{ss}",!1)}}}},grid:{containLabel:!0,left:40},xAxis:{type:"time",splitLine:{show:!0},axisLabel:{hideOverlap:!0,padding:8,formatter:{hour:"{bold|{HH}:{mm}}",minute:"{bold|{HH}:{mm}}",second:"{HH}:{mm}:{ss}"},color:r.cssVar("--gw-neutral-dark"),rich:{bold:{fontWeight:500}}}},yAxis:{type:"value",splitLine:{show:!0},axisLabel:{color:r.cssVar("--gw-neutral-dark")},axisTick:{lineStyle:{type:"solid"}}},textStyle:{fontFamily:r.cssVar("--main-font"),fontWeight:400}}}static getMaxValueFromDataHolder(t,e){const a=t.filter(t=>!e||angular.isUndefined(e[t.name])||!0===e[t.name]).map(t=>r.getMaxValueForDataSeries(t));return Math.max(1,...a)}static getMaxValueForDataSeries(t){return Math.max(...t.data.map(t=>t.value[1]))}static calculateMaxChartValueAndDivisions(t,e,a){let s;s=Array.isArray(t)?r.getMaxValueFromDataHolder(t,a):r.getMaxValueForDataSeries(t);const i=Math.ceil(s*(e||r.DEFAULT_MULTIPLIER))||1;return[i,Math.ceil(i/r.MAXIMUM_DIVISIONS)]}static getIntegerRangeForValues(t,e,a){const[s,i]=r.calculateMaxChartValueAndDivisions(t,e,a);return[s,i]}static formatBytesValue(t,e,a){let s=t;e&&(s=r.getMaxValueFromDataHolder(e,a));const i=Math.floor(Math.log(s)/Math.log(1024));return`${(parseFloat(t)/Math.pow(1024,i)).toFixed(2)} ${["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][i]}`}formatNumber(t){if(!angular.isUndefined(t)&&this.filter)return this.filter("currency")(t,"",0)}}},72720:(t,e,a)=>{a.d(e,{V:()=>r});var s=a(8642);class r extends s.h{constructor(t,e){super(t,!1,!1,e)}chartSetup(t){const e={yAxis:{axisLabel:{formatter:t=>this.formatNumber(t)},min:0},tooltip:{valueFormatter:t=>this.formatNumber(t)}};_.merge(t,e)}createDataHolder(){return[{name:this.translateService.instant("resource.system.file_descriptors.open"),type:"line",areaStyle:{opacity:s.h.AREA_BAR_OPACITY},showSymbol:!1,smooth:!0,color:s.h.COLORS[1],data:[]}]}translateLabels(){const[t]=this.dataHolder;t.name=this.translateService.instant("resource.system.file_descriptors.open"),this.configureSubtitle()}addNewData(t,e,a){this.latestData={maxFileDescriptors:a.maxFileDescriptors,openFileDescriptors:a.openFileDescriptors},this.configureSubtitle(),a.openFileDescriptors&&t[0].data.push({value:[e,a.openFileDescriptors]})}configureSubtitle(){let t;t=this.latestData.openFileDescriptors?[{label:this.translateService.instant("resource.system.file_descriptors.max"),value:this.formatNumber(this.latestData.maxFileDescriptors)}]:[{label:this.translateService.instant("resource.system.file_descriptors.only_unix")}],this.setSubTitle(t)}updateRange(t){super.updateRange(t,2)}}}}; //# sourceMappingURL=72720.048944efcc7dca2f8946.bundle.js.map