﻿<template>
    <div class="card device-component">
        <div class="card-header">
            <h3 class="card-title">
                {{device.displayName}}
                <i v-if="device.isOnline" class="text-success ion ion-ios-wifi"></i>
                <i v-else class="text-danger ion ion-ios-wifi"></i>
            </h3>
        </div>
        <div class="card-body">
            <div class="row device-row">
                <div class="col-4 align-self-center">
                    <img class="device-image" :src="device.ioTProduct.image" />
                </div>
                <div class="col-8 align-self-center">
                    <div class="row">
                        <span :class="cls">
                            {{status}}
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    export default {
        props: ['device'],
        computed: {
            status: function () {
                return getIoTDataValue(this.device, '警报') === '1' ? '警报' : '正常';
            },
            cls: function () {
                var cls = getIoTDataValue(this.device, '警报') === '0' ? 'status text-success' : 'status text-danger';
                return cls;
            }
        }
    };
</script>