Skip to content

Commit 892a985

Browse files
committed
Make all components standalone with explicit imports
1 parent c87ab49 commit 892a985

File tree

12 files changed

+89
-25
lines changed

12 files changed

+89
-25
lines changed

src/app/app.component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
import { filter, map, switchMap } from 'rxjs'
22

33
import { Component, OnInit, HostListener } from '@angular/core'
4-
import { MatSnackBar } from '@angular/material/snack-bar'
4+
import { RouterModule } from '@angular/router'
5+
import { MatSnackBarModule } from '@angular/material/snack-bar'
56
//import { MatSnackBar } from '@material/snackbar'
67
import { SwUpdate, VersionReadyEvent } from '@angular/service-worker'
78

89
import { LogService } from './shared/services'
10+
import { HeaderComponent } from './shared/header/header.component'
11+
import { NavbarComponent } from './shared/navbar/navbar.component'
12+
import { FooterComponent } from './shared/footer/footer.component'
13+
import { AlertsComponent } from './shared/alerts/alerts.component'
914

1015
@Component({
1116
selector: 'rangertrak-root',
17+
standalone: true,
18+
imports: [
19+
RouterModule,
20+
MatSnackBarModule,
21+
HeaderComponent,
22+
NavbarComponent,
23+
FooterComponent,
24+
AlertsComponent
25+
],
1226
templateUrl: './app.component.html',
1327
styleUrls: ['./app.component.scss']
1428
})

src/app/app.module.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { HeaderComponent, AlertsComponent, FooterComponent, IconsComponent, Inst
5050
// Import sub-modules
5151
imports: [
5252
BrowserAnimationsModule,
53-
BrowserModule.withServerTransition({ appId: 'serverApp' }),
53+
BrowserModule,
5454
CommonModule,
5555
// DayjsModule,
5656
FormsModule,
@@ -71,19 +71,29 @@ import { HeaderComponent, AlertsComponent, FooterComponent, IconsComponent, Inst
7171
// Register the ServiceWorker as soon as the app is stable
7272
// or after 30 seconds (whichever comes first).
7373
registrationStrategy: 'registerWhenStable:30000'
74-
})
74+
}),
75+
// Import standalone components
76+
AppComponent,
77+
HeaderComponent,
78+
AlertsComponent,
79+
FooterComponent,
80+
IconsComponent,
81+
InstallPromptComponent,
82+
NavbarComponent,
83+
TimePickerComponent,
84+
X404Component
7585
],
7686

