-
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.
- Loading branch information
Showing
12 changed files
with
143 additions
and
28 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
35 changes: 35 additions & 0 deletions
35
back/src/main/java/net/daw/alist/services/ChartService.java
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,35 @@ | ||
package net.daw.alist.services; | ||
|
||
import net.daw.alist.models.Post; | ||
import net.daw.alist.models.Topic; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
import java.util.*; | ||
|
||
@Service | ||
public class ChartService { | ||
|
||
@Autowired | ||
private PostService postService; | ||
|
||
@GetMapping("/chart") | ||
|
||
public Map<String,Integer> getTopicsMapped(){ | ||
List<Post> posts = postService.findAll(); | ||
Map<String, Integer> map = new HashMap<>(); | ||
for (Post post:posts) { | ||
List<Topic> topics = post.getTopics(); | ||
for (Topic topic:topics) { | ||
if(map.containsKey(topic.getName())){ | ||
Integer repetition = map.get(topic.getName()); | ||
map.put(topic.getName(), repetition+1); | ||
}else{ | ||
map.put(topic.getName(), 1); | ||
} | ||
} | ||
} | ||
return map; | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,6 +1,8 @@ | ||
<p>chart works!</p> | ||
|
||
<div class="m-auto"> | ||
<google-chart #chart [title]="title" [type]="type" [data]="data" [options]="options" [width]="width" | ||
[height]="height"> | ||
</google-chart> | ||
|
||
</div> |
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
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 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Observable, catchError, of } from 'rxjs'; | ||
|
||
|
||
@Injectable({ providedIn: 'root' }) | ||
|
||
export class AdminHttpsService { | ||
constructor(private httpClient: HttpClient) { } | ||
|
||
topics: Map<string, number> | undefined; | ||
|
||
getTopicsMapped(): Observable<Map<string, number>> { | ||
return this.httpClient.get<Map<string, number>>("api/topics/chart").pipe( | ||
catchError(error => { | ||
console.error(error); | ||
return of(new Map<string, number>()); | ||
}) | ||
); | ||
} | ||
|
||
|
||
} |