diff --git a/nezha-fronted/src/assets/css/main.css b/nezha-fronted/src/assets/css/main.css index 414ab10f7..8b1e29159 100644 --- a/nezha-fronted/src/assets/css/main.css +++ b/nezha-fronted/src/assets/css/main.css @@ -529,3 +529,7 @@ html { color: #F98D9A; } /* end--自定义可编辑的el-select下拉框样式*/ +.right-box-add-chart { + width: 520px; + height: calc(100% - 100px); +} diff --git a/nezha-fronted/src/components/charts/chart-list.vue b/nezha-fronted/src/components/charts/chart-list.vue new file mode 100644 index 000000000..ae39e3192 --- /dev/null +++ b/nezha-fronted/src/components/charts/chart-list.vue @@ -0,0 +1,328 @@ + + + diff --git a/nezha-fronted/src/components/charts/chart-table.scss b/nezha-fronted/src/components/charts/chart-table.scss new file mode 100644 index 000000000..ae6382a9a --- /dev/null +++ b/nezha-fronted/src/components/charts/chart-table.scss @@ -0,0 +1,63 @@ +/* ---------edit-chart-move--------- */ +.chart-table { + width: 100%; + height: 100%; + // min-height: 500px; + position: relative; + background: #FFF; + border: 1px solid #d8dce1; + padding: 10px; + margin-bottom: 10px; + .table-title { + font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; + font-size: 14px; + } + .edit { + // position: absolute; + // right: 40px; + // top: 5px; + // z-index: 10; + padding-right: 40px; + .set-icon { + display: inline-block; + cursor: pointer; + font-size: 14px; + margin-left: 15px; + color: #5aacff; + border: 0 none; + background: transparent; + } + .list-icon { + float: left; + margin-right: 10px; + } + .show-icon { + cursor: pointer; + float: right; + font-size: 14px; + } + } + .chart-select { + position: absolute; + left: 40px; + top: 25px; + z-index: 10; + font-size: 14px; + .chart-select-btn { + margin-right: 10px; + cursor: pointer; + &.active { + color: #5aacff; + } + } + } + /*没有数据显示*/ + .null { + position: absolute; + top: 50%; + width: 100%; + text-align: center; + font-size: 24px; + font-weight: 600; + } +} diff --git a/nezha-fronted/src/components/charts/chart-table.vue b/nezha-fronted/src/components/charts/chart-table.vue new file mode 100644 index 000000000..52abfdf62 --- /dev/null +++ b/nezha-fronted/src/components/charts/chart-table.vue @@ -0,0 +1,187 @@ + + + diff --git a/nezha-fronted/src/components/charts/line-chart-block.scss b/nezha-fronted/src/components/charts/line-chart-block.scss new file mode 100644 index 000000000..ab099563c --- /dev/null +++ b/nezha-fronted/src/components/charts/line-chart-block.scss @@ -0,0 +1,86 @@ +/* ---------edit-chart-move--------- */ +.line-chart-block { + width: 100%; + height: 100%; + // min-height: 500px; + position: relative; + background: #FFF; + border: 1px solid #d8dce1; + margin-bottom: 10px; + padding-bottom: 3px; + .line-area { + box-sizing: border-box; + background: #FFF; + min-height: 400px; + span.highcharts-title { + display: block !important; + width: 50%; + font-size: 14px !important; + overflow: hidden; + word-wrap: break-word !important; + white-space: pre-wrap !important; + } + } + .edit { + position: absolute; + right: 40px; + top: 15px; + z-index: 10; + .set-icon { + display: inline-block; + cursor: pointer; + font-size: 14px; + margin-left: 15px; + color: #5aacff; + border: 0 none; + background: transparent; + } + .list-icon { + float: left; + margin-right: 10px; + } + .show-icon { + cursor: pointer; + float: right; + font-size: 14px; + } + } + .chart-select { + position: absolute; + left: 40px; + top: 25px; + z-index: 10; + font-size: 14px; + .chart-select-btn { + margin-right: 10px; + cursor: pointer; + &.active { + color: #5aacff; + } + } + } + /*没有数据显示*/ + .null { + position: absolute; + top: 50%; + width: 100%; + text-align: center; + font-size: 24px; + font-weight: 600; + } +} +.line-chart-block-modal { + .line-area { + box-sizing: border-box; + background: #FFF; + min-height: 400px; + span.highcharts-title {/*针对highcharts设置的样式,echarts需要修改??*/ + display: block !important; + width: 50%; + font-size: 14px !important; + overflow: hidden; + word-wrap: break-word !important; + white-space: pre-wrap !important; + } + } +} diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue new file mode 100644 index 000000000..26e7765be --- /dev/null +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -0,0 +1,599 @@ + + + diff --git a/nezha-fronted/src/components/common/header.vue b/nezha-fronted/src/components/common/header.vue index 1ea91af09..58eccadda 100644 --- a/nezha-fronted/src/components/common/header.vue +++ b/nezha-fronted/src/components/common/header.vue @@ -204,7 +204,7 @@ --> - + + +
+ +
+ + + + +
+ + + +
{{rightBox.title}}
+ + + +
+
+
{{$t('dashboard.panel.panelForm.panelName')}}
+
+ +
+
+
+ + + + + + +
+
+ + + + + diff --git a/nezha-fronted/src/components/page/dashboard/chartBox.vue b/nezha-fronted/src/components/page/dashboard/chartBox.vue new file mode 100644 index 000000000..c2f8a6732 --- /dev/null +++ b/nezha-fronted/src/components/page/dashboard/chartBox.vue @@ -0,0 +1,496 @@ + + + + + + diff --git a/nezha-fronted/src/components/page/dashboard/chartMetric.vue b/nezha-fronted/src/components/page/dashboard/chartMetric.vue new file mode 100644 index 000000000..b23a5b30c --- /dev/null +++ b/nezha-fronted/src/components/page/dashboard/chartMetric.vue @@ -0,0 +1,418 @@ + + + diff --git a/nezha-fronted/src/components/page/dashboard/panel.vue b/nezha-fronted/src/components/page/dashboard/panel.vue index 75f773b59..c0a6a6e65 100644 --- a/nezha-fronted/src/components/page/dashboard/panel.vue +++ b/nezha-fronted/src/components/page/dashboard/panel.vue @@ -22,11 +22,15 @@ .content-right-option .el-icon-view:hover { color: #409EFF; } - +/* begin-chart list*/ .table-list { - margin-top: 100px; - } + margin-top: 10px; + } + .box-content { + position: relative; + } + /* end-chart list*/ /* begin--Panel-自定义可编辑的el-select下拉框样式*/ .panel-dropdown-btn { display: inline-block; @@ -64,255 +68,277 @@ diff --git a/nezha-fronted/src/libs/bus.js b/nezha-fronted/src/libs/bus.js new file mode 100644 index 000000000..87e73370b --- /dev/null +++ b/nezha-fronted/src/libs/bus.js @@ -0,0 +1,175 @@ +import Vue from 'vue'; +//import Cookies from 'js-cookie'; +//import md5 from 'md5'; + +Date.prototype.setStart = function() { + this.setHours(0); + this.setMinutes(0); + this.setSeconds(0); +}; +// eslint-disable-next-line +Date.prototype.setEnd = function() { + this.setHours(23); + this.setMinutes(59); + this.setSeconds(59); +}; + +export default new Vue({ + data() { + return { + selectDate: [], // 选中的时间段 + emailReg: /^[a-zA-Z0-9]{1,10}@[a-zA-Z0-9]{1,5}\.[a-zA-Z0-9]{1,5}$/, + // 创建策略信息 + buildRuleInfo: { + triggers: [], + actions: [], + }, + backtoRulelist: '', // 返回策略列表页信息 + //role: md5(1), + role:1, + // 创建图表信息 + chartAddInfo: { + metricTarget: [], + }, + }; + }, + methods: { + // 获取初始化时间,默认最近一周 + getDefaultDate() { + let start = this.getDays(-7); + let end = this.getDays(0); + start.setStart(); + end.setEnd(); + // let start = this.getHoursTime(-1); + // let end = this.getHoursTime(0); + start = this.timeFormate(start, 'yyyy-MM-dd hh:mm:ss'); + end = this.timeFormate(end, 'yyyy-MM-dd hh:mm:ss'); + this.selectDate = [start, end]; + }, + getHoursTime(hours) { + const today = new Date().getTime(); + const date = new Date(today + (hours * 60 * 60 * 1000)); + return date; + }, + // 初始化日期 + getDays(days) { + const today = new Date().getTime(); + const date = new Date(today + (days * 24 * 60 * 60 * 1000)); + return date; + }, + formatDate(date, type) { + const yy = date.getFullYear(); + const dateM = date.getMonth() + 1; + const mm = dateM > 9 ? dateM : `0${dateM}`; + const dateD = date.getDate(); + const dd = dateD > 9 ? dateD : `0${dateD}`; + if (type) { + return `${yy}${type}${mm}${type}${dd}`; + } + return `${yy}${mm}${dd}`; + }, + timeFormate(date, fmt) { + const time = new Date(date); + let fm = fmt; + // fmt 自定义格式,如:yy-MM-dd + let week = ''; + switch (time.getDay()) { + case 0: + week = '周日'; + break; + case 1: + week = '周一'; + break; + case 2: + week = '周二'; + break; + case 3: + week = '周三'; + break; + case 4: + week = '周四'; + break; + case 5: + week = '周五'; + break; + case 6: + week = '周六'; + break; + default: + week = ''; + break; + } + const o = { + 'M+': time.getMonth() + 1, // 月份 + 'd+': time.getDate(), // 日 + 'h+': time.getHours(), // 小时 + 'm+': time.getMinutes(), // 分 + 's+': time.getSeconds(), // 秒 + 'q+': Math.floor((time.getMonth() + 3) / 3), // 季度 + S: time.getMilliseconds(), // 毫秒 + w: week, + }; + if (/(y+)/.test(fm)) { + fm = fm.replace(RegExp.$1, (time.getFullYear().toString()).substr(4 - RegExp.$1.length)); + } + Object.keys(o).forEach((k) => { + if (new RegExp(`(${k})`).test(fm)) { + fm = fm.replace(RegExp.$1, (RegExp.$1.length === 1) ? + (o[k]) : ((`00${o[k]}`).substr((`${o[k]}`).length))); + } + }); + return fm; + }, + isEmptyObject(obj) { + if (obj) { + let name = ''; + // eslint-disable-next-line + for (name in obj) { return false; } + return true; + } + return true; + }, + validateEmail(rule, value, callback) { + if (value === '') { + callback(new Error('请输入邮箱')); + } else if (!this.emailReg.test(value)) { + callback(new Error('邮箱格式不正确')); + } else { + callback(); + } + }, + getNumStr(num) { + if (num >= 1000) { + const kbNum = num / 1000; + if (kbNum >= 1000) { + const mbNum = kbNum / 1000; + if (mbNum > 1000) { + const gbNum = mbNum / 1000; + if (gbNum > 1000) { + const tbNum = gbNum / 1000; + if (tbNum > 1000) { + const pbNum = tbNum / 1000; + return `${pbNum.toFixed(2)}PB`; + } + return `${tbNum.toFixed(2)}TB`; + } + return `${gbNum.toFixed(2)}GB`; + } + return `${mbNum.toFixed(2)}MB`; + } + return `${kbNum.toFixed(2)}KB`; + } + return num.toFixed(2); + }, + }, + created() { + this.getDefaultDate(); + }, + computed: { + /* + isAdmin() { + return this.role === Cookies.get('owl_role'); + }, + */ + }, +}); diff --git a/nezha-fronted/src/main.js b/nezha-fronted/src/main.js index 1be1fbb27..da2bddbad 100644 --- a/nezha-fronted/src/main.js +++ b/nezha-fronted/src/main.js @@ -25,6 +25,7 @@ import assetAddUnit from "./components/page/asset/assetAddUnit"; //资产添加 import assetEditUnit from "./components/page/asset/assetEditUnit"; //资产添加组件 import alertConfigBox from "./components/common/rightBox/alertConfigBox"; //告警规则弹框组件 import dcConfigBox from "./components/common/dcConfig"; //idc配置弹框组件 +import panelBox from "./components/common/rightBox/panelBox"; //面板弹框组件 Vue.component("Pagination", Pagination); Vue.component("searchInput", searchInput); @@ -36,6 +37,7 @@ Vue.component("assetAddUnit", assetAddUnit); Vue.component("assetEditUnit", assetEditUnit); Vue.component("alert-config-box", alertConfigBox); Vue.component("idc-config-box", dcConfigBox); +Vue.component("panel-box", panelBox); Vue.prototype.$axios = axios; Vue.prototype.$post = post; diff --git a/nezha-fronted/src/store/index.js b/nezha-fronted/src/store/index.js index 72bff57dc..af18b08cc 100644 --- a/nezha-fronted/src/store/index.js +++ b/nezha-fronted/src/store/index.js @@ -17,6 +17,7 @@ const store = new Vuex.Store({ projectListChange: 0, moduleListChange: 0, flushDataSign: false, + panelListReload:false }, getters: { }, @@ -32,6 +33,9 @@ const store = new Vuex.Store({ }, moduleListChange(state) { state.moduleListChange = state.moduleListChange + 1; + }, + panelListChange(state,status){ + state.panelListReload = status; } }, actions: {