AdminInterface: Support labels for commands
This commit is contained in:
parent
84ea5f3249
commit
6e1af765cd
6 changed files with 35 additions and 17 deletions
|
@ -69,7 +69,7 @@ class AdminInterfaceCommand {
|
|||
std::string example;
|
||||
};
|
||||
|
||||
AdminInterfaceCommand(const std::string &name, Category category, Context context, AccessMode accessMode, Actions actions);
|
||||
AdminInterfaceCommand(const std::string &name, Category category, Context context, AccessMode accessMode, Actions actions, const std::string &label = "");
|
||||
|
||||
virtual ~AdminInterfaceCommand() { }
|
||||
|
||||
|
@ -112,6 +112,10 @@ class AdminInterfaceCommand {
|
|||
return m_args;
|
||||
}
|
||||
|
||||
const std::string &getLabel() {
|
||||
return m_label;
|
||||
}
|
||||
|
||||
virtual std::string handleSetRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
|
||||
virtual std::string handleGetRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
|
||||
virtual std::string handleExecuteRequest(UserInfo &uinfo, User *user, std::vector<std::string> &args);
|
||||
|
@ -124,6 +128,7 @@ class AdminInterfaceCommand {
|
|||
Actions m_actions;
|
||||
std::string m_desc;
|
||||
std::list<Arg> m_args;
|
||||
std::string m_label;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -247,7 +247,8 @@ class ReloadCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::General,
|
||||
AdminInterfaceCommand::GlobalContext,
|
||||
AdminInterfaceCommand::AdminMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"Reload Spectrum 2 configuration") {
|
||||
m_component = component;
|
||||
setDescription("Reloads config file");
|
||||
}
|
||||
|
@ -278,7 +279,7 @@ class HasOnlineUserCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::Users,
|
||||
AdminInterfaceCommand::GlobalContext,
|
||||
AdminInterfaceCommand::AdminMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute, "Has online user") {
|
||||
m_userManager = userManager;
|
||||
setDescription("Returns 1 if user is online");
|
||||
addArg("username", "Username", "user@domain.tld");
|
||||
|
@ -703,7 +704,8 @@ class RegisterCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::Users,
|
||||
AdminInterfaceCommand::GlobalContext,
|
||||
AdminInterfaceCommand::UserMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"Register") {
|
||||
m_userRegistration = userRegistration;
|
||||
setDescription("Registers the new user");
|
||||
|
||||
|
@ -761,7 +763,8 @@ class UnregisterCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::Users,
|
||||
AdminInterfaceCommand::UserContext,
|
||||
AdminInterfaceCommand::UserMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"Unregister") {
|
||||
m_userRegistration = userRegistration;
|
||||
setDescription("Unregisters existing user");
|
||||
|
||||
|
@ -866,7 +869,8 @@ class HelpCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::General,
|
||||
AdminInterfaceCommand::GlobalContext,
|
||||
AdminInterfaceCommand::AdminMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"Help") {
|
||||
m_commands = commands;
|
||||
setDescription("Shows help message");
|
||||
}
|
||||
|
@ -920,7 +924,8 @@ class CommandsCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::General,
|
||||
AdminInterfaceCommand::GlobalContext,
|
||||
AdminInterfaceCommand::AdminMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"Available commands") {
|
||||
m_commands = commands;
|
||||
setDescription("Shows all the available commands with extended information.");
|
||||
}
|
||||
|
@ -958,6 +963,8 @@ class CommandsCommand : public AdminInterfaceCommand {
|
|||
output += " Global";
|
||||
}
|
||||
|
||||
output += " Label: \"" + (command->getLabel().empty() ? command->getName() : command->getLabel()) + "\"";
|
||||
|
||||
output += "\n";
|
||||
}
|
||||
|
||||
|
@ -976,7 +983,8 @@ class VariablesCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::General,
|
||||
AdminInterfaceCommand::GlobalContext,
|
||||
AdminInterfaceCommand::AdminMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"Available variables") {
|
||||
m_commands = commands;
|
||||
setDescription("Shows all the available variables.");
|
||||
}
|
||||
|
@ -1040,7 +1048,7 @@ class ArgsCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::General,
|
||||
AdminInterfaceCommand::GlobalContext,
|
||||
AdminInterfaceCommand::AdminMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute, "Command's arguments") {
|
||||
m_commands = commands;
|
||||
setDescription("Shows descripton of arguments for command");
|
||||
addArg("command", "Command", "register");
|
||||
|
|
|
@ -30,12 +30,13 @@
|
|||
|
||||
namespace Transport {
|
||||
|
||||
AdminInterfaceCommand::AdminInterfaceCommand(const std::string &name, Category category, Context context, AccessMode accessMode, Actions actions) {
|
||||
AdminInterfaceCommand::AdminInterfaceCommand(const std::string &name, Category category, Context context, AccessMode accessMode, Actions actions, const std::string &label) {
|
||||
m_name = name;
|
||||
m_category = category;
|
||||
m_context = context;
|
||||
m_accessMode = accessMode;
|
||||
m_actions = actions;
|
||||
m_label = label;
|
||||
}
|
||||
|
||||
const std::string AdminInterfaceCommand::getCategoryName(Category category) {
|
||||
|
|
|
@ -49,7 +49,8 @@ class ListRoomsCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::Frontend,
|
||||
AdminInterfaceCommand::UserContext,
|
||||
AdminInterfaceCommand::UserMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"List joined 3rd-party network rooms") {
|
||||
m_storageBackend = storageBackend;
|
||||
setDescription("List connected rooms");
|
||||
}
|
||||
|
@ -81,7 +82,8 @@ class JoinRoomCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::Frontend,
|
||||
AdminInterfaceCommand::UserContext,
|
||||
AdminInterfaceCommand::UserMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"Join 3rd-party network room") {
|
||||
m_storageBackend = storageBackend;
|
||||
setDescription("Join the room");
|
||||
|
||||
|
@ -140,7 +142,8 @@ class LeaveRoomCommand : public AdminInterfaceCommand {
|
|||
AdminInterfaceCommand::Frontend,
|
||||
AdminInterfaceCommand::UserContext,
|
||||
AdminInterfaceCommand::UserMode,
|
||||
AdminInterfaceCommand::Execute) {
|
||||
AdminInterfaceCommand::Execute,
|
||||
"Leave 3rd-party network room") {
|
||||
m_storageBackend = storageBackend;
|
||||
setDescription("Leave the room");
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ void APIServer::serve_instances_commands(Server *server, Server::session *sessio
|
|||
tokens.push_back(*beg);
|
||||
}
|
||||
|
||||
if (tokens.size() != 9) {
|
||||
if (tokens.size() != 11) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -337,6 +337,7 @@ void APIServer::serve_instances_commands(Server *server, Server::session *sessio
|
|||
cmd.AddMember("desc", tokens[2].c_str(), json.GetAllocator());
|
||||
cmd.AddMember("category", tokens[4].c_str(), json.GetAllocator());
|
||||
cmd.AddMember("context", tokens[8].c_str(), json.GetAllocator());
|
||||
cmd.AddMember("label", tokens[10].c_str(), json.GetAllocator());
|
||||
cmds.PushBack(cmd, json.GetAllocator());
|
||||
}
|
||||
|
||||
|
@ -422,7 +423,7 @@ void APIServer::serve_instances_command_args(Server *server, Server::session *se
|
|||
tokens.push_back(*beg);
|
||||
}
|
||||
|
||||
if (tokens.size() != 9) {
|
||||
if (tokens.size() != 11) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -524,7 +525,7 @@ void APIServer::serve_instances_execute(Server *server, Server::session *session
|
|||
tokens.push_back(*beg);
|
||||
}
|
||||
|
||||
if (tokens.size() != 9) {
|
||||
if (tokens.size() != 11) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ function show_instance() {
|
|||
$.get($.cookie("base_location") + "api/v1/instances/commands/" + query.id, function(data) {
|
||||
$.each(data.commands, function(i, command) {
|
||||
var row = '<tr>'
|
||||
row += '<td><a class="button_command" command="' + command.name + '" instance="' + query.id + '" href="' + $.cookie("base_location") + 'api/v1/instances/command_args/' + query.id + '?command=' + command.name +'">' + command.name + '</a></td>';
|
||||
row += '<td><a class="button_command" command="' + command.name + '" instance="' + query.id + '" href="' + $.cookie("base_location") + 'api/v1/instances/command_args/' + query.id + '?command=' + command.name +'">' + command.label + '</a></td>';
|
||||
row += '<td>' + command.category + '</td>';
|
||||
row += '<td>' + command.desc + '</td>';
|
||||
row += '</tr>';
|
||||
|
|
Loading…
Add table
Reference in a new issue