-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
the css needs to be fixed but most of banning logic is implemented
- Loading branch information
Showing
6 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
<p>chart works!</p> | ||
<p>chart works!</p> | ||
<div id="piechart" class="m-auto"></div> |
30 changes: 29 additions & 1 deletion
30
front/src/app/admin/components/manage-users/manage-users.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
<p>manage-users works!</p> | ||
<p>manage-users works!</p> | ||
|
||
<div class="feature-icon d-inline-flex align-items-center justify-content-center fs-2 mb-3"> | ||
<i class="fa-regular fa-solid fa-user fa-xl"></i> | ||
</div> | ||
<h3 class="fs-2">Manage Users</h3> | ||
|
||
<p> | ||
Click on a user to ban their account. If a user is highlighted in red, that means their account is suspended. | ||
Clicking on it again will unban the user. | ||
</p> | ||
|
||
<input type="text" #username> | ||
|
||
<button class="btn btn-primary mt-2" (click)="getUser(username.value)"> | ||
Search | ||
</button> | ||
<div *ngIf="userStared?.locked; else otherCont"> | ||
<a (click)="banUser()" class="listItem btn btn-primary mt-2"> | ||
{{userStared?.username}} | ||
</a> | ||
</div> | ||
<ng-template #otherCont> | ||
<div> | ||
<a (click)="banUser()" class="listItemLocked btn btn-primary mt-2"> | ||
{{userStared?.username}} | ||
</a> | ||
</div> | ||
</ng-template> |
34 changes: 32 additions & 2 deletions
34
front/src/app/admin/components/manage-users/manage-users.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,38 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Component } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { LoggedUser } from '../../interfaces/staredUser.interface'; | ||
|
||
|
||
|
||
|
||
|
||
@Component({ | ||
selector: 'app-manage-users', | ||
templateUrl: './manage-users.component.html', | ||
styleUrls: ['./manage-users.component.css'], | ||
|
||
}) | ||
export class ManageUsersComponent {} | ||
|
||
export class ManageUsersComponent { | ||
userStared: LoggedUser | undefined; | ||
username = ''; | ||
|
||
constructor(private httpClient: HttpClient) { } | ||
|
||
getUser(username: String) { | ||
this.httpClient.get<LoggedUser>("https://localhost:8443/api/users/" + username).subscribe( | ||
response => { | ||
this.userStared = response; | ||
} | ||
) | ||
} | ||
|
||
banUser() { | ||
this.httpClient.put("https://localhost:8443/api/users/" + this.userStared?.id, this.userStared).subscribe( | ||
response => console.log(response), | ||
error => console.error(error) | ||
); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export interface LoggedUser { | ||
'@Id': number; | ||
id: number; | ||
date: Date; | ||
username: string; | ||
email: string; | ||
role: string; | ||
enabled: boolean; | ||
locked: boolean; | ||
bio: string; | ||
imagePath: string; | ||
posts: any[]; | ||
comments: any[]; | ||
admin: boolean; | ||
accountNonExpired: boolean; | ||
accountNonLocked: boolean; | ||
credentialsNonExpired: boolean; | ||
authorities: Authority[]; | ||
} | ||
|
||
interface Authority { | ||
authority: string; | ||
} |
20 changes: 17 additions & 3 deletions
20
front/src/app/admin/pages/admin-panel/admin-panel.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
<app-chart></app-chart> | ||
<app-manage-users></app-manage-users> | ||
<app-manage-topics></app-manage-topics> | ||
<div class="container px-4 py-5 text-center" id="featured-3"> | ||
<h1 class="pb-2 border-bottom">Admin Panel</h1> | ||
<h5 class="mt-4 font-weight-bold">Topic popularity</h5> | ||
<div class="row d-flex row-cols-1 row-cols-lg-3 m-auto"> | ||
<app-chart></app-chart> | ||
|
||
</div> | ||
<div class="row d-flex row-cols-1 row-cols-lg-3 m-auto"> | ||
|
||
<div class="feature col flex-grow-1"> | ||
<app-manage-users></app-manage-users> | ||
</div> | ||
<div class="feature col flex-grow-1"> | ||
<app-manage-topics></app-manage-topics> | ||
</div> | ||
</div> | ||
</div> |