-
Notifications
You must be signed in to change notification settings - Fork 503
feat(viewer): add advanced dashboard view with widget configuration #1987
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
muzaffarmhd
wants to merge
3
commits into
emqx:prepare/1.13.0
Choose a base branch
from
muzaffarmhd:feat/dashboard-view
base: prepare/1.13.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+6,650
−10
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| <template> | ||
| <div class="key-value-editor"> | ||
| <div class="editor-header"> | ||
| <div class="header-left"> | ||
| <span class="editor-title"> {{ title }} </span> | ||
| <el-select | ||
| v-model="localThresholdsType" | ||
| size="mini" | ||
| placeholder="Select type" | ||
| style="margin-left: 10px" | ||
| @change="emitThresholdsTypeChange" | ||
| > | ||
| <el-option label="Absolute" value="Absolute" /> | ||
| <el-option label="Percentage" value="Percentage" /> | ||
| </el-select> | ||
| <el-button | ||
| icon="el-icon-plus" | ||
| class="btn-props-plus" | ||
| type="text" | ||
| @click="addThreshold" | ||
| style="margin-left: 10px" | ||
| ></el-button> | ||
| </div> | ||
| </div> | ||
| <div class="editor-row"> | ||
| <el-row v-for="(threshold, index) in localThresholds" :key="index" :gutter="10" class="editor-row"> | ||
| <el-col :span="10"> | ||
| <el-input | ||
| type="number" | ||
| v-model.number="threshold.value" | ||
| size="mini" | ||
| placeholder="Value" | ||
| @input="onThresholdChange" | ||
| /> | ||
| </el-col> | ||
| <el-col :span="4"> | ||
| <el-color-picker v-model="threshold.color" size="mini" color-format="hex" @change="onThresholdChange" /> | ||
| </el-col> | ||
| <el-col :span="4"> | ||
| <el-button icon="el-icon-delete" class="btn-delete" type="text" @click="removeThreshold(index)" /> | ||
| </el-col> | ||
| </el-row> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| import { Component, Vue, Prop, Watch } from 'vue-property-decorator' | ||
|
|
||
| @Component | ||
| export default class ThresholdEditor extends Vue { | ||
| @Prop({ type: String, default: 'Thresholds' }) readonly title!: string | ||
| @Prop({ type: Array, default: () => [] }) readonly value!: Array<{ value: number; color: string }> | ||
| @Prop({ type: String, default: 'Absolute' }) readonly thresholdsType!: 'Absolute' | 'Percentage' | ||
|
|
||
| private localThresholds: Array<{ value: number; color: string }> = [] | ||
| private localThresholdsType: 'Absolute' | 'Percentage' = 'Absolute' | ||
|
|
||
| mounted() { | ||
| this.initializeLocalData() | ||
| } | ||
|
|
||
| @Watch('value', { deep: true, immediate: true }) | ||
| onValueChange(newValue: Array<{ value: number; color: string }>) { | ||
| if (JSON.stringify(this.localThresholds) !== JSON.stringify(newValue)) { | ||
| this.localThresholds = [...(newValue || [])] | ||
| } | ||
| } | ||
|
|
||
| @Watch('thresholdsType', { immediate: true }) | ||
| onThresholdsTypeChange(newType: 'Absolute' | 'Percentage') { | ||
| this.localThresholdsType = newType | ||
| } | ||
|
|
||
| private initializeLocalData() { | ||
| this.localThresholds = [...(this.value || [])] | ||
| this.localThresholdsType = this.thresholdsType | ||
| } | ||
|
|
||
| private addThreshold() { | ||
| this.localThresholds.push({ value: 0, color: '#FF0000' }) | ||
| this.emitChange() | ||
| } | ||
|
|
||
| private removeThreshold(index: number) { | ||
| this.localThresholds.splice(index, 1) | ||
| this.emitChange() | ||
| } | ||
|
|
||
| private onThresholdChange() { | ||
| this.emitChange() | ||
| } | ||
|
|
||
| private emitThresholdsTypeChange() { | ||
| this.$emit('update:thresholdsType', this.localThresholdsType) | ||
| } | ||
|
|
||
| private emitChange() { | ||
| this.$emit('input', [...this.localThresholds]) | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .key-value-editor { | ||
| .editor-header { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| .header-left { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
| .editor-title { | ||
| font-weight: 600; | ||
| color: var(--color-text-default); | ||
| } | ||
| } | ||
| .editor-row { | ||
| margin-top: 10px; | ||
| .el-col { | ||
| display: flex; | ||
| align-items: center; | ||
| } | ||
| } | ||
| .btn-props-plus { | ||
| font-size: 12px; | ||
| } | ||
| .btn-delete { | ||
| color: var(--color-text-light); | ||
| } | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this new component created because the built-in key value editor couldn't satisfy the needs?