data-traceback.vue 73.7 KB
Newer Older
G
gaocongli 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
<!--
Copyright 2020 Huawei Technologies Co., Ltd.All Rights Reserved.

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>
P
ph 已提交
17
  <div id="cl-data-traceback">
18 19 20 21 22 23 24 25 26 27
    <div v-if="loading"
         class="no-data-page">
      <div class="no-data-img">
        <img :src="require('@/assets/images/nodata.png')"
             alt="" />
        <p class="no-data-text">{{$t("public.dataLoading")}}</p>
      </div>
    </div>
    <div class="cl-data-right"
         v-if="!loading">
G
gaocongli 已提交
28
      <!-- select area -->
29
      <div class="data-checkbox-area"
30
           v-show="!errorData&&!(!totalSeries.length&&pagination.total)">
P
ph 已提交
31
        <div class="select-container"
P
ph 已提交
32 33
             v-show="totalSeries && totalSeries.length &&
              (!summaryDirList || (summaryDirList && summaryDirList.length))">
P
ph 已提交
34 35
          <div class="display-column">
            {{$t('modelTraceback.displayColumn')}}
G
gaocongli 已提交
36
          </div>
P
ph 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
          <div class="inline-block-set">
            <!-- multiple collapse-tags -->
            <el-select v-model="selectArrayValue"
                       multiple
                       collapse-tags
                       @change="selectValueChange"
                       :placeholder="$t('public.select')"
                       @focus="selectinputFocus">
              <div class="select-input-button">
                <div class="select-inner-input">
                  <el-input v-model="keyWord"
                            v-on:input="myfilter"
                            :placeholder="$t('public.search')">
                  </el-input>
                </div>
P
update  
ph 已提交
52 53 54
                <button type="text"
                        @click="allSelect"
                        class="select-all-button"
P
ph 已提交
55 56 57
                        :class="[selectCheckAll ? 'checked-color' : 'button-text',
                           basearr.length > checkOptions.length ? 'btn-disabled' : '']"
                        :disabled="basearr.length > checkOptions.length">
P
ph 已提交
58
                  {{ $t('public.selectAll')}}
P
update  
ph 已提交
59 60 61 62
                </button>
                <button type="text"
                        @click="deselectAll"
                        class="deselect-all-button"
P
ph 已提交
63 64 65
                        :class="[!selectCheckAll ? 'checked-color' : 'button-text',
                           basearr.length > checkOptions.length ? 'btn-disabled' : '']"
                        :disabled="basearr.length > checkOptions.length">
P
ph 已提交
66
                  {{ $t('public.deselectAll')}}
P
update  
ph 已提交
67
                </button>
P
ph 已提交
68
              </div>
P
ph 已提交
69 70 71 72 73
              <el-option v-for="item in checkOptions"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value"
                         :disabled="item.disabled"
P
ph 已提交
74
                         :title="item.disabled ? $t('modelTraceback.mustExist') : ''">
P
ph 已提交
75 76
              </el-option>
            </el-select>
G
gaocongli 已提交
77
          </div>
P
ph 已提交
78
        </div>
79 80 81 82 83 84 85 86 87 88 89
        <!-- show all data button -->
        <div class="btns">
          <el-button class="reset-btn custom-btn"
                     @click="echartShowAllData"
                     type="primary"
                     size="mini"
                     plain
                     v-show="(summaryDirList && !summaryDirList.length)||(totalSeries && totalSeries.length)">
            {{ $t('modelTraceback.showAllData') }}
          </el-button>
        </div>
G
gaocongli 已提交
90 91
      </div>
      <!-- echart drawing area -->
P
ph 已提交
92 93 94
      <div id="data-echart"
           v-show="showEchartPic && !echartNoData"></div>
      <div class="echart-nodata-container"
P
ph 已提交
95 96
           v-show="!showEchartPic && showTable && !(summaryDirList && !summaryDirList.length)">
      </div>
P
ph 已提交
97 98 99 100 101 102
      <div class="btns-container"
           v-show="!echartNoData && showTable">
        <el-button type="primary"
                   size="mini"
                   class="custom-btn"
                   @click="hiddenRecords"
P
update  
ph 已提交
103 104 105
                   plain>
          {{ $t('modelTraceback.hide')}}
        </el-button>
P
ph 已提交
106 107 108 109 110 111 112 113
        <el-button type="primary"
                   size="mini"
                   class="custom-btn"
                   @click="unhideRecords"
                   plain>
          {{$t('modelTraceback.unhide')}}
        </el-button>
      </div>
G
gaocongli 已提交
114 115
      <!-- table area -->
      <div class="table-container"
P
ph 已提交
116
           v-show="!echartNoData && showTable">
117 118
        <div class="disabled-checked"
             v-show="!table.data.length"></div>
G
gaocongli 已提交
119 120 121
        <el-table ref="table"
                  :data="table.data"
                  tooltip-effect="light"
P
ph 已提交
122
                  height="calc(100% - 40px)"
P
ph 已提交
123 124 125
                  row-key="summary_dir"
                  @selection-change="handleSelectionChange"
                  @sort-change="tableSortChange">
G
gaocongli 已提交
126 127
          <el-table-column type="selection"
                           width="55"
P
ph 已提交
128 129
                           :reserve-selection="true"
                           v-show="!echartNoData && showTable">
G
gaocongli 已提交
130 131 132 133 134
          </el-table-column>
          <el-table-column v-for="key in table.column"
                           :key="key"
                           :prop="key"
                           :label="table.columnOptions[key].label"
P
ph 已提交
135
                           :sortable="sortArray.includes(table.columnOptions[key].label) ? 'custom' : false"
136
                           :fixed="table.columnOptions[key].label === text ? true : false"
P
ph 已提交
137
                           min-width="200"
G
gaocongli 已提交
138
                           show-overflow-tooltip>
P
ph 已提交
139 140 141 142
            <template slot="header"
                      slot-scope="scope">
              <div class="custom-label"
                   :title="scope.column.label">
P
ph 已提交
143
                {{scope.column.label}}
P
ph 已提交
144
              </div>
P
ph 已提交
145
            </template>
G
gaocongli 已提交
146 147
            <template slot-scope="scope">
              <span class="icon-container"
P
ph 已提交
148
                    v-show="table.columnOptions[key].label === text">
G
gaocongli 已提交
149 150 151
                <el-tooltip effect="light"
                            :content="$t('dataTraceback.dataTraceTips')"
                            placement="top"
P
ph 已提交
152
                            v-show="scope.row.children">
G
gaocongli 已提交
153 154 155 156
                  <i class="el-icon-warning"></i>
                </el-tooltip>
              </span>
              <span @click="jumpToTrainDashboard(scope.row[key])"
P
ph 已提交
157 158 159
                    v-if="table.columnOptions[key].label === text"
                    class="href-color">
                {{ scope.row[key] }}
G
gaocongli 已提交
160 161 162 163
              </span>
              <span v-else
                    @click="showDialogData(scope.row[key], scope)"
                    class="click-span">
P
ph 已提交
164
                {{formatNumber(key, scope.row[key]) }}
G
gaocongli 已提交
165 166 167
              </span>
            </template>
          </el-table-column>
P
ph 已提交
168
          <!-- remark column -->
W
溯源  
WeiFeng 已提交
169
          <el-table-column fixed="right"
P
ph 已提交
170
                           width="260">
W
溯源  
WeiFeng 已提交
171 172 173 174 175 176
            <template slot="header">
              <div>
                <div class="label-text">{{$t('public.remark')}}</div>
                <div class="remark-tip">{{$t('modelTraceback.remarkTips')}}</div>
              </div>
            </template>
P
ph 已提交
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
            <template slot-scope="scope">
              <!-- The system determines whether to display the pen icon and
              text box based on the values of editShow -->
              <div class="edit-text-container"
                   v-show="scope.row.editShow">{{ scope.row.remark }}</div>
              <div class="inline-block-set">
                <i class="el-icon-edit"
                   @click="editRemarks(scope.row)"
                   v-show="scope.row.editShow"></i>
                <el-input type="text"
                          v-model="scope.row.remark"
                          v-show="!scope.row.editShow"
                          :placeholder="$t('public.enter')"
                          class="remark-input-style"></el-input>
                <i class="el-icon-check"
                   @click="saveRemarksValue(scope.row)"
                   v-show="!scope.row.editShow"></i>
                <i class="el-icon-close"
                   @click="cancelRemarksValue(scope.row)"
                   v-show="!scope.row.editShow"></i>
                <div class="validation-error"
                     v-show="scope.row.isError">
                  {{ $t('modelTraceback.remarkValidation')}}
                </div>
              </div>
            </template>
          </el-table-column>
          <!-- tag column -->
          <el-table-column label="tag"
                           fixed="right"
                           prop="tag"
                           sortable="custom">
            <template slot-scope="scope">
210
              <div @click="showAllIcon(scope.row, scope, $event)"
P
ph 已提交
211
                   class="tag-icon-container">
212 213
                <img v-if="scope.row.tag"
                     :class="'img' + scope.$index"
214 215
                     :src="require('@/assets/images/icon' + scope.row.tag + '.svg')">
                <img v-else
216 217
                     :class="'img' + scope.$index"
                     :src="require('@/assets/images/icon-down.svg')">
P
ph 已提交
218 219 220
              </div>
            </template>
          </el-table-column>
G
gaocongli 已提交
221
        </el-table>
P
ph 已提交
222
        <div class="pagination-container">
P
ph 已提交
223 224 225 226 227 228
          <el-pagination @current-change="handleCurrentChange"
                         :current-page="pagination.currentPage"
                         :page-size="pagination.pageSize"
                         :layout="pagination.layout"
                         :total="pagination.total">
          </el-pagination>
P
ph 已提交
229 230 231 232 233
          <div class="hide-count"
               v-show="recordsNumber-showNumber">
            {{ $t('modelTraceback.totalHide').replace(`{n}`, (recordsNumber-showNumber))}}
          </div>
          <div class="clear"></div>
P
ph 已提交
234
        </div>
G
gaocongli 已提交
235
      </div>
236
      <div v-show="nodata"
G
gaocongli 已提交
237
           class="no-data-page">
238 239
        <div class="no-data-img"
             :class="{'set-height-class':(summaryDirList && !summaryDirList.length)}">
G
gaocongli 已提交
240 241
          <img :src="require('@/assets/images/nodata.png')"
               alt="" />
P
ph 已提交
242
          <p class="no-data-text"
P
ph 已提交
243
             v-show="!summaryDirList || (summaryDirList && summaryDirList.length) && !lineagedata.serData">
P
ph 已提交
244
            {{ $t('public.noData') }}
G
gaocongli 已提交
245
          </p>
P
ph 已提交
246
          <div v-show="echartNoData && (lineagedata.serData && !!lineagedata.serData.length)">
P
ph 已提交
247
            <p class="no-data-text">{{ $t('dataTraceback.noDataFound') }}</p>
P
ph 已提交
248
          </div>
P
ph 已提交
249
          <div v-show="summaryDirList && !summaryDirList.length">
P
ph 已提交
250
            <p class="no-data-text">{{ $t('dataTraceback.noDataFound') }}</p>
P
ph 已提交
251 252 253 254 255
            <p class="no-data-text">
              {{ $t('dataTraceback.click') }}
              <b> {{ $t('modelTraceback.showAllDataBtn') }}</b>
              {{ $t('dataTraceback.viewAllData') }}
            </p>
P
ph 已提交
256
          </div>
G
gaocongli 已提交
257 258 259
        </div>
      </div>
    </div>
Q
qin_jun_yan 已提交
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
    <div v-if="detailsDialogVisible">
      <el-dialog :title="rowName"
                 :visible.sync="detailsDialogVisible"
                 width="50%"
                 :close-on-click-modal="false"
                 class="details-data-list">
        <div class="details-data-title">{{ detailsDataTitle }}</div>
        <el-table :data="detailsDataList"
                  row-key="id"
                  lazy
                  tooltip-effect="light"
                  :load="loadDataListChildren"
                  :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
          <el-table-column width="50" />
          <el-table-column prop="key"
                           width="180"
                           label="Key">
          </el-table-column>
          <el-table-column prop="value"
                           show-overflow-tooltip
                           label="Value">
            <template slot-scope="scope">
              {{ scope.row.value }}
            </template>
          </el-table-column>
        </el-table>
      </el-dialog>
    </div>
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
    <!-- tag dialog -->
    <div v-show="tagDialogShow"
         id="tag-dialog"
         class="icon-dialog">
      <div>
        <div class="icon-image-container">
          <div class="icon-image"
               v-for="item in imageList"
               :key="item.number"
               :class="[tagScope.row && item.number === tagScope.row.tag ? 'icon-border' : '']"
               @click="iconValueChange(tagScope.row, item.number, $event)">
            <img :src="item.iconAdd">
          </div>
        </div>
        <div class="btn-container-margin">
303 304 305 306 307 308 309 310 311 312 313 314 315
          <div class="tag-button-container">
            <el-button type="primary"
                       size="mini"
                       class="custom-btn"
                       @click="iconChangeSave(tagScope)"
                       plain>
              {{ $t('public.sure')}}
            </el-button>
          </div>
          <div class="tag-button-container">
            <el-button type="primary"
                       size="mini"
                       class="custom-btn"
316
                       @click="clearIcon(tagScope,$event)"
317 318 319 320 321 322 323 324 325 326 327 328 329
                       plain>
              {{ $t('public.clear')}}
            </el-button>
          </div>
          <div class="tag-button-container">
            <el-button type="primary"
                       size="mini"
                       class="custom-btn"
                       @click="cancelChangeIcon(tagScope.row)"
                       plain>
              {{ $t('public.cancel')}}
            </el-button>
          </div>
330 331 332
        </div>
      </div>
    </div>
G
gaocongli 已提交
333 334 335 336 337 338 339 340 341
  </div>
</template>
<script>
import RequestService from '../../services/request-service';
import CommonProperty from '@/common/common-property.js';
import Echarts from 'echarts';
export default {
  data() {
    return {
342 343 344
      tableSortTimer: null,
      showAllTimer: null,
      unhideTimer: null,
345
      loading: true,
346
      errorData: true,
347
      tagDialogShow: false,
348
      nodata: false,
349
      tagScope: {},
P
ph 已提交
350
      iconValue: 0,
P
update  
ph 已提交
351 352
      // icon list of tag
      imageList: [],
P
ph 已提交
353
      selectCheckAll: true,
G
gaocongli 已提交
354
      initOver: false, // Page initialization completed.
P
ph 已提交
355 356
      dataCheckedSummary: [],
      selectedBarList: [],
P
ph 已提交
357 358 359 360 361 362 363 364 365 366 367 368 369 370
      // The selected summarydir list to hide.
      hidenDirChecked: [],
      showTable: false,
      hideRecord: false,
      // Whether to display the echart
      showEchartPic: true,
      checkOptions: [],
      basearr: [],
      sortInfo: {},
      keyWord: '',
      // Number of data records returned by the interface.
      recordsNumber: 0,
      // Number of displayed records.
      showNumber: 0,
371
      delayTime: 500,
P
ph 已提交
372
      selectArrayValue: [],
P
ph 已提交
373 374 375 376 377 378 379 380
      customizedColumnOptions: [],
      // Set the type of customized
      customizedTypeObject: [],
      // Value of the vertical axis query interface brought by model source tracing
      modelObjectArray: [],
      summaryDirList: undefined,
      // Table filter condition
      tableFilter: {},
381
      echartNoData: true,
G
gaocongli 已提交
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
      // Encapsulate the data returned by the background interface.
      lineagedata: {},
      // Create an array of the type and filter the mandatory options from the array.
      createType: {
        StorageDataset: true,
        ImageFolderDataset: true,
        ImageFolderDatasetV2: true,
        MnistDataset: true,
        MindDataset: true,
        GeneratorDataset: true,
        TFRecordDataset: true,
        ManifestDataset: true,
        Cifar10Dataset: true,
        Cifar100Dataset: true,
        Schema: true,
        VOCDataset: true,
      },
      // echart parallel line coordinate system
      parallelEchart: null,
P
update  
ph 已提交
401
      deviceNum: 'device_num',
G
gaocongli 已提交
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
      shuffleTitle: 'Shuffle',
      repeatTitle: 'Repeat',
      categoryType: 'category',
      objectType: 'object',
      type: {
        batch: 'BatchDataset',
        shuffle: 'ShuffleDataset',
        repeat: 'RepeatDataset',
        mapData: 'MapDataset',
      },
      batchNode: 'Batch',
      echart: {
        brushData: [],
        // Data of echart  need to be displayed
        showData: [],
      },
      text: this.$t('modelTraceback.summaryPath'),
      // Selected option
      checkedSeries: [],
      // fixed option
      fixedSeries: [],
      // other option can be selected
      noFixedSeries: [],
      // Array of all options
      totalSeries: [],
      // Page data
      pagination: {
        currentPage: 1,
        pageSize: 8,
        total: 0,
        layout: 'total, prev, pager, next, jumper',
      },
      // Summary path column
P
ph 已提交
435 436 437 438 439 440 441 442 443 444 445
      dirPathList: ['summary_dir'],
      // Options that support sorting
      sortArray: [
        this.$t('modelTraceback.summaryPath'),
        'loss',
        this.$t('modelTraceback.network'),
        this.$t('modelTraceback.optimizer'),
        this.$t('modelTraceback.trainingSampleNum'),
        this.$t('modelTraceback.testSampleNum'),
        this.$t('modelTraceback.learningRate'),
        'epoch',
446
        'batch_size',
P
update  
ph 已提交
447
        this.$t('modelTraceback.deviceNum'),
P
ph 已提交
448 449 450 451 452 453 454 455 456 457 458
        this.$t('modelTraceback.modelSize'),
        this.$t('modelTraceback.lossFunc'),
      ],
      numberTypeIdList: [
        'train_dataset_count',
        'test_dataset_count',
        'epoch',
        'batch_size',
        'model_size',
        'loss',
        'learning_rate',
P
update  
ph 已提交
459
        'device_num',
P
ph 已提交
460
      ],
461 462 463 464 465 466 467 468
      valueType: {
        float: 'float',
        int: 'int',
        string: 'string',
        model_size: 'model_size',
        learning_rate: 'learning_rate',
        dataset_mark: 'dataset_mark',
      },
G
gaocongli 已提交
469 470
      table: {
        columnOptions: {
P
ph 已提交
471
          summary_dir: {
G
gaocongli 已提交
472 473 474
            label: this.$t('modelTraceback.summaryPath'),
            required: true,
          },
P
ph 已提交
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
          dataset_mark: {
            label: this.$t('modelTraceback.dataProcess'),
          },
          model_size: {
            label: this.$t('modelTraceback.modelSize'),
          },
          network: {
            label: this.$t('modelTraceback.network'),
          },
          loss: {
            label: 'loss',
          },
          optimizer: {
            label: this.$t('modelTraceback.optimizer'),
          },
          train_dataset_count: {
            label: this.$t('modelTraceback.trainingSampleNum'),
          },
          test_dataset_count: {
            label: this.$t('modelTraceback.testSampleNum'),
          },
          learning_rate: {
            label: this.$t('modelTraceback.learningRate'),
          },
          epoch: {
            label: 'epoch',
          },
          batch_size: {
503
            label: 'batch_size',
P
ph 已提交
504
          },
P
update  
ph 已提交
505 506 507
          device_num: {
            label: this.$t('modelTraceback.deviceNum'),
          },
P
ph 已提交
508 509 510
          loss_function: {
            label: this.$t('modelTraceback.lossFunc'),
          },
G
gaocongli 已提交
511 512 513 514 515 516 517 518 519 520 521 522
        },
        // All options of the column in the table
        column: [],
        // Data of the table
        data: [],
      },

      tempFormateData: {},
      detailsDialogVisible: false,
      detailsDataTitle: '',
      detailsDataList: [],
      rowName: this.$t('dataTraceback.details'),
P
ph 已提交
523 524 525 526
      replaceStr: {
        metric: 'metric/',
        userDefined: 'user_defined/',
      },
G
gaocongli 已提交
527 528 529 530
    };
  },
  computed: {},
  mounted() {
P
update  
ph 已提交
531
    this.imageList = [];
532
    for (let i = 1; i <= 10; i++) {
P
update  
ph 已提交
533
      const obj = {};
534
      obj.number = i;
P
update  
ph 已提交
535 536 537
      obj.iconAdd = require('@/assets/images/icon' + obj.number + '.svg');
      this.imageList.push(obj);
    }
P
ph 已提交
538
    document.title = `${this.$t('summaryManage.dataTraceback')}-MindInsight`;
P
ph 已提交
539
    document.addEventListener('click', this.blurFloat, true);
G
gaocongli 已提交
540 541 542 543 544
    this.$nextTick(() => {
      this.init();
    });
  },
  methods: {
P
ph 已提交
545 546
    blurFloat(event) {
      const domArr = document.querySelectorAll('.icon-dialog');
547 548
      const path = event.path || (event.composedPath && event.composedPath());
      const isActiveDom = path.some((item) => {
P
ph 已提交
549 550 551
        return item.className === 'icon-dialog';
      });
      if (!isActiveDom) {
552
        this.removeIconBorder();
P
ph 已提交
553 554 555
        domArr.forEach((item) => {
          item.style.display = 'none';
        });
556
        this.tagDialogShow = false;
P
ph 已提交
557 558 559 560 561
      }
    },
    /**
     * Display of the icon dialog box
     * @param {Object} row
562
     * @param {Object} scope
563
     * @param {Object} event
P
ph 已提交
564
     */
565
    showAllIcon(row, scope, event) {
566 567 568 569 570 571 572 573 574
      this.tagScope = scope;
      this.iconValue = row.tag >= 0 ? row.tag : 0;
      if (this.tagDialogShow) {
        this.tagDialogShow = false;
        this.removeIconBorder();
        return;
      }
      this.addIconBorder(row);
      this.tagDialogShow = true;
575 576
      const ev = window.event || event;
      document.getElementById('tag-dialog').style.top = ev.clientY - 130 + 'px';
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597
    },

    /**
     * Add icon border style
     * @param {Object} row
     */
    addIconBorder(row) {
      const iconImage = document.querySelectorAll('.icon-image');
      iconImage.forEach((item, index) => {
        if (index + 1 === row.tag) {
          item.classList.add('icon-border');
        }
      });
    },

    /**
     * Remove  icon border style
     */
    removeIconBorder() {
      const classArr = document.querySelectorAll('.icon-border');
      if (classArr.length) {
P
ph 已提交
598 599 600 601 602 603
        classArr.forEach((item) => {
          item.classList.remove('icon-border');
        });
      }
    },

604 605 606 607 608 609
    /**
     *  icon value change
     * @param {Object} row
     * @param {Number} num
     * @param {Object} event
     */
P
ph 已提交
610
    iconValueChange(row, num, event) {
611 612
      const path = event.path || (event.composedPath && event.composedPath());
      const classWrap = path.find((item) => {
P
ph 已提交
613 614 615 616 617 618
        return item.className === 'icon-dialog';
      });
      const classArr = classWrap.querySelectorAll('.icon-border');
      classArr.forEach((item) => {
        item.classList.remove('icon-border');
      });
619
      const htmDom = path.find((item) => {
P
ph 已提交
620 621 622 623 624 625 626 627
        return item.nodeName === 'DIV';
      });
      htmDom.classList.add('icon-border');
      this.iconValue = num;
    },

    /**
     * Save the modification of the icon
628
     * @param {Object} scope
P
ph 已提交
629
     */
630
    iconChangeSave(scope) {
631
      this.tagDialogShow = false;
632
      if (scope.row.tag === this.iconValue || this.iconValue === 0) {
P
ph 已提交
633 634
        return;
      }
635
      this.tagScope.row.tag = this.iconValue;
636 637 638 639 640
      const imgDom = document.querySelectorAll('.img' + scope.$index);
      imgDom.forEach((item) => {
        item.src = require('@/assets/images/icon' + this.iconValue + '.svg');
      });
      this.$forceUpdate();
P
ph 已提交
641
      const params = {
642
        train_id: scope.row.summary_dir,
P
ph 已提交
643
        body: {
644
          tag: this.tagScope.row.tag,
P
ph 已提交
645 646 647 648 649 650 651
        },
      };
      this.putChangeToLineagesData(params);
    },

    /**
     * clear icon
652
     * @param {Object} scope
653
     * @param {Object} event
P
ph 已提交
654
     */
655 656 657
    clearIcon(scope, event) {
      const path = event.path || (event.composedPath && event.composedPath());
      const classWrap = path.find((item) => {
P
ph 已提交
658 659 660 661 662 663
        return item.className === 'icon-dialog';
      });
      const classArr = classWrap.querySelectorAll('.icon-border');
      classArr.forEach((item) => {
        item.classList.remove('icon-border');
      });
664
      this.tagDialogShow = false;
P
ph 已提交
665
      this.iconValue = 0;
666
      this.tagScope.row.tag = 0;
667 668 669 670
      const imgDom = document.querySelectorAll('.img' + scope.$index);
      imgDom.forEach((item) => {
        item.src = require('@/assets/images/icon-down.svg');
      });
P
ph 已提交
671
      const params = {
672
        train_id: scope.row.summary_dir,
P
ph 已提交
673
        body: {
674
          tag: 0,
P
ph 已提交
675 676 677
        },
      };
      this.putChangeToLineagesData(params);
678
      this.tagDialogShow = false;
P
ph 已提交
679 680 681
    },

    /**
P
update  
ph 已提交
682
     * Cancel Save
P
ph 已提交
683 684 685
     * @param {Object} row
     */
    cancelChangeIcon(row) {
686 687 688
      this.removeIconBorder();
      this.addIconBorder(row);
      this.tagDialogShow = false;
P
ph 已提交
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703
    },

    /**
     * Select all
     */
    allSelect() {
      if (this.selectCheckAll) {
        return;
      }
      this.selectArrayValue = [];
      this.checkOptions.forEach((item) => {
        this.selectArrayValue.push(item.value);
      });

      this.selectCheckAll = !this.selectCheckAll;
704 705 706
      this.$nextTick(() => {
        this.initChart();
      });
P
ph 已提交
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734
      const list = [];
      this.checkOptions.forEach((item) => {
        this.selectArrayValue.forEach((i) => {
          if (i === item.value) {
            list.push(i);
          }
        });
      });

      if (this.selectedBarList) {
        const resultArray = this.hideDataMarkTableData();
        this.table.column = this.dirPathList.concat(resultArray, list);
      } else {
        this.table.column = this.dirPathList.concat(list);
      }
    },

    /**
     * deselect all
     */
    deselectAll() {
      this.selectArrayValue = [];
      this.checkOptions.forEach((item) => {
        if (item.disabled) {
          this.selectArrayValue.push(item.value);
        }
      });
      this.selectCheckAll = false;
735 736 737
      this.$nextTick(() => {
        this.initChart();
      });
P
ph 已提交
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760
      const list = [];
      this.checkOptions.forEach((item) => {
        this.selectArrayValue.forEach((i) => {
          if (i === item.value) {
            list.push(i);
          }
        });
      });
      if (this.selectedBarList) {
        const resultArray = this.hideDataMarkTableData();
        this.table.column = this.dirPathList.concat(resultArray, list);
      } else {
        this.table.column = this.dirPathList.concat(list);
      }
    },

    /**
     * Edit remarks
     * @param {Object} row
     */
    editRemarks(row) {
      row.editShow = false;
      row.isError = false;
W
溯源  
WeiFeng 已提交
761
      this.beforeEditValue = row.remark;
P
ph 已提交
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791
    },

    /**
     * Save remarks
     * @param {Object} row
     */
    saveRemarksValue(row) {
      const tagValidation = new RegExp('^[a-zA-Z0-9\u4e00-\u9fa5_.-]{1,128}$');
      const result = row.remark.length ? tagValidation.test(row.remark) : true;
      if (result) {
        row.isError = false;
        row.editShow = true;
        const params = {
          train_id: row.summary_dir,
          body: {
            remark: row.remark,
          },
        };
        this.putChangeToLineagesData(params);
      } else {
        row.isError = true;
      }
    },

    /**
     * Cancel Save Editing
     * @param {Object} row
     */
    cancelRemarksValue(row) {
      row.editShow = true;
W
溯源  
WeiFeng 已提交
792
      row.remark = this.beforeEditValue;
P
ph 已提交
793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846
      row.isError = false;
    },

    /**
     * After the remark or tag is modified,invoke the interface and save the modification
     * @param {Object} params
     */
    putChangeToLineagesData(params) {
      RequestService.putLineagesData(params)
          .then(
              (res) => {
                if (res) {
                  this.$message.success(this.$t('modelTraceback.changeSuccess'));
                }
              },
              (error) => {},
          )
          .catch(() => {});
    },

    /**
     * Hidden records
     */
    hiddenRecords() {
      this.hideRecord = true;
      if (this.dataCheckedSummary.length) {
        this.dataCheckedSummary.forEach((i) => {
          this.hidenDirChecked.push(i.summary_dir);
        });
      }
      this.$store.commit('setHidenDirChecked', this.hidenDirChecked);
      if (this.hidenDirChecked.length) {
        const tempEchartData = this.echart.brushData.slice();
        this.hidenDirChecked.forEach((dir) => {
          tempEchartData.forEach((item, index) => {
            if (item.summary_dir === dir) {
              tempEchartData.splice(index, 1);
            }
          });
        });
        const tableTemp = this.table.data.slice();
        this.hidenDirChecked.forEach((dir) => {
          tableTemp.forEach((item, index) => {
            if (item.summary_dir === dir) {
              tableTemp.splice(index, 1);
            }
          });
        });
        this.dataCheckedSummary = [];
        this.table.data = tableTemp;
        this.showNumber = tableTemp.length;
        this.echart.showData = tempEchartData;
        this.$refs.table.clearSelection();
        if (this.echart.showData.length > 0) {
847 848 849
          this.$nextTick(() => {
            this.initChart();
          });
P
ph 已提交
850 851 852 853 854 855 856 857 858 859 860
        } else {
          this.showEchartPic = false;
        }
      }
      this.hideRecord = false;
    },

    /**
     * Unhide
     */
    unhideRecords() {
861 862 863
      if (this.unhideTimer) {
        clearTimeout(this.unhideTimer);
        this.unhideTimer = null;
P
ph 已提交
864
      }
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
      this.unhideTimer = setTimeout(() => {
        this.showEchartPic = true;
        this.$refs.table.clearSelection();
        if (this.parallelEchart) {
          this.parallelEchart.clear();
        }
        this.$store.commit('setHidenDirChecked', []);
        if (this.hidenDirChecked.length) {
          this.checkedSummary = [];
          this.hidenDirChecked = [];
        }
        this.checkOptions = [];
        this.selectArrayValue = [];
        this.basearr = [];
        const params = {
          body: {},
        };
        const tempParam = {
          sorted_name: this.sortInfo.sorted_name,
          sorted_type: this.sortInfo.sorted_type,
        };
        this.summaryDirList = this.$store.state.summaryDirList;
        this.tableFilter.summary_dir = {
          in: this.summaryDirList,
        };
        params.body = Object.assign(
            params.body,
            this.chartFilter,
            tempParam,
            this.tableFilter,
        );
        this.queryLineagesData(params);
      }, this.delayTime);
P
ph 已提交
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940
    },
    /**
     * Input search filtering in the select module
     */
    myfilter() {
      const queryString = this.keyWord;
      const restaurants = this.basearr;
      const results = queryString
        ? this.createFilter(queryString, restaurants)
        : restaurants;
      this.checkOptions = results;
    },

    /**
     * Input search filtering in the select module
     * @param {String} queryString
     * @param {Array} restaurants
     * @return {Array}
     */
    createFilter(queryString, restaurants) {
      const list = [];
      restaurants.forEach((item) => {
        const object = {};
        if (
          item &&
          item.label.toLowerCase().indexOf(queryString.toLowerCase()) >= 0
        ) {
          object.label = item.label;
          object.value = item.value;
          object.disabled = item.disabled;
          list.push(object);
        }
      });
      return list;
    },

    selectinputFocus() {
      // the text box is restored to empty
      this.keyWord = '';
      this.checkOptions = this.basearr;
    },

    /**
P
update  
ph 已提交
941
     * Selected data in the table
P
ph 已提交
942 943 944 945 946 947 948 949 950 951 952
     */
    selectValueChange() {
      const templist = [];
      this.basearr.forEach((item) => {
        templist.push(item.label);
      });
      if (templist.length > this.selectArrayValue.length) {
        this.selectCheckAll = false;
      } else {
        this.selectCheckAll = true;
      }
953 954 955
      this.$nextTick(() => {
        this.initChart();
      });
P
ph 已提交
956
      const list = [];
P
ph 已提交
957
      this.basearr.forEach((item) => {
P
ph 已提交
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972
        this.selectArrayValue.forEach((i) => {
          if (i === item.value) {
            list.push(i);
          }
        });
      });

      if (this.selectedBarList) {
        const resultArray = this.hideDataMarkTableData();
        this.table.column = this.dirPathList.concat(resultArray, list);
      } else {
        this.table.column = this.dirPathList.concat(list);
      }
    },

G
gaocongli 已提交
973 974 975 976
    /**
     * init
     */
    init() {
P
ph 已提交
977 978 979 980 981 982
      this.customizedColumnOptions =
        this.$store.state.customizedColumnOptions || [];
      this.table.columnOptions = Object.assign(
          this.table.columnOptions,
          this.customizedColumnOptions,
      );
P
ph 已提交
983
      // Obtain the value of summary_dir from the store,
P
ph 已提交
984 985 986 987
      this.summaryDirList = this.$store.state.summaryDirList;
      this.selectedBarList = this.$store.state.selectedBarList;
      if (this.selectedBarList && this.selectedBarList.length) {
        this.tableFilter = {};
P
ph 已提交
988
      } else {
P
ph 已提交
989
        this.tableFilter.lineage_type = {in: ['dataset']};
P
ph 已提交
990
      }
P
ph 已提交
991
      const params = {};
P
ph 已提交
992
      if (this.summaryDirList) {
P
ph 已提交
993
        this.tableFilter.summary_dir = {in: this.summaryDirList};
P
ph 已提交
994
      } else {
P
ph 已提交
995
        this.tableFilter.summary_dir = undefined;
P
ph 已提交
996
      }
P
ph 已提交
997
      params.body = Object.assign({}, this.tableFilter);
P
ph 已提交
998
      this.queryLineagesData(params);
G
gaocongli 已提交
999 1000 1001 1002 1003 1004 1005
    },

    /*
     * Initialize the echart diagram.
     */
    initChart() {
      const parallelAxis = [];
P
ph 已提交
1006
      const selectedBarList = this.$store.state.selectedBarList;
G
gaocongli 已提交
1007
      const data = [];
P
ph 已提交
1008 1009 1010 1011 1012 1013 1014 1015 1016
      const arrayTemp = [];
      if (selectedBarList && selectedBarList.length) {
        selectedBarList.forEach((item) => {
          const value = this.customizedTypeObject[item];
          const obj = {
            name: this.table.columnOptions[item].label,
            id: item,
            checked: true,
          };
1017 1018 1019 1020
          if (value && value.type === this.valueType.float) {
            obj.type = this.valueType.float;
          } else if (value && value.type === this.valueType.int) {
            obj.type = this.valueType.int;
P
ph 已提交
1021
          }
P
ph 已提交
1022
          arrayTemp.push(obj);
P
ph 已提交
1023 1024
        });
      }
P
ph 已提交
1025
      const list = [];
P
ph 已提交
1026
      this.basearr.forEach((item) => {
P
ph 已提交
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
        this.selectArrayValue.forEach((i) => {
          if (i === item.value) {
            const obj = {};
            obj.id = item.value;
            obj.name = item.label;
            list.push(obj);
          }
        });
      });
      const totalBarArray = arrayTemp.concat(list);
G
gaocongli 已提交
1037
      this.echart.showData.forEach((val, i) => {
P
ph 已提交
1038 1039
        let item = {};
        item = {
G
gaocongli 已提交
1040 1041 1042 1043 1044 1045 1046
          lineStyle: {
            normal: {
              color: CommonProperty.commonColorArr[i % 10],
            },
          },
          value: [],
        };
P
ph 已提交
1047
        totalBarArray.forEach((obj) => {
G
gaocongli 已提交
1048 1049 1050 1051 1052
          item.value.push(val[obj.id]);
        });
        data.push(item);
      });

P
ph 已提交
1053
      totalBarArray.forEach((content, i) => {
G
gaocongli 已提交
1054 1055 1056
        const obj = {dim: i, name: content.name, id: content.id};
        if (
          content.name === this.repeatTitle ||
P
update  
ph 已提交
1057
          content.name === this.shuffleTitle ||
P
ph 已提交
1058
          content.id === this.deviceNum ||
1059
          (content.type && content.type === this.valueType.int)
G
gaocongli 已提交
1060 1061
        ) {
          obj.scale = true;
P
ph 已提交
1062
          obj.minInterval = 1;
P
ph 已提交
1063 1064
          this.setColorOfSelectedBar(selectedBarList, obj);
        } else if (
P
ph 已提交
1065
          this.numberTypeIdList.includes(content.id) ||
1066
          (content.type && content.type === this.valueType.float)
P
ph 已提交
1067
        ) {
P
ph 已提交
1068
          obj.scale = true;
P
ph 已提交
1069
          this.setColorOfSelectedBar(selectedBarList, obj);
G
gaocongli 已提交
1070
        } else {
P
ph 已提交
1071
          // String type
G
gaocongli 已提交
1072 1073 1074 1075
          obj.type = this.categoryType;
          obj.axisLabel = {
            show: false,
          };
P
ph 已提交
1076
          this.setColorOfSelectedBar(selectedBarList, obj);
1077
          if (content.id === this.valueType.dataset_mark) {
P
ph 已提交
1078
            obj.axisLabel = {
P
ph 已提交
1079 1080 1081
              show: false,
            };
          }
G
gaocongli 已提交
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100
          const values = {};
          this.echart.showData.forEach((i) => {
            if (i[content.id] || i[content.id] === 0) {
              values[i[content.id]] = '';
            }
          });
          obj.data = Object.keys(values);
        }
        parallelAxis.push(obj);
      });

      const option = {
        backgroundColor: 'white',
        parallelAxis: parallelAxis,
        tooltip: {
          trigger: 'axis',
        },
        parallel: {
          top: 30,
1101
          left: 90,
P
ph 已提交
1102
          right: 100,
G
gaocongli 已提交
1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116
          bottom: 12,
          parallelAxisDefault: {
            areaSelectStyle: {
              width: 40,
            },
            tooltip: {
              show: true,
            },
            realtime: false,
          },
        },
        series: {
          type: 'parallel',
          lineStyle: {
P
ph 已提交
1117 1118
            width: 1,
            opacity: 1,
G
gaocongli 已提交
1119 1120 1121 1122 1123 1124 1125
          },
          data: data,
        },
      };
      if (this.parallelEchart) {
        this.parallelEchart.off('axisareaselected', null);
        window.removeEventListener('resize', this.resizeChart, false);
1126 1127 1128 1129
      } else {
        this.parallelEchart = Echarts.init(
            document.querySelector('#data-echart'),
        );
G
gaocongli 已提交
1130 1131 1132
      }
      this.parallelEchart.setOption(option, true);
      window.addEventListener('resize', this.resizeChart, false);
1133 1134 1135
      this.chartEventsListen(parallelAxis);
    },
    chartEventsListen(parallelAxis) {
G
gaocongli 已提交
1136
      this.parallelEchart.on('axisareaselected', (params) => {
P
ph 已提交
1137 1138
        this.recordsNumber = 0;
        this.showNumber = 0;
G
gaocongli 已提交
1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
        const key = params.parallelAxisId;
        const range = params.intervals[0] || [];
        const [axisData] = parallelAxis.filter((i) => {
          return i.id === key;
        });
        if (axisData && range.length === 2) {
          if (axisData.type === this.categoryType) {
            const selectedAxisKeys = axisData.data.slice(
                range[0],
                range[1] + 1,
            );
            this.echart.brushData = this.echart.showData.filter((i) => {
              return selectedAxisKeys.includes(i[key]);
            });
          } else {
            this.echart.brushData = this.echart.showData.filter((i) => {
              return i[key] >= range[0] && i[key] <= range[1];
            });
          }
P
ph 已提交
1158
          const tempList = this.echart.brushData;
P
ph 已提交
1159 1160
          const summaryList = [];
          tempList.forEach((item) => {
P
ph 已提交
1161 1162 1163
            summaryList.push(item.summary_dir);
          });
          // The summaryList value could not be saved in the destroy state.
P
ph 已提交
1164
          this.dataCheckedSummary = [];
P
ph 已提交
1165
          this.$store.commit('setSummaryDirList', summaryList);
P
ph 已提交
1166
          this.tableFilter.summary_dir = {in: summaryList};
P
ph 已提交
1167
          if (!tempList.length) {
P
ph 已提交
1168 1169
            this.summaryDirList = [];
            this.lineagedata.serData = undefined;
P
ph 已提交
1170
            this.showTable = false;
1171
            this.nodata = true;
P
ph 已提交
1172
            this.echartNoData = true;
P
ph 已提交
1173 1174
          } else {
            this.echart.showData = this.echart.brushData;
1175 1176 1177
            this.$nextTick(() => {
              this.initChart();
            });
P
ph 已提交
1178 1179 1180 1181 1182 1183
            this.pagination.currentPage = 1;
            this.pagination.total = this.echart.brushData.length;
            this.table.data = this.echart.brushData.slice(
                (this.pagination.currentPage - 1) * this.pagination.pageSize,
                this.pagination.currentPage * this.pagination.pageSize,
            );
1184 1185 1186
            const tableLength = this.table.data.length;
            this.recordsNumber = tableLength;
            this.showNumber = tableLength;
P
ph 已提交
1187
            this.showTable = true;
P
ph 已提交
1188
          }
G
gaocongli 已提交
1189 1190 1191
        }
      });
    },
P
ph 已提交
1192 1193
    /**
     * Set the color of the model tracing axis.
P
ph 已提交
1194 1195
     * @param {Array} selectedBarList
     * @param {Object} obj
P
ph 已提交
1196 1197
     */
    setColorOfSelectedBar(selectedBarList, obj) {
P
ph 已提交
1198 1199
      if (selectedBarList && obj.dim < selectedBarList.length) {
        obj.nameTextStyle = {
P
ph 已提交
1200 1201
          color: '#00a5a7',
        };
P
ph 已提交
1202
        obj.axisLabel = {
P
ph 已提交
1203 1204 1205 1206
          show: true,
          textStyle: {
            color: '#00a5a7',
          },
P
ph 已提交
1207
          formatter: function(val) {
1208
            if (typeof val !== 'string') {
P
ph 已提交
1209 1210 1211 1212
              return val;
            }
            const strs = val.split('');
            let str = '';
1213 1214 1215 1216
            const maxStringLength = 100;
            const showStringLength = 12;
            if (val.length > maxStringLength) {
              return val.substring(0, showStringLength) + '...';
P
ph 已提交
1217 1218 1219
            } else {
              for (let i = 0, s = ''; (s = strs[i++]); ) {
                str += s;
1220
                if (!(i % showStringLength)) {
P
ph 已提交
1221 1222 1223 1224 1225 1226
                  str += '\n';
                }
              }
              return str;
            }
          },
P
ph 已提交
1227
        };
P
ph 已提交
1228
        obj.axisLine = {
P
ph 已提交
1229 1230 1231 1232 1233 1234 1235
          show: true,
          lineStyle: {
            color: '#00a5a7',
          },
        };
      } else {
        // Text color
P
ph 已提交
1236
        obj.nameTextStyle = {
P
ph 已提交
1237 1238 1239 1240
          color: 'black',
        };
      }
    },
G
gaocongli 已提交
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254

    /**
     * jump to train dashboard
     * @param {String} val
     */
    jumpToTrainDashboard(val) {
      const trainId = encodeURIComponent(val);
      const routeUrl = this.$router.resolve({
        path: '/train-manage/training-dashboard',
        query: {id: trainId},
      });
      window.open(routeUrl.href, '_blank');
    },

P
ph 已提交
1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
    /**
     * Formatting Data
     * @param {String} key
     * @param {String} value
     * @return {Object}
     */
    formatNumber(key, value) {
      if (isNaN(value) || !value) {
        return value;
      } else {
1265 1266 1267
        const numDigits = 4;
        if (key === this.valueType.learning_rate) {
          let temp = value.toPrecision(numDigits);
P
ph 已提交
1268 1269 1270 1271 1272
          let row = 0;
          while (temp < 1) {
            temp = temp * 10;
            row += 1;
          }
1273
          temp = this.toFixedFun(temp, numDigits);
P
ph 已提交
1274
          return `${temp}${row ? `e-${row}` : ''}`;
1275
        } else if (key === this.valueType.model_size) {
P
ph 已提交
1276 1277
          return value + 'MB';
        } else {
1278 1279 1280 1281 1282 1283
          const num = 1000;
          if (value < num) {
            return (
              Math.round(value * Math.pow(10, numDigits)) /
              Math.pow(10, numDigits)
            );
P
ph 已提交
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304
          } else {
            const reg = /(?=(\B)(\d{3})+$)/g;
            return (value + '').replace(reg, ',');
          }
        }
      }
    },

    /**
     * Keep the number with n decimal places.
     * @param {Number} num
     * @param {Number} pow Number of decimal places
     * @return {Number}
     */
    toFixedFun(num, pow) {
      if (isNaN(num) || isNaN(pow) || !num || !pow) {
        return num;
      }
      return Math.round(num * Math.pow(10, pow)) / Math.pow(10, pow);
    },

G
gaocongli 已提交
1305 1306 1307 1308 1309 1310
    /**
     * The detailed information is displayed in the dialog box.
     * @param {String} val
     * @param {Object} scope
     */
    showDialogData(val, scope) {
1311 1312
      const emptyObjectStr = '{}';
      if (typeof val !== this.valueType.string || val === emptyObjectStr) {
P
ph 已提交
1313 1314
        return;
      } else {
P
ph 已提交
1315
        const isJson = this.isJSON(val);
P
ph 已提交
1316 1317 1318 1319
        if (!isJson) {
          return;
        }
      }
P
ph 已提交
1320
      this.rowName = `${scope.column.label}${this.$t('dataTraceback.details')}`;
G
gaocongli 已提交
1321
      this.detailsDialogVisible = true;
P
ph 已提交
1322
      this.detailsDataTitle = scope.row.summary_dir;
G
gaocongli 已提交
1323 1324 1325
      this.detailsDataList = this.formateJsonString(val);
    },

P
ph 已提交
1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339
    /**
     * Checks whether the value is a JSON character string.
     *  @param {String} val
     * @return {Boolean}
     */
    isJSON(val) {
      try {
        JSON.parse(val);
        return true;
      } catch (e) {
        return false;
      }
    },

G
gaocongli 已提交
1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353
    /**
     * set object value
     * @param {Array} array
     * @param {boolean} booleanValue
     */
    setObjectValue(array, booleanValue) {
      array.forEach((val) => {
        const obj = {};
        obj.label = val.name;
        obj.required = booleanValue;
        this.table.columnOptions[val.id] = obj;
      });
    },

1354 1355 1356 1357 1358 1359 1360 1361 1362
    /**
     * get data of table
     * @param {Object} params
     */
    queryTableLineagesData(params) {
      RequestService.queryLineagesData(params)
          .then(
              (res) => {
                if (!res || !res.data) {
1363
                  this.nodata = true;
1364 1365
                  return;
                }
1366
                this.nodata = false;
1367
                this.errorData = false;
1368 1369
                this.lineagedata = this.formateOriginData(res.data);
                const serData = this.lineagedata.serData;
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434
                if (this.selectedBarList && this.selectedBarList.length) {
                  const tempList = JSON.parse(JSON.stringify(res.data.object));
                  const list = [];
                  const metricKeys = {};
                  tempList.forEach((item) => {
                    if (item.model_lineage) {
                      const modelData = JSON.parse(
                          JSON.stringify(item.model_lineage),
                      );
                      modelData.model_size = parseFloat(
                          ((modelData.model_size || 0) / 1024 / 1024).toFixed(2),
                      );
                      const keys = Object.keys(modelData.metric || {});
                      if (keys.length) {
                        keys.forEach((key) => {
                          if (
                            modelData.metric[key] ||
                        modelData.metric[key] === 0
                          ) {
                            const temp = this.replaceStr.metric + key;
                            metricKeys[temp] = key;
                            modelData[temp] = modelData.metric[key];
                          }
                        });
                        delete modelData.metric;
                      }
                      const udkeys = Object.keys(modelData.user_defined || {});
                      if (udkeys.length) {
                        udkeys.forEach((key) => {
                          if (
                            modelData.user_defined[key] ||
                        modelData.user_defined[key] === 0
                          ) {
                            const temp = this.replaceStr.userDefined + key;
                            modelData[temp] = modelData.user_defined[key];
                          }
                        });
                        delete modelData.user_defined;
                      }
                      list.push(modelData);
                    }
                  });
                  this.modelObjectArray = [];
                  for (let i = 0; i < list.length; i++) {
                    const modelObject = {};
                    for (let j = 0; j < this.selectedBarList.length; j++) {
                      const tempObject = list[i];
                      const key = this.selectedBarList[j];
                      modelObject[key] = tempObject[key];
                    }
                    this.modelObjectArray.push(modelObject);
                  }
                  if (this.modelObjectArray.length) {
                    const list = JSON.parse(JSON.stringify(serData));
                    for (let i = 0; i < list.length; i++) {
                      const temp = this.modelObjectArray[i];
                      list[i] = Object.assign(list[i], temp);
                    }
                    this.table.data = list;
                  } else {
                    this.table.data = JSON.parse(JSON.stringify(serData));
                  }
                } else {
                  this.table.data = JSON.parse(JSON.stringify(serData));
                }
1435
              },
1436 1437
              (error) => {
                this.errorData = true;
1438
                this.nodata = true;
1439
              },
1440
          )
1441 1442
          .catch(() => {
            this.errorData = true;
1443
            this.nodata = true;
1444
          });
1445 1446
    },

G
gaocongli 已提交
1447 1448
    /**
     * Method of invoking the interface
P
ph 已提交
1449
     * @param {Object} params
G
gaocongli 已提交
1450
     */
P
ph 已提交
1451 1452
    queryLineagesData(params) {
      RequestService.queryLineagesData(params)
G
gaocongli 已提交
1453 1454 1455
          .then(
              (res) => {
                this.initOver = true;
1456 1457
                this.loading = false;
                this.echartNoData = false;
G
gaocongli 已提交
1458
                if (!res || !res.data) {
1459
                  this.nodata = true;
G
gaocongli 已提交
1460 1461
                  return;
                }
1462
                this.nodata = false;
1463
                this.errorData = false;
P
ph 已提交
1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474
                this.customizedTypeObject = res.data.customized;
                let keys = Object.keys(this.customizedTypeObject);
                if (keys.length) {
                  keys = keys.map((i) => {
                    if (i.startsWith(this.replaceStr.userDefined)) {
                      return i.replace(this.replaceStr.userDefined, '[U]');
                    } else if (i.startsWith(this.replaceStr.metric)) {
                      return i.replace(this.replaceStr.metric, '[M]');
                    }
                  });
                  this.sortArray = this.sortArray.concat(keys);
P
ph 已提交
1475 1476
                }
                // Model source tracing filtering parameters
P
ph 已提交
1477 1478
                this.selectedBarList = this.$store.state.selectedBarList;
                if (this.selectedBarList && this.selectedBarList.length) {
P
ph 已提交
1479
                  const tempList = JSON.parse(JSON.stringify(res.data.object));
P
ph 已提交
1480 1481 1482
                  const list = [];
                  const metricKeys = {};
                  tempList.forEach((item) => {
P
ph 已提交
1483
                    if (item.model_lineage) {
P
ph 已提交
1484 1485 1486 1487 1488 1489 1490
                      const modelData = JSON.parse(
                          JSON.stringify(item.model_lineage),
                      );
                      modelData.model_size = parseFloat(
                          ((modelData.model_size || 0) / 1024 / 1024).toFixed(2),
                      );
                      const keys = Object.keys(modelData.metric || {});
P
ph 已提交
1491
                      if (keys.length) {
P
ph 已提交
1492 1493 1494 1495 1496 1497 1498 1499
                        keys.forEach((key) => {
                          if (
                            modelData.metric[key] ||
                        modelData.metric[key] === 0
                          ) {
                            const temp = this.replaceStr.metric + key;
                            metricKeys[temp] = key;
                            modelData[temp] = modelData.metric[key];
P
ph 已提交
1500 1501
                          }
                        });
P
ph 已提交
1502
                        delete modelData.metric;
P
ph 已提交
1503
                      }
P
ph 已提交
1504
                      const udkeys = Object.keys(modelData.user_defined || {});
P
ph 已提交
1505
                      if (udkeys.length) {
P
ph 已提交
1506 1507 1508 1509 1510 1511 1512
                        udkeys.forEach((key) => {
                          if (
                            modelData.user_defined[key] ||
                        modelData.user_defined[key] === 0
                          ) {
                            const temp = this.replaceStr.userDefined + key;
                            modelData[temp] = modelData.user_defined[key];
P
ph 已提交
1513 1514
                          }
                        });
P
ph 已提交
1515
                        delete modelData.user_defined;
P
ph 已提交
1516
                      }
P
ph 已提交
1517
                      list.push(modelData);
P
ph 已提交
1518 1519
                    }
                  });
P
ph 已提交
1520 1521 1522 1523 1524 1525 1526
                  this.modelObjectArray = [];
                  for (let i = 0; i < list.length; i++) {
                    const modelObject = {};
                    for (let j = 0; j < this.selectedBarList.length; j++) {
                      const tempObject = list[i];
                      const key = this.selectedBarList[j];
                      modelObject[key] = tempObject[key];
P
ph 已提交
1527 1528 1529 1530 1531
                    }
                    this.modelObjectArray.push(modelObject);
                  }
                }

G
gaocongli 已提交
1532 1533 1534 1535 1536
                this.fixedSeries = [];
                this.noFixedSeries = [];
                this.checkedSeries = [];
                this.lineagedata = this.formateOriginData(res.data);
                this.totalSeries = this.lineagedata.fullNodeList;
P
ph 已提交
1537
                if (!this.totalSeries.length) {
P
ph 已提交
1538
                  this.echartNoData = true;
1539 1540 1541
                  this.nodata = true;
                } else {
                  this.nodata = false;
P
ph 已提交
1542
                }
G
gaocongli 已提交
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561
                this.totalSeries.forEach((nodeItem) => {
                  if (this.createType[nodeItem.name]) {
                    nodeItem.checked = true;
                    this.fixedSeries.push(nodeItem);
                  } else {
                    nodeItem.checked = false;
                    this.noFixedSeries.push(nodeItem);
                  }
                });
                this.noFixedSeries.forEach((item) => {
                  item.checked = true;
                });
                this.getCheckedSerList();
                if (this.fixedSeries.length) {
                  this.setObjectValue(this.fixedSeries, true);
                }
                if (this.noFixedSeries.length) {
                  this.setObjectValue(this.noFixedSeries, false);
                }
P
ph 已提交
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578
                const list1 = this.fixedSeries.concat(this.noFixedSeries);
                list1.forEach((item, index) => {
                  this.checkOptions[index] = {};
                  this.basearr[index] = {};
                  this.checkOptions[index].label = item.name;
                  this.checkOptions[index].value = item.id;
                  if (this.createType[item.name]) {
                    this.checkOptions[index].disabled = true;
                    this.basearr[index].disabled = true;
                  }
                  this.basearr[index].label = item.name;
                  this.basearr[index].value = item.id;
                });
                this.checkOptions.forEach((item) => {
                  this.selectArrayValue.push(item.value);
                });
                this.hidenDirChecked = this.$store.state.hidenDirChecked || [];
G
gaocongli 已提交
1579
                this.echart.brushData = this.lineagedata.serData;
P
ph 已提交
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597
                if (this.hidenDirChecked.length) {
                  const listdada = this.lineagedata.serData.slice();
                  this.hidenDirChecked.forEach((item) => {
                    listdada.forEach((i, index) => {
                      if (i.summary_dir === item) {
                        listdada.splice(index, 1);
                      }
                    });
                  });
                  if (listdada.length) {
                    this.showEchartPic = true;
                  } else {
                    this.showEchartPic = false;
                  }
                  this.echart.showData = listdada;
                } else {
                  this.echart.showData = this.echart.brushData;
                  this.showEchartPic = true;
G
gaocongli 已提交
1598
                }
1599
                this.resizeChart();
P
ph 已提交
1600
                this.setEchartValue();
1601 1602 1603
                this.$nextTick(() => {
                  this.initChart();
                });
G
gaocongli 已提交
1604
                // Total number of pages in the table
P
ph 已提交
1605
                this.pagination.total = res.data.count;
G
gaocongli 已提交
1606
                // Data encapsulation of the table
P
ph 已提交
1607 1608 1609 1610
                let data = [];
                data = this.setTableData();
                this.table.data = data;
                this.showTable = true;
P
ph 已提交
1611
                if (this.selectedBarList) {
P
ph 已提交
1612 1613
                  const resultArray = this.hideDataMarkTableData();
                  this.table.column = this.dirPathList.concat(
P
ph 已提交
1614
                      resultArray,
P
ph 已提交
1615
                      this.checkedSeries.map((i) => i.id),
P
ph 已提交
1616 1617 1618 1619 1620 1621
                  );
                } else {
                  this.table.column = this.dirPathList.concat(
                      this.checkedSeries.map((i) => i.id),
                  );
                }
G
gaocongli 已提交
1622 1623
              },
              (error) => {
1624
                this.loading = false;
G
gaocongli 已提交
1625
                this.initOver = true;
P
ph 已提交
1626
                this.showEchartPic = false;
1627
                this.errorData = true;
1628
                this.nodata = true;
G
gaocongli 已提交
1629 1630 1631
              },
          )
          .catch(() => {
1632
            this.loading = false;
G
gaocongli 已提交
1633
            this.initOver = true;
P
ph 已提交
1634
            this.showEchartPic = false;
1635
            this.errorData = true;
1636
            this.nodata = true;
G
gaocongli 已提交
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655
          });
    },

    /**
     *  Gets the selected items and updates the select all state.
     */
    getCheckedSerList() {
      this.checkedSeries = [];
      this.totalSeries.forEach((nodeItem) => {
        if (nodeItem.checked) {
          this.checkedSeries.push(nodeItem);
        }
      });
    },

    /**
     *  The window size changes. Resizing Chart
     */
    resizeChart() {
1656 1657 1658 1659 1660 1661 1662
      if (
        document.getElementById('data-echart') &&
        document.getElementById('data-echart').style.display !== 'none' &&
        this.parallelEchart
      ) {
        this.parallelEchart.resize();
      }
G
gaocongli 已提交
1663 1664 1665 1666 1667 1668 1669
    },

    /**
     * reset echart data.Show all data
     */
    echartShowAllData() {
      // The first page is displayed.
1670
      this.nodata = false;
1671 1672 1673
      if (this.showAllTimer) {
        clearTimeout(this.showAllTimer);
        this.showAllTimer = null;
P
ph 已提交
1674
      }
1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692
      this.showAllTimer = setTimeout(() => {
        this.initOver = false;
        this.echartNoData = false;
        this.showEchartPic = true;
        this.selectCheckAll = true;
        // checkOptions initializate to an empty array
        this.checkOptions = [];
        this.selectArrayValue = [];
        this.basearr = [];
        this.pagination.currentPage = 1;
        this.$store.commit('setSummaryDirList', undefined);
        this.$store.commit('setSelectedBarList', []);
        if (this.parallelEchart) {
          this.parallelEchart.clear();
        }
        this.$refs.table.clearSelection();
        this.init();
      }, this.delayTime);
G
gaocongli 已提交
1693 1694
    },

P
ph 已提交
1695 1696 1697 1698 1699
    /**
     * The table column data is deleted from the data processing result.
     * @return {Array}
     */
    hideDataMarkTableData() {
P
ph 已提交
1700 1701
      const result = [];
      this.selectedBarList.forEach((item) => {
1702
        if (item !== this.valueType.dataset_mark) {
P
ph 已提交
1703 1704 1705 1706 1707 1708
          result.push(item);
        }
      });
      return result;
    },

G
gaocongli 已提交
1709 1710 1711 1712 1713
    /**
     * Selected rows of tables
     * @param {Object} val
     */
    handleSelectionChange(val) {
P
ph 已提交
1714
      // summary_dir cannot be stored here.If it is not selected ,it cannot be stroed correctly.
P
ph 已提交
1715 1716 1717
      if (this.hideRecord) {
        return;
      }
P
ph 已提交
1718
      this.dataCheckedSummary = val;
G
gaocongli 已提交
1719 1720 1721 1722 1723
      if (val.length) {
        this.echart.showData = val;
      } else {
        this.echart.showData = this.echart.brushData;
      }
1724 1725 1726
      this.$nextTick(() => {
        this.initChart();
      });
G
gaocongli 已提交
1727 1728
    },

P
ph 已提交
1729 1730
    setEchartValue() {
      if (this.modelObjectArray.length) {
P
ph 已提交
1731 1732 1733 1734 1735 1736 1737
        const list = this.echart.showData;
        for (let i = 0; i < list.length; i++) {
          const temp = this.modelObjectArray[i];
          this.echart.showData[i] = Object.assign(
              this.echart.showData[i],
              temp,
          );
P
ph 已提交
1738 1739 1740 1741 1742 1743 1744 1745 1746
        }
      }
    },

    /**
     * Sort by path parameter
     * @param {Object} data
     */
    tableSortChange(data) {
1747 1748 1749
      if (this.tableSortTimer) {
        clearTimeout(this.tableSortTimer);
        this.tableSortTimer = null;
1750
      }
1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771
      this.tableSortTimer = setTimeout(() => {
        this.sortInfo.sorted_name = data.prop;
        this.sortInfo.sorted_type = data.order;
        const params = {};
        const tempParam = {
          sorted_name: data.prop,
          sorted_type: data.order,
        };
        this.checkOptions = [];
        this.selectArrayValue = [];
        this.basearr = [];
        this.pagination.currentPage = 1;
        this.summaryDirList = this.$store.state.summaryDirList;
        if (this.summaryDirList) {
          this.tableFilter.summary_dir = {in: this.summaryDirList};
        } else {
          this.tableFilter.summary_dir = undefined;
        }
        params.body = Object.assign({}, tempParam, this.tableFilter);
        this.queryLineagesData(params);
      }, this.delayTime);
P
ph 已提交
1772 1773
    },

G
gaocongli 已提交
1774 1775 1776 1777 1778 1779
    /**
     * Setting Table Data
     * @param {Number} val
     */
    handleCurrentChange(val) {
      this.pagination.currentPage = val;
1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801
      const data = this.setTableData();
      const summaryDirList = [];
      data.forEach((item) => {
        summaryDirList.push(item.summary_dir);
      });
      const params = {
        body: {},
      };
      const tempParam = {
        sorted_name: this.sortInfo.sorted_name,
        sorted_type: this.sortInfo.sorted_type,
      };
      this.tableFilter.summary_dir = {
        in: summaryDirList,
      };
      params.body = Object.assign(
          params.body,
          this.chartFilter,
          tempParam,
          this.tableFilter,
      );
      this.queryTableLineagesData(params);
G
gaocongli 已提交
1802 1803 1804 1805
    },

    /**
     * Setting Table Data
P
ph 已提交
1806
     * @return {Array}
G
gaocongli 已提交
1807 1808
     */
    setTableData() {
P
ph 已提交
1809
      let data = [];
G
gaocongli 已提交
1810 1811 1812
      // Table data encapsulation
      const pathData = JSON.parse(JSON.stringify(this.echart.brushData));
      // Obtain table data based on the page number and number of records.
P
ph 已提交
1813
      data = pathData.slice(
G
gaocongli 已提交
1814 1815 1816
          (this.pagination.currentPage - 1) * this.pagination.pageSize,
          this.pagination.currentPage * this.pagination.pageSize,
      );
P
ph 已提交
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828
      this.recordsNumber = data.length;
      if (this.hidenDirChecked.length) {
        this.hidenDirChecked.forEach((dir) => {
          data.forEach((item, index) => {
            if (item.summary_dir === dir) {
              data.splice(index, 1);
            }
          });
        });
      }
      this.showNumber = data.length;
      return data;
G
gaocongli 已提交
1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846
    },

    /**
     * Chart data encapsulation
     * @param {Object} data
     * @return {Object}
     */
    formateOriginData(data) {
      if (!data || !data.object) {
        return {};
      }
      // Preliminarily filter the required data from the original data and form a unified format.
      const objectDataArr = [];
      data.object.forEach((object) => {
        this.tempFormateData = {
          nodeList: [],
          children: false,
          summary_dir: object.summary_dir,
P
ph 已提交
1847 1848
          remark: object.added_info.remark ? object.added_info.remark : '',
          tag: object.added_info.tag,
G
gaocongli 已提交
1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871
        };
        if (JSON.stringify(object.dataset_graph) !== '{}') {
          this.getSingleRunData(object.dataset_graph);
        }
        objectDataArr.push(JSON.parse(JSON.stringify(this.tempFormateData)));
      });
      // The data in the unified format is combined by category.
      const fullNodeList = [];
      const tempDic = {};
      objectDataArr.forEach((objectData) => {
        if (fullNodeList.length) {
          let startIndex = 0;
          let tempNodeListMap = fullNodeList.map((nodeObj) => nodeObj.name);
          objectData.nodeList.forEach((nodeItem) => {
            const tempIndex = tempNodeListMap.indexOf(
                nodeItem.name,
                startIndex,
            );
            if (tempIndex === -1) {
              if (!tempDic[nodeItem.name]) {
                tempDic[nodeItem.name] = 0;
              }
              tempDic[nodeItem.name]++;
P
ph 已提交
1872 1873 1874 1875 1876 1877 1878
              let tempId = '';
              const createKey = Object.keys(this.createType);
              if (createKey.includes(nodeItem.name)) {
                tempId = nodeItem.name;
              } else {
                tempId = `${nodeItem.name}${tempDic[nodeItem.name]}`;
              }
G
gaocongli 已提交
1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896
              fullNodeList.splice(startIndex, 0, {
                name: nodeItem.name,
                id: tempId,
              });
              nodeItem.id = tempId;
              startIndex++;
              tempNodeListMap = fullNodeList.map((nodeObj) => nodeObj.name);
            } else {
              nodeItem.id = fullNodeList[tempIndex].id;
              startIndex = tempIndex + 1;
            }
          });
        } else {
          objectData.nodeList.forEach((nodeItem) => {
            if (!tempDic[nodeItem.name]) {
              tempDic[nodeItem.name] = 0;
            }
            tempDic[nodeItem.name]++;
P
ph 已提交
1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910
            const createKey = Object.keys(this.createType);
            if (createKey.includes(nodeItem.name)) {
              fullNodeList.push({
                name: nodeItem.name,
                id: nodeItem.name,
              });
              nodeItem.id = nodeItem.name;
            } else {
              fullNodeList.push({
                name: nodeItem.name,
                id: `${nodeItem.name}${tempDic[nodeItem.name]}`,
              });
              nodeItem.id = `${nodeItem.name}${tempDic[nodeItem.name]}`;
            }
G
gaocongli 已提交
1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921
          });
        }
      });
      // Obtain the value of run on each coordinate.
      const serData = [];
      objectDataArr.forEach((objectData) => {
        const curDataObj = {};
        objectData.nodeList.forEach((nodeItem) => {
          curDataObj[nodeItem.id] = nodeItem.value;
        });
        curDataObj.children = objectData.children;
P
ph 已提交
1922
        curDataObj.summary_dir = objectData.summary_dir;
P
ph 已提交
1923 1924 1925 1926 1927 1928 1929 1930

        // set remark value
        curDataObj.remark = objectData.remark;
        // set tag value
        curDataObj.tag = objectData.tag;
        // set remark icon is show
        curDataObj.editShow = true;
        curDataObj.isError = false;
G
gaocongli 已提交
1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007
        serData.push(curDataObj);
      });
      const formateData = {
        fullNodeList: fullNodeList,
        serData: serData,
      };
      return formateData;
    },

    /**
     * Get single run data
     * @param {Object} nodeObj
     */
    getSingleRunData(nodeObj) {
      if (nodeObj.children && nodeObj.children.length) {
        if (nodeObj.children.length > 1) {
          this.tempFormateData.children = true;
        }
        this.getSingleRunData(nodeObj.children[0]);
      }
      let nodeType = nodeObj.op_type;
      let nodeName = '';
      let nodeValue = '';

      if (nodeType === this.type.batch) {
        nodeName = this.batchNode;
        nodeValue = `batch_size:${nodeObj.batch_size},drop_remainder:${nodeObj.drop_remainder}`;
      } else if (nodeType === this.type.shuffle) {
        nodeName = this.shuffleTitle;
        nodeValue = nodeObj.buffer_size;
      } else if (nodeType === this.type.repeat) {
        nodeValue = nodeObj.count;
        nodeName = this.repeatTitle;
      } else if (nodeType === this.type.mapData) {
        const nodeOptions = nodeObj.operations;
        nodeType = nodeOptions.forEach((nodeOption) => {
          nodeName = `Map_${nodeOption.tensor_op_name}`;
          delete nodeOption.tensor_op_module;
          delete nodeOption.tensor_op_name;
          nodeValue = JSON.stringify(nodeOption);
          this.tempFormateData.nodeList.push({
            name: nodeName,
            id: ``,
            value: nodeValue,
          });
        });
      } else {
        nodeValue = JSON.stringify(nodeObj);
        nodeName = nodeType;
      }
      if (nodeObj.op_type !== this.type.mapData) {
        this.tempFormateData.nodeList.push({
          name: nodeName,
          id: ``,
          value: nodeValue,
        });
      }
    },
    /**
     * Converts JSON strings.
     * @param {String} str
     * @return {Array}
     */
    formateJsonString(str) {
      if (!str) {
        return [];
      }
      const resultArr = [];
      const dataObj = JSON.parse(str);
      const keys = Object.keys(dataObj);
      keys.forEach((key, index) => {
        const tempData = {
          id: index + 1,
          hasChildren: false,
          key: key,
          value: '',
        };
2008 2009 2010 2011 2012 2013
        if (dataObj[key] === null) {
          tempData.value = 'None';
        } else if (
          typeof dataObj[key] === this.objectType &&
          dataObj[key] !== null
        ) {
G
gaocongli 已提交
2014 2015 2016 2017 2018 2019
          if (!(dataObj[key] instanceof Array)) {
            tempData.hasChildren = true;
            tempData.children = [];
            Object.keys(dataObj[key]).forEach((k, j) => {
              const item = {};
              item.key = k;
2020 2021 2022 2023 2024
              if (dataObj[key][k] === null) {
                item.value = 'None';
              } else {
                item.value = dataObj[key][k];
              }
P
ph 已提交
2025 2026 2027
              item.id =
                `${new Date().getTime()}` + `${this.$store.state.tableId}`;
              this.$store.commit('increaseTableId');
G
gaocongli 已提交
2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049
              tempData.children.push(item);
            });
          }
          tempData.value = JSON.stringify(dataObj[key]);
        } else {
          tempData.value = dataObj[key];
        }
        resultArr.push(tempData);
      });
      return resultArr;
    },
    loadDataListChildren(tree, treeNode, resolve) {
      setTimeout(() => {
        resolve(tree.children);
      });
    },
  },

  /**
   * Destroy the page
   */
  destroyed() {
2050 2051 2052
    this.tableSortTimer = null;
    this.showAllTimer = null;
    this.unhideTimer = null;
P
ph 已提交
2053 2054 2055
    if (this.dataCheckedSummary && this.dataCheckedSummary.length) {
      const summaryDirList = [];
      this.dataCheckedSummary.forEach((item) => {
P
ph 已提交
2056 2057 2058 2059
        summaryDirList.push(item.summary_dir);
      });
      this.$store.commit('setSummaryDirList', summaryDirList);
    }
G
gaocongli 已提交
2060 2061 2062 2063 2064 2065 2066 2067 2068 2069
    if (this.parallelEchart) {
      window.removeEventListener('resize', this.resizeChart, false);
      this.parallelEchart.clear();
      this.parallelEchart = null;
    }
  },
  components: {},
};
</script>
<style lang="scss">
W
溯源  
WeiFeng 已提交
2070 2071
.label-text {
  line-height: 20px !important;
P
ph 已提交
2072 2073
  padding-top: 20px;
  display: block !important;
W
溯源  
WeiFeng 已提交
2074 2075
}
.remark-tip {
P
ph 已提交
2076
  line-height: 20px !important;
W
溯源  
WeiFeng 已提交
2077 2078 2079
  font-size: 12px;
  white-space: pre-wrap !important;
  color: gray;
P
ph 已提交
2080
  display: block !important;
W
溯源  
WeiFeng 已提交
2081
}
P
ph 已提交
2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107
.el-color-dropdown__main-wrapper,
.el-color-dropdown__value,
.el-color-alpha-slider {
  display: none;
}
.select-inner-input {
  width: calc(100% - 140px);
  margin: 2px 4px;
  display: inline-block;
}
.select-input-button {
  position: relative;
}
.el-select-group__title {
  font-size: 14px;
  font-weight: 700;
}
.el-select-dropdown__item.selected {
  font-weight: 400;
}
.checked-color {
  color: #00a5a7 !important;
}
.el-tag.el-tag--info .el-tag__close {
  display: none;
}
P
update  
ph 已提交
2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130
.select-all-button {
  padding: 4px 0;
  display: inline-block;
  position: absolute;
  right: 80px;
  padding: 5px;
  height: 32px;
  border: none;
  background: none;
}
.deselect-all-button {
  padding: 4px 0;
  display: inline-block;
  position: absolute;
  right: 10px;
  padding: 5px;
  height: 32px;
  border: none;
  background: none;
}
.btn-disabled {
  cursor: not-allowed !important;
}
G
gaocongli 已提交
2131
#cl-data-traceback {
2132
  display: flex;
