Skip to content

Commit

Permalink
Refactor interface definitions and formatting for improved consistenc…
Browse files Browse the repository at this point in the history
…y and readability
  • Loading branch information
simlarsen committed Nov 14, 2024
1 parent fe0dc51 commit 3b76b92
Show file tree
Hide file tree
Showing 32 changed files with 272 additions and 262 deletions.
31 changes: 15 additions & 16 deletions Common/Types/Dashboard/DashboardComponents/ComponentArgument.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
import DashboardBaseComponent from "./DashboardBaseComponent";

export enum ComponentInputType {
Text = "Text",
Date = "Date",
DateTime = "Date Time",
Boolean = "True or False",
Number = "Number",
Decimal = "Decimal",
MetricsEditor = "MetricsEditor",
LongText = "Long Text",
Text = "Text",
Date = "Date",
DateTime = "Date Time",
Boolean = "True or False",
Number = "Number",
Decimal = "Decimal",
MetricsEditor = "MetricsEditor",
LongText = "Long Text",
}


export interface ComponentArgument<T extends DashboardBaseComponent> {
name: string;
description: string;
required: boolean;
type: ComponentInputType;
id: keyof T["arguments"];
isAdvanced?: boolean | undefined;
placeholder?: string | undefined;
name: string;
description: string;
required: boolean;
type: ComponentInputType;
id: keyof T["arguments"];
isAdvanced?: boolean | undefined;
placeholder?: string | undefined;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ObjectType } from "../../JSON";
import ObjectID from "../../ObjectID";
import DashboardComponentType from "../DashboardComponentType";


export default interface DashboardBaseComponent {
_type: ObjectType.DashboardComponent;
componentId: ObjectID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export default interface DashboardChartComponent extends BaseComponent {
componentId: ObjectID;
arguments: {
metricsViewConfig?: MetricsViewConfig | undefined;
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export default interface DashboardTextComponent extends BaseComponent {
isBold: boolean;
isItalic: boolean;
isUnderline: boolean;
}

};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ export default interface DashboardValueComponent extends BaseComponent {
componentId: ObjectID;
arguments: {
metricsViewConfig?: MetricsViewConfig | undefined;
}
};
}
9 changes: 4 additions & 5 deletions Common/Types/Dashboard/DashboardComponents/Index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
enum DashboardComponentType {
Chart = 'Chart',
Value = 'Value',
Text = 'Text',
Chart = "Chart",
Value = "Value",
Text = "Text",
}


export default DashboardComponentType;
export default DashboardComponentType;
8 changes: 4 additions & 4 deletions Common/Types/Metrics/MetricAliasData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default interface MetricAliasData {
metricVariable: string;
title: string;
description: string;
}
metricVariable: string;
title: string;
description: string;
}
7 changes: 3 additions & 4 deletions Common/Types/Metrics/MetricFormulaConfigData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import MetricAliasData from "./MetricAliasData";
import MetricFormulaData from "./MetricFormulaData";

export default interface MetricFormulaConfigData {
metricAliasData: MetricAliasData;
metricFormulaData: MetricFormulaData;
}

metricAliasData: MetricAliasData;
metricFormulaData: MetricFormulaData;
}
4 changes: 2 additions & 2 deletions Common/Types/Metrics/MetricFormulaData.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export default interface MetricFormulaData {
metricFormula: string;
}
metricFormula: string;
}
10 changes: 5 additions & 5 deletions Common/Types/Metrics/MetricQueryConfigData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import MetricAliasData from "./MetricAliasData";
import MetricQueryData from "./MetricQueryData";

export interface ChartSeries {
title: string;
title: string;
}

export default interface MetricQueryConfigData {
metricAliasData: MetricAliasData;
metricQueryData: MetricQueryData;
getSeries?: ((data: AggregatedModel) => ChartSeries) | undefined;
}
metricAliasData: MetricAliasData;
metricQueryData: MetricQueryData;
getSeries?: ((data: AggregatedModel) => ChartSeries) | undefined;
}
6 changes: 3 additions & 3 deletions Common/Types/Metrics/MetricQueryData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import GroupBy from "../../UI/Utils/BaseDatabase/GroupBy";
import MetricsQuery from "./MetricsQuery";

