mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
feat: Add clearConfig
This commit is contained in:
parent
a8a4fb1ac5
commit
9fb398e92d
3 changed files with 56 additions and 38 deletions
|
|
@ -20,9 +20,9 @@ limitations under the License.
|
|||
<span style="vertical-align: middle; display: inline-block; margin-top: 3px;">Configured Columns</span>
|
||||
<span style="float: right;">
|
||||
<div class="btn-group" role="group" aria-label="...">
|
||||
<div type="button" ng-click="parameterChanged()"
|
||||
<div type="button" ng-click="clearConfig()"
|
||||
class="btn btn-default" style="padding: 2px 5px 2px 5px;">
|
||||
<i class="fa fa-floppy-o" aria-hidden="true"></i>
|
||||
<i class="fa fa-trash-o" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div type="button" ng-if="config.panel.columnPanelOpened"
|
||||
ng-click="toggleColumnPanel()"
|
||||
|
|
@ -185,6 +185,7 @@ 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-if="config.panel.parameterPanelOpened"
|
||||
ng-click="toggleParameterPanel()"
|
||||
class="btn btn-default" style="padding: 2px 5px 2px 5px;">
|
||||
|
|
|
|||
|
|
@ -15,17 +15,59 @@
|
|||
const lo = _; /** provided by bower */
|
||||
|
||||
export const Aggregator = {
|
||||
SUM: 'sum',
|
||||
COUNT: 'count',
|
||||
AVG: 'avg',
|
||||
MIN: 'min',
|
||||
MAX: 'max',
|
||||
}
|
||||
SUM: 'sum',
|
||||
COUNT: 'count',
|
||||
AVG: 'avg',
|
||||
MIN: 'min',
|
||||
MAX: 'max',
|
||||
}
|
||||
|
||||
export function isAggregator(axisSpec) { return axisSpec.aggregator; }
|
||||
export function isGroup(axisSpec) { return axisSpec.group; }
|
||||
export function isGroupBase(axisSpec) { return axisSpec.groupBase; }
|
||||
export function isSingleDimension(axisSpec) { return axisSpec.dimension === 'single'; }
|
||||
|
||||
export function clearConfig(configInstance) {
|
||||
delete configInstance.panel
|
||||
delete configInstance.axis
|
||||
delete configInstance.parameter
|
||||
|
||||
return configInstance
|
||||
}
|
||||
|
||||
export function initializeConfig(config, axisSpecs, paramSpecs) {
|
||||
config = clearConfig(config)
|
||||
|
||||
/** initialize config.axis */
|
||||
if (!config.axis) { config.axis = {}; }
|
||||
for (let i = 0; i < axisSpecs.length; i++) {
|
||||
const axisSpec = axisSpecs[i];
|
||||
const persistedConfig = config.axis[axisSpec.name];
|
||||
|
||||
// behavior of jqyoui-element depends on its model (ng-model)
|
||||
// so, we have to initialize its underlying ng-model to array if it's not array
|
||||
if (!isSingleDimension(axisSpec) && !Array.isArray(persistedConfig)) {
|
||||
config.axis[axisSpec.name] = [];
|
||||
} else if (isSingleDimension(axisSpec) && Array.isArray(persistedConfig)) {
|
||||
config.axis[axisSpec.name] = {};
|
||||
}
|
||||
}
|
||||
|
||||
/** initialize config.parameter*/
|
||||
if (!config.parameter) { config.parameter = {}; }
|
||||
for (let i = 0; i < paramSpecs.length; i++) {
|
||||
const paramSpec = paramSpecs[i];
|
||||
if (!config.parameter[paramSpec.name]) {
|
||||
config.parameter[paramSpec.name] = paramSpec.defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/** initialize config.panel */
|
||||
if (!config.panel) {
|
||||
config.panel = { columnPanelOpened: true, parameterPanelOpened: true, };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function getGroupAndAggrColumns(axisSpecs, axisConfig) {
|
||||
const groupAxisNames = [];
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import Transformation from './transformation';
|
|||
|
||||
import {
|
||||
isAggregator, isGroup, isGroupBase, isSingleDimension,
|
||||
initializeConfig,
|
||||
groupAndAggregateRows, getGroupAndAggrColumns,
|
||||
} from './advanced-transformation-util';
|
||||
|
||||
|
|
@ -50,34 +51,7 @@ class AdvancedTransformation extends Transformation {
|
|||
}
|
||||
this.paramSpecs = paramSpecs;
|
||||
|
||||
/** initialize config.axis */
|
||||
if (!this.config.axis) { this.config.axis = {}; }
|
||||
for (let i = 0; i < axisSpecs.length; i++) {
|
||||
const axisSpec = axisSpecs[i];
|
||||
const persistedConfig = this.config.axis[axisSpec.name];
|
||||
|
||||
// // behavior of jqyoui-element depends on its model (ng-model)
|
||||
// // so, we have to initialize its underlying ng-model to array if it's not array
|
||||
if (!isSingleDimension(axisSpec) && !Array.isArray(persistedConfig)) {
|
||||
this.config.axis[axisSpec.name] = [];
|
||||
} else if (isSingleDimension(axisSpec) && Array.isArray(persistedConfig)) {
|
||||
this.config.axis[axisSpec.name] = {};
|
||||
}
|
||||
}
|
||||
|
||||
/** initialize config.parameter*/
|
||||
if (!this.config.parameter) { this.config.parameter = {}; }
|
||||
for (let i = 0; i < paramSpecs.length; i++) {
|
||||
const paramSpec = paramSpecs[i];
|
||||
if (!this.config.parameter[paramSpec.name]) {
|
||||
this.config.parameter[paramSpec.name] = paramSpec.defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/** initialize config.panel */
|
||||
if (!this.config.panel) {
|
||||
this.config.panel = { columnPanelOpened: true, parameterPanelOpened: true, };
|
||||
}
|
||||
initializeConfig(this.config, axisSpecs, paramSpecs)
|
||||
}
|
||||
|
||||
getSetting() {
|
||||
|
|
@ -85,7 +59,7 @@ class AdvancedTransformation extends Transformation {
|
|||
/**
|
||||
* config: { axis, parameter }
|
||||
*/
|
||||
const configInstance = self.config; /** for closure */
|
||||
let configInstance = self.config; /** for closure */
|
||||
|
||||
return {
|
||||
template: SETTING_TEMPLATE,
|
||||
|
|
@ -110,7 +84,8 @@ class AdvancedTransformation extends Transformation {
|
|||
},
|
||||
|
||||
clearConfig: () => {
|
||||
|
||||
initializeConfig(configInstance, this.axisSpecs, this.paramSpecs)
|
||||
self.emitConfig(configInstance)
|
||||
},
|
||||
|
||||
toggleParameterPanel: () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue