[WIP] Improved auto roles #134
This commit is contained in:
31
kdb-web/src/app/models/data/discord.model.ts
Normal file
31
kdb-web/src/app/models/data/discord.model.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
export interface Guild {
|
||||
id?: string;
|
||||
name?: string;
|
||||
|
||||
channels: [Channel]
|
||||
role: [Role]
|
||||
emojis: [Emoji]
|
||||
}
|
||||
|
||||
export interface Channel {
|
||||
id?: string;
|
||||
name?: string;
|
||||
type?: ChannelType;
|
||||
}
|
||||
|
||||
export enum ChannelType {
|
||||
category = "category",
|
||||
text = "text",
|
||||
voice = "voice"
|
||||
}
|
||||
|
||||
export interface Role {
|
||||
id?: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface Emoji {
|
||||
id?: string;
|
||||
name?: string;
|
||||
url?: string;
|
||||
}
|
@@ -1,5 +1,29 @@
|
||||
export class Queries {
|
||||
|
||||
static guildsQuery = `
|
||||
query GuildsQuery($id: ID) {
|
||||
guilds(filter: {id: $id}) {
|
||||
id
|
||||
name
|
||||
|
||||
channels {
|
||||
id
|
||||
name
|
||||
type
|
||||
}
|
||||
roles {
|
||||
id
|
||||
name
|
||||
}
|
||||
emojis {
|
||||
id
|
||||
name
|
||||
url
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
static serversQuery = `
|
||||
query ServerInfo($filter: ServerFilter, $page: Page, $sort: Sort) {
|
||||
servers(filter: $filter, page: $page, sort: $sort) {
|
||||
|
@@ -1,12 +1,17 @@
|
||||
import { Server } from "../data/server.model";
|
||||
import { User } from "../data/user.model";
|
||||
import { AutoRole } from "../data/auto_role.model";
|
||||
import { Guild } from "../data/discord.model";
|
||||
|
||||
export interface Query {
|
||||
serverCount: number;
|
||||
servers: Server[];
|
||||
}
|
||||
|
||||
export interface SingleDiscordQuery {
|
||||
guilds: Guild[];
|
||||
}
|
||||
|
||||
export interface UserListQuery {
|
||||
userCount: number;
|
||||
users: User[];
|
||||
|
@@ -63,13 +63,13 @@
|
||||
</div>
|
||||
</th>
|
||||
|
||||
<th class="table-header-small-dropdown">
|
||||
<th>
|
||||
<div class="table-header-label">
|
||||
<div class="table-header-text">{{'common.created_at' | translate}}</div>
|
||||
</div>
|
||||
</th>
|
||||
|
||||
<th class="table-header-small-dropdown">
|
||||
<th>
|
||||
<div class="table-header-label">
|
||||
<div class="table-header-text">{{'common.modified_at' | translate}}</div>
|
||||
</div>
|
||||
@@ -104,8 +104,8 @@
|
||||
</form>
|
||||
</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th class="table-header-small-dropdown"></th>
|
||||
<th class="table-header-small-dropdown"></th>
|
||||
<th class="table-header-actions"></th>
|
||||
</tr>
|
||||
</ng-template>
|
||||
@@ -127,6 +127,7 @@
|
||||
<p-cellEditor>
|
||||
<ng-template pTemplate="input">
|
||||
{{autoRole.channelId}}
|
||||
<p-dropdown [options]="channels" [(ngModel)]="autoRole.channelName" placeholder="{{'view.server.members.headers.level' | translate}}"></p-dropdown>
|
||||
</ng-template>
|
||||
<ng-template pTemplate="output">
|
||||
{{autoRole.channelId}}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { User } from "../../../../../../models/data/user.model";
|
||||
import { LazyLoadEvent } from "primeng/api";
|
||||
import { LazyLoadEvent, MenuItem } from "primeng/api";
|
||||
import { FormBuilder, FormControl, FormGroup } from "@angular/forms";
|
||||
import { Page } from "../../../../../../models/graphql/filter/page.model";
|
||||
import { Sort, SortDirection } from "../../../../../../models/graphql/filter/sort.model";
|
||||
@@ -12,7 +12,7 @@ import { TranslateService } from "@ngx-translate/core";
|
||||
import { DataService } from "../../../../../../services/data/data.service";
|
||||
import { SidebarService } from "../../../../../../services/sidebar/sidebar.service";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { AutoRoleQuery } from "../../../../../../models/graphql/query.model";
|
||||
import { AutoRoleQuery, SingleDiscordQuery } from "../../../../../../models/graphql/query.model";
|
||||
import { Queries } from "../../../../../../models/graphql/queries.model";
|
||||
import { catchError, debounceTime } from "rxjs/operators";
|
||||
import { Table } from "primeng/table";
|
||||
@@ -20,6 +20,7 @@ import { UpdateUserMutationResult } from "../../../../../../models/graphql/resul
|
||||
import { Mutations } from "../../../../../../models/graphql/mutations.model";
|
||||
import { throwError } from "rxjs";
|
||||
import { AutoRole, AutoRoleFilter } from "../../../../../../models/data/auto_role.model";
|
||||
import { ChannelType, Guild } from "../../../../../../models/data/discord.model";
|
||||
|
||||
@Component({
|
||||
selector: "app-auto-roles",
|
||||
@@ -28,6 +29,8 @@ import { AutoRole, AutoRoleFilter } from "../../../../../../models/data/auto_rol
|
||||
})
|
||||
export class AutoRolesComponent implements OnInit {
|
||||
auto_roles!: AutoRole[];
|
||||
guild!: Guild;
|
||||
channels!: MenuItem[];
|
||||
loading = true;
|
||||
|
||||
clonedUsers: { [s: string]: User; } = {};
|
||||
@@ -74,6 +77,20 @@ export class AutoRolesComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
this.data.getServerFromRoute(this.route);
|
||||
|
||||
this.spinner.showSpinner();
|
||||
this.data.query<SingleDiscordQuery>(Queries.guildsQuery, {
|
||||
filter: {
|
||||
id: this.sidebar.server$.value?.discordId
|
||||
}
|
||||
}
|
||||
).subscribe(data => {
|
||||
this.guild = data.guilds[0];
|
||||
this.channels = this.guild.channels
|
||||
.filter(x => x.type === ChannelType.text)
|
||||
.map(x => {return {value: x.name, label: x.id}});
|
||||
this.spinner.hideSpinner();
|
||||
});
|
||||
|
||||
this.setFilterForm();
|
||||
this.loadNextPage();
|
||||
}
|
||||
@@ -96,7 +113,7 @@ export class AutoRolesComponent implements OnInit {
|
||||
id: new FormControl<number | null>(null),
|
||||
channelId: new FormControl<string | null>(null),
|
||||
channelName: new FormControl<string | null>(null),
|
||||
messageId: new FormControl<string | null>(null),
|
||||
messageId: new FormControl<string | null>(null)
|
||||
});
|
||||
|
||||
this.filterForm.valueChanges.pipe(
|
||||
|
Reference in New Issue
Block a user