Search working

This commit is contained in:
Henrique Dias
2017-07-03 18:07:14 +01:00
parent e0f3687b26
commit da3f043cfd
2 changed files with 52 additions and 35 deletions
+25 -1
View File
@@ -119,10 +119,34 @@ function checksum (url, algo) {
})
}
function command (url, command, onmessage, onclose) {
let protocol = (store.state.ssl ? 'wss:' : 'ws:')
url = removePrefix(url)
url = `${protocol}//${window.location.hostname}${store.state.baseURL}/api/command${url}?token=${store.state.jwt}`
let conn = new window.WebSocket(url)
conn.onopen = () => conn.send(command)
conn.onmessage = onmessage
conn.onclose = onclose
}
function search (url, search, onmessage, onclose) {
let protocol = (store.state.ssl ? 'wss:' : 'ws:')
url = removePrefix(url)
url = `${protocol}//${window.location.hostname}${store.state.baseURL}/api/search${url}?token=${store.state.jwt}`
let conn = new window.WebSocket(url)
conn.onopen = () => conn.send(search)
conn.onmessage = onmessage
conn.onclose = onclose
}
export default {
delete: rm,
fetch,
checksum,
move,
put
put,
command,
search
}