diff --git a/nezha-fronted/src/assets/css/components/page/notebook/notebook.scss b/nezha-fronted/src/assets/css/components/page/notebook/notebook.scss index a904edb4e..cfe5db1ef 100644 --- a/nezha-fronted/src/assets/css/components/page/notebook/notebook.scss +++ b/nezha-fronted/src/assets/css/components/page/notebook/notebook.scss @@ -41,114 +41,115 @@ margin-right: 10px; } } - .notebook-scrollWrap{ - width: 100%; - height: 100%; - overflow: hidden scroll; - position: relative; + } +} + +.notebook-scrollWrap{ + width: 100%; + height: 100%; + overflow: hidden scroll; + position: relative; + .notebook-content{ + width: 100%; + max-width: 1200px; + margin: auto; + &>:not(.notebook-list){ + width: calc(100% - 40px); + margin-left: 20px; + margin-right: 20px; } - .notebook-content{ - width: 100%; - max-width: 1200px; - margin: auto; - &>:not(.notebook-list){ - width: calc(100% - 40px); - margin-left: 20px; - margin-right: 20px; - } - } - .notebook-title{ - box-sizing: border-box; - margin-top: 30px; - padding-bottom: 20px; + } + .notebook-title{ + box-sizing: border-box; + margin-top: 30px; + padding-bottom: 20px; + font-family: Roboto-Medium; + font-size: 24px; + color: $--color-text-primary; + letter-spacing: 0; + font-weight: 500; + line-height: 28px; + border-bottom: 1px solid $--border-color-light; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + } + .notebook-title-input{ + box-sizing: border-box; + margin-top: 30px; + .el-input__inner{ + height: 46px; font-family: Roboto-Medium; font-size: 24px; color: $--color-text-primary; letter-spacing: 0; font-weight: 500; - line-height: 28px; - border-bottom: 1px solid $--border-color-light; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; + line-height: 46px; } - .notebook-title-input{ - box-sizing: border-box; - margin-top: 30px; - .el-input__inner{ - height: 46px; - font-family: Roboto-Medium; - font-size: 24px; - color: $--color-text-primary; - letter-spacing: 0; - font-weight: 500; - line-height: 46px; - } + } + .notebook-list{ + height: auto; + .panel-chart.my-loading-parent--relative{ + height: 100% !important; } - .notebook-list{ - height: auto; - .panel-chart.my-loading-parent--relative{ - height: 100% !important; - } - .no-data{ - text-align: center; - position: absolute; - left: 0; - right: 0; - top: 50%; - margin-top: -54px; - .no-data-div { - color: $--color-text-regular; - } - } - } - .notebook-add{ - padding-bottom: 60px; - .notebook-add-title{ - margin-bottom: 10px; - font-family: Roboto-Regular; - font-size: 14px; - color: $--color-text-primary; - font-weight: 400; - } - .notebook-add-list{ - display: grid; - grid-gap:10px; - grid-template-columns:repeat(auto-fill, minmax(172px, 1fr)); - } - .notebook-add-item{ - min-width: 172px; - height: 62px; - border: 1px solid $--border-color-light; - border-radius: 4px; - padding: 0 20px; - box-sizing: border-box; - cursor: pointer; - transition: all 0.2s; - display: flex; - align-items: center; - &:hover{ - background: #FFFBF5; - border: 1px solid rgba(250,144,28,0.49); - box-shadow: 0px 1px 4px 0px rgba(250,144,28,0.13); - } - .notebook-chart-icon{ - width: 24px; - margin-right: 12px; - } - span{ - font-size: 14px; - color: $--color-text-primary; - } - } - .notebook-add-show{ - font-family: Roboto-Regular; - font-size: 14px; - color: #FA901C; - font-weight: 400; - margin-top: 16px; - cursor: pointer; + .no-data{ + text-align: center; + position: absolute; + left: 0; + right: 0; + top: 50%; + margin-top: -54px; + .no-data-div { + color: $--color-text-regular; } } } + .notebook-add{ + padding-bottom: 60px; + .notebook-add-title{ + margin-bottom: 10px; + font-family: Roboto-Regular; + font-size: 14px; + color: $--color-text-primary; + font-weight: 400; + } + .notebook-add-list{ + display: grid; + grid-gap:10px; + grid-template-columns:repeat(auto-fill, minmax(172px, 1fr)); + } + .notebook-add-item{ + min-width: 172px; + height: 62px; + border: 1px solid $--border-color-light; + border-radius: 4px; + padding: 0 20px; + box-sizing: border-box; + cursor: pointer; + transition: all 0.2s; + display: flex; + align-items: center; + &:hover{ + background: #FFFBF5; + border: 1px solid rgba(250,144,28,0.49); + box-shadow: 0px 1px 4px 0px rgba(250,144,28,0.13); + } + .notebook-chart-icon{ + width: 24px; + margin-right: 12px; + } + span{ + font-size: 14px; + color: $--color-text-primary; + } + } + .notebook-add-show{ + font-family: Roboto-Regular; + font-size: 14px; + color: #FA901C; + font-weight: 400; + margin-top: 16px; + cursor: pointer; + } + } } \ No newline at end of file diff --git a/nezha-fronted/src/components/chart/chart.vue b/nezha-fronted/src/components/chart/chart.vue index 8d7bd52cf..269e14606 100644 --- a/nezha-fronted/src/components/chart/chart.vue +++ b/nezha-fronted/src/components/chart/chart.vue @@ -70,6 +70,7 @@ :globalVariables="globalVariables" > - + diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/notebookTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/notebookTab.vue index 7c669921b..c5c2f7b21 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/notebookTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/notebookTab.vue @@ -32,7 +32,7 @@
{{$t('notebook.downloadAs',{format:'markdown'})}}
-
{{$t('notebook.downloadNotebook')}} JSON
+
{{$t('notebook.downloadAs',{format:'html'})}}
@@ -88,7 +88,7 @@ - + @@ -245,6 +245,8 @@ export default { const index = this.$refs.notebookList.copyDataList.findIndex(item => item.id == chart.id) this.$refs.notebookList.copyDataList.splice(index, 1) this.$refs.notebookList.onScroll(this.scrollbarWrap.scrollTop) + this.chart = {} + this.$store.dispatch('clearPanel') }, /* 图表相关操作--start */ addChart (chart) { @@ -278,6 +280,22 @@ export default { this.$refs.addChartModal.isStable = 'stable' }) }, + addText () { + const chart = { + name: '', + type: 'text', + unit: 2, + datasource: 'misc', + span: 12, + height: 4, + w: 12, + h: 4, + x: 0, + y: this.getMaxY(this.$refs.notebookList.copyDataList), + param: this.newChart('text') + } + this.createSuccess(chart) + }, getMaxId (arr) { // 获取当前列表最大的id if (!arr.length) { return 1 @@ -446,13 +464,18 @@ export default { varValue: '', result: 'show' }, - editorType: 'markdown' + editorType: 'markdown', + isEdit: true } break } return param }, addChartBefore (chart) { + // if (chart.type === 'text') { + // this.addText() + // return false + // } this.$store.dispatch('dispatchEditChart', { chart: chart, type: 'add' @@ -485,7 +508,8 @@ export default { this.$store.commit('setNotebookEdit', true) }, download (type) { - console.log(type) + this.showPanel.format = type + this.snapshotVisible = true }, // 获取数据,用在子页面 getData () { diff --git a/nezha-fronted/src/components/common/rightBox/chart/otherChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/otherChartConfig.vue index 907f7081d..b65ac2cd8 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/otherChartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/otherChartConfig.vue @@ -98,7 +98,7 @@ -
+
{{$t('dashboard.dashboard.chartForm.content')}}
@@ -130,7 +130,7 @@ :isChart="true" /> - + diff --git a/nezha-fronted/src/components/common/snapshotProgress/snapshotProgress.vue b/nezha-fronted/src/components/common/snapshotProgress/snapshotProgress.vue index e80ba79e4..00adb4907 100644 --- a/nezha-fronted/src/components/common/snapshotProgress/snapshotProgress.vue +++ b/nezha-fronted/src/components/common/snapshotProgress/snapshotProgress.vue @@ -75,7 +75,8 @@ export default { snapshotVisible: { type: Boolean, default: false - } + }, + api: String }, data () { return { @@ -99,14 +100,18 @@ export default { } }) const params = { - format: 'html', - dashboardId: this.showPanel.id, + format: this.showPanel.format || 'html', start: this.$stringTimeParseToUnix(bus.formateTimeToTime(this.searchTime[0])), - end: this.$stringTimeParseToUnix(bus.formateTimeToTime(this.searchTime[1])), - vars: vars + end: this.$stringTimeParseToUnix(bus.formateTimeToTime(this.searchTime[1])) + } + if (this.api === 'dashboard') { + params.dashboardId = this.showPanel.id + params.vars = vars + } else { + params.id = this.showPanel.id } // 创建任务 - const res = await this.$post('/visual/dashboard/snapshot/task', params) + const res = await this.$post(`/visual/${this.api}/snapshot/task`, params) if (res.code === 200) { // 定时获取运行时间 this.timer = createWorker(() => { @@ -124,7 +129,7 @@ export default { this.task = setInterval(async () => { if (this.process < 100) { try { - const res = await this.$get('/visual/dashboard/snapshot/result/' + this.tid) + const res = await this.$get(`/visual/${this.api}/snapshot/result/` + this.tid) this.total = res.data.taskId.total this.done = res.data.taskId.done this.process = parseFloat(res.data.taskId.process) @@ -140,7 +145,7 @@ export default { downloadSnapshot () { let total = 10 let loaded = 0 - this.$get('/visual/dashboard/snapshot/download/' + this.tid, {}, { + this.$get(`/visual/${this.api}/snapshot/download/` + this.tid, {}, { onDownloadProgress: function (progressEvent) { // 处理原生进度事件 total = progressEvent.total @@ -165,13 +170,13 @@ export default { if (window.navigator.msSaveOrOpenBlob) { // 兼容ie11 const blobObject = new Blob([res]) - window.navigator.msSaveOrOpenBlob(blobObject, fileName + '.html') + window.navigator.msSaveOrOpenBlob(blobObject, fileName + '.' + (this.showPanel.format || 'html')) } else { const blob = new Blob([res]) const link = document.createElement('a') const href = window.URL.createObjectURL(blob) // 下载链接 link.href = href - link.download = fileName + '.html' // 下载后文件名 + link.download = fileName + '.' + (this.showPanel.format || 'html') // 下载后文件名 document.body.appendChild(link) link.click() // 点击下载 document.body.removeChild(link) // 下载完成移除元素 @@ -217,7 +222,7 @@ export default { beforeDestroy () { this.clearTimer() if (this.tid) { - this.$get('/visual/dashboard/snapshot/cancel/' + this.tid) + this.$get(`/visual/${this.api}/snapshot/cancel/` + this.tid) } } } diff --git a/nezha-fronted/src/components/page/dashboard/dashboard.vue b/nezha-fronted/src/components/page/dashboard/dashboard.vue index e11076444..3f1a82a66 100644 --- a/nezha-fronted/src/components/page/dashboard/dashboard.vue +++ b/nezha-fronted/src/components/page/dashboard/dashboard.vue @@ -153,7 +153,7 @@ - +
diff --git a/nezha-fronted/src/entrance/exportHtml/App.vue b/nezha-fronted/src/entrance/exportHtml/App.vue index 3ab0acd77..6f8fbc5c0 100644 --- a/nezha-fronted/src/entrance/exportHtml/App.vue +++ b/nezha-fronted/src/entrance/exportHtml/App.vue @@ -13,8 +13,11 @@
-
{{dataJson.dashboard.data.name}}
-
Explore
+
+ {{dataJson.dashboard.data.name}} + {{dataJson.notebook.data.name}} + Explore +
{{dateFormat(dataJson.start * 1000)}} - {{dateFormat(dataJson.end * 1000)}} ({{dataJson.timezone}})
@@ -47,6 +50,22 @@ > + +
+
+ + +
+
+ @@ -58,6 +77,7 @@