Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/high frontend update #358

Merged
merged 23 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
69b692f
📐Switch mood list Accent
21434809 Sep 9, 2024
fa5e68a
🔥Remove console.log statements
21434809 Sep 9, 2024
daa71a2
📐Refactor mood list component to fix selected mood logic
21434809 Sep 9, 2024
7e7bfca
📐Refactor grid layout in app component and side bar component
21434809 Sep 9, 2024
9bdf340
🚧created a plus icon from svg icon for exapading side bar
21434809 Sep 10, 2024
ed4cadd
🎉Create expandable icon component for sidebar
21434809 Sep 10, 2024
d2576bb
📐Refactor SvgIconComponent to accept dynamic width
21434809 Sep 10, 2024
bd2a8c7
📐added side bar toggle on app.component
21434809 Sep 11, 2024
ec44d85
📐Refactor grid layout in app component and side bar component can now…
21434809 Sep 11, 2024
d36b01d
📐Refactor grid layout in app component and side bar component to incl…
21434809 Sep 11, 2024
072bf16
📐Switch mood list Accent
21434809 Sep 9, 2024
4ac58c2
🔥Remove console.log statements
21434809 Sep 9, 2024
88b7ffd
📐Refactor mood list component to fix selected mood logic
21434809 Sep 9, 2024
2006f37
📐Refactor grid layout in app component and side bar component
21434809 Sep 9, 2024
955c68b
🚧created a plus icon from svg icon for exapading side bar
21434809 Sep 10, 2024
4dcea1b
🎉Create expandable icon component for sidebar
21434809 Sep 10, 2024
b724b7f
📐Refactor SvgIconComponent to accept dynamic width
21434809 Sep 10, 2024
2f6dec4
📐added side bar toggle on app.component
21434809 Sep 11, 2024
a0db4fb
📐Refactor grid layout in app component and side bar component can now…
21434809 Sep 11, 2024
2c85cc4
📐Refactor grid layout in app component and side bar component to incl…
21434809 Sep 11, 2024
45750bb
Merge branch 'feat/highFrontendUpdate' of https://github.com/COS301-S…
21434809 Sep 23, 2024
ac513aa
Merge branch 'develop' into feat/highFrontendUpdate
21434809 Sep 25, 2024
49cb5f2
📐Move wildcard in app.routes.ts
Douglasj02 Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
<router-outlet></router-outlet>
</div>
<div *ngIf="!isCurrentRouteAuth()">
<div *ngIf="screenSize === 'desktop'" class="grid grid-cols-[1fr,1fr,1fr,1fr,200px] grid-rows-[0.01fr,0.01fr,0.67fr] min-h-screen pl-2 pr-2 relative">
<app-header class="col-start-2 col-span-1 row-start-2 row-span-1"></app-header>
<div *ngIf="screenSize === 'desktop'" class="grid grid-cols-5 grid-rows-[0.01fr,0.01fr,0.67fr] min-h-screen pl-2 pr-2 relative">
<app-header [ngClass]="'col-start-' + columnStart" class="col-span-1 row-start-2 row-span-1 pl-[2.5vw]"></app-header>
<app-other-nav class="col-start-5 col-span-1 row-start-1 row-span-1 justify-self-end"></app-other-nav>
<app-left class="col-start-1 col-span-1 row-start-1 row-span-3"></app-left>
<div id="center" class="no-scrollbar col-span-4 row-start-3 row-span-2 overflow-y-scroll overflow-hidden">
<app-navbar class="col-start-1 col-span-1 row-start-1 row-span-3"></app-navbar>
<app-side-bar [isSideBarHidden]="isSidebarOpen" (sidebarToggled)="layout($event)" class="col-start-1 col-span-1 row-start-2 row-span-3 pr-2"></app-side-bar>
<!-- dont remove this div -->
<div class="col-span-4"></div>
<div [ngClass]="'col-span-' + colSpan + ' col-start-' + columnStart"
id="center"
class="no-scrollbar row-span-2 row-start-3 overflow-y-scroll overflow-hidden p-2">
<router-outlet></router-outlet>
</div>
</div>
</div>
<div *ngIf="screenSize === 'mobile'">
<div class="grid grid-cols-3 grid-rows-[0.1fr,1fr,1fr] min-h-screen relative">
<app-header class="col-start-2 col-span-1 row-start-1 row-span-1"></app-header>
Expand Down
21 changes: 16 additions & 5 deletions Frontend/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { ScreenSizeService } from "./services/screen-size-service.service";
import { SwUpdate } from "@angular/service-worker";
import { filter } from "rxjs/operators";
import { CommonModule, isPlatformBrowser } from "@angular/common";
import { SideBarComponent } from "./components/organisms/side-bar/side-bar.component";
import { ProviderService } from "./services/provider.service";
import { PageHeaderComponent } from "./components/molecules/page-header/page-header.component";
import { MoodService } from "./services/mood-service.service";
import { BackgroundAnimationComponent } from "./components/organisms/background-animation/background-animation.component";

