Made default messages editible (required TeaSpeak 1.2.6)

canary
WolverinDEV 2018-08-13 11:03:55 +02:00
parent 66bb1350cb
commit 0309862c7f
6 changed files with 84 additions and 35 deletions

View File

@ -59,6 +59,10 @@
resize: none; resize: none;
} }
} }
.properties_messages textarea {
height: 70px;
resize: none;
}
.container { .container {
padding: 6px; padding: 6px;

View File

@ -392,7 +392,7 @@ class ConnectionCommandHandler {
updates.push({key: key, value: json[key]}); updates.push({key: key, value: json[key]});
} }
this.connection._client.channelTree.server.updateVariables(...updates); this.connection._client.channelTree.server.updateVariables(false, ...updates);
chat.serverChat().name = this.connection._client.channelTree.server.properties["virtualserver_name"]; chat.serverChat().name = this.connection._client.channelTree.server.properties["virtualserver_name"];
@ -757,7 +757,7 @@ class ConnectionCommandHandler {
updates.push({key: key, value: json[key]}); updates.push({key: key, value: json[key]});
} }
this.connection._client.channelTree.server.updateVariables(...updates); this.connection._client.channelTree.server.updateVariables(false, ...updates);
if(this.connection._client.selectInfo.currentSelected == this.connection._client.channelTree.server) if(this.connection._client.selectInfo.currentSelected == this.connection._client.channelTree.server)
this.connection._client.selectInfo.update(); this.connection._client.selectInfo.update();
} }
@ -777,7 +777,7 @@ class ConnectionCommandHandler {
updates.push({key: key, value: json[key]}); updates.push({key: key, value: json[key]});
} }
this.connection._client.channelTree.server.updateVariables(...updates); this.connection._client.channelTree.server.updateVariables(true, ...updates);
let info = this.connection._client.selectInfo; let info = this.connection._client.selectInfo;
if(info.currentSelected instanceof ServerEntry) if(info.currentSelected instanceof ServerEntry)
info.update(); info.update();

View File

