shwstppr commented on a change in pull request #5588:
URL: https://github.com/apache/cloudstack/pull/5588#discussion_r762840155



##########
File path: ui/src/components/view/Metrics.vue
##########
@@ -0,0 +1,196 @@
+// 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.
+
+<template>
+  <div>
+    <a-row :gutter="12">
+      <a-col :md="24">
+        <a-card class="breadcrumb-card">
+          <a-row>
+            <a-col :span="24" style="padding-left: 12px">
+              <breadcrumb>
+                <a-tooltip placement="bottom" slot="end">
+                  <template slot="title">{{ $t('label.refresh') }}</template>
+                  <a-button
+                    style="margin-top: 4px"
+                    :loading="loading"
+                    shape="round"
+                    size="small"
+                    icon="reload"
+                    @click="fetchDetails()"
+                  >{{ $t('label.refresh') }}</a-button>
+                </a-tooltip>
+              </breadcrumb>
+            </a-col>
+          </a-row>
+        </a-card>
+      </a-col>
+    </a-row>
+    <a-divider/>
+    <a-row>
+      <a-col :md="24" :lg="12" :gutter="12">
+        <a-card>
+          <a-table
+            class="metric-card"
+            :columns="columns"
+            :loading="loading"
+            :data-source="dbMetrics"
+            :pagination="{ pageSize: 15}"
+            size="middle"
+          >
+            <template slot="title">
+              <a>{{ $t('label.desc.db.stats') }}</a>
+            </template>

Review comment:
       Please move this out of `a-table` tag and remove `<a>` for consistency
   
   ```
           <a-card>
             <template slot="title">
               {{ $t('label.desc.db.stats') }}
             </template>
             <a-table
               class="metric-card"
               :columns="columns"
               :loading="loading"
               :data-source="dbMetrics"
               :pagination="{ pageSize: 15}"
               size="middle"
             >
   ```

##########
File path: ui/public/locales/en.json
##########
@@ -760,7 +764,9 @@
 "label.deny": "Deny",
 "label.deployasis":"Read VM settings from OVA",
 "label.deploymentplanner": "Deployment planner",
+"label.desc.db.stats": "DataBase Statistics",

Review comment:
       ```suggestion
   "label.desc.db.stats": "Database Statistics",
   ```

