Skip to content

Commit

Permalink
240 post grade (#241)
Browse files Browse the repository at this point in the history
- hide muted message
- fix owner is not an admin
- add refresh button on leaderboard
  • Loading branch information
Pixailz authored Oct 29, 2023
1 parent 7c48bff commit 51bb1db
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/angularjs/src/app/components/chat-view/chat-view.component.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
<ol>
<li *ngFor="let _ of room.message; let i=index;" [ngClass]="{'me': getCurrentMessage(i).userId === userService.user.id}">
<span class="date" *ngIf="!isFollowingDay(i)">{{getCurrentMessage(i).updateAt | date: 'dd/MM/YYYY'}}</span>
<div class="msg-line">
<div class="msg">
<span class="login" *ngIf="!isSameUser(i)">{{getCurrentMessageUser(i).nickname}}</span>
<div *ngFor="let content of getCurrentMessage(i).content">
<div *ngIf="content.type == 0">
<!-- STRING:<br> -->
<span class="content-string">
{{content.content.replace(' ', '&nbsp;')}}
</span>
</div>
<div *ngIf="content.type == 1">
<!-- GAME-INVITE:<br> -->
<button class="content-game-invite" (click)="joinGame(content.content)">
<mat-icon fontIcon="videogame_asset"> </mat-icon >
</button>
<div *ngFor="let _ of room.message; let i=index;">
<li *ngIf="!friendService.isTargetBlocked(getCurrentMessageUser(i).id)"
[ngClass]="{'me': getCurrentMessage(i).userId === userService.user.id}">
<div class="msg-line">
<span class="date" *ngIf="!isFollowingDay(i)">{{getCurrentMessage(i).updateAt | date: 'dd/MM/YYYY'}}</span>
<div class="msg">
<span class="login" *ngIf="!isSameUser(i)">{{getCurrentMessageUser(i).nickname}}</span>
<div *ngFor="let content of getCurrentMessage(i).content">
<div *ngIf="content.type == 0">
<!-- STRING:<br> -->
<span class="content-string">
{{content.content.replace(' ', '&nbsp;')}}
</span>
</div>
<div *ngIf="content.type == 1">
<!-- GAME-INVITE:<br> -->
<button class="content-game-invite" (click)="joinGame(content.content)">
<mat-icon fontIcon="videogame_asset"> </mat-icon >
</button>
</div>
</div>
</div>
<span class="time">{{getCurrentMessage(i).updateAt | date: 'HH:mm'}}</span>
</div>
<span class="time">{{getCurrentMessage(i).updateAt | date: 'HH:mm'}}</span>
</div>
</li>
</li>
</div>
</ol>

<span class="char-left" *ngIf="!blocked">{{messageLength}}/120</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { MessageContentI, MessageContentType, MessageI } from 'src/app/interface
import { UserI } from 'src/app/interfaces/user/user.interface';
import { UserService } from 'src/app/services/user.service';
import { ChatRoomService } from 'src/app/services/websocket/chat/chatroom.service';
import { FriendService } from 'src/app/services/websocket/friend/service';

@Component({
selector: 'app-chat-view',
Expand All @@ -27,6 +28,7 @@ export class ChatViewComponent {
private formBuilder: FormBuilder,
private chatRoomService: ChatRoomService,
public userService: UserService,
public friendService: FriendService,
public router: Router,
) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ <h1 class="mat-h1">Dashboard</h1>
<mat-card-header>
<mat-card-title>
Leaderboard
<button mat-icon-button class="refresh-button" aria-label="refresh" (click)="refLeaderboard()">
<mat-icon>refresh</mat-icon>
</button>
</mat-card-title>
</mat-card-header>
<mat-card-content class="dashboard-card-content">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,20 @@ export class HomeDashboardComponent {
.subscribe((res) => { this.onlineusers = res[0]; });
}

async refLeaderboard() {
const leadreq = await this.back.req("GET", "/leaderboard");

this.breakpointObserver.observe(Breakpoints.Handset).pipe(
map(({ matches }) => {
if (matches) {
return [
{ cols: 3, rows: 1, content: leadreq }
];
}
return [
{ cols: 2, rows: 2, content: leadreq }
];
}))
.subscribe((res) => { this.leaderboard = res[0]; });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ export class ChatRoomService {
{
const admin = this.getAdmin(room);

if (this.isOwner(room, user_id))
return (true);
if (!admin.length || admin.length === 0) return false;
for (var i = 0; i < admin.length; i++)
if (admin[i].id === user_id)
Expand Down
Empty file modified src/angularjs/src/favicon.ico
100644 → 100755
Empty file.

0 comments on commit 51bb1db

Please sign in to comment.