web-mojo 2.1.1110 → 2.2.0
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 +4 -4
- 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/{MetricsMiniChartWidget-BJJY9R-s.js → MetricsMiniChartWidget-CTPAXwFC.js} +2 -2
- package/dist/chunks/MetricsMiniChartWidget-CTPAXwFC.js.map +1 -0
- package/dist/chunks/{MetricsMiniChartWidget-bmnV82d1.js → MetricsMiniChartWidget-DaP5lSll.js} +194 -205
- package/dist/chunks/{MetricsMiniChartWidget-bmnV82d1.js.map → MetricsMiniChartWidget-DaP5lSll.js.map} +1 -1
- package/dist/chunks/version-YvYg2w4d.js +2 -0
- package/dist/chunks/version-YvYg2w4d.js.map +1 -0
- package/dist/chunks/{version-FRgkiWti.js → version-uoDXr8WG.js} +5 -5
- package/dist/chunks/version-uoDXr8WG.js.map +1 -0
- package/dist/css/web-mojo.css +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.es.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/MetricsMiniChartWidget-BJJY9R-s.js.map +0 -1
- package/dist/chunks/version-C5lFa1F0.js +0 -2
- package/dist/chunks/version-C5lFa1F0.js.map +0 -1
- package/dist/chunks/version-FRgkiWti.js.map +0 -1
package/dist/chunks/{MetricsMiniChartWidget-bmnV82d1.js → MetricsMiniChartWidget-DaP5lSll.js}
RENAMED
|
@@ -2684,6 +2684,69 @@ 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
|
+
getTemplate() {
|
|
2701
|
+
return `
|
|
2702
|
+
<div style="min-width: 220px;">
|
|
2703
|
+
<div class="d-flex justify-content-between align-items-center mb-2 pb-2 border-bottom">
|
|
2704
|
+
<h6 class="mb-0">Chart Settings</h6>
|
|
2705
|
+
<button type="button" class="btn-close btn-close-sm" data-action="close" aria-label="Close"></button>
|
|
2706
|
+
</div>
|
|
2707
|
+
|
|
2708
|
+
<label class="form-label small mb-1">Granularity</label>
|
|
2709
|
+
<select class="form-select form-select-sm mb-2" data-setting="granularity">
|
|
2710
|
+
<option value="hours" ${this.granularity === "hours" ? "selected" : ""}>Hours</option>
|
|
2711
|
+
<option value="days" ${this.granularity === "days" ? "selected" : ""}>Days</option>
|
|
2712
|
+
<option value="weeks" ${this.granularity === "weeks" ? "selected" : ""}>Weeks</option>
|
|
2713
|
+
<option value="months" ${this.granularity === "months" ? "selected" : ""}>Months</option>
|
|
2714
|
+
<option value="years" ${this.granularity === "years" ? "selected" : ""}>Years</option>
|
|
2715
|
+
</select>
|
|
2716
|
+
|
|
2717
|
+
<label class="form-label small mb-1">Chart Type</label>
|
|
2718
|
+
<select class="form-select form-select-sm mb-2" data-setting="chartType">
|
|
2719
|
+
<option value="line" ${this.chartType === "line" ? "selected" : ""}>Line</option>
|
|
2720
|
+
<option value="bar" ${this.chartType === "bar" ? "selected" : ""}>Bar</option>
|
|
2721
|
+
</select>
|
|
2722
|
+
|
|
2723
|
+
${this.showDateRange ? `
|
|
2724
|
+
<label class="form-label small mb-1">Date Range</label>
|
|
2725
|
+
<input type="date" class="form-control form-control-sm mb-1" data-setting="dateStart" value="${this.dateStart || ""}" />
|
|
2726
|
+
<input type="date" class="form-control form-control-sm mb-2" data-setting="dateEnd" value="${this.dateEnd || ""}" />
|
|
2727
|
+
` : ""}
|
|
2728
|
+
|
|
2729
|
+
<div class="d-grid gap-2">
|
|
2730
|
+
<button type="button" class="btn btn-sm btn-primary" data-action="apply">Apply</button>
|
|
2731
|
+
<button type="button" class="btn btn-sm btn-outline-secondary" data-action="cancel">Cancel</button>
|
|
2732
|
+
</div>
|
|
2733
|
+
</div>
|
|
2734
|
+
`;
|
|
2735
|
+
}
|
|
2736
|
+
async onActionApply() {
|
|
2737
|
+
const granularity = this.element.querySelector('[data-setting="granularity"]')?.value;
|
|
2738
|
+
const chartType = this.element.querySelector('[data-setting="chartType"]')?.value;
|
|
2739
|
+
const dateStart = this.element.querySelector('[data-setting="dateStart"]')?.value;
|
|
2740
|
+
const dateEnd = this.element.querySelector('[data-setting="dateEnd"]')?.value;
|
|
2741
|
+
this.emit("settings:apply", { granularity, chartType, dateStart, dateEnd });
|
|
2742
|
+
}
|
|
2743
|
+
async onActionCancel() {
|
|
2744
|
+
this.emit("settings:cancel");
|
|
2745
|
+
}
|
|
2746
|
+
async onActionClose() {
|
|
2747
|
+
this.emit("settings:cancel");
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2687
2750
|
class MetricsMiniChartWidget extends View {
|
|
2688
2751
|
constructor(options = {}) {
|
|
2689
2752
|
super({
|
|
@@ -2699,6 +2762,7 @@ class MetricsMiniChartWidget extends View {
|
|
|
2699
2762
|
this.showSettings = options.showSettings || false;
|
|
2700
2763
|
this.settingsKey = options.settingsKey || null;
|
|
2701
2764
|
this.showDateRange = options.showDateRange || false;
|
|
2765
|
+
this.showRefresh = options.showRefresh !== false;
|
|
2702
2766
|
this._pendingSettings = null;
|
|
2703
2767
|
this.showTrending = !!options.showTrending;
|
|
2704
2768
|
this.trendRange = options.trendRange ?? null;
|
|
@@ -2774,7 +2838,7 @@ class MetricsMiniChartWidget extends View {
|
|
|
2774
2838
|
icon: this.icon,
|
|
2775
2839
|
template: `
|
|
2776
2840
|
<div class="d-flex justify-content-between align-items-start mb-2">
|
|
2777
|
-
<div class="
|
|
2841
|
+
<div class="flex-grow-1">
|
|
2778
2842
|
<h6 class="card-title mb-1" style="${this.textColor ? `color: ${this.textColor}` : ""}">${this.title}</h6>
|
|
2779
2843
|
<div class="metrics-mini-chart-subtitle" style="${this.textColor ? `color: ${this.textColor}` : ""}">${this.subtitle}</div>
|
|
2780
2844
|
{{#hasTrending}}
|
|
@@ -2783,14 +2847,7 @@ class MetricsMiniChartWidget extends View {
|
|
|
2783
2847
|
</div>
|
|
2784
2848
|
{{/hasTrending}}
|
|
2785
2849
|
</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>
|
|
2850
|
+
${this.icon ? `<i class="${this.icon} fs-4 flex-shrink-0" aria-hidden="true" style="${this.textColor ? `color: ${this.textColor}` : ""}"></i>` : ""}
|
|
2794
2851
|
</div>`
|
|
2795
2852
|
});
|
|
2796
2853
|
this.addChild(this.header);
|
|
@@ -2807,11 +2864,12 @@ class MetricsMiniChartWidget extends View {
|
|
|
2807
2864
|
}
|
|
2808
2865
|
onChildMetricsLoaded() {
|
|
2809
2866
|
this.updateFromChartData({ render: true });
|
|
2810
|
-
if (this.showSettings && this.isMounted()) {
|
|
2867
|
+
if (this.showSettings && this.isMounted() && !this._skipNextPopoverInit) {
|
|
2811
2868
|
setTimeout(() => {
|
|
2812
2869
|
this._initSettingsPopover();
|
|
2813
2870
|
}, 100);
|
|
2814
2871
|
}
|
|
2872
|
+
this._skipNextPopoverInit = false;
|
|
2815
2873
|
}
|
|
2816
2874
|
updateFromChartData({ render = true } = {}) {
|
|
2817
2875
|
const values = Array.isArray(this.chart?.data) ? this.chart.data : null;
|
|
@@ -2927,7 +2985,21 @@ class MetricsMiniChartWidget extends View {
|
|
|
2927
2985
|
}
|
|
2928
2986
|
async getTemplate() {
|
|
2929
2987
|
return `
|
|
2930
|
-
<div class="card h-100 shadow-sm" style="${this.cardStyle}">
|
|
2988
|
+
<div class="card h-100 shadow-sm" style="${this.cardStyle}; position: relative;">
|
|
2989
|
+
${this.showRefresh || this.showSettings ? `
|
|
2990
|
+
<div class="metrics-chart-actions">
|
|
2991
|
+
${this.showRefresh ? `
|
|
2992
|
+
<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` : ""}">
|
|
2993
|
+
<i class="bi bi-arrow-clockwise"></i>
|
|
2994
|
+
</button>
|
|
2995
|
+
` : ""}
|
|
2996
|
+
${this.showSettings ? `
|
|
2997
|
+
<button class="btn btn-link p-0 text-muted metrics-settings-btn" type="button" data-settings-trigger style="${this.textColor ? `color: ${this.textColor} !important` : ""}">
|
|
2998
|
+
<i class="bi bi-gear-fill"></i>
|
|
2999
|
+
</button>
|
|
3000
|
+
` : ""}
|
|
3001
|
+
</div>
|
|
3002
|
+
` : ""}
|
|
2931
3003
|
<div class="card-body p-3">
|
|
2932
3004
|
<div data-container="chart-header"></div>
|
|
2933
3005
|
<div data-container="chart"></div>
|
|
@@ -2936,6 +3008,10 @@ class MetricsMiniChartWidget extends View {
|
|
|
2936
3008
|
`;
|
|
2937
3009
|
}
|
|
2938
3010
|
async onBeforeDestroy() {
|
|
3011
|
+
if (this._settingsView) {
|
|
3012
|
+
await this._settingsView.destroy();
|
|
3013
|
+
this._settingsView = null;
|
|
3014
|
+
}
|
|
2939
3015
|
if (this._settingsPopover) {
|
|
2940
3016
|
this._settingsPopover.dispose();
|
|
2941
3017
|
this._settingsPopover = null;
|
|
@@ -2951,184 +3027,113 @@ class MetricsMiniChartWidget extends View {
|
|
|
2951
3027
|
*/
|
|
2952
3028
|
_initSettingsPopover() {
|
|
2953
3029
|
const button = this.element.querySelector("[data-settings-trigger]");
|
|
2954
|
-
if (!button)
|
|
2955
|
-
|
|
2956
|
-
|
|
3030
|
+
if (!button) return;
|
|
3031
|
+
if (this._settingsView) {
|
|
3032
|
+
this._settingsView.destroy();
|
|
3033
|
+
this._settingsView = null;
|
|
2957
3034
|
}
|
|
2958
3035
|
if (this._settingsPopover) {
|
|
2959
|
-
|
|
2960
|
-
this._settingsPopover.dispose();
|
|
2961
|
-
} catch (e) {
|
|
2962
|
-
console.warn("Error disposing popover:", e);
|
|
2963
|
-
}
|
|
3036
|
+
this._settingsPopover.dispose();
|
|
2964
3037
|
this._settingsPopover = null;
|
|
2965
3038
|
}
|
|
2966
|
-
|
|
3039
|
+
if (this._popoverShownHandler) {
|
|
3040
|
+
button.removeEventListener("shown.bs.popover", this._popoverShownHandler);
|
|
3041
|
+
}
|
|
3042
|
+
this._settingsView = new SettingsView({
|
|
3043
|
+
granularity: this.chartOptions.granularity,
|
|
3044
|
+
chartType: this.chartOptions.chartType,
|
|
3045
|
+
dateStart: this.chartOptions.dateStart,
|
|
3046
|
+
dateEnd: this.chartOptions.dateEnd,
|
|
3047
|
+
showDateRange: this.showDateRange
|
|
3048
|
+
});
|
|
3049
|
+
this._settingsView.on("settings:apply", (data) => this._handleSettingsApply(data));
|
|
3050
|
+
this._settingsView.on("settings:cancel", () => this._handleSettingsCancel());
|
|
3051
|
+
this._settingsView.render();
|
|
3052
|
+
this._popoverShownHandler = () => {
|
|
3053
|
+
const popoverBody = document.querySelector(".popover.show .popover-body");
|
|
3054
|
+
if (popoverBody && this._settingsView) {
|
|
3055
|
+
popoverBody.innerHTML = "";
|
|
3056
|
+
popoverBody.appendChild(this._settingsView.element);
|
|
3057
|
+
this._settingsView.bindEvents();
|
|
3058
|
+
}
|
|
3059
|
+
};
|
|
2967
3060
|
this._settingsPopover = new bootstrap.Popover(button, {
|
|
2968
|
-
content,
|
|
3061
|
+
content: "<div>Loading...</div>",
|
|
2969
3062
|
html: true,
|
|
2970
3063
|
placement: "bottom",
|
|
2971
3064
|
trigger: "click",
|
|
2972
3065
|
sanitize: false,
|
|
2973
3066
|
customClass: "metrics-chart-settings-popover"
|
|
2974
3067
|
});
|
|
2975
|
-
button.addEventListener("shown.bs.popover",
|
|
2976
|
-
setTimeout(() => {
|
|
2977
|
-
this._attachSettingsHandlers();
|
|
2978
|
-
}, 10);
|
|
2979
|
-
});
|
|
2980
|
-
button.addEventListener("inserted.bs.popover", () => {
|
|
2981
|
-
this._attachSettingsHandlers();
|
|
2982
|
-
});
|
|
3068
|
+
button.addEventListener("shown.bs.popover", this._popoverShownHandler);
|
|
2983
3069
|
}
|
|
2984
3070
|
/**
|
|
2985
|
-
*
|
|
3071
|
+
* Handle settings apply
|
|
2986
3072
|
* @private
|
|
2987
3073
|
*/
|
|
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
|
-
});
|
|
3074
|
+
async _handleSettingsApply(data) {
|
|
3075
|
+
if (this._settingsPopover) {
|
|
3076
|
+
this._settingsPopover.hide();
|
|
3101
3077
|
}
|
|
3102
|
-
}
|
|
3103
|
-
/**
|
|
3104
|
-
* Apply all pending settings changes
|
|
3105
|
-
* @private
|
|
3106
|
-
*/
|
|
3107
|
-
async _applyPendingSettings() {
|
|
3108
|
-
if (!this._pendingSettings) return;
|
|
3109
3078
|
let hasChanges = false;
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3079
|
+
let granularityChanged = false;
|
|
3080
|
+
let datesExplicitlySet = false;
|
|
3081
|
+
if (data.dateStart && data.dateStart !== this.chartOptions.dateStart || data.dateEnd && data.dateEnd !== this.chartOptions.dateEnd) {
|
|
3082
|
+
datesExplicitlySet = true;
|
|
3083
|
+
}
|
|
3084
|
+
if (data.granularity && data.granularity !== this.chartOptions.granularity) {
|
|
3085
|
+
this.chartOptions.granularity = data.granularity;
|
|
3086
|
+
this.chart.granularity = data.granularity;
|
|
3087
|
+
granularityChanged = true;
|
|
3113
3088
|
hasChanges = true;
|
|
3114
3089
|
}
|
|
3115
|
-
if (
|
|
3116
|
-
this.chartOptions.chartType =
|
|
3117
|
-
this.chart.chartType =
|
|
3090
|
+
if (data.chartType && data.chartType !== this.chartOptions.chartType) {
|
|
3091
|
+
this.chartOptions.chartType = data.chartType;
|
|
3092
|
+
this.chart.chartType = data.chartType;
|
|
3118
3093
|
hasChanges = true;
|
|
3119
3094
|
}
|
|
3120
|
-
if (
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3095
|
+
if (datesExplicitlySet) {
|
|
3096
|
+
if (data.dateStart) {
|
|
3097
|
+
this.chartOptions.dateStart = new Date(data.dateStart);
|
|
3098
|
+
this.chart.dateStart = new Date(data.dateStart);
|
|
3099
|
+
}
|
|
3100
|
+
if (data.dateEnd) {
|
|
3101
|
+
this.chartOptions.dateEnd = new Date(data.dateEnd);
|
|
3102
|
+
this.chart.dateEnd = new Date(data.dateEnd);
|
|
3103
|
+
}
|
|
3128
3104
|
hasChanges = true;
|
|
3105
|
+
} else if (granularityChanged) {
|
|
3106
|
+
const endDate = /* @__PURE__ */ new Date();
|
|
3107
|
+
let startDate;
|
|
3108
|
+
switch (data.granularity) {
|
|
3109
|
+
case "hours":
|
|
3110
|
+
startDate = new Date(endDate.getTime() - 24 * 60 * 60 * 1e3);
|
|
3111
|
+
break;
|
|
3112
|
+
case "days":
|
|
3113
|
+
startDate = new Date(endDate.getTime() - 30 * 24 * 60 * 60 * 1e3);
|
|
3114
|
+
break;
|
|
3115
|
+
case "weeks":
|
|
3116
|
+
startDate = new Date(endDate.getTime() - 12 * 7 * 24 * 60 * 60 * 1e3);
|
|
3117
|
+
break;
|
|
3118
|
+
case "months":
|
|
3119
|
+
startDate = new Date(endDate);
|
|
3120
|
+
startDate.setMonth(startDate.getMonth() - 12);
|
|
3121
|
+
break;
|
|
3122
|
+
case "years":
|
|
3123
|
+
startDate = new Date(endDate);
|
|
3124
|
+
startDate.setFullYear(startDate.getFullYear() - 5);
|
|
3125
|
+
break;
|
|
3126
|
+
default:
|
|
3127
|
+
startDate = new Date(endDate.getTime() - 30 * 24 * 60 * 60 * 1e3);
|
|
3128
|
+
}
|
|
3129
|
+
this.chartOptions.dateStart = startDate;
|
|
3130
|
+
this.chart.dateStart = startDate;
|
|
3131
|
+
this.chartOptions.dateEnd = endDate;
|
|
3132
|
+
this.chart.dateEnd = endDate;
|
|
3129
3133
|
}
|
|
3130
3134
|
if (hasChanges) {
|
|
3131
3135
|
this._saveSettings();
|
|
3136
|
+
this._skipNextPopoverInit = true;
|
|
3132
3137
|
await this.chart.refresh();
|
|
3133
3138
|
setTimeout(() => {
|
|
3134
3139
|
if (this.showSettings && this.isMounted()) {
|
|
@@ -3136,53 +3141,37 @@ class MetricsMiniChartWidget extends View {
|
|
|
3136
3141
|
}
|
|
3137
3142
|
}, 150);
|
|
3138
3143
|
}
|
|
3139
|
-
this._pendingSettings = null;
|
|
3140
|
-
}
|
|
3141
|
-
refresh() {
|
|
3142
|
-
if (this.chart) {
|
|
3143
|
-
if (this.account) this.chart.account = this.account;
|
|
3144
|
-
this.chart.refresh();
|
|
3145
|
-
}
|
|
3146
|
-
}
|
|
3147
|
-
/**
|
|
3148
|
-
* Handle granularity change
|
|
3149
|
-
*/
|
|
3150
|
-
async onActionChangeGranularity(event, element) {
|
|
3151
|
-
const newGranularity = element.value;
|
|
3152
|
-
this.chartOptions.granularity = newGranularity;
|
|
3153
|
-
this.chart.granularity = newGranularity;
|
|
3154
|
-
this._saveSettings();
|
|
3155
|
-
await this.chart.refresh();
|
|
3156
3144
|
}
|
|
3157
3145
|
/**
|
|
3158
|
-
* Handle
|
|
3146
|
+
* Handle settings cancel
|
|
3147
|
+
* @private
|
|
3159
3148
|
*/
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
this._saveSettings();
|
|
3165
|
-
await this.chart.refresh();
|
|
3149
|
+
_handleSettingsCancel() {
|
|
3150
|
+
if (this._settingsPopover) {
|
|
3151
|
+
this._settingsPopover.hide();
|
|
3152
|
+
}
|
|
3166
3153
|
}
|
|
3167
3154
|
/**
|
|
3168
|
-
* Handle
|
|
3155
|
+
* Handle refresh button click
|
|
3169
3156
|
*/
|
|
3170
|
-
async
|
|
3171
|
-
const
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3157
|
+
async onActionRefreshChart(event, element) {
|
|
3158
|
+
const icon = element.querySelector("i");
|
|
3159
|
+
if (icon) {
|
|
3160
|
+
icon.classList.add("spin");
|
|
3161
|
+
}
|
|
3162
|
+
if (this.chart) {
|
|
3163
|
+
if (this.account) this.chart.account = this.account;
|
|
3164
|
+
await this.chart.refresh();
|
|
3165
|
+
}
|
|
3166
|
+
if (icon) {
|
|
3167
|
+
icon.classList.remove("spin");
|
|
3168
|
+
}
|
|
3176
3169
|
}
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
this.chartOptions.dateEnd = newDateEnd;
|
|
3183
|
-
this.chart.dateEnd = newDateEnd;
|
|
3184
|
-
this._saveSettings();
|
|
3185
|
-
await this.chart.refresh();
|
|
3170
|
+
refresh() {
|
|
3171
|
+
if (this.chart) {
|
|
3172
|
+
if (this.account) this.chart.account = this.account;
|
|
3173
|
+
this.chart.refresh();
|
|
3174
|
+
}
|
|
3186
3175
|
}
|
|
3187
3176
|
/**
|
|
3188
3177
|
* Load settings from localStorage
|
|
@@ -3239,4 +3228,4 @@ export {
|
|
|
3239
3228
|
MetricsMiniChart as b,
|
|
3240
3229
|
MetricsMiniChartWidget as c
|
|
3241
3230
|
};
|
|
3242
|
-
//# sourceMappingURL=MetricsMiniChartWidget-
|
|
3231
|
+
//# sourceMappingURL=MetricsMiniChartWidget-DaP5lSll.js.map
|