@@ -6,6 +6,7 @@ import { GlobalMessageService } from '~/app/services/messaging.service';
66import { EnvService , EnvVar } from '~/app/services/environment.service' ;
77import { HttpClient } from '@angular/common/http' ;
88import { firstValueFrom } from 'rxjs' ;
9+ import DatabaseService from '~/app/services/database.service' ;
910
1011interface DiagnosticEndpoint {
1112 label : string ;
@@ -29,6 +30,8 @@ interface EndpointGroup {
2930 showRunAll ?: boolean ;
3031}
3132
33+ declare const __APP_VERSION__ : string ;
34+
3235@Component ( {
3336 standalone : true ,
3437 imports : [ CommonModule , PrimeNgModule ] ,
@@ -43,11 +46,18 @@ export default class ErrorPage implements OnInit {
4346 endpoints : DiagnosticEndpoint [ ] = [ ] ;
4447 resolutionEndpoints : DiagnosticEndpoint [ ] = [ ] ;
4548
49+ appVersion = typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : '0.0.0' ;
50+ updateStatus = 'pending' ;
51+ updateMessage = '' ;
52+
53+ databaseResults = '' ;
54+ databaseSuccess = '' ;
55+
4656 constructor (
4757 private http : HttpClient ,
4858 private route : ActivatedRoute ,
49- private messagingService : GlobalMessageService ,
5059 private envService : EnvService ,
60+ private databaseService : DatabaseService ,
5161 ) { }
5262
5363 ngOnInit ( ) : void {
@@ -156,30 +166,59 @@ export default class ErrorPage implements OnInit {
156166 showReset : false ,
157167 showRunAll : true ,
158168 } ,
159- {
160- title : 'Remote Endpoint Tests' ,
161- endpoints : [ ] ,
162- showReset : false ,
163- showRunAll : true ,
164- } ,
165169 ] ;
166170 }
167171
168- reload ( ) {
169- this . messagingService . showInfo ( 'Reloading...' , '' ) ;
170- window . location . href = '/' ;
172+ checkDatabaseConnection ( ) : void {
173+ this . databaseResults = 'Loading...' ;
174+ this . databaseSuccess = '' ;
175+ try {
176+ this . databaseService . instance . checkAllTables ( ) . subscribe ( {
177+ next : ( results ) => {
178+ this . databaseResults = '' ;
179+ if ( ! results || ! results . length ) {
180+ throw new Error ( 'No tables found in the database.' ) ;
181+ }
182+ this . databaseSuccess = 'passed' ;
183+ results . forEach ( ( table ) => {
184+ this . databaseResults += `${ table . success } ${ table . table } (${ table . count } records)\n` ;
185+ if ( table . success !== '✅' ) {
186+ this . databaseSuccess = 'some_errors' ;
187+ } ;
188+ } ) ;
189+ } ,
190+ error : ( err ) => {
191+ this . databaseResults = `Error checking tables: ${ err . message || err } ` ;
192+ this . databaseSuccess = 'errored' ;
193+ } ,
194+ } ) ;
195+ } catch ( err : any ) {
196+ this . databaseResults = `Error checking tables: ${ err . message || err } ` ;
197+ this . databaseSuccess = 'errored' ;
198+ }
171199 }
172200
173- clearStorage ( ) {
174- this . messagingService . showInfo ( 'Clearing Session Data' , '' ) ;
175- localStorage . clear ( ) ;
176- sessionStorage . clear ( ) ;
177- this . reload ( ) ;
201+ checkAppVersion ( ) : void {
202+ const currentVersion = this . appVersion ;
203+ this . http . get < { version : string } > ( 'https://raw.githubusercontent.com/Lissy93/domain-locker/refs/heads/main/package.json' )
204+ . subscribe ( {
205+ next : ( data ) => {
206+ const latestVersion = data . version ;
207+ if ( latestVersion && latestVersion !== currentVersion ) {
208+ this . updateStatus = 'update_available' ;
209+ this . updateMessage = `A new version (${ latestVersion } ) is available. You are running ${ currentVersion } .` ;
210+ } else {
211+ this . updateStatus = 'up_to_date' ;
212+ this . updateMessage = `You are running the latest version (${ currentVersion } ).` ;
213+ }
214+ } ,
215+ error : ( ) => {
216+ this . updateStatus = 'error' ;
217+ this . updateMessage = 'Could not check for updates. Please try again later.' ;
218+ }
219+ } ) ;
178220 }
179221
180- enableDebugging ( ) {
181- this . messagingService . showInfo ( 'Enabling Debug Mode' , 'Error logs and diagnostics will be send to us' ) ;
182- }
183222
184223 getEnvValue ( key : EnvVar , fallback ?: string ) : string {
185224 return this . envService . getEnvVar ( key , fallback ) || fallback || '' ;
0 commit comments