index.vue 2.35 KB
Newer Older
Johannes Edmeier committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<!--
  - Copyright 2014-2018 the original author or authors.
  -
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
  -->

<template>
18
  <div class="instances">
19
    <sba-instance-header :instance="instance" :application="application" :class="headerClass"/>
20
    <sba-instance-tabs :views="views" :instance="instance" :application="application" :class="headerClass"/>
21 22
    <router-view v-if="instance" :instance="instance"/>
  </div>
Johannes Edmeier committed
23 24 25
</template>

<script>
26 27
  import sbaInstanceHeader from './header';
  import sbaInstanceTabs from './tabs';
Johannes Edmeier committed
28 29 30

  export default {
    components: {sbaInstanceHeader, sbaInstanceTabs},
31 32 33 34
    props: {
      instanceId: {
        type: String,
        required: true
35
      },
36 37 38 39
      views: {
        type: Array,
        default: () => []
      },
40 41 42 43 44
      applications: {
        type: Array,
        default: () => [],
      },
      error: {
Johannes Edmeier committed
45
        type: null,
46
        default: null
47 48
      }
    },
Johannes Edmeier committed
49
    computed: {
50 51 52 53 54 55
      instance() {
        return this.applications.findInstance(this.instanceId);
      },
      application() {
        return this.applications.findApplicationForInstance(this.instanceId);
      },
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
      headerClass() {
        if (!this.instance) {
          return '';
        }
        if (this.instance.statusInfo.status === 'UP') {
          return 'is-primary';
        }
        if (this.instance.statusInfo.status === 'RESTRICTED') {
          return 'is-warning';
        }
        if (this.instance.statusInfo.status === 'DOWN') {
          return 'is-danger';
        }
        if (this.instance.statusInfo.status === 'OUT_OF_SERVICE') {
          return 'is-danger';
        }
        if (this.instance.statusInfo.status === 'OFFLINE') {
          return 'is-light';
        }
        return 'is-light';
Johannes Edmeier committed
76 77 78
      }
    }
  }
79
</script>
80 81 82 83 84 85 86 87

<style lang="scss">
  .instances {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
  }
</style>