Skip to content

Commit

Permalink
Fix crash during dashboard loading
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBurgess committed Nov 18, 2024
1 parent f199cea commit c0da393
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions ui/dashboard/src/components/dashboards/data/CardDataProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ export class CardDataProcessor {
getDefaultState = (
status: DashboardRunState,
properties: CardProperties,
display_type: CardType | undefined
display_type: CardType | undefined,
): CardState => {
return {
loading: status === "running" || !!properties.loading,
label: properties.label || null,
value: isNumber(properties.value)
? properties.value.toLocaleString()
: properties.value || null,
value_number: isNumber(properties.value) ? properties.value : null,
loading: status === "running" || !!properties?.loading,
label: properties?.label || null,
value: isNumber(properties?.value)
? properties?.value.toLocaleString()
: properties?.value || null,
value_number: isNumber(properties?.value) ? properties?.value : null,
type: display_type || null,
icon: getIconForType(display_type, properties.icon),
href: properties.href || null,
icon: getIconForType(display_type, properties?.icon),
href: properties?.href || null,
};
};

Expand All @@ -65,15 +65,15 @@ export class CardDataProcessor {
diff_panel: PanelDefinition | undefined,
display_type: CardType | undefined,
properties: CardProperties,
status: DashboardRunState
status: DashboardRunState,
): CardState {
if (!data || !hasData(data)) {
const state = this.getDefaultState(status, properties, display_type);
if (!!diff_panel && !!diff_panel.properties) {
const diffState = this.getDefaultState(
status,
diff_panel.properties,
display_type
display_type,
);
state.diff = this.diff(properties, state, diffState) as CardDiffState;
}
Expand All @@ -86,7 +86,7 @@ export class CardDataProcessor {
const diffState = this.parseData(
diff_panel.data,
display_type,
properties
properties,
);
state.diff = this.diff(properties, state, diffState) as CardDiffState;
}
Expand All @@ -96,7 +96,7 @@ export class CardDataProcessor {
parseData(
data: LeafNodeData,
display_type: CardType | undefined,
properties: CardProperties
properties: CardProperties,
): CardState {
const dataFormat = this.getDataFormat(data);
if (dataFormat === "simple") {
Expand Down Expand Up @@ -138,7 +138,7 @@ export class CardDataProcessor {
type: formalType || display_type || null,
icon: getIconForType(
formalType || display_type,
formalIcon || properties.icon
formalIcon || properties.icon,
),
href: formalHref || properties.href || null,
};
Expand All @@ -148,7 +148,7 @@ export class CardDataProcessor {
diff(
properties: IDiffProperties,
state: CardState,
previous_state: CardState
previous_state: CardState,
): CardDiffState {
// If the columns aren't numeric then we can't diff...
if (state.value_number === null || previous_state.value_number === null) {
Expand Down

0 comments on commit c0da393

Please sign in to comment.