<template>
<div class="bg-lightgray m-1 p-2 border rounded container">
    <div class="row no-gutters">
        <div class="h5 col-3 text-left">{{this.data.creddesc}}</div>
        <div class="col-9 text-right">{{this.data.creddate}}</div>
    </div>
    <div class="row">
        <div class="col-lg-8">
            <div>
                <label for="username"><i class="fas fa-fw fa-user"></i></label>
                <input type="text" v-bind:id="'username' + this.data.credid" class="border-0 credential" v-bind:value=this.data.creduser readonly/>
                <button v-bind:id="'btn-username' + this.data.credid" class="btn-clip btn btn-primary rounded-pill py-1" v-bind:data-clipboard-target="'#username' + this.data.credid">
                    <i class="far fa-clone"></i>
                </button>
            </div>
            <div>
                <label for="password"><i class="fas fa-fw fa-key"></i></label>
                <input type="text" v-bind:id="'password' + this.data.credid" class="border-0 credential" v-bind:value=this.data.credpass readonly/>
                <button v-bind:id="'btn-password' + this.data.credid" class="btn-clip btn btn-primary rounded-pill py-1" v-bind:data-clipboard-target="'#password' + this.data.credid">
                    <i class="far fa-clone"></i>
                </button>
            </div>
        </div>
        <div class="btn-group col-lg-3 m-2 my-lg-3 w-25" role="group" aria-label="Edit and Delete">
            <button type="button" class="btn btn-secondary p-lg-1"><i class="fas fa-fw fa-edit"></i></button>
            <button type="button" class="btn btn-danger p-lg-1"><i class="fas fa-fw fa-trash-alt"></i></button>
        </div>
    </div>
</div>
</template>
<script>
export default {
    props: ['credential'],
    data() {
        return {
            data: JSON.parse(this.credential)
        }
    },
    mounted() {
        Echo.channel('credentials')
            .listen('CredentialUpdated', (e) => {
                this.data = JSON.parse(e.data);
            });
    }
}
</script>