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