Newer
Older
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
<template>
<form class="ui form" @submit.prevent="scan">
<div v-if="errors.length > 0" class="ui negative message">
<div class="header"><translate>Error while fetching remote library</translate></div>
<ul class="list">
<li v-for="error in errors">{{ error }}</li>
</ul>
</div>
<div class="ui field">
<label><translate>Search a remote library</translate></label>
<div :class="['ui', 'action', {loading: isLoading}, 'input']">
<input v-model="query" :placeholder="labels.placeholder" type="url">
<button type="submit" class="ui icon button">
<i class="search icon"></i>
</button>
</div>
</div>
</form>
</template>
<script>
import axios from 'axios'
export default {
data () {
return {
query: '',
isLoading: false,
errors: []
}
},
methods: {
scan () {
if (!this.query) {
return
}
let self = this
axios.post('federation/libraries/scan/', {fid: this.query}).then((response) => {
self.$emit('scanned', response.data)
self.isLoading = false
}, error => {
self.isLoading = false
self.errors = error.backendErrors
})
}
},
computed: {
labels () {
let placeholder = this.$gettext('Enter a library url')
return {
placeholder
}
}
}
}
</script>