G
gaocongli 已提交
2133 2134 2135
  height: 100%;
  overflow-y: auto;
  position: relative;
2136
  background: #fff;
2137 2138 2139 2140
  .el-select > .el-input {
    width: 280px !important;
    max-width: 500px !important;
  }
P
ph 已提交
2141 2142 2143 2144 2145 2146 2147
  .el-table th.is-leaf {
    background: #f5f7fa;
  }
  .el-table td,
  .el-table th.is-leaf {
    border: 1px solid #ebeef5;
  }
P
ph 已提交
2148 2149 2150 2151 2152 2153
  .inline-block-set {
    display: inline-block;
  }
  .icon-border {
    border: 1px solid #00a5a7 !important;
  }
2154
  .btn-container-margin {
2155 2156 2157 2158 2159 2160
    margin: 0 10%;
  }
  .tag-button-container {
    display: inline-block;
    width: 33.3%;
    text-align: center;
2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172
  }
  .custom-btn {
    border: 1px solid #00a5a7;
    border-radius: 2px;
    background-color: white;
    color: #00a5a7;
  }
  .custom-btn:hover {
    color: #00a5a7;
    background: #e9f7f7;
  }
  #tag-dialog {
P
ph 已提交
2173 2174 2175 2176 2177 2178
    z-index: 999;
    border: 1px solid #d6c9c9;
    position: fixed;
    width: 326px;
    height: 120px;
    background-color: #efebeb;