export default interface MetricQueryData {
filterData: FilterData<MetricsQuery>;
groupBy?: GroupBy<Metric> | undefined;
}
filterData: FilterData<MetricsQuery>;
groupBy?: GroupBy<Metric> | undefined;
}
8 changes: 4 additions & 4 deletions Common/Types/Metrics/MetricsViewConfig.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import MetricFormulaConfigData from "./MetricFormulaConfigData";
import MetricQueryConfigData from "./MetricQueryConfigData";

export default interface MetricsViewConfig {
queryConfigs: Array<MetricQueryConfigData>;
formulaConfigs: Array<MetricFormulaConfigData>;
}
export default interface MetricsViewConfig {
queryConfigs: Array<MetricQueryConfigData>;
formulaConfigs: Array<MetricFormulaConfigData>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default class DashboardBaseComponentUtil {
throw new NotImplementedException();
}

public static getComponentConfigArguments(): Array<ComponentArgument<any>> {
public static getComponentConfigArguments(): Array<ComponentArgument<any>> {
return [];
}
}
23 changes: 16 additions & 7 deletions Common/Utils/Dashboard/Components/DashboardChartComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,43 @@ import DashboardChartComponent from "../../../Types/Dashboard/DashboardComponent
import { ObjectType } from "../../../Types/JSON";
import ObjectID from "../../../Types/ObjectID";
import DashboardBaseComponentUtil from "./DashboardBaseComponent";
import { ComponentArgument, ComponentInputType } from "../../../Types/Dashboard/DashboardComponents/ComponentArgument";
import {
ComponentArgument,
ComponentInputType,
} from "../../../Types/Dashboard/DashboardComponents/ComponentArgument";
import DashboardComponentType from "../../../Types/Dashboard/DashboardComponentType";

export default class DashboardChartComponentUtil extends DashboardBaseComponentUtil {
public static override getDefaultComponent(): DashboardChartComponent {
return {
_type: ObjectType.DashboardChartComponent,
_type: ObjectType.DashboardComponent,
componentType: DashboardComponentType.Chart,
widthInDashboardUnits: 12,
heightInDashboardUnits: 6,
topInDashboardUnits: 0,
leftInDashboardUnits: 0,
componentId: ObjectID.generate(),
minHeightInDashboardUnits: 3,
minWidthInDashboardUnits: 6,
arguments: {}
arguments: {},
};
}

public static override getComponentConfigArguments(): Array<ComponentArgument<DashboardChartComponent>> {
const componentArguments: Array<ComponentArgument<DashboardChartComponent>> = [];
public static override getComponentConfigArguments(): Array<
ComponentArgument<DashboardChartComponent>
> {
const componentArguments: Array<
ComponentArgument<DashboardChartComponent>
> = [];

componentArguments.push({
name: "Metrics",
description: "Please select the metrics to display on the chart",
required: true,
type: ComponentInputType.MetricsEditor,
id: "metricsViewConfig"
id: "metricsViewConfig",
});

return componentArguments;
}
}
}
30 changes: 19 additions & 11 deletions Common/Utils/Dashboard/Components/DashboardTextComponent.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { ComponentArgument, ComponentInputType } from "../../../Types/Dashboard/DashboardComponents/ComponentArgument";
import {
ComponentArgument,
ComponentInputType,
} from "../../../Types/Dashboard/DashboardComponents/ComponentArgument";
import DashboardTextComponent from "../../../Types/Dashboard/DashboardComponents/DashboardTextComponent";
import DashboardComponentType from "../../../Types/Dashboard/DashboardComponentType";
import { ObjectType } from "../../../Types/JSON";
import ObjectID from "../../../Types/ObjectID";
import DashboardBaseComponentUtil from "./DashboardBaseComponent";

export default class DashboardTextComponentUtil extends DashboardBaseComponentUtil {
public static override getDefaultComponent(): DashboardTextComponent {
return {
_type: ObjectType.DashboardTextComponent,
_type: ObjectType.DashboardComponent,
componentType: DashboardComponentType.Text,
widthInDashboardUnits: 6,
heightInDashboardUnits: 1,
topInDashboardUnits: 0,
Expand All @@ -16,24 +21,27 @@ export default class DashboardTextComponentUtil extends DashboardBaseComponentUt
text: "Hello, World!",
isBold: false,
isItalic: false,
isUnderline: false
isUnderline: false,
},
componentId: ObjectID.generate(),
minHeightInDashboardUnits: 1,
minWidthInDashboardUnits: 3
minWidthInDashboardUnits: 3,
};
}

public static override getComponentConfigArguments(): Array<ComponentArgument<DashboardTextComponent>> {
const componentArguments: Array<ComponentArgument<DashboardTextComponent>> = [];
public static override getComponentConfigArguments(): Array<
ComponentArgument<DashboardTextComponent>
> {
const componentArguments: Array<ComponentArgument<DashboardTextComponent>> =
[];

componentArguments.push({
name: "Text",
description: "The text to display",
required: true,
type: ComponentInputType.LongText,
id: "text",
placeholder: "Hello, World!"
placeholder: "Hello, World!",
});

componentArguments.push({
Expand All @@ -42,7 +50,7 @@ export default class DashboardTextComponentUtil extends DashboardBaseComponentUt
required: false,
type: ComponentInputType.Boolean,
id: "isBold",
placeholder: "false"
placeholder: "false",
});

componentArguments.push({
Expand All @@ -51,7 +59,7 @@ export default class DashboardTextComponentUtil extends DashboardBaseComponentUt
required: false,
type: ComponentInputType.Boolean,
id: "isItalic",
placeholder: "false"
placeholder: "false",
});

componentArguments.push({
Expand All @@ -60,9 +68,9 @@ export default class DashboardTextComponentUtil extends DashboardBaseComponentUt
required: false,
type: ComponentInputType.Boolean,
id: "isUnderline",
placeholder: "false"
placeholder: "false",
});

return componentArguments;
}
}
}
23 changes: 16 additions & 7 deletions Common/Utils/Dashboard/Components/DashboardValueComponent.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
import { ComponentArgument, ComponentInputType } from "../../../Types/Dashboard/DashboardComponents/ComponentArgument";
import {
ComponentArgument,
ComponentInputType,
} from "../../../Types/Dashboard/DashboardComponents/ComponentArgument";
import DashboardValueComponent from "../../../Types/Dashboard/DashboardComponents/DashboardValueComponent";
import DashboardComponentType from "../../../Types/Dashboard/DashboardComponentType";
import { ObjectType } from "../../../Types/JSON";
import ObjectID from "../../../Types/ObjectID";
import DashboardBaseComponentUtil from "./DashboardBaseComponent";

