1 |
50216
|
myrto.kouk
|
import { Component, OnInit } from '@angular/core';
|
2 |
50706
|
myrto.kouk
|
import { BrowseEntry, Term } from '../../domain/typeScriptClasses';
|
3 |
50746
|
myrto.kouk
|
import { ActivatedRoute, Router } from '@angular/router';
|
4 |
50706
|
myrto.kouk
|
import { loadingTopics, loadingTopicsError, noTopicsFound } from '../../domain/shared-messages';
|
5 |
50556
|
myrto.kouk
|
import { BrokerService } from '../../services/broker.service';
|
6 |
50216
|
myrto.kouk
|
|
7 |
|
|
@Component ({
|
8 |
|
|
selector: 'content-events-of-repository',
|
9 |
|
|
templateUrl: 'content-events-of-repository.component.html'
|
10 |
|
|
})
|
11 |
|
|
|
12 |
|
|
export class ContentEventsOfRepositoryComponent implements OnInit {
|
13 |
|
|
errorMessage: string;
|
14 |
50600
|
myrto.kouk
|
loadingMessage: string;
|
15 |
50746
|
myrto.kouk
|
noTopics: string;
|
16 |
50216
|
myrto.kouk
|
|
17 |
50746
|
myrto.kouk
|
repoName = '';
|
18 |
|
|
topics: Map<string,Term> = new Map<string,Term>();
|
19 |
|
|
repoTopics: BrowseEntry[] = [];
|
20 |
|
|
moreList: BrowseEntry[] = [];
|
21 |
|
|
missingList: BrowseEntry[] = [];
|
22 |
|
|
totalMore = 0;
|
23 |
|
|
totalMissing = 0;
|
24 |
|
|
|
25 |
50216
|
myrto.kouk
|
constructor(
|
26 |
|
|
private route: ActivatedRoute,
|
27 |
50746
|
myrto.kouk
|
private router: Router,
|
28 |
50556
|
myrto.kouk
|
private brokerService: BrokerService
|
29 |
50216
|
myrto.kouk
|
) {}
|
30 |
|
|
|
31 |
|
|
ngOnInit() {
|
32 |
50746
|
myrto.kouk
|
this.repoName = this.route.snapshot.paramMap.get('name');
|
33 |
|
|
setTimeout(() => {
|
34 |
|
|
this.getTopics();
|
35 |
|
|
},500);
|
36 |
50216
|
myrto.kouk
|
}
|
37 |
|
|
|
38 |
50746
|
myrto.kouk
|
getRepoTopics(): void {
|
39 |
50600
|
myrto.kouk
|
this.loadingMessage = loadingTopics;
|
40 |
50746
|
myrto.kouk
|
this.brokerService.getTopicsForDataSource(this.repoName)
|
41 |
50536
|
myrto.kouk
|
.subscribe(
|
42 |
|
|
topics => {
|
43 |
|
|
this.repoTopics = topics;
|
44 |
|
|
},
|
45 |
50706
|
myrto.kouk
|
error => {
|
46 |
|
|
console.log(error);
|
47 |
|
|
this.errorMessage = loadingTopicsError;
|
48 |
50746
|
myrto.kouk
|
this.loadingMessage = '';
|
49 |
50706
|
myrto.kouk
|
},
|
50 |
50600
|
myrto.kouk
|
() => {
|
51 |
|
|
this.loadingMessage = '';
|
52 |
50843
|
myrto.kouk
|
if(this.repoTopics.length == 0){
|
53 |
50746
|
myrto.kouk
|
this.noTopics=noTopicsFound;
|
54 |
|
|
} else {
|
55 |
|
|
for(let browseEntry of this.repoTopics) {
|
56 |
|
|
if(browseEntry.value.startsWith("ENRICH/MORE")) {
|
57 |
|
|
this.totalMore += browseEntry.size;
|
58 |
|
|
this.moreList.push(browseEntry);
|
59 |
|
|
}
|
60 |
|
|
else if(browseEntry.value.startsWith("ENRICH/MISSING")) {
|
61 |
|
|
this.totalMissing += browseEntry.size;
|
62 |
|
|
this.missingList.push(browseEntry);
|
63 |
|
|
}
|
64 |
|
|
}
|
65 |
|
|
}
|
66 |
50216
|
myrto.kouk
|
}
|
67 |
|
|
);
|
68 |
|
|
}
|
69 |
|
|
|
70 |
50746
|
myrto.kouk
|
|
71 |
|
|
getTopics () {
|
72 |
|
|
this.loadingMessage = loadingTopics;
|
73 |
|
|
this.brokerService.getDnetTopics().subscribe(
|
74 |
|
|
topics => this.topics = topics,
|
75 |
|
|
error => {
|
76 |
|
|
console.log(error);
|
77 |
|
|
this.errorMessage = loadingTopicsError;
|
78 |
|
|
this.loadingMessage = '';
|
79 |
|
|
},
|
80 |
|
|
() => {
|
81 |
|
|
this.loadingMessage = '';
|
82 |
50765
|
myrto.kouk
|
console.log(this.topics);
|
83 |
|
|
this.getRepoTopics();
|
84 |
50746
|
myrto.kouk
|
}
|
85 |
|
|
);
|
86 |
|
|
}
|
87 |
|
|
|
88 |
50765
|
myrto.kouk
|
goToEventsList(topic: string) {
|
89 |
51543
|
myrto.kouk
|
let temp = topic.replace(/\//g,'|');
|
90 |
50746
|
myrto.kouk
|
let chosenTopic = temp[0];
|
91 |
|
|
for (let i=1; i<temp.length; i++){
|
92 |
51543
|
myrto.kouk
|
chosenTopic += '|' + temp[i];
|
93 |
50746
|
myrto.kouk
|
}
|
94 |
51543
|
myrto.kouk
|
chosenTopic = encodeURIComponent(chosenTopic);
|
95 |
|
|
/*this.router.navigate([`/content/events/${this.repoName}`, chosenTopic]);*/
|
96 |
|
|
console.log(temp,this.route.url);
|
97 |
|
|
this.router.navigate([temp], {relativeTo: this.route});
|
98 |
|
|
|
99 |
50746
|
myrto.kouk
|
}
|
100 |
|
|
|
101 |
|
|
|
102 |
50216
|
myrto.kouk
|
}
|