aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/RedisCacheConfig.vue
blob: 3225ff44dcac22afb56b417d7424779390903309 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
<template>
    <div>
        <label class="col-4">
            <span class="required">
                {{ $gettext('Hostname') }}
            </span>
            <input required type="text" name="hostname" placeholder="localhost" v-model="theHostname">
        </label>
        <label class="col-2">
            <span class="required">
                {{ $gettext('Port') }}
            </span>
            <input required type="text" name="port" placeholder="6379" v-model="thePort">
        </label>
        <label>
            {{ $gettext('Passwort/Token zur Authentifizierung') }}
            <input type="text" name="auth" v-model="theAuth">
        </label>
    </div>
</template>

<script>
export default {
    name: 'RedisCacheConfig',
    emits: ['is-valid'],
    props: {
        hostname: {
            type: String,
            default: 'localhost'
        },
        port: {
            type: Number,
            default: 6379
        },
        auth: {
            type: String,
            default: ''
        }
    },
    data () {
        return {
            theHostname: this.hostname,
            thePort: this.port,
            theAuth: this.auth
        }
    },
    methods: {
        isValid () {
            return this.theHostname.trim().length > 0
                && !isNaN(parseInt(this.thePort, 10));
        }
    },
    watch: {
        theHostname: {
            handler () {
                this.$emit('is-valid', this.isValid());
            },
            immediate: true
        },
        thePort: {
            handler () {
                this.$emit('is-valid', this.isValid());
            },
            immediate: true
        }
    }
}
</script>