Skip to content

Commit

Permalink
Feature/refresh indicator (#93)
Browse files Browse the repository at this point in the history
* Renamed refreshing observable, added refreshMessage$ observable, refresh-alert component
* Remove refreshing$ observable, use refreshMessage$ for checks
* Refresh indicator, disable buttons when refreshing
* Fix errorObj grammar
* Fix merge conflicts, moved error service, renamed refresh-alert to alert
  • Loading branch information
garyluu authored Oct 10, 2017
1 parent b59e590 commit e0561e7
Show file tree
Hide file tree
Showing 39 changed files with 213 additions and 117 deletions.
17 changes: 1 addition & 16 deletions src/app/container/container.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,6 @@

<div class="row" *ngIf="error || refreshing || missingWarning">
<div class="col-md-12" *ngIf="!isToolPublic">
<div class="alert alert-danger alert-dismissable" ng-class="!editMode ? 'push-top' : ''" role="alert" *ngIf="error">
<button type="button" class="close" data-dismiss="alert" (click)="closeError()">
&times;
</button>
<p>
<span class="glyphicon glyphicon-warning-sign"></span>
{{error.message}}
</p>
<p class="error-output">{{error.errorDetails}}</p>
</div>
<div class="alert alert-info" role="alert" *ngIf="refreshing">
<span class="glyphicon glyphicon-refresh glyphicon-refresh-animate">
</span>
Please wait, retrieving {{tool?.imgProvider}} tool...
</div>
<div class="alert alert-warning" ng-class="!editMode ? 'push-top' : ''" role="alert" *ngIf="missingWarning">
<button type="button" class="close" data-dismiss="alert" ng-click="missingWarning = false">
&times;
Expand Down Expand Up @@ -77,7 +62,7 @@ <h3>

<app-deregister-modal *ngIf="tool?.mode === 'MANUAL_IMAGE_PATH'"></app-deregister-modal>
</div>
<button type="button" class="btn btn-primary" (click)="refresh()" [disabled]="refreshing">
<button type="button" class="btn btn-primary" (click)="refresh()" [disabled]="refreshMessage !== null">
Refresh
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/container/container.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import { ErrorService } from './../shared/error.service';
import { PublishRequest } from './../shared/swagger/model/publishRequest';
import { Subscription } from 'rxjs/Subscription';
import { ContainersService } from './../shared/swagger/api/containers.service';
import { ErrorService } from './error.service';
import { StateService } from './../shared/state.service';
import { RefreshService } from './../shared/refresh.service';
import { FormsModule } from '@angular/forms';
Expand Down Expand Up @@ -171,7 +171,7 @@ export class ContainerComponent extends Entry {
}

publishDisable() {
return this.refreshing || !this.isContainerValid();
return this.refreshMessage !== null || !this.isContainerValid();
}

isContainerValid() {
Expand Down
4 changes: 2 additions & 2 deletions src/app/container/info-tab/info-tab.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ export class InfoTabService {

updateAndRefresh(tool: any) {
this.containersService.updateContainer(this.tool.id, tool).subscribe(response => {
this.stateService.setRefreshing(true);
this.stateService.setRefreshMessage('Updating tool info...');
this.containersService.refresh(this.tool.id).subscribe(refreshResponse => {
this.containerService.replaceTool(this.tools, refreshResponse);
this.containerService.setTool(refreshResponse);
this.stateService.setRefreshing(false);
this.stateService.setRefreshMessage(null);
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export class RefreshToolOrganizationComponent extends RefreshOrganizationCompone
refreshOrganization(): void {
const splitOrganization: string[] = this.organization.split('/');
const actualOrganization: string = splitOrganization[1];
this.stateService.setRefreshing(true);
this.stateService.setRefreshMessage('Refreshing ' + actualOrganization + '...');
this.usersService.refreshToolsByOrganization(this.userId, actualOrganization).subscribe(
(success: DockstoreTool[]) => {
this.containerService.setTools(success);
this.stateService.setRefreshing(false);
}, error => this.stateService.setRefreshing(false));
this.stateService.setRefreshMessage(null);
}, error => this.stateService.setRefreshMessage(null));
}

}
4 changes: 2 additions & 2 deletions src/app/container/register-tool/register-tool.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h4 class="modal-title">Register Tool</h4>
</p>
<p class="error-output">{{toolRegisterError.errorDetails}}</p>
</div>
<div class="alert alert-info" role="alert" *ngIf="refreshing">
<div class="alert alert-info" role="alert" *ngIf="refreshMessage !== null">
<span class="glyphicon glyphicon-refresh glyphicon-refresh-animate">
</span>
Please wait, retrieving tool...
Expand Down Expand Up @@ -171,7 +171,7 @@ <h4 class="modal-title">Register Tool</h4>
<button type="button" class="btn btn-secondary" data-dismiss="modal" (click)="hideModal()">
Close
</button>
<button id="submitButton" type="submit" class="btn btn-primary" [disabled]="!registerToolForm.form.valid || savingActive || refreshing || isInvalidCustomRegistry() || isInvalidPrivateTool()">
<button id="submitButton" type="submit" class="btn btn-primary" [disabled]="!registerToolForm.form.valid || savingActive || refreshMessage !== null || isInvalidCustomRegistry() || isInvalidPrivateTool()">
Add Tool
</button>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/container/register-tool/register-tool.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class RegisterToolComponent implements OnInit, AfterViewChecked {
public validationPatterns = validationPatterns;
public customDockerRegistryPath: string;
public showCustomDockerRegistryPath: boolean;
public refreshing: boolean;
public refreshMessage: string;
public isModalShown: boolean;

registerToolForm: NgForm;
Expand Down Expand Up @@ -96,7 +96,7 @@ export class RegisterToolComponent implements OnInit, AfterViewChecked {
this.registerToolService.customDockerRegistryPath.subscribe(path => this.customDockerRegistryPath = path);
this.registerToolService.showCustomDockerRegistryPath.subscribe(showPath => this.showCustomDockerRegistryPath = showPath);
this.registerToolService.toolRegisterError.subscribe(error => this.toolRegisterError = error);
this.stateService.refreshing.subscribe(status => this.refreshing = status);
this.stateService.refreshMessage$.subscribe(status => this.refreshMessage = status);
this.registerToolService.isModalShown.subscribe(isModalShown => this.isModalShown = isModalShown);
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/container/register-tool/register-tool.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ export class RegisterToolService {
const normalizedToolObj: DockstoreTool = this.getNormalizedToolObj(newTool, customDockerRegistryPath);
this.containersService.registerManual(normalizedToolObj).subscribe(response => {
this.setToolRegisterError(null);
this.stateService.setRefreshing(true);
this.stateService.setRefreshMessage('Registering new tool...');
this.containersService.refresh(response.id).subscribe(refreshResponse => {
this.setIsModalShown(false);
this.containerService.addToTools(this.tools, refreshResponse);
this.containerService.setTool(refreshResponse);
this.stateService.setRefreshing(false);
this.stateService.setRefreshMessage(null);
});
// Use types instead
}, error => this.setToolRegisterError(error)
Expand Down
5 changes: 3 additions & 2 deletions src/app/mytools/mytools.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
<img src="../assets/images/dockstore/dockstore-tools-blue.png">
My Tools
<div class="pull-right refresh-all-holder">
<button type="button" class="refresh-all-button btn btn-primary" (click)="refreshAllTools()">
<button type="button" class="refresh-all-button btn btn-primary" (click)="refreshAllTools()" [disabled]="refreshMessage !== null">
Refresh All Tools
</button>
</div>
</app-header>
<div class="container padding-top">
<app-alert></app-alert>
<!--Msg/Warning Page, this should be a Component-->
<div class="row" *ngIf="nsContainers?.length == 0">
<div class="col-md-12">
Expand Down Expand Up @@ -76,7 +77,7 @@
</accordion-group>
</accordion>
<button (click)="showRegisterToolModal()" id="register_tool_button" type="button"
class="btn btn-primary btn-sm pull-right">
class="btn btn-primary btn-sm pull-right" [disabled]="refreshMessage !== null">
Add Tool
</button>

Expand Down
5 changes: 4 additions & 1 deletion src/app/mytools/mytools.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { StateService } from './../shared/state.service';
import { Component, OnInit } from '@angular/core';
import { AuthService } from 'ng2-ui-auth/commonjs/auth.service';

Expand All @@ -40,10 +41,11 @@ export class MyToolsComponent implements OnInit {
tools: any;
user: any;
tool: any;
public refreshMessage: string;
private registerTool: Tool;
constructor(private mytoolsService: MytoolsService, private configuration: Configuration,
private communicatorService: CommunicatorService, private usersService: UsersService,
private userService: UserService, private authService: AuthService,
private userService: UserService, private authService: AuthService, private stateService: StateService,
private containerService: ContainerService,
private refreshService: RefreshService,
private registerToolService: RegisterToolService) { }
Expand Down Expand Up @@ -80,6 +82,7 @@ export class MyToolsComponent implements OnInit {
this.selectContainer(null);
}
});
this.stateService.refreshMessage$.subscribe(refreshMessage => this.refreshMessage = refreshMessage);
this.registerToolService.tool.subscribe(tool => this.registerTool = tool);
}
setIsFirstOpen() {
Expand Down
2 changes: 2 additions & 0 deletions src/app/mytools/mytools.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { RefreshAlertModule } from '../shared/alert/alert.module';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
Expand Down Expand Up @@ -46,6 +47,7 @@ import { mytoolsRouting } from './mytools.routing';
mytoolsRouting,
AccordionModule.forRoot(),
ModalModule.forRoot(),
RefreshAlertModule,
TabsModule.forRoot(),
TooltipModule.forRoot()
],
Expand Down
5 changes: 3 additions & 2 deletions src/app/myworkflows/myworkflows.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
<app-header>
<img src="../assets/images/dockstore/dockstore-workflows-green.png"> My Workflows
<div class="pull-right refresh-all-holder">
<button type="button" class="refresh-all-button btn btn-primary" (click)="refreshAllWorkflows()">
<button type="button" class="refresh-all-button btn btn-primary" (click)="refreshAllWorkflows()" [disabled]="refreshMessage !== null">
Refresh All Workflows
</button>
</div>
</app-header>
<div class="container padding-top">
<app-alert></app-alert>
<div class="row" *ngIf="orgWorkflows?.length == 0">
<div class="col-md-12">
<div class="alert alert-info" role="alert">
Expand Down Expand Up @@ -66,7 +67,7 @@
</accordion-group>
</accordion>
<div>
<button type="button" class="btn btn-primary btn-sm pull-right" (click)="showModal()">Register Workflow</button>
<button type="button" class="btn btn-primary btn-sm pull-right" (click)="showModal()" [disabled]="refreshMessage !== null">Register Workflow</button>
</div>
<app-register-workflow-modal></app-register-workflow-modal>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/myworkflows/myworkflows.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { StateService } from './../shared/state.service';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AuthService } from 'ng2-ui-auth';
Expand All @@ -31,6 +32,7 @@ import {
ConfigurationStub,
RefreshStubService,
RegisterWorkflowModalStubService,
StateStubService,
UsersStubService,
UserStubService,
WorkflowStubService,
Expand All @@ -54,7 +56,8 @@ describe('MyWorkflowsComponent', () => {
{ provide: WorkflowService, useClass: WorkflowStubService },
{ provide: RefreshService, useClass: RefreshStubService },
{ provide: RegisterWorkflowModalService, useClass: RegisterWorkflowModalStubService },
{ provide: UserService, useClass: UserStubService }
{ provide: UserService, useClass: UserStubService },
{ provide: StateService, useClass: StateStubService }
]
})
.compileComponents();
Expand Down
6 changes: 4 additions & 2 deletions src/app/myworkflows/myworkflows.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { StateService } from '../shared/state.service';
import { Component, OnInit } from '@angular/core';
import { AuthService } from 'ng2-ui-auth';

Expand All @@ -40,12 +41,12 @@ export class MyWorkflowsComponent implements OnInit {
workflow: any;
user: any;
workflows: any;
public refreshMessage: string;
constructor(private myworkflowService: MyWorkflowsService, private configuration: Configuration,
private usersService: UsersService, private userService: UserService,
private workflowService: WorkflowService, private authService: AuthService,
private refreshService: RefreshService,
private refreshService: RefreshService, private stateService: StateService,
private registerWorkflowModalService: RegisterWorkflowModalService) {

}

ngOnInit() {
Expand Down Expand Up @@ -81,6 +82,7 @@ export class MyWorkflowsComponent implements OnInit {
this.selectWorkflow(null);
}
});
this.stateService.refreshMessage$.subscribe(refreshMessage => this.refreshMessage = refreshMessage);
}
setIsFirstOpen() {
if (this.orgWorkflows && this.workflow) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/myworkflows/myworkflows.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { RefreshAlertModule } from './../shared/alert/alert.module';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
Expand Down Expand Up @@ -45,6 +46,7 @@ import { myworkflowRouting } from './myworkflows.routing';
myworkflowRouting,
ModalModule.forRoot(),
AccordionModule.forRoot(),
RefreshAlertModule,
TabsModule.forRoot(),
TooltipModule.forRoot()
]
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions src/app/shared/alert/alert.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="alert alert-info" role="alert" *ngIf="refreshMessage">
<span class="glyphicon glyphicon-refresh glyphicon-refresh-animate">
</span>
{{ refreshMessage }}
</div>
<div class="alert alert-danger alert-dismissable" ng-class="!editMode ? 'push-top' : ''" role="alert" *ngIf="errorObj">
<button type="button" class="close" data-dismiss="alert" ng-click="setError(null)">
&times;
</button>
<p>
<span class="glyphicon glyphicon-warning-sign"></span>
{{errorObj.message}}
</p>
<p class="error-output">{{errorObj.errorDetails}}</p>
</div>
34 changes: 34 additions & 0 deletions src/app/shared/alert/alert.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { ErrorStubService } from './../../test/service-stubs';
import { ErrorService } from './../../shared/error.service';
import { StateStubService } from '../../test/service-stubs';
import { StateService } from '../state.service';
/* tslint:disable:no-unused-variable */
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DebugElement } from '@angular/core';

import { AlertComponent } from './alert.component';

describe('RefreshAlertComponent', () => {
let component: AlertComponent;
let fixture: ComponentFixture<AlertComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AlertComponent ],
providers: [ {provide: StateService, useClass: StateStubService},
{ provide: ErrorService, useClass: ErrorStubService}]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(AlertComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
22 changes: 22 additions & 0 deletions src/app/shared/alert/alert.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ErrorService } from '../../shared/error.service';
import { StateService } from '../state.service';
import { Component, OnInit } from '@angular/core';

// TODO: Rename this component to something like 'alert' since it contains both error and refresh alerts

@Component({
selector: 'app-alert',
templateUrl: './alert.component.html',
styleUrls: ['./alert.component.css']
})
export class AlertComponent implements OnInit {
public refreshMessage: string;
public errorObj: any;
constructor(private stateService: StateService, private errorService: ErrorService) { }

ngOnInit() {
this.stateService.refreshMessage$.subscribe(refreshMessage => this.refreshMessage = refreshMessage);
this.errorService.errorObj$.subscribe(errorObj => this.errorObj = errorObj);
}

}
20 changes: 20 additions & 0 deletions src/app/shared/alert/alert.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { StateService } from '../state.service';
import { AlertComponent } from './alert.component';
import { NgModule } from '@angular/core';

@NgModule({
declarations: [
AlertComponent
],
imports: [
CommonModule,
FormsModule
],
providers: [
StateService
],
exports: [AlertComponent]
})
export class RefreshAlertModule {}
Loading

0 comments on commit e0561e7

Please sign in to comment.