aboutsummaryrefslogtreecommitdiff
path: root/resources/vue/components/RedisCacheConfig.vue
blob: ae254b9e7eca76e9e58928e64704ea591c7222eb (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
<template>
    <div>
        <label class="col-4">
            <span class="required">
                <translate>Hostname</translate>
            </span>
            <input required type="text" name="hostname" placeholder="localhost" v-model="theHostname">
        </label>
        <label class="col-2">
            <span class="required">
                <translate>Port</translate>
            </span>
            <input required type="text" name="port" placeholder="6379" v-model="thePort">
        </label>
    </div>
</template>

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