2179
    right: 106px;
P
ph 已提交
2180 2181 2182 2183 2184 2185 2186
    border-radius: 4px;
  }
  .icon-image {
    display: inline-block;
    padding: 4px;
    height: 30px;
    width: 30px;
W
溯源  
WeiFeng 已提交
2187
    border: 1px solid transparent;
P
ph 已提交
2188 2189 2190 2191 2192
  }
  .icon-image-container {
    margin: 16px 10px 18px;
  }
  .tag-icon-container {
2193 2194
    width: 21px;
    height: 21px;
P
ph 已提交
2195 2196 2197 2198
    border: 1px solid #e6e6e6;
    cursor: pointer;
    border-radius: 2px;
  }
G
gaocongli 已提交
2199
  .no-data-page {
2200
    display: flex;
G
gaocongli 已提交
2201
    width: 100%;
2202 2203 2204 2205 2206
    flex: 1;
    justify-content: center;
    align-items: center;
    .set-height-class {
      height: 282px !important;
G
gaocongli 已提交
2207
    }
2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222
    .no-data-img {
      background: #fff;
      text-align: center;
      height: 200px;
      width: 310px;
      margin: auto;
      img {
        max-width: 100%;
      }
      p {
        font-size: 16px;
        padding-top: 10px;
      }
    }
    .no-data-text {
P
ph 已提交
2223 2224
      font-size: 16px;
      padding-top: 10px;
P
ph 已提交
2225
    }
G
gaocongli 已提交
2226
  }
