From bf1529733d8c071f2b36a4ab696f6f70f887938c Mon Sep 17 00:00:00 2001 From: zekroTJA Date: Mon, 10 Aug 2020 19:13:10 +0200 Subject: [PATCH] add report revocation to web frontend [#153] --- web/src/app/api/api.service.ts | 10 ++++-- .../components/report/report.component.html | 6 +++- .../components/report/report.component.sass | 4 +++ .../app/components/report/report.component.ts | 4 ++- web/src/app/routes/guild/guild.component.html | 20 +++++++++++- web/src/app/routes/guild/guild.component.sass | 7 +++++ web/src/app/routes/guild/guild.component.ts | 31 ++++++++++++++++++- .../app/routes/member/member.component.html | 21 ++++++++++++- web/src/app/routes/member/member.component.ts | 28 +++++++++++++++++ 9 files changed, 124 insertions(+), 7 deletions(-) diff --git a/web/src/app/api/api.service.ts b/web/src/app/api/api.service.ts index 8d39c5f52..41333fc06 100644 --- a/web/src/app/api/api.service.ts +++ b/web/src/app/api/api.service.ts @@ -90,8 +90,8 @@ export class APIService { memberID: string ) => `${this.rcGuildMemberReports(guildID, memberID)}/count`; - private readonly rcReports = (reportID: string) => - `${this.rcAPI('reports')}/${reportID}`; + private readonly rcReports = (reportID: string, rc: string = '') => + `${this.rcAPI('reports')}/${reportID}${rc ? '/' + rc : ''}`; private readonly rcGuildSettings = (guildID: string) => `${this.rcGuilds(guildID)}/settings`; @@ -294,6 +294,12 @@ export class APIService { ); } + public postReportRevoke(reportID: string, reason: string): Observable { + return this.http + .post(this.rcReports(reportID, 'revoke'), { reason }, this.defopts()) + .pipe(catchError(this.errorCatcher)); + } + public getGuildSettings(guildID: string): Observable { return this.http .get(this.rcGuildSettings(guildID), this.defopts()) diff --git a/web/src/app/components/report/report.component.html b/web/src/app/components/report/report.component.html index 65ed06d16..4fa7a47a4 100644 --- a/web/src/app/components/report/report.component.html +++ b/web/src/app/components/report/report.component.html @@ -45,7 +45,11 @@

Attachment

- + \ No newline at end of file diff --git a/web/src/app/components/report/report.component.sass b/web/src/app/components/report/report.component.sass index 39637809d..001100d42 100644 --- a/web/src/app/components/report/report.component.sass +++ b/web/src/app/components/report/report.component.sass @@ -9,6 +9,10 @@ p h4 margin-bottom: 10px !important +a + color: $c-blurple !important + text-decoration: underline !important + .report-container background-color: $c-nqblack border-radius: $border-rad diff --git a/web/src/app/components/report/report.component.ts b/web/src/app/components/report/report.component.ts index 682b3df2f..4ec172645 100644 --- a/web/src/app/components/report/report.component.ts +++ b/web/src/app/components/report/report.component.ts @@ -1,6 +1,6 @@ /** @format */ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; import { Report, Member } from 'src/app/api/api.models'; import { APIService } from 'src/app/api/api.service'; import dateFormat from 'dateformat'; @@ -17,6 +17,8 @@ export class ReportComponent implements OnInit { @Input() public victim: Member; @Input() public executor: Member; + @Output() public revoke = new EventEmitter(); + public dateFormat = dateFormat; constructor(private api: APIService) {} diff --git a/web/src/app/routes/guild/guild.component.html b/web/src/app/routes/guild/guild.component.html index 3aa530122..43bedadf6 100644 --- a/web/src/app/routes/guild/guild.component.html +++ b/web/src/app/routes/guild/guild.component.html @@ -1,4 +1,18 @@
+ + + + + +
@@ -104,7 +118,11 @@

MOD LOG

Mod log is empty. - +
ATTACHMENT
+ + + + + + @@ -157,7 +171,12 @@

Reports

{{ member.user.username }} has a white vest! 👌 - +
diff --git a/web/src/app/routes/member/member.component.ts b/web/src/app/routes/member/member.component.ts index 104e9557e..eeb94f611 100644 --- a/web/src/app/routes/member/member.component.ts +++ b/web/src/app/routes/member/member.component.ts @@ -36,6 +36,7 @@ export class MemberRouteComponent { @ViewChild('modalReport') private modalReport: TemplateRef; @ViewChild('modalKick') private modalKick: TemplateRef; @ViewChild('modalBan') private modalBan: TemplateRef; + @ViewChild('modalRevoke') private modalRevoke: TemplateRef; public repModalType = 3; public repModalReason = ''; @@ -189,6 +190,33 @@ export class MemberRouteComponent { .catch(() => this.clearReportModalModels()); } + public revokeReport(report: Report) { + this.openModal(this.modalRevoke) + .then((res) => { + if (res && this.checkReason()) { + this.api + .postReportRevoke(report.id, this.repModalReason) + .subscribe((revRes) => { + if (revRes) { + const i = this.reports.indexOf(report); + if (i >= 0) { + this.reports.splice(i, 1); + } + this.toasts.push( + 'Report revoked.', + 'Revoked', + 'success', + 5000, + true + ); + } + }); + } + this.clearReportModalModels(); + }) + .catch(() => this.clearReportModalModels()); + } + private openModal(modal: TemplateRef): Promise { return this.modal.open(modal, { windowClass: 'dark-modal' }).result; }