diff --git a/src/app/layout/layouts/empty/empty.module.ts b/src/app/layout/layouts/empty/empty.module.ts
index 339f5cc6..12153080 100644
--- a/src/app/layout/layouts/empty/empty.module.ts
+++ b/src/app/layout/layouts/empty/empty.module.ts
@@ -1,5 +1,6 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
+import { FuseLoadingBarModule } from '@fuse/components/loading-bar';
import { SharedModule } from 'app/shared/shared.module';
import { EmptyLayoutComponent } from 'app/layout/layouts/empty/empty.component';
@@ -9,6 +10,7 @@ import { EmptyLayoutComponent } from 'app/layout/layouts/empty/empty.component';
],
imports : [
RouterModule,
+ FuseLoadingBarModule,
SharedModule
],
exports : [
diff --git a/src/app/layout/layouts/horizontal/centered/centered.component.html b/src/app/layout/layouts/horizontal/centered/centered.component.html
index 8b2ca444..c6c8ca70 100644
--- a/src/app/layout/layouts/horizontal/centered/centered.component.html
+++ b/src/app/layout/layouts/horizontal/centered/centered.component.html
@@ -1,3 +1,6 @@
+
+
+
diff --git a/src/app/layout/layouts/horizontal/centered/centered.module.ts b/src/app/layout/layouts/horizontal/centered/centered.module.ts
index b1d952f4..cc4bc461 100644
--- a/src/app/layout/layouts/horizontal/centered/centered.module.ts
+++ b/src/app/layout/layouts/horizontal/centered/centered.module.ts
@@ -6,6 +6,7 @@ import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { FuseFullscreenModule } from '@fuse/components/fullscreen';
+import { FuseLoadingBarModule } from '@fuse/components/loading-bar';
import { FuseNavigationModule } from '@fuse/components/navigation';
import { LanguagesModule } from 'app/layout/common/languages/languages.module';
import { MessagesModule } from 'app/layout/common/messages/messages.module';
@@ -28,6 +29,7 @@ import { CenteredLayoutComponent } from 'app/layout/layouts/horizontal/centered/
MatIconModule,
MatMenuModule,
FuseFullscreenModule,
+ FuseLoadingBarModule,
FuseNavigationModule,
LanguagesModule,
MessagesModule,
diff --git a/src/app/layout/layouts/horizontal/enterprise/enterprise.component.html b/src/app/layout/layouts/horizontal/enterprise/enterprise.component.html
index 4f376812..45b3fb3f 100644
--- a/src/app/layout/layouts/horizontal/enterprise/enterprise.component.html
+++ b/src/app/layout/layouts/horizontal/enterprise/enterprise.component.html
@@ -1,3 +1,6 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ fuse-loading-bar is a small component to show the loading status at the top of the page. It can be configured to the
+ Auto Mode to show/hide automatically on each HTTP request. It can also be toggled manually using its service.
+
+
+ Exported as: fuseLoadingBar
+
+
+
Module
+
+
+
Usage
+
+ Here's the basic usage of the fuse-loading-bar
. We already placed the component to the
+ layout templates for you but you can always move it!
+
+
+
+
+
+
Properties
+
+
+
+
+ Name
+ Description
+ Default
+
+
+
+
+
+ @Input()
+ autoMode: boolean
+
+
+ Turn on or off the Auto Mode.
+
+
+ true
+
+
+
+
+
+
+
Service
+
+ FuseLoadingBarService
can be injected to control the loading bar from anywhere.
+
+
+
+ show(): void;
+
+
+ Shows the loading bar
+
+
+
+
+ hide(): void;
+
+
+ Hides the loading bar
+
+
+
+
+ setAutoMode(value: boolean): void;
+
+
+ Sets the Auto Mode. In Auto mode, loading bar will show when there is an HTTP request and it will
+ hide when all HTTP requests are completed or failed.
+
+
+
+
+ setMode(value: 'determinate' | 'indeterminate'): void;
+
+
+ Sets the mode of the underlying MatProgressBar
component.
+
+
+
+
+ setProgress(value: number): void;
+
+
+ Sets the progress manually. Only available on determinate
mode.
+
+
+
+
Examples
+
+
+
+
Show / hide the loading bar manually
+
+
+
+
+
+
+
+
+
+
+
+
+ Show loading bar
+
+
+
+ Hide loading bar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Toggle the Auto Mode
+
+
+
+
+
+
+
+
+
+
+
+
+ Auto Mode
+
+
+
+
+
+ Make an API call (2000ms delay)
+
+
+
API call status: {{apiCallStatus}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Manually set the progress
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Show loading bar
+
+
+
+ Hide loading bar
+
+
+
+
+ Toggle determinate mode
+
+
+
+ Progress value
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/modules/admin/ui/fuse-components/components/loading-bar/loading-bar.component.ts b/src/app/modules/admin/ui/fuse-components/components/loading-bar/loading-bar.component.ts
new file mode 100644
index 00000000..b52d5258
--- /dev/null
+++ b/src/app/modules/admin/ui/fuse-components/components/loading-bar/loading-bar.component.ts
@@ -0,0 +1,109 @@
+import { Component } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import { MatSliderChange } from '@angular/material/slider';
+import { MatSlideToggleChange } from '@angular/material/slide-toggle';
+import { finalize } from 'rxjs/operators';
+import { FuseLoadingBarService } from '@fuse/components/loading-bar';
+import { FuseComponentsComponent } from 'app/modules/admin/ui/fuse-components/fuse-components.component';
+
+@Component({
+ selector : 'loading-bar',
+ templateUrl: './loading-bar.component.html'
+})
+export class LoadingBarComponent
+{
+ apiCallStatus: string = '-';
+ mode: 'determinate' | 'indeterminate' = 'indeterminate';
+
+ /**
+ * Constructor
+ */
+ constructor(
+ private _httpClient: HttpClient,
+ private _fuseComponentsComponent: FuseComponentsComponent,
+ private _fuseLoadingBarService: FuseLoadingBarService
+ )
+ {
+ }
+
+ // -----------------------------------------------------------------------------------------------------
+ // @ Public methods
+ // -----------------------------------------------------------------------------------------------------
+
+ /**
+ * Toggle the drawer
+ */
+ toggleDrawer(): void
+ {
+ // Toggle the drawer
+ this._fuseComponentsComponent.matDrawer.toggle();
+ }
+
+ /**
+ * Show the loading bar
+ */
+ showLoadingBar(): void
+ {
+ this._fuseLoadingBarService.show();
+ }
+
+ /**
+ * Hide the loading bar
+ */
+ hideLoadingBar(): void
+ {
+ this._fuseLoadingBarService.hide();
+ }
+
+ /**
+ * Set the auto mode
+ *
+ * @param change
+ */
+ setAutoMode(change: MatSlideToggleChange): void
+ {
+ this._fuseLoadingBarService.setAutoMode(change.checked);
+ }
+
+ /**
+ * Make a fake API call
+ */
+ makeAPICall(): void
+ {
+ this.apiCallStatus = 'Waiting...';
+
+ this._httpClient.get('https://jsonplaceholder.typicode.com/posts?_delay=2000')
+ .pipe(finalize(() => {
+ this.apiCallStatus = 'Finished!';
+ }))
+ .subscribe((response) => {
+ console.log(response);
+ });
+ }
+
+ /**
+ * Toggle the mode
+ */
+ toggleMode(): void
+ {
+ // Show the loading bar
+ this._fuseLoadingBarService.show();
+
+ // Turn off the auto mode
+ this._fuseLoadingBarService.setAutoMode(false);
+
+ // Set the mode
+ this.mode = this.mode === 'indeterminate' ? 'determinate' : 'indeterminate';
+ this._fuseLoadingBarService.setMode(this.mode);
+ }
+
+ /**
+ * Set the progress
+ *
+ * @param change
+ */
+ setProgress(change: MatSliderChange): void
+ {
+ this._fuseLoadingBarService.setProgress(change.value);
+ }
+}
diff --git a/src/app/modules/admin/ui/fuse-components/fuse-components.component.ts b/src/app/modules/admin/ui/fuse-components/fuse-components.component.ts
index 017d93da..df3f0781 100644
--- a/src/app/modules/admin/ui/fuse-components/fuse-components.component.ts
+++ b/src/app/modules/admin/ui/fuse-components/fuse-components.component.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
+import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { FuseNavigationItem } from '@fuse/components/navigation';
import { MatDrawer } from '@angular/material/sidenav';
import { Subject } from 'rxjs';
@@ -6,11 +6,10 @@ import { FuseMediaWatcherService } from '@fuse/services/media-watcher';
import { takeUntil } from 'rxjs/operators';
@Component({
- selector : 'fuse-components',
- templateUrl : './fuse-components.component.html',
- styleUrls : ['./fuse-components.component.scss'],
- encapsulation : ViewEncapsulation.None,
- changeDetection: ChangeDetectionStrategy.OnPush
+ selector : 'fuse-components',
+ templateUrl : './fuse-components.component.html',
+ styleUrls : ['./fuse-components.component.scss'],
+ encapsulation: ViewEncapsulation.None
})
export class FuseComponentsComponent implements OnInit, OnDestroy
{
@@ -24,7 +23,6 @@ export class FuseComponentsComponent implements OnInit, OnDestroy
* Constructor
*/
constructor(
- private _changeDetectorRef: ChangeDetectorRef,
private _fuseMediaWatcherService: FuseMediaWatcherService
)
{
@@ -83,6 +81,12 @@ export class FuseComponentsComponent implements OnInit, OnDestroy
type : 'basic',
link : '/ui/fuse-components/components/highlight'
},
+ {
+ id : 'fuse-components.components.loading-bar',
+ title: 'Loading Bar',
+ type : 'basic',
+ link : '/ui/fuse-components/components/loading-bar'
+ },
{
id : 'fuse-components.components.masonry',
title: 'Masonry',
@@ -201,9 +205,6 @@ export class FuseComponentsComponent implements OnInit, OnDestroy
this.drawerMode = 'over';
this.drawerOpened = false;
}
-
- // Mark for check
- this._changeDetectorRef.markForCheck();
});
}
diff --git a/src/app/modules/admin/ui/fuse-components/fuse-components.module.ts b/src/app/modules/admin/ui/fuse-components/fuse-components.module.ts
index 113c0e58..0007cb8b 100644
--- a/src/app/modules/admin/ui/fuse-components/fuse-components.module.ts
+++ b/src/app/modules/admin/ui/fuse-components/fuse-components.module.ts
@@ -5,6 +5,8 @@ import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatSelectModule } from '@angular/material/select';
+import { MatSlideToggleModule } from '@angular/material/slide-toggle';
+import { MatSliderModule } from '@angular/material/slider';
import { MatSidenavModule } from '@angular/material/sidenav';
import { MatTabsModule } from '@angular/material/tabs';
import { MatTreeModule } from '@angular/material/tree';
@@ -31,6 +33,7 @@ import { ScrollbarComponent } from 'app/modules/admin/ui/fuse-components/directi
import { ScrollResetComponent } from 'app/modules/admin/ui/fuse-components/directives/scroll-reset/scroll-reset.component';
import { ConfigComponent } from 'app/modules/admin/ui/fuse-components/services/config/config.component';
import { ConfirmationComponent } from 'app/modules/admin/ui/fuse-components/services/confirmation/confirmation.component';
+import { LoadingBarComponent } from 'app/modules/admin/ui/fuse-components/components/loading-bar/loading-bar.component';
import { MediaWatcherComponent } from 'app/modules/admin/ui/fuse-components/services/media-watcher/media-watcher.component';
import { SplashScreenComponent } from 'app/modules/admin/ui/fuse-components/services/splash-screen/splash-screen.component';
import { FindByKeyComponent } from 'app/modules/admin/ui/fuse-components/pipes/find-by-key/find-by-key.component';
@@ -47,6 +50,7 @@ import { fuseComponentsRoutes } from 'app/modules/admin/ui/fuse-components/fuse-
DrawerComponent,
FullscreenComponent,
HighlightComponent,
+ LoadingBarComponent,
MasonryComponent,
NavigationComponent,
ScrollbarComponent,
@@ -58,13 +62,15 @@ import { fuseComponentsRoutes } from 'app/modules/admin/ui/fuse-components/fuse-
FindByKeyComponent,
MustMatchComponent
],
- imports: [
+ imports : [
RouterModule.forChild(fuseComponentsRoutes),
MatButtonModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatSelectModule,
+ MatSlideToggleModule,
+ MatSliderModule,
MatSidenavModule,
MatTabsModule,
MatTreeModule,
diff --git a/src/app/modules/admin/ui/fuse-components/fuse-components.routing.ts b/src/app/modules/admin/ui/fuse-components/fuse-components.routing.ts
index c8c27748..21a8b83a 100644
--- a/src/app/modules/admin/ui/fuse-components/fuse-components.routing.ts
+++ b/src/app/modules/admin/ui/fuse-components/fuse-components.routing.ts
@@ -7,6 +7,7 @@ import { DateRangeComponent } from 'app/modules/admin/ui/fuse-components/compone
import { DrawerComponent } from 'app/modules/admin/ui/fuse-components/components/drawer/drawer.component';
import { FullscreenComponent } from 'app/modules/admin/ui/fuse-components/components/fullscreen/fullscreen.component';
import { HighlightComponent } from 'app/modules/admin/ui/fuse-components/components/highlight/highlight.component';
+import { LoadingBarComponent } from 'app/modules/admin/ui/fuse-components/components/loading-bar/loading-bar.component';
import { MasonryComponent } from 'app/modules/admin/ui/fuse-components/components/masonry/masonry.component';
import { NavigationComponent } from 'app/modules/admin/ui/fuse-components/components/navigation/navigation.component';
import { ScrollbarComponent } from 'app/modules/admin/ui/fuse-components/directives/scrollbar/scrollbar.component';
@@ -69,6 +70,10 @@ export const fuseComponentsRoutes: Route[] = [
path : 'highlight',
component: HighlightComponent
},
+ {
+ path : 'loading-bar',
+ component: LoadingBarComponent
+ },
{
path : 'masonry',
component: MasonryComponent