@ -78,6 +78,7 @@ enum PermissionType {
B_VIRTUALSERVER_MODIFY_TEMPORARY_PASSWORDS_OWN = "b_virtualserver_modify_temporary_passwords_own", B_VIRTUALSERVER_MODIFY_TEMPORARY_PASSWORDS_OWN = "b_virtualserver_modify_temporary_passwords_own",
B_VIRTUALSERVER_MODIFY_CHANNEL_TEMP_DELETE_DELAY_DEFAULT = "b_virtualserver_modify_channel_temp_delete_delay_default", B_VIRTUALSERVER_MODIFY_CHANNEL_TEMP_DELETE_DELAY_DEFAULT = "b_virtualserver_modify_channel_temp_delete_delay_default",
B_VIRTUALSERVER_MODIFY_MUSIC_BOT_LIMIT = "b_virtualserver_modify_music_bot_limit", B_VIRTUALSERVER_MODIFY_MUSIC_BOT_LIMIT = "b_virtualserver_modify_music_bot_limit",
B_VIRTUALSERVER_MODIFY_DEFAULT_MESSAGES = "b_virtualserver_modify_music_bot_limit",
I_CHANNEL_MIN_DEPTH = "i_channel_min_depth", I_CHANNEL_MIN_DEPTH = "i_channel_min_depth",
I_CHANNEL_MAX_DEPTH = "i_channel_max_depth", I_CHANNEL_MAX_DEPTH = "i_channel_max_depth",
B_CHANNEL_GROUP_INHERITANCE_END = "b_channel_group_inheritance_end", B_CHANNEL_GROUP_INHERITANCE_END = "b_channel_group_inheritance_end",

View File

@ -31,6 +31,7 @@ namespace Modals {
server_applyGeneralListener(properties, modal.htmlTag.find(".properties_general"), modal.htmlTag.find(".button_ok")); server_applyGeneralListener(properties, modal.htmlTag.find(".properties_general"), modal.htmlTag.find(".button_ok"));
server_applyHostListener(properties, server.properties, modal.htmlTag.find(".properties_host"), modal.htmlTag.find(".button_ok")); server_applyHostListener(properties, server.properties, modal.htmlTag.find(".properties_host"), modal.htmlTag.find(".button_ok"));
server_applyMessages(properties, server, modal.htmlTag.find(".properties_messages"));
modal.htmlTag.find(".button_ok").click(() => { modal.htmlTag.find(".button_ok").click(() => {
modal.close(); modal.close();
@ -93,20 +94,6 @@ namespace Modals {
} }
/*
virtualserver_hostmessage
virtualserver_hostmessage_mode X
virtualserver_hostbanner_url
virtualserver_hostbanner_gfx_url
virtualserver_hostbanner_gfx_interval
virtualserver_hostbanner_mode X
virtualserver_hostbutton_tooltip
virtualserver_hostbutton_url
virtualserver_hostbutton_gfx_url
*/
function server_applyHostListener(properties: ServerProperties, original_properties: ServerProperties, tag: JQuery, button: JQuery) { function server_applyHostListener(properties: ServerProperties, original_properties: ServerProperties, tag: JQuery, button: JQuery) {
tag.find(".virtualserver_host").change(function (this: HTMLInputElement) { tag.find(".virtualserver_host").change(function (this: HTMLInputElement) {
properties.virtualserver_host = this.value; properties.virtualserver_host = this.value;
@ -158,18 +145,26 @@ virtualserver_hostbutton_gfx_url
}).prop("disabled", !globalClient.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_MODIFY_HOSTBUTTON).granted(1)); }).prop("disabled", !globalClient.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_MODIFY_HOSTBUTTON).granted(1));
} }
/*
<!--
virtualserver_hostmessage: string = "";
virtualserver_hostmessage_mode: string = "";
virtualserver_hostbanner_url: string = ""; function server_applyMessages(properties: ServerProperties, server: ServerEntry, tag: JQuery) {
virtualserver_hostbanner_gfx_url: string = ""; server.updateProperties().then(() => {
virtualserver_hostbanner_gfx_interval: number = 0; tag.find(".virtualserver_default_client_description").val(server.properties.virtualserver_default_client_description);
tag.find(".virtualserver_default_channel_description").val(server.properties.virtualserver_default_channel_description);
tag.find(".virtualserver_default_channel_topic").val(server.properties.virtualserver_default_channel_topic);
});
virtualserver_hostbutton_tooltip: string = ""; console.log(tag);
virtualserver_hostbutton_url: string = ""; console.log(tag.find(".virtualserver_default_client_description"));
virtualserver_hostbutton_gfx_url: string = ""; tag.find(".virtualserver_default_client_description").change(function (this: HTMLInputElement) {
--> properties.virtualserver_default_client_description = this.value;
*/ }).prop("disabled", !globalClient.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_MODIFY_DEFAULT_MESSAGES).granted(1));
tag.find(".virtualserver_default_channel_description").change(function (this: HTMLInputElement) {
properties.virtualserver_default_channel_description = this.value;
}).prop("disabled", !globalClient.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_MODIFY_DEFAULT_MESSAGES).granted(1));
tag.find(".virtualserver_default_channel_topic").change(function (this: HTMLInputElement) {
properties.virtualserver_default_channel_topic = this.value;
}).prop("disabled", !globalClient.permissions.neededPermission(PermissionType.B_VIRTUALSERVER_MODIFY_DEFAULT_MESSAGES).granted(1));
}
} }

View File

