Added dropdown to technicianId input #344 #1.1.0.rc4
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
export interface Discord {
|
||||
guilds?: Guild[];
|
||||
users?: DiscordUser[];
|
||||
}
|
||||
|
||||
export interface Guild {
|
||||
id?: string;
|
||||
name?: string;
|
||||
@@ -14,9 +19,9 @@ export interface Channel {
|
||||
}
|
||||
|
||||
export enum ChannelType {
|
||||
category = "category",
|
||||
text = "text",
|
||||
voice = "voice"
|
||||
category = "CategoryChannel",
|
||||
text = "TextChannel",
|
||||
voice = "VoiceChannel"
|
||||
}
|
||||
|
||||
export interface Role {
|
||||
@@ -29,3 +34,9 @@ export interface Emoji {
|
||||
name?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface DiscordUser {
|
||||
id?: string;
|
||||
name?: string;
|
||||
bot?: boolean;
|
||||
}
|
||||
|
@@ -1,25 +1,38 @@
|
||||
export class Queries {
|
||||
|
||||
static guildsQuery = `
|
||||
query GuildsQuery($id: ID) {
|
||||
guilds(filter: {id: $id}) {
|
||||
id
|
||||
name
|
||||
query GuildsQuery($id: ID, $filter: ChannelFilter) {
|
||||
discord {
|
||||
guilds(filter: {id: $id}) {
|
||||
id
|
||||
name
|
||||
|
||||
channels {
|
||||
id
|
||||
name
|
||||
type
|
||||
channels(filter: $filter) {
|
||||
id
|
||||
name
|
||||
type
|
||||
}
|
||||
roles {
|
||||
id
|
||||
name
|
||||
}
|
||||
emojis {
|
||||
id
|
||||
name
|
||||
url
|
||||
}
|
||||
}
|
||||
roles {
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
static discordUsersQuery = `
|
||||
query DiscordUsersQuery {
|
||||
discord {
|
||||
users {
|
||||
id
|
||||
name
|
||||
}
|
||||
emojis {
|
||||
id
|
||||
name
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -29,10 +42,11 @@ export class Queries {
|
||||
serverCount
|
||||
servers(filter: $filter, page: $page, sort: $sort) {
|
||||
id
|
||||
discordId
|
||||
name
|
||||
iconURL
|
||||
userCount
|
||||
clients{
|
||||
clients {
|
||||
id
|
||||
discordId
|
||||
name
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { GameServer, Server } from "../data/server.model";
|
||||
import { User } from "../data/user.model";
|
||||
import { AutoRole, AutoRoleRule } from "../data/auto_role.model";
|
||||
import { Guild } from "../data/discord.model";
|
||||
import { Discord, Guild } from "../data/discord.model";
|
||||
import { Level } from "../data/level.model";
|
||||
import { Achievement, AchievementAttribute } from "../data/achievement.model";
|
||||
import { TechnicianConfig } from "../config/technician-config.model";
|
||||
@@ -21,7 +21,7 @@ export interface ServerConfigQuery {
|
||||
}
|
||||
|
||||
export interface SingleDiscordQuery {
|
||||
guilds: Guild[];
|
||||
discord: Discord;
|
||||
}
|
||||
|
||||
export interface UserListQuery {
|
||||
|
@@ -162,7 +162,7 @@
|
||||
|
||||
<div class="content-divider"></div>
|
||||
<app-config-list translationKey="admin.settings.bot.ping_urls" [(data)]="config.pingURLs"></app-config-list>
|
||||
<app-config-list translationKey="admin.settings.bot.technician_ids" [(data)]="config.technicianIds"></app-config-list>
|
||||
<app-config-list translationKey="admin.settings.bot.technician_ids" [options]="possibleTechnicians" optionLabel="name" optionValue="id" [(data)]="config.technicianIds"></app-config-list>
|
||||
<app-feature-flag-list [(data)]="config.featureFlags"></app-feature-flag-list>
|
||||
|
||||
<div class="content-row">
|
||||
|
@@ -11,12 +11,13 @@ import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
||||
import { ToastService } from "src/app/services/toast/toast.service";
|
||||
import { forkJoin, throwError } from "rxjs";
|
||||
import { TechnicianConfig } from "../../../../../models/config/technician-config.model";
|
||||
import { TechnicianConfigQuery } from "../../../../../models/graphql/query.model";
|
||||
import { SingleDiscordQuery, TechnicianConfigQuery } from "../../../../../models/graphql/query.model";
|
||||
import { Queries } from "../../../../../models/graphql/queries.model";
|
||||
import { DataService } from "../../../../../services/data/data.service";
|
||||
import { TechnicianConfigMutationResult } from "../../../../../models/graphql/result.model";
|
||||
import { Mutations } from "../../../../../models/graphql/mutations.model";
|
||||
import { AuthService } from "../../../../../services/auth/auth.service";
|
||||
import { ChannelType, DiscordUser } from "../../../../../models/data/discord.model";
|
||||
|
||||
|
||||
@Component({
|
||||
@@ -54,6 +55,8 @@ export class SettingsComponent implements OnInit {
|
||||
technicianIds: []
|
||||
};
|
||||
|
||||
possibleTechnicians?: DiscordUser[];
|
||||
|
||||
constructor(
|
||||
private dataService: DataService,
|
||||
private settingsService: SettingsService,
|
||||
@@ -76,7 +79,8 @@ export class SettingsComponent implements OnInit {
|
||||
this.spinnerService.hideSpinner();
|
||||
return throwError(() => error);
|
||||
})),
|
||||
this.dataService.query<TechnicianConfigQuery>(Queries.technicianConfigQuery)
|
||||
this.dataService.query<TechnicianConfigQuery>(Queries.technicianConfigQuery),
|
||||
this.dataService.query<SingleDiscordQuery>(Queries.discordUsersQuery)
|
||||
]).subscribe(data => {
|
||||
this.data = data[0];
|
||||
this.data.webVersion = this.settingsService.getWebVersion()?.getVersionString() ?? "0.0.0";
|
||||
@@ -86,6 +90,7 @@ export class SettingsComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.config = data[1].technicianConfig;
|
||||
this.possibleTechnicians = data[2].discord.users ?? undefined;
|
||||
this.initForms();
|
||||
this.spinnerService.hideSpinner();
|
||||
});
|
||||
|
@@ -19,10 +19,13 @@
|
||||
<td style="flex: 1;">
|
||||
<p-cellEditor>
|
||||
<ng-template pTemplate="input">
|
||||
<input class="table-edit-input" pInputText type="text" [(ngModel)]="value.value">
|
||||
<p-dropdown *ngIf="options" [options]="options" [optionLabel]="optionLabel ?? ''" [optionValue]="optionValue ?? ''" [(ngModel)]="value.value"></p-dropdown>
|
||||
|
||||
<input *ngIf="!options" class="table-edit-input" pInputText type="text" [(ngModel)]="value.value">
|
||||
</ng-template>
|
||||
<ng-template pTemplate="output">
|
||||
{{value.value}}
|
||||
<p-dropdown *ngIf="options" [options]="options" [optionLabel]="optionLabel ?? ''" [optionValue]="optionValue ?? ''" [(ngModel)]="value.value" [disabled]="true"></p-dropdown>
|
||||
<input *ngIf="!options" class="table-edit-input" pInputText type="text" [(ngModel)]="value.value" [disabled]="true">
|
||||
</ng-template>
|
||||
</p-cellEditor>
|
||||
</td>
|
||||
|
@@ -10,6 +10,9 @@ export class ConfigListComponent {
|
||||
internal_data: any[] = [];
|
||||
|
||||
@Input() translationKey: string = "";
|
||||
@Input() options?: Array<any>;
|
||||
@Input() optionLabel?: string = "";
|
||||
@Input() optionValue?: string = "";
|
||||
|
||||
@Input()
|
||||
set data(val: any[]) {
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
import { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from "@angular/router";
|
||||
import { ActivatedRoute, ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from "@angular/router";
|
||||
import { catchError } from "rxjs/operators";
|
||||
import { AuthService } from "src/app/services/auth/auth.service";
|
||||
import { ThemeService } from "src/app/services/theme/theme.service";
|
||||
import { SidebarService } from "../../../../services/sidebar/sidebar.service";
|
||||
import { MemberRoles } from "../../../../models/auth/auth-user.dto";
|
||||
import { DataService } from "../../../../services/data/data.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: "root"
|
||||
@@ -14,7 +15,9 @@ export class AuthGuard implements CanActivate {
|
||||
private router: Router,
|
||||
private authService: AuthService,
|
||||
private themeService: ThemeService,
|
||||
private sidebarService: SidebarService
|
||||
private sidebarService: SidebarService,
|
||||
private data: DataService,
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -47,8 +50,13 @@ export class AuthGuard implements CanActivate {
|
||||
if (memberRole !== undefined) {
|
||||
let userHasAccess = false;
|
||||
let authUser = await this.authService.getLoggedInUser();
|
||||
let server = route.params["serverId"];
|
||||
|
||||
if (!authUser || !authUser.users) {
|
||||
return true;
|
||||
}
|
||||
authUser?.users?.forEach(u => {
|
||||
if (u.server === +(this.sidebarService.server$.value?.id ?? 0)) {
|
||||
if (u.server === +(server ?? 0)) {
|
||||
if (
|
||||
memberRole === MemberRoles.Moderator && u.isModerator ||
|
||||
memberRole === MemberRoles.Admin && u.isAdmin ||
|
||||
|
@@ -105,9 +105,11 @@ export class AutoRolesRulesComponent extends ComponentWithTable implements OnIni
|
||||
filter: {
|
||||
id: server.discordId
|
||||
}
|
||||
}
|
||||
},
|
||||
).subscribe(data => {
|
||||
this.guild = data.guilds[0];
|
||||
if (data.discord.guilds) {
|
||||
this.guild = data.discord.guilds[0];
|
||||
}
|
||||
this.emojis = this.guild.emojis
|
||||
.map(x => {
|
||||
return { label: x.name, value: x };
|
||||
|
@@ -77,7 +77,7 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On
|
||||
private sidebar: SidebarService,
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
super('auto-role', ['id', 'channel_id', 'channel_name', 'message_id', 'rule_count'])
|
||||
super("auto-role", ["id", "channel_id", "channel_name", "message_id", "rule_count"]);
|
||||
}
|
||||
|
||||
public ngOnInit(): void {
|
||||
@@ -87,14 +87,16 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On
|
||||
this.server = server;
|
||||
this.spinner.showSpinner();
|
||||
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
|
||||
id: server?.discordId,
|
||||
filter: {
|
||||
id: server?.discordId
|
||||
type: ChannelType.text
|
||||
}
|
||||
}
|
||||
).subscribe(data => {
|
||||
this.guild = data.guilds[0];
|
||||
if (data.discord.guilds) {
|
||||
this.guild = data.discord.guilds[0];
|
||||
}
|
||||
this.channels = this.guild.channels
|
||||
.filter(x => x.type === ChannelType.text)
|
||||
.map(x => {
|
||||
return { label: x.name, value: x };
|
||||
});
|
||||
|
Reference in New Issue
Block a user