-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
app.component.ts
36 lines (31 loc) · 1.28 KB
/
app.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { HttpClient } from '@angular/common/http';
import { Component, NgZone, OnInit } from '@angular/core';
import { ActivatedRoute, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
import { NgbdDemoVersionsComponent } from './demo-versions.component';
import { COMPONENT_LIST } from './shared/component-list';
import { environment } from '../environments/environment';
import { AnalyticsService } from './services/analytics.service';
import { map } from 'rxjs/operators';
import { of } from 'rxjs';
@Component({
standalone: true,
selector: 'ngbd-app',
templateUrl: './app.component.html',
imports: [RouterLink, RouterLinkActive, RouterOutlet, NgbdDemoVersionsComponent],
})
export class AppComponent implements OnInit {
downloadCount = '';
navbarCollapsed = true;
components = COMPONENT_LIST;
constructor(private _analytics: AnalyticsService, route: ActivatedRoute, zone: NgZone, httpClient: HttpClient) {
if (environment.production) {
httpClient
.get<{ downloads: string }>('https://api.npmjs.org/downloads/point/last-month/@ng-bootstrap/ng-bootstrap')
.pipe(map((data) => data?.downloads))
.subscribe({ next: (count) => (this.downloadCount = count.toLocaleString()), error: () => of('') });
}
}
ngOnInit(): void {
this._analytics.trackPageViews();
}
}