Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
Adapt UI to ViewEditorState
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrillin committed Aug 8, 2018
1 parent ccf4a8c commit cae2ef8
Show file tree
Hide file tree
Showing 40 changed files with 1,634 additions and 756 deletions.
28 changes: 14 additions & 14 deletions ngapp/src/app/core/selection.service.ts
Expand Up @@ -17,15 +17,15 @@

import { Injectable } from "@angular/core";
import { Dataservice } from "@dataservices/shared/dataservice.model";
import { View } from "@dataservices/shared/view.model";
import { Connection } from "@connections/shared/connection.model";
import { ViewDefinition } from "@dataservices/shared/view-definition.model";

@Injectable()
export class SelectionService {

private selectedConnection: Connection;
private selectedVirtualization: Dataservice;
private selectedView: View;
private selectedViewDefinition: ViewDefinition;
private connectionForSchemaRegen = "";

constructor() {
Expand Down Expand Up @@ -81,28 +81,28 @@ export class SelectionService {
}

/**
* Gets the selected view
* @returns {View} the selected view
* Gets the selected view definition
* @returns {ViewDefinition} the selected view definition
*/
public getSelectedView(): View {
return this.selectedView;
public getSelectedViewDefinition(): ViewDefinition {
return this.selectedViewDefinition;
}

/**
* Sets the selected view
* @param {View} view the selected view
* Sets the selected view definition
* @param {ViewDefinition} view the selected view definition
*/
public setSelectedView(virtualization: Dataservice, view: View): void {
public setSelectedViewDefinition(virtualization: Dataservice, viewDefn: ViewDefinition): void {
this.selectedVirtualization = virtualization;
this.selectedView = view;
this.selectedViewDefinition = viewDefn;
}

/**
* Determine if there is a selected view
* @returns {boolean} 'true' if a view is selected
* Determine if there is a selected view definition
* @returns {boolean} 'true' if a view definition is selected
*/
public get hasSelectedView(): boolean {
return this.selectedView && this.selectedView !== null;
public get hasSelectedViewDefinition(): boolean {
return this.selectedViewDefinition && this.selectedViewDefinition !== null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ngapp/src/app/dataservices/dataservices.component.html
Expand Up @@ -105,7 +105,7 @@ <h1 class="card-pf-title">
<span class="pull-right fa fa-fw fa-close dataservice-results-action-icon-close" (click)="setQuickLookPanelOpenState(false)"></span>
</div>
<br>
<app-sql-control [quicklook]="true" [selectedViews]="selectedViews" [serviceViews]="allServiceViews"
<app-sql-control [quicklook]="true" [selectedViews]="selectedViewNames" [serviceViews]="allServiceViewNames"
[viewSql]="quickLookSql"></app-sql-control>
</div>
<div class="col-md-12 {{resultsAreaCss}}" *ngIf="showOdataEditor">
Expand Down
32 changes: 16 additions & 16 deletions ngapp/src/app/dataservices/dataservices.component.ts
Expand Up @@ -29,7 +29,6 @@ import { DeploymentState } from "@dataservices/shared/deployment-state.enum";
import { NotifierService } from "@dataservices/shared/notifier.service";
import { PublishState } from "@dataservices/shared/publish-state.enum";
import { VdbService } from "@dataservices/shared/vdb.service";
import { View } from "@dataservices/shared/view.model";
import { Virtualization } from "@dataservices/shared/virtualization.model";
import { SqlControlComponent } from "@dataservices/sql-control/sql-control.component";
import { AbstractPageComponent } from "@shared/abstract-page.component";
Expand All @@ -51,6 +50,7 @@ import {
SortField
} from "patternfly-ng";
import { Subscription } from "rxjs/Subscription";
import { SqlView } from "@dataservices/shared/sql-view.model";

@Component({
moduleId: module.id,
Expand Down Expand Up @@ -104,8 +104,8 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
private dataserviceDeployStateSubscription: Subscription;
private dataservicePublishStateSubscription: Subscription;
private notifierService: NotifierService;
private selectedSvcViews: View[] = [];
private allSvcViews: View[] = [];
private selectedSvcViewNames: SqlView[] = [];
private allSvcViewNames: SqlView[] = [];
private modalService: BsModalService;
private selectionService: SelectionService;

Expand Down Expand Up @@ -386,17 +386,17 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
}

/**
* Accessor for all available service views
* Accessor for all available service view names
*/
public get allServiceViews( ): View[] {
return this.allSvcViews;
public get allServiceViewNames( ): SqlView[] {
return this.allSvcViewNames;
}

/**
* Accessor for selected service view
* Accessor for selected service view names
*/
public get selectedViews( ): View[] {
return this.selectedSvcViews;
public get selectedViewNames( ): SqlView[] {
return this.selectedSvcViewNames;
}

/**
Expand Down Expand Up @@ -455,9 +455,9 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
public onTest(svcName: string): void {
const selectedService = this.filteredDataservices.find((x) => x.getId() === svcName);
this.dataserviceService.setSelectedDataservice(selectedService);
this.allSvcViews = this.dataserviceService.getSelectedDataserviceViews();
this.selectedSvcViews = [];
this.selectedSvcViews.push(this.allServiceViews[0]);
this.allSvcViewNames = this.dataserviceService.getSelectedDataserviceViewNames();
this.selectedSvcViewNames = [];
this.selectedSvcViewNames.push(this.allServiceViewNames[0]);

this.closeLookPanels();

Expand Down Expand Up @@ -601,10 +601,10 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
public onQuickLook(svcName: string): void {
const selectedService = this.filteredDataservices.find((x) => x.getId() === svcName);
this.dataserviceService.setSelectedDataservice(selectedService);
this.allSvcViews = this.dataserviceService.getSelectedDataserviceViews();
this.selectedSvcViews = [];
this.selectedSvcViews.push(this.allServiceViews[0]);
const viewName = this.selectedSvcViews[0].getName();
this.allSvcViewNames = this.dataserviceService.getSelectedDataserviceViewNames();
this.selectedSvcViewNames = [];
this.selectedSvcViewNames.push(this.allServiceViewNames[0]);
const viewName = this.selectedSvcViewNames[0];
this.quickLookQueryText = "SELECT * FROM " + viewName + ";";

if (!this.resultsShowing) {
Expand Down
5 changes: 2 additions & 3 deletions ngapp/src/app/dataservices/shared/composition.model.spec.ts
@@ -1,6 +1,5 @@
import { Composition } from "@dataservices/shared/composition.model";
import { CompositionType } from "@dataservices/shared/composition-type.enum";
import { Column } from "@dataservices/shared/column.model";
import { CompositionOperator } from "@dataservices/shared/composition-operator.enum";

describe("Composition", () => {
Expand All @@ -25,8 +24,8 @@ describe("Composition", () => {
expect(composition.getName()).toEqual("myView");
expect(composition.getLeftSourcePath()).toEqual("leftPath");
expect(composition.getRightSourcePath()).toEqual("rightPath");
expect(composition.getType()).toEqual("INNER_JOIN");
expect(composition.getOperator()).toEqual("EQ");
expect(composition.getType()).toEqual(CompositionType.INNER_JOIN);
expect(composition.getOperator()).toEqual(CompositionOperator.EQ);

const json = composition.toJSON();

Expand Down
8 changes: 1 addition & 7 deletions ngapp/src/app/dataservices/shared/dataservice.model.spec.ts
Expand Up @@ -21,16 +21,11 @@ describe("Dataservice", () => {
"serviceVdbName": "mongovirtualizationvdb",
"serviceVdbVersion": "1",
"serviceViewModel": "views",
"serviceViews": [
"serviceViewDefinitions": [
"addressView",
"gradesView",
"restaurantsView"
],
"serviceViewTables": [
"mongoconnschemavdb.address",
"mongoconnschemavdb.grades",
"mongoconnschemavdb.restaurants"
],
"connections": 0,
"drivers": 0,
"keng___links": [
Expand Down Expand Up @@ -62,7 +57,6 @@ describe("Dataservice", () => {
expect(dataservice.getServiceVdbName()).toEqual("mongovirtualizationvdb");
expect(dataservice.getServiceVdbVersion()).toEqual("1");
expect(dataservice.getServiceViewModel()).toEqual("views");
expect(dataservice.getServiceViewTables().length).toEqual(3);
expect(dataservice.getServiceViewNames().length).toEqual(3);
expect(dataservice.getServiceDeploymentState()).toEqual(DeploymentState.LOADING);
expect(dataservice.getServicePublishState()).toEqual(PublishState.NOT_PUBLISHED);
Expand Down
49 changes: 5 additions & 44 deletions ngapp/src/app/dataservices/shared/dataservice.model.ts
Expand Up @@ -17,7 +17,6 @@

import { DeploymentState } from "@dataservices/shared/deployment-state.enum";
import { PublishState } from "@dataservices/shared/publish-state.enum";
import { View } from "@dataservices/shared/view.model";
import { Virtualization } from "@dataservices/shared/virtualization.model";
import { VirtRoute } from "@dataservices/shared/virt-route.model";
import { Identifiable } from "@shared/identifiable";
Expand All @@ -30,12 +29,10 @@ export class Dataservice implements Identifiable< string > {
private tko__description: string;
private serviceVdbName: string;
private serviceVdbVersion: string;
private serviceViews: string[];
private serviceViewDefinitions: string[];
private serviceViewModel: string;
private serviceViewTables: string[];
private deploymentState: DeploymentState = DeploymentState.LOADING;
private virtualization: Virtualization = null;
private views: View[] = [];

/**
* @param {Object} json the JSON representation of a Dataservice
Expand Down Expand Up @@ -122,8 +119,8 @@ export class Dataservice implements Identifiable< string > {
* @returns {string[]} the dataservice view names (never null or undefined)
*/
public getServiceViewNames(): string[] {
if ( this.serviceViews ) {
return this.serviceViews;
if ( this.serviceViewDefinitions ) {
return this.serviceViewDefinitions;
}

return [];
Expand All @@ -136,20 +133,6 @@ export class Dataservice implements Identifiable< string > {
return this.serviceViewModel;
}

/**
* @returns {string} the dataservice view table names array (can be null)
*/
public getServiceViewTables(): string[] {
return this.serviceViewTables;
}

/**
* @returns {View[]} the dataservice views array (never null, but can be empty)
*/
public getViews(): View[] {
return this.views;
}

/**
* @returns {string} the dataservice type name (can be null)
*/
Expand Down Expand Up @@ -318,34 +301,13 @@ export class Dataservice implements Identifiable< string > {
this.serviceVdbVersion = version;
}

/**
* @param {View[]} views the dataservice views
*/
public setViews( views: View[] ): void {
this.views = views;
}

/**
* @param {string[]} viewNames the dataservice view names
*/
public setServiceViewNames( viewNames: string[] ): void {
this.serviceViews = viewNames;
}

/**
* @param {string} viewModel the dataservice view model
*/
public setServiceViewModel( viewModel: string ): void {
this.serviceViewModel = viewModel;
}

/**
* @param {string[]} viewTables the dataservice view tables
*/
public setServiceViewTables( viewTables: string[] ): void {
this.serviceViewTables = viewTables;
}

/**
* @param {DeploymentState} state the dataservice deployment state
*/
Expand All @@ -367,9 +329,8 @@ export class Dataservice implements Identifiable< string > {
tko__description: this.tko__description,
serviceVdbName: this.serviceVdbName,
serviceVdbVersion: this.serviceVdbVersion,
serviceViews: this.serviceViews,
serviceViewModel: this.serviceViewModel,
serviceViewTables: this.serviceViewTables
serviceViews: this.serviceViewDefinitions,
serviceViewModel: this.serviceViewModel
};
}

Expand Down

0 comments on commit cae2ef8

Please sign in to comment.