##########
File path: ui/src/components/view/Metrics.vue
##########
@@ -0,0 +1,196 @@
+// 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.
+
+<template>
+  <div>
+    <a-row :gutter="12">
+      <a-col :md="24">
+        <a-card class="breadcrumb-card">
+          <a-row>
+            <a-col :span="24" style="padding-left: 12px">
+              <breadcrumb>
+                <a-tooltip placement="bottom" slot="end">
+                  <template slot="title">{{ $t('label.refresh') }}</template>
+                  <a-button
+                    style="margin-top: 4px"
+                    :loading="loading"
+                    shape="round"
+                    size="small"
+                    icon="reload"
+                    @click="fetchDetails()"
+                  >{{ $t('label.refresh') }}</a-button>
+                </a-tooltip>
+              </breadcrumb>
+            </a-col>
+          </a-row>
+        </a-card>
+      </a-col>
+    </a-row>
+    <a-divider/>
+    <a-row>
+      <a-col :md="24" :lg="12" :gutter="12">
+        <a-card>
+          <a-table
+            class="metric-card"
+            :columns="columns"
+            :loading="loading"
+            :data-source="dbMetrics"
+            :pagination="{ pageSize: 15}"
+            size="middle"
+          >
+            <template slot="title">
+              <a>{{ $t('label.desc.db.stats') }}</a>
+            </template>
+          </a-table>
+        </a-card>
+      </a-col>
+      <a-col :md="24" :lg="12" :gutter="12">
+        <a-card>
+          <a-table
+            class="metric-card"
+            :columns="columns"
+            :data-source="usageMetrics"
+            :pagination="false"
+            size="middle"
+          >
+            <template slot="title">
+              <a>{{ $t('label.desc.usage.stats') }}</a>
+            </template>
+          </a-table>
+        </a-card>
+      </a-col>
+    </a-row>
+  </div>
+</template>
+
+<script>
+import { api } from '@/api'
+import { genericCompare } from '@/utils/sort.js'
+import Breadcrumb from '@/components/widgets/Breadcrumb'
+
+export default {
+  name: 'Metrics',
+  components: {
+    Breadcrumb
+  },
+  props: {
+    loading: {
+      type: Boolean,
+      default: false
+    }
+  },
+  data () {
+    return {
+      dbMetrics: [],
+      usageMetrics: [],
+      columns: [
+        {
+          title: this.$t('label.name'),
+          sorter: true,
+          dataIndex: 'name',
+          width: '30%'
+        },
+        {
+          title: this.$t('label.value'),
+          dataIndex: 'value'
+        }
+      ]
+    }
+  },
+  mounted () {
+    this.fetchDetails()
+  },
+  watch: {
+  },
+  methods: {
+    fetchDbMetrics () {
+      var metrics
+      api('listDbMetrics').then(json => {
+        metrics = this.mapToArray(json.listdbmetricsresponse.dbMetrics)
+        this.dbMetrics = metrics
+      })
+      return metrics
+    },
+    fetchUsageMetrics () {
+      var metrics
+      api('listUsageServerMetrics').then(json => {
+        metrics = 
this.mapToArray(json.listusageservermetricsresponse.usageMetrics)
+        this.usageMetrics = metrics
+      })
+      return metrics
+    },
+    mapToArray (map) {
+      /* eslint-disable no-unused-vars */
+      var array = []
+      for (var key in map) {
+        if (key === 'replicas') {
+          map[key].forEach(function (value, i) {
+            var metric = {}
+            var name = 'replica[' + i + ']'
+            metric.name = name
+            metric.value = value
+            array.push(metric)
+          })
+        } else if (key === 'loadaverages') {
+          map[key].forEach(function (value, i) {
+            var metric = {}
+            metric.name = 'load-average[' + i + ']'
+            metric.value = value
+            array.push(metric)
+          })
+        } else {
+          var metric = {}
+          metric.name = key
+          metric.value = map[key]
+          array.push(metric)
+        }
+      }
+      /* eslint-enable no-unused-vars */
+      return array
+    },
+    fetchDetails () {
+      this.dbMetrics = this.fetchDbMetrics()
+      this.usageMetrics = this.fetchUsageMetrics()
+    },
+    fetchUsageListData () {
+      this.columns = []
+      this.columns.push({
+        dataIndex: 'name',
+        title: this.$t('label.name'),
+        sorter: function (a, b) { return genericCompare(a[this.dataIndex] || 
'', b[this.dataIndex] || '') }

Review comment:
       Sorting didn't work for me in my test

##########
File path: ui/src/components/view/Metrics.vue
##########
@@ -0,0 +1,196 @@
+// 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.
+
+<template>
+  <div>
+    <a-row :gutter="12">
+      <a-col :md="24">
+        <a-card class="breadcrumb-card">
+          <a-row>
+            <a-col :span="24" style="padding-left: 12px">
+              <breadcrumb>
+                <a-tooltip placement="bottom" slot="end">
+                  <template slot="title">{{ $t('label.refresh') }}</template>
+                  <a-button
+                    style="margin-top: 4px"
+                    :loading="loading"
+                    shape="round"
+                    size="small"
+                    icon="reload"
+                    @click="fetchDetails()"
+                  >{{ $t('label.refresh') }}</a-button>
+                </a-tooltip>
+              </breadcrumb>
+            </a-col>
+          </a-row>
+        </a-card>
+      </a-col>
+    </a-row>
+    <a-divider/>
+    <a-row>
+      <a-col :md="24" :lg="12" :gutter="12">
+        <a-card>
+          <a-table
+            class="metric-card"
+            :columns="columns"
+            :loading="loading"
+            :data-source="dbMetrics"
+            :pagination="{ pageSize: 15}"

Review comment:
       Use pagination similar to other pages in UI (with option to select page 
size and left aligned) for consistency




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to