Skip to content

Commit 0c24387

Browse files
McNaBrysamuelim01
andauthored
Update history page styles (#101)
* Update history page styles * Move history out of account as parent div being flex/grid affects table style * Adjust width of side panel to be maximum 90% of screen width * Update styles of readonly editor * Fix compose.dev.yml * Fix panel description styling Co-authored-by: samuelim01 <[email protected]> * Conver history panel to primeNG sidebar * Fix sorting for history table * Remove console log statements in history component * Add fix to history * Make SortEvent required * Adjust undefined handling for dt * Adjust time format * Remove removable sort * Fix question sort * Fix filter --------- Co-authored-by: Samuel Lim <[email protected]> Co-authored-by: samuelim01 <[email protected]>
1 parent 8520762 commit 0c24387

File tree

11 files changed

+179
-105
lines changed

11 files changed

+179
-105
lines changed

compose.dev.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ services:
4848
- /app/node_modules
4949
- ./services/collaboration:/app
5050

51+
collaboration-db:
52+
ports:
53+
- 27020:27017
54+
5155
history:
5256
command: npm run dev
5357
ports:

frontend/src/_services/history.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
22
import { HttpClient } from '@angular/common/http';
33
import { Observable } from 'rxjs';
44
import { map } from 'rxjs/operators';
5-
import { historyResponse, MatchingHistory } from '../app/account/history/history.model';
5+
import { historyResponse, MatchingHistory } from '../app/history/history.model';
66
import { ApiService } from './api.service';
77

88
@Injectable({
@@ -22,7 +22,8 @@ export class HistoryService extends ApiService {
2222
id: item._id,
2323
roomId: item.roomId,
2424
collaborator: item.collaborator.username,
25-
question: item.question,
25+
title: item.question.title,
26+
description: item.question.description,
2627
topics: item.question.topics,
2728
difficulty: item.question.difficulty,
2829
status: item.status,

frontend/src/app/account/account.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { LoginComponent } from './login/login.component';
55
import { RegisterComponent } from './register/register.component';
66
import { LayoutComponent } from './layout.component';
77
import { ProfileComponent } from './profile/profile.component';
8-
import { HistoryComponent } from './history/history.component';
98

109
const routes: Routes = [
1110
{
@@ -16,7 +15,6 @@ const routes: Routes = [
1615
{ path: 'login', component: LoginComponent },
1716
{ path: 'register', component: RegisterComponent },
1817
{ path: 'profile', component: ProfileComponent },
19-
{ path: 'history', component: HistoryComponent },
2018
],
2119
},
2220
];

frontend/src/app/account/account.module.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { RegisterComponent } from './register/register.component';
77
import { LayoutComponent } from './layout.component';
88
import { AccountRoutingModule } from './account.component';
99
import { ProfileComponent } from './profile/profile.component';
10-
import { HistoryComponent } from './history/history.component';
1110

1211
@NgModule({
1312
imports: [
@@ -18,7 +17,6 @@ import { HistoryComponent } from './history/history.component';
1817
LoginComponent,
1918
RegisterComponent,
2019
ProfileComponent,
21-
HistoryComponent,
2220
],
2321
})
2422
export class AccountModule {}

frontend/src/app/account/history/history.component.html

Lines changed: 0 additions & 84 deletions
This file was deleted.

frontend/src/app/app.routes.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { MatchingComponent } from './matching/matching.component';
55
import { HomeComponent } from './home/home.component';
66
import { AuthGuardService } from '../_services/auth.guard.service';
77
import { CollabGuardService } from '../_services/collab.guard.service';
8+
import { HistoryComponent } from './history/history.component';
89

910
const accountModule = () => import('./account/account.module').then(x => x.AccountModule);
1011

@@ -33,6 +34,11 @@ export const routes: Routes = [
3334
component: HomeComponent,
3435
canActivate: [AuthGuardService],
3536
},
37+
{
38+
path: 'history',
39+
component: HistoryComponent,
40+
canActivate: [AuthGuardService],
41+
},
3642
{
3743
path: '**',
3844
redirectTo: '/home',

frontend/src/app/account/history/history.component.css renamed to frontend/src/app/history/history.component.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
.container {
2+
min-height: calc(100dvh - 160px);
3+
width: 100%;
4+
justify-content: center;
5+
align-items: center;
6+
padding: 1rem;
7+
margin-top: auto;
8+
}
9+
110
.sliding-panel {
211
position: fixed;
312
top: 0;
@@ -9,6 +18,7 @@
918
box-shadow: -2px 0 5px rgba(0,0,0,0.5);
1019
transition: right 0.3s ease;
1120
z-index: 1000;
21+
max-width: 90%;
1222
}
1323

1424
.sliding-panel.open {
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<div class="container">
2+
<div class="table-container" style="max-width: 1150px; margin: 100px auto">
3+
<p-table
4+
#dt
5+
sortField="time"
6+
[sortOrder]="1"
7+
[value]="histories"
8+
datakey="id"
9+
[tableStyle]="{ 'table-layout': 'auto', width: '100%', 'min-width': '50rem', 'text-align': 'center' }"
10+
[paginator]="true"
11+
[rows]="10"
12+
[rowsPerPageOptions]="[10, 25, 50]"
13+
[globalFilterFields]="['title', 'difficulty', 'topics', 'collaborator', 'status', 'time']"
14+
styleClass="p-datatable-gridlines-striped"
15+
(sortFunction)="customSort($event)"
16+
[customSort]="true">
17+
<ng-template pTemplate="caption">
18+
<div class="flex flex-wrap align-items-center justify-content-between">
19+
<h3 class="">Matching History</h3>
20+
<p-iconField iconPosition="left">
21+
<p-inputIcon>
22+
<i class="pi pi-search"></i>
23+
</p-inputIcon>
24+
<input
25+
pInputText
26+
type="text"
27+
(input)="dt.filterGlobal($any($event.target).value, 'contains')"
28+
placeholder="Search keyword" />
29+
</p-iconField>
30+
</div>
31+
</ng-template>
32+
<ng-template pTemplate="header" let-columns>
33+
<tr>
34+
<th pSortableColumn="title" style="width: 20%">Question<p-sortIcon field="title"></p-sortIcon></th>
35+
<th pSortableColumn="difficulty" style="width: 15%">
36+
Difficulty<p-sortIcon field="difficulty"></p-sortIcon>
37+
</th>
38+
<th pSortableColumn="topics" style="width: 24%">Topics<p-sortIcon field="topics"></p-sortIcon></th>
39+
<th pSortableColumn="collaborator" style="width: 17%">
40+
Collaborator<p-sortIcon field="collaborator"></p-sortIcon>
41+
</th>
42+
<th pSortableColumn="status" style="width: 12%">Status<p-sortIcon field="status"></p-sortIcon></th>
43+
<th pSortableColumn="time" style="width: 12%">Time<p-sortIcon field="time"></p-sortIcon></th>
44+
</tr>
45+
</ng-template>
46+
<ng-template pTemplate="body" let-history>
47+
<tr (click)="onRowSelect(history)">
48+
<td>{{ history.title }}</td>
49+
<td>{{ history.difficulty }}</td>
50+
<td>{{ history.topics.join(', ') }}</td>
51+
<td>{{ history.collaborator }}</td>
52+
<td>
53+
@if (history.status === 'COMPLETED') {
54+
<i class="pi pi-check" style="color: green; font-size: large"></i>
55+
} @else if (history.status === 'FORFEITED') {
56+
<i class="pi pi-times" style="color: red; font-size: large"></i>
57+
} @else if (history.status === 'IN_PROGRESS') {
58+
<i class="pi pi-spin pi-spinner" style="color: white; font-size: large"></i>
59+
}
60+
</td>
61+
<td>{{ history.time | date: 'dd/MM/yyyy hh:mm a' }}</td>
62+
</tr>
63+
</ng-template>
64+
</p-table>
65+
</div>
66+
<p-sidebar
67+
[(visible)]="isPanelVisible"
68+
position="right"
69+
[blockScroll]="true"
70+
styleClass="w-10 md:w-8 lg:w-6"
71+
transitionOptions="200ms cubic-bezier(0, 0, 0.2, 1)"
72+
(onHide)="closePanel()">
73+
<ng-template pTemplate="header">
74+
<h3>{{ panelHistory?.title }}</h3>
75+
</ng-template>
76+
<div class="panel-content">
77+
<p style="white-space: pre-wrap">{{ panelHistory?.description }}</p>
78+
<h4>Submitted Solution</h4>
79+
<div #editor class="editor-content text-lg"></div>
80+
</div>
81+
</p-sidebar>
82+
<p-toast position="bottom-right" [breakpoints]="{ '920px': { width: '90%' } }" />
83+
</div>

0 commit comments

Comments
 (0)