Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1591 cant apply preset datasource of type merico metric system #1592

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/api",
"version": "14.3.3",
"version": "14.3.4",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
19 changes: 19 additions & 0 deletions api/src/preset/scripts/configure_datasources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class PresetDatasources {
@ValidateNested({ each: true })
@Type(() => DatabaseSource)
http: DatabaseSource[];

@ValidateNested({ each: true })
@Type(() => DatabaseSource)
merico_metric_system: DatabaseSource[];
}

async function upsert() {
Expand Down Expand Up @@ -112,6 +116,21 @@ async function upsert() {
dataSource.is_preset = true;
await datasourceRepo.save(dataSource);
}

for (const source of data.merico_metric_system) {
const { key } = validateClass(DatabaseSource, source);
const config = validateClass(BaseConfig, source.config);
let dataSource: DataSource | null;
dataSource = await datasourceRepo.findOneBy({ type: 'merico_metric_system', key });
if (!dataSource) {
dataSource = new DataSource();
dataSource.type = 'merico_metric_system';
dataSource.key = key;
}
dataSource.config = config;
dataSource.is_preset = true;
await datasourceRepo.save(dataSource);
}
await queryRunner.commitTransaction();
console.info('Finished upsert of preset datasources');
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/dashboard",
"version": "14.3.3",
"version": "14.3.4",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/root",
"version": "14.3.3",
"version": "14.3.4",
"private": true,
"workspaces": [
"api",
Expand Down
2 changes: 1 addition & 1 deletion settings-form/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtable/settings-form",
"version": "14.3.3",
"version": "14.3.4",
"license": "Apache-2.0",
"publishConfig": {
"access": "public",
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@devtable/website",
"private": true,
"license": "Apache-2.0",
"version": "14.3.3",
"version": "14.3.4",
"scripts": {
"dev": "vite",
"preview": "vite preview"
Expand Down
Loading