@ -34,6 +34,11 @@ class ServerProperties {
virtualserver_hostbutton_tooltip: string = ""; virtualserver_hostbutton_tooltip: string = "";
virtualserver_hostbutton_url: string = ""; virtualserver_hostbutton_url: string = "";
virtualserver_hostbutton_gfx_url: string = ""; virtualserver_hostbutton_gfx_url: string = "";
//Special requested properties
virtualserver_default_client_description: string = "";
virtualserver_default_channel_description: string = "";
virtualserver_default_channel_topic: string = "";
} }
interface ServerAddress { interface ServerAddress {
@ -46,6 +51,10 @@ class ServerEntry {
channelTree: ChannelTree; channelTree: ChannelTree;
properties: ServerProperties; properties: ServerProperties;
private info_request_promise: Promise<void> = undefined;
private info_request_promise_resolve: any = undefined;
private info_request_promise_reject: any = undefined;
lastInfoRequest: number = 0; lastInfoRequest: number = 0;
nextInfoRequest: number = 0; nextInfoRequest: number = 0;
private _htmlTag: JQuery<HTMLElement>; private _htmlTag: JQuery<HTMLElement>;
@ -109,7 +118,7 @@ class ServerEntry {
); );
} }
updateVariables(...variables: {key: string, value: string}[]) { updateVariables(is_self_notify: boolean, ...variables: {key: string, value: string}[]) {
let group = log.group(log.LogType.DEBUG, LogCategory.SERVER, "Update properties (%i)", variables.length); let group = log.group(log.LogType.DEBUG, LogCategory.SERVER, "Update properties (%i)", variables.length);
for(let variable of variables) { for(let variable of variables) {
@ -125,12 +134,29 @@ class ServerEntry {
} }
group.end(); group.end();
if(is_self_notify && this.info_request_promise_resolve) {
this.info_request_promise_resolve();
this.info_request_promise = undefined;
this.info_request_promise_reject = undefined;
this.info_request_promise_resolve = undefined;
}
} }
updateProperties() { updateProperties() : Promise<void> {
this.lastInfoRequest = new Date().getTime(); if(this.info_request_promise && Date.now() - this.lastInfoRequest < 1000) return this.info_request_promise;
this.lastInfoRequest = Date.now();
this.nextInfoRequest = this.lastInfoRequest + 10 * 1000; this.nextInfoRequest = this.lastInfoRequest + 10 * 1000;
this.channelTree.client.serverConnection.sendCommand("servergetvariables"); this.channelTree.client.serverConnection.sendCommand("servergetvariables").catch(error => {
this.info_request_promise_reject(error);
this.info_request_promise = undefined;
this.info_request_promise_reject = undefined;
this.info_request_promise_resolve = undefined;
});
return this.info_request_promise = new Promise<void>((resolve, reject) => {
this.info_request_promise_reject = reject;
this.info_request_promise_resolve = resolve;
});
} }
shouldUpdateProperties() : boolean { shouldUpdateProperties() : boolean {

View File

@ -227,7 +227,29 @@
</x-entry> </x-entry>
<x-entry> <x-entry>
<x-tag>Messages</x-tag> <x-tag>Messages</x-tag>
<x-content>TODO!</x-content> <x-content>
<div> <!-- We have to move the shit one layer up -->
<div class="container properties_messages">
<div class="group_box">
<div class="header">Channel</div>
<div class="content properties">
<div class="key">Default Topic:</div>
<textarea class="value virtualserver_default_channel_topic">{{>virtualserver_default_channel_topic}}</textarea>
<div class="key">Default Description</div>
<textarea class="value virtualserver_default_channel_description">{{>virtualserver_default_channel_description}}</textarea>
</div>
</div>
<div class="group_box">
<div class="header">Client</div>
<div class="content properties">
<div class="key">Default Description</div>
<textarea class="value virtualserver_default_client_description">{{>virtualserver_default_client_description}}</textarea>
</div>
</div>
</div>
</div>
</x-content>
</x-entry> </x-entry>
</x-tab> </x-tab>
</script> </script>
@ -701,7 +723,8 @@
</td> </td>
</tr> </tr>
</table> </table>
<div> <div style="margin-top: 10px">
<b style="margin-bottom: 2px">Description</b>
<node key="bbcode_channel_description"></node> <node key="bbcode_channel_description"></node>
</div> </div>
</script> </script>