mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
feat: clear chart, param separately
This commit is contained in:
parent
4d0d62be59
commit
881695a6b4
3 changed files with 55 additions and 49 deletions
|
|
@ -20,7 +20,7 @@ limitations under the License.
|
|||
<span style="vertical-align: middle; display: inline-block; margin-top: 3px;">Charts</span>
|
||||
<span style="float: right;">
|
||||
<div class="btn-group" role="group" aria-label="...">
|
||||
<div type="button" ng-click="clearConfig()"
|
||||
<div type="button" ng-click="clearChartConfig()"
|
||||
class="btn btn-default" style="padding: 2px 5px 2px 5px;">
|
||||
<i class="fa fa-trash-o" aria-hidden="true"></i>
|
||||
</div>
|
||||
|
|
@ -195,7 +195,10 @@ limitations under the License.
|
|||
class="btn btn-default" style="padding: 2px 5px 2px 5px;">
|
||||
<i class="fa fa-floppy-o" aria-hidden="true"></i>
|
||||
</div>
|
||||
|
||||
<div type="button" ng-click="clearParameterConfig()"
|
||||
class="btn btn-default" style="padding: 2px 5px 2px 5px;">
|
||||
<i class="fa fa-trash-o" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div type="button" ng-if="config.panel.parameterPanelOpened"
|
||||
ng-click="toggleParameterPanel()"
|
||||
class="btn btn-default" style="padding: 2px 5px 2px 5px;">
|
||||
|
|
|
|||
|
|
@ -188,49 +188,14 @@ export function removeDuplicatedColumnsInMultiDimensionAxis(config, axisSpec) {
|
|||
return config
|
||||
}
|
||||
|
||||
export function clearPanelConfig(config) {
|
||||
/** DON'T delete `config.panel` directly to avoid annoying behavior */
|
||||
const columnPanelOpened = config.panel.columnPanelOpened
|
||||
const parameterPanelOpened = config.panel.parameterPanelOpened
|
||||
delete config.panel
|
||||
export function clearChartConfig(config) {
|
||||
delete config.axis /** Object: persisted axis for each chart */
|
||||
config.axis = {}
|
||||
|
||||
/** initialize config.panel */
|
||||
config.panel = {
|
||||
columnPanelOpened: columnPanelOpened,
|
||||
parameterPanelOpened: parameterPanelOpened,
|
||||
}
|
||||
}
|
||||
const spec = config.spec
|
||||
const availableCharts = getAvailableChartNames(spec.charts)
|
||||
config.chart.current = availableCharts[0];
|
||||
|
||||
export function clearConfig(config) {
|
||||
delete config.chart; /** Object: contains current, available chart */
|
||||
delete config.spec; /** Object: axis, parameter spec for each chart */
|
||||
clearPanelConfig(config)
|
||||
|
||||
delete config.axis; /** Object: persisted axis for each chart */
|
||||
delete config.parameter; /** Object: persisted parameter for each chart */
|
||||
delete config.axisSpecs; /** Object: persisted axisSpecs for each chart */
|
||||
delete config.paramSpecs; /** Object: persisted paramSpecs for each chart */
|
||||
}
|
||||
|
||||
export function initializeConfig(config, spec) {
|
||||
const currentVersion = JSON.stringify(spec)
|
||||
if (!config.spec || !config.spec.version || config.spec.version !== currentVersion) {
|
||||
spec.version = currentVersion
|
||||
clearConfig(config)
|
||||
}
|
||||
|
||||
const availableCharts = getAvailableChartNames(spec.charts);
|
||||
|
||||
if (!config.spec) { config.spec = spec; }
|
||||
|
||||
if (!config.chart) {
|
||||
config.chart = {};
|
||||
config.chart.current = availableCharts[0];
|
||||
config.chart.available = availableCharts;
|
||||
}
|
||||
|
||||
/** initialize config.axis, config.axisSpecs for each chart */
|
||||
if (!config.axis) { config.axis = {}; }
|
||||
if (!config.axisSpecs) { config.axisSpecs = {}; }
|
||||
for (let i = 0; i < availableCharts.length; i++) {
|
||||
const chartName = availableCharts[i];
|
||||
|
|
@ -247,9 +212,15 @@ export function initializeConfig(config, spec) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function clearParameterConfig(config) {
|
||||
delete config.parameter /** Object: persisted parameter for each chart */
|
||||
config.parameter = {}
|
||||
|
||||
const spec = config.spec
|
||||
const availableCharts = getAvailableChartNames(spec.charts)
|
||||
|
||||
/** initialize config.parameter for each chart */
|
||||
if (!config.parameter) { config.parameter = {}; }
|
||||
if (!config.paramSpecs) { config.paramSpecs = {}; }
|
||||
for (let i = 0; i < availableCharts.length; i++) {
|
||||
const chartName = availableCharts[i];
|
||||
|
|
@ -265,7 +236,35 @@ export function initializeConfig(config, spec) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function initializeConfig(config, spec) {
|
||||
const currentVersion = JSON.stringify(spec)
|
||||
if (!config.spec || !config.spec.version || config.spec.version !== currentVersion) {
|
||||
spec.version = currentVersion
|
||||
delete config.chart /** Object: contains current, available chart */
|
||||
delete config.spec /** Object: axis, parameter spec for each chart */
|
||||
config.panel = { columnPanelOpened: true, parameterPanelOpened: true, }
|
||||
|
||||
delete config.axisSpecs /** Object: persisted axisSpecs for each chart */
|
||||
delete config.paramSpecs /** Object: persisted paramSpecs for each chart */
|
||||
}
|
||||
|
||||
const availableCharts = getAvailableChartNames(spec.charts)
|
||||
|
||||
if (!config.spec) { config.spec = spec; }
|
||||
|
||||
if (!config.chart) {
|
||||
config.chart = {};
|
||||
config.chart.current = availableCharts[0];
|
||||
config.chart.available = availableCharts;
|
||||
}
|
||||
|
||||
/** initialize config.axis, config.axisSpecs for each chart */
|
||||
clearChartConfig(config)
|
||||
|
||||
/** initialize config.parameter for each chart */
|
||||
clearParameterConfig(config)
|
||||
return config
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ import Transformation from './transformation';
|
|||
import {
|
||||
getCurrentChart, getCurrentChartAxis, getCurrentChartParam,
|
||||
getCurrentChartAxisSpecs, getCurrentChartParamSpecs,
|
||||
initializeConfig, clearChartConfig, clearParameterConfig,
|
||||
isAggregatorAxis, isGroupAxis, isKeyAxis, isSingleDimensionAxis,
|
||||
clearConfig, initializeConfig,
|
||||
removeDuplicatedColumnsInMultiDimensionAxis, applyMaxAxisCount, getColumnsFromAxis,
|
||||
getTransformer,
|
||||
isInputWidget, isOptionWidget, isCheckboxWidget, isTextareaWidget, parseParameter,
|
||||
|
|
@ -47,9 +47,13 @@ class AdvancedTransformation extends Transformation {
|
|||
config: configInstance,
|
||||
columns: self.columns,
|
||||
|
||||
clearConfig: () => {
|
||||
clearConfig(configInstance)
|
||||
initializeConfig(configInstance, self.spec)
|
||||
clearChartConfig: () => {
|
||||
clearChartConfig(configInstance)
|
||||
self.emitConfig(configInstance)
|
||||
},
|
||||
|
||||
clearParameterConfig: () => {
|
||||
clearParameterConfig(configInstance)
|
||||
self.emitConfig(configInstance)
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue