fixed some errors
This commit is contained in:
parent
9b52f0a858
commit
e4b7ac02a6
5 changed files with 53 additions and 31 deletions
|
@ -25,6 +25,7 @@ namespace Modals {
|
||||||
export interface BanListManager {
|
export interface BanListManager {
|
||||||
addbans : (ban: BanEntry[]) => void;
|
addbans : (ban: BanEntry[]) => void;
|
||||||
clear : (ban?: any) => void;
|
clear : (ban?: any) => void;
|
||||||
|
modal: Modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function openBanList(client: TSClient) {
|
export function openBanList(client: TSClient) {
|
||||||
|
@ -84,8 +85,10 @@ namespace Modals {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
update = () => {
|
const single_handler: connection.SingleCommandHandler = {
|
||||||
client.serverConnection.commandHandler["notifybanlist"] = json => {
|
command: "notifybanlist",
|
||||||
|
function: command => {
|
||||||
|
const json = command.arguments;
|
||||||
console.log(tr("Got banlist: %o"), json);
|
console.log(tr("Got banlist: %o"), json);
|
||||||
|
|
||||||
let bans: BanEntry[] = [];
|
let bans: BanEntry[] = [];
|
||||||
|
@ -136,7 +139,15 @@ namespace Modals {
|
||||||
}
|
}
|
||||||
|
|
||||||
modal.addbans(bans);
|
modal.addbans(bans);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
client.serverConnection.command_handler_boss().register_single_handler(single_handler);
|
||||||
|
modal.modal.close_listener.push(() => {
|
||||||
|
client.serverConnection.command_handler_boss().remove_single_handler(single_handler);
|
||||||
|
});
|
||||||
|
|
||||||
|
update = () => {
|
||||||
|
|
||||||
//TODO test permission
|
//TODO test permission
|
||||||
modal.clear();
|
modal.clear();
|
||||||
|
@ -208,6 +219,7 @@ namespace Modals {
|
||||||
modal.htmlTag.find(".entry-container .entries").children().detach();
|
modal.htmlTag.find(".entry-container .entries").children().detach();
|
||||||
update_function();
|
update_function();
|
||||||
};
|
};
|
||||||
|
result.modal = modal;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -745,7 +745,7 @@ namespace Modals {
|
||||||
|
|
||||||
const resolve_client = () => {
|
const resolve_client = () => {
|
||||||
let client_uid = tag_select_uid.val() as string;
|
let client_uid = tag_select_uid.val() as string;
|
||||||
globalClient.serverConnection.helper.info_from_uid(client_uid).then(result => {
|
globalClient.serverConnection.command_helper.info_from_uid(client_uid).then(result => {
|
||||||
if(!result || result.length == 0) return Promise.reject("invalid data");
|
if(!result || result.length == 0) return Promise.reject("invalid data");
|
||||||
tag_select_uid.attr('pattern', null).removeClass('is-invalid');
|
tag_select_uid.attr('pattern', null).removeClass('is-invalid');
|
||||||
|
|
||||||
|
@ -888,7 +888,7 @@ namespace Modals {
|
||||||
|
|
||||||
const resolve_client = () => {
|
const resolve_client = () => {
|
||||||
let client_uid = tag_select_uid.val() as string;
|
let client_uid = tag_select_uid.val() as string;
|
||||||
globalClient.serverConnection.helper.info_from_uid(client_uid).then(result => {
|
globalClient.serverConnection.command_helper.info_from_uid(client_uid).then(result => {
|
||||||
if(!result || result.length == 0) return Promise.reject("invalid data");
|
if(!result || result.length == 0) return Promise.reject("invalid data");
|
||||||
tag_select_uid.attr('pattern', null).removeClass('is-invalid');
|
tag_select_uid.attr('pattern', null).removeClass('is-invalid');
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,7 @@ namespace Modals {
|
||||||
|
|
||||||
const update_songs = () => {
|
const update_songs = () => {
|
||||||
set_song_info(tr("loading song list"));
|
set_song_info(tr("loading song list"));
|
||||||
client.serverConnection.helper.request_playlist_songs(playlist.playlist_id).then(result => {
|
client.serverConnection.command_helper.request_playlist_songs(playlist.playlist_id).then(result => {
|
||||||
const entries_tag = song_tag.find(".song-list-entries");
|
const entries_tag = song_tag.find(".song-list-entries");
|
||||||
const entry_template = $("#tmpl_playlist_edit-song_entry");
|
const entry_template = $("#tmpl_playlist_edit-song_entry");
|
||||||
entries_tag.empty();
|
entries_tag.empty();
|
||||||
|
@ -297,7 +297,7 @@ namespace Modals {
|
||||||
function apply_properties(tag: JQuery, client: TSClient, playlist: Playlist, change_property: (key: string, value: string) => any, callback_current_song: (id: number) => any) {
|
function apply_properties(tag: JQuery, client: TSClient, playlist: Playlist, change_property: (key: string, value: string) => any, callback_current_song: (id: number) => any) {
|
||||||
const owns_playlist = playlist.playlist_owner_dbid == client.getClient().properties.client_database_id;
|
const owns_playlist = playlist.playlist_owner_dbid == client.getClient().properties.client_database_id;
|
||||||
|
|
||||||
client.serverConnection.helper.request_playlist_info(playlist.playlist_id).then(info => {
|
client.serverConnection.command_helper.request_playlist_info(playlist.playlist_id).then(info => {
|
||||||
tag.find(".property-owner input")
|
tag.find(".property-owner input")
|
||||||
.val(info.playlist_owner_name + " (" + info.playlist_owner_dbid + ")");
|
.val(info.playlist_owner_name + " (" + info.playlist_owner_dbid + ")");
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace Modals {
|
||||||
update_selected();
|
update_selected();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
available_playlists = await client.serverConnection.helper.request_playlist_list();
|
available_playlists = await client.serverConnection.command_helper.request_playlist_list();
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
info_tag.text("failed to query playlist list.");
|
info_tag.text("failed to query playlist list.");
|
||||||
//FIXME error handling?
|
//FIXME error handling?
|
||||||
|
@ -92,8 +92,9 @@ namespace Modals {
|
||||||
template.find(".footer .buttons .button-refresh").on('click', update_list);
|
template.find(".footer .buttons .button-refresh").on('click', update_list);
|
||||||
|
|
||||||
template.find(".button-playlist-create").on('click', event => {
|
template.find(".button-playlist-create").on('click', event => {
|
||||||
const notify_handler = json => {
|
const single_handler: connection.SingleCommandHandler = {
|
||||||
client.serverConnection.commandHandler.unset_handler("notifyplaylistcreated", notify_handler);
|
function: command => {
|
||||||
|
const json = command.arguments;
|
||||||
update_list().then(() => {
|
update_list().then(() => {
|
||||||
spawnYesNo(tr("Playlist created successful"), tr("The playlist has been successfully created.<br>Should we open the editor?"), result => {
|
spawnYesNo(tr("Playlist created successful"), tr("The playlist has been successfully created.<br>Should we open the editor?"), result => {
|
||||||
if(result) {
|
if(result) {
|
||||||
|
@ -106,10 +107,14 @@ namespace Modals {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
command: "notifyplaylistcreated"
|
||||||
};
|
};
|
||||||
client.serverConnection.commandHandler.set_handler("notifyplaylistcreated", notify_handler);
|
client.serverConnection.command_handler_boss().register_single_handler(single_handler);
|
||||||
client.serverConnection.send_command("playlistcreate").catch(error => {
|
client.serverConnection.send_command("playlistcreate").catch(error => {
|
||||||
client.serverConnection.commandHandler.unset_handler("notifyplaylistcreated", notify_handler);
|
client.serverConnection.command_handler_boss().remove_single_handler(single_handler);
|
||||||
if(error instanceof CommandResult)
|
if(error instanceof CommandResult)
|
||||||
error = error.extra_message || error.message;
|
error = error.extra_message || error.message;
|
||||||
createErrorModal(tr("Unable to create playlist"), tr("Failed to create playlist<br>Message: ") + error).open();
|
createErrorModal(tr("Unable to create playlist"), tr("Failed to create playlist<br>Message: ") + error).open();
|
||||||
|
|
|
@ -20,8 +20,9 @@ namespace Modals {
|
||||||
}
|
}
|
||||||
|
|
||||||
//client_login_password
|
//client_login_password
|
||||||
globalClient.serverConnection.commandHandler["notifyquerycreated"] = json => {
|
const single_handler: connection.SingleCommandHandler = {
|
||||||
json = json[0];
|
function: command => {
|
||||||
|
const json = command.arguments[0];
|
||||||
|
|
||||||
spawnQueryCreated({
|
spawnQueryCreated({
|
||||||
username: name,
|
username: name,
|
||||||
|
@ -30,11 +31,15 @@ namespace Modals {
|
||||||
|
|
||||||
if(callback_created)
|
if(callback_created)
|
||||||
callback_created(name, json.client_login_password);
|
callback_created(name, json.client_login_password);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
globalClient.serverConnection.command_handler_boss().register_single_handler(single_handler);
|
||||||
globalClient.serverConnection.sendCommand("querycreate", {
|
globalClient.serverConnection.send_command("querycreate", {
|
||||||
client_login_name: name
|
client_login_name: name
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
globalClient.serverConnection.command_handler_boss().remove_single_handler(single_handler);
|
||||||
|
|
||||||
if(error instanceof CommandResult)
|
if(error instanceof CommandResult)
|
||||||
error = error.extra_message || error.message;
|
error = error.extra_message || error.message;
|
||||||
createErrorModal(tr("Unable to create account"), tr("Failed to create account<br>Message: ") + error).open();
|
createErrorModal(tr("Unable to create account"), tr("Failed to create account<br>Message: ") + error).open();
|
||||||
|
|
Loading…
Add table
Reference in a new issue