This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch DLAB-1385
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 79aa6403ad0889b200dab70978cf5231220678b5
Author: Dmytro Gnatyshyn <di1...@ukr.net>
AuthorDate: Mon Dec 23 16:32:42 2019 +0200

    [DLAB-1385]: Added progress bar service and component
---
 .../app/core/services/progress-bar.service.spec.ts | 12 ++++++++
 .../src/app/core/services/progress-bar.service.ts  | 23 +++++++++++++++
 .../src/app/shared/navbar/navbar.component.html    |  1 +
 .../src/app/shared/navbar/navbar.component.ts      | 19 +++++++++++--
 .../webapp/src/app/shared/progress-bar/index.ts    | 33 ++++++++++++++++++++++
 .../progress-bar/progress-bar.component.html       |  2 ++
 .../progress-bar/progress-bar.component.scss       |  0
 .../progress-bar/progress-bar.component.spec.ts    | 25 ++++++++++++++++
 .../shared/progress-bar/progress-bar.component.ts  | 18 ++++++++++++
 .../webapp/src/assets/styles/app-loading.scss      |  5 ++++
 10 files changed, 135 insertions(+), 3 deletions(-)

diff --git 
a/services/self-service/src/main/resources/webapp/src/app/core/services/progress-bar.service.spec.ts
 
b/services/self-service/src/main/resources/webapp/src/app/core/services/progress-bar.service.spec.ts
new file mode 100644
index 0000000..021b583
--- /dev/null
+++ 
b/services/self-service/src/main/resources/webapp/src/app/core/services/progress-bar.service.spec.ts
@@ -0,0 +1,12 @@
+import { TestBed } from '@angular/core/testing';
+
+import { ProgressBarService } from './progress-bar.service';
+
+describe('ProgressBarService', () => {
+  beforeEach(() => TestBed.configureTestingModule({}));
+
+  it('should be created', () => {
+    const service: ProgressBarService = TestBed.get(ProgressBarService);
+    expect(service).toBeTruthy();
+  });
+});
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/core/services/progress-bar.service.ts
 
b/services/self-service/src/main/resources/webapp/src/app/core/services/progress-bar.service.ts
new file mode 100644
index 0000000..d2ec24d
--- /dev/null
+++ 
b/services/self-service/src/main/resources/webapp/src/app/core/services/progress-bar.service.ts
@@ -0,0 +1,23 @@
+import { Injectable } from '@angular/core';
+import {Subject} from "rxjs";
+
+@Injectable({
+  providedIn: 'root'
+})
+export class ProgressBarService {
+  public showProgressBar = new Subject();
+
+  constructor() { }
+
+  public toggleProgressBar(value) {
+    this.showProgressBar.next(value);
+  }
+
+  public stopProgressBar() {
+    this.showProgressBar.next(false);
+  }
+
+  public startProgressBar() {
+    this.showProgressBar.next(true);
+  }
+}
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
index ca89f33..31e9176 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.html
@@ -18,6 +18,7 @@
   -->
 
 <div class="nav-bar" [hidden]="!isLoggedIn">
+  <mat-progress-bar *ngIf="showProgressBar" mode="indeterminate" 
></mat-progress-bar>
   <div class="menu-area" *ngIf="healthStatus">
 
     <button class="hamburger" (click)="collapse()">
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.ts
 
b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.ts
index 7c61100..ac9cb67 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.ts
+++ 
b/services/self-service/src/main/resources/webapp/src/app/shared/navbar/navbar.component.ts
@@ -19,7 +19,7 @@
 
 import { Component, ViewEncapsulation, OnInit, OnDestroy, ViewChild } from 
'@angular/core';
 import { MatDialog, MatDialogRef } from '@angular/material/dialog';
-import { Subscription, timer, interval } from 'rxjs';
+import {Subscription, timer, interval, Subject} from 'rxjs';
 import { ToastrService } from 'ngx-toastr';
 import { RouterOutlet } from '@angular/router';
 
@@ -38,6 +38,7 @@ import {
   animateChild,
   state
 } from '@angular/animations';
