-
-
-
-
-
-
- No tables selected
-
-
-
diff --git a/ngapp/src/app/dataservices/jdbc-table-selector/jdbc-table-selector.component.spec.ts b/ngapp/src/app/dataservices/jdbc-table-selector/jdbc-table-selector.component.spec.ts
index 18dc91f3..bdd7406c 100644
--- a/ngapp/src/app/dataservices/jdbc-table-selector/jdbc-table-selector.component.spec.ts
+++ b/ngapp/src/app/dataservices/jdbc-table-selector/jdbc-table-selector.component.spec.ts
@@ -7,6 +7,11 @@ import { MockConnectionService } from "@connections/shared/mock-connection.servi
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
import { SelectedTableComponent } from "@dataservices/selected-table/selected-table.component";
+import { DataserviceService } from "@dataservices/shared/dataservice.service";
+import { MockDataserviceService } from "@dataservices/shared/mock-dataservice.service";
+import { MockVdbService } from "@dataservices/shared/mock-vdb.service";
+import { NotifierService } from "@dataservices/shared/notifier.service";
+import { VdbService } from "@dataservices/shared/vdb.service";
import { JdbcTableSelectorComponent } from "./jdbc-table-selector.component";
describe("JdbcTableSelectorComponent", () => {
@@ -18,8 +23,10 @@ describe("JdbcTableSelectorComponent", () => {
imports: [ FormsModule, HttpModule ],
declarations: [ JdbcTableSelectorComponent, SelectedTableComponent ],
providers: [
- AppSettingsService, LoggerService,
+ AppSettingsService, LoggerService, NotifierService,
{ provide: ConnectionService, useClass: MockConnectionService },
+ { provide: DataserviceService, useClass: MockDataserviceService },
+ { provide: VdbService, useClass: MockVdbService },
]
})
.compileComponents().then(() => {
@@ -34,6 +41,7 @@ describe("JdbcTableSelectorComponent", () => {
});
it("should be created", () => {
+ console.log("========== [JdbcTableSelectorComponent] should be created");
expect(component).toBeTruthy();
});
});
diff --git a/ngapp/src/app/dataservices/jdbc-table-selector/jdbc-table-selector.component.ts b/ngapp/src/app/dataservices/jdbc-table-selector/jdbc-table-selector.component.ts
index 20c20343..1bca40ad 100644
--- a/ngapp/src/app/dataservices/jdbc-table-selector/jdbc-table-selector.component.ts
+++ b/ngapp/src/app/dataservices/jdbc-table-selector/jdbc-table-selector.component.ts
@@ -16,15 +16,16 @@
*/
import { Component, OnInit } from "@angular/core";
+import { Input } from "@angular/core";
import { EventEmitter } from "@angular/core";
import { Output } from "@angular/core";
-import { Input } from "@angular/core";
import { Connection } from "@connections/shared/connection.model";
import { ConnectionService } from "@connections/shared/connection.service";
import { JdbcTableFilter } from "@connections/shared/jdbc-table-filter.model";
import { SchemaInfo } from "@connections/shared/schema-info.model";
import { LoggerService } from "@core/logger.service";
import { CatalogSchema } from "@dataservices/shared/catalog-schema.model";
+import { DataserviceService } from "@dataservices/shared/dataservice.service";
import { TableSelector } from "@dataservices/shared/table-selector";
import { Table } from "@dataservices/shared/table.model";
import { LoadingState } from "@shared/loading-state.enum";
@@ -38,18 +39,21 @@ import { LoadingState } from "@shared/loading-state.enum";
export class JdbcTableSelectorComponent implements OnInit, TableSelector {
@Input() public connection: Connection;
- @Output() public tableSelectionChanged: EventEmitter
= new EventEmitter();
+ @Output() public tableSelectionAdded: EventEmitter = new EventEmitter();
+ @Output() public tableSelectionRemoved: EventEmitter = new EventEmitter();
private connectionService: ConnectionService;
+ private dataserviceService: DataserviceService;
private logger: LoggerService;
private schemas: CatalogSchema[] = [];
private tables: Table[] = [];
- private selectedSchemas: CatalogSchema[] = [];
+ private currentSchema: CatalogSchema = null;
private schemaLoadingState: LoadingState = LoadingState.LOADING;
private tableLoadingState: LoadingState = LoadingState.LOADING;
- constructor( connectionService: ConnectionService, logger: LoggerService ) {
+ constructor( connectionService: ConnectionService, dataserviceService: DataserviceService, logger: LoggerService ) {
this.connectionService = connectionService;
+ this.dataserviceService = dataserviceService;
this.logger = logger;
}
@@ -63,10 +67,11 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
* @param {Connection} conn the jdbc connection
*/
public setConnection(conn: Connection): void {
+ this.clearSchemas();
+ this.clearTables();
if (conn && conn.isJdbc()) {
this.connection = conn;
// Load the schema info for a connection
- this.schemas = [];
this.schemaLoadingState = LoadingState.LOADING;
const self = this;
this.connectionService
@@ -82,25 +87,31 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
}
);
} else {
- this.schemas = [];
this.schemaLoadingState = LoadingState.LOADING;
}
}
+ public clearSchemas(): void {
+ this.schemas = [];
+ this.currentSchema = null;
+ }
+
+ public clearTables(): void {
+ this.tables = [];
+ this.tableLoadingState = LoadingState.LOADING;
+ }
+
/*
* Toggle the schema selection
* @param {CatalogSchema} schema the schema that has been selected or deselected
*/
public toggleSchemaSelected(schema: CatalogSchema): void {
if (this.isSchemaSelected(schema)) {
- this.selectedSchemas.shift();
+ this.currentSchema = null;
// Deselection of schema clears tables
this.tables = [];
- this.selectedTablesChanged();
} else {
- // Only allow one item to be selected
- this.selectedSchemas.shift();
- this.selectedSchemas.push(schema);
+ this.currentSchema = schema;
const filterInfo = new JdbcTableFilter();
filterInfo.setConnectionName(this.connection.getId());
filterInfo.setCatalogFilter(schema.getCatalogName());
@@ -115,7 +126,7 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
* @param {CatalogSchema} schema the CatalogSchema to check
*/
public isSchemaSelected(schema: CatalogSchema): boolean {
- return this.selectedSchemas.indexOf(schema) !== -1;
+ return schema === this.currentSchema;
}
/*
@@ -123,7 +134,7 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
* @returns {CatalogSchema} the selected schema
*/
public get selectedSchema( ): CatalogSchema {
- return this.selectedSchemas[0];
+ return this.currentSchema;
}
/*
@@ -131,7 +142,7 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
* @returns {CatalogSchema} the selected schema
*/
public get hasSelectedSchema( ): boolean {
- return this.selectedSchemas.length > 0;
+ return this.currentSchema != null;
}
/**
@@ -231,8 +242,12 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
/*
* Handler for changes in table selection
*/
- public selectedTablesChanged( ): void {
- this.tableSelectionChanged.emit();
+ public selectedTablesChanged(table: Table): void {
+ if (table.selected) {
+ this.tableSelectionAdded.emit(table);
+ } else {
+ this.tableSelectionRemoved.emit(table);
+ }
}
/*
@@ -290,6 +305,8 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
table.setSchemaName(self.selectedSchema.getName());
self.tables.push(table);
}
+ // select any of the tables that are already selected
+ self.setInitialTableSelections();
self.tableLoadingState = LoadingState.LOADED_VALID;
},
(error) => {
@@ -299,4 +316,23 @@ export class JdbcTableSelectorComponent implements OnInit, TableSelector {
);
}
+ private setInitialTableSelections(): void {
+ for ( const table of this.tables ) {
+ // const catName = table.getCatalogName();
+ const schemaName = table.getSchemaName();
+ const tableName = table.getName();
+ const connName = table.getConnection().getId();
+ for ( const initialTable of this.dataserviceService.getWizardSelectedTables() ) {
+ // const iCatName = initialTable.getCatalogName();
+ const iSchemaName = initialTable.getSchemaName();
+ const iTableName = initialTable.getName();
+ const iConnName = initialTable.getConnection().getId();
+ if (iConnName === connName && iTableName === tableName && iSchemaName === schemaName ) {
+ table.selected = true;
+ break;
+ }
+ }
+ }
+ }
+
}
diff --git a/ngapp/src/app/dataservices/selected-table/selected-table.component.spec.ts b/ngapp/src/app/dataservices/selected-table/selected-table.component.spec.ts
index c28990f2..be27c518 100644
--- a/ngapp/src/app/dataservices/selected-table/selected-table.component.spec.ts
+++ b/ngapp/src/app/dataservices/selected-table/selected-table.component.spec.ts
@@ -1,6 +1,6 @@
import { async, ComponentFixture, TestBed } from "@angular/core/testing";
-import { Connection } from "../../connections/shared/connection.model";
+import { Connection } from "@connections/shared/connection.model";
import { Table } from "../shared/table.model";
import { SelectedTableComponent } from "./selected-table.component";
diff --git a/ngapp/src/app/dataservices/selected-table/selected-table.component.ts b/ngapp/src/app/dataservices/selected-table/selected-table.component.ts
index 83baf9d3..dba7d5c7 100644
--- a/ngapp/src/app/dataservices/selected-table/selected-table.component.ts
+++ b/ngapp/src/app/dataservices/selected-table/selected-table.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input, OnInit } from "@angular/core";
+import { Component, EventEmitter, Input, OnInit, Output } from "@angular/core";
import { Table } from "@dataservices/shared/table.model";
@Component({
@@ -9,6 +9,7 @@ import { Table } from "@dataservices/shared/table.model";
export class SelectedTableComponent implements OnInit {
@Input() public table: Table;
+ @Output() public selectionListTableRemoved: EventEmitter = new EventEmitter();
constructor() {
// nothing to do
@@ -20,5 +21,6 @@ export class SelectedTableComponent implements OnInit {
public onRemove(): void {
this.table.selected = false;
+ this.selectionListTableRemoved.emit(this.table);
}
}
diff --git a/ngapp/src/app/dataservices/shared/dataservice.service.ts b/ngapp/src/app/dataservices/shared/dataservice.service.ts
index a9ea03e6..d73f8950 100644
--- a/ngapp/src/app/dataservices/shared/dataservice.service.ts
+++ b/ngapp/src/app/dataservices/shared/dataservice.service.ts
@@ -51,10 +51,12 @@ export class DataserviceService extends ApiService {
private http: Http;
private notifierService: NotifierService;
+ private appSettingsService: AppSettingsService;
private vdbService: VdbService;
private selectedDataservice: Dataservice;
private cachedDataserviceStates: Map = new Map();
private updatesSubscription: Subscription;
+ private wizardSelectedTablesArray: Table[] = [];
constructor(http: Http, vdbService: VdbService, appSettings: AppSettingsService,
notifierService: NotifierService, logger: LoggerService ) {
@@ -62,6 +64,7 @@ export class DataserviceService extends ApiService {
this.http = http;
this.notifierService = notifierService;
this.vdbService = vdbService;
+ this.appSettingsService = appSettings;
// Polls to fire Dataservice state updates every minute
this.pollDataserviceStatus(60);
}
@@ -86,7 +89,7 @@ export class DataserviceService extends ApiService {
* Validates the specified data service name. If the name contains valid characters and the name is unique, the
* service returns 'null'. Otherwise, a 'string' containing an error message is returned.
*
- * @param {string} dataserviceName
+ * @param {string} name the dataservice name
* @returns {Observable}
*/
public isValidName( name: string ): Observable< string > {
@@ -372,6 +375,77 @@ export class DataserviceService extends ApiService {
});
}
+ /**
+ * Get the wizard table selections
+ * @returns {Table[]} the selections
+ */
+ public getWizardSelectedTables( ): Table[] {
+ return this.wizardSelectedTablesArray;
+ }
+
+ /**
+ * Clears the list of wizard table selections
+ */
+ public clearWizardSelectedTables( ): void {
+ this.wizardSelectedTablesArray = [];
+ }
+
+ /**
+ * Determine if the supplied table is one of the current selections in the wizard
+ * @param {Table} table the table
+ */
+ public isWizardSelectedTable(table: Table): boolean {
+ return this.getWizardTableIndex(table) > -1;
+ }
+
+ /**
+ * Add a table to the current wizard selections
+ * @param {Table} tableToAdd table to add
+ */
+ public addToWizardSelectionTables(tableToAdd: Table): void {
+ if (!this.isWizardSelectedTable(tableToAdd)) {
+ this.wizardSelectedTablesArray.push(tableToAdd);
+ }
+ }
+
+ /**
+ * Remove a table from the current wizard selections
+ * @param {Table} tableToRemove
+ * @returns {boolean}
+ */
+ public removeFromWizardSelectionTables(tableToRemove: Table): boolean {
+ let wasRemoved = false;
+
+ const index = this.getWizardTableIndex(tableToRemove);
+ if (index > -1) {
+ this.wizardSelectedTablesArray.splice(index, 1);
+ wasRemoved = true;
+ }
+
+ return wasRemoved;
+ }
+
+ /**
+ * Find index of the table in the wizard selected tables list. -1 if not found
+ * @param {Table} table
+ * @returns {number}
+ */
+ private getWizardTableIndex(table: Table): number {
+ // supplied table and connection
+ const connName = table.getConnection().getId();
+ const tableName = table.getName();
+ let i = 0;
+ for (const wizTable of this.wizardSelectedTablesArray) {
+ const wizTableName = wizTable.getName();
+ const wizConnName = wizTable.getConnection().getId();
+ if (wizTableName === tableName && wizConnName === connName) {
+ return i;
+ }
+ i++;
+ }
+ return -1;
+ }
+
/*
* Get updates for the provided array of Dataservices and broadcast the map of states
* @param {Dataservice[]} services the array of Dataservices
diff --git a/ngapp/src/app/dataservices/shared/mock-dataservice.service.ts b/ngapp/src/app/dataservices/shared/mock-dataservice.service.ts
index 794991ec..431e1d86 100644
--- a/ngapp/src/app/dataservices/shared/mock-dataservice.service.ts
+++ b/ngapp/src/app/dataservices/shared/mock-dataservice.service.ts
@@ -16,7 +16,7 @@
*/
import { Injectable } from "@angular/core";
-import { Http } from "@angular/http";
+import { Http, Response } from "@angular/http";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
import { Dataservice } from "@dataservices/shared/dataservice.model";
@@ -29,6 +29,7 @@ import "rxjs/add/observable/throw";
import "rxjs/add/operator/catch";
import "rxjs/add/operator/map";
import { Observable } from "rxjs/Observable";
+import { ErrorObservable } from "rxjs/observable/ErrorObservable";
@Injectable()
export class MockDataserviceService extends DataserviceService {
@@ -104,4 +105,20 @@ export class MockDataserviceService extends DataserviceService {
// Nothing to do
}
+ /**
+ * Query a Dataservice via the komodo rest interface
+ * @param {string} query the SQL query
+ * @param {string} dataserviceName the dataservice name
+ * @param {number} limit the limit for the number of result rows
+ * @param {number} offset the offset for the result rows
+ * @returns {Observable}
+ */
+ public queryDataservice(query: string, dataserviceName: string, limit: number, offset: number): Observable {
+ return Observable.of();
+ }
+
+ protected handleError(error: Response): ErrorObservable {
+ return Observable.throw(error);
+ }
+
}
diff --git a/ngapp/src/app/dataservices/sql-control/sql-control.component.spec.ts b/ngapp/src/app/dataservices/sql-control/sql-control.component.spec.ts
index 53d58283..e7d74c3c 100644
--- a/ngapp/src/app/dataservices/sql-control/sql-control.component.spec.ts
+++ b/ngapp/src/app/dataservices/sql-control/sql-control.component.spec.ts
@@ -41,6 +41,7 @@ describe("SqlControlComponent", () => {
});
it("should be created", () => {
+ console.log("========== [SqlControlComponent] should be created");
expect(component).toBeTruthy();
});
});
diff --git a/ngapp/src/app/dataservices/test-dataservice/test-dataservice.component.spec.ts b/ngapp/src/app/dataservices/test-dataservice/test-dataservice.component.spec.ts
index 79f38acc..455c3104 100644
--- a/ngapp/src/app/dataservices/test-dataservice/test-dataservice.component.spec.ts
+++ b/ngapp/src/app/dataservices/test-dataservice/test-dataservice.component.spec.ts
@@ -39,6 +39,7 @@ describe("TestDataserviceComponent", () => {
});
it("should be created", () => {
+ console.log("========== [TestDataserviceComponent] should be created");
expect(component).toBeTruthy();
});
});
diff --git a/ngapp/src/app/shared/confirm-delete/confirm-delete.component.spec.ts b/ngapp/src/app/shared/confirm-delete/confirm-delete.component.spec.ts
index 932c770b..9d7dedeb 100644
--- a/ngapp/src/app/shared/confirm-delete/confirm-delete.component.spec.ts
+++ b/ngapp/src/app/shared/confirm-delete/confirm-delete.component.spec.ts
@@ -23,6 +23,7 @@ describe("ConfirmDeleteComponent", () => {
});
it("should be created", () => {
+ console.log("========== [ConfirmDeleteComponent] should be created");
expect(component).toBeTruthy();
});
});
diff --git a/ngapp/src/app/shared/page-error/page-error.component.spec.ts b/ngapp/src/app/shared/page-error/page-error.component.spec.ts
index a086b02c..9938b625 100644
--- a/ngapp/src/app/shared/page-error/page-error.component.spec.ts
+++ b/ngapp/src/app/shared/page-error/page-error.component.spec.ts
@@ -24,6 +24,7 @@ describe("PageErrorComponent", () => {
});
it("should be created", () => {
+ console.log("========== [PageErrorComponent] should be created");
expect(component).toBeTruthy();
});
});
diff --git a/ngapp/src/app/shared/page-not-found/page-not-found.component.spec.ts b/ngapp/src/app/shared/page-not-found/page-not-found.component.spec.ts
index 078092d5..f2c135f3 100644
--- a/ngapp/src/app/shared/page-not-found/page-not-found.component.spec.ts
+++ b/ngapp/src/app/shared/page-not-found/page-not-found.component.spec.ts
@@ -21,6 +21,7 @@ describe("PageNotFoundComponent", () => {
});
it("should be created", () => {
+ console.log("========== [PageNotFoundComponent] should be created");
expect(component).toBeTruthy();
});
});
diff --git a/ngapp/src/app/shared/property-form/property-form.component.spec.ts b/ngapp/src/app/shared/property-form/property-form.component.spec.ts
index 821dc23a..80233727 100644
--- a/ngapp/src/app/shared/property-form/property-form.component.spec.ts
+++ b/ngapp/src/app/shared/property-form/property-form.component.spec.ts
@@ -41,6 +41,7 @@ describe("PropertyFormComponent", () => {
});
it("should be created", () => {
+ console.log("========== [PropertyFormComponent] should be created");
expect(component).toBeTruthy();
});
});
diff --git a/ngapp/src/styles.css b/ngapp/src/styles.css
index 47262e20..bedc1662 100644
--- a/ngapp/src/styles.css
+++ b/ngapp/src/styles.css
@@ -57,5 +57,6 @@
}
.datatable-body-row.active .datatable-row-group {
- background-color: #39a5dc !important;
+ background-color: darkblue !important;
+ color: white;
}