Skip to content

Commit

Permalink
Show active node in footer
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Johnston committed Oct 7, 2023
1 parent eb6ecc7 commit 6549900
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 85 deletions.
79 changes: 0 additions & 79 deletions .github/workflows/master_joeljca.yml

This file was deleted.

4 changes: 2 additions & 2 deletions blog-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { NavigationCancel, NavigationEnd, NavigationStart, Router, RouterEvent } from '@angular/router';
import { filter } from 'rxjs';
import { StrengthJournalConstants } from './constants';
import { JoelJConstants } from './constants';
import { MonitoringService } from './services/monitoring.service';

@Component({
Expand All @@ -16,7 +16,7 @@ export class AppComponent implements OnInit {
constructor(private monitoring: MonitoringService, private router: Router) {}

ngOnInit(): void {
if (!StrengthJournalConstants.isServer) this.monitoring.checkIn();
if (!JoelJConstants.isServer) this.monitoring.checkIn();
this.router.events.pipe(
filter(event => event instanceof RouterEvent)
)
Expand Down
2 changes: 1 addition & 1 deletion blog-app/src/app/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const StrengthJournalConstants = {
export const JoelJConstants = {
isServer: (typeof window == 'undefined') || Number.isNaN(window.scrollY + 1)
}
5 changes: 5 additions & 0 deletions blog-app/src/app/footer/footer.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<p>Credits to <a href="https://twitter.com/mdo">@mdo</a> for the original blog theme.</p>
<p>
{{ serverInfo().node }}
{{ serverInfo().slot }}
{{ serverInfo().version }}
</p>
8 changes: 8 additions & 0 deletions blog-app/src/app/footer/footer.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { JoelJConstants } from '../constants';

@Component({
selector: 'app-footer',
Expand All @@ -12,4 +13,11 @@ export class FooterComponent implements OnInit {
ngOnInit(): void {
}

serverInfo() {
if (!JoelJConstants.isServer)
return (window as any).serverInfo;
else
return { node: "ssr", slot: "ssr", version: "ssr" };
}

}
6 changes: 3 additions & 3 deletions blog-app/src/app/services/monitoring.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
import { environment } from 'src/environments/environment';
import { StrengthJournalConstants } from '../constants';
import { JoelJConstants } from '../constants';

@Injectable({
providedIn: 'root'
Expand All @@ -15,15 +15,15 @@ export class MonitoringService {
});

constructor() {
if (!StrengthJournalConstants.isServer && environment.production) {
if (!JoelJConstants.isServer && environment.production) {
console.info('Loading application insights.');
this.insights.loadAppInsights();
}
}

checkIn() {
try {
if (!StrengthJournalConstants.isServer)
if (!JoelJConstants.isServer)
this.insights.trackEvent({name: 'CheckIn'}, (<any>window).serverInfo);
}
catch (e) {
Expand Down

0 comments on commit 6549900

Please sign in to comment.