|
|
@ -2,6 +2,7 @@ import {Injectable} from '@angular/core';
|
|
|
|
import { BehaviorSubject } from 'rxjs';
|
|
|
|
import { BehaviorSubject } from 'rxjs';
|
|
|
|
import { Activity, Activitylist } from 'src/app/models/activity';
|
|
|
|
import { Activity, Activitylist } from 'src/app/models/activity';
|
|
|
|
import { Level, LevelList } from 'src/app/models/levellist';
|
|
|
|
import { Level, LevelList } from 'src/app/models/levellist';
|
|
|
|
|
|
|
|
import { ReportReason } from 'src/app/models/reportReason';
|
|
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
import { environment } from 'src/environments/environment';
|
|
|
|
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
|
|
|
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
|
|
|
|
import { BaseService } from '../base.service';
|
|
|
|
import { BaseService } from '../base.service';
|
|
|
@ -14,6 +15,7 @@ export class ActivityService extends BaseService {
|
|
|
|
|
|
|
|
|
|
|
|
public activitylist = new BehaviorSubject<Activitylist>(new Activitylist());
|
|
|
|
public activitylist = new BehaviorSubject<Activitylist>(new Activitylist());
|
|
|
|
public levelList = new BehaviorSubject<LevelList>(new LevelList());
|
|
|
|
public levelList = new BehaviorSubject<LevelList>(new LevelList());
|
|
|
|
|
|
|
|
public reportReasonList = new BehaviorSubject<ReportReason[]>(new Array());
|
|
|
|
|
|
|
|
|
|
|
|
constructor(http: HttpClient) {
|
|
|
|
constructor(http: HttpClient) {
|
|
|
|
super(http);
|
|
|
|
super(http);
|
|
|
@ -37,6 +39,15 @@ export class ActivityService extends BaseService {
|
|
|
|
return body;
|
|
|
|
return body;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static buildGetReportReasonsBody(): any {
|
|
|
|
|
|
|
|
const body = {
|
|
|
|
|
|
|
|
query: `query{getReportReasons {
|
|
|
|
|
|
|
|
id name description
|
|
|
|
|
|
|
|
}}`, variables: {}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return body;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
changeUserInfo(pActivitylist: Activitylist) {
|
|
|
|
changeUserInfo(pActivitylist: Activitylist) {
|
|
|
|
this.activitylist.next(pActivitylist);
|
|
|
|
this.activitylist.next(pActivitylist);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -63,6 +74,17 @@ export class ActivityService extends BaseService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public getReportReasons() {
|
|
|
|
|
|
|
|
if (this.reportReasonList.getValue().length < 1) {
|
|
|
|
|
|
|
|
this.http.post(environment.graphQLUrl, ActivityService.buildGetReportReasonsBody(), { headers: this.headers })
|
|
|
|
|
|
|
|
.pipe(this.retryRated())
|
|
|
|
|
|
|
|
.subscribe(result => {
|
|
|
|
|
|
|
|
// push onto subject
|
|
|
|
|
|
|
|
this.reportReasonList.next(this.renderReportReasons(result));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public renderActivity(response: any): Activitylist {
|
|
|
|
public renderActivity(response: any): Activitylist {
|
|
|
|
const activitylist = new Activitylist();
|
|
|
|
const activitylist = new Activitylist();
|
|
|
|
for (const activity of response.data.getActivities) {
|
|
|
|
for (const activity of response.data.getActivities) {
|
|
|
@ -86,5 +108,16 @@ export class ActivityService extends BaseService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return levelList;
|
|
|
|
return levelList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public renderReportReasons(response: any): ReportReason[] {
|
|
|
|
|
|
|
|
const reportReasons: ReportReason[] = new Array();
|
|
|
|
|
|
|
|
for (const reason of response.data.getReportReasons) {
|
|
|
|
|
|
|
|
reportReasons.push(new ReportReason(
|
|
|
|
|
|
|
|
reason.id,
|
|
|
|
|
|
|
|
reason.name,
|
|
|
|
|
|
|
|
reason.description));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return reportReasons;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|