Changeset - 144ccb07e8e2
[Not reviewed]
0 2 0
Jan Kaluza - 10 years ago 2016-01-28 09:23:41
jkaluza@redhat.com
Web interface: Fix missing ',' in app.js
2 files changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/APIServer.cpp
Show inline comments
 
@@ -131,48 +131,52 @@ void APIServer::serve_instances(Server *server, Server::session *session, struct
 
void APIServer::serve_instances_list_rooms(Server *server, Server::session *session, struct mg_connection *conn, struct http_message *hm) {
 
	std::string uri(hm->uri.p, hm->uri.len);
 
	std::string instance = uri.substr(uri.rfind("/") + 1);
 

	
 
	UserInfo info;
 
	m_storage->getUser(session->user, info);
 

	
 
	std::string username = "";
 
	int type = (int) TYPE_STRING;
 
	m_storage->getUserSetting(info.id, instance, type, username);
 

	
 
	if (username.empty()) {
 
		send_ack(conn, true, "You are not registered to this Spectrum 2 instance.");
 
		return;
 
	}
 

	
 
	std::string response = server->send_command(instance, "list_rooms " + username);
 

	
 
	std::vector<std::string> commands;
 
	boost::split(commands, response, boost::is_any_of("\n"));
 

	
 
	Document json;
 
	json.SetObject();
 
	json.AddMember("error", 0, json.GetAllocator());
 
	json.AddMember("name_label", "Nickname in 3rd-party room", json.GetAllocator());
 
	json.AddMember("legacy_room_label", "3rd-party room name", json.GetAllocator());
 
	json.AddMember("legacy_server_label", "3rd-party server", json.GetAllocator());
 
	json.AddMember("frontend_room_label", "Slack channel", json.GetAllocator());
 

	
 
	std::vector<std::vector<std::string> > tmp;
 
	Value rooms(kArrayType);
 
	BOOST_FOREACH(const std::string &command, commands) {
 
		if (command.size() > 5) {
 
			std::vector<std::string> args2;
 
			boost::split(args2, command, boost::is_any_of(" "));
 
			if (args2.size() == 6) {
 
				tmp.push_back(args2);
 
				Value room;
 
				room.SetObject();
 
				room.AddMember("name", tmp.back()[2].c_str(), json.GetAllocator());
 
				room.AddMember("legacy_room", tmp.back()[3].c_str(), json.GetAllocator());
 
				room.AddMember("legacy_server", tmp.back()[4].c_str(), json.GetAllocator());
 
				room.AddMember("frontend_room", tmp.back()[5].c_str(), json.GetAllocator());
 
				rooms.PushBack(room, json.GetAllocator());
 
			}
 
		}
 
	}
 

	
 
	json.AddMember("rooms", rooms, json.GetAllocator());
 
	send_json(conn, json);
 
}
 

	
spectrum_manager/src/html/js/app.js
Show inline comments
 
@@ -116,49 +116,49 @@ function show_users() {
 
			$(".button_command").click(function(e) {
 
				e.preventDefault();
 
				$(this).parent().empty().progressbar( {value: false} ).css('height', '1em');
 

	
 
				var url = $(this).attr('href');
 
				$.get(url, function(data) {
 
					show_users();
 
				});
 
			})
 
		});
 
	});
 
}
 

	
 
function fill_instances_join_room_form() {
 
	var query = getQueryParams(document.location.search);
 
	$("#instance").attr("value", query.id);
 

	
 
	$(".button_command").click(function(e) {
 
		e.preventDefault();
 
		$(this).parent().empty().progressbar( {value: false} ).css('height', '1em');
 

	
 
		var postdata ={
 
			"name": $("#name").val(),
 
			"legacy_room": $("#legacy_room").val(),
 
			"legacy_server": $("#legacy_server").val()
 
			"legacy_server": $("#legacy_server").val(),
 
			"frontend_room": $("#frontend_room").val()
 
		};
 

	
 
		$.post($.cookie("base_location") + "api/v1/instances/join_room/" + $("#instance").val(), postdata, function(data) {
 
			window.location.replace("index.shtml");
 
		});
 
	})
 
	
 
	$.get($.cookie("base_location") + "api/v1/instances/join_room_form/" + query.id, function(data) {
 
		$("#name_desc").html(data.name_label + ":");
 
		$("#legacy_room_desc").html(data.legacy_room_label + ":");
 
		$("#legacy_server_desc").html(data.legacy_server_label + ":");
 
		$("#frontend_room_desc").html(data.frontend_room_label + ":");
 

	
 
		$("#name").attr("placeholder", data.name_label + ":");
 
		$("#legacy_room").attr("placeholder", data.legacy_room_label + ":");
 
		$("#legacy_server").attr("placeholder", data.legacy_server_label + ":");
 
		$("#frontend_room").attr("placeholder", data.frontend_room_label + ":");
 
	});
 
}
 

	
 
function fill_instances_register_form() {
 
	var query = getQueryParams(document.location.search);
 
	$("#instance").attr("value", query.id);
0 comments (0 inline, 0 general)