Clivern / Kraven

:white_flower: A SaaS docker management dashboard to manage your docker containers, images, volumes, networks and much more!
Apache License 2.0
7 stars 1 forks source link

Integrate VueJs & Axios to build non blocking UI #21

Closed Clivern closed 6 years ago

Clivern commented 6 years ago
<div id="app" class="card">
    <div class="card-header">
        <h3 class="card-title">Invoices</h3>
    </div>
    <div class="dimmer" v-bind:class="{ active: isDimmerActive }">
        <div class="loader"></div>
        <div class="dimmer-content">
            <div class="table-responsive">
                <table class="table card-table table-vcenter text-nowrap">
                    <thead>
                        <tr>
                            <th class="w-1">No.</th>
                            <th>Invoice Subject</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="item in items">
                            <td><span class="text-muted">${item.no}</span></td>
                            <td>${item.subject}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
kraven_app.load_tabular_data = function(Vue, axios){
    return new Vue({
        delimiters: ['${', '}'],
        el: '#app',
        data () {
            return {
                info: null,
                items: [
                    { no: '12', subject: "Carl" },
                    { no: '13', subject: "Duck" }
                ],
                isDimmerActive: true,
                errored: false
            }
        },
        mounted () {
            axios
                .get('https://api.coindesk.com/v1/bpi/currentprice.json')
                .then(response => {
                    this.info = response
                })
                .catch(error => {
                    console.log(error)
                    this.errored = true
                })
                .finally(() => this.isDimmerActive = false)
        }
    });
}