Skip to content

Commit

Permalink
b
Browse files Browse the repository at this point in the history
  • Loading branch information
polterguy committed Dec 20, 2023
1 parent 30e94a6 commit d4276a5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
4 changes: 2 additions & 2 deletions backend/files/misc/workflows/actions/sql-select.hl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
database-type
type:enum
default:sqlite
mandatory:bool:false
mandatory:bool:true
values
.:sqlite
.:mssql
Expand All @@ -16,7 +16,7 @@
connection-string
type:string
default:generic
mandatory:bool:false
mandatory:bool:true
database
type:string
default:magic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export class CodemirrorSqlFormlyComponent extends FieldType<FieldTypeConfig> imp
this.generalService.hideLoading();
this.databases = result;
this.connected = true;
this.formControl.setErrors(null);
this.cdn.detectChanges();
this.databaseChanged();
},
Expand All @@ -124,6 +125,7 @@ export class CodemirrorSqlFormlyComponent extends FieldType<FieldTypeConfig> imp

this.generalService.hideLoading();
this.connected = false;
this.formControl.setErrors({connected: false});
this.cdn.detectChanges();
}
});
Expand All @@ -132,16 +134,23 @@ export class CodemirrorSqlFormlyComponent extends FieldType<FieldTypeConfig> imp
private databaseChanged() {

let hintTables = (this.databases.databases || []).find((db: any) => db.name === this.model['database'])?.tables || [];

if (hintTables.length === 0) {

this.connected = false;
this.formControl.setErrors({connected: false});
this.cdn.detectChanges();

} else {

const hints = Object.fromEntries(hintTables.map((x: any) => [x.name, x.columns.map((y: any) => y.name)]));
this.cmOptions.hintOptions = {
tables: hints,
};
this.connected = true;
this.formControl.setErrors(null);
this.cdn.detectChanges();

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// Angular and system imports.
import { FormGroup } from '@angular/forms';
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';

// Utility imports
import { FormlyFieldConfig } from '@ngx-formly/core';
import { GeneralService } from 'src/app/services/general.service';
import { ConfirmationDialogComponent } from 'src/app/components/protected/common/confirmation-dialog/confirmation-dialog.component';

/**
* Modal dialog allowing you to parametrise and execute a macro.
Expand All @@ -27,7 +27,7 @@ export class ParametriseActionDialog implements OnInit {
model: any = {};

constructor(
private generalService: GeneralService,
private dialog: MatDialog,
@Inject(MAT_DIALOG_DATA) public data: any,
private refDialog: MatDialogRef<ParametriseActionDialog>) {}

Expand Down Expand Up @@ -111,9 +111,26 @@ export class ParametriseActionDialog implements OnInit {

if (!this.form.valid) {

this.generalService.showFeedback('Input is not valid', 'errorMessage');
return;
// Asking user to confirm action.
this.dialog.open(ConfirmationDialogComponent, {
width: '500px',
data: {
title: `Action is not valid`,
description: `Action has invalid arguments, are you sure you want to save it?`,
action_btn: 'Yes',
close_btn: 'No',
action_btn_color: 'warn',
}
}).afterClosed().subscribe((result: string) => {

if (result === 'confirm') {
this.refDialog.close(model);
}
});

} else {

this.refDialog.close(model);
}
this.refDialog.close(model);
}
}

0 comments on commit d4276a5

Please sign in to comment.