diff --git a/src/static/js/analysis-details.js b/src/static/js/analysis-details.js index bc2ac268c8bc63a65dc9b25d58dc1169042f3e60..09d022a4ac06174f3c94f7dc20e3fe6da034257e 100644 --- a/src/static/js/analysis-details.js +++ b/src/static/js/analysis-details.js @@ -15,7 +15,7 @@ import echarts from 'echarts'; import axios from 'axios'; -import {host, port, engineHost, enginePort} from './utils.js'; +import {engineHost, enginePort} from './utils.js'; export default { data() { @@ -145,7 +145,7 @@ export default { }, addCompareFileInfo(file, line, fileNum) { - const path = `http://${host}:${port}/v1/UI/analysis/compareWith`; + const path = `http://${engineHost}:${enginePort}/v1/UI/analysis/compareWith`; var params = {name: file, csvLine: line}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -185,7 +185,7 @@ export default { }, initialDetailInfo(file, csvLine, logLine) { - const path = `http://${host}:${port}/v1/UI/analysis/getAnalysisData`; + const path = `http://${engineHost}:${enginePort}/v1/UI/analysis/getAnalysisData`; var params = {name: file, csvLine: csvLine, logLine: logLine}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -460,11 +460,14 @@ function deleteOldData(fileChartId, compareChartId, fileName) { } option.series[i] = undefined; } + while (option.series[0] !== undefined && option.xAxis[0].data.length > option.series[0].data.length) { + option.xAxis[0].data.pop(); + } chart.setOption(option, true); } for (var e in compareChartId) { var element = document.getElementById(compareChartId[e]); - if (element !== undefined) { + if (element !== undefined && element != null) { element.remove(); } } @@ -472,17 +475,15 @@ function deleteOldData(fileChartId, compareChartId, fileName) { function addSeriesForChart(id, fileName) { var chart = echarts.init(document.getElementById(id)); - var series = chart.getOption().series; - series.push({ + var option = chart.getOption(); + option.series.push({ name: fileName, type: 'line', symbolSize: 5, barGap: 0, data: [] }); - chart.setOption({ - series: series - }); + chart.setOption(option, true); } function getTotal(list) { diff --git a/src/static/js/analysis.js b/src/static/js/analysis.js index fba18edeb6759ea489b48e2a8421be99c90e97c9..75a183d461d05c9c11cbec505ec9503bba880833 100644 --- a/src/static/js/analysis.js +++ b/src/static/js/analysis.js @@ -14,7 +14,7 @@ */ import echarts from 'echarts'; import axios from 'axios'; -import {host, port} from './utils.js'; +import {engineHost, enginePort} from './utils.js'; export default { data() { @@ -54,7 +54,7 @@ export default { } else if (this.newFileName === this.currFileName) { document.getElementById('rename-error-same').style.display = 'block'; } else { - const path = `http://${host}:${port}/v1/UI/analysis/rename`; + const path = `http://${engineHost}:${enginePort}/v1/UI/analysis/rename`; var params = {name: this.currFileName, newName: this.newFileName}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -81,7 +81,7 @@ export default { if (uid === null || uid === '') { return; } - const path = `http://${host}:${port}/v1/UI/analysis/initialPage`; + const path = `http://${engineHost}:${enginePort}/v1/UI/analysis/initialPage`; var params = {uid, uid}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -102,7 +102,7 @@ export default { if (this.optionCompare.indexOf(file.name) > -1) { this.optionCompare.splice(this.optionCompare.indexOf(file.name), 1); } - const path = `http://${host}:${port}/v1/UI/analysis/chooseFile`; + const path = `http://${engineHost}:${enginePort}/v1/UI/analysis/chooseFile`; var params = {name: file.name}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { diff --git a/src/static/js/login.js b/src/static/js/login.js index 447201c927bd0c1f5a68d5281a97688f65905e6d..74daa3c8ba30e2eb83e55f557c8938040454680f 100644 --- a/src/static/js/login.js +++ b/src/static/js/login.js @@ -12,7 +12,7 @@ * See the Mulan PSL v2 for more details. * Create: 2020-12-21 */ -import {host, port} from './utils.js'; +import {engineHost, enginePort} from './utils.js'; import axios from 'axios'; import crypto from 'crypto'; @@ -52,7 +52,7 @@ export default{ this.fakeLogin(); return; } - const path = `http://${host}:${port}/v1/UI/user/login`; + const path = `http://${engineHost}:${enginePort}/v1/UI/user/login`; var pwd = crypto.createHash('sha256').update(this.password).digest('base64'); var params = {email: this.email, password: pwd}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { @@ -74,7 +74,7 @@ export default{ }, checkSignup() { this.clearAll(); - const path = `http://${host}:${port}/v1/UI/user/signup`; + const path = `http://${engineHost}:${enginePort}/v1/UI/user/signup`; var pwd = crypto.createHash('sha256').update(this.password).digest('base64'); var params = {email: this.email, password: pwd, name: this.username}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { diff --git a/src/static/js/tuning-details.js b/src/static/js/tuning-details.js index c1be3148b80e478b29e0e10984c552de10744f01..b389de378c6faba819393872f2ca0a444b3175ec 100644 --- a/src/static/js/tuning-details.js +++ b/src/static/js/tuning-details.js @@ -15,7 +15,7 @@ import echarts from 'echarts'; import axios from 'axios'; -import {deleteChild, host, port} from './utils.js'; +import {deleteChild, engineHost, enginePort} from './utils.js'; export default { data() { @@ -50,7 +50,7 @@ export default { chart.setOption(option, true); } } - const path = `http://${host}:${port}/v1/UI/tuning/compareWith`; + const path = `http://${engineHost}:${enginePort}/v1/UI/tuning/compareWith`; var params = {name: file, line: line}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -100,7 +100,7 @@ export default { }, initialPage() { - const path = `http://${host}:${port}/v1/UI/tuning/initialChart`; + const path = `http://${engineHost}:${enginePort}/v1/UI/tuning/initialChart`; var params = {status: this.fileStatus, name: this.fileName}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -303,7 +303,7 @@ export default { }, updateChart(res, line, stat) { - const path = `http://${host}:${port}/v1/UI/tuning/getTuningData`; + const path = `http://${engineHost}:${enginePort}/v1/UI/tuning/getTuningData`; var params = {status: res.data.status, name: res.data.file_name, line: line}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -346,7 +346,7 @@ export default { }, findFile(filename, res, line) { - const path = `http://${host}:${port}/v1/UI/tuning/getTuningStatus`; + const path = `http://${engineHost}:${enginePort}/v1/UI/tuning/getTuningStatus`; var params = {name: filename}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((ret) => { res.data = JSON.parse(res.data); @@ -418,7 +418,7 @@ function updatePerformanceChart(name, times, value, fileName) { count++; } for (var i in times) { - if (count === 0) { + if (count === 0 || oldX.length - 1 < times[i]) { oldX.push(times[i]); } if (name === 'best evaluation') { @@ -447,6 +447,7 @@ function updatePerformanceChart(name, times, value, fileName) { var oldSeries = chart.getOption().series; oldSeries[count].data = oldData; chart.setOption({ + xAxis: {data: oldX}, series: oldSeries }); } else { @@ -465,6 +466,9 @@ function deleteOldData(compareChartId) { for (var i = 1; i < oldSeries.length; i++) { option.series[i] = undefined; } + while (option.series[0] !== undefined && option.xAxis[0].data.length > option.series[0].data.length) { + option.xAxis[0].data.pop(); + } chart.setOption(option, true); } } diff --git a/src/static/js/tuning.js b/src/static/js/tuning.js index 3cd9d2d08c19dbed40997ba62a727edb4f3954ae..3dd4a7d02ab35533b318a2631e1dc9aca3bdb09e 100644 --- a/src/static/js/tuning.js +++ b/src/static/js/tuning.js @@ -13,7 +13,7 @@ * Create: 2020-10-29 */ import axios from 'axios'; -import {host, port} from './utils.js'; +import {engineHost, enginePort} from './utils.js'; export default { data() { @@ -45,7 +45,7 @@ export default { if (uid === null || uid === '') { return; } - const path = `http://${host}:${port}/v1/UI/tuning/initialPage`; + const path = `http://${engineHost}:${enginePort}/v1/UI/tuning/initialPage`; var params = {status: type, uid: uid}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -78,7 +78,7 @@ export default { } else if (this.newFileName === this.currFileName) { document.getElementById('rename-error-same').style.display = 'block'; } else { - const path = `http://${host}:${port}/v1/UI/tuning/rename`; + const path = `http://${engineHost}:${enginePort}/v1/UI/tuning/rename`; var params = {name: this.currFileName, newName: this.newFileName}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { @@ -101,7 +101,7 @@ export default { }, initialTuningDetails(file) { - const path = `http://${host}:${port}/v1/UI/tuning/chooseFile`; + const path = `http://${engineHost}:${enginePort}/v1/UI/tuning/chooseFile`; var params = {status: file.status, name: file.name}; axios.get(path, {params: params}, {'Access-Control-Allow-Origin': '*'}).then((res) => { if (typeof(res.data) === 'string') { diff --git a/src/static/js/utils.js b/src/static/js/utils.js index eb3563f01fac352dc72be03a83b2c8c6335586a3..61eb4ed8e8f77486dea55d05876cc2ac3a822eaf 100644 --- a/src/static/js/utils.js +++ b/src/static/js/utils.js @@ -12,8 +12,6 @@ * See the Mulan PSL v2 for more details. * Create: 2020-10-29 */ -var host = 'HOST'; -var port = 'PORT'; var engineHost = 'ENGINE_HOST'; var enginePort = 'ENGINE_PORT'; @@ -26,8 +24,6 @@ function deleteChild(id) { export { deleteChild, - host, - port, engineHost, enginePort };