<template>
  <div :class="{tile: true, alive: appData.healthcheckStatus === true, dead: appData.healthcheckStatus === false}" @click="click">
    <font-awesome-icon v-if="appData.glyph && !appData.favicon" :icon="appData.glyph" size="2x" />
    <img :src="favicon" v-if="appData.favicon" width="30" height="30"/>
    <div class="label">
      <div class="title">{{appData.appName}}</div>
      <div class="description">{{appData.description}}</div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["appData"],
  computed: {
    favicon() {
      return `${this.$rootUrl()}/api/icon_proxy?url=${encodeURIComponent(this.appData.url)}`;
    }
  },
  methods: {
    click(e) {
      this.$emit("clicked", e, this.appData);
    },
  },
};
</script>
<style scoped>
.tile {
  transition: all 0.5s;
  padding: 16px 25px;
  border-radius: 5px;
  margin: 5px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  background: transparent;
}
.tile:hover {
  transition: all 0.1s;
  background-color: rgba(50,50,50, 0.5);
  box-shadow: rgba(0, 0, 0, 0.5) 0px 20px 30px -10px;
}
.label {
  flex: 1;
  text-align: left;
}
svg, img {
  color: #fff;
  margin-right: 20px;
}

.lightMode svg {
  color: #444;
}

 .tile.alive svg {
   color: #009900;
}
.tile.dead svg {
   color: #900;
}
.title {
  color: #fff;
  font-weight: bold;
  text-transform: uppercase;
  line-height: 1;
}
.description {
  color: #ccc;
  font-size: 0.8em;
  line-height: 1;
  margin-top: 4px;
}


.lightMode .title {
   color: #000;
}
 .lightMode .description {
   color: #444;
}

.lightMode .tile:hover {
  background-color: rgba(200,200,200, 0.5);
}
.tile.dead {
  background: rgba(50,0,0,0.4);
}
</style>