export default class DashboardValueComponentUtil extends DashboardBaseComponentUtil {
public static override getDefaultComponent(): DashboardValueComponent {
return {
_type: ObjectType.DashboardValueComponent,
_type: ObjectType.DashboardComponent,
componentType: DashboardComponentType.Value,
widthInDashboardUnits: 3,
heightInDashboardUnits: 1,
topInDashboardUnits: 0,
leftInDashboardUnits: 0,
componentId: ObjectID.generate(),
minHeightInDashboardUnits: 1,
minWidthInDashboardUnits: 1,
arguments: {}
arguments: {},
};
}

public static override getComponentConfigArguments(): Array<ComponentArgument<DashboardValueComponent>> {
const componentArguments: Array<ComponentArgument<DashboardValueComponent>> = [];
public static override getComponentConfigArguments(): Array<
ComponentArgument<DashboardValueComponent>
> {
const componentArguments: Array<
ComponentArgument<DashboardValueComponent>
> = [];

componentArguments.push({
name: "Metrics",
description: "Please select the metrics to display on the chart",
required: true,
type: ComponentInputType.MetricsEditor,
id: "metricsViewConfig"
id: "metricsViewConfig",
});

return componentArguments;
}
}
}
Loading

0 comments on commit 3b76b92

Please sign in to comment.