var VPLogActivity = (function () {
    let vp_template = `
    <template v-if="data.length>0">
    <div class="element-heading pt-3">
        <h5 class="ps-1">
            <i class="bi bi-journals"></i>
            Log Aktivitas Hari ini
        </h5>
    </div>
    <!-- Chat User List -->
    <ul class="ps-0 chat-user-list">
        <!-- Single Chat User -->
        <li v-for="log in data" class="p-3 chat-unread">
            <!-- Thumbnail -->
            <!-- Random Colour -->
            <div class="chat-user-thumbnail me-3 text-center">
                <i class="bi bi-journal-plus" style="font-size:25px"></i>
                <!-- <span class="active-status"></span> -->
            </div>
            <!-- Info -->
            <div class="chat-user-info">
                <h6 class="text-truncate mb-0">{{log.detail}}</h6>
                <div class="last-chat">
                    <p class="mb-0 text-truncate">{{log.time}}</p>
                </div>
            </div>
        </li>
    </ul>
</template>
    `
    return {
        template: vp_template,
        data() {
            return {
                data: []
            }
        },
        mounted() {
            this.load();
        },
        methods: {
            load() {
                axios({
                    method: 'GET',
                    url: window.location.href + '/utils/logActivity',
                }).then((response) => {
                    
                    if (!isObject(response.data)) return setTimeout(() => this.load(), 5000);
                    this.data = response.data.map(v => {
                        v.time = `${(new Date(v.created_at)).getDate()} ${bulanIndo((new Date(v.created_at)).getMonth())} ${(new Date(v.created_at)).getFullYear()} ${(new Date(v.created_at)).getHours()}:${(new Date(v.created_at)).getMinutes()}`;
                        return v;
                    });
                }, (error) => { });
            }
        }
    }
})();