@ -10,6 +10,9 @@ import { Alias } from '../model/alias';
import { WhereCardComponent } from '../where-card/where-card.component' ;
import { WhereCardComponent } from '../where-card/where-card.component' ;
import { Condition } from '../model/condition' ;
import { Condition } from '../model/condition' ;
import { ColumnData } from '../model/column-data' ;
import { ColumnData } from '../model/column-data' ;
import { ClipboardModule } from '@angular/cdk/clipboard' ;
import { MatIconRegistry } from '@angular/material/icon' ;
import { DomSanitizer } from '@angular/platform-browser' ;
@Component ( {
@Component ( {
selector : 'app-create-joins-page' ,
selector : 'app-create-joins-page' ,
@ -42,12 +45,19 @@ export class CreateJoinsPageComponent implements OnInit, AfterViewInit{
passTable : String = "" ;
passTable : String = "" ;
baseAlias : Alias | undefined ;
baseAlias : Alias | undefined ;
memoAlias : Alias | undefined ;
memoAlias : Alias | undefined ;
conditionData : Condition [ ] = [ ]
conditionData : Condition [ ] = [ ] ;
newRequestData : string = "SELECT * FROM" ;
constructor (
constructor (
private infoColumnService : InfoColumnService ,
private infoColumnService : InfoColumnService ,
private infoTableService : InfoTableService
private infoTableService : InfoTableService ,
) { }
private clipboard : ClipboardModule ,
private matIconRegistry : MatIconRegistry ,
private domSanitizer : DomSanitizer
) {
this . matIconRegistry . addSvgIcon ( 'copy' , this . domSanitizer . bypassSecurityTrustResourceUrl ( '../../assets/svg/copy.svg' ) )
}
ngAfterViewInit ( ) : void {
ngAfterViewInit ( ) : void {
}
}
@ -57,6 +67,29 @@ export class CreateJoinsPageComponent implements OnInit, AfterViewInit{
this . requestInfoJoin . push ( new JoinsTableComponent ( this . infoColumnService , this . infoTableService ) ) ;
this . requestInfoJoin . push ( new JoinsTableComponent ( this . infoColumnService , this . infoTableService ) ) ;
}
}
public refreshRequestData ( ) {
this . newRequestData = "SELECT * FROM" ;
this . newRequestData += ` ${ this . baseSchema } . ${ this . baseTableName } AS ${ this . baseTableNameLowerCase } ` ;
for ( let i = 0 ; i < this . allData . length ; i ++ ) {
const join : Join = this . allData [ i ] ;
this . newRequestData += `
$ { join . joinSpec } $ { join . specificSchema } . $ { join . specificTable } AS $ { join . aliasSpecificTable } ` ;
for ( let j = 0 ; j < join . columns . length ; j ++ ) {
const allCol = join . columns [ j ] ;
this . newRequestData += `
$ { allCol . operator } $ { join . baseAlias } . $ { allCol . aliasColumn } = $ { join . aliasSpecificTable } . $ { allCol . specColumn } ` ;
}
}
for ( let i = 0 ; i < this . conditionData . length ; i ++ ) {
const cond : Condition = this . conditionData [ i ] ;
this . newRequestData += `
$ { cond . operator } $ { cond . alias } . $ { cond . column } $ { cond . condition } $ { cond . value } ` ;
}
}
public getSchemas ( ) : void {
public getSchemas ( ) : void {
this . infoTableService . getSchemas ( ) . subscribe (
this . infoTableService . getSchemas ( ) . subscribe (
( response : String [ ] ) = > {
( response : String [ ] ) = > {
@ -74,6 +107,7 @@ export class CreateJoinsPageComponent implements OnInit, AfterViewInit{
( response : InfoTable [ ] ) = > {
( response : InfoTable [ ] ) = > {
this . tablesByBaseSchemaAll = response ;
this . tablesByBaseSchemaAll = response ;
this . divideTablesAndViews ( ) ;
this . divideTablesAndViews ( ) ;
this . refreshRequestData ( ) ;
} ,
} ,
( error : HttpErrorResponse ) = > {
( error : HttpErrorResponse ) = > {
alert ( error . message )
alert ( error . message )
@ -125,6 +159,7 @@ export class CreateJoinsPageComponent implements OnInit, AfterViewInit{
this . aliasData . shift ( ) ;
this . aliasData . shift ( ) ;
this . aliasData . unshift ( this . baseAlias ) ;
this . aliasData . unshift ( this . baseAlias ) ;
}
}
this . refreshRequestData ( ) ;
}
}
public addTable ( ) {
public addTable ( ) {
@ -196,6 +231,7 @@ export class CreateJoinsPageComponent implements OnInit, AfterViewInit{
}
}
this . checkLength ( ) ;
this . checkLength ( ) ;
this . aliasData = [ . . . this . aliasData ]
this . aliasData = [ . . . this . aliasData ]
this . refreshRequestData ( ) ;
}
}
public checkLength ( ) {
public checkLength ( ) {
@ -374,7 +410,7 @@ export class CreateJoinsPageComponent implements OnInit, AfterViewInit{
} ) ;
} ) ;
}
}
this . aliasData = [ . . . this . aliasData ] ;
this . aliasData = [ . . . this . aliasData ] ;
this . refreshRequestData ( ) ;
}
}
public removeWhereCard ( i : number ) {
public removeWhereCard ( i : number ) {
@ -385,6 +421,7 @@ export class CreateJoinsPageComponent implements OnInit, AfterViewInit{
if ( this . conditionData [ 0 ] ) {
if ( this . conditionData [ 0 ] ) {
this . conditionData [ 0 ] . operator = "WHERE" ;
this . conditionData [ 0 ] . operator = "WHERE" ;
}
}
this . refreshRequestData ( ) ;
}
}
public getConditionData ( event : String [ ] , index : number ) {
public getConditionData ( event : String [ ] , index : number ) {
@ -400,6 +437,7 @@ export class CreateJoinsPageComponent implements OnInit, AfterViewInit{
} else {
} else {
this . conditionData . push ( tempCondition ) ;
this . conditionData . push ( tempCondition ) ;
}
}
this . refreshRequestData ( ) ;
}
}
public checkValue ( event : any ) {
public checkValue ( event : any ) {