Skip to content

Commit

Permalink
style source database connection error
Browse files Browse the repository at this point in the history
  • Loading branch information
scottreisdorf committed Nov 29, 2018
1 parent 03a18d4 commit 7dd272c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,19 @@
</mat-form-field>

<div *ngIf="databaseConnectionError == true" fxLayout="column">
<div class="layout-padding-top-bottom">{{databaseConnectionErrorMessage}}</div>

<div fxLayout="column" fxLayoutAlign="center center" class="tc-grey-500 mat-typography">
<mat-icon color="warn" class="push-bottom-sm" style="font-size:40px;">warning</mat-icon>
<h2>{{databaseConnectionErrorObject.message}}</h2>
<h3>{{databaseConnectionErrorObject.developerMessage}}</h3>
</div>

<mat-form-field class="layout-padding-top-bottom" *ngIf="renderLoadStrategyOptions" fxFill>
<input matInput placeholder="Table Name" [(ngModel)]="tableProperty.value" (change)="onManualTableNameChange()">
<input matInput placeholder="Table Name" [(ngModel)]="tableProperty.value" (change)="onManualTableNameChange()" required>
</mat-form-field>

<mat-form-field class="layout-padding-top-bottom" *ngIf="renderLoadStrategyOptions" fxFill>
<input matInput placeholder="Fields" [(ngModel)]="fieldsProperty.value" (change)="onManualFieldNameChange()">
<input matInput placeholder="Fields" [(ngModel)]="fieldsProperty.value" (change)="onManualFieldNameChange()" required>
<mat-hint>Field names separated by a comma</mat-hint>
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class TablePropertiesComponent implements OnChanges, OnInit {
*/
databaseConnectionError = false;

databaseConnectionErrorMessage: string;
databaseConnectionErrorObject: any;

dbConnectionProperty: any;

Expand Down Expand Up @@ -492,22 +492,34 @@ export class TablePropertiesComponent implements OnChanges, OnInit {
return query ? tables.filter(this.createFilterForTable(query)) : tables;
}),
catchError<any, any[]>((error: any) => {
this.databaseConnectionError = true;
if(error && error.error && error.error.message){
this.databaseConnectionErrorMessage = error.error.message;
}
else if(error && error.message ){
this.databaseConnectionErrorMessage = error.message;
}
else {
this.databaseConnectionErrorMessage = "Unable to connecto to data source.";
}
throw error;
this.setDatabaseConnectionError(error)
return Observable.throw(error);
})
);
}
}

private setDatabaseConnectionError(error:any){
if(error && error.error && error.error.message){
this.databaseConnectionErrorObject = error.error;
}
else if(error && error.message ){
this.databaseConnectionErrorObject = error;
}
else {
this.databaseConnectionErrorObject = {message:"Unable to connect to data source ",developerMessage:null};
}
this.databaseConnectionErrorObject.message +=". You can manually enter the table and fields below";

if(this.tableProperty){
this.tableProperty.value = "";
}
if(this.fieldsProperty) {
this.fieldsProperty.value = "";
}
this.databaseConnectionError = true;
}

/**
* Turn the schema.table string into an object for template display
*/
Expand Down Expand Up @@ -562,7 +574,7 @@ export class TablePropertiesComponent implements OnChanges, OnInit {
this.tableFields = this.tableSchema.fields;
this.filteredFieldDates = this.tableFields.filter(this.filterFieldDates);
}, (error:any) => {
this.databaseConnectionError = true;
this.setDatabaseConnectionError(error);
console.error("error",error)
});
}
Expand Down Expand Up @@ -621,15 +633,16 @@ export class TablePropertiesComponent implements OnChanges, OnInit {
this.model.table.sourceTableSchema.name = this.model.table.existingTableName;
this.describingTableSchema = false;
this.hideDescribeTableSchemaDialog(dialogRef);
}, () => {
this.databaseConnectionError = true;
}, (error:any) => {
this.setDatabaseConnectionError(error)
this.describingTableSchema = false;
this.hideDescribeTableSchemaDialog(dialogRef);
});

}
}


onManualTableNameChange() {
if (this.model.table.method != 'EXISTING_TABLE') {
this.model.table.method = 'EXISTING_TABLE';
Expand All @@ -653,7 +666,7 @@ export class TablePropertiesComponent implements OnChanges, OnInit {
fieldNames.push(col.name);
});
this.model.table.sourceTableSchema.fields = [...fields];
this.feedService.setTableFields(fields);
this.model.table.setTableFields(fields)

this.model.table.sourceFieldsCommaString = fieldNames.join(",");
this.model.table.sourceFields = fieldNames.join("\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,15 @@ public Response getTableNames(@PathParam("serviceId") String serviceId, @QueryPa
tables = catalogTableManager.getTableNames(dataSource.get(), schema, tableName);
} catch (final SQLException | InvalidControllerServiceLookupException e) {
log.error("Unable to list table names for data source: {}", dataSource.get().getId(), e);
throw new InternalServerErrorException(e.getMessage(), e);
throw new InternalServerErrorException("Unable to connect to the data source", e);
}
} else {
log.info("Query for Table Names against service: {}({})", serviceName, serviceId);
try {
tables = dbcpConnectionPoolTableInfo.getTableNamesForControllerService(serviceId, serviceName, schema, tableName);
} catch (final InvalidControllerServiceLookupException e) {
log.error("Unable to list table names for controller service: {}", serviceName, e);
throw new InternalServerErrorException(e.getMessage(), e);
throw new InternalServerErrorException("Unable to connect to the data source", e);
}
}

Expand Down

0 comments on commit 7dd272c

Please sign in to comment.