aboutsummaryrefslogtreecommitdiff
path: root/kamon-status/src/components/EnvironmentCard.vue
blob: 97e79d28c7461fdd67296537dadbec34b3347df0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
  <div class="row">
    <div class="col-12">
      <card>
        <div class="row py-2 no-gutters">
          <div class="col-auto py-2 px-3">
            <div class="text-uppercase text-label pb-1">Service</div>
            <h6>{{ service }}</h6>
          </div>
          <div class="col-auto py-2 px-3">
            <div class="text-uppercase text-label pb-1">Host</div>
            <h6>{{ host }}</h6>
          </div>
          <div class="col-auto py-2 px-3">
            <div class="text-uppercase text-label pb-1">instance</div>
            <h6>{{instance}}</h6>
          </div>
          <div class="col-12 col-md-3 py-2 px-3">
            <div class="text-uppercase text-label pb-1">tags</div>
            <div class="tag-container" v-if="Object.keys(environmentTags).length > 0">
              <span class="tag" v-for="tag in Object.keys(environmentTags)" :key="tag">
                {{ tag }}=<span class="tag-value">{{ environmentTags[tag] }}</span>
                </span>
            </div>
            <div v-else>
              <h6>None</h6>
            </div>
          </div>
        </div>
      </card>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import {Environment} from '../api/StatusApi'
import Card from './Card.vue'
import {Option, none} from 'ts-option'


@Component({
  components: {
    card: Card
  }
})
export default class EnvironmentCard extends Vue {
  @Prop() private environment: Option<Environment> = none

  get instance(): string {
    return this.environment.map(e => e.instance).getOrElse('Unknown')
  }

  get host(): string {
    return this.environment.map(e => e.host).getOrElse('Unknown')
  }

  get service(): string {
    return this.environment.map(e => e.service).getOrElse('Unknown')
  }

  get environmentTags(): { [key: string]: string } {
    return this.environment.map(e => e.tags).getOrElse({})
  }
}
</script>