P
ph 已提交
2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258
  .edit-text-container {
    display: inline-block;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .btns-container {
    padding: 14px 32px 4px;
  }
  .table-container .el-icon-edit {
    margin-left: 5px;
  }
  .table-container i {
    font-size: 18px;
    margin: 0 2px;
    color: #00a5a7;
    cursor: pointer;
  }
  .table-container .el-icon-close {
    color: #f56c6c;
  }
  .table-container .validation-error {
    color: #ff0000;
  }
  .display-column {
    display: inline-block;
    padding-right: 6px;
  }
  .remark-input-style {
    width: 140px;
  }
G
gaocongli 已提交
2259
  .cl-data-right {
2260 2261 2262 2263
    display: flex;
    flex-direction: column;
    flex: 1;
    background-color: #fff;
G
gaocongli 已提交
2264 2265 2266 2267 2268 2269
    -webkit-box-shadow: 0 1px 0 0 rgba(200, 200, 200, 0.5);
    box-shadow: 0 1px 0 0 rgba(200, 200, 200, 0.5);
    overflow: hidden;

    .data-checkbox-area {
      margin: 24px 32px 12px;
P
ph 已提交
2270
      height: 46px;
2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281
      display: flex;
      justify-content: flex-end;
      .select-container {
        padding-top: 10px;
        height: 46px;
        flex-grow: 1;
      }
      .btns {
        margin-left: 20px;
        padding-top: 12px;
        height: 46px;
G
gaocongli 已提交
2282 2283 2284
      }
    }
    #data-echart {
P
ph 已提交
2285
      height: 32%;
G
gaocongli 已提交
2286
      width: 100%;
P
ph 已提交
2287 2288 2289
      padding: 0 12px;
    }
    .echart-nodata-container {
P
ph 已提交
2290
      height: 32%;
P
ph 已提交
2291 2292
      width: 100%;
    }
G
gaocongli 已提交
2293 2294
    .table-container {
      background-color: white;
P
ph 已提交
2295 2296
      height: calc(68% - 130px);
      padding: 6px 32px;
G
gaocongli 已提交
2297
      position: relative;
2298 2299 2300 2301 2302 2303 2304 2305 2306
      .disabled-checked {
        position: absolute;
        top: 9px;
        left: 0px;
        z-index: 1000;
        width: 87px;
        height: 66px;
        cursor: not-allowed;
      }
P
ph 已提交
2307 2308 2309 2310
      .custom-label {
        max-width: calc(100% - 25px);
        padding: 0;
        vertical-align: middle;
P
ph 已提交
2311
      }
G
gaocongli 已提交
2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325
      .el-icon-warning {
        font-size: 16px;
      }
      .icon-container {
        padding-right: 5px;
        width: 20px;
      }
      .href-color {
        cursor: pointer;
        color: #3399ff;
      }
      .click-span {
        cursor: pointer;
      }
P
ph 已提交
2326 2327 2328
      .clear {
        clear: both;
      }
P
ph 已提交
2329 2330 2331 2332
      .hide-count {
        height: 32px;
        line-height: 32px;
        color: red;
P
ph 已提交
2333 2334
        float: right;
        margin-right: 10px;
P
ph 已提交
2335
      }
G
gaocongli 已提交
2336
      .el-pagination {
P
ph 已提交
2337 2338
        float: right;
        margin-right: 32px;
G
gaocongli 已提交
2339 2340
        bottom: 10px;
      }
P
ph 已提交
2341 2342 2343
      .pagination-container {
        height: 40px;
      }
G
gaocongli 已提交
2344 2345
    }
  }
