ngx-admin-lte icon indicating copy to clipboard operation
ngx-admin-lte copied to clipboard

Avoid wrong click.

Open fanuelson opened this issue 6 years ago • 7 comments

Just an enhancement.

fanuelson avatar Mar 28 '18 08:03 fanuelson

Hello,

How are we supposed to use the AppLoadingComponent ? Can you provide Example ?

TwanoO67 avatar Apr 09 '18 07:04 TwanoO67

It seems he encapsuled in an exportable component the black squares that animate during app loading. He got them from bootstrapping-ngx-admin-lte (index.html). I think it's not a bad idea, but the question is: if app is not initialized yet, how can those squares displayed? It needs to be tried, I've some doubts.

fabioformosa avatar Apr 09 '18 15:04 fabioformosa

Hello, @fabioformosa, @TwanoO67 Yes fabio. I did something like that but with a different loading style component. Here is an example of use. I use AppLoadingComponent out of the 'AuthComponent'. I use it in AppComponent:

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  
  isLoading = true;

    constructor(public router: Router) {
        router.events.subscribe((event: RouterEvent) => {
            this.navigationInterceptor(event)
        })
    }

  navigationInterceptor(event: RouterEvent): void {

    if (event instanceof NavigationStart) {
      this.isLoading = true
    }
    if (event instanceof NavigationEnd) {
      this.isLoading = false
    }
    if (event instanceof NavigationCancel) {
      this.isLoading = false
    }
    if (event instanceof NavigationError) {
      this.isLoading = false
    }

  }
}

And here is the AppComponent HTML Example like bootstraping-ngx-admin-lte

<app-route-loading [loading]="isLoading" ></app-route-loading>
<router-outlet></router-outlet>

The component is in the ngx-admin-lte module, separeted from the form of how the users will use it. In this example i use the component in AppComponent but can use it in another way.

IMPORTANT: To really see the component in action, its good to create a resolve that makes any http request that takes some time just to simulate a real scenario.

Observation: My english is bad. So sorry for any mistakes i've made.

fanuelson avatar Apr 09 '18 23:04 fanuelson

Ok, I understand. It would be great if loading template was customizable through ng-content and the squares were a fallback strategy. The business logic of hide/show could be embedded in the loading component, couldn't it?

fabioformosa avatar Apr 10 '18 08:04 fabioformosa

Yeah, It would be great if loading template was customizable through ng-content.

@fabioformosa The business logic of hide/show could be embedded in the loading component, couldn't it? i dont think that its a good idea. Its good to left the business logic to the user to create as he desire.

fanuelson avatar Apr 10 '18 12:04 fanuelson

If you give to the component the name AppLoadingComponent, the only possible logic seems to me a loader that freezes all app (handle the boolean "isLoading", apply a curtain, etc). Instead, I would like to define the style of loader. If you have a component customizable in style and logic, likely it's would be almost empty and its name should be AComponentShallDoEverythingYouWant.

fabioformosa avatar Apr 10 '18 15:04 fabioformosa

We can change the name to NgxAdminLteLoading.

fanuelson avatar Apr 14 '18 00:04 fanuelson