diff --git a/ide/build.js b/ide/build.js
deleted file mode 100644
index 17ea40aa71d11a237975315293478e11c628e01d..0000000000000000000000000000000000000000
--- a/ide/build.js
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Copyright (C) 2022 Huawei Device Co., Ltd.
- * 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.
- */
-
-const path = require('path');
-const fs = require('fs');
-const childProcess = require('child_process');
-const os = require('os');
-const log4js = require('log4js');
-
-const compileServer = true;
-const outDir = 'dist';
-
-const sdkWams = [
- 'trace_streamer_sdk_builtin.js',
- 'trace_streamer_sdk_builtin.wasm',
- 'trace_streamer_dubai_builtin.js',
- 'trace_streamer_dubai_builtin.wasm',
- 'trace_converter_builtin.js',
- 'trace_converter_builtin.wasm',
-];
-
-const necessaryWams = [
- 'trace_streamer_builtin.js',
- 'trace_streamer_builtin.wasm',
- 'trace_converter_builtin.js',
- 'trace_converter_builtin.wasm',
-];
-
-const staticPath = ['/src/img', '/server/cert', '/src/doc', '/src/figures'];
-
-const staticFiles = [
- '/server/version.txt',
- '/src/index.html',
- '/src/base-ui/icon.svg',
- '/server/wasm.json',
- '/server/server-config.txt',
-];
-
-const thirdParty = [
- {
- srcFilePath: '/third-party/sql-wasm.wasm',
- distFilePath: '/trace/database/sql-wasm.wasm',
- },
- {
- srcFilePath: '/third-party/sql-wasm.js',
- distFilePath: '/trace/database/sql-wasm.js',
- },
- {
- srcFilePath: '/third-party/worker.sql-wasm.js',
- distFilePath: '/trace/database/worker.sql-wasm.js',
- },
-];
-
-let log;
-
-function cpFile(from, to) {
- if (fs.existsSync(from)) {
- fs.writeFileSync(to, fs.readFileSync(from));
- log.info('cp file %s to %s', from, to);
- } else {
- log.warn('file %s is not exists', from, to);
- }
-}
-
-function checkEnvironment() {
- let goVersion = childProcess.execSync('go version', {
- encoding: 'utf-8',
- });
- log.info('go is', goVersion);
- let nodeVersion = childProcess.execSync('node -v', {
- encoding: 'utf-8',
- });
- log.info('node version is', nodeVersion);
- let tscVersion = childProcess.execSync('tsc -v', {
- encoding: 'utf-8',
- });
- log.info('tsc version is', tscVersion);
- if (goVersion == '' || nodeVersion == '' || tscVersion == '') {
- return false;
- }
- let traceStreamer = path.normalize(path.join(__dirname, '/bin'));
- if (!checkDirExist(traceStreamer + '/trace_streamer_builtin.js')) {
- log.error(traceStreamer + '/trace_streamer_builtin.js' + ' Must exist');
- return false;
- }
- if (!checkDirExist(traceStreamer + '/trace_streamer_builtin.wasm')) {
- log.error(traceStreamer + '/trace_streamer_builtin.wasm' + ' Must exist');
- return false;
- }
- return true;
-}
-
-function initLog() {
- log4js.configure({
- appenders: {
- out: { type: 'stdout' },
- },
- categories: {
- default: { appenders: ['out'], level: 'debug' },
- },
- });
- return log4js.getLogger('smartPerf');
-}
-
-function main() {
- log = initLog();
- if (!checkEnvironment()) {
- return;
- }
- // clean outDir
- let outPath = path.normalize(path.join(__dirname, '/', outDir));
- if (checkDirExist(outPath)) {
- log.info('delete the last compilation result');
- removeDir(outPath);
- log.info('delete the last compilation success');
- }
- // run tsc compile
- log.info('start compiling typeScript code');
- let rootPath = path.join(__dirname, '/');
- childProcess.execSync('tsc -p ' + rootPath, {
- encoding: 'utf-8',
- });
- log.info('compiling typeScript code success');
- // run cp to mv all staticFile
- staticFiles.forEach((value) => {
- let filePath = path.join(__dirname, value);
- let distFile;
- if (value.startsWith('/src')) {
- distFile = path.join(__dirname, outDir, value.substring(4, value.length + 1));
- } else if (value.startsWith('/server')) {
- distFile = path.join(__dirname, outDir, value.substring(7, value.length + 1));
- }
- cpFile(filePath, distFile);
- });
- staticPath.forEach((value) => {
- let pa = path.join(__dirname, value);
- let distPath;
- if (value.startsWith('/src')) {
- distPath = path.join(__dirname, outDir, value.substring(4, value.length + 1));
- } else if (value.startsWith('/server')) {
- distPath = path.join(__dirname, outDir, value.substring(7, value.length + 1));
- }
- copyDirectory(pa, distPath);
- });
- thirdParty.forEach((value) => {
- let thirdFile = path.join(__dirname, value.srcFilePath);
- let thirdDistFile = path.join(__dirname, outDir, value.distFilePath);
- cpFile(thirdFile, thirdDistFile);
- });
- let traceStreamer = path.normalize(path.join(__dirname, '/bin'));
- if (checkDirExist(traceStreamer)) {
- let dest = path.normalize(path.join(__dirname, outDir, '/bin'));
- copyDirectory(traceStreamer, dest);
- // to mv traceStream Wasm and js
- if (sdkWams.length > 0) {
- sdkWams.forEach((fileName) => {
- cpFile(traceStreamer + '/' + fileName, rootPath + outDir + '/trace/database/' + fileName);
- });
- }
- if (necessaryWams.length > 0) {
- necessaryWams.forEach((fileName) => {
- cpFile(traceStreamer + '/' + fileName, rootPath + outDir + '/trace/database/' + fileName);
- });
- }
- } else {
- log.error('traceStreamer dir is not Exits');
- return;
- }
- // compile server
- if (compileServer) {
- log.log('start compile server');
- let serverSrc = path.normalize(path.join(__dirname, '/server/main.go'));
- let rs;
- if (os.type() === 'Windows_NT') {
- rs = childProcess.spawnSync('go', ['build', '-o', outPath, serverSrc], {
- encoding: 'utf-8',
- });
- } else {
- rs = childProcess.spawnSync('go', ['build', '-o', outPath + '/main', serverSrc], {
- encoding: 'utf-8',
- });
- }
- if (rs.status == 0) {
- log.log('compile server success');
- } else {
- log.error('compile server failed', rs);
- }
- } else {
- log.warn('skip compile server');
- }
- log.log('smartPerf compile success');
-}
-
-function copyDirectory(src, dest) {
- if (checkDirExist(dest) == false) {
- fs.mkdirSync(dest);
- }
- if (checkDirExist(src) == false) {
- return false;
- }
- let directories = fs.readdirSync(src);
- directories.forEach((value) => {
- let filePath = path.join(src, value);
- let fileSys = fs.statSync(filePath);
- if (fileSys.isFile()) {
- let destPath = path.join(dest, value);
- log.info('cp file %s to %s', filePath, destPath);
- fs.copyFileSync(filePath, destPath);
- } else if (fileSys.isDirectory()) {
- copyDirectory(filePath, path.join(dest, value));
- }
- });
-}
-
-function checkDirExist(dirPath) {
- return fs.existsSync(dirPath);
-}
-
-function removeDir(outPath) {
- let files = [];
- if (fs.existsSync(outPath)) {
- files = fs.readdirSync(outPath);
- files.forEach((file, index) => {
- let curPath = outPath + '/' + file;
- if (fs.statSync(curPath).isDirectory()) {
- removeDir(curPath);
- } else {
- fs.unlinkSync(curPath);
- }
- });
- fs.rmdirSync(outPath);
- }
-}
-
-main();
diff --git a/ide/src/base-ui/button/LitButton.ts b/ide/src/base-ui/button/LitButton.ts
index 9c2c9b12db41cebea0d3d78c6742cb277ba0b344..e04eb065bbc1bf135fead4bd69ca46a18ecb66f9 100644
--- a/ide/src/base-ui/button/LitButton.ts
+++ b/ide/src/base-ui/button/LitButton.ts
@@ -128,10 +128,19 @@ export class LitButton extends BaseElement {
initHtml(): string {
return `
-
-
-
-
- `;
+ `
}
initElements(): void {
diff --git a/ide/src/base-ui/chart/pagenation/PageNation.ts b/ide/src/base-ui/chart/pagenation/PageNation.ts
index 2039e69205e509b8537a271f13d35674a476e069..f78ef5db9a3274b81be7d0e347faf00c154ce72f 100644
--- a/ide/src/base-ui/chart/pagenation/PageNation.ts
+++ b/ide/src/base-ui/chart/pagenation/PageNation.ts
@@ -308,20 +308,24 @@ export class PageNation {
}
if (current == totalpage - 4) {
// 左边5个 中间 ... 右边2个
- for (let i = 0; i < 2; i++) {
- this.buildLi(origin, i, current);
- }
- span = document.createElement('span');
- span.innerText = '...';
- this.list.appendChild(span);
- for (let i = totalpage - 7; i < totalpage; i++) {
- this.buildLi(origin, i, current);
- }
+ this.nodeAppendChild(origin,current,span,totalpage);
return true;
}
return false;
}
+ nodeAppendChild(origin: HTMLElement,current: number,span: any,totalpage: number):void{
+ for (let i = 0; i < 2; i++) {
+ this.buildLi(origin, i, current);
+ }
+ span = document.createElement('span');
+ span.innerText = '...';
+ this.list.appendChild(span);
+ for (let i = totalpage - 7; i < totalpage; i++) {
+ this.buildLi(origin, i, current);
+ }
+ }
+
bindPageEvent() {
this.element.addEventListener(
'click',
diff --git a/ide/src/base-ui/chart/pie/LitChartPie.ts b/ide/src/base-ui/chart/pie/LitChartPie.ts
index 73b2a4b822d08c28d886ecf1395fde5a97f8f4c3..5910d731476f10cd315ad208a733d0c48d7935ab 100644
--- a/ide/src/base-ui/chart/pie/LitChartPie.ts
+++ b/ide/src/base-ui/chart/pie/LitChartPie.ts
@@ -324,6 +324,10 @@ export class LitChartPie extends BaseElement {
this.ctx!.stroke();
this.ctx?.closePath();
});
+ this.setData(ease);
+ }
+
+ setData(ease: boolean):void{
this.data
.filter((it) => it.hover)
.forEach((it) => {
@@ -444,7 +448,18 @@ export class LitChartPie extends BaseElement {
initHtml(): string {
return `
-
- `;
+ `
}
}
diff --git a/ide/src/base-ui/chart/scatter/LitChartScatter.ts b/ide/src/base-ui/chart/scatter/LitChartScatter.ts
deleted file mode 100644
index cc9cff75a96e6bfd71e7da0baa894f48d142f79c..0000000000000000000000000000000000000000
--- a/ide/src/base-ui/chart/scatter/LitChartScatter.ts
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * Copyright (C) 2023 Huawei Device Co., Ltd.
- * 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.
- */
-
-import { resizeCanvas } from '../helper';
-import { BaseElement, element } from '../../BaseElement';
-import { LitChartScatterConfig } from './LitChartScatterConfig';
-
-@element('lit-chart-scatter')
-export class LitChartScatter extends BaseElement {
- private scatterTipEL: HTMLDivElement | null | undefined;
- private labelsEL: HTMLDivElement | null | undefined;
- canvas: HTMLCanvasElement | undefined | null;
- canvas2: HTMLCanvasElement | undefined | null;
- ctx: CanvasRenderingContext2D | undefined | null;
- originX: number = 0;
- finalX: number = 0;
- originY: number = 0;
- finalY: number = 0;
- options: LitChartScatterConfig | undefined;
-
- set config(LitChartScatterConfig: LitChartScatterConfig) {
- this.options = LitChartScatterConfig;
- this.init();
- }
- init(): void {
- if (this.options) {
- // 清楚上一次绘制的数据
- this.ctx?.clearRect(0, 0, this.clientWidth, this.clientHeight);
- this.drawBackground();
- this.drawScatterChart(this.options);
- //使用off-screen-canvas保存绘制的像素点
- this.setOffScreen();
- this.labelsEL!.innerText = this.options.title;
- }
- }
- // 使用离屏技术保存绘制的像素点
- setOffScreen(): void {
- this.canvas2 = document.createElement('canvas');
- this.canvas2.height = this.clientHeight;
- this.canvas2.width = this.clientWidth;
- let context2: CanvasRenderingContext2D | null = this.canvas2.getContext('2d');
- if (this.canvas?.width !== 0 && this.canvas?.height !== 0) {
- context2!.drawImage(this.canvas!, 0, 0);
- }
- }
- /*绘制渐变色背景*/
- drawBackground(): void {
- let w: number = this.clientWidth;
- let h: number = this.clientHeight;
- let color: CanvasGradient = this.ctx?.createRadialGradient(
- w / 2,
- h / 2,
- 0.2 * w,
- w / 2,
- h / 2,
- 0.5 * w
- )!;
- color?.addColorStop(0, '#eaeaea');
- color?.addColorStop(1, '#ccc');
- if (this.options) {
- this.options!.globalGradient = color;
- }
- this.ctx?.save();
- this.ctx!.fillStyle = color;
- this.ctx?.fillRect(0, 0, w, h);
- this.ctx?.restore();
- }
- /**
- * 绘制散点图
- */
- drawScatterChart(options: LitChartScatterConfig): void {
- this.drawAxis(options); //绘制坐标轴
- this.drawYLabels(options); //绘制y轴坐标
- this.drawXLabels(options); //绘制x轴坐标
- let drawload: boolean = false;
- if (options) {
- drawload = options.drawload;
- }
- if (drawload) {
- let load: Array = [];
- if (options) {
- load = options.load;
- this.drawBalanceLine(load); //绘制均衡线
- this.drawLoadLine(load); //绘制最大负载线
- }
- }
- this.drawData(options); //绘制散点图
- }
- /**
- * 绘制坐标轴
- */
- drawAxis(options: LitChartScatterConfig): void {
- let text: Array = new Array();
- if (options) {
- text = options.axisLabel;
- }
- this.ctx!.font = '10px KATTI';
- this.ctx!.fillStyle = '#000000';
- this.ctx!.strokeStyle = '#000000';
- // 画x轴
- this.ctx?.beginPath();
- this.ctx?.moveTo(this.originX, this.originY);
- this.ctx?.lineTo(this.finalX, this.originY);
- this.ctx?.fillText(text[0], this.finalX, this.originY);
- this.ctx?.stroke();
- // 画Y轴
- this.ctx?.beginPath();
- this.ctx?.moveTo(this.originX, this.originY);
- this.ctx?.lineTo(this.originX, this.finalY);
- this.ctx?.fillText(text[1], this.originX - 20, this.finalY - 10);
- this.ctx?.stroke();
- }
- /**
- * 绘制y轴坐标
- */
- drawYLabels(options: LitChartScatterConfig): void {
- const AXAIS_DELTA: number = 5;
- const QUYU: number = 100;
- // 添加原点刻度
- this.ctx!.font = '12px KATTI';
- this.ctx!.fillStyle = '#000000';
- this.ctx!.strokeStyle = '#000000';
- this.ctx?.fillText('0', this.originX - AXAIS_DELTA, this.originY + AXAIS_DELTA * 2);
- let yAxis: Array = [];
- if (options) {
- yAxis = options.yAxisLabel;
- }
- // 画Y轴坐标尺
- for (let i = 0; i < yAxis.length; i++) {
- let length1: number =
- (this.originY - this.finalY - ((this.originY - this.finalY) % QUYU)) *
- (yAxis[i] / yAxis[yAxis.length - 1]);
- let length2: number = this.originY - length1;
- let text: string = yAxis[i].toString();
- let x: number = this.originX - this.ctx?.measureText(text).width! - AXAIS_DELTA;
- this.ctx?.beginPath();
- this.ctx?.moveTo(this.originX, length2);
- this.ctx?.lineTo(this.originX + AXAIS_DELTA, length2);
- this.ctx?.fillText(text, x, length2 + AXAIS_DELTA);
- this.ctx?.stroke();
- }
- }
- /**
- * 绘制x轴坐标
- */
- drawXLabels(options: LitChartScatterConfig): void {
- // 画X轴坐标尺
- this.ctx!.fillStyle = '#000000';
- this.ctx!.strokeStyle = '#000000';
- const QUYU: number = 100;
- const DELTA: number = 5;
- let xAxis: Array = [];
- if (options) {
- xAxis = options.xAxisLabel;
- }
- for (let i = 0; i < xAxis.length; i++) {
- let length3: number =
- (this.finalX - this.originX - ((this.finalX - this.originX) % QUYU)) *
- (xAxis[i] / xAxis[xAxis.length - 1]);
- let length4: number = this.originX + length3;
- this.ctx?.beginPath();
- this.ctx?.moveTo(length4, this.originY);
- this.ctx?.lineTo(length4, this.originY - DELTA);
- this.ctx?.fillText(xAxis[i].toString(), length4 - DELTA * 3, this.originY + DELTA * 2);
- this.ctx?.stroke();
- }
- }
-
- /**
- * 绘制数据
- */
- drawData(options: LitChartScatterConfig): void {
- let data: Array>> = [];
- let yAxis: Array = [];
- let xAxis: Array = [];
- let colorPool: Array = new Array();
- let colorPoolText: Array = new Array();
- let rectY: number = this.clientHeight * 0.05;
- const QUYU: number = 100;
- const WIDTH_DELTA: number = 70;
- if (options) {
- data = options.data;
- yAxis = options.yAxisLabel;
- xAxis = options.xAxisLabel;
- colorPool = options.colorPool();
- colorPoolText = options.colorPoolText();
- options.paintingData = [];
- }
- let xLength: number = this.finalX - this.originX - ((this.finalX - this.originX) % QUYU);
- let yLength: number = this.originY - this.finalY - ((this.originY - this.finalY) % QUYU);
- for (let i = 0; i < data.length; i++) {
- for (let j = 0; j < data[i].length; j++) {
- // 打点x坐标
- let x: number = this.originX + (data[i][j][0] / xAxis[xAxis.length - 1]) * xLength;
- // 打点y坐标
- let y: number = this.originY - (data[i][j][1] / yAxis[yAxis.length - 1]) * yLength;
- let r: number = 6;
- if (i > 0) {
- options.paintingData[data[i][j][2] - 1] = {
- x,
- y,
- r,
- c: data[i][j],
- color: colorPool[i],
- };
- } else {
- options.paintingData.push({
- x,
- y,
- r,
- c: data[i][j],
- color: colorPool[i],
- });
- }
- this.drawCycle(x, y, r, 0.8, colorPool[i]);
- }
- if (data[i].length) {
- rectY = rectY + 20;
- this.ctx?.fillText(colorPoolText[i] + ': ', this.clientWidth - WIDTH_DELTA, rectY + 4);
- this.drawCycle(this.clientWidth - (QUYU / 5), rectY, 7.5, 0.8, colorPool[i]);
- }
- }
- }
- /**
- * 画圆点
- */
- drawCycle(
- x: number,
- y: number,
- r: number,
- transparency: number,
- color: string
- ): void {
- this.ctx!.fillStyle = color;
- this.ctx?.beginPath();
- this.ctx!.globalAlpha = transparency;
- this.ctx?.arc(x, y, r, 0, Math.PI * 2, true);
- this.ctx?.closePath();
- this.ctx?.fill();
- }
-
- /**
- * 绘制最大负载线
- */
- drawLoadLine(data: Array): void {
- let maxXAxis: number = 1;
- const QUYU: number = 100;
- const FOR_VALUE = 60;
- if (this.options) {
- maxXAxis = this.options.xAxisLabel[this.options.xAxisLabel.length - 1];
- }
- // data[1]用来标注n Hz负载线
- let addr1: number =
- this.originX +
- (this.finalX - this.originX - ((this.finalX - this.originX) % QUYU)) *
- (data[0] / maxXAxis);
- let addr2: number =
- (this.originY - this.finalY - ((this.originY - this.finalY) % QUYU)) / FOR_VALUE;
- let y: number = this.originY;
- this.ctx!.strokeStyle = '#ff0000';
- for (let i = 0; i < FOR_VALUE; i++) {
- this.ctx?.beginPath();
- this.ctx?.moveTo(addr1, y);
- y -= addr2;
- this.ctx?.lineTo(addr1, y);
- if (i % 2 !== 0) {
- this.ctx?.stroke();
- }
- }
- this.ctx!.font = '10px KATTI';
- this.ctx!.fillStyle = '#ff0000';
- this.ctx?.fillText(
- data[1] + 'Hz最大负载线',
- addr1 - FOR_VALUE / 3,
- this.originY - addr2 * FOR_VALUE - FOR_VALUE / 4
- );
- this.ctx!.fillStyle = '#000000';
- this.ctx?.fillText('过供给区', addr1 / 2, y + FOR_VALUE / 2);
- this.ctx?.fillText('欠供给区', addr1 / 2, this.originY - this.finalY);
- this.ctx?.fillText(
- '超负载区',
- addr1 + FOR_VALUE / 3,
- (this.finalY + this.originY) / 2
- );
- }
-
- /**
- * 绘制均衡线
- */
- drawBalanceLine(data: Array): void {
- let maxXAxis: number = 1;
- const QUYU: number = 100;
- const FOR_VALUE = 60;
- if (this.options) {
- maxXAxis = this.options.xAxisLabel[this.options.xAxisLabel.length - 1];
- }
- // data[1]用来标注n Hz均衡线
- let addr1: number =
- ((this.finalX - this.originX - ((this.finalX - this.originX) % QUYU)) *
- (data[0] / maxXAxis)) / FOR_VALUE;
- let addr2: number =
- (this.originY - this.finalY - ((this.originY - this.finalY) % QUYU)) / FOR_VALUE;
- let x: number = this.originX;
- let y: number = this.originY;
- this.ctx!.strokeStyle = '#00ff00';
- for (let i = 0; i < FOR_VALUE; i++) {
- this.ctx?.beginPath();
- this.ctx?.moveTo(x, y);
- x += addr1;
- y -= addr2;
- this.ctx?.lineTo(x, y);
- if (i % 2 === 0) {
- this.ctx?.stroke();
- }
- }
- this.ctx?.save();
- this.ctx?.translate(addr1 * 25 + this.originX, addr2 * 40 + this.finalY);
- this.ctx!.font = '10px KATTI';
- this.ctx!.fillStyle = '#ff0f00';
- this.ctx?.rotate(-Math.atan(addr2 / addr1));
- this.ctx?.fillText(data[1] + 'Hz均衡线', 0, 0);
- this.ctx?.restore();
- }
-
- /*检测是否hover在散点之上*/
- checkHover(
- options: LitChartScatterConfig | undefined,
- pos: Object
- ): Object | boolean {
- let data: Array