web-mojo 2.1.1111 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin.cjs.js +1 -1
- package/dist/admin.cjs.js.map +1 -1
- package/dist/admin.es.js +7 -7
- package/dist/admin.es.js.map +1 -1
- package/dist/auth.cjs.js +1 -1
- package/dist/auth.es.js +1 -1
- package/dist/charts.cjs.js +1 -1
- package/dist/charts.css +61 -20
- package/dist/charts.es.js +2 -2
- package/dist/chunks/{ChatView-BsANcDiL.js → ChatView-CWNoGk-B.js} +4 -4
- package/dist/chunks/{ChatView-BsANcDiL.js.map → ChatView-CWNoGk-B.js.map} +1 -1
- package/dist/chunks/{Collection-vtImpCcS.js → Collection-C7rteLDn.js} +2 -2
- package/dist/chunks/{Collection-vtImpCcS.js.map → Collection-C7rteLDn.js.map} +1 -1
- package/dist/chunks/{ContextMenu-DfrWFc5y.js → ContextMenu-JJ51hS-a.js} +2 -2
- package/dist/chunks/{ContextMenu-DfrWFc5y.js.map → ContextMenu-JJ51hS-a.js.map} +1 -1
- package/dist/chunks/{ListView-BtZ7fylv.js → ListView-DWaowghQ.js} +2 -2
- package/dist/chunks/{ListView-BtZ7fylv.js.map → ListView-DWaowghQ.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-B_AUB4YG.js → MetricsMiniChartWidget-BHrvOb3y.js} +196 -251
- package/dist/chunks/{MetricsMiniChartWidget-B_AUB4YG.js.map → MetricsMiniChartWidget-BHrvOb3y.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-DTjYy6Mh.js → MetricsMiniChartWidget-CZ-cQgUg.js} +2 -2
- package/dist/chunks/MetricsMiniChartWidget-CZ-cQgUg.js.map +1 -0
- package/dist/chunks/{TokenManager-CKkIWgzy.js → TokenManager-CoHKTGNX.js} +3 -3
- package/dist/chunks/{TokenManager-CKkIWgzy.js.map → TokenManager-CoHKTGNX.js.map} +1 -1
- package/dist/chunks/version-C9Ldou9O.js +2 -0
- package/dist/chunks/version-C9Ldou9O.js.map +1 -0
- package/dist/chunks/{version-VfBIdNp3.js → version-DMWafX9X.js} +5 -5
- package/dist/chunks/version-DMWafX9X.js.map +1 -0
- package/dist/css/web-mojo.css +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +4 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +8 -8
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.es.js +1 -1
- package/dist/map.es.js +1 -1
- package/dist/timeline.es.js +2 -2
- package/package.json +1 -1
- package/dist/chunks/MetricsMiniChartWidget-DTjYy6Mh.js.map +0 -1
- package/dist/chunks/version-BZvxqd84.js +0 -2
- package/dist/chunks/version-BZvxqd84.js.map +0 -1
- package/dist/chunks/version-VfBIdNp3.js.map +0 -1
package/dist/chunks/{MetricsMiniChartWidget-B_AUB4YG.js → MetricsMiniChartWidget-BHrvOb3y.js}
RENAMED
|
@@ -2544,7 +2544,7 @@ class MetricsMiniChart extends MiniChart {
|
|
|
2544
2544
|
this.isLoading = false;
|
|
2545
2545
|
this.lastFetch = null;
|
|
2546
2546
|
this.refreshInterval = options.refreshInterval;
|
|
2547
|
-
if (!this.dateStart || !this.dateEnd) {
|
|
2547
|
+
if ((!this.dateStart || !this.dateEnd) && this.defaultDateRange) {
|
|
2548
2548
|
this.setQuickRange(this.defaultDateRange);
|
|
2549
2549
|
}
|
|
2550
2550
|
if (this.slugs && !Array.isArray(this.slugs)) {
|
|
@@ -2684,6 +2684,81 @@ class MetricsMiniChart extends MiniChart {
|
|
|
2684
2684
|
await super.onBeforeDestroy();
|
|
2685
2685
|
}
|
|
2686
2686
|
}
|
|
2687
|
+
class SettingsView extends View {
|
|
2688
|
+
constructor(options = {}) {
|
|
2689
|
+
super({
|
|
2690
|
+
tagName: "div",
|
|
2691
|
+
className: "metrics-chart-settings-content",
|
|
2692
|
+
...options
|
|
2693
|
+
});
|
|
2694
|
+
this.granularity = options.granularity;
|
|
2695
|
+
this.chartType = options.chartType;
|
|
2696
|
+
this.dateStart = options.dateStart;
|
|
2697
|
+
this.dateEnd = options.dateEnd;
|
|
2698
|
+
this.showDateRange = options.showDateRange;
|
|
2699
|
+
}
|
|
2700
|
+
formatDateForInput(date) {
|
|
2701
|
+
if (!date) return "";
|
|
2702
|
+
if (typeof date === "string" && /^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
2703
|
+
return date;
|
|
2704
|
+
}
|
|
2705
|
+
const d = date instanceof Date ? date : new Date(date);
|
|
2706
|
+
if (isNaN(d.getTime())) return "";
|
|
2707
|
+
const year = d.getFullYear();
|
|
2708
|
+
const month = String(d.getMonth() + 1).padStart(2, "0");
|
|
2709
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
2710
|
+
return `${year}-${month}-${day}`;
|
|
2711
|
+
}
|
|
2712
|
+
getTemplate() {
|
|
2713
|
+
return `
|
|
2714
|
+
<div style="min-width: 220px;">
|
|
2715
|
+
<div class="d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom">
|
|
2716
|
+
<h6 class="mb-0">Chart Settings</h6>
|
|
2717
|
+
<button type="button" class="btn-close btn-close-sm" data-action="close" aria-label="Close"></button>
|
|
2718
|
+
</div>
|
|
2719
|
+
|
|
2720
|
+
<label class="form-label small mb-1">Granularity</label>
|
|
2721
|
+
<select class="form-select form-select-sm mb-2" data-setting="granularity">
|
|
2722
|
+
<option value="hours" ${this.granularity === "hours" ? "selected" : ""}>Hours</option>
|
|
2723
|
+
<option value="days" ${this.granularity === "days" ? "selected" : ""}>Days</option>
|
|
2724
|
+
<option value="weeks" ${this.granularity === "weeks" ? "selected" : ""}>Weeks</option>
|
|
2725
|
+
<option value="months" ${this.granularity === "months" ? "selected" : ""}>Months</option>
|
|
2726
|
+
<option value="years" ${this.granularity === "years" ? "selected" : ""}>Years</option>
|
|
2727
|
+
</select>
|
|
2728
|
+
|
|
2729
|
+
<label class="form-label small mb-1">Chart Type</label>
|
|
2730
|
+
<select class="form-select form-select-sm mb-2" data-setting="chartType">
|
|
2731
|
+
<option value="line" ${this.chartType === "line" ? "selected" : ""}>Line</option>
|
|
2732
|
+
<option value="bar" ${this.chartType === "bar" ? "selected" : ""}>Bar</option>
|
|
2733
|
+
</select>
|
|
2734
|
+
|
|
2735
|
+
${this.showDateRange ? `
|
|
2736
|
+
<label class="form-label small mb-1">Date Range</label>
|
|
2737
|
+
<input type="date" class="form-control form-control-sm mb-1" data-setting="dateStart" value="${this.formatDateForInput(this.dateStart)}" />
|
|
2738
|
+
<input type="date" class="form-control form-control-sm mb-2" data-setting="dateEnd" value="${this.formatDateForInput(this.dateEnd)}" />
|
|
2739
|
+
` : ""}
|
|
2740
|
+
|
|
2741
|
+
<div class="d-grid gap-2">
|
|
2742
|
+
<button type="button" class="btn btn-sm btn-primary" data-action="apply">Apply</button>
|
|
2743
|
+
<button type="button" class="btn btn-sm btn-outline-secondary" data-action="cancel">Cancel</button>
|
|
2744
|
+
</div>
|
|
2745
|
+
</div>
|
|
2746
|
+
`;
|
|
2747
|
+
}
|
|
2748
|
+
async onActionApply() {
|
|
2749
|
+
const granularity = this.element.querySelector('[data-setting="granularity"]')?.value;
|
|
2750
|
+
const chartType = this.element.querySelector('[data-setting="chartType"]')?.value;
|
|
2751
|
+
const dateStart = this.element.querySelector('[data-setting="dateStart"]')?.value;
|
|
2752
|
+
const dateEnd = this.element.querySelector('[data-setting="dateEnd"]')?.value;
|
|
2753
|
+
this.emit("settings:apply", { granularity, chartType, dateStart, dateEnd });
|
|
2754
|
+
}
|
|
2755
|
+
async onActionCancel() {
|
|
2756
|
+
this.emit("settings:cancel");
|
|
2757
|
+
}
|
|
2758
|
+
async onActionClose() {
|
|
2759
|
+
this.emit("settings:cancel");
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2687
2762
|
class MetricsMiniChartWidget extends View {
|
|
2688
2763
|
constructor(options = {}) {
|
|
2689
2764
|
super({
|
|
@@ -2699,7 +2774,7 @@ class MetricsMiniChartWidget extends View {
|
|
|
2699
2774
|
this.showSettings = options.showSettings || false;
|
|
2700
2775
|
this.settingsKey = options.settingsKey || null;
|
|
2701
2776
|
this.showDateRange = options.showDateRange || false;
|
|
2702
|
-
this.
|
|
2777
|
+
this.showRefresh = options.showRefresh !== false;
|
|
2703
2778
|
this.showTrending = !!options.showTrending;
|
|
2704
2779
|
this.trendRange = options.trendRange ?? null;
|
|
2705
2780
|
this.trendOffset = options.trendOffset ?? 0;
|
|
@@ -2715,7 +2790,6 @@ class MetricsMiniChartWidget extends View {
|
|
|
2715
2790
|
this.trendingLabel = "";
|
|
2716
2791
|
this.chartOptions = {
|
|
2717
2792
|
endpoint: options.endpoint,
|
|
2718
|
-
// defaults inside MetricsMiniChart
|
|
2719
2793
|
account: options.account,
|
|
2720
2794
|
granularity: options.granularity,
|
|
2721
2795
|
slugs: options.slugs,
|
|
@@ -2724,7 +2798,6 @@ class MetricsMiniChartWidget extends View {
|
|
|
2724
2798
|
dateEnd: options.dateEnd,
|
|
2725
2799
|
defaultDateRange: options.defaultDateRange,
|
|
2726
2800
|
refreshInterval: options.refreshInterval,
|
|
2727
|
-
// Visuals and interactions
|
|
2728
2801
|
chartType: options.chartType || "line",
|
|
2729
2802
|
showTooltip: options.showTooltip !== void 0 ? options.showTooltip : true,
|
|
2730
2803
|
showXAxis: options.showXAxis || false,
|
|
@@ -2736,19 +2809,16 @@ class MetricsMiniChartWidget extends View {
|
|
|
2736
2809
|
smoothing: options.smoothing ?? 0.3,
|
|
2737
2810
|
strokeWidth: options.strokeWidth,
|
|
2738
2811
|
barGap: options.barGap,
|
|
2739
|
-
// Optional formatters and templates
|
|
2740
2812
|
valueFormat: options.valueFormat,
|
|
2741
2813
|
labelFormat: options.labelFormat,
|
|
2742
2814
|
tooltipFormatter: options.tooltipFormatter,
|
|
2743
2815
|
tooltipTemplate: options.tooltipTemplate,
|
|
2744
|
-
// Crosshair and axis styling overrides (optional passthroughs)
|
|
2745
2816
|
showCrosshair: options.showCrosshair,
|
|
2746
2817
|
crosshairColor: options.crosshairColor,
|
|
2747
2818
|
crosshairWidth: options.crosshairWidth,
|
|
2748
2819
|
xAxisColor: options.xAxisColor,
|
|
2749
2820
|
xAxisWidth: options.xAxisWidth,
|
|
2750
2821
|
xAxisDashed: options.xAxisDashed,
|
|
2751
|
-
// Other rendering params
|
|
2752
2822
|
padding: options.padding,
|
|
2753
2823
|
minValue: options.minValue,
|
|
2754
2824
|
maxValue: options.maxValue,
|
|
@@ -2765,7 +2835,6 @@ class MetricsMiniChartWidget extends View {
|
|
|
2765
2835
|
this.chart = new MetricsMiniChart({
|
|
2766
2836
|
...this.chartOptions,
|
|
2767
2837
|
containerId: "chart"
|
|
2768
|
-
// mount inside our template container
|
|
2769
2838
|
});
|
|
2770
2839
|
this.addChild(this.chart);
|
|
2771
2840
|
this.header = new View({
|
|
@@ -2774,7 +2843,7 @@ class MetricsMiniChartWidget extends View {
|
|
|
2774
2843
|
icon: this.icon,
|
|
2775
2844
|
template: `
|
|
2776
2845
|
<div class="d-flex justify-content-between align-items-start mb-2">
|
|
2777
|
-
<div class="
|
|
2846
|
+
<div class="flex-grow-1">
|
|
2778
2847
|
<h6 class="card-title mb-1" style="${this.textColor ? `color: ${this.textColor}` : ""}">${this.title}</h6>
|
|
2779
2848
|
<div class="metrics-mini-chart-subtitle" style="${this.textColor ? `color: ${this.textColor}` : ""}">${this.subtitle}</div>
|
|
2780
2849
|
{{#hasTrending}}
|
|
@@ -2783,17 +2852,23 @@ class MetricsMiniChartWidget extends View {
|
|
|
2783
2852
|
</div>
|
|
2784
2853
|
{{/hasTrending}}
|
|
2785
2854
|
</div>
|
|
2786
|
-
|
|
2787
|
-
${this.showSettings ? `
|
|
2788
|
-
<button class="btn btn-link p-0 text-muted metrics-settings-btn" type="button" data-settings-trigger style="${this.textColor ? `color: ${this.textColor} !important` : ""}">
|
|
2789
|
-
<i class="bi bi-gear-fill" style="font-size: 1.1rem;"></i>
|
|
2790
|
-
</button>
|
|
2791
|
-
` : ""}
|
|
2792
|
-
${this.icon ? `<i class="${this.icon} fs-4 flex-shrink-0" aria-hidden="true" style="${this.textColor ? `color: ${this.textColor}` : ""}"></i>` : ""}
|
|
2793
|
-
</div>
|
|
2855
|
+
${this.icon ? `<i class="${this.icon} fs-4 flex-shrink-0" aria-hidden="true" style="${this.textColor ? `color: ${this.textColor}` : ""}"></i>` : ""}
|
|
2794
2856
|
</div>`
|
|
2795
2857
|
});
|
|
2796
2858
|
this.addChild(this.header);
|
|
2859
|
+
if (this.showSettings) {
|
|
2860
|
+
this.settingsView = new SettingsView({
|
|
2861
|
+
containerId: "settings",
|
|
2862
|
+
granularity: this.chartOptions.granularity,
|
|
2863
|
+
chartType: this.chartOptions.chartType,
|
|
2864
|
+
dateStart: this.chartOptions.dateStart,
|
|
2865
|
+
dateEnd: this.chartOptions.dateEnd,
|
|
2866
|
+
showDateRange: this.showDateRange
|
|
2867
|
+
});
|
|
2868
|
+
this.settingsView.on("settings:apply", (data) => this._handleSettingsApply(data));
|
|
2869
|
+
this.settingsView.on("settings:cancel", () => this._handleSettingsCancel());
|
|
2870
|
+
this.addChild(this.settingsView);
|
|
2871
|
+
}
|
|
2797
2872
|
if (this.chart?.on) {
|
|
2798
2873
|
this.chart.on("metrics:loaded", this.onChildMetricsLoaded, this);
|
|
2799
2874
|
}
|
|
@@ -2801,17 +2876,12 @@ class MetricsMiniChartWidget extends View {
|
|
|
2801
2876
|
}
|
|
2802
2877
|
async onAfterRender() {
|
|
2803
2878
|
await super.onAfterRender();
|
|
2804
|
-
if (this.showSettings) {
|
|
2879
|
+
if (this.showSettings && this.settingsView) {
|
|
2805
2880
|
this._initSettingsPopover();
|
|
2806
2881
|
}
|
|
2807
2882
|
}
|
|
2808
2883
|
onChildMetricsLoaded() {
|
|
2809
2884
|
this.updateFromChartData({ render: true });
|
|
2810
|
-
if (this.showSettings && this.isMounted()) {
|
|
2811
|
-
setTimeout(() => {
|
|
2812
|
-
this._initSettingsPopover();
|
|
2813
|
-
}, 100);
|
|
2814
|
-
}
|
|
2815
2885
|
}
|
|
2816
2886
|
updateFromChartData({ render = true } = {}) {
|
|
2817
2887
|
const values = Array.isArray(this.chart?.data) ? this.chart.data : null;
|
|
@@ -2895,10 +2965,6 @@ class MetricsMiniChartWidget extends View {
|
|
|
2895
2965
|
this.header.render();
|
|
2896
2966
|
}
|
|
2897
2967
|
}
|
|
2898
|
-
/**
|
|
2899
|
-
* Update labels based on current granularity
|
|
2900
|
-
* @private
|
|
2901
|
-
*/
|
|
2902
2968
|
_updateGranularityLabels() {
|
|
2903
2969
|
const granularity = this.chartOptions.granularity || "days";
|
|
2904
2970
|
const nowLabels = {
|
|
@@ -2927,10 +2993,25 @@ class MetricsMiniChartWidget extends View {
|
|
|
2927
2993
|
}
|
|
2928
2994
|
async getTemplate() {
|
|
2929
2995
|
return `
|
|
2930
|
-
<div class="card h-100 shadow-sm" style="${this.cardStyle}">
|
|
2996
|
+
<div class="card h-100 shadow-sm" style="${this.cardStyle}; position: relative;">
|
|
2997
|
+
${this.showRefresh || this.showSettings ? `
|
|
2998
|
+
<div class="metrics-chart-actions">
|
|
2999
|
+
${this.showRefresh ? `
|
|
3000
|
+
<button class="btn btn-link p-0 text-muted metrics-refresh-btn" type="button" data-action="refresh-chart" style="${this.textColor ? `color: ${this.textColor} !important` : ""}">
|
|
3001
|
+
<i class="bi bi-arrow-clockwise"></i>
|
|
3002
|
+
</button>
|
|
3003
|
+
` : ""}
|
|
3004
|
+
${this.showSettings ? `
|
|
3005
|
+
<button class="btn btn-link p-0 text-muted metrics-settings-btn" type="button" data-action="toggle-settings" style="${this.textColor ? `color: ${this.textColor} !important` : ""}">
|
|
3006
|
+
<i class="bi bi-gear-fill"></i>
|
|
3007
|
+
</button>
|
|
3008
|
+
` : ""}
|
|
3009
|
+
</div>
|
|
3010
|
+
` : ""}
|
|
2931
3011
|
<div class="card-body p-3">
|
|
2932
3012
|
<div data-container="chart-header"></div>
|
|
2933
3013
|
<div data-container="chart"></div>
|
|
3014
|
+
<div data-container="settings" style="display: none;"></div>
|
|
2934
3015
|
</div>
|
|
2935
3016
|
</div>
|
|
2936
3017
|
`;
|
|
@@ -2946,263 +3027,131 @@ class MetricsMiniChartWidget extends View {
|
|
|
2946
3027
|
await super.onBeforeDestroy();
|
|
2947
3028
|
}
|
|
2948
3029
|
/**
|
|
2949
|
-
*
|
|
3030
|
+
* Toggle settings popover
|
|
3031
|
+
*/
|
|
3032
|
+
async onActionToggleSettings(event, element) {
|
|
3033
|
+
if (!this._settingsPopover) {
|
|
3034
|
+
this._initSettingsPopover();
|
|
3035
|
+
}
|
|
3036
|
+
this._settingsPopover?.toggle();
|
|
3037
|
+
}
|
|
3038
|
+
/**
|
|
3039
|
+
* Initialize settings popover (once)
|
|
2950
3040
|
* @private
|
|
2951
3041
|
*/
|
|
2952
3042
|
_initSettingsPopover() {
|
|
2953
|
-
const button = this.element.querySelector(
|
|
2954
|
-
if (!button)
|
|
2955
|
-
|
|
2956
|
-
return;
|
|
2957
|
-
}
|
|
2958
|
-
if (this._settingsPopover) {
|
|
2959
|
-
try {
|
|
2960
|
-
this._settingsPopover.dispose();
|
|
2961
|
-
} catch (e) {
|
|
2962
|
-
console.warn("Error disposing popover:", e);
|
|
2963
|
-
}
|
|
2964
|
-
this._settingsPopover = null;
|
|
2965
|
-
}
|
|
2966
|
-
const content = this._getSettingsContent();
|
|
3043
|
+
const button = this.element.querySelector('[data-action="toggle-settings"]');
|
|
3044
|
+
if (!button || !this.settingsView || !this.settingsView.element) return;
|
|
3045
|
+
if (this._settingsPopover) return;
|
|
2967
3046
|
this._settingsPopover = new bootstrap.Popover(button, {
|
|
2968
|
-
content,
|
|
3047
|
+
content: this.settingsView.element,
|
|
2969
3048
|
html: true,
|
|
2970
3049
|
placement: "bottom",
|
|
2971
|
-
trigger: "
|
|
3050
|
+
trigger: "manual",
|
|
2972
3051
|
sanitize: false,
|
|
2973
3052
|
customClass: "metrics-chart-settings-popover"
|
|
2974
3053
|
});
|
|
2975
|
-
button.addEventListener("shown.bs.popover", () => {
|
|
2976
|
-
setTimeout(() => {
|
|
2977
|
-
this._attachSettingsHandlers();
|
|
2978
|
-
}, 10);
|
|
2979
|
-
});
|
|
2980
|
-
button.addEventListener("inserted.bs.popover", () => {
|
|
2981
|
-
this._attachSettingsHandlers();
|
|
2982
|
-
});
|
|
2983
3054
|
}
|
|
2984
3055
|
/**
|
|
2985
|
-
*
|
|
3056
|
+
* Handle settings apply
|
|
2986
3057
|
* @private
|
|
2987
3058
|
*/
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
<div class="d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom">
|
|
2992
|
-
<h6 class="mb-0">Chart Settings</h6>
|
|
2993
|
-
<button type="button" class="btn-close btn-close-sm" data-setting-action="close" aria-label="Close"></button>
|
|
2994
|
-
</div>
|
|
2995
|
-
|
|
2996
|
-
<label class="form-label small mb-1">Granularity</label>
|
|
2997
|
-
<select class="form-select form-select-sm mb-2" data-setting="granularity">
|
|
2998
|
-
<option value="hours" ${this.chartOptions.granularity === "hours" ? "selected" : ""}>Hours</option>
|
|
2999
|
-
<option value="days" ${this.chartOptions.granularity === "days" ? "selected" : ""}>Days</option>
|
|
3000
|
-
<option value="weeks" ${this.chartOptions.granularity === "weeks" ? "selected" : ""}>Weeks</option>
|
|
3001
|
-
<option value="months" ${this.chartOptions.granularity === "months" ? "selected" : ""}>Months</option>
|
|
3002
|
-
<option value="years" ${this.chartOptions.granularity === "years" ? "selected" : ""}>Years</option>
|
|
3003
|
-
</select>
|
|
3004
|
-
|
|
3005
|
-
<label class="form-label small mb-1">Chart Type</label>
|
|
3006
|
-
<select class="form-select form-select-sm mb-2" data-setting="chartType">
|
|
3007
|
-
<option value="line" ${this.chartOptions.chartType === "line" ? "selected" : ""}>Line</option>
|
|
3008
|
-
<option value="bar" ${this.chartOptions.chartType === "bar" ? "selected" : ""}>Bar</option>
|
|
3009
|
-
</select>
|
|
3010
|
-
|
|
3011
|
-
${this.showDateRange ? `
|
|
3012
|
-
<label class="form-label small mb-1">Date Range</label>
|
|
3013
|
-
<input type="date" class="form-control form-control-sm mb-1" data-setting="dateStart" value="${this.chartOptions.dateStart || ""}" />
|
|
3014
|
-
<input type="date" class="form-control form-control-sm mb-2" data-setting="dateEnd" value="${this.chartOptions.dateEnd || ""}" />
|
|
3015
|
-
` : ""}
|
|
3016
|
-
|
|
3017
|
-
<div class="d-grid gap-2">
|
|
3018
|
-
<button type="button" class="btn btn-sm btn-primary" data-setting-action="apply">Apply</button>
|
|
3019
|
-
<button type="button" class="btn btn-sm btn-outline-secondary" data-setting-action="cancel">Cancel</button>
|
|
3020
|
-
</div>
|
|
3021
|
-
</div>
|
|
3022
|
-
`;
|
|
3023
|
-
}
|
|
3024
|
-
/**
|
|
3025
|
-
* Attach event handlers to settings controls in popover
|
|
3026
|
-
* @private
|
|
3027
|
-
*/
|
|
3028
|
-
_attachSettingsHandlers() {
|
|
3029
|
-
let popoverElement = document.querySelector(".metrics-chart-settings-popover");
|
|
3030
|
-
if (!popoverElement) {
|
|
3031
|
-
popoverElement = document.querySelector(".popover.metrics-chart-settings-popover");
|
|
3032
|
-
}
|
|
3033
|
-
if (!popoverElement) {
|
|
3034
|
-
const popovers = document.querySelectorAll(".popover.show");
|
|
3035
|
-
if (popovers.length > 0) {
|
|
3036
|
-
popoverElement = popovers[popovers.length - 1];
|
|
3037
|
-
}
|
|
3038
|
-
}
|
|
3039
|
-
if (!popoverElement) {
|
|
3040
|
-
console.warn("MetricsMiniChartWidget: Could not find popover element");
|
|
3041
|
-
return;
|
|
3042
|
-
}
|
|
3043
|
-
this._pendingSettings = {
|
|
3044
|
-
granularity: this.chartOptions.granularity,
|
|
3045
|
-
chartType: this.chartOptions.chartType,
|
|
3046
|
-
dateStart: this.chartOptions.dateStart,
|
|
3047
|
-
dateEnd: this.chartOptions.dateEnd
|
|
3048
|
-
};
|
|
3049
|
-
const granularitySelect = popoverElement.querySelector('[data-setting="granularity"]');
|
|
3050
|
-
if (granularitySelect) {
|
|
3051
|
-
granularitySelect.addEventListener("change", (e) => {
|
|
3052
|
-
this._pendingSettings.granularity = e.target.value;
|
|
3053
|
-
});
|
|
3054
|
-
}
|
|
3055
|
-
const chartTypeSelect = popoverElement.querySelector('[data-setting="chartType"]');
|
|
3056
|
-
if (chartTypeSelect) {
|
|
3057
|
-
chartTypeSelect.addEventListener("change", (e) => {
|
|
3058
|
-
this._pendingSettings.chartType = e.target.value;
|
|
3059
|
-
});
|
|
3060
|
-
}
|
|
3061
|
-
if (this.showDateRange) {
|
|
3062
|
-
const dateStartInput = popoverElement.querySelector('[data-setting="dateStart"]');
|
|
3063
|
-
if (dateStartInput) {
|
|
3064
|
-
dateStartInput.addEventListener("change", (e) => {
|
|
3065
|
-
this._pendingSettings.dateStart = e.target.value;
|
|
3066
|
-
});
|
|
3067
|
-
}
|
|
3068
|
-
const dateEndInput = popoverElement.querySelector('[data-setting="dateEnd"]');
|
|
3069
|
-
if (dateEndInput) {
|
|
3070
|
-
dateEndInput.addEventListener("change", (e) => {
|
|
3071
|
-
this._pendingSettings.dateEnd = e.target.value;
|
|
3072
|
-
});
|
|
3073
|
-
}
|
|
3074
|
-
}
|
|
3075
|
-
const applyButton = popoverElement.querySelector('[data-setting-action="apply"]');
|
|
3076
|
-
if (applyButton) {
|
|
3077
|
-
applyButton.addEventListener("click", async () => {
|
|
3078
|
-
await this._applyPendingSettings();
|
|
3079
|
-
if (this._settingsPopover) {
|
|
3080
|
-
this._settingsPopover.hide();
|
|
3081
|
-
}
|
|
3082
|
-
});
|
|
3083
|
-
}
|
|
3084
|
-
const cancelButton = popoverElement.querySelector('[data-setting-action="cancel"]');
|
|
3085
|
-
if (cancelButton) {
|
|
3086
|
-
cancelButton.addEventListener("click", () => {
|
|
3087
|
-
this._pendingSettings = null;
|
|
3088
|
-
if (this._settingsPopover) {
|
|
3089
|
-
this._settingsPopover.hide();
|
|
3090
|
-
}
|
|
3091
|
-
});
|
|
3092
|
-
}
|
|
3093
|
-
const closeButton = popoverElement.querySelector('[data-setting-action="close"]');
|
|
3094
|
-
if (closeButton) {
|
|
3095
|
-
closeButton.addEventListener("click", () => {
|
|
3096
|
-
this._pendingSettings = null;
|
|
3097
|
-
if (this._settingsPopover) {
|
|
3098
|
-
this._settingsPopover.hide();
|
|
3099
|
-
}
|
|
3100
|
-
});
|
|
3059
|
+
async _handleSettingsApply(data) {
|
|
3060
|
+
if (this._settingsPopover) {
|
|
3061
|
+
this._settingsPopover.hide();
|
|
3101
3062
|
}
|
|
3102
|
-
}
|
|
3103
|
-
/**
|
|
3104
|
-
* Apply all pending settings changes
|
|
3105
|
-
* @private
|
|
3106
|
-
*/
|
|
3107
|
-
async _applyPendingSettings() {
|
|
3108
|
-
if (!this._pendingSettings) return;
|
|
3109
3063
|
let hasChanges = false;
|
|
3110
3064
|
let granularityChanged = false;
|
|
3111
3065
|
let datesExplicitlySet = false;
|
|
3112
|
-
if (
|
|
3066
|
+
if (data.dateStart && data.dateStart !== this.chartOptions.dateStart || data.dateEnd && data.dateEnd !== this.chartOptions.dateEnd) {
|
|
3113
3067
|
datesExplicitlySet = true;
|
|
3114
3068
|
}
|
|
3115
|
-
if (
|
|
3116
|
-
this.chartOptions.granularity =
|
|
3117
|
-
this.chart.granularity =
|
|
3069
|
+
if (data.granularity && data.granularity !== this.chartOptions.granularity) {
|
|
3070
|
+
this.chartOptions.granularity = data.granularity;
|
|
3071
|
+
this.chart.granularity = data.granularity;
|
|
3118
3072
|
granularityChanged = true;
|
|
3119
3073
|
hasChanges = true;
|
|
3120
3074
|
}
|
|
3121
|
-
if (
|
|
3122
|
-
this.chartOptions.chartType =
|
|
3123
|
-
this.chart.chartType =
|
|
3075
|
+
if (data.chartType && data.chartType !== this.chartOptions.chartType) {
|
|
3076
|
+
this.chartOptions.chartType = data.chartType;
|
|
3077
|
+
this.chart.chartType = data.chartType;
|
|
3124
3078
|
hasChanges = true;
|
|
3125
3079
|
}
|
|
3126
3080
|
if (datesExplicitlySet) {
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3081
|
+
if (data.dateStart) {
|
|
3082
|
+
this.chartOptions.dateStart = new Date(data.dateStart);
|
|
3083
|
+
this.chart.dateStart = new Date(data.dateStart);
|
|
3084
|
+
}
|
|
3085
|
+
if (data.dateEnd) {
|
|
3086
|
+
this.chartOptions.dateEnd = new Date(data.dateEnd);
|
|
3087
|
+
this.chart.dateEnd = new Date(data.dateEnd);
|
|
3088
|
+
}
|
|
3131
3089
|
hasChanges = true;
|
|
3132
|
-
} else if (granularityChanged
|
|
3133
|
-
const
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
"
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3090
|
+
} else if (granularityChanged) {
|
|
3091
|
+
const endDate = /* @__PURE__ */ new Date();
|
|
3092
|
+
let startDate;
|
|
3093
|
+
switch (data.granularity) {
|
|
3094
|
+
case "hours":
|
|
3095
|
+
startDate = new Date(endDate.getTime() - 24 * 60 * 60 * 1e3);
|
|
3096
|
+
break;
|
|
3097
|
+
case "days":
|
|
3098
|
+
startDate = new Date(endDate.getTime() - 30 * 24 * 60 * 60 * 1e3);
|
|
3099
|
+
break;
|
|
3100
|
+
case "weeks":
|
|
3101
|
+
startDate = new Date(endDate.getTime() - 12 * 7 * 24 * 60 * 60 * 1e3);
|
|
3102
|
+
break;
|
|
3103
|
+
case "months":
|
|
3104
|
+
startDate = new Date(endDate);
|
|
3105
|
+
startDate.setMonth(startDate.getMonth() - 12);
|
|
3106
|
+
break;
|
|
3107
|
+
case "years":
|
|
3108
|
+
startDate = new Date(endDate);
|
|
3109
|
+
startDate.setFullYear(startDate.getFullYear() - 5);
|
|
3110
|
+
break;
|
|
3111
|
+
default:
|
|
3112
|
+
startDate = new Date(endDate.getTime() - 30 * 24 * 60 * 60 * 1e3);
|
|
3113
|
+
}
|
|
3114
|
+
this.chartOptions.dateStart = startDate;
|
|
3115
|
+
this.chart.dateStart = startDate;
|
|
3116
|
+
this.chartOptions.dateEnd = endDate;
|
|
3117
|
+
this.chart.dateEnd = endDate;
|
|
3144
3118
|
}
|
|
3145
3119
|
if (hasChanges) {
|
|
3146
3120
|
this._saveSettings();
|
|
3147
3121
|
await this.chart.refresh();
|
|
3148
|
-
setTimeout(() => {
|
|
3149
|
-
if (this.showSettings && this.isMounted()) {
|
|
3150
|
-
this._initSettingsPopover();
|
|
3151
|
-
}
|
|
3152
|
-
}, 150);
|
|
3153
|
-
}
|
|
3154
|
-
this._pendingSettings = null;
|
|
3155
|
-
}
|
|
3156
|
-
refresh() {
|
|
3157
|
-
if (this.chart) {
|
|
3158
|
-
if (this.account) this.chart.account = this.account;
|
|
3159
|
-
this.chart.refresh();
|
|
3160
3122
|
}
|
|
3161
3123
|
}
|
|
3162
3124
|
/**
|
|
3163
|
-
* Handle
|
|
3164
|
-
|
|
3165
|
-
async onActionChangeGranularity(event, element) {
|
|
3166
|
-
const newGranularity = element.value;
|
|
3167
|
-
this.chartOptions.granularity = newGranularity;
|
|
3168
|
-
this.chart.granularity = newGranularity;
|
|
3169
|
-
this._saveSettings();
|
|
3170
|
-
await this.chart.refresh();
|
|
3171
|
-
}
|
|
3172
|
-
/**
|
|
3173
|
-
* Handle chart type change
|
|
3125
|
+
* Handle settings cancel
|
|
3126
|
+
* @private
|
|
3174
3127
|
*/
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
this._saveSettings();
|
|
3180
|
-
await this.chart.refresh();
|
|
3128
|
+
_handleSettingsCancel() {
|
|
3129
|
+
if (this._settingsPopover) {
|
|
3130
|
+
this._settingsPopover.hide();
|
|
3131
|
+
}
|
|
3181
3132
|
}
|
|
3182
3133
|
/**
|
|
3183
|
-
* Handle
|
|
3134
|
+
* Handle refresh button click
|
|
3184
3135
|
*/
|
|
3185
|
-
async
|
|
3186
|
-
const
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3136
|
+
async onActionRefreshChart(event, element) {
|
|
3137
|
+
const icon = element.querySelector("i");
|
|
3138
|
+
if (icon) {
|
|
3139
|
+
icon.classList.add("spin");
|
|
3140
|
+
}
|
|
3141
|
+
if (this.chart) {
|
|
3142
|
+
if (this.account) this.chart.account = this.account;
|
|
3143
|
+
await this.chart.refresh();
|
|
3144
|
+
}
|
|
3145
|
+
if (icon) {
|
|
3146
|
+
icon.classList.remove("spin");
|
|
3147
|
+
}
|
|
3191
3148
|
}
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
this.chartOptions.dateEnd = newDateEnd;
|
|
3198
|
-
this.chart.dateEnd = newDateEnd;
|
|
3199
|
-
this._saveSettings();
|
|
3200
|
-
await this.chart.refresh();
|
|
3149
|
+
refresh() {
|
|
3150
|
+
if (this.chart) {
|
|
3151
|
+
if (this.account) this.chart.account = this.account;
|
|
3152
|
+
this.chart.refresh();
|
|
3153
|
+
}
|
|
3201
3154
|
}
|
|
3202
|
-
/**
|
|
3203
|
-
* Load settings from localStorage
|
|
3204
|
-
* @private
|
|
3205
|
-
*/
|
|
3206
3155
|
_loadSettings() {
|
|
3207
3156
|
if (!this.settingsKey) return;
|
|
3208
3157
|
try {
|
|
@@ -3226,10 +3175,6 @@ class MetricsMiniChartWidget extends View {
|
|
|
3226
3175
|
console.error("Failed to load chart settings:", error);
|
|
3227
3176
|
}
|
|
3228
3177
|
}
|
|
3229
|
-
/**
|
|
3230
|
-
* Save settings to localStorage
|
|
3231
|
-
* @private
|
|
3232
|
-
*/
|
|
3233
3178
|
_saveSettings() {
|
|
3234
3179
|
if (!this.settingsKey) return;
|
|
3235
3180
|
try {
|
|
@@ -3254,4 +3199,4 @@ export {
|
|
|
3254
3199
|
MetricsMiniChart as b,
|
|
3255
3200
|
MetricsMiniChartWidget as c
|
|
3256
3201
|
};
|
|
3257
|
-
//# sourceMappingURL=MetricsMiniChartWidget-
|
|
3202
|
+
//# sourceMappingURL=MetricsMiniChartWidget-BHrvOb3y.js.map
|