1.1.0.rc4 #345
@ -37,6 +37,25 @@ export class Queries {
|
||||
}
|
||||
`;
|
||||
|
||||
static serverConfigDiscordQuery = `
|
||||
query ServerConfigDiscordQuery($id: ID) {
|
||||
discord {
|
||||
guilds(filter: {id: $id}) {
|
||||
roles {
|
||||
id
|
||||
name
|
||||
}
|
||||
|
||||
channels {
|
||||
id
|
||||
name
|
||||
type
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
static serversQuery = `
|
||||
query ServerInfo($filter: ServerFilter, $page: Page, $sort: Sort) {
|
||||
serverCount
|
||||
|
@ -81,38 +81,41 @@
|
||||
<div class="content-row">
|
||||
<div class="content-column">
|
||||
<div class="content-data-name">{{'view.server.config.bot.afk_command_channel_id' | translate}}:</div>
|
||||
<input class="content-data-value" type="text" pInputText [(ngModel)]="config.afkCommandChannelId"
|
||||
placeholder="{{'view.server.config.bot.afk_command_channel_id' | translate}}">
|
||||
<p-dropdown class="content-data-value" [options]="voiceChannels" optionLabel="name" optionValue="id" [(ngModel)]="config.afkCommandChannelId"
|
||||
placeholder="{{'view.server.config.bot.afk_command_channel_id' | translate}}"></p-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-row">
|
||||
<div class="content-column">
|
||||
<div class="content-data-name">{{'view.server.config.bot.help_voice_channel_id' | translate}}:</div>
|
||||
<input class="content-data-value" type="text" pInputText [(ngModel)]="config.helpVoiceChannelId"
|
||||
placeholder="{{'view.server.config.bot.help_voice_channel_id' | translate}}">
|
||||
<p-dropdown class="content-data-value" [options]="voiceChannels" optionLabel="name" optionValue="id" [(ngModel)]="config.helpVoiceChannelId"
|
||||
placeholder="{{'view.server.config.bot.help_voice_channel_id' | translate}}"></p-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-row">
|
||||
<div class="content-column">
|
||||
<div class="content-data-name">{{'view.server.config.bot.team_channel_id' | translate}}:</div>
|
||||
<input class="content-data-value" type="text" pInputText [(ngModel)]="config.teamChannelId" placeholder="{{'view.server.config.bot.team_channel_id' | translate}}">
|
||||
<p-dropdown class="content-data-value" [options]="textChannels" optionLabel="name" optionValue="id" [(ngModel)]="config.teamChannelId"
|
||||
placeholder="{{'view.server.config.bot.team_channel_id' | translate}}"></p-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-row">
|
||||
<div class="content-column">
|
||||
<div class="content-data-name">{{'view.server.config.bot.login_message_channel_id' | translate}}:</div>
|
||||
<input class="content-data-value" type="text" pInputText [(ngModel)]="config.loginMessageChannelId"
|
||||
placeholder="{{'view.server.config.bot.login_message_channel_id' | translate}}">
|
||||
<p-dropdown class="content-data-value" [options]="textChannels" optionLabel="name" optionValue="id" [(ngModel)]="config.loginMessageChannelId"
|
||||
placeholder="{{'view.server.config.bot.login_message_channel_id' | translate}}"></p-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content-divider"></div>
|
||||
<app-config-list translationKey="view.server.config.bot.afk_channels" [(data)]="config.afkChannelIds"></app-config-list>
|
||||
<app-config-list translationKey="view.server.config.bot.moderator_roles" [(data)]="config.moderatorRoleIds"></app-config-list>
|
||||
<app-config-list translationKey="view.server.config.bot.admin_roles" [(data)]="config.adminRoleIds"></app-config-list>
|
||||
<app-config-list [options]="voiceChannels" optionLabel="name" optionValue="id" translationKey="view.server.config.bot.afk_channels"
|
||||
[(data)]="config.afkChannelIds"></app-config-list>
|
||||
<app-config-list [options]="roles" optionLabel="name" optionValue="id" translationKey="view.server.config.bot.moderator_roles"
|
||||
[(data)]="config.moderatorRoleIds"></app-config-list>
|
||||
<app-config-list [options]="roles" optionLabel="name" optionValue="id" translationKey="view.server.config.bot.admin_roles" [(data)]="config.adminRoleIds"></app-config-list>
|
||||
<app-feature-flag-list *ngIf="isTechnician" [(data)]="config.featureFlags"></app-feature-flag-list>
|
||||
|
||||
<div class="content-row">
|
||||
|
@ -6,8 +6,8 @@ import { GuiService } from "src/app/services/gui/gui.service";
|
||||
import { SettingsService } from "src/app/services/settings/settings.service";
|
||||
import { SpinnerService } from "src/app/services/spinner/spinner.service";
|
||||
import { ToastService } from "src/app/services/toast/toast.service";
|
||||
import { throwError } from "rxjs";
|
||||
import { Query, ServerConfigQuery } from "../../../../../../models/graphql/query.model";
|
||||
import { forkJoin, throwError } from "rxjs";
|
||||
import { Query, ServerConfigQuery, SingleDiscordQuery } from "../../../../../../models/graphql/query.model";
|
||||
import { Queries } from "../../../../../../models/graphql/queries.model";
|
||||
import { DataService } from "../../../../../../services/data/data.service";
|
||||
import { ServerConfigMutationResult } from "../../../../../../models/graphql/result.model";
|
||||
@ -16,7 +16,7 @@ import { AuthService } from "../../../../../../services/auth/auth.service";
|
||||
import { ServerConfig } from "../../../../../../models/config/server-config.model";
|
||||
import { Server } from "../../../../../../models/data/server.model";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { UserDTO } from "../../../../../../models/auth/auth-user.dto";
|
||||
import { Channel, ChannelType, Role } from "../../../../../../models/data/discord.model";
|
||||
|
||||
type AFKChannelId = {
|
||||
id: number;
|
||||
@ -43,6 +43,9 @@ export class ConfigComponent implements OnInit {
|
||||
|
||||
private server: Server = {};
|
||||
isTechnician: boolean = false;
|
||||
roles?: Role[];
|
||||
voiceChannels: Channel[] = [];
|
||||
textChannels: Channel[] = [];
|
||||
|
||||
constructor(
|
||||
private data: DataService,
|
||||
@ -71,20 +74,29 @@ export class ConfigComponent implements OnInit {
|
||||
}
|
||||
|
||||
loadConfig() {
|
||||
this.data.query<ServerConfigQuery>(Queries.serverConfigQuery, {
|
||||
serverId: this.server.id
|
||||
},
|
||||
(data: Query) => {
|
||||
return data.servers[0];
|
||||
}).subscribe(data => {
|
||||
this.config = data.config;
|
||||
|
||||
forkJoin([
|
||||
this.data.query<ServerConfigQuery>(Queries.serverConfigQuery, {
|
||||
serverId: this.server.id
|
||||
},
|
||||
(data: Query) => {
|
||||
return data.servers[0];
|
||||
}),
|
||||
this.data.query<SingleDiscordQuery>(Queries.serverConfigDiscordQuery)
|
||||
]).subscribe(data => {
|
||||
this.config = data[0].config;
|
||||
let id = 0;
|
||||
for (const afkChannelId of this.config.afkChannelIds ?? []) {
|
||||
this.afkChannelIds.push({ id: id, value: afkChannelId });
|
||||
id++;
|
||||
}
|
||||
|
||||
if (data[1].discord.guilds) {
|
||||
const guild = data[1].discord.guilds[0];
|
||||
this.roles = guild.roles ?? undefined;
|
||||
this.voiceChannels = guild.channels.filter(x => x.type == ChannelType.voice) ?? undefined;
|
||||
this.textChannels = guild.channels.filter(x => x.type == ChannelType.text) ?? undefined;
|
||||
}
|
||||
|
||||
this.spinnerService.hideSpinner();
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user