+import {ProgressBarService} from "../../core/services/progress-bar.service";
 
 @Component({
   selector: 'dlab-navbar',
@@ -83,9 +84,10 @@ export class NavbarComponent implements OnInit, OnDestroy {
   isLoggedIn: boolean = false;
   metadata: any;
   isExpanded: boolean = true;
-
+  public showProgressBar: any;
   healthStatus: GeneralEnvironmentStatus;
   subscriptions: Subscription = new Subscription();
+  showProgressBarSubscr = new Subscription();
 
   constructor(
     public toastr: ToastrService,
@@ -94,10 +96,12 @@ export class NavbarComponent implements OnInit, OnDestroy {
     private healthStatusService: HealthStatusService,
     private schedulerService: SchedulerService,
     private storage: StorageService,
-    private dialog: MatDialog
+    private dialog: MatDialog,
+    private progressBarService: ProgressBarService,
   ) { }
 
   ngOnInit() {
+    this.showProgressBarSubscr =  
this.progressBarService.showProgressBar.subscribe(isProgressBarVissible => 
this.showProgressBar = isProgressBarVissible);
     this.applicationSecurityService.loggedInStatus.subscribe(response => {
       this.subscriptions.unsubscribe();
       this.subscriptions.closed = false;
@@ -118,6 +122,7 @@ export class NavbarComponent implements OnInit, OnDestroy {
 
   ngOnDestroy(): void {
     this.subscriptions.unsubscribe();
+    this.showProgressBarSubscr.unsubscribe();
   }
 
   public getRouterOutletState(routerOutlet: RouterOutlet) {
@@ -128,6 +133,14 @@ export class NavbarComponent implements OnInit, OnDestroy {
     return this.storage.getUserName() || '';
   }
 
+  public startProgressBar() {
+    this.progressBarService.startProgressBar()
+  }
+
+  public stopProgressBar() {
+    this.progressBarService.stopProgressBar()
+  }
+
   logout_btnClick(): void {
     this.healthStatusService.resetStatusValue();
     this.applicationSecurityService.logout().subscribe(
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/index.ts
 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/index.ts
new file mode 100644
index 0000000..689becc
--- /dev/null
+++ 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/index.ts
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { NgModule } from '@angular/core';
+import { MaterialModule } from '../material.module';
+import {ProgressBarComponent} from "./progress-bar.component";
+
+export * from './progress-bar.component';
+
+@NgModule({
+  imports: [
+    MaterialModule,
+  ],
+  declarations: [ProgressBarComponent],
+  exports: [ProgressBarComponent]
+})
+export class ProgressBarModule { }
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.html
new file mode 100644
index 0000000..eb9de9a
--- /dev/null
+++ 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.html
@@ -0,0 +1,2 @@
+<mat-progress-bar mode="indeterminate"></mat-progress-bar>
+
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.scss
 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.scss
new file mode 100644
index 0000000..e69de29
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.spec.ts
 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.spec.ts
new file mode 100644
index 0000000..f41343a
--- /dev/null
+++ 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { ProgressBarComponent } from './progress-bar.component';
+
+describe('ProgressBarComponent', () => {
+  let component: ProgressBarComponent;
+  let fixture: ComponentFixture<ProgressBarComponent>;
+
+  beforeEach(async(() => {
+    TestBed.configureTestingModule({
+      declarations: [ ProgressBarComponent ]
+    })
+    .compileComponents();
+  }));
+
+  beforeEach(() => {
+    fixture = TestBed.createComponent(ProgressBarComponent);
+    component = fixture.componentInstance;
+    fixture.detectChanges();
+  });
+
+  it('should create', () => {
+    expect(component).toBeTruthy();
+  });
+});
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.ts
 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.ts
new file mode 100644
index 0000000..0e99c67
--- /dev/null
+++ 
b/services/self-service/src/main/resources/webapp/src/app/shared/progress-bar/progress-bar.component.ts
@@ -0,0 +1,18 @@
+import { Component, OnInit } from '@angular/core';
+import {MatProgressBarModule} from '@angular/material/progress-bar';
+import {ProgressBarService} from "../../core/services/progress-bar.service";
+
+@Component({
+  selector: 'dlab-progress-bar',
+  templateUrl: './progress-bar.component.html',
+  styleUrls: ['./progress-bar.component.scss']
+})
+export class ProgressBarComponent implements OnInit {
+  constructor(
+    public progressBarService: ProgressBarService,
+  ) { }
+
+  ngOnInit() {
+
+  }
+}
diff --git 
a/services/self-service/src/main/resources/webapp/src/assets/styles/app-loading.scss
 
b/services/self-service/src/main/resources/webapp/src/assets/styles/app-loading.scss
index 91b62c3..6fb034b 100644
--- 
a/services/self-service/src/main/resources/webapp/src/assets/styles/app-loading.scss
+++ 
b/services/self-service/src/main/resources/webapp/src/assets/styles/app-loading.scss
@@ -82,3 +82,8 @@ html {
     background-size: cover;
   }
 }
+
+.nav-bar .mat-progress-bar {
+  position: absolute;
+  height: 2px;
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org
For additional commands, e-mail: commits-h...@dlab.apache.org

Reply via email to