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

Commit

Permalink
Merge pull request #182 from mdrillin/viewEditorFix
Browse files Browse the repository at this point in the history
TEIIDTOOLS-499 - Adds spinner during view operations.
  • Loading branch information
mdrillin committed Oct 2, 2018
2 parents bb627e3 + 542bbe4 commit 356a6ac
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 30 deletions.
44 changes: 22 additions & 22 deletions ngapp/src/app/dataservices/dataservices.component.html
Expand Up @@ -36,24 +36,32 @@ <h2 class="app-feature-title" i18n="@@dataservices.dataservices">Data Virtualiza
</div>
<!-- List of Dataservices -->
<div class="row object-collection-page">
<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 class="dataservices-toast">
<!-- Toast Notification for Dataservice operations -->
<pfng-toast-notification *ngIf="showToastNotification" [header]="toastNotificationHeader"
[message]="toastNotificationMessage"
[type]="toastNotificationType">
</pfng-toast-notification>
</div>

<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>
<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 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>
<!-- The 'loading Dataservices' card -->
<div class="col-md-12" *ngIf="!isLoaded('dataservices') || !isLoaded( connectionsLoadedTag )">
<div class="container-fluid container-cards-pf">
Expand All @@ -71,14 +79,6 @@ <h1 class="card-pf-title">

<!-- The list or card view -->
<div class="col-md-12" *ngIf="isLoaded('dataservices')">
<div class="dataservices-toast">
<!-- Toast Notification for Dataservice operations -->
<pfng-toast-notification *ngIf="showToastNotification" [header]="toastNotificationHeader"
[message]="toastNotificationMessage"
[type]="toastNotificationType">
</pfng-toast-notification>
</div>

<div class="{{cardListAreaCss}}">
<app-dataservices-list *ngIf="isListLayout && hasDataservices" [dataservices]="filteredDataservices" [selectedDataservices]="selectedDataservices"
(activateDataservice)="onActivate($event)" (testDataservice)="onTest($event)"
Expand Down
Expand Up @@ -14,7 +14,7 @@ <h4>Virtualization Name: '{{virtualizationName}}'</h4>
<div class="col-sm-1">
<span class="pull-right"><strong>Views:</strong></span>
</div>
<div class="col-sm-2 view-table-div" id="view-editor-header-table">
<div class="col-sm-2 view-table-div" id="view-editor-header-table" [hidden]="viewsLoading">
<pfng-table
[columns]="tableColumns"
[config]="tableConfig"
Expand All @@ -23,6 +23,10 @@ <h4>Virtualization Name: '{{virtualizationName}}'</h4>
[rows]="tableRows">
</pfng-table>
</div>
<!-- Show spinner while fetching views -->
<div class="col-sm-2" [hidden]="!viewsLoading">
<div class="spinner spinner-inline"></div>
</div>

<div class="col-sm-1">
<div class="col-sm-12 pull-left view-editor-header-create-button">
Expand Down
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { AfterViewInit, Component, OnDestroy, OnInit, ViewEncapsulation } from "@angular/core";
import { Component, OnDestroy, OnInit, ViewEncapsulation } from "@angular/core";
import { LoggerService } from "@core/logger.service";
import { ViewEditorPart } from "@dataservices/virtualization/view-editor/view-editor-part.enum";
import { ViewEditorService } from "@dataservices/virtualization/view-editor/view-editor.service";
Expand All @@ -42,7 +42,7 @@ import { ViewEditorProgressChangeId } from "@dataservices/virtualization/view-ed
templateUrl: "./view-editor-header.component.html",
styleUrls: ["./view-editor-header.component.css"]
})
export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestroy {
export class ViewEditorHeaderComponent implements OnInit, OnDestroy {

// used by html
public readonly viewDescriptionLabel = ViewEditorI18n.viewDescriptionLabel;
Expand Down Expand Up @@ -136,9 +136,7 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
this.tableConfig = {
emptyStateConfig: this.emptyStateConfig
} as TableConfig;
}

public ngAfterViewInit(): void {
// init the available views
this.initViews();
}
Expand Down Expand Up @@ -182,8 +180,8 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
} else {
initialView = self.tableRows.find((x) => x.getName() === selectedView.getName());
}
self.selectView(initialView);
self.viewsLoadingState = LoadingState.LOADED_VALID;
self.selectView(initialView);
},
(error) => {
self.logger.error("[VirtualizationComponent] Error updating the views for the virtualization: %o", error);
Expand All @@ -200,6 +198,13 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
return !this.editorService.getEditorView() || this.editorService.isReadOnly();
}

/**
* @returns {boolean} `true` if views are being loaded
*/
public get viewsLoading(): boolean {
return this.viewsLoadingState === LoadingState.LOADING;
}

/**
* @returns {string} the view description
*/
Expand Down Expand Up @@ -326,6 +331,8 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
const editorStates: ViewEditorState[] = [];
editorStates.push(editorState);

this.viewsLoadingState = LoadingState.LOADING;

const self = this;
this.dataserviceService
.saveViewEditorStatesRefreshViews(editorStates, selectedDs.getId())
Expand All @@ -334,10 +341,12 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
// Add the new ViewDefinition to the table
self.addViewDefinitionToList(viewDefn);
self.viewSavedUponCompletion = null;
self.viewsLoadingState = LoadingState.LOADED_VALID;
},
(error) => {
self.logger.error("[VirtualizationComponent] Error saving the editor state: %o", error);
self.viewSavedUponCompletion = null;
self.viewsLoadingState = LoadingState.LOADED_INVALID;
}
);
}
Expand Down Expand Up @@ -385,6 +394,8 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
const vdbName = selectedDs.getServiceVdbName();
const editorStateId = vdbName.toLowerCase() + "." + viewDefnName;
const dataserviceName = selectedDs.getId();

this.viewsLoadingState = LoadingState.LOADING;
// Note: we can only doDelete selected items that we can see in the UI.
this.logger.debug("[VirtualizationComponent] Deleting selected Virtualization View.");
const self = this;
Expand All @@ -395,9 +406,11 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
self.removeViewDefinitionFromList(selectedViewDefn);
// deletion of a view undeploys active serviceVdb
self.editorService.undeploySelectedVirtualization();
this.viewsLoadingState = LoadingState.LOADED_VALID;
},
(error) => {
self.logger.error("[VirtualizationComponent] Error deleting the editor state: %o", error);
this.viewsLoadingState = LoadingState.LOADED_INVALID;
}
);
}
Expand Down Expand Up @@ -450,7 +463,7 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
private selectView( selView: ViewDefinition ): void {
// Updates table selection display
let viewSelection = null;
if ( selView !== null ) {
if ( selView && selView !== null ) {
for (const view of this.tableRows) {
if (view.getName() === selView.getName()) {
view.setSelected(true);
Expand All @@ -461,7 +474,7 @@ export class ViewEditorHeaderComponent implements OnInit, AfterViewInit, OnDestr
}
}
// Update selection service, then fire event
this.selectionService.setSelectedViewDefinition(this.selectedVirtualization, selView);
this.selectionService.setSelectedViewDefinition(this.selectedVirtualization, viewSelection);
this.editorService.setEditorView(viewSelection, ViewEditorPart.HEADER);
}

Expand Down

0 comments on commit 356a6ac

Please sign in to comment.