graphdb-workbench
Version:
The web application for GraphDB APIs
2 lines • 6.81 kB
JavaScript
export const __webpack_id__=53952;export const __webpack_ids__=[8642,53952];export const __webpack_modules__={8642:(t,e,a)=>{a.r(e),a.d(e,{ChartData:()=>s});var r=a(18301);class s{static get DEFAULT_MULTIPLIER(){return 1.2}static get MAXIMUM_DIVISIONS(){return 10}static get COLORS(){return[s.cssVar("--secondary-color"),s.cssVar("--primary-color"),s.cssVar("--tertiary-color"),s.cssVar("--gray-color")]}static get AREA_BAR_OPACITY(){return.5}static cssVar(t){return getComputedStyle(document.documentElement).getPropertyValue(t)}constructor(t,e,a,r){this.filter=r,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((r,s)=>{if(Array.isArray(r.value)&&!r.value.length)return;const i=Array.isArray(r.value)?r.value.join("/"):r.value;a+=`{a|${r.label}}`,void 0!==i&&(a+=`{b|${i}}`),s+1<t.length&&(a+=e>0&&(s+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,r){}setSelectedSeries(t){this.selectedSeries=t}updateRange(t,e){if(this.disableRangeUpdate)return;const[a]=s.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:s.cssVar("--secondary-color"),fontWeight:400,fontSize:14}}}},animation:!1,color:s.COLORS,legend:{right:"15%",top:"6%",textStyle:{overflow:"truncate"},icon:"circle"},tooltip:{trigger:"axis",axisPointer:{animation:!1,label:{formatter:function(t){return r.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:s.cssVar("--gray-color-dark"),rich:{bold:{fontWeight:500}}}},yAxis:{type:"value",splitLine:{show:!0},axisLabel:{color:s.cssVar("--gray-color-dark")},axisTick:{lineStyle:{type:"solid"}}},textStyle:{fontFamily:s.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=>s.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 r;r=Array.isArray(t)?s.getMaxValueFromDataHolder(t,a):s.getMaxValueForDataSeries(t);const i=Math.ceil(r*(e||s.DEFAULT_MULTIPLIER))||1;return[i,Math.ceil(i/s.MAXIMUM_DIVISIONS)]}static getIntegerRangeForValues(t,e,a){const[r,i]=s.calculateMaxChartValueAndDivisions(t,e,a);return[r,i]}static formatBytesValue(t,e,a){let r=t;e&&(r=s.getMaxValueFromDataHolder(e,a));const i=Math.floor(Math.log(r)/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)}}},53952:(t,e,a)=>{a.r(e),a.d(e,{DiskStorageChart:()=>s});var r=a(8642);class s extends r.ChartData{constructor(t){super(t,!0,!0)}chartSetup(t){const e={height:250,tooltip:{trigger:"axis",axisPointer:{type:"shadow",label:null},valueFormatter:function(t){return(100*t).toFixed(2)+"%"}},xAxis:{type:"value",min:0,max:1,splitNumber:2,axisLabel:{formatter:function(t){return(100*t).toFixed(2)+"%"}}},yAxis:{type:"category",data:[this.translateService.instant("resource.storage.logs"),this.translateService.instant("resource.storage.work"),this.translateService.instant("resource.storage.data")]},legend:{itemStyle:{opacity:1}}};_.merge(t,e)}createDataHolder(){return[this.createDataHolderForItem("resource.storage.used",r.ChartData.COLORS[1]),this.createDataHolderForItem("resource.storage.free",r.ChartData.COLORS[0])]}createDataHolderForItem(t,e){return{name:this.translateService.instant(t),type:"bar",stack:!0,showSymbol:!1,smooth:!0,barCategoryGap:"10%",color:e,itemStyle:{opacity:r.ChartData.AREA_BAR_OPACITY},label:{show:!0,color:"black",opacity:1,formatter:function({value:t}){return(100*t).toFixed(2)+"%"}},emphasis:{itemStyle:{color:e,opacity:1},label:{color:"white"}},data:[]}}translateLabels(){const[t,e]=this.dataHolder;t.name=this.translateService.instant("resource.storage.used"),e.name=this.translateService.instant("resource.storage.free"),this.chartSetup(this.chartOptions),this.configureSubtitle()}addNewData(t,e,a,r){const s=a.storageMemory,[i,o]=t;this.latestData={data:{used:s.dataDirUsed,free:s.dataDirFree},work:{used:s.workDirUsed,free:s.workDirFree},logs:{used:s.logsDirUsed,free:s.logsDirFree}},this.configureSubtitle();const l=s.dataDirUsed+s.dataDirFree,n=s.workDirUsed+s.workDirFree,h=s.logsDirUsed+s.logsDirFree,c=s.dataDirUsed/l,d=s.workDirUsed/n,u=s.logsDirUsed/h,g=s.dataDirFree/l,f=s.workDirFree/n,m=s.logsDirFree/h;i.data.push(u,d,c),o.data.push(m,f,g)}configureSubtitle(){const t=[{label:this.translateService.instant("resource.storage.subtitle.data"),value:[s.formatBytesValue(this.latestData.data.used,null,this.selectedSeries),s.formatBytesValue(this.latestData.data.free,null,this.selectedSeries)]},{label:this.translateService.instant("resource.storage.subtitle.work"),value:[s.formatBytesValue(this.latestData.work.used,null,this.selectedSeries),s.formatBytesValue(this.latestData.work.free,null,this.selectedSeries)]},{label:this.translateService.instant("resource.storage.subtitle.logs"),value:[s.formatBytesValue(this.latestData.logs.used,null,this.selectedSeries),s.formatBytesValue(this.latestData.logs.free,null,this.selectedSeries)]}];this.setSubTitle(t)}}}};
//# sourceMappingURL=53952.f18adf38fd324c9cbe33.bundle.js.map