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

Commit

Permalink
TEIIDTOOLS-365 Do not allow dataservice wizard to start when there ar…
Browse files Browse the repository at this point in the history
…e no connections

- upgraded dataservices summary page to use the patternfly-ng empty state component
- added another empty state component to the dataservices summary page for when there are no connections
  • Loading branch information
elvisisking committed Mar 15, 2018
1 parent 89721a5 commit 5f0cb20
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 26 deletions.
29 changes: 15 additions & 14 deletions ngapp/src/app/dataservices/dataservices.component.html
Expand Up @@ -36,25 +36,26 @@ <h2 class="app-feature-title" i18n="@@dataservices.dataservices">Dataservices</h
</div>
<!-- List of Dataservices -->
<div class="row object-collection-page">
<div class="col-md-12 empty-state" *ngIf="isLoaded('dataservices') && allDataservices.length === 0">
<div class="blank-slate-pf">
<div class="blank-slate-pf-icon">
<span class="pficon pficon pficon-add-circle-o"></span>
<div class="row" *ngIf="isLoaded( connectionsLoadedTag) && !connectionsExist" >
<div class="col-sm-12">
<div class="form-group">
<pfng-empty-state
[config]="noConnectionsEmptyConfig"
(onActionSelect)="onNewConnection()"></pfng-empty-state>
</div>
</div>
<h1 i18n="@@dataservices.noDataservicesFound">No Dataservices Found</h1>
<p i18n="@@dataservices.noDataservicesFoundPleaseClick">
No Dataservices were found - please click below to create a new Dataservice!
</p>
<div class="blank-slate-pf-main-action">
<div class="btn-group">
<a i18n="@@dataservices.addDataservice" class="btn btn-primary btn-lg" (click)="onNew()">Add Dataservice</a>
</div>
<div class="row" *ngIf="connectionsExist && isLoaded('dataservices') && allDataservices.length === 0" >
<div class="col-sm-12">
<div class="form-group">
<pfng-empty-state
[config]="noDataservicesEmptyConfig"
(onActionSelect)="onNew()"></pfng-empty-state>
</div>
</div>
</div>
</div>

<!-- The 'loading Dataservices' card -->
<div class="col-md-12" *ngIf="!isLoaded('dataservices')">
<div class="col-md-12" *ngIf="!isLoaded('dataservices') || !isLoaded( connectionsLoadedTag )">
<div class="container-fluid container-cards-pf">
<div class="row row-cards-pf">
<div class="card-pf card-pf-accented">
Expand Down
3 changes: 3 additions & 0 deletions ngapp/src/app/dataservices/dataservices.component.spec.ts
Expand Up @@ -3,6 +3,8 @@ import { FormsModule } from "@angular/forms";
import { HttpModule } from "@angular/http";
import { By } from "@angular/platform-browser";
import { RouterTestingModule } from "@angular/router/testing";
import { ConnectionService } from "@connections/shared/connection.service";
import { MockConnectionService } from "@connections/shared/mock-connection.service";
import { AppSettingsService } from "@core/app-settings.service";
import { CoreModule } from "@core/core.module";
import { MockAppSettingsService } from "@core/mock-app-settings.service";
Expand Down Expand Up @@ -44,6 +46,7 @@ describe("DataservicesComponent", () => {
NotifierService,
WizardService,
{ provide: AppSettingsService, useClass: MockAppSettingsService },
{ provide: ConnectionService, useClass: MockConnectionService },
{ provide: DataserviceService, useClass: MockDataserviceService },
{ provide: VdbService, useClass: MockVdbService }
]
Expand Down
111 changes: 99 additions & 12 deletions ngapp/src/app/dataservices/dataservices.component.ts
Expand Up @@ -17,6 +17,8 @@

import { Component, OnInit, ViewChild } from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { ConnectionService } from "@connections/shared/connection.service";
import { ConnectionsConstants } from "@connections/shared/connections-constants";
import { AppSettingsService } from "@core/app-settings.service";
import { LoggerService } from "@core/logger.service";
import { Dataservice } from "@dataservices/shared/dataservice.model";
Expand All @@ -32,18 +34,21 @@ import { AbstractPageComponent } from "@shared/abstract-page.component";
import { ConfirmDeleteComponent } from "@shared/confirm-delete/confirm-delete.component";
import { LayoutType } from "@shared/layout-type.enum";
import { SortDirection } from "@shared/sort-direction.enum";
import { NotificationType } from "patternfly-ng";
import {
ActionConfig,
EmptyStateConfig,
Filter,
FilterConfig,
FilterEvent,
FilterField,
FilterType,
NotificationType,
SortConfig,
SortEvent,
SortField
} from "patternfly-ng";
import { Subscription } from "rxjs/Subscription";

import { Filter } from "patternfly-ng";
import { FilterConfig } from "patternfly-ng";
import { FilterField } from "patternfly-ng";
import { FilterEvent } from "patternfly-ng";
import { FilterType } from "patternfly-ng";
import { SortConfig } from "patternfly-ng";
import { SortField } from "patternfly-ng";
import { SortEvent } from "patternfly-ng";

@Component({
moduleId: module.id,
selector: "app-dataservices",
Expand All @@ -55,20 +60,28 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
public readonly exportInProgressHeader: string = "Publishing: ";
public readonly exportSuccessHeader: string = "Publish Succeeded: ";
public readonly exportFailedHeader: string = "Publish Failed: ";

public readonly connectionsLoadedTag = "connections";

public filterConfig: FilterConfig;
public filtersText = "";
public items: Dataservice[];
public sortConfig: SortConfig;
public currentSortField: SortField;
public isAscendingSort = true;

private connectionsExist = false;
private noConnectionsConfig: EmptyStateConfig;
private noDataservicesConfig: EmptyStateConfig;

private cardListAreaCss = "dataservice-summary-top-area-no-results";
private resultsAreaCss = "dataservice-summary-bottom-area-no-results";
private resultsShowing = false;
private quickLookSvcName: string;
private quickLookQueryText: string;

private allServices: Dataservice[] = [];
private connectionService: ConnectionService;
private filteredServices: Dataservice[] = [];
private selectedServices: Dataservice[] = [];
private dataserviceNameForDelete: string;
Expand All @@ -92,7 +105,7 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn

constructor(router: Router, route: ActivatedRoute, dataserviceService: DataserviceService,
logger: LoggerService, appSettingsService: AppSettingsService, wizardService: WizardService,
notifierService: NotifierService, vdbService: VdbService ) {
notifierService: NotifierService, vdbService: VdbService, connectionService: ConnectionService ) {
super(route, logger);
this.router = router;
this.appSettingsService = appSettingsService;
Expand All @@ -104,10 +117,10 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
this.dataserviceStateSubscription = this.notifierService.getDataserviceStateMap().subscribe((serviceStateMap) => {
this.onDataserviceStateChanged(serviceStateMap);
});
this.connectionService = connectionService;
}

public ngOnInit(): void {

super.ngOnInit();

this.filterConfig = {
Expand Down Expand Up @@ -140,6 +153,68 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
} as SortConfig;
}

public get noConnectionsEmptyConfig(): EmptyStateConfig {
if ( !this.noConnectionsConfig ) {
const actionConfig = {
primaryActions: [
{
id: "createConnectionActionId",
title: "Add Connection",
tooltip: "Add a connection"
}
]
} as ActionConfig;

this.noConnectionsConfig = {
actions: actionConfig,
iconStyleClass: "pficon-warning-triangle-o",
info: "No dataservices were found. In order to create a dataservice, you must first create a connection. "
+ "Please click below to create a connection.",
title: "No Dataservices Available"
} as EmptyStateConfig;
}

return this.noConnectionsConfig;
}

public get noDataservicesEmptyConfig(): EmptyStateConfig {
if ( !this.noDataservicesConfig ) {
const actionConfig = {
primaryActions: [
{
id: "createDataserviceActionId",
title: "Add Dataservice",
tooltip: "Add a dataservice"
}
]
} as ActionConfig;

this.noDataservicesConfig = {
actions: actionConfig,
iconStyleClass: "pficon-warning-triangle-o",
info: "No dataservices were found. Please click below to create a dataservice.",
title: "No Dataservices Available"
} as EmptyStateConfig;
}

return this.noDataservicesConfig;
}

public get hasConnections(): boolean {
return this.isLoaded( this.connectionsLoadedTag ) && this.connectionsExist;
}

public onNewConnection(): void {
// TODO ask Mark if this will work
this.wizardService.setEdit(false);

const link: string[] = [ ConnectionsConstants.addConnectionPath ];
this.logger.log( "[DataservicesPageComponent] Navigating to: %o", link );
this.router.navigate( link ).then(() => {
// nothing to do
} );
}

public loadAsyncPageData(): void {
const self = this;
this.dataserviceService
Expand All @@ -155,6 +230,18 @@ export class DataservicesComponent extends AbstractPageComponent implements OnIn
self.error(error, "Error getting dataservices");
}
);

this.connectionService
.getAllConnections()
.subscribe(
( connections ) => {
self.connectionsExist = connections.length !== 0;
self.loaded( self.connectionsLoadedTag );
},
( error ) => {
self.error( error, "Error getting connections" );
}
);
}

/**
Expand Down

0 comments on commit 5f0cb20

Please sign in to comment.