Search working
Former-commit-id: 968264159ae078bee3ad9be3d5996b7760d28378 [formerly 7f1c96ac435ca9e8c53568c833acefd88e25c1b8] [formerly 2cfc462e4bea9110429add93121e12479c39d0e6 [formerly da3f043cfd
]]
Former-commit-id: 1074083560c0f7d451011617d39350b754516dfa [formerly 0edd1dc392bb57295d47219da9c1acc7eead4761]
Former-commit-id: a651c40fd4a4892c9dd2f72cbe6653b53809be38
pull/726/head
parent
009916d954
commit
869cd562e7
|
@ -13,7 +13,7 @@
|
|||
<div>
|
||||
<span v-if="search.length === 0 && commands.length === 0">{{ text() }}</span>
|
||||
<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 v-else-if="commands.length > 0">
|
||||
<li v-for="c in commands">{{ c }}</li>
|
||||
|
@ -27,6 +27,7 @@
|
|||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import url from '@/utils/url'
|
||||
import api from '@/utils/api'
|
||||
|
||||
export default {
|
||||
name: 'search',
|
||||
|
@ -89,49 +90,41 @@ export default {
|
|||
},
|
||||
submit: function (event) {
|
||||
this.ongoing = true
|
||||
let uri = window.location.host + window.location.pathname
|
||||
|
||||
let path = this.$route.path
|
||||
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) {
|
||||
let conn = new window.WebSocket(`${uri}?command=true`)
|
||||
|
||||
conn.onopen = () => conn.send(this.value)
|
||||
|
||||
conn.onmessage = (event) => {
|
||||
api.command(path, this.value,
|
||||
(event) => {
|
||||
this.commands.push(event.data)
|
||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||
}
|
||||
|
||||
conn.onclose = (event) => {
|
||||
},
|
||||
(event) => {
|
||||
this.ongoing = false
|
||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||
this.$store.commit('setReload', true)
|
||||
}
|
||||
)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let conn = new window.WebSocket(`${uri}?search=true`)
|
||||
|
||||
conn.onopen = () => conn.send(this.value)
|
||||
|
||||
conn.onmessage = (event) => {
|
||||
api.search(path, this.value,
|
||||
(event) => {
|
||||
let url = event.data
|
||||
if (url[0] === '/') url = url.substring(1)
|
||||
|
||||
this.search.push(url)
|
||||
this.scrollable.scrollTop = this.scrollable.scrollHeight
|
||||
}
|
||||
|
||||
conn.onclose = () => {
|
||||
},
|
||||
(event) => {
|
||||
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 {
|
||||
delete: rm,
|
||||
fetch,
|
||||
checksum,
|
||||
move,
|
||||
put
|
||||
put,
|
||||
command,
|
||||
search
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue