@cubejs-client/vue3 0.30.60 → 0.30.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cubejs-client-vue3.esm.js +451 -654
- package/dist/cubejs-client-vue3.esm.js.map +1 -1
- package/dist/cubejs-client-vue3.umd.js +3858 -3908
- package/dist/cubejs-client-vue3.umd.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,46 +1,13 @@
|
|
|
1
1
|
import { isQueryPresent, areQueriesEqual, GRANULARITIES, ResultSet, moveItemInArray, movePivotItem, getOrderMembersFromOrder, defaultHeuristics, defaultOrder } from '@cubejs-client/core';
|
|
2
2
|
export { GRANULARITIES } from '@cubejs-client/core';
|
|
3
|
-
import 'core-js/modules/es.object.keys.js';
|
|
4
|
-
import 'core-js/modules/es.symbol.js';
|
|
5
|
-
import 'core-js/modules/es.array.filter.js';
|
|
6
|
-
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
|
-
import 'core-js/modules/es.array.for-each.js';
|
|
8
|
-
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
9
|
-
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
10
|
-
import 'core-js/modules/es.object.define-properties.js';
|
|
11
|
-
import 'core-js/modules/es.object.define-property.js';
|
|
12
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
13
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
14
|
-
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
15
|
-
import 'core-js/modules/es.array.iterator.js';
|
|
16
|
-
import 'core-js/modules/es.object.to-string.js';
|
|
17
|
-
import 'core-js/modules/es.promise.js';
|
|
18
|
-
import 'core-js/modules/es.string.iterator.js';
|
|
19
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
20
|
-
import 'core-js/modules/es.array.map.js';
|
|
21
|
-
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
22
3
|
import { toPairs, fromPairs, clone, equals } from 'ramda';
|
|
23
4
|
import { h } from 'vue';
|
|
24
|
-
|
|
25
|
-
import 'core-js/modules/es.function.name.js';
|
|
26
|
-
import 'core-js/modules/es.array.reduce.js';
|
|
27
|
-
import 'core-js/modules/es.array.concat.js';
|
|
28
|
-
import 'core-js/modules/es.array.some.js';
|
|
29
|
-
import 'core-js/modules/es.array.slice.js';
|
|
30
|
-
import 'core-js/modules/es.array.find.js';
|
|
31
|
-
import 'core-js/modules/es.array.find-index.js';
|
|
32
|
-
import 'core-js/modules/es.array.splice.js';
|
|
33
|
-
|
|
34
|
-
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
35
|
-
|
|
36
|
-
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
|
+
|
|
37
6
|
var QueryRenderer = {
|
|
38
7
|
props: {
|
|
39
8
|
query: {
|
|
40
9
|
type: [Object, Array],
|
|
41
|
-
|
|
42
|
-
return {};
|
|
43
|
-
}
|
|
10
|
+
default: () => ({})
|
|
44
11
|
},
|
|
45
12
|
// TODO: validate with current react implementation
|
|
46
13
|
queries: {
|
|
@@ -56,16 +23,15 @@ var QueryRenderer = {
|
|
|
56
23
|
builderProps: {
|
|
57
24
|
type: Object,
|
|
58
25
|
required: false,
|
|
59
|
-
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
26
|
+
default: () => ({})
|
|
62
27
|
},
|
|
63
28
|
chartType: {
|
|
64
29
|
type: String,
|
|
65
30
|
required: false
|
|
66
31
|
}
|
|
67
32
|
},
|
|
68
|
-
|
|
33
|
+
|
|
34
|
+
data() {
|
|
69
35
|
return {
|
|
70
36
|
mutexObj: {},
|
|
71
37
|
error: undefined,
|
|
@@ -74,236 +40,134 @@ var QueryRenderer = {
|
|
|
74
40
|
sqlQuery: undefined
|
|
75
41
|
};
|
|
76
42
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
_context.next = 6;
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
_context.next = 4;
|
|
94
|
-
return _this.load();
|
|
95
|
-
|
|
96
|
-
case 4:
|
|
97
|
-
_context.next = 9;
|
|
98
|
-
break;
|
|
99
|
-
|
|
100
|
-
case 6:
|
|
101
|
-
if (!isQueryPresent(queries)) {
|
|
102
|
-
_context.next = 9;
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
_context.next = 9;
|
|
107
|
-
return _this.loadQueries(queries);
|
|
108
|
-
|
|
109
|
-
case 9:
|
|
110
|
-
case "end":
|
|
111
|
-
return _context.stop();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}, _callee);
|
|
115
|
-
}))();
|
|
43
|
+
|
|
44
|
+
async mounted() {
|
|
45
|
+
const {
|
|
46
|
+
query,
|
|
47
|
+
queries
|
|
48
|
+
} = this;
|
|
49
|
+
|
|
50
|
+
if (isQueryPresent(query)) {
|
|
51
|
+
await this.load();
|
|
52
|
+
} else if (isQueryPresent(queries)) {
|
|
53
|
+
await this.loadQueries(queries);
|
|
54
|
+
}
|
|
116
55
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
56
|
+
|
|
57
|
+
render() {
|
|
58
|
+
const {
|
|
59
|
+
$slots,
|
|
60
|
+
resultSet,
|
|
61
|
+
error,
|
|
62
|
+
loading,
|
|
63
|
+
sqlQuery
|
|
64
|
+
} = this;
|
|
65
|
+
const empty = h('div', {});
|
|
66
|
+
let slot = this.$slots.empty ? this.$slots.empty() : empty;
|
|
67
|
+
let controls = h('div', {});
|
|
68
|
+
const onlyDefault = !('empty' in this.$slots) && !('error' in this.$slots);
|
|
127
69
|
|
|
128
70
|
if ($slots.builder && this.builderProps.measures) {
|
|
129
|
-
controls = $slots.builder(
|
|
71
|
+
controls = $slots.builder({ ...this.builderProps
|
|
72
|
+
});
|
|
130
73
|
}
|
|
131
74
|
|
|
132
75
|
if (!loading && resultSet && !error || onlyDefault) {
|
|
133
|
-
|
|
134
|
-
resultSet
|
|
135
|
-
sqlQuery
|
|
76
|
+
let slotProps = {
|
|
77
|
+
resultSet,
|
|
78
|
+
sqlQuery,
|
|
136
79
|
query: this.builderProps.query || this.query
|
|
137
80
|
};
|
|
138
81
|
|
|
139
82
|
if (onlyDefault) {
|
|
140
|
-
slotProps =
|
|
141
|
-
loading
|
|
142
|
-
error
|
|
143
|
-
refetch: this.load
|
|
144
|
-
|
|
83
|
+
slotProps = {
|
|
84
|
+
loading,
|
|
85
|
+
error,
|
|
86
|
+
refetch: this.load,
|
|
87
|
+
...this.builderProps,
|
|
88
|
+
...slotProps
|
|
89
|
+
};
|
|
145
90
|
}
|
|
146
91
|
|
|
147
|
-
slot = $slots
|
|
92
|
+
slot = $slots.default ? $slots.default(slotProps) : slot;
|
|
148
93
|
} else if (error) {
|
|
149
94
|
slot = $slots.error ? $slots.error({
|
|
150
|
-
error
|
|
151
|
-
sqlQuery
|
|
95
|
+
error,
|
|
96
|
+
sqlQuery
|
|
152
97
|
}) : slot;
|
|
153
98
|
}
|
|
154
99
|
|
|
155
100
|
return h('div', {}, [controls, slot]);
|
|
156
101
|
},
|
|
102
|
+
|
|
157
103
|
methods: {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (!_this2.loadSql) {
|
|
200
|
-
_context2.next = 22;
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
_context2.next = 16;
|
|
205
|
-
return _this2.cubejsApi.sql(query, {
|
|
206
|
-
mutexObj: _this2.mutexObj,
|
|
207
|
-
mutexKey: 'sql'
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
case 16:
|
|
211
|
-
_this2.sqlQuery = _context2.sent;
|
|
212
|
-
_context2.next = 19;
|
|
213
|
-
return _this2.cubejsApi.load(query, {
|
|
214
|
-
mutexObj: _this2.mutexObj,
|
|
215
|
-
mutexKey: 'query'
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
case 19:
|
|
219
|
-
_this2.resultSet = _context2.sent;
|
|
220
|
-
_context2.next = 25;
|
|
221
|
-
break;
|
|
222
|
-
|
|
223
|
-
case 22:
|
|
224
|
-
_context2.next = 24;
|
|
225
|
-
return _this2.cubejsApi.load(query, {
|
|
226
|
-
mutexObj: _this2.mutexObj,
|
|
227
|
-
mutexKey: 'query'
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
case 24:
|
|
231
|
-
_this2.resultSet = _context2.sent;
|
|
232
|
-
|
|
233
|
-
case 25:
|
|
234
|
-
_this2.loading = false;
|
|
235
|
-
_context2.next = 33;
|
|
236
|
-
break;
|
|
237
|
-
|
|
238
|
-
case 28:
|
|
239
|
-
_context2.prev = 28;
|
|
240
|
-
_context2.t0 = _context2["catch"](3);
|
|
241
|
-
_this2.error = _context2.t0;
|
|
242
|
-
_this2.resultSet = undefined;
|
|
243
|
-
_this2.loading = false;
|
|
244
|
-
|
|
245
|
-
case 33:
|
|
246
|
-
case "end":
|
|
247
|
-
return _context2.stop();
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}, _callee2, null, [[3, 28]]);
|
|
251
|
-
}))();
|
|
104
|
+
async load() {
|
|
105
|
+
const {
|
|
106
|
+
query
|
|
107
|
+
} = this;
|
|
108
|
+
|
|
109
|
+
if (!isQueryPresent(query)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
this.loading = true;
|
|
115
|
+
this.error = null;
|
|
116
|
+
this.resultSet = null;
|
|
117
|
+
|
|
118
|
+
if (this.loadSql === 'only') {
|
|
119
|
+
this.sqlQuery = await this.cubejsApi.sql(query, {
|
|
120
|
+
mutexObj: this.mutexObj,
|
|
121
|
+
mutexKey: 'sql'
|
|
122
|
+
});
|
|
123
|
+
} else if (this.loadSql) {
|
|
124
|
+
this.sqlQuery = await this.cubejsApi.sql(query, {
|
|
125
|
+
mutexObj: this.mutexObj,
|
|
126
|
+
mutexKey: 'sql'
|
|
127
|
+
});
|
|
128
|
+
this.resultSet = await this.cubejsApi.load(query, {
|
|
129
|
+
mutexObj: this.mutexObj,
|
|
130
|
+
mutexKey: 'query'
|
|
131
|
+
});
|
|
132
|
+
} else {
|
|
133
|
+
this.resultSet = await this.cubejsApi.load(query, {
|
|
134
|
+
mutexObj: this.mutexObj,
|
|
135
|
+
mutexKey: 'query'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
this.loading = false;
|
|
140
|
+
} catch (error) {
|
|
141
|
+
this.error = error;
|
|
142
|
+
this.resultSet = undefined;
|
|
143
|
+
this.loading = false;
|
|
144
|
+
}
|
|
252
145
|
},
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
mutexObj: _this3.mutexObj,
|
|
273
|
-
mutexKey: name
|
|
274
|
-
}).then(function (r) {
|
|
275
|
-
return [name, r];
|
|
276
|
-
});
|
|
277
|
-
}));
|
|
278
|
-
_context3.t0 = fromPairs;
|
|
279
|
-
_context3.next = 8;
|
|
280
|
-
return resultPromises;
|
|
281
|
-
|
|
282
|
-
case 8:
|
|
283
|
-
_context3.t1 = _context3.sent;
|
|
284
|
-
_this3.resultSet = (0, _context3.t0)(_context3.t1);
|
|
285
|
-
_this3.loading = false;
|
|
286
|
-
_context3.next = 17;
|
|
287
|
-
break;
|
|
288
|
-
|
|
289
|
-
case 13:
|
|
290
|
-
_context3.prev = 13;
|
|
291
|
-
_context3.t2 = _context3["catch"](1);
|
|
292
|
-
_this3.error = _context3.t2;
|
|
293
|
-
_this3.loading = false;
|
|
294
|
-
|
|
295
|
-
case 17:
|
|
296
|
-
case "end":
|
|
297
|
-
return _context3.stop();
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}, _callee3, null, [[1, 13]]);
|
|
301
|
-
}))();
|
|
146
|
+
|
|
147
|
+
async loadQueries() {
|
|
148
|
+
const {
|
|
149
|
+
queries
|
|
150
|
+
} = this;
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
this.error = undefined;
|
|
154
|
+
this.loading = true;
|
|
155
|
+
const resultPromises = Promise.all(toPairs(queries).map(([name, query]) => this.cubejsApi.load(query, {
|
|
156
|
+
mutexObj: this.mutexObj,
|
|
157
|
+
mutexKey: name
|
|
158
|
+
}).then(r => [name, r])));
|
|
159
|
+
this.resultSet = fromPairs(await resultPromises);
|
|
160
|
+
this.loading = false;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
this.error = error;
|
|
163
|
+
this.loading = false;
|
|
164
|
+
}
|
|
302
165
|
}
|
|
166
|
+
|
|
303
167
|
},
|
|
304
168
|
watch: {
|
|
305
|
-
loading
|
|
306
|
-
if (
|
|
169
|
+
loading(loading) {
|
|
170
|
+
if (loading === false) {
|
|
307
171
|
this.$emit('queryStatus', {
|
|
308
172
|
isLoading: false,
|
|
309
173
|
error: this.error,
|
|
@@ -315,106 +179,98 @@ var QueryRenderer = {
|
|
|
315
179
|
});
|
|
316
180
|
}
|
|
317
181
|
},
|
|
318
|
-
|
|
182
|
+
|
|
183
|
+
cubejsApi() {
|
|
319
184
|
this.load();
|
|
320
185
|
},
|
|
321
|
-
|
|
186
|
+
|
|
187
|
+
chartType() {
|
|
322
188
|
this.load();
|
|
323
189
|
},
|
|
190
|
+
|
|
324
191
|
query: {
|
|
325
192
|
deep: true,
|
|
326
|
-
|
|
193
|
+
|
|
194
|
+
handler(query, prevQuery) {
|
|
327
195
|
if (!areQueriesEqual(query, prevQuery)) {
|
|
328
196
|
this.load();
|
|
329
197
|
}
|
|
330
198
|
}
|
|
199
|
+
|
|
331
200
|
},
|
|
332
201
|
queries: {
|
|
333
|
-
handler
|
|
202
|
+
handler(val) {
|
|
334
203
|
if (val) {
|
|
335
204
|
this.loadQueries();
|
|
336
205
|
}
|
|
337
206
|
},
|
|
207
|
+
|
|
338
208
|
deep: true
|
|
339
209
|
}
|
|
340
210
|
}
|
|
341
211
|
};
|
|
342
212
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
346
|
-
var QUERY_ELEMENTS = ['measures', 'dimensions', 'segments', 'timeDimensions', 'filters'];
|
|
347
|
-
|
|
348
|
-
var toOrderMember = function toOrderMember(member) {
|
|
349
|
-
return {
|
|
350
|
-
id: member.name,
|
|
351
|
-
title: member.title
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
|
|
355
|
-
var reduceOrderMembers = function reduceOrderMembers(array) {
|
|
356
|
-
return array.reduce(function (acc, _ref) {
|
|
357
|
-
var id = _ref.id,
|
|
358
|
-
order = _ref.order;
|
|
359
|
-
return order !== 'none' ? [].concat(_toConsumableArray(acc), [[id, order]]) : acc;
|
|
360
|
-
}, []);
|
|
361
|
-
};
|
|
213
|
+
const QUERY_ELEMENTS = ['measures', 'dimensions', 'segments', 'timeDimensions', 'filters'];
|
|
362
214
|
|
|
363
|
-
|
|
215
|
+
const toOrderMember = member => ({
|
|
216
|
+
id: member.name,
|
|
217
|
+
title: member.title
|
|
218
|
+
});
|
|
364
219
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
220
|
+
const reduceOrderMembers = array => array.reduce((acc, {
|
|
221
|
+
id,
|
|
222
|
+
order
|
|
223
|
+
}) => order !== 'none' ? [...acc, [id, order]] : acc, []);
|
|
370
224
|
|
|
371
|
-
|
|
372
|
-
var filters = raw[operator];
|
|
373
|
-
var booleanFilters = validateFilters(filters || []);
|
|
225
|
+
const operators = ['and', 'or'];
|
|
374
226
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
227
|
+
const validateFilters = filters => filters.reduce((acc, raw) => {
|
|
228
|
+
if (raw.operator) {
|
|
229
|
+
return [...acc, raw];
|
|
230
|
+
}
|
|
378
231
|
|
|
379
|
-
|
|
380
|
-
|
|
232
|
+
const validBooleanFilter = operators.reduce((acc, operator) => {
|
|
233
|
+
const filters = raw[operator];
|
|
234
|
+
const booleanFilters = validateFilters(filters || []);
|
|
381
235
|
|
|
382
|
-
if (
|
|
383
|
-
return
|
|
384
|
-
|
|
385
|
-
|
|
236
|
+
if (booleanFilters.length) {
|
|
237
|
+
return { ...acc,
|
|
238
|
+
[operator]: booleanFilters
|
|
239
|
+
};
|
|
386
240
|
}
|
|
387
241
|
|
|
388
242
|
return acc;
|
|
389
|
-
},
|
|
390
|
-
};
|
|
243
|
+
}, {});
|
|
391
244
|
|
|
392
|
-
|
|
393
|
-
|
|
245
|
+
if (operators.some(operator => validBooleanFilter[operator])) {
|
|
246
|
+
return [...acc, validBooleanFilter];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return acc;
|
|
250
|
+
}, []);
|
|
251
|
+
|
|
252
|
+
const getDimensionOrMeasure = (meta, m) => {
|
|
253
|
+
const memberName = m.member || m.dimension;
|
|
394
254
|
return memberName && meta.resolveMember(memberName, ['dimensions', 'measures']);
|
|
395
255
|
};
|
|
396
256
|
|
|
397
|
-
|
|
398
|
-
return
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
});
|
|
406
|
-
};
|
|
257
|
+
const resolveMembers = (meta, arr) => arr && arr.map((e, index) => {
|
|
258
|
+
return { ...e,
|
|
259
|
+
member: getDimensionOrMeasure(meta, e),
|
|
260
|
+
index,
|
|
261
|
+
and: resolveMembers(meta, e.and),
|
|
262
|
+
or: resolveMembers(meta, e.or)
|
|
263
|
+
};
|
|
264
|
+
});
|
|
407
265
|
|
|
408
266
|
var QueryBuilder = {
|
|
409
267
|
components: {
|
|
410
|
-
QueryRenderer
|
|
268
|
+
QueryRenderer
|
|
411
269
|
},
|
|
412
270
|
props: {
|
|
413
271
|
query: {
|
|
414
272
|
type: Object,
|
|
415
|
-
|
|
416
|
-
return {};
|
|
417
|
-
}
|
|
273
|
+
default: () => ({})
|
|
418
274
|
},
|
|
419
275
|
cubejsApi: {
|
|
420
276
|
type: Object,
|
|
@@ -422,9 +278,7 @@ var QueryBuilder = {
|
|
|
422
278
|
},
|
|
423
279
|
initialChartType: {
|
|
424
280
|
type: String,
|
|
425
|
-
|
|
426
|
-
return 'line';
|
|
427
|
-
}
|
|
281
|
+
default: () => 'line'
|
|
428
282
|
},
|
|
429
283
|
disableHeuristics: {
|
|
430
284
|
type: Boolean
|
|
@@ -434,24 +288,22 @@ var QueryBuilder = {
|
|
|
434
288
|
},
|
|
435
289
|
initialVizState: {
|
|
436
290
|
type: Object,
|
|
437
|
-
|
|
438
|
-
return {};
|
|
439
|
-
}
|
|
291
|
+
default: () => ({})
|
|
440
292
|
}
|
|
441
293
|
},
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
294
|
+
|
|
295
|
+
data() {
|
|
296
|
+
const {
|
|
297
|
+
query = this.query,
|
|
298
|
+
chartType = this.initialChartType,
|
|
299
|
+
pivotConfig
|
|
300
|
+
} = this.initialVizState;
|
|
449
301
|
return {
|
|
450
302
|
initialQuery: query,
|
|
451
303
|
skipHeuristics: true,
|
|
452
304
|
meta: undefined,
|
|
453
305
|
mutex: {},
|
|
454
|
-
chartType
|
|
306
|
+
chartType,
|
|
455
307
|
measures: [],
|
|
456
308
|
dimensions: [],
|
|
457
309
|
segments: [],
|
|
@@ -470,192 +322,187 @@ var QueryBuilder = {
|
|
|
470
322
|
pivotConfig: ResultSet.getNormalizedPivotConfig(query || {}, pivotConfig)
|
|
471
323
|
};
|
|
472
324
|
},
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
325
|
+
|
|
326
|
+
render() {
|
|
327
|
+
const {
|
|
328
|
+
chartType,
|
|
329
|
+
cubejsApi,
|
|
330
|
+
dimensions,
|
|
331
|
+
filters,
|
|
332
|
+
measures,
|
|
333
|
+
meta,
|
|
334
|
+
query,
|
|
335
|
+
segments,
|
|
336
|
+
timeDimensions,
|
|
337
|
+
validatedQuery,
|
|
338
|
+
isQueryPresent,
|
|
339
|
+
availableSegments,
|
|
340
|
+
availableTimeDimensions,
|
|
341
|
+
availableDimensions,
|
|
342
|
+
availableMeasures,
|
|
343
|
+
limit,
|
|
344
|
+
offset,
|
|
345
|
+
setLimit,
|
|
346
|
+
removeLimit,
|
|
347
|
+
setOffset,
|
|
348
|
+
removeOffset,
|
|
349
|
+
renewQuery,
|
|
350
|
+
order,
|
|
351
|
+
orderMembers
|
|
352
|
+
} = this;
|
|
353
|
+
let builderProps = {};
|
|
501
354
|
|
|
502
355
|
if (meta) {
|
|
503
356
|
builderProps = {
|
|
504
|
-
query
|
|
505
|
-
validatedQuery
|
|
506
|
-
isQueryPresent
|
|
507
|
-
chartType
|
|
508
|
-
measures
|
|
509
|
-
dimensions
|
|
510
|
-
segments
|
|
511
|
-
timeDimensions
|
|
512
|
-
filters
|
|
513
|
-
availableSegments
|
|
514
|
-
availableTimeDimensions
|
|
515
|
-
availableDimensions
|
|
516
|
-
availableMeasures
|
|
357
|
+
query,
|
|
358
|
+
validatedQuery,
|
|
359
|
+
isQueryPresent,
|
|
360
|
+
chartType,
|
|
361
|
+
measures,
|
|
362
|
+
dimensions,
|
|
363
|
+
segments,
|
|
364
|
+
timeDimensions,
|
|
365
|
+
filters,
|
|
366
|
+
availableSegments,
|
|
367
|
+
availableTimeDimensions,
|
|
368
|
+
availableDimensions,
|
|
369
|
+
availableMeasures,
|
|
517
370
|
updateChartType: this.updateChart,
|
|
518
|
-
limit
|
|
519
|
-
offset
|
|
520
|
-
setLimit
|
|
521
|
-
removeLimit
|
|
522
|
-
setOffset
|
|
523
|
-
removeOffset
|
|
524
|
-
renewQuery
|
|
525
|
-
order
|
|
526
|
-
orderMembers
|
|
371
|
+
limit,
|
|
372
|
+
offset,
|
|
373
|
+
setLimit,
|
|
374
|
+
removeLimit,
|
|
375
|
+
setOffset,
|
|
376
|
+
removeOffset,
|
|
377
|
+
renewQuery,
|
|
378
|
+
order,
|
|
379
|
+
orderMembers,
|
|
527
380
|
setOrder: this.setOrder,
|
|
528
381
|
pivotConfig: this.pivotConfig,
|
|
529
382
|
updateOrder: {
|
|
530
|
-
set:
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
});
|
|
535
|
-
}));
|
|
383
|
+
set: (memberId, newOrder) => {
|
|
384
|
+
this.order = reduceOrderMembers(orderMembers.map(orderMember => ({ ...orderMember,
|
|
385
|
+
order: orderMember.id === memberId ? newOrder : orderMember.order
|
|
386
|
+
})));
|
|
536
387
|
},
|
|
537
|
-
update:
|
|
538
|
-
|
|
388
|
+
update: newOrder => {
|
|
389
|
+
this.order = newOrder;
|
|
539
390
|
},
|
|
540
|
-
reorder:
|
|
541
|
-
|
|
391
|
+
reorder: (sourceIndex, destinationIndex) => {
|
|
392
|
+
this.order = reduceOrderMembers(moveItemInArray(orderMembers, sourceIndex, destinationIndex));
|
|
542
393
|
}
|
|
543
394
|
},
|
|
544
395
|
updatePivotConfig: {
|
|
545
|
-
moveItem:
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
396
|
+
moveItem: ({
|
|
397
|
+
sourceIndex,
|
|
398
|
+
destinationIndex,
|
|
399
|
+
sourceAxis,
|
|
400
|
+
destinationAxis
|
|
401
|
+
}) => {
|
|
402
|
+
this.pivotConfig = movePivotItem(this.pivotConfig, sourceIndex, destinationIndex, sourceAxis, destinationAxis);
|
|
551
403
|
},
|
|
552
|
-
update:
|
|
553
|
-
|
|
554
|
-
x: pivotConfig.x ||
|
|
555
|
-
y: pivotConfig.y ||
|
|
404
|
+
update: pivotConfig => {
|
|
405
|
+
this.pivotConfig = {
|
|
406
|
+
x: pivotConfig.x || this.pivotConfig.x,
|
|
407
|
+
y: pivotConfig.y || this.pivotConfig.y
|
|
556
408
|
};
|
|
557
409
|
}
|
|
558
410
|
}
|
|
559
411
|
};
|
|
560
|
-
QUERY_ELEMENTS.forEach(
|
|
561
|
-
|
|
412
|
+
QUERY_ELEMENTS.forEach(elementName => {
|
|
413
|
+
const name = elementName.charAt(0).toUpperCase() + elementName.slice(1);
|
|
562
414
|
|
|
563
|
-
builderProps[
|
|
564
|
-
|
|
415
|
+
builderProps[`add${name}`] = member => {
|
|
416
|
+
this.addMember(elementName, member);
|
|
565
417
|
};
|
|
566
418
|
|
|
567
|
-
builderProps[
|
|
568
|
-
|
|
419
|
+
builderProps[`update${name}`] = (member, updateWith) => {
|
|
420
|
+
this.updateMember(elementName, member, updateWith);
|
|
569
421
|
};
|
|
570
422
|
|
|
571
|
-
builderProps[
|
|
572
|
-
|
|
423
|
+
builderProps[`remove${name}`] = member => {
|
|
424
|
+
this.removeMember(elementName, member);
|
|
573
425
|
};
|
|
574
426
|
|
|
575
|
-
builderProps[
|
|
576
|
-
|
|
427
|
+
builderProps[`set${name}`] = members => {
|
|
428
|
+
this.setMembers(elementName, members);
|
|
577
429
|
};
|
|
578
430
|
});
|
|
579
431
|
}
|
|
580
432
|
|
|
581
433
|
return h(QueryRenderer, {
|
|
582
434
|
query: this.validatedQuery,
|
|
583
|
-
cubejsApi
|
|
584
|
-
builderProps
|
|
435
|
+
cubejsApi,
|
|
436
|
+
builderProps,
|
|
585
437
|
slots: this.$slots,
|
|
586
438
|
on: {
|
|
587
|
-
queryStatus:
|
|
588
|
-
|
|
439
|
+
queryStatus: event => {
|
|
440
|
+
this.$emit('queryStatus', event);
|
|
589
441
|
}
|
|
590
442
|
}
|
|
591
443
|
}, this.$slots);
|
|
592
444
|
},
|
|
445
|
+
|
|
593
446
|
computed: {
|
|
594
|
-
isQueryPresent
|
|
595
|
-
|
|
447
|
+
isQueryPresent() {
|
|
448
|
+
const {
|
|
449
|
+
validatedQuery
|
|
450
|
+
} = this;
|
|
596
451
|
return isQueryPresent(validatedQuery);
|
|
597
452
|
},
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
}))).map(
|
|
603
|
-
|
|
453
|
+
|
|
454
|
+
orderMembers() {
|
|
455
|
+
return getOrderMembersFromOrder([...this.measures, ...this.dimensions, ...this.timeDimensions.map(({
|
|
456
|
+
dimension
|
|
457
|
+
}) => toOrderMember(dimension))].map((member, index) => {
|
|
458
|
+
const id = member.name || member.id;
|
|
604
459
|
|
|
605
460
|
if (!id) {
|
|
606
461
|
return false;
|
|
607
462
|
}
|
|
608
463
|
|
|
609
464
|
return {
|
|
610
|
-
index
|
|
611
|
-
id
|
|
465
|
+
index,
|
|
466
|
+
id,
|
|
612
467
|
title: member.title
|
|
613
468
|
};
|
|
614
469
|
}).filter(Boolean), this.order);
|
|
615
470
|
},
|
|
616
|
-
|
|
471
|
+
|
|
472
|
+
vizState() {
|
|
617
473
|
return {
|
|
618
474
|
query: this.validatedQuery,
|
|
619
475
|
chartType: this.chartType,
|
|
620
476
|
pivotConfig: this.pivotConfig
|
|
621
477
|
};
|
|
622
478
|
},
|
|
623
|
-
validatedQuery: function validatedQuery() {
|
|
624
|
-
var _this2 = this;
|
|
625
479
|
|
|
626
|
-
|
|
480
|
+
validatedQuery() {
|
|
481
|
+
let validatedQuery = {};
|
|
627
482
|
|
|
628
|
-
|
|
629
|
-
return member.name;
|
|
630
|
-
}; // TODO: implement timezone
|
|
483
|
+
let toQuery = member => member.name; // TODO: implement timezone
|
|
631
484
|
|
|
632
485
|
|
|
633
|
-
|
|
634
|
-
QUERY_ELEMENTS.forEach(
|
|
486
|
+
let hasElements = false;
|
|
487
|
+
QUERY_ELEMENTS.forEach(element => {
|
|
635
488
|
if (element === 'timeDimensions') {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
};
|
|
642
|
-
};
|
|
489
|
+
toQuery = member => ({
|
|
490
|
+
dimension: member.dimension.name,
|
|
491
|
+
granularity: member.granularity,
|
|
492
|
+
dateRange: member.dateRange
|
|
493
|
+
});
|
|
643
494
|
} else if (element === 'filters') {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
};
|
|
652
|
-
};
|
|
495
|
+
toQuery = member => ({
|
|
496
|
+
member: member.member && member.member.name,
|
|
497
|
+
operator: member.operator,
|
|
498
|
+
values: member.values,
|
|
499
|
+
and: member.and && member.and.map(toQuery),
|
|
500
|
+
or: member.or && member.or.map(toQuery)
|
|
501
|
+
});
|
|
653
502
|
}
|
|
654
503
|
|
|
655
|
-
if (
|
|
656
|
-
validatedQuery[element] =
|
|
657
|
-
return _toQuery(x);
|
|
658
|
-
});
|
|
504
|
+
if (this[element].length > 0) {
|
|
505
|
+
validatedQuery[element] = this[element].map(x => toQuery(x));
|
|
659
506
|
hasElements = true;
|
|
660
507
|
}
|
|
661
508
|
});
|
|
@@ -685,25 +532,25 @@ var QueryBuilder = {
|
|
|
685
532
|
}
|
|
686
533
|
|
|
687
534
|
if (!this.skipHeuristics && !this.disableHeuristics && isQueryPresent(validatedQuery) && this.meta) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
535
|
+
const heuristicsFn = this.stateChangeHeuristics || defaultHeuristics;
|
|
536
|
+
const {
|
|
537
|
+
query,
|
|
538
|
+
chartType,
|
|
539
|
+
shouldApplyHeuristicOrder,
|
|
540
|
+
pivotConfig
|
|
541
|
+
} = heuristicsFn({
|
|
693
542
|
query: validatedQuery,
|
|
694
543
|
chartType: this.chartType
|
|
695
544
|
}, this.prevValidatedQuery, {
|
|
696
545
|
meta: this.meta,
|
|
697
|
-
sessionGranularity:
|
|
698
|
-
})
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
order: defaultOrder(query)
|
|
706
|
-
} : null);
|
|
546
|
+
sessionGranularity: validatedQuery?.timeDimensions?.[0]?.granularity
|
|
547
|
+
});
|
|
548
|
+
validatedQuery = { ...validatedQuery,
|
|
549
|
+
...query,
|
|
550
|
+
...(shouldApplyHeuristicOrder ? {
|
|
551
|
+
order: defaultOrder(query)
|
|
552
|
+
} : null)
|
|
553
|
+
};
|
|
707
554
|
this.chartType = chartType || this.chartType;
|
|
708
555
|
this.pivotConfig = ResultSet.getNormalizedPivotConfig(validatedQuery, pivotConfig || this.pivotConfig);
|
|
709
556
|
this.copyQueryFromProps(validatedQuery);
|
|
@@ -717,250 +564,186 @@ var QueryBuilder = {
|
|
|
717
564
|
this.prevValidatedQuery = validatedQuery;
|
|
718
565
|
return validatedQuery;
|
|
719
566
|
}
|
|
567
|
+
|
|
720
568
|
},
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
_context.next = 2;
|
|
731
|
-
return _this3.cubejsApi.meta();
|
|
732
|
-
|
|
733
|
-
case 2:
|
|
734
|
-
_this3.meta = _context.sent;
|
|
735
|
-
|
|
736
|
-
_this3.copyQueryFromProps();
|
|
737
|
-
|
|
738
|
-
if (!isQueryPresent(_this3.initialQuery)) {
|
|
739
|
-
_context.next = 9;
|
|
740
|
-
break;
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
_context.next = 7;
|
|
744
|
-
return _this3.cubejsApi.dryRun(_this3.initialQuery);
|
|
745
|
-
|
|
746
|
-
case 7:
|
|
747
|
-
dryRunResponse = _context.sent;
|
|
748
|
-
_this3.pivotConfig = ResultSet.getNormalizedPivotConfig((dryRunResponse === null || dryRunResponse === void 0 ? void 0 : dryRunResponse.pivotQuery) || {}, _this3.pivotConfig);
|
|
749
|
-
|
|
750
|
-
case 9:
|
|
751
|
-
case "end":
|
|
752
|
-
return _context.stop();
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
}, _callee);
|
|
756
|
-
}))();
|
|
569
|
+
|
|
570
|
+
async mounted() {
|
|
571
|
+
this.meta = await this.cubejsApi.meta();
|
|
572
|
+
this.copyQueryFromProps();
|
|
573
|
+
|
|
574
|
+
if (isQueryPresent(this.initialQuery)) {
|
|
575
|
+
const dryRunResponse = await this.cubejsApi.dryRun(this.initialQuery);
|
|
576
|
+
this.pivotConfig = ResultSet.getNormalizedPivotConfig(dryRunResponse?.pivotQuery || {}, this.pivotConfig);
|
|
577
|
+
}
|
|
757
578
|
},
|
|
579
|
+
|
|
758
580
|
methods: {
|
|
759
|
-
copyQueryFromProps
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
});
|
|
783
|
-
this.
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
},
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
});
|
|
800
|
-
});
|
|
801
|
-
var memberTypes = ['dimensions', 'measures'];
|
|
802
|
-
this.filters = filters.map(function (m, index) {
|
|
803
|
-
var memberName = m.member || m.dimension;
|
|
804
|
-
return _objectSpread(_objectSpread({}, m), {}, {
|
|
805
|
-
member: memberName && _this4.meta.resolveMember(memberName, memberTypes),
|
|
806
|
-
operators: memberName && _this4.meta.filterOperatorsForMember(memberName, memberTypes),
|
|
807
|
-
and: resolveMembers(_this4.meta, m.and),
|
|
808
|
-
or: resolveMembers(_this4.meta, m.or),
|
|
809
|
-
index: index
|
|
810
|
-
});
|
|
581
|
+
copyQueryFromProps(query) {
|
|
582
|
+
const {
|
|
583
|
+
measures = [],
|
|
584
|
+
dimensions = [],
|
|
585
|
+
segments = [],
|
|
586
|
+
timeDimensions = [],
|
|
587
|
+
filters = [],
|
|
588
|
+
limit,
|
|
589
|
+
offset,
|
|
590
|
+
renewQuery,
|
|
591
|
+
order
|
|
592
|
+
} = query || this.initialQuery;
|
|
593
|
+
this.measures = measures.map((m, index) => ({
|
|
594
|
+
index,
|
|
595
|
+
...this.meta.resolveMember(m, 'measures')
|
|
596
|
+
}));
|
|
597
|
+
this.dimensions = dimensions.map((m, index) => ({
|
|
598
|
+
index,
|
|
599
|
+
...this.meta.resolveMember(m, 'dimensions')
|
|
600
|
+
}));
|
|
601
|
+
this.segments = segments.map((m, index) => ({
|
|
602
|
+
index,
|
|
603
|
+
...this.meta.resolveMember(m, 'segments')
|
|
604
|
+
}));
|
|
605
|
+
this.timeDimensions = timeDimensions.map((m, index) => ({ ...m,
|
|
606
|
+
dimension: { ...this.meta.resolveMember(m.dimension, 'dimensions'),
|
|
607
|
+
granularities: this.granularities
|
|
608
|
+
},
|
|
609
|
+
index
|
|
610
|
+
}));
|
|
611
|
+
const memberTypes = ['dimensions', 'measures'];
|
|
612
|
+
this.filters = filters.map((m, index) => {
|
|
613
|
+
const memberName = m.member || m.dimension;
|
|
614
|
+
return { ...m,
|
|
615
|
+
member: memberName && this.meta.resolveMember(memberName, memberTypes),
|
|
616
|
+
operators: memberName && this.meta.filterOperatorsForMember(memberName, memberTypes),
|
|
617
|
+
and: resolveMembers(this.meta, m.and),
|
|
618
|
+
or: resolveMembers(this.meta, m.or),
|
|
619
|
+
index
|
|
620
|
+
};
|
|
811
621
|
});
|
|
812
622
|
this.availableMeasures = this.meta.membersForQuery({}, 'measures') || [];
|
|
813
623
|
this.availableDimensions = this.meta.membersForQuery({}, 'dimensions') || [];
|
|
814
|
-
this.availableTimeDimensions = (this.meta.membersForQuery({}, 'dimensions') || []).filter(
|
|
815
|
-
return m.type === 'time';
|
|
816
|
-
});
|
|
624
|
+
this.availableTimeDimensions = (this.meta.membersForQuery({}, 'dimensions') || []).filter(m => m.type === 'time');
|
|
817
625
|
this.availableSegments = this.meta.membersForQuery({}, 'segments') || [];
|
|
818
626
|
this.limit = limit || 10000;
|
|
819
627
|
this.offset = offset || null;
|
|
820
628
|
this.renewQuery = renewQuery || false;
|
|
821
629
|
this.order = order || null;
|
|
822
630
|
},
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
631
|
+
|
|
632
|
+
addMember(element, member) {
|
|
633
|
+
const name = element.charAt(0).toUpperCase() + element.slice(1);
|
|
634
|
+
let mem;
|
|
826
635
|
|
|
827
636
|
if (element === 'timeDimensions') {
|
|
828
|
-
mem = this[
|
|
829
|
-
return m.name === member.dimension;
|
|
830
|
-
});
|
|
637
|
+
mem = this[`available${name}`].find(m => m.name === member.dimension);
|
|
831
638
|
|
|
832
639
|
if (mem) {
|
|
833
|
-
|
|
640
|
+
const dimension = { ...this.meta.resolveMember(mem.name, 'dimensions'),
|
|
834
641
|
granularities: this.granularities
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
mem = _objectSpread(_objectSpread({}, mem), {}, {
|
|
642
|
+
};
|
|
643
|
+
mem = { ...mem,
|
|
838
644
|
granularity: member.granularity,
|
|
839
645
|
dateRange: member.dateRange,
|
|
840
|
-
dimension
|
|
646
|
+
dimension,
|
|
841
647
|
index: this[element].length
|
|
842
|
-
}
|
|
648
|
+
};
|
|
843
649
|
}
|
|
844
650
|
} else if (element === 'filters') {
|
|
845
|
-
mem =
|
|
651
|
+
mem = { ...member,
|
|
846
652
|
and: resolveMembers(this.meta, member.and),
|
|
847
653
|
or: resolveMembers(this.meta, member.or),
|
|
848
654
|
member: getDimensionOrMeasure(this.meta, member)
|
|
849
|
-
}
|
|
655
|
+
};
|
|
850
656
|
} else {
|
|
851
|
-
mem = this[
|
|
852
|
-
return m.name === member;
|
|
853
|
-
});
|
|
657
|
+
mem = this[`available${name}`].find(m => m.name === member);
|
|
854
658
|
}
|
|
855
659
|
|
|
856
660
|
if (mem) {
|
|
857
661
|
this[element].push(mem);
|
|
858
662
|
}
|
|
859
663
|
},
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
664
|
+
|
|
665
|
+
removeMember(element, member) {
|
|
666
|
+
const name = element.charAt(0).toUpperCase() + element.slice(1);
|
|
667
|
+
let mem;
|
|
863
668
|
|
|
864
669
|
if (element === 'timeDimensions') {
|
|
865
|
-
mem = this[
|
|
866
|
-
return x.name === member;
|
|
867
|
-
});
|
|
670
|
+
mem = this[`available${name}`].find(x => x.name === member);
|
|
868
671
|
} else if (element === 'filters') {
|
|
869
672
|
mem = member;
|
|
870
673
|
} else {
|
|
871
|
-
mem = this[
|
|
872
|
-
return m.name === member;
|
|
873
|
-
});
|
|
674
|
+
mem = this[`available${name}`].find(m => m.name === member);
|
|
874
675
|
}
|
|
875
676
|
|
|
876
677
|
if (mem) {
|
|
877
|
-
|
|
878
|
-
return x.name === mem;
|
|
879
|
-
});
|
|
678
|
+
const index = this[element].findIndex(x => x.name === mem);
|
|
880
679
|
this[element].splice(index, 1);
|
|
881
680
|
}
|
|
882
681
|
},
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
682
|
+
|
|
683
|
+
updateMember(element, old, member) {
|
|
684
|
+
const name = element.charAt(0).toUpperCase() + element.slice(1);
|
|
685
|
+
let mem;
|
|
686
|
+
let index;
|
|
887
687
|
|
|
888
688
|
if (element === 'timeDimensions') {
|
|
889
|
-
index = this[element].findIndex(
|
|
890
|
-
|
|
891
|
-
});
|
|
892
|
-
mem = this["available".concat(name)].find(function (m) {
|
|
893
|
-
return m.name === member.dimension;
|
|
894
|
-
});
|
|
689
|
+
index = this[element].findIndex(x => x.dimension.name === old.dimension);
|
|
690
|
+
mem = this[`available${name}`].find(m => m.name === member.dimension);
|
|
895
691
|
|
|
896
692
|
if (mem) {
|
|
897
|
-
|
|
693
|
+
const dimension = { ...this.meta.resolveMember(mem.name, 'dimensions'),
|
|
898
694
|
granularities: this.granularities
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
dimension: dimension,
|
|
695
|
+
};
|
|
696
|
+
mem = { ...mem,
|
|
697
|
+
dimension,
|
|
903
698
|
granularity: member.granularity,
|
|
904
699
|
dateRange: member.dateRange,
|
|
905
|
-
index
|
|
906
|
-
}
|
|
700
|
+
index
|
|
701
|
+
};
|
|
907
702
|
}
|
|
908
703
|
} else if (element === 'filters') {
|
|
909
|
-
index = this[element].findIndex(
|
|
910
|
-
|
|
911
|
-
});
|
|
912
|
-
mem = _objectSpread(_objectSpread({}, member), {}, {
|
|
704
|
+
index = this[element].findIndex(x => x.dimension === old);
|
|
705
|
+
mem = { ...member,
|
|
913
706
|
and: resolveMembers(this.meta, member.and),
|
|
914
707
|
or: resolveMembers(this.meta, member.or),
|
|
915
708
|
member: getDimensionOrMeasure(this.meta, member)
|
|
916
|
-
}
|
|
709
|
+
};
|
|
917
710
|
} else {
|
|
918
|
-
index = this[element].findIndex(
|
|
919
|
-
|
|
920
|
-
});
|
|
921
|
-
mem = this["available".concat(name)].find(function (m) {
|
|
922
|
-
return m.name === member;
|
|
923
|
-
});
|
|
711
|
+
index = this[element].findIndex(x => x.name === old);
|
|
712
|
+
mem = this[`available${name}`].find(m => m.name === member);
|
|
924
713
|
}
|
|
925
714
|
|
|
926
715
|
if (mem) {
|
|
927
716
|
this[element].splice(index, 1, mem);
|
|
928
717
|
}
|
|
929
718
|
},
|
|
930
|
-
setMembers: function setMembers(element, members) {
|
|
931
|
-
var _this5 = this;
|
|
932
719
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
720
|
+
setMembers(element, members) {
|
|
721
|
+
const name = element.charAt(0).toUpperCase() + element.slice(1);
|
|
722
|
+
let mem;
|
|
723
|
+
const elements = [];
|
|
724
|
+
members.filter(Boolean).forEach(m => {
|
|
937
725
|
if (element === 'timeDimensions') {
|
|
938
|
-
mem =
|
|
939
|
-
return x.name === m.dimension;
|
|
940
|
-
});
|
|
726
|
+
mem = this[`available${name}`].find(x => x.name === m.dimension);
|
|
941
727
|
|
|
942
728
|
if (mem) {
|
|
943
|
-
|
|
944
|
-
granularities:
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
mem = _objectSpread(_objectSpread({}, mem), {}, {
|
|
729
|
+
const dimension = { ...this.meta.resolveMember(mem.name, 'dimensions'),
|
|
730
|
+
granularities: this.granularities
|
|
731
|
+
};
|
|
732
|
+
mem = { ...mem,
|
|
948
733
|
granularity: m.granularity,
|
|
949
734
|
dateRange: m.dateRange,
|
|
950
|
-
dimension
|
|
951
|
-
index:
|
|
952
|
-
}
|
|
735
|
+
dimension,
|
|
736
|
+
index: this[element].length
|
|
737
|
+
};
|
|
953
738
|
}
|
|
954
739
|
} else if (element === 'filters') {
|
|
955
|
-
mem =
|
|
956
|
-
and: resolveMembers(
|
|
957
|
-
or: resolveMembers(
|
|
958
|
-
member: getDimensionOrMeasure(
|
|
959
|
-
}
|
|
740
|
+
mem = { ...m,
|
|
741
|
+
and: resolveMembers(this.meta, m.and),
|
|
742
|
+
or: resolveMembers(this.meta, m.or),
|
|
743
|
+
member: getDimensionOrMeasure(this.meta, m)
|
|
744
|
+
};
|
|
960
745
|
} else {
|
|
961
|
-
mem =
|
|
962
|
-
return x.name === m;
|
|
963
|
-
});
|
|
746
|
+
mem = this[`available${name}`].find(x => x.name === m);
|
|
964
747
|
}
|
|
965
748
|
|
|
966
749
|
if (mem) {
|
|
@@ -969,62 +752,71 @@ var QueryBuilder = {
|
|
|
969
752
|
});
|
|
970
753
|
this[element] = elements;
|
|
971
754
|
},
|
|
972
|
-
|
|
755
|
+
|
|
756
|
+
setLimit(limit) {
|
|
973
757
|
this.limit = limit;
|
|
974
758
|
},
|
|
975
|
-
|
|
759
|
+
|
|
760
|
+
removeLimit() {
|
|
976
761
|
this.limit = null;
|
|
977
762
|
},
|
|
978
|
-
|
|
763
|
+
|
|
764
|
+
setOffset(offset) {
|
|
979
765
|
this.offset = offset;
|
|
980
766
|
},
|
|
981
|
-
|
|
767
|
+
|
|
768
|
+
removeOffset() {
|
|
982
769
|
this.offset = null;
|
|
983
770
|
},
|
|
984
|
-
|
|
771
|
+
|
|
772
|
+
updateChart(chartType) {
|
|
985
773
|
this.chartType = chartType;
|
|
986
774
|
},
|
|
987
|
-
|
|
988
|
-
|
|
775
|
+
|
|
776
|
+
setOrder(order = {}) {
|
|
989
777
|
this.order = order;
|
|
990
778
|
},
|
|
991
|
-
|
|
992
|
-
|
|
779
|
+
|
|
780
|
+
emitVizStateChange(partialVizState) {
|
|
781
|
+
this.$emit('vizStateChange', clone({ ...this.vizState,
|
|
782
|
+
...partialVizState
|
|
783
|
+
}));
|
|
993
784
|
}
|
|
785
|
+
|
|
994
786
|
},
|
|
995
787
|
watch: {
|
|
996
788
|
validatedQuery: {
|
|
997
789
|
deep: true,
|
|
998
|
-
handler: function handler(query, prevQuery) {
|
|
999
|
-
var _this6 = this;
|
|
1000
790
|
|
|
1001
|
-
|
|
791
|
+
handler(query, prevQuery) {
|
|
792
|
+
const hasQueryChanged = !areQueriesEqual(query, prevQuery);
|
|
1002
793
|
|
|
1003
794
|
if (hasQueryChanged) {
|
|
1004
795
|
this.emitVizStateChange({
|
|
1005
|
-
query
|
|
796
|
+
query
|
|
1006
797
|
});
|
|
1007
798
|
}
|
|
1008
799
|
|
|
1009
800
|
if (isQueryPresent(query) && hasQueryChanged) {
|
|
1010
801
|
this.cubejsApi.dryRun(query, {
|
|
1011
802
|
mutexObj: this.mutex
|
|
1012
|
-
}).then(
|
|
1013
|
-
|
|
1014
|
-
|
|
803
|
+
}).then(({
|
|
804
|
+
pivotQuery
|
|
805
|
+
}) => {
|
|
806
|
+
const pivotConfig = ResultSet.getNormalizedPivotConfig(pivotQuery, this.pivotConfig);
|
|
1015
807
|
|
|
1016
|
-
if (!equals(pivotConfig,
|
|
1017
|
-
|
|
808
|
+
if (!equals(pivotConfig, this.pivotConfig)) {
|
|
809
|
+
this.pivotConfig = pivotConfig;
|
|
1018
810
|
}
|
|
1019
|
-
})
|
|
1020
|
-
return console.error(error);
|
|
1021
|
-
});
|
|
811
|
+
}).catch(error => console.error(error));
|
|
1022
812
|
}
|
|
1023
813
|
}
|
|
814
|
+
|
|
1024
815
|
},
|
|
1025
816
|
query: {
|
|
1026
817
|
deep: true,
|
|
1027
|
-
|
|
818
|
+
|
|
819
|
+
handler(query) {
|
|
1028
820
|
if (!this.meta) {
|
|
1029
821
|
// this is ok as if meta has not been loaded by the time query prop has changed,
|
|
1030
822
|
// then the promise for loading meta (found in mounted()) will call
|
|
@@ -1034,22 +826,27 @@ var QueryBuilder = {
|
|
|
1034
826
|
|
|
1035
827
|
this.copyQueryFromProps(query);
|
|
1036
828
|
}
|
|
829
|
+
|
|
1037
830
|
},
|
|
1038
831
|
pivotConfig: {
|
|
1039
832
|
deep: true,
|
|
1040
|
-
|
|
833
|
+
|
|
834
|
+
handler(pivotConfig, prevPivotConfig) {
|
|
1041
835
|
if (!equals(pivotConfig, prevPivotConfig)) {
|
|
1042
836
|
this.emitVizStateChange({
|
|
1043
|
-
pivotConfig
|
|
837
|
+
pivotConfig
|
|
1044
838
|
});
|
|
1045
839
|
}
|
|
1046
840
|
}
|
|
841
|
+
|
|
1047
842
|
},
|
|
1048
|
-
|
|
843
|
+
|
|
844
|
+
chartType(value) {
|
|
1049
845
|
this.emitVizStateChange({
|
|
1050
846
|
chartType: value
|
|
1051
847
|
});
|
|
1052
848
|
}
|
|
849
|
+
|
|
1053
850
|
}
|
|
1054
851
|
};
|
|
1055
852
|
|