Fixed modal paths

master
WolverinDEV 2021-02-09 10:11:40 +01:00
parent 01081ac3ac
commit c297c441b0
18 changed files with 219 additions and 23 deletions

View File

@ -33,7 +33,7 @@ function load_script_url(url: string) : Promise<void> {
const timeout_handle = setTimeout(() => {
cleanup();
reject("timeout");
}, 15 * 1000);
}, 120 * 1000);
script_tag.type = "application/javascript";
script_tag.async = true;
script_tag.defer = true;

View File

@ -29,7 +29,7 @@ export class ServerFeatures {
readonly events: Registry<ServerFeatureEvents>;
private readonly connection: ConnectionHandler;
private readonly explicitCommandHandler: ExplicitCommandHandler;
private readonly stateChangeListener: (event: ConnectionEvents["notify_connection_state_changed"]) => void;
private readonly stateChangeListener: () => void;
private featureAwait: Promise<boolean>;
private featureAwaitCallback: (success: boolean) => void;
@ -68,7 +68,7 @@ export class ServerFeatures {
}
});
this.connection.events().on("notify_connection_state_changed", this.stateChangeListener = event => {
this.stateChangeListener = this.connection.events().on("notify_connection_state_changed", event => {
if(event.newState === ConnectionState.CONNECTED) {
this.connection.getServerConnection().send_command("listfeaturesupport").catch(error => {
this.disableAllFeatures();
@ -95,7 +95,7 @@ export class ServerFeatures {
}
destroy() {
this.connection.events().off(this.stateChangeListener);
this.stateChangeListener();
this.connection.getServerConnection()?.command_handler_boss()?.unregister_explicit_handler("notifyfeaturesupport", this.explicitCommandHandler);
if(this.featureAwaitCallback) {

View File

@ -49,7 +49,7 @@ export interface TranslationRepository {
let translations: Translation[] = [];
let translateCache: { [key:string]: string; } = {};
export function tr(message: string, key?: string) {
export function tr(message: string, key?: string) : string {
const sloppy = translateCache[message];
if(sloppy) {
return sloppy;

View File

@ -1,4 +1,4 @@
import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {spawnReactModal} from "tc-shared/ui/react-elements/modal";
import * as React from "react";
import {Slider} from "tc-shared/ui/react-elements/Slider";
import {Button} from "tc-shared/ui/react-elements/Button";

View File

@ -1,4 +1,4 @@
import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {spawnReactModal} from "tc-shared/ui/react-elements/modal";
import {ConnectionHandler} from "tc-shared/ConnectionHandler";
import {Registry} from "tc-shared/events";
import {FlatInputField, Select} from "tc-shared/ui/react-elements/InputField";

View File

@ -1,4 +1,4 @@
import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {spawnReactModal} from "tc-shared/ui/react-elements/modal";
import {ConnectionHandler} from "tc-shared/ConnectionHandler";
import {Registry} from "tc-shared/events";
import * as React from "react";

View File

@ -1,7 +1,7 @@
import {createErrorModal, createModal} from "../../ui/elements/Modal";
import {ConnectionHandler} from "../../ConnectionHandler";
import {MusicClientEntry} from "../../tree/Client";
import {modal, Registry} from "../../events";
import {Registry} from "../../events";
import {CommandResult} from "../../connection/ServerConnectionDeclaration";
import {LogCategory, logError, logWarn} from "../../log";
import {tr, tra} from "../../i18n/localize";
@ -12,8 +12,160 @@ import * as htmltags from "../../ui/htmltags";
import {ErrorCode} from "../../connection/ErrorCode";
import ServerGroup = find.ServerGroup;
type BotStatusType = "name" | "description" | "volume" | "country_code" | "channel_commander" | "priority_speaker";
type PlaylistStatusType = "replay_mode" | "finished" | "delete_played" | "max_size" | "notify_song_change";
interface music_manage {
show_container: { container: "settings" | "permissions"; };
/* setting relevant */
query_bot_status: {},
bot_status: {
status: "success" | "error";
error_msg?: string;
data?: {
name: string,
description: string,
volume: number,
country_code: string,
default_country_code: string,
channel_commander: boolean,
priority_speaker: boolean,
client_version: string,
client_platform: string,
uptime_mode: number,
bot_type: number
}
},
set_bot_status: {
key: BotStatusType,
value: any
},
set_bot_status_result: {
key: BotStatusType,
status: "success" | "error" | "timeout",
error_msg?: string,
value?: any
}
query_playlist_status: {},
playlist_status: {
status: "success" | "error",
error_msg?: string,
data?: {
replay_mode: number,
finished: boolean,
delete_played: boolean,
max_size: number,
notify_song_change: boolean
}
},
set_playlist_status: {
key: PlaylistStatusType,
value: any
},
set_playlist_status_result: {
key: PlaylistStatusType,
status: "success" | "error" | "timeout",
error_msg?: string,
value?: any
}
/* permission relevant */
show_client_list: {},
hide_client_list: {},
filter_client_list: { filter: string | undefined },
"refresh_permissions": {},
query_special_clients: {},
special_client_list: {
status: "success" | "error" | "error-permission",
error_msg?: string,
clients?: {
name: string,
unique_id: string,
database_id: number
}[]
},
search_client: { text: string },
search_client_result: {
status: "error" | "timeout" | "empty" | "success",
error_msg?: string,
client?: {
name: string,
unique_id: string,
database_id: number
}
},
/* sets a client to set the permission for */
special_client_set: {
client?: {
name: string,
unique_id: string,
database_id: number
}
},
"query_general_permissions": {},
"general_permissions": {
status: "error" | "timeout" | "success",
error_msg?: string,
permissions?: {[key: string]:number}
},
"set_general_permission_result": {
status: "error" | "success",
key: string,
value?: number,
error_msg?: string
},
"set_general_permission": { /* try to change a permission for the server */
key: string,
value: number
},
"query_client_permissions": { client_database_id: number },
"client_permissions": {
status: "error" | "timeout" | "success",
client_database_id: number,
error_msg?: string,
permissions?: {[key: string]:number}
},
"set_client_permission_result": {
status: "error" | "success",
client_database_id: number,
key: string,
value?: number,
error_msg?: string
},
"set_client_permission": { /* try to change a permission for the server */
client_database_id: number,
key: string,
value: number
},
"query_group_permissions": { permission_name: string },
"group_permissions": {
permission_name: string;
status: "error" | "timeout" | "success"
groups?: {
name: string,
value: number,
id: number
}[],
error_msg?: string
}
}
export function openMusicManage(client: ConnectionHandler, bot: MusicClientEntry) {
const ev_registry = new Registry<modal.music_manage>();
const ev_registry = new Registry<music_manage>();
ev_registry.enableDebug("music-manage");
//dummy_controller(ev_registry);
permission_controller(ev_registry, bot, client);
@ -36,7 +188,7 @@ export function openMusicManage(client: ConnectionHandler, bot: MusicClientEntry
modal.open();
}
function permission_controller(event_registry: Registry<modal.music_manage>, bot: MusicClientEntry, client: ConnectionHandler) {
function permission_controller(event_registry: Registry<music_manage>, bot: MusicClientEntry, client: ConnectionHandler) {
const error_msg = error => {
if (error instanceof CommandResult) {
if (error.id === ErrorCode.SERVER_INSUFFICIENT_PERMISSIONS) {
@ -380,7 +532,7 @@ function permission_controller(event_registry: Registry<modal.music_manage>, bot
}
}
function dummy_controller(event_registry: Registry<modal.music_manage>) {
function dummy_controller(event_registry: Registry<music_manage>) {
/* settings */
{
event_registry.on("query_bot_status", event => {
@ -510,7 +662,7 @@ function dummy_controller(event_registry: Registry<modal.music_manage>) {
}
function build_modal(event_registry: Registry<modal.music_manage>): JQuery<HTMLElement> {
function build_modal(event_registry: Registry<music_manage>): JQuery<HTMLElement> {
const tag = $("#tmpl_music_manage").renderTag();
const container_settings = tag.find(".body > .category-settings");
@ -563,7 +715,7 @@ function build_modal(event_registry: Registry<modal.music_manage>): JQuery<HTMLE
return tag.children();
}
function build_settings_container(event_registry: Registry<modal.music_manage>, tag: JQuery<HTMLElement>) {
function build_settings_container(event_registry: Registry<music_manage>, tag: JQuery<HTMLElement>) {
const show_change_error = (header, message) => {
createErrorModal(tr("Failed to change value"), header + "<br>" + message).open();
};
@ -1169,7 +1321,7 @@ function build_settings_container(event_registry: Registry<modal.music_manage>,
}
}
function build_permission_container(event_registry: Registry<modal.music_manage>, tag: JQuery<HTMLElement>) {
function build_permission_container(event_registry: Registry<music_manage>, tag: JQuery<HTMLElement>) {
/* client search mechanism */
{
const container = tag.find(".table-head .column-client-specific .client-select");

View File

@ -10,7 +10,7 @@ import {Registry} from "tc-shared/events";
import {ChannelPropertyProviders} from "tc-shared/ui/modal/channel-edit/ControllerProperties";
import {LogCategory, logDebug, logError} from "tc-shared/log";
import {ChannelPropertyPermissionsProviders} from "tc-shared/ui/modal/channel-edit/ControllerPermissions";
import {spawnModal} from "tc-shared/ui/react-elements/Modal";
import {spawnModal} from "tc-shared/ui/react-elements/modal";
import {PermissionValue} from "tc-shared/permission/PermissionManager";
import {CommandResult} from "tc-shared/connection/ServerConnectionDeclaration";
import PermissionType from "tc-shared/permission/PermissionType";

View File

@ -1,4 +1,4 @@
import {spawnModal} from "tc-shared/ui/react-elements/Modal";
import {spawnModal} from "tc-shared/ui/react-elements/modal";
import * as React from "react";
import {Registry} from "tc-shared/events";
import {EchoTestEvents, TestState} from "tc-shared/ui/modal/echo-test/Definitions";

View File

@ -1,4 +1,4 @@
import {spawnModal} from "tc-shared/ui/react-elements/Modal";
import {spawnModal} from "tc-shared/ui/react-elements/modal";
import {Registry} from "tc-shared/events";
import {ModalGlobalSettingsEditorEvents, Setting} from "tc-shared/ui/modal/global-settings-editor/Definitions";
import {RegistryKey, RegistryValueType, Settings, settings} from "tc-shared/settings";

View File

@ -1,7 +1,6 @@
import {Translatable} from "tc-shared/ui/react-elements/i18n";
import * as React from "react";
import {createContext, useContext, useRef, useState} from "react";
import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller";
import {IpcRegistryDescription, Registry} from "tc-shared/events";
import {ModalGlobalSettingsEditorEvents, Setting} from "tc-shared/ui/modal/global-settings-editor/Definitions";
import {LoadingDots} from "tc-shared/ui/react-elements/LoadingDots";

View File

@ -1,4 +1,4 @@
import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {spawnReactModal} from "tc-shared/ui/react-elements/modal";
import {ConnectionHandler} from "tc-shared/ConnectionHandler";
import * as React from "react";
import {useState} from "react";

View File

@ -1,4 +1,4 @@
import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {spawnReactModal} from "tc-shared/ui/react-elements/modal";
import * as React from "react";
import {Registry} from "tc-shared/events";
import {FileBrowserRenderer, NavigationBar} from "./FileBrowserRenderer";

View File

@ -1,5 +1,5 @@
import {Registry} from "tc-shared/events";
import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {spawnReactModal} from "tc-shared/ui/react-elements/modal";
import {ModalVideoSourceEvents} from "tc-shared/ui/modal/video-source/Definitions";
import {ModalVideoSource} from "tc-shared/ui/modal/video-source/Renderer";
import {getVideoDriver, VideoPermissionStatus, VideoSource} from "tc-shared/video/VideoSource";

View File

@ -1,4 +1,4 @@
import {spawnReactModal} from "tc-shared/ui/react-elements/Modal";
import {spawnReactModal} from "tc-shared/ui/react-elements/modal";
import {InternalModal} from "tc-shared/ui/react-elements/internal-modal/Controller";
import * as React from "react";
import {WhatsNew} from "tc-shared/ui/modal/whats-new/Renderer";

View File

@ -7,6 +7,7 @@ import {EchoTestEvents} from "tc-shared/ui/modal/echo-test/Definitions";
import {ModalGlobalSettingsEditorEvents} from "tc-shared/ui/modal/global-settings-editor/Definitions";
export type ModalType = "error" | "warning" | "info" | "none";
export type ModalRenderType = "page" | "dialog";
export interface ModalOptions {
/**

View File

@ -0,0 +1,43 @@
import {
AbstractModal,
ModalFunctionController,
ModalOptions,
ModalRenderType
} from "tc-shared/ui/react-elements/modal/Definitions";
import {useContext} from "react";
const ControllerContext = useContext<ModalRendererController>(undefined);
interface RendererControllerEvents {
}
export class ModalRendererController {
readonly renderType: ModalRenderType;
readonly modal: AbstractModal;
constructor(renderType: ModalRenderType, modal: AbstractModal,) {
this.renderType = renderType;
this.modal = modal;
}
setShown(shown: boolean) {
}
}
export const ModalRenderer = (props: {
mode: "page" | "dialog",
modal: AbstractModal,
modalOptions: ModalOptions,
modalActions: ModalFunctionController
}) => {
}
const ModalRendererDialog = (props: {
modal: AbstractModal,
modalOptions: ModalOptions,
modalActions: ModalFunctionController
}) => {
}

View File

@ -23,6 +23,7 @@ export class VoicePlayer implements VoicePlayer {
private currentRtpTrack: RemoteRTPAudioTrack;
constructor() {
this.volume = 1;
this.listenerTrackStateChanged = event => this.handleTrackStateChanged(event.newState);
this.events = new Registry<VoicePlayerEvents>();
this.currentState = VoicePlayerState.STOPPED;