wu-sheng commented on a change in pull request #488:
URL: 
https://github.com/apache/skywalking-rocketbot-ui/pull/488#discussion_r624513251



##########
File path: src/views/components/common/trace-detail-statistics-table.vue
##########
@@ -0,0 +1,351 @@
+<!-- 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 class="trace-detail-chart-table">
+    <div class="rk-trace-t-loading" v-show="loading">
+      <svg class="icon loading">
+        <use xlink:href="#spinner"></use>
+      </svg>
+    </div>
+    <TraceContainer :tableData="tableData" :type="HeaderType">
+      <div class="trace-tips" v-if="!tableData.length">{{ $t('noData') }}</div>
+    </TraceContainer>
+    <rk-sidebox :width="'50%'" :show.sync="showDetail" :title="$t('spanInfo')">
+      <TraceSpanLogs :currentSpan="currentSpan" />
+    </rk-sidebox>
+  </div>
+</template>
+<style lang="scss">
+  .rk-tooltip-popper.trace-table-tooltip .rk-tooltip-inner {
+    max-width: 600px;
+  }
+  .trace-detail-chart-table {
+    position: relative;
+    min-height: 300px;
+    border-bottom: 1px solid #ccc;
+  }
+</style>
+
+<script lang="js">
+  import copy from '@/utils/copy';
+  import TraceContainer from './trace-statistics-table/trace-container';
+  import _ from 'lodash';
+  import TraceSpanLogs from '../trace/trace-span-logs.vue';
+  /* eslint-disable */
+  /* tslint:disable */
+  export default {
+    components: {
+      TraceContainer,
+      TraceSpanLogs,
+    },
+    props: ['data', 'traceId', 'showBtnDetail', 'HeaderType'],
+    watch: {
+      data(val, oldVal) {
+        if (!this.data.length) {
+          this.tableData = [];
+          return;
+        }
+        this.tableData = this.formatData(this.changeTree());
+        this.loading = false;
+      },
+    },
+    data() {
+      return {
+        tableData: [],
+        diaplay: true,
+        // segmentId: [],
+        showDetail: false,
+        list: [],
+        currentSpan: [],
+        loading: true,
+      };
+    },
+    methods: {
+      copy,
+      // TODO 统计计算
+      compute(data){
+        const traceData = data[0].children;
+        const map = new Map();
+        //数据转化
+        for (let i=0; i<traceData.length;i++) {
+          const element = traceData[i];
+          // console.log(element);
+          if (map.has(element.endpointName)) {
+            let arr =  map.get(element.endpointName);
+            arr[0].children.push(element);
+            map.set(element.endpointName,arr);
+          }else{
+            let arr = [];
+            arr.push(element);
+            map.set(element.endpointName,arr);
+          }
+        };
+        console.log(map);
+        const result = [];
+
+       for(let value of map.values()){
+          let maxTime = 0;
+          let minTime;
+          let sumTime = 0;
+          let val = value[0].children;
+          let count = val.length;
+          let endpointName;
+          //如果只出现一次,取value[0]
+          if(count == 0){
+            val = value[0];
+            count = 1;
+            let a = val.endTime;
+            let b = val.startTime;
+            let ms = a - b;
+            maxTime = ms;
+            minTime = ms;
+            sumTime = ms;
+            endpointName = val.endpointName;
+
+          } else {
+            //循环计算
+            for (let i = 0; i < val.length;i++) {
+              let element = val[i];
+              let a = element.endTime;
+              let b = element.startTime;
+              let ms = a - b;
+              //默认赋值
+              if(i == 0){
+                endpointName = element.endpointName;
+                maxTime = ms;
+                minTime = ms;
+              }else{
+                if (ms > maxTime){
+                  maxTime = ms;
+                }
+                if (ms < minTime) {
+                  minTime = ms;
+                }
+              }
+              sumTime = sumTime + ms;
+
+            };
+          }
+          let avgTime = count == 0 ? 0 :(sumTime / count);
+          let jsonStr = {
+              'maxTime': maxTime,
+              'minTime': minTime,
+              'avgTime': avgTime,
+              'count': count,
+              'endpointName': endpointName
+              };
+          result.push(jsonStr);
+        };
+        console.log("--- this is result---");
+        console.log(result);
+        console.log("------");
+        return result;
+      },
+      // 给增加层级关系

Review comment:
       Chinese comments are not allowed. @Fine0830 We need to be careful about 
this, it seems CI doesn't check this. But the main repo CI will check.




-- 
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.

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


Reply via email to