7787
// Define all the components, directives and pipes,
7888
// that are declared and used inside this module.
7989
// ? If you want to use any of these in multiple modules,
8090
// bundle it into a separate module & import that in the module
8191
declarations: [
82-
AppComponent,
92+
//AppComponent, // Now standalone
8393
//AppShellComponent,
84-
NavbarComponent,
85-
FooterComponent,
86-
AlertsComponent,
94+
//NavbarComponent, // Now standalone
95+
//FooterComponent, // Now standalone
96+
//AlertsComponent, // Now standalone
8797
GmapComponent,
8898
LmapComponent,
8999
EntryComponent,
@@ -93,12 +103,15 @@ import { HeaderComponent, AlertsComponent, FooterComponent, IconsComponent, Inst
93103
//MoodEditor,
94104
//MoodRenderer,
95105
RangersComponent,
96-
X404Component,
106+
//X404Component, // Now standalone
97107
LogComponent,
98108
LocationComponent,
99109
MiniGMapComponent,
100-
MiniLMapComponent,
101-
HeaderComponent,
110+
MiniLMapComponent
111+
//HeaderComponent, // Now standalone
112+
//TimePickerComponent, // Now standalone
113+
//IconsComponent, // Now standalone
114+
//InstallPromptComponent // Now standalone,
102115
TimePickerComponent,
103116
IconsComponent,
104117
InstallPromptComponent
@@ -118,8 +131,7 @@ import { HeaderComponent, AlertsComponent, FooterComponent, IconsComponent, Inst
118131
// per https://angular.io/guide/singleton-services
119132
providers: [
120133
//ClockService, FieldReportService, LogService, PopupService, RangerService, SettingsService,
121-
{ provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: { duration: 2500 } },
122-
{ provide: MAT_COLOR_FORMATS, useValue: NGX_MAT_COLOR_FORMATS }
134+
{ provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: { duration: 2500 } }
123135
],
124136
//{provide: MAT_BANNER_DEFAULT_OPTIONS}],
125137
// Ranger,
@@ -133,6 +145,11 @@ import { HeaderComponent, AlertsComponent, FooterComponent, IconsComponent, Inst
133145
exports: [
134146
//AppShellComponent
135147
// SettingsComponent
148+
RouterModule,
149+
MaterialModule,
150+
FormsModule,
151+
ReactiveFormsModule,
152+
CommonModule
136153
]
137154
})
138155
export class AppModule { }

src/app/shared/alerts/alerts.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Subscription } from 'rxjs'
22

3-
import { DOCUMENT } from '@angular/common'
3+
import { CommonModule, DOCUMENT } from '@angular/common'
44
import { Component, Inject, OnDestroy, OnInit } from '@angular/core'
5-
import { MatSnackBar } from '@angular/material/snack-bar'
5+
import { MatSnackBarModule } from '@angular/material/snack-bar'
66
import { NavigationEnd } from '@angular/router'
77
//import { MatFormFieldModule } from '@angular/material/form-field';
88
import { MDCBanner } from '@material/banner'
@@ -14,6 +14,8 @@ import { LogService } from '../services/log.service'
1414

1515
@Component({
1616
selector: 'rangertrak-alerts',
17+
standalone: true,
18+
imports: [CommonModule, MatSnackBarModule],
1719
templateUrl: './alerts.component.html',
1820
styleUrls: ['./alerts.component.scss']
1921
})

src/app/shared/footer/footer.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import { Subscription } from 'rxjs'
22

3+
import { CommonModule, DOCUMENT, formatDate } from '@angular/common'
34
import { Component, Inject, OnDestroy, OnInit } from '@angular/core'
45

56
import { LogService, SettingsService, SettingsType } from '../services'
6-
import { DOCUMENT, formatDate } from '@angular/common'
77
import { Utility } from '../utility';
88
/**
99
* Footer component
1010
*/
1111
@Component({
1212
selector: 'rangertrak-footer',
13+
standalone: true,
14+
imports: [CommonModule],
1315
templateUrl: './footer.component.html',
1416
styleUrls: ['./footer.component.scss']
1517
})

src/app/shared/header/header.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { interval, map, Observable, Subscription } from 'rxjs'
22

3+
import { CommonModule } from '@angular/common'
34
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
45

56
import { ClockService, LogService, SettingsService, SettingsType } from '../services'
@@ -17,6 +18,8 @@ import { Utility } from '../'
1718
*/
1819
@Component({
1920
selector: 'pageHeader',
21+
standalone: true,
22+
imports: [CommonModule],
2023
templateUrl: './header.component.html',
2124
styleUrls: ['./header.component.scss']
2225
})

src/app/shared/icons/icons.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
22

33
import { faMapMarkedAlt, faInfoCircle } from '@fortawesome/free-solid-svg-icons';
44
import { mdiAccount, mdiInformationOutline } from '@mdi/js';
5-
import { MatIconRegistry } from '@angular/material/icon';
5+
import { MatIconModule } from '@angular/material/icon';
66
//import { lookupCollections, locate } from '@iconify/json'; //https://docs.iconify.design/icons/all.html vs https://docs.iconify.design/icons/icons.html
77
import { DomSanitizer } from '@angular/platform-browser';
88
import { LogService } from '../services';
@@ -49,6 +49,8 @@ type Options = {|
4949

5050
@Component({
5151
selector: 'rangertrak-icons',
52+
standalone: true,
53+
imports: [MatIconModule],
5254
templateUrl: './icons.component.html',
5355
styleUrls: ['./icons.component.scss']
5456
})

src/app/shared/install-prompt/install-prompt.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { MatButtonModule } from '@angular/material/button';
3+
import { MatDialogModule } from '@angular/material/dialog';
24

35
@Component({
46
selector: 'rangertrak-install-prompt',
7+
standalone: true,
8+
imports: [MatButtonModule, MatDialogModule],
59
templateUrl: './install-prompt.component.html',
610
styleUrls: ['./install-prompt.component.scss']
711
})

src/app/shared/navbar/navbar.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import { CommonModule } from '@angular/common'
12
import { Component, OnInit } from '@angular/core'
2-
import { NavigationEnd, NavigationError, NavigationStart, Router } from '@angular/router';
3+
import { NavigationEnd, NavigationError, NavigationStart, Router, RouterModule } from '@angular/router';
34
import { faL, faMapMarkedAlt } from '@fortawesome/free-solid-svg-icons'
5+
import { MatProgressBarModule } from '@angular/material/progress-bar'
46
import { MDCTopAppBar } from '@material/top-app-bar'
57
// import { MatButton } from '@angular/material/button'
68
// import { MatButtonModule } from '@angular/material/button'
@@ -11,6 +13,8 @@ import { Utility } from '../utility';
1113

1214
@Component({
1315
selector: 'rangertrak-navbar',
16+
standalone: true,
17+
imports: [CommonModule, RouterModule, MatProgressBarModule],
1418
templateUrl: './navbar.component.html',
1519
styleUrls: ['./navbar.component.scss']
1620
})

src/app/shared/time-picker/time-picker.component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@ import {
33
debounceTime, map, Observable, startWith, subscribeOn, Subscription, switchMap
44
} from 'rxjs'
55

6-
import { DOCUMENT } from '@angular/common'
6+
import { CommonModule, DOCUMENT } from '@angular/common'
77
import { Component, EventEmitter, Inject, Input, OnInit, Output, ViewChild } from '@angular/core'
88
import {
99
FormControl, FormGroup, FormsModule, ReactiveFormsModule, UntypedFormBuilder, UntypedFormGroup,
1010
Validators
1111
} from '@angular/forms'
12-
import { ThemePalette } from '@angular/material/core'
12+
import { MatDatepickerModule } from '@angular/material/datepicker'
13+
import { MatFormFieldModule } from '@angular/material/form-field'
14+
import { MatInputModule } from '@angular/material/input'
15+
import { MatNativeDateModule } from '@angular/material/core'
1316

1417
import {
1518
FieldReportService, FieldReportStatusType, LocationType, LogService, RangerService, RangerType,
@@ -38,6 +41,16 @@ import {
3841

3942
@Component({
4043
selector: 'rangertrak-time-picker',
44+
standalone: true,
45+
imports: [
46+
CommonModule,
47+
FormsModule,
48+
ReactiveFormsModule,
49+
MatDatepickerModule,
50+
MatFormFieldModule,
51+
MatInputModule,
52+
MatNativeDateModule
53+
],
4154
templateUrl: './time-picker.component.html',
4255
styleUrls: ['./time-picker.component.scss']
4356
})
@@ -88,7 +101,7 @@ export class TimePickerComponent implements OnInit {
88101
public stepHour = 1
89102
public stepMinute = 1
90103
public stepSecond = 1
91-
public color: ThemePalette = 'primary'
104+
public color: 'primary' | 'accent' | 'warn' = 'primary'
92105
disableMinute = false
93106
hideTime = false
94107
//dateCtrl = new FormControl(new Date()) //TODO: Still need to grab the result during submit...!

src/app/x404/x404.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit } from '@angular/core'
2+
import { HeaderComponent } from '../shared/header/header.component'
23

34
// TODO: https://bobrov.dev/blog/angular-smart-404-page/ - suggest the *right* page!
45

@@ -7,6 +8,8 @@ import { Component, OnInit } from '@angular/core'
78
*/
89
@Component({
910
selector: 'rangertrak-x404',
11+
standalone: true,
12+
imports: [HeaderComponent],
1013
templateUrl: './x404.component.html',
1114
styleUrls: ['./x404.component.scss']
1215
})

0 commit comments

Comments
 (0)