update client
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
<div class="config">
|
||||
<label>Base URL: </label>
|
||||
<input id="baseUrl" value="http://localhost:8080">
|
||||
<span id="current-user" style="margin-left:14px;color:#666;font-size:0.85em"></span>
|
||||
</div>
|
||||
|
||||
<div id="log-header">
|
||||
@@ -86,7 +87,6 @@
|
||||
<button data-form="msg-user" onclick="showForm('msg-user')">POST /connection/message</button>
|
||||
<button data-form="hub-create" onclick="showForm('hub-create')">POST /hub</button>
|
||||
<button data-form="hub-join" onclick="showForm('hub-join')">PUT /hub/join</button>
|
||||
<button data-form="channel-message" onclick="showForm('channel-message')">POST /channel/message</button>
|
||||
<button data-form="websocket" onclick="showForm('websocket')">WS /ws</button>
|
||||
</div>
|
||||
|
||||
@@ -246,16 +246,6 @@
|
||||
<div class="form-actions"><button class="send" onclick="submit('hub-join')">Send</button></div>
|
||||
</div>
|
||||
|
||||
<!-- POST /channel/message -->
|
||||
<div class="form-content" id="fc-channel-message">
|
||||
<div class="field"><label>token</label><input id="cm-token" placeholder=""></div>
|
||||
<div class="field"><label>hubid</label><input id="cm-hubid" placeholder="UUID"></div>
|
||||
<div class="field"><label>channelid</label><input id="cm-channelid" placeholder="UUID"></div>
|
||||
<div class="field"><label>msgContent</label><input id="cm-msgContent" placeholder="message text (optional if file set)"></div>
|
||||
<div class="field"><label>attachedFile</label><input id="cm-attachedFile" placeholder="key from POST /file (optional)"></div>
|
||||
<div class="form-actions"><button class="send" onclick="submit('channel-message')">Send</button></div>
|
||||
</div>
|
||||
|
||||
<!-- WS /ws -->
|
||||
<div class="form-content" id="fc-websocket">
|
||||
<div class="form-actions" style="margin-bottom:10px">
|
||||
@@ -278,6 +268,7 @@
|
||||
let ws = null;
|
||||
let activeForm = null;
|
||||
let currentToken = '';
|
||||
let currentUserId = '';
|
||||
|
||||
// method, path, which field ids go where
|
||||
// dest: 'header' | 'body' | 'query'
|
||||
@@ -297,7 +288,6 @@
|
||||
'msg-user': { method:'POST', path:'/connection/message', title:'POST /connection/message — send direct message', fields:[{id:'mu-token',dest:'header',name:'token'},{id:'mu-connectionid',dest:'body',name:'connectionid'},{id:'mu-msgContent',dest:'body',name:'msgContent'},{id:'mu-attachedFile',dest:'body',name:'attachedFile'}] },
|
||||
'hub-create': { method:'POST', path:'/hub', title:'POST /hub — create a new hub', fields:[{id:'hc-token',dest:'header',name:'token'},{id:'hc-hubname',dest:'body',name:'hubname'}] },
|
||||
'hub-join': { method:'PUT', path:'/hub/join', title:'PUT /hub/join — join hub (hubid as header)', fields:[{id:'hj-token',dest:'header',name:'token'},{id:'hj-hubid',dest:'header',name:'hubid'}] },
|
||||
'channel-message': { method:'POST', path:'/channel/message', title:'POST /channel/message — send hub channel msg',fields:[{id:'cm-token',dest:'header',name:'token'},{id:'cm-hubid',dest:'body',name:'hubid'},{id:'cm-channelid',dest:'body',name:'channelid'},{id:'cm-msgContent',dest:'body',name:'msgContent'},{id:'cm-attachedFile',dest:'body',name:'attachedFile'}] },
|
||||
'mod-user-avatar': { title:'PATCH /user/avatar — set avatar image' },
|
||||
'mod-user-profilebg': { title:'PATCH /user/profilebg — set profile background' },
|
||||
'file-upload': { title:'POST /file — upload file (multipart)' },
|
||||
@@ -403,7 +393,13 @@
|
||||
log('HTTP ' + resp.status, text, resp.ok ? 'log-http' : 'log-err');
|
||||
|
||||
if (method === 'POST' && path === '/token' && resp.ok) {
|
||||
try { currentToken = JSON.parse(text).token; } catch(e) {}
|
||||
try {
|
||||
const parsed = JSON.parse(text);
|
||||
currentToken = parsed.token || '';
|
||||
currentUserId = parsed.userId || '';
|
||||
} catch(e) {}
|
||||
const userEl = document.getElementById('current-user');
|
||||
if (userEl) userEl.textContent = currentUserId ? 'userId: ' + currentUserId : '';
|
||||
autofillTokens();
|
||||
wsConnectAndAuth();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user