index.vue 3.94 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 19 20 21 22 23 24 25 26
  <section class="section" :class="{ 'is-loading' : !hasLoaded }">
    <div class="container" v-if="hasLoaded">
      <div v-if="error" class="message is-danger">
        <div class="message-body">
          <strong>
            <font-awesome-icon class="has-text-danger" icon="exclamation-triangle"/>
            Fetching Flyway reports failed.
          </strong>
          <p v-text="error.message"/>
Johannes Edmeier committed
27
        </div>
28
      </div>
29 30 31
      <template v-for="(context, ctxName) in contexts">
        <h3 class="title" v-text="ctxName" :key="ctxName"/>
        <sba-panel v-for="(report, name) in context.flywayBeans" :key="`${ctxName}-${name}`" :title="name"
32
                   :header-sticks-below="['#navigation', '#instance-tabs']"
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
                   class="migration">
          <table class="table">
            <thead>
              <tr>
                <th>Type</th>
                <th>Checksum</th>
                <th>Version</th>
                <th>Description</th>
                <th>Script</th>
                <th>State</th>
                <th>Installed by</th>
                <th>Installed on</th>
                <th>Installed rank</th>
                <th>Execution Time</th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="migration in report.migrations" :key="migration.checksum">
                <td v-text="migration.type"/>
                <td v-text="migration.checksum"/>
                <td v-text="migration.version"/>
                <td v-text="migration.description"/>
                <td v-text="migration.script"/>
                <td><span v-text="migration.state" class="tag"
                          :class="stateClass(migration.state)"/></td>
                <td v-text="migration.installedBy"/>
                <td v-text="migration.installedOn"/>
                <td v-text="migration.installedRank"/>
                <td v-text="`${migration.executionTime}ms`"/>
              </tr>
            </tbody>
          </table>
        </sba-panel>
      </template>
67 68
    </div>
  </section>
Johannes Edmeier committed
69 70 71
</template>

<script>
72 73
  import Instance from '@/services/instance';

Johannes Edmeier committed
74
  export default {
75 76 77 78 79 80
    props: {
      instance: {
        type: Instance,
        required: true
      }
    },
Johannes Edmeier committed
81
    data: () => ({
82 83
      hasLoaded: false,
      error: null,
84
      contexts: null
Johannes Edmeier committed
85 86 87 88 89 90 91
    }),
    computed: {},
    created() {
      this.fetchFlyway();
    },
    methods: {
      async fetchFlyway() {
92 93 94 95 96 97 98
        this.error = null;
        try {
          const res = await this.instance.fetchFlyway();
          this.contexts = res.data.contexts;
        } catch (error) {
          console.warn('Fetching flyway reports failed:', error);
          this.error = error;
Johannes Edmeier committed
99
        }
100
        this.hasLoaded = true;
Johannes Edmeier committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
      },
      stateClass(state) {
        switch (state) {
          case 'BASELINE' :
          case  'MISSING_SUCCESS' :
          case  'SUCCESS' :
          case  'OUT_OF_ORDER' :
          case  'FUTURE_SUCCESS' :
            return 'is-success';
          case 'PENDING':
          case 'ABOVE_TARGET':
          case 'PREINIT':
          case 'BELOW_BASELINE':
          case 'IGNORED':
            return 'is-warning';
          case 'MISSING_FAILED':
          case 'FAILED':
          case 'FUTURE_FAILED':
            return 'is-danger';
          default:
            return 'is-light';
        }
      }
    }
  }
</script>