Q
qin_jun_yan 已提交
2346 2347 2348 2349
  .el-dialog {
    min-width: 500px;
    padding-bottom: 30px;
  }
G
gaocongli 已提交
2350
  .details-data-list {
P
ph 已提交
2351 2352 2353 2354 2355
    .el-table td,
    .el-table th.is-leaf {
      border: none;
      border-top: 1px solid #ebeef5;
    }
G
gaocongli 已提交
2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395
    .el-table {
      th {
        padding: 10px 0;
        border-top: 1px solid #ebeef5;
        .cell {
          border-left: 1px solid #d9d8dd;
          height: 14px;
          line-height: 14px;
        }
      }
      th:first-child {
        .cell {
          border-left: none;
        }
      }
      th:nth-child(2),
      td:nth-child(2) {
        max-width: 30%;
      }
      td {
        padding: 8px 0;
      }
    }
    .el-table__row--level-0 td:first-child:after {
      width: 20px;
      height: 1px;
      background: #ebeef5;
      z-index: 11;
      position: absolute;
      left: 0;
      bottom: -1px;
      content: '';
      display: block;
    }
    .el-table__row--level-1 {
      td {
        padding: 4px 0;
        position: relative;
      }
      td:first-child::before {
P
update  
ph 已提交
2396 2397 2398
        width: 42px;
        background: #f0fdfd;
        border-right: 2px #00a5a7 solid;
G
gaocongli 已提交
2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419
        z-index: 10;
        position: absolute;
        left: 0;
        top: -1px;
        bottom: 0px;
        content: '';
        display: block;
      }
    }

    .el-table__row--level-1:first-child {
      td:first-child::before {
        bottom: 0;
      }
    }
    .el-dialog__title {
      font-weight: bold;
    }
    .el-dialog__body {
      max-height: 500px;
      padding-top: 10px;
Q
qin_jun_yan 已提交
2420
      padding-bottom: 0px;
G
gaocongli 已提交
2421 2422 2423 2424 2425 2426 2427 2428
      overflow: auto;
      .details-data-title {
        margin-bottom: 20px;
      }
    }
  }
}
</style>