Skip to content

Commit

Permalink
feat: topic managment logic implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr4ll committed Apr 17, 2023
1 parent e2b18ed commit aded85d
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ public class TopicRestController {
@Autowired
private Utils utils;

@Operation(summary = "Get specific topic")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Topic found", content = {
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Topic.class)))
}),
@ApiResponse(responseCode = "404", description = "Topic not found", content = @Content)
})
@GetMapping("/{topicName}")
public ResponseEntity<Topic> getTopic(@PathVariable String topicName) {
Optional<Topic> optionalTopic = topicService.findByName(topicName);
if (optionalTopic.isPresent()) {
Topic topic = optionalTopic.get();
return new ResponseEntity<>(topic, HttpStatus.OK);
}
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

@Operation(summary = "Get specific topic")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Topic found", content = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public interface TopicRepository extends JpaRepository<Topic, Long> {

Optional<Topic> findByName(String name);


@Query(value = "SELECT name FROM Topic t")
List<String> findAllTopicNames();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public List<Topic> getTopics(List<String> topicNames) {
return topics;
}

public Optional<Topic> findByName(String name){return topicRepository.findByName(name);}
public List<Topic> findAll() {
return topicRepository.findAll();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
<p>manage-topics works!</p>
<p>manage-topics works!</p>
<div class="feature col flex-grow-1">
<a href="#collapseTopics" data-bs-toggle="collapse" data-bs-target="#collapseTopics" role="button"
aria-expanded="true" aria-controls="collapseTopics">
<div class="feature-icon d-inline-flex align-items-center justify-content-center fs-2 mb-3">
<i class="fa-regular fa-solid fa-at fa-xl"></i>
</div>
<h3 class="fs-2">Manage Topics</h3>
</a>
<p>
Type in a new topic to create it, or click on an already existing one to delete it.
</p>
<div class="collapse" id="collapseTopics">

<form class="m-auto" action="/addTopic">
<div class="form-floating mb-2">
<input type="text" class="form-control h-100" id="newTopic" placeholder="Type new topic..." name="topicName">
<label for="newTopic" class="text-muted">Type new topic...</label>
</div>
<button class="w-100 btn btn-lg btn-light" type="submit">Add topic</button>
</form>


<input type="text" #topicName>

<button class="btn btn-primary mt-2" (click)="getTopic(topicName.value)">
Search
</button>
<div *ngIf="topic">
<a (click)="deleteTopic(topic.name)" class="listItem btn btn-primary mt-2">
{{topic.name}}
</a>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,25 @@ export class ManageTopicsComponent {
topicsURL = "/api/topics/";
topic: Topic | undefined;

constructor(private httpClient: HttpClient, private array_topics:Array<Topic>) { }
constructor(private httpClient: HttpClient) {

deleteTopic(title: string) {

}

getTopic(username: String) {
this.httpClient.get<Topic>(this.topicsURL+ username).subscribe(
getTopic(topicName: String) {
this.httpClient.get<Topic>(this.topicsURL + topicName).subscribe(
response => {
this.topic = response;
}
)
}

deleteTopic(topicName: String) {
this.httpClient.delete(this.topicsURL+topicName)
}








Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.listItem, form{
width: 100%;
}

.listItemLocked{
width: 100%;
background-color: rgb(126, 64, 64);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpParams } from '@angular/common/http';
import { StaredUser } from '../../interfaces/staredUser.interface';


Expand All @@ -14,7 +14,7 @@ import { StaredUser } from '../../interfaces/staredUser.interface';
})

export class ManageUsersComponent {
usersURL = "/api/users/";
usersURL = "api/users/";
userStared: StaredUser | undefined;
username = '';

Expand All @@ -29,7 +29,9 @@ export class ManageUsersComponent {
}

banUser() {
this.httpClient.put(this.usersURL + this.userStared?.id, this.userStared).subscribe(
const params = new HttpParams()
.set('operation', 'ban');
this.httpClient.put(this.usersURL + this.userStared?.id, params).subscribe(
response => console.log(response),
error => console.error(error)
);
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion front/src/app/shared/components/nav/nav.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<a class="navbar-brand" [routerLink]="['/']" (click)="toggleCompassIcon()">
<img src="assets/images/alistLogo.svg" alt="Alist logo" width="80" height="30">
</a>
<app-icon iconName="compass" [glow]="compassIconGlow" [routerLink]="['/']"
<app-icon iconName="compass" [glow]="compassIconGlow" [routerLink]="['/admin']"
(click)="toggleCompassIcon()"></app-icon>
<app-search></app-search>
<app-icon iconName="heart" [glow]="heartIconGlow" (click)="toggleHeartIcon()" [routerLink]="['/']"></app-icon>
Expand Down

0 comments on commit aded85d

Please sign in to comment.