import { NavbarComponent } from "./components/organisms/navbar/navbar.component";
import { SideBarComponent } from './components/organisms/side-bar/side-bar.component';
//template imports
import { HeaderComponent } from "./components/organisms/header/header.component";
import { OtherNavComponent } from "./components/templates/desktop/other-nav/other-nav.component";
Expand All @@ -32,7 +33,9 @@ import { Observable } from "rxjs";
HeaderComponent,
OtherNavComponent,
LeftComponent,
BackgroundAnimationComponent
BackgroundAnimationComponent,
NavbarComponent,
SideBarComponent
],
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
Expand All @@ -41,6 +44,10 @@ export class AppComponent implements OnInit, OnDestroy {
update: boolean = false;
screenSize!: string;
displayPageName: boolean = false;
columnStart: number = 3;
columnStartNav: number = 1;
colSpan: number = 4;
isSidebarOpen: boolean = false;
protected displaySideBar: boolean = false;
protected isAuthRoute: boolean = false;
protected isCallbackRoute: boolean = false;
Expand Down Expand Up @@ -76,12 +83,11 @@ export class AppComponent implements OnInit, OnDestroy {
this.router.events.pipe(
filter((event): event is NavigationEnd => event instanceof NavigationEnd)
).subscribe((event: NavigationEnd) => {
console.log('Navigation ended:', event.urlAfterRedirects);
this.isAuthRoute = ['/login', '/register'].includes(event.urlAfterRedirects);
this.isCallbackRoute = ['/auth/callback'].includes(event.urlAfterRedirects);
});
}

async ngOnInit() {
this.screenSizeService.screenSize$.subscribe(screenSize => {
this.screenSize = screenSize;
Expand All @@ -95,6 +101,11 @@ export class AppComponent implements OnInit, OnDestroy {
return ['/login', '/register','/Auth/callback'].includes(this.router.url);
}

layout(isSidebarOpen: boolean) {
this.isSidebarOpen = isSidebarOpen;
this.columnStart = isSidebarOpen ? 1 : 3;
this.colSpan = isSidebarOpen ? 5 : 4;
}

isReady(): boolean {
if (isPlatformBrowser(this.platformId))
Expand All @@ -106,4 +117,4 @@ export class AppComponent implements OnInit, OnDestroy {
{
this.authService.signOut();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<button
(click)="handleClick($event)"
[ngClass]="isSelected ? moodComponentClassesDark[this.moodService.getCurrentMood()] : moodComponentClassesHover[this.moodService.getCurrentMood()]"
[ngClass]="isSelected ? moodComponentClassesHover[this.moodService.getCurrentMood()] : moodComponentClassesDark[this.moodService.getCurrentMood()]"
class="ml-1 mb-1 px-5 py-2 rounded-full focus:cursor-pointer">
{{ label }}
</button>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<svg class="bounce-on-hover" fill-rule="evenodd" clip-rule="evenodd" (click)="onClick()" width="10vh" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg class="bounce-on-hover" fill-rule="evenodd" clip-rule="evenodd" (click)="onClick()" [attr.width]="width" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle class="bounce-circle"
[ngClass]="{'animate': isAnimating}"
[class]="circleColor()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export class SvgIconComponent {
moodComponentClasses!: { [key: string]: string };
@Input() svgPath: string = '';
@Input() fillColor: string = '#000000';
@Input() width: string = '10vh';
@Input() selected: boolean = false;
@Input() isAnimating: boolean = false;
@Input() middleColor: string = '#FFFFFF';
@Input() middleColor: string = '#191716';
@Input() pathHeight: string = '1'; // Default path height as a string
@Input() circleAnimation: boolean = false;
@Output() svgClick = new EventEmitter<MouseEvent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<app-button-component
*ngFor="let mood of moods; let i = index"
[label]="mood"
[isSelected]="selectedMood === null && i === 0 || selectedMood === i"
[isSelected]="selectedMood === i"
(click)="selectMood(i)">
</app-button-component>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { ButtonComponentComponent } from './../../atoms/button-component/button-
})
export class MoodListComponent {
@Input() moods!: string[];
@Input() selectedMood!: number | null;
@Input() selectedMood = 0;
@Input() screenSize!: string;

constructor(public moodService: MoodService) {

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ export class MoodsListComponent implements OnInit {
this.redirectToMoodPage.emit(mood);
}
ngOnInit(): void {
for (let mood of this.moods){
console.log(mood);
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class TopCardComponent {
});

dialogRef.afterClosed().subscribe((result) => {
console.log('The dialog was closed');
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<app-svg-icon
[svgPath]="svgString"
[selected]="true"
[fillColor]="'#000000'"
[width]="'1.5vw'"
(svgClick)="handleSvgClick($event)">
</app-svg-icon>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ExpandableIconComponent } from './expandable-icon.component';

describe('ExpandableIconComponent', () => {
let component: ExpandableIconComponent;
let fixture: ComponentFixture<ExpandableIconComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ExpandableIconComponent]
})
.compileComponents();

fixture = TestBed.createComponent(ExpandableIconComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Component, Output, EventEmitter } from '@angular/core';
import { CommonModule } from "@angular/common";
import { SvgIconComponent } from '../../atoms/svg-icon/svg-icon.component';

const SVG_PATHS = {
PLUS: 'M20 0 H30 V20 H50 V30 H30 V50 H20 V30 H0 V20 H20 Z',
MIN: 'M0 20 H50 V30 H0 Z',
};

@Component({
selector: 'app-expandable-icon',
standalone: true,
imports: [CommonModule, SvgIconComponent],
templateUrl: './expandable-icon.component.html',
styleUrl: './expandable-icon.component.css'
})
export class ExpandableIconComponent {

svgString: string = SVG_PATHS.MIN;

@Output() svgClicked = new EventEmitter<void>();

handleSvgClick(event: MouseEvent) {
this.svgString = this.svgString === SVG_PATHS.PLUS ? SVG_PATHS.MIN : SVG_PATHS.PLUS;
this.svgClicked.emit();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div *ngIf="screenSize === 'desktop'" class="flex flex-col pl-1 ml-[2vw]">
<div *ngIf="screenSize === 'desktop'" class="flex flex-col">
<div class="card-body relative">
<app-page-title>Favourite Moods</app-page-title>
<app-moods-list [moods]="favouriteMoods" (redirectToMoodPage)="redirectToMoodPage($event)"></app-moods-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@
.scrollbar-hidden::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
.container {
width: var(--tw-w);
height: var(--tw-h);
}

.view-more-container {
/* Adjust the padding value based on your needs */
margin-bottom: calc(50vh - 50px); /* Assuming the button's height is around 100px */
Expand All @@ -47,4 +44,3 @@
color: inherit !important; /* Neutralizes text color change */
/* Add any other properties that change on hover to be neutralized */
}

Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<div class="z-10 w-[42vh]" style="--tw-h: 75vh; left: 1vw; top: 10.2vh;">
<div class="container pl-5 rounded-md h-full">
<div class="z-10" style="left: 1vw; top: 10.2vh;">
<div [ngClass]="{'w-[2.5vw] h-[2vw]': isSideBarHidden, 'w-[20vw] h-[75vh]': !isSideBarHidden}" class="container pl-5 rounded-md max-h-screen " >
<div [ngClass]="moodComponentClasses[moodService.getCurrentMood()]" class="rounded-lg overflow-auto h-full flex flex-col justify-between scrollbar-hidden">
<!-- SVG button always visible -->
<div class="flex justify-between items-center mb-2 mt-3">
<div class="button-container" [ngClass]="getButtonClasses('suggestions')">
<button class="px-10 text-sm font-bold text-white focus:outline-none truncate" (click)="selectOption('suggestions')">Suggestions</button>
<div class="button-container">
<app-expandable-icon class="focus:outline-none max-w-[.5vw]" (click)="toggleSideBar()"></app-expandable-icon>
</div>
<div class="button-container" [ngClass]="getButtonClasses('recentListening')">
<button class="px-10 text-sm text-white focus:outline-none truncate" (click)="selectOption('recentListening')">Recent listening</button>
<!-- Only show these buttons when the sidebar is expanded -->
<div *ngIf="!isSideBarHidden" class="button-container" [ngClass]="getButtonClasses('suggestions')">
<button class="px-10 text-sm font-bold text-white focus:outline-none truncate max-w-[9.5vw] flex-1" (click)="selectOption('suggestions')">Suggestions</button>
</div>
<div *ngIf="!isSideBarHidden" class="button-container" [ngClass]="getButtonClasses('recentListening')">
<button class="px-10 text-sm text-white focus:outline-none truncate max-w-[9.5vw] flex-1" (click)="selectOption('recentListening')">Recent listening</button>
</div>
</div>
<div class="mt-7 mx-3 flex-grow overflow-auto scrollbar-hidden">
<ng-container *ngIf="!isLoading; else loading">

<!-- Content of the sidebar -->
<div *ngIf="!isSideBarHidden" class="mt-7 mx-3 flex-grow overflow-auto scrollbar-hidden">
<ng-container *ngIf="!isLoading ; else loading">
<div *ngFor="let card of getSelectedCardData(); let i = index">
<app-song-cards [svgSize]="'2.5vw'" [imgSize]="'5vw'" [card]="card"></app-song-cards>
</div>
Expand All @@ -22,9 +29,12 @@
<app-toast></app-toast>
</div>
</div>

</div>
</div>
</div>


<div *ngIf="isEchoModalVisible" id="echo-songs" tabindex="-1" aria-hidden="true" class="fixed top-0 right-0 left-0 z-50 flex justify-center items-center w-full h-full bg-black bg-opacity-50">
<div class="relative p-4 w-full max-w-2xl max-h-full">
<!-- Modal content -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild, ChangeDetectorRef } from "@angular/core";
import { Component, OnInit, ViewChild, EventEmitter, Output, ChangeDetectorRef,Input } from "@angular/core";
import { MatCard, MatCardContent } from "@angular/material/card";
import { NgClass, NgForOf, NgIf } from "@angular/common";
import { SpotifyService } from "../../../services/spotify.service";
Expand All @@ -13,19 +13,22 @@ import { SearchService } from "../../../services/search.service";
import { SkeletonSongCardComponent } from "../../atoms/skeleton-song-card/skeleton-song-card.component";
import { ToastComponent } from "../../../components/organisms/toast/toast.component";
import { YouTubeService } from "../../../services/youtube.service";
import { ExpandableIconComponent } from '../../organisms/expandable-icon/expandable-icon.component';

type SelectedOption = "suggestions" | "recentListening";

@Component({
selector: "app-side-bar",
standalone: true,
imports: [MatCard, MatCardContent, NgForOf, NgIf, NgClass, EchoButtonComponent, SongCardsComponent, SkeletonSongCardComponent, ToastComponent],
imports: [MatCard, MatCardContent, NgForOf, NgIf, NgClass, EchoButtonComponent, SongCardsComponent, SkeletonSongCardComponent, ToastComponent, ExpandableIconComponent],
templateUrl: "./side-bar.component.html",
styleUrls: ["./side-bar.component.css"]
styleUrls: ["./side-bar.component.css"],
})
export class SideBarComponent implements OnInit
{
@ViewChild(ToastComponent) toastComponent!: ToastComponent; // Declare ToastComponent
@Output() sidebarToggled = new EventEmitter<boolean>(); // Declare EventEmitter
@Input() isSideBarHidden!: boolean; // Declare Input

// Mood Service Variables
moodComponentClasses!: { [key: string]: string };
Expand Down Expand Up @@ -62,13 +65,13 @@ export class SideBarComponent implements OnInit
isLoading: boolean = true;
skeletonArray = Array(10);

async ngAfterViewInit()
{
this.cdRef.detectChanges();

toggleSideBar() {
this.isSideBarHidden = !this.isSideBarHidden;
this.sidebarToggled.emit(this.isSideBarHidden); // Emit event
}

toggleDropdown(): void
{
toggleDropdown(): void {
this.isDropdownVisible = !this.isDropdownVisible;
}

Expand Down Expand Up @@ -116,9 +119,7 @@ export class SideBarComponent implements OnInit
{
this.suggestionsCardData = await this.spotifyService.getQueue(this.provider);
await this.suggestionsCardData.unshift(this.getEchoedCardData()[0]);
}
catch (error)
{
} catch (error) {
console.error("Error loading up next data:", error);
}
}
Expand Down Expand Up @@ -154,9 +155,9 @@ export class SideBarComponent implements OnInit
{
this.isLoading = true;
const data = await this.spotifyService.getRecentlyPlayedTracks(this.provider);
console.log("Recently Played Tracks Data:", data);
data.items.forEach((item: any) =>
{
console.log("First track: ", data.items[0]);
console.log("First track: ", data.items[0]);
data.items.forEach((item: any) => {
const trackId = item.track.id;
if (!this.recentListeningCardData.find(track => track.id === trackId))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<app-navbar></app-navbar>
<app-side-bar></app-side-bar>
<app-side-bar></app-side-bar>
Loading
Loading