master.vue 3.9 KB
Newer Older
K
khadgarmage 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */
L
ligang 已提交
17
<template>
G
gongzijian 已提交
18
  <m-list-construction :title="'Master ' + $t('Manage')">
19
    <template slot="content">
G
gongzijian 已提交
20
      <div class="servers-wrapper" v-show="masterList.length">
B
bao liang 已提交
21
        <div class="row-box" v-for="(item,$index) in masterList" :key="$index">
G
gongzijian 已提交
22 23 24
          <div class="row-title">
            <div class="left">
              <span class="sp">IP: {{item.host}}</span>
25
              <span class="sp">{{$t('Process Pid')}}: {{item.port}}</span>
G
gongzijian 已提交
26
              <span class="sp">{{$t('Zk registration directory')}}: {{item.zkDirectory}}</span>
G
gongzijian 已提交
27
            </div>
G
gongzijian 已提交
28
            <div class="right">
G
gongzijian 已提交
29 30
              <span class="sp">{{$t('Create Time')}}: {{item.createTime | formatDate}}</span>
              <span class="sp">{{$t('Last heartbeat time')}}: {{item.lastHeartbeatTime | formatDate}}</span>
G
gongzijian 已提交
31 32
            </div>
          </div>
G
gongzijian 已提交
33 34 35 36 37 38 39
          <div class="row-cont">
            <div class="col-md-4">
              <m-gauge
                      :value="(item.resInfo.cpuUsage * 100).toFixed(2)"
                      :name="'cpuUsage'"
                      :id="'gauge-cpu-' + item.id">
              </m-gauge>
G
gongzijian 已提交
40
            </div>
G
gongzijian 已提交
41 42 43 44 45 46
            <div class="col-md-4">
              <m-gauge
                      :value="(item.resInfo.memoryUsage * 100).toFixed(2)"
                      :name="'memoryUsage'"
                      :id="'gauge-memory-' + item.id">
              </m-gauge>
G
gongzijian 已提交
47
            </div>
G
gongzijian 已提交
48 49 50
            <div class="col-md-4">
              <div class="text-num-model">
                <div class="value-p">
51
                  <strong :style="{color:color[$index]}">{{item.resInfo.loadAverage > 0? item.resInfo.loadAverage.toFixed(2):0}}</strong>
G
gongzijian 已提交
52 53 54 55
                </div>
                <div class="text-1">
                  loadAverage
                </div>
G
gongzijian 已提交
56 57 58
              </div>
            </div>
          </div>
G
gongzijian 已提交
59 60
        </div>
      </div>
G
gongzijian 已提交
61 62 63
      <div v-if="!masterList.length">
        <m-no-data></m-no-data>
      </div>
G
gongzijian 已提交
64
      <m-spin :is-spin="isLoading"></m-spin>
65 66
    </template>
  </m-list-construction>
L
ligang 已提交
67 68
</template>
<script>
G
gongzijian 已提交
69
  import _ from 'lodash'
L
ligang 已提交
70
  import { mapActions } from 'vuex'
G
gongzijian 已提交
71 72
  import mGauge from './_source/gauge'
  import mList from './_source/zookeeperList'
73
  import mSpin from '@/module/components/spin/spin'
L
ligang 已提交
74
  import mNoData from '@/module/components/noData/noData'
G
gongzijian 已提交
75
  import themeData from '@/module/echarts/themeData.json'
76
  import mListConstruction from '@/module/components/listConstruction/listConstruction'
L
ligang 已提交
77 78 79 80 81 82

  export default {
    name: 'servers-master',
    data () {
      return {
        isLoading: false,
G
gongzijian 已提交
83 84
        masterList: [],
        color: themeData.color
L
ligang 已提交
85 86 87 88
      }
    },
    props: {},
    methods: {
G
gongzijian 已提交
89
      ...mapActions('monitor', ['getMasterData'])
L
ligang 已提交
90 91 92 93 94
    },
    watch: {},
    created () {
    },
    mounted () {
G
gongzijian 已提交
95 96 97 98 99 100 101 102 103 104
      this.isLoading = true
      this.getMasterData().then(res => {
        this.masterList = _.map(res, (v, i) => {
          return _.assign(v, {
            resInfo: JSON.parse(v.resInfo)
          })
        })
        this.isLoading = false
      }).catch(() => {
        this.isLoading = false
G
gongzijian 已提交
105
      })
L
ligang 已提交
106
    },
G
gongzijian 已提交
107
    components: { mList, mListConstruction, mSpin, mNoData, mGauge }
L
ligang 已提交
108 109
  }
</script>
G
gongzijian 已提交
110 111
<style lang="scss" rel="stylesheet/scss">
  @import "./servers";
112
</style>