Search working
parent
e0f3687b26
commit
da3f043cfd
|
@ -13,7 +13,7 @@
|
||||||
<div>
|
<div>
|
||||||
<span v-if="search.length === 0 && commands.length === 0">{{ text() }}</span>
|
<span v-if="search.length === 0 && commands.length === 0">{{ text() }}</span>
|
||||||
<ul v-else-if="search.length > 0">
|
<ul v-else-if="search.length > 0">
|
||||||
<li v-for="s in search"><a :href="'./' + s">./{{ s }}</a></li>
|
<li v-for="s in search"><router-link :to="'./' + s">./{{ s }}</router-link></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul v-else-if="commands.length > 0">
|
<ul v-else-if="commands.length > 0">
|
||||||
<li v-for="c in commands">{{ c }}</li>
|
<li v-for="c in commands">{{ c }}</li>
|
||||||
|
@ -27,6 +27,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import url from '@/utils/url'
|
import url from '@/utils/url'
|
||||||
|
import api from '@/utils/api'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'search',
|
name: 'search',
|
||||||
|
@ -89,49 +90,41 @@ export default {
|
||||||
},
|
},
|
||||||
submit: function (event) {
|
submit: function (event) {
|
||||||
this.ongoing = true
|
this.ongoing = true
|
||||||
let uri = window.location.host + window.location.pathname
|
|
||||||
|
|
||||||
|
let path = this.$route.path
|
||||||
if (this.$store.state.req.kind !== 'listing') {
|
if (this.$store.state.req.kind !== 'listing') {
|
||||||
uri = url.removeLastDir(uri) + '/'
|
path = url.removeLastDir(path) + '/'
|
||||||
}
|
}
|
||||||
|
|
||||||
uri = `${(this.$store.state.ssl ? 'wss:' : 'ws:')}//${uri}`
|
|
||||||
|
|
||||||
if (this.supported() && this.user.allowCommands) {
|
if (this.supported() && this.user.allowCommands) {
|
||||||
let conn = new window.WebSocket(`${uri}?command=true`)
|
api.command(path, this.value,
|
||||||
|
(event) => {
|
||||||
conn.onopen = () => conn.send(this.value)
|
this.commands.push(event.data)
|
||||||
|
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||||
conn.onmessage = (event) => {
|
},
|
||||||
this.commands.push(event.data)
|
(event) => {
|
||||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
this.ongoing = false
|
||||||
}
|
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||||
|
this.$store.commit('setReload', true)
|
||||||
conn.onclose = (event) => {
|
}
|
||||||
this.ongoing = false
|
)
|
||||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
|
||||||
this.$store.commit('setReload', true)
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let conn = new window.WebSocket(`${uri}?search=true`)
|
api.search(path, this.value,
|
||||||
|
(event) => {
|
||||||
|
let url = event.data
|
||||||
|
if (url[0] === '/') url = url.substring(1)
|
||||||
|
|
||||||
conn.onopen = () => conn.send(this.value)
|
this.search.push(url)
|
||||||
|
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||||
conn.onmessage = (event) => {
|
},
|
||||||
let url = event.data
|
(event) => {
|
||||||
if (url[0] === '/') url = url.substring(1)
|
this.ongoing = false
|
||||||
|
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||||
this.search.push(url)
|
}
|
||||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
)
|
||||||
}
|
|
||||||
|
|
||||||
conn.onclose = () => {
|
|
||||||
this.ongoing = false
|
|
||||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
export default {
|
||||||
delete: rm,
|
delete: rm,
|
||||||
fetch,
|
fetch,
|
||||||
checksum,
|
checksum,
|
||||||
move,
|
move,
|
||||||
put
|
put,
|
||||||
|
command,
|
||||||
|
search
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue