-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
145 lines (124 loc) · 4.79 KB
/
Copy pathadmin.html
File metadata and controls
145 lines (124 loc) · 4.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
<title>Admin</title>
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="css/demo.css">
<style type="text/css" class="init"></style>
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js"></script>
<script type="text/javascript" language="javascript" class="init">
// Record current client_id and channel_id
var selected_client_id = -1;
var selected_channel_id = -1;
// Send an ajax request to server, to assign a client to another channel
function adminPickChannel() {
selected_channel_id = $('#channel-select-options').val();
if (selected_client_id < 0 || selected_channel_id < 0) return;
$.ajax("/assign_user_to_channel?client=" + selected_client_id + "&channel=" + selected_channel_id)
.done(function() {
console.log(selected_client_id + ' - ' + selected_channel_id);
})
.fail(function() {
console.log(selected_client_id + ' - ' + selected_channel_id);
})
$("#channel-selector-box").dialog("close");
location.reload();
}
// Send an ajax request to server, to reset a channel's music patterns
function adminResetChannel() {
var channel_id = $('#channel-reset-options').val();
$.ajax("/generate_patterns?channel=" + channel_id)
.done(function() {
console.log('Okay: generate_patterns - ' + channel_id);
})
.fail(function() {
console.log('Fail: generate_patterns - ' + channel_id);
})
location.reload();
}
// Send an ajax request to server, to send real-time message to a client
function adminSendMessageToClient() {
var message = $('#send-player-msg-input').val();
$.ajax("/send_message_to_client?client=" + selected_client_id + "&msg=" + message)
.done(function() {
console.log('Okay: send_message_to_client - ' + selected_client_id);
})
.fail(function() {
console.log('Fail: send_message_to_client - ' + selected_client_id);
})
location.reload();
}
$(document).ready(function() {
$("#channel-selector-box").dialog({ autoOpen: false });
$('#example').dataTable({ "ajax": '/get_clients' });
$('#example tbody').on('click', 'tr', function (){
selected_client_id = $('td', this).eq(0).text();
selected_channel_id = $('td', this).eq(2).text();
$("#channel-selector-box-client-name").text($('td', this).eq(1).text());
//$("#channel-select-options option[value=" + selected_channel_id + "]").prop("selected", "selected");
$("#channel-selector-box").dialog("open");
});
});
</script>
</head>
<body class="dt-example">
<!--
Control box for each client:
1. Send message to client
2. Assign client to another group
-->
<div id="channel-selector-box" title="Select Channel">
<h5 id="channel-selector-box-client-name"></h5>
<p>
<select id="channel-select-options">
<option value="0">Channel 0</option>
<option value="1">Channel 1</option>
<option value="2">Channel 2</option>
<option value="3">Channel 3</option>
</select>
<button id="channel-select-submit" onclick="adminPickChannel()">Submit</button>
</p>
<p>
<input id="send-player-msg-input"/>
<button id="send-player-msg-button" onclick="adminSendMessageToClient()">Send Message</button>
</p>
</div>
<!-- Client table -->
<div class="container">
<section>
<h1>Sync-sounds <span> admin dashboard</span></h1>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Client ID</th>
<th>Name</th>
<th>Join Time</th>
<th>IP</th>
<th class="channel-selector">Channel</th>
<th>Patterns</th>
</tr>
</thead>
<tbody></tbody>
</table>
</section>
<!--
Control box: Reset channel's music patterns (randomly)
-->
<section>
Reset Channel Patterns:
<select id="channel-reset-options">
<option value="0">Channel 0</option>
<option value="1">Channel 1</option>
<option value="2">Channel 2</option>
<option value="3">Channel 3</option>
</select>
<button onclick="adminResetChannel()">Reset</button>
</section>
</div>
</body>
</html>