mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Refactor dashlet factory into its own index file, so it's obvious where to add them.
This commit is contained in:
parent
ab240de711
commit
d1f37ed164
@ -1,12 +1,7 @@
|
|||||||
import {subscribeWS, resetWS} from "../pubsub/ws";
|
import {subscribeWS, resetWS} from "../pubsub/ws";
|
||||||
import {ThroughputBpsDash} from "./throughput_bps_dash";
|
|
||||||
import {ThroughputPpsDash} from "./throughput_pps_dash";
|
|
||||||
import {ShapedUnshapedDash} from "./shaped_unshaped_dash";
|
|
||||||
import {TrackedFlowsCount} from "./tracked_flow_count_dash";
|
|
||||||
import {ThroughputRingDash} from "./throughput_ring_dash";
|
|
||||||
import {RttHistoDash} from "./rtt_histo_dash";
|
|
||||||
import {darkBackground, modalContent} from "../helpers/our_modals";
|
import {darkBackground, modalContent} from "../helpers/our_modals";
|
||||||
import {heading5Icon, theading} from "../helpers/builders";
|
import {heading5Icon, theading} from "../helpers/builders";
|
||||||
|
import {DashletMenu, widgetFactory} from "./dashlet_index";
|
||||||
|
|
||||||
export class Dashboard {
|
export class Dashboard {
|
||||||
// Takes the name of the parent div to start building the dashboard
|
// Takes the name of the parent div to start building the dashboard
|
||||||
@ -50,7 +45,7 @@ export class Dashboard {
|
|||||||
#filterWidgetList() {
|
#filterWidgetList() {
|
||||||
this.dashlets = [];
|
this.dashlets = [];
|
||||||
for (let i=0; i<this.dashletIdentities.length; i++) {
|
for (let i=0; i<this.dashletIdentities.length; i++) {
|
||||||
let widget = this.#factory(i);
|
let widget = widgetFactory(this.dashletIdentities[i].tag, i);
|
||||||
if (widget == null) continue; // Skip build
|
if (widget == null) continue; // Skip build
|
||||||
widget.size = this.dashletIdentities[i].size;
|
widget.size = this.dashletIdentities[i].size;
|
||||||
this.dashlets.push(widget);
|
this.dashlets.push(widget);
|
||||||
@ -104,24 +99,6 @@ export class Dashboard {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#factory(count) {
|
|
||||||
let widgetName = this.dashletIdentities[count].tag;
|
|
||||||
let widget = null;
|
|
||||||
switch (widgetName) {
|
|
||||||
case "throughputBps": widget = new ThroughputBpsDash(count); break;
|
|
||||||
case "throughputPps": widget = new ThroughputPpsDash(count); break;
|
|
||||||
case "shapedUnshaped": widget = new ShapedUnshapedDash(count); break;
|
|
||||||
case "trackedFlowsCount": widget = new TrackedFlowsCount(count); break;
|
|
||||||
case "throughputRing": widget = new ThroughputRingDash(count); break;
|
|
||||||
case "rttHistogram": widget = new RttHistoDash(count); break;
|
|
||||||
default: {
|
|
||||||
console.log("I don't know how to construct a widget of type [" + widgetName + "]");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
editMode() {
|
editMode() {
|
||||||
let darken = darkBackground("darkEdit");
|
let darken = darkBackground("darkEdit");
|
||||||
let content = modalContent("darkEdit");
|
let content = modalContent("darkEdit");
|
||||||
@ -516,13 +493,4 @@ class Layout {
|
|||||||
let template = JSON.stringify(dashletIdentities);
|
let template = JSON.stringify(dashletIdentities);
|
||||||
localStorage.setItem("dashboardLayout", template);
|
localStorage.setItem("dashboardLayout", template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const DashletMenu = [
|
|
||||||
{ name: "Throughput Bits/Second", tag: "throughputBps", size: 3 },
|
|
||||||
{ name: "Throughput Packets/Second", tag: "throughputPps", size: 3 },
|
|
||||||
{ name: "Shaped/Unshaped Pie", tag: "shapedUnshaped", size: 3 },
|
|
||||||
{ name: "Tracked Flows Counter", tag: "trackedFlowsCount", size: 3 },
|
|
||||||
{ name: "Last 5 Minutes Throughput", tag: "throughputRing", size: 6 },
|
|
||||||
{ name: "Round-Trip Time Histogram", tag: "rttHistogram", size: 6 },
|
|
||||||
];
|
|
@ -0,0 +1,32 @@
|
|||||||
|
import {ThroughputBpsDash} from "./throughput_bps_dash";
|
||||||
|
import {ThroughputPpsDash} from "./throughput_pps_dash";
|
||||||
|
import {ShapedUnshapedDash} from "./shaped_unshaped_dash";
|
||||||
|
import {TrackedFlowsCount} from "./tracked_flow_count_dash";
|
||||||
|
import {ThroughputRingDash} from "./throughput_ring_dash";
|
||||||
|
import {RttHistoDash} from "./rtt_histo_dash";
|
||||||
|
|
||||||
|
export const DashletMenu = [
|
||||||
|
{ name: "Throughput Bits/Second", tag: "throughputBps", size: 3 },
|
||||||
|
{ name: "Throughput Packets/Second", tag: "throughputPps", size: 3 },
|
||||||
|
{ name: "Shaped/Unshaped Pie", tag: "shapedUnshaped", size: 3 },
|
||||||
|
{ name: "Tracked Flows Counter", tag: "trackedFlowsCount", size: 3 },
|
||||||
|
{ name: "Last 5 Minutes Throughput", tag: "throughputRing", size: 6 },
|
||||||
|
{ name: "Round-Trip Time Histogram", tag: "rttHistogram", size: 6 },
|
||||||
|
];
|
||||||
|
|
||||||
|
export function widgetFactory(widgetName, count) {
|
||||||
|
let widget = null;
|
||||||
|
switch (widgetName) {
|
||||||
|
case "throughputBps": widget = new ThroughputBpsDash(count); break;
|
||||||
|
case "throughputPps": widget = new ThroughputPpsDash(count); break;
|
||||||
|
case "shapedUnshaped": widget = new ShapedUnshapedDash(count); break;
|
||||||
|
case "trackedFlowsCount": widget = new TrackedFlowsCount(count); break;
|
||||||
|
case "throughputRing": widget = new ThroughputRingDash(count); break;
|
||||||
|
case "rttHistogram": widget = new RttHistoDash(count); break;
|
||||||
|
default: {
|
||||||
|
console.log("I don't know how to construct a widget of type [" + widgetName + "]");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return widget;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user