• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

COS301-SE-2024 / ECHO / 11092462749

29 Sep 2024 12:03PM UTC coverage: 65.619% (-2.7%) from 68.342%
11092462749

Pull #415

github

web-flow
Merge d3626b5cc into 1cba1227b
Pull Request #415: Feat/render deployment

164 of 388 branches covered (42.27%)

Branch coverage included in aggregate %.

36 of 75 new or added lines in 7 files covered. (48.0%)

38 existing lines in 3 files now uncovered.

1590 of 2285 relevant lines covered (69.58%)

5.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.61
/Frontend/src/app/app.component.ts
1
import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from "@angular/core";
1✔
2
import { RouterOutlet, Router, NavigationEnd, ActivatedRoute } from "@angular/router";
1✔
3
import { BottomPlayerComponent } from "./components/organisms/bottom-player/bottom-player.component";
1✔
4
import { BottomNavComponent } from "./components/organisms/bottom-nav/bottom-nav.component";
1✔
5
import { ScreenSizeService } from "./services/screen-size-service.service";
1✔
6
import { SwUpdate } from "@angular/service-worker";
1✔
7
import { filter } from "rxjs/operators";
1✔
8
import { CommonModule, isPlatformBrowser } from "@angular/common";
1✔
9
import { ProviderService } from "./services/provider.service";
1✔
10
import { PageHeaderComponent } from "./components/molecules/page-header/page-header.component";
1✔
11
import { MoodService } from "./services/mood-service.service";
1✔
12
import {
1✔
13
  BackgroundAnimationComponent
14
} from "./components/organisms/background-animation/background-animation.component";
15
import { ExpandableIconComponent } from './components/organisms/expandable-icon/expandable-icon.component';
1✔
16
import { NavbarComponent } from "./components/organisms/navbar/navbar.component";
1✔
17
import { SideBarComponent } from './components/organisms/side-bar/side-bar.component';
1✔
18
//template imports
19
import { HeaderComponent } from "./components/organisms/header/header.component";
1✔
20
import { OtherNavComponent } from "./components/templates/desktop/other-nav/other-nav.component";
1✔
21
import { AuthService } from "./services/auth.service";
1✔
22
import { PlayerStateService } from "./services/player-state.service";
1✔
23
import { Observable } from "rxjs";
24

25
@Component({
26
  selector: "app-root",
27
  standalone: true,
28
  imports: [
29
    RouterOutlet,
30
    BottomPlayerComponent,
31
    CommonModule,
32
    BottomNavComponent,
33
    PageHeaderComponent,
34
    HeaderComponent,
35
    OtherNavComponent,
36
    BackgroundAnimationComponent,
37
    NavbarComponent,
38
    SideBarComponent,
39
    ExpandableIconComponent
40
  ],
41
  templateUrl: "./app.component.html",
42
  styleUrls: ["./app.component.css"]
43
})
44
export class AppComponent implements OnInit, OnDestroy
1✔
45
{
46
  update: boolean = false;
9✔
47
  screenSize!: string;
48
  displayPageName: boolean = false;
9✔
49
  columnStart: number = 3;
9✔
50
  columnStartNav: number = 1;
9✔
51
  colSpan: number = 4;
9✔
52
  isSidebarOpen: boolean = false;
9✔
53
  protected displaySideBar: boolean = false;
9✔
54
  protected isAuthRoute: boolean = false;
9✔
55
  protected isCallbackRoute: boolean = false;
9✔
56
  // Mood Service Variables
57
  currentMood!: string;
58
  moodComponentClasses!: { [key: string]: string };
59
  backgroundMoodClasses!: { [key: string]: string };
60
  isLoggedIn$!: Observable<boolean>;
61
  isSideBarHidden!: boolean; // Declare Input
62

63
  constructor(
64
    private router: Router,
9✔
65
    private route: ActivatedRoute,
9✔
66
    private screenSizeService: ScreenSizeService,
9✔
67
    private providerService: ProviderService,
9✔
68
    private updates: SwUpdate,
9✔
69
    public moodService: MoodService,
9✔
70
    private authService: AuthService,
9✔
71
    private playerStateService: PlayerStateService,
9✔
72
    @Inject(PLATFORM_ID) private platformId: Object
9✔
73
  )
74
  {
75
    this.isLoggedIn$ = this.authService.isLoggedIn$;
9✔
76
    updates.versionUpdates.subscribe(event =>
9✔
77
    {
78
      if (event.type === "VERSION_READY")
9✔
79
      {
80
        updates.activateUpdate().then(() =>
9✔
81
        {
82
          this.update = true;
×
83
          document.location.reload();
×
84
        });
85
      }
86
    });
87

88
    this.router.events.pipe(
9✔
89
      filter((event): event is NavigationEnd => event instanceof NavigationEnd)
9✔
90
    ).subscribe((event: NavigationEnd) =>
91
    {
92
      this.isAuthRoute = ["/login", "/register"].includes(event.urlAfterRedirects);
9✔
93
      this.isCallbackRoute = ["/auth/callback"].includes(event.urlAfterRedirects);
9✔
94
    });
95
  }
96

97
  async ngOnInit()
98
  {
99
    window.addEventListener('beforeunload', this.handleTabClose);
1✔
100
    this.screenSizeService.screenSize$.subscribe(screenSize =>
1✔
101
    {
102
      this.screenSize = screenSize;
1✔
103
    });
104

105
    // Handle OAuth login and redirect to /auth/callback
106
    const url = window.location.href;
1✔
107
    if (url.includes("access_token")) {
1!
NEW
108
      const fragment = url.split("#")[1];  // Get everything after #
×
NEW
109
      this.router.navigate(['/auth/callback'], { fragment });
×
110
    }
111
  }
112

113
  // Handle the browser tab close event
114
  handleTabClose = (event: BeforeUnloadEvent) => {
9✔
NEW
115
    this.authService.signOut().subscribe({
×
116
      next: (response) => {
NEW
117
        console.log('User signed out successfully on tab close');
×
118
      },
119
      error: (error) => {
NEW
120
        console.error('Error during sign out on tab close:', error);
×
121
      }
122
    });
123
  }
124

125
  async ngAfterViewInit()
126
  {
127
    this.playerStateService.setReady();
1✔
128
  }
129

130
  isCurrentRouteAuth(): boolean
131
  {
132
    return ["/login", "/register", "/Auth/callback"].includes(this.router.url);
2✔
133
  }
134

135
  layout(isSidebarOpen: boolean) {
136
    this.isSidebarOpen = isSidebarOpen;
3✔
137
    this.columnStart = isSidebarOpen ? 1 : 3;
3✔
138
    this.colSpan = isSidebarOpen ? 5 : 4;
3✔
139
  }
140

141
  isReady(): boolean
142
  {
143
    if (isPlatformBrowser(this.platformId))
2✔
144
      return this.playerStateService.isReady();
1✔
145
    return false;
1✔
146
  }
147

148
  ngOnDestroy() {
149
    window.removeEventListener('beforeunload', this.handleTabClose);
10✔
150
  }
151

152

153
  toggleSideBar() {
154
    this.isSideBarHidden = !this.isSideBarHidden;
1✔
155
    this.layout(this.isSideBarHidden);
1✔
156
  }
157

158

159
}
160

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc