Changeset - b11cb99ccd57
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2016-02-20 15:37:39
jkaluza@redhat.com
Web interface: Fix leaving the room with hash in the name
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/html/js/app.js
Show inline comments
 
@@ -36,97 +36,97 @@ function show_instances() {
 
				var command = "";
 
			}
 
			var row = '<tr>'
 
			row += '<td>' + instance.name + '</td>'
 
			row += '<td>' + instance.status + '</td>'
 

	
 
			if (command == 'register') {
 
				row += '<td><a class="button_command" href="' + $.cookie("base_location") + 'instances/register.shtml?id=' + instance.id + '">' + command + '</a>' + '</td></tr>';
 
				$("#main_result  > tbody:last-child").append(row);
 
			}
 
			else if (command == "") {
 
				row += '<td></td></tr>';
 
				$("#main_result  > tbody:last-child").append(row);
 
			}
 
			else {
 
				row += '<td>';
 
				if (command == 'unregister' && instance.frontend == "slack") {
 
					row += '<a href="' + $.cookie("base_location") + 'instances/join_room.shtml?id=' + instance.id + '">Join room</a> | ';
 
					row += '<a href="' + $.cookie("base_location") + 'instances/list_rooms.shtml?id=' + instance.id + '">List joined rooms</a> | ';
 
				}
 
				row += '<a class="button_command" href="' + $.cookie("base_location") +  'api/v1/instances/' + command + '/' + instance.id + '">' + command + '</a>';
 
				row += '</td></tr>';
 
				$("#main_result  > tbody:last-child").append(row);
 
				$(".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_instances();
 
					});
 
				})
 
			}
 
		});
 
	});
 
}
 

	
 
function show_list_rooms() {
 
	var query = getQueryParams(document.location.search);
 
	$.get($.cookie("base_location") + "api/v1/instances/list_rooms/" + query.id, function(data) {
 
		$("#main_content").html("<h2>Joined rooms</h2><table id='main_result'><tr><th>" + data.frontend_room_label + "</th><th>" + data.legacy_room_label + "</th><th>" + data.legacy_server_label + "</th><th>" + data.name_label + "</th><th>Actions</th></tr>");
 

	
 
		$.each(data.rooms, function(i, room) {
 
			var row = '<tr>';
 
			row += '<td>' + room.frontend_room + '</td>';
 
			row += '<td>' + room.legacy_room + '</td>';
 
			row += '<td>' + room.legacy_server + '</td>';
 
			row += '<td>' + room.name + '</td>';
 
			row += '<td><a class="button_command" href="' + $.cookie("base_location") +  'api/v1/instances/leave_room/' + query.id + '?frontend_room=' + room.frontend_room + '">Leave</a></td>';
 
			row += '<td><a class="button_command" href="' + $.cookie("base_location") +  'api/v1/instances/leave_room/' + query.id + '?frontend_room=' + encodeURIComponent(room.frontend_room) + '">Leave</a></td>';
 
			row += '</tr>';
 

	
 
			$("#main_result  > tbody:last-child").append(row);
 
			$(".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_list_rooms();
 
				});
 
			})
 
		});
 
	});
 
}
 

	
 
function show_users() {
 
	var admin = $.cookie("admin") == "1";
 
	if (!admin) {
 
		$("#main_content").html("<h2>List of Spectrum 2 users</h2><p>Only administrator can list the users.</p>");
 
		return;
 
	}
 

	
 
	$.get($.cookie("base_location") + "api/v1/users", function(data) {
 
		$("#main_content").html("<h2>List of Spectrum 2 users</h2><p>You can add new users <a href=\"register.shtml?back_to_list=1\">here</a>.</p><table id='main_result'><tr><th>Name<th>Actions</th></tr>");
 

	
 
		$.each(data.users, function(i, user) {
 
			var row = '<tr>'
 
			row += '<td>' + user.username + '</td>'
 
			row += '<td><a class="button_command" href="' + $.cookie("base_location") +  'api/v1/users/remove/' + user.username + '">remove</a></td></tr>';
 
			$("#main_result  > tbody:last-child").append(row);
 
			$(".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);
 

	
0 comments (0 inline, 0 general)