Compare commits
18 Commits
QB-493/wro
...
QB262
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
468598540f | ||
|
|
045d0db215 | ||
|
|
73011d0388 | ||
|
|
41cf77e8d2 | ||
|
|
1355381346 | ||
|
|
730f35a83c | ||
|
|
71bf25e8fb | ||
|
|
9b4fe54239 | ||
|
|
e59c594215 | ||
|
|
97a54e6f5a | ||
|
|
eac9fd2a5f | ||
|
|
96f09f9323 | ||
|
|
2ab340f3f1 | ||
|
|
58d0f542eb | ||
|
|
8ba826a0ea | ||
|
|
d2446395e2 | ||
|
|
f17a7b7714 | ||
|
|
fd9e645fc1 |
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"json.format.enable": false
|
||||||
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
|
/* eslint-disable react/sort-prop-types */
|
||||||
|
/* eslint-disable space-before-function-paren */
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Tooltip from '../tooltip/index.jsx';
|
import Tooltip from '../tooltip/index.jsx';
|
||||||
|
|
||||||
class DataCell extends React.PureComponent {
|
class DataCell extends React.PureComponent {
|
||||||
constructor (props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleSelect = this.handleSelect.bind(this);
|
this.handleSelect = this.handleSelect.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSelect () {
|
handleSelect() {
|
||||||
const {
|
const {
|
||||||
data: {
|
data: {
|
||||||
meta: {
|
meta: {
|
||||||
@@ -26,14 +28,14 @@ class DataCell extends React.PureComponent {
|
|||||||
if (!allowFilteringByClick) {
|
if (!allowFilteringByClick) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// fixes the console error on selection made from data cells
|
||||||
component.backendApi.selectValues(0, [measurement.parents.dimension1.elementNumber], false);
|
component.selectValues(0, [measurement.parents.dimension1.elementNumber], false);
|
||||||
if (hasSecondDimension) {
|
if (hasSecondDimension) {
|
||||||
component.backendApi.selectValues(1, [measurement.parents.dimension2.elementNumber], false);
|
component.selectValues(1, [measurement.parents.dimension2.elementNumber], false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render() {
|
||||||
const {
|
const {
|
||||||
cellWidth,
|
cellWidth,
|
||||||
measurement,
|
measurement,
|
||||||
@@ -41,9 +43,9 @@ class DataCell extends React.PureComponent {
|
|||||||
styling
|
styling
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
let textAlignment = styling.options.textAlignment || 'Right';
|
const textAlignment = styling.options.textAlignment || 'Right';
|
||||||
|
|
||||||
let cellStyle = {
|
const cellStyle = {
|
||||||
fontFamily: styling.options.fontFamily,
|
fontFamily: styling.options.fontFamily,
|
||||||
...styleBuilder.getStyle(),
|
...styleBuilder.getStyle(),
|
||||||
paddingLeft: '5px',
|
paddingLeft: '5px',
|
||||||
@@ -64,10 +66,10 @@ class DataCell extends React.PureComponent {
|
|||||||
const { conditionalColoring } = styling;
|
const { conditionalColoring } = styling;
|
||||||
if (conditionalColoring.enabled) {
|
if (conditionalColoring.enabled) {
|
||||||
const isValidConditionalColoringValue = !styleBuilder.hasComments() && !isNaN(measurement.value);
|
const isValidConditionalColoringValue = !styleBuilder.hasComments() && !isNaN(measurement.value);
|
||||||
const isSpecifiedRow =
|
const isSpecifiedRow
|
||||||
conditionalColoring.rows.indexOf(measurement.parents.dimension1.header) !== -1;
|
= conditionalColoring.rows.indexOf(measurement.parents.dimension1.header) !== -1;
|
||||||
const isSpecifiedMeasure =
|
const isSpecifiedMeasure
|
||||||
conditionalColoring.measures.indexOf(measurement.parents.measurement.index) !== -1;
|
= conditionalColoring.measures.indexOf(measurement.parents.measurement.index) !== -1;
|
||||||
const shouldHaveConditionalColoring = (conditionalColoring.colorAllRows || isSpecifiedRow)
|
const shouldHaveConditionalColoring = (conditionalColoring.colorAllRows || isSpecifiedRow)
|
||||||
&& (conditionalColoring.colorAllMeasures || isSpecifiedMeasure);
|
&& (conditionalColoring.colorAllMeasures || isSpecifiedMeasure);
|
||||||
if (isValidConditionalColoringValue && shouldHaveConditionalColoring) {
|
if (isValidConditionalColoringValue && shouldHaveConditionalColoring) {
|
||||||
@@ -112,7 +114,7 @@ DataCell.propTypes = {
|
|||||||
}).isRequired,
|
}).isRequired,
|
||||||
component: PropTypes.shape({
|
component: PropTypes.shape({
|
||||||
backendApi: PropTypes.shape({
|
backendApi: PropTypes.shape({
|
||||||
selectValues: function (props, propName) {
|
selectValues (props, propName) {
|
||||||
if (props.isSnapshot || typeof props[propName] === 'function') {
|
if (props.isSnapshot || typeof props[propName] === 'function') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -130,7 +132,7 @@ DataCell.propTypes = {
|
|||||||
|
|
||||||
export default DataCell;
|
export default DataCell;
|
||||||
|
|
||||||
function formatMeasurementValue (measurement, styling) {
|
function formatMeasurementValue(measurement, styling) {
|
||||||
if (isNaN(measurement.value)) {
|
if (isNaN(measurement.value)) {
|
||||||
return styling.symbolForNulls;
|
return styling.symbolForNulls;
|
||||||
}
|
}
|
||||||
@@ -138,7 +140,7 @@ function formatMeasurementValue (measurement, styling) {
|
|||||||
return measurement.displayValue;
|
return measurement.displayValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConditionalColor (measurement, conditionalColoring) {
|
function getConditionalColor(measurement, conditionalColoring) {
|
||||||
if (measurement.value < conditionalColoring.threshold.poor) {
|
if (measurement.value < conditionalColoring.threshold.poor) {
|
||||||
return conditionalColoring.colors.poor;
|
return conditionalColoring.colors.poor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,20 +43,42 @@ class DataTable extends React.PureComponent {
|
|||||||
return injectSeparatorsArray;
|
return injectSeparatorsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
let measurementDataRow = [],
|
const measurementDataRow = [];
|
||||||
index = 0;
|
let index = 0,
|
||||||
|
match;
|
||||||
dimension2.forEach((dim2) => {
|
dimension2.forEach((dim2) => {
|
||||||
measurements.forEach((measure) => {
|
measurements.forEach((measure, mesInd) => {
|
||||||
for (index = 0; index < injectSeparatorsArray.length; index++) {
|
for (index = 0; index < injectSeparatorsArray.length; index++) {
|
||||||
if (dimension1[dimIndex].displayValue === injectSeparatorsArray[index].parents.dimension1.header) {
|
match = false;
|
||||||
|
if (injectSeparatorsArray[index].parents && dimension1[dimIndex].displayValue === injectSeparatorsArray[index].parents.dimension1.header) {
|
||||||
if (dim2.displayValue === injectSeparatorsArray[index].parents.dimension2.header) {
|
if (dim2.displayValue === injectSeparatorsArray[index].parents.dimension2.header) {
|
||||||
if (measure.name === injectSeparatorsArray[index].parents.measurement.header) {
|
if (measure.name === injectSeparatorsArray[index].parents.measurement.header) {
|
||||||
measurementDataRow.push(injectSeparatorsArray[index]);
|
measurementDataRow.push(injectSeparatorsArray[index]);
|
||||||
|
match = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!match) {
|
||||||
|
measurementDataRow.push({
|
||||||
|
displayValue: '',
|
||||||
|
parents: {
|
||||||
|
dimension1: {
|
||||||
|
elementNumber: dimension1[dimIndex].elementNumber,
|
||||||
|
header: dimension1[dimIndex].displayValue
|
||||||
|
},
|
||||||
|
dimension2: {
|
||||||
|
elementNumber: dim2.elementNumber,
|
||||||
|
header: dim2.displayValue
|
||||||
|
},
|
||||||
|
measurement: {
|
||||||
|
header: measure.name,
|
||||||
|
index: mesInd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return measurementDataRow;
|
return measurementDataRow;
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ class RowHeader extends React.PureComponent {
|
|||||||
this.handleSelect = this.handleSelect.bind(this);
|
this.handleSelect = this.handleSelect.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fixes the console error on row selected values
|
||||||
handleSelect () {
|
handleSelect () {
|
||||||
const { component, entry } = this.props;
|
const { component, entry } = this.props;
|
||||||
component.backendApi.selectValues(0, [entry.elementNumber], false);
|
component.selectValues(0, [entry.elementNumber], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
@@ -42,13 +43,9 @@ class RowHeader extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RowHeader.propTypes = {
|
RowHeader.propTypes = {
|
||||||
entry: PropTypes.shape({
|
|
||||||
displayValue: PropTypes.string.isRequired,
|
|
||||||
elementNumber: PropTypes.number.isRequired
|
|
||||||
}).isRequired,
|
|
||||||
component: PropTypes.shape({
|
component: PropTypes.shape({
|
||||||
backendApi: PropTypes.shape({
|
backendApi: PropTypes.shape({
|
||||||
selectValues: function (props, propName) {
|
selectValues (props, propName) {
|
||||||
if (props.isSnapshot || typeof props[propName] === 'function') {
|
if (props.isSnapshot || typeof props[propName] === 'function') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -56,6 +53,10 @@ RowHeader.propTypes = {
|
|||||||
}
|
}
|
||||||
}).isRequired
|
}).isRequired
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
|
entry: PropTypes.shape({
|
||||||
|
displayValue: PropTypes.string.isRequired,
|
||||||
|
elementNumber: PropTypes.number.isRequired
|
||||||
|
}).isRequired,
|
||||||
rowStyle: PropTypes.shape({}).isRequired,
|
rowStyle: PropTypes.shape({}).isRequired,
|
||||||
styleBuilder: PropTypes.shape({}).isRequired,
|
styleBuilder: PropTypes.shape({}).isRequired,
|
||||||
styling: PropTypes.shape({}).isRequired
|
styling: PropTypes.shape({}).isRequired
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ function createCube (definition, app) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildDataCube (originCubeDefinition, originCube, app) {
|
async function buildDataCube (originCubeDefinition, originCube, app, requestPage) {
|
||||||
const cubeDefinition = {
|
const cubeDefinition = {
|
||||||
...originCubeDefinition,
|
...originCubeDefinition,
|
||||||
qInitialDataFetch: [
|
qInitialDataFetch: [
|
||||||
{
|
{
|
||||||
qHeight: originCube.qSize.qcy,
|
// eslint-disable-next-line no-undefined
|
||||||
|
qTop: requestPage === undefined ? 0 : requestPage[0].qTop,
|
||||||
|
qLeft: 0,
|
||||||
|
qHeight: 1000,
|
||||||
qWidth: originCube.qSize.qcx
|
qWidth: originCube.qSize.qcx
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -28,12 +31,15 @@ async function buildDataCube (originCubeDefinition, originCube, app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function initializeDataCube (component, layout) {
|
export async function initializeDataCube (component, layout) {
|
||||||
|
|
||||||
if (component.backendApi.isSnapshot) {
|
if (component.backendApi.isSnapshot) {
|
||||||
return layout.snapshotData.dataCube;
|
return layout.snapshotData.dataCube;
|
||||||
}
|
}
|
||||||
|
|
||||||
const app = qlik.currApp(component);
|
const app = qlik.currApp(component);
|
||||||
const properties = (await component.backendApi.getProperties());
|
const properties = (await component.backendApi.getProperties());
|
||||||
|
const rowCount = component.backendApi.getRowCount();
|
||||||
|
const cellCount = rowCount * layout.qHyperCube.qSize.qcx;
|
||||||
|
const maxLoops = layout.maxloops;
|
||||||
|
|
||||||
// If this is a master object, fetch the hyperCubeDef of the original object
|
// If this is a master object, fetch the hyperCubeDef of the original object
|
||||||
let hyperCubeDef = properties.qExtendsId
|
let hyperCubeDef = properties.qExtendsId
|
||||||
@@ -41,8 +47,25 @@ export async function initializeDataCube (component, layout) {
|
|||||||
: properties.qHyperCubeDef;
|
: properties.qHyperCubeDef;
|
||||||
hyperCubeDef = JSON.parse(JSON.stringify(hyperCubeDef));
|
hyperCubeDef = JSON.parse(JSON.stringify(hyperCubeDef));
|
||||||
hyperCubeDef.qStateName = layout.qStateName;
|
hyperCubeDef.qStateName = layout.qStateName;
|
||||||
|
const pagedCube = {};
|
||||||
return buildDataCube(hyperCubeDef, layout.qHyperCube, app);
|
let lastRow = 0;
|
||||||
|
if (cellCount < (maxLoops * 10000)) {
|
||||||
|
for (let index = 0; cellCount > lastRow; index += 1) {
|
||||||
|
const requestPage = [
|
||||||
|
{
|
||||||
|
qHeight: 1000,
|
||||||
|
qLeft: 0,
|
||||||
|
qTop: lastRow,
|
||||||
|
qWidth: 10 // should be # of columns
|
||||||
|
}
|
||||||
|
];
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
pagedCube[index] = await buildDataCube(hyperCubeDef, layout.qHyperCube, app, requestPage);
|
||||||
|
lastRow = lastRow + 1000;
|
||||||
|
}
|
||||||
|
return pagedCube;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initializeDesignList (component, layout) {
|
export function initializeDesignList (component, layout) {
|
||||||
|
|||||||
@@ -23,30 +23,6 @@ const pagination = {
|
|||||||
{
|
{
|
||||||
value: 4,
|
value: 4,
|
||||||
label: '40k cells'
|
label: '40k cells'
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 5,
|
|
||||||
label: '50k cells'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 6,
|
|
||||||
label: '60k cells'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 7,
|
|
||||||
label: '70k cells'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 8,
|
|
||||||
label: '80k cells'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 9,
|
|
||||||
label: '90k cells'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 10,
|
|
||||||
label: '100k cells'
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
defaultValue: 2
|
defaultValue: 2
|
||||||
@@ -55,7 +31,8 @@ const pagination = {
|
|||||||
ref: 'errormessage',
|
ref: 'errormessage',
|
||||||
label: 'Default error message',
|
label: 'Default error message',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
defaultValue: 'Unable to display all the data. Apply more filters to limit the amount of displayed data.'
|
defaultValue: `Unable to display all the data.
|
||||||
|
Change the pagination size supported or apply more filters to limit the amount of displayed data.`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,20 +1,23 @@
|
|||||||
|
/* eslint-disable object-shorthand */
|
||||||
|
/* eslint-disable space-before-function-paren */
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { HEADER_FONT_SIZE } from '../initialize-transformed';
|
import { HEADER_FONT_SIZE } from '../initialize-transformed';
|
||||||
import Tooltip from '../tooltip/index.jsx';
|
import Tooltip from '../tooltip/index.jsx';
|
||||||
|
|
||||||
class ColumnHeader extends React.PureComponent {
|
class ColumnHeader extends React.PureComponent {
|
||||||
constructor (props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleSelect = this.handleSelect.bind(this);
|
this.handleSelect = this.handleSelect.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSelect () {
|
// fixes console error for column selected values
|
||||||
|
handleSelect() {
|
||||||
const { component, entry } = this.props;
|
const { component, entry } = this.props;
|
||||||
component.backendApi.selectValues(1, [entry.elementNumber], false);
|
component.selectValues(1, [entry.elementNumber], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render() {
|
||||||
const { baseCSS, cellWidth, colSpan, component, entry, styling } = this.props;
|
const { baseCSS, cellWidth, colSpan, component, entry, styling } = this.props;
|
||||||
const inEditState = component.inEditState();
|
const inEditState = component.inEditState();
|
||||||
const isMediumFontSize = styling.headerOptions.fontSizeAdjustment === HEADER_FONT_SIZE.MEDIUM;
|
const isMediumFontSize = styling.headerOptions.fontSizeAdjustment === HEADER_FONT_SIZE.MEDIUM;
|
||||||
|
|||||||
118
src/index.js
118
src/index.js
@@ -1,15 +1,16 @@
|
|||||||
import definition from './definition';
|
import definition from "./definition";
|
||||||
import { exportXLS } from './excel-export';
|
import { exportXLS } from "./excel-export";
|
||||||
import { initializeDataCube, initializeDesignList } from './dataset';
|
import { initializeDataCube, initializeDesignList } from "./dataset";
|
||||||
import initializeStore from './store';
|
import initializeStore from "./store";
|
||||||
import qlik from 'qlik';
|
import qlik from "qlik";
|
||||||
import React from 'react';
|
import React from "react";
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from "react-dom";
|
||||||
import Root from './root.jsx';
|
import Root from "./root.jsx";
|
||||||
import './main.less';
|
import "./main.less";
|
||||||
|
|
||||||
if (!window._babelPolyfill) { // eslint-disable-line no-underscore-dangle
|
if (!window._babelPolyfill) {
|
||||||
require('@babel/polyfill'); // eslint-disable-line global-require
|
// eslint-disable-line no-underscore-dangle
|
||||||
|
require("@babel/polyfill"); // eslint-disable-line global-require
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -21,14 +22,14 @@ export default {
|
|||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
dimensions: {
|
dimensions: {
|
||||||
max: function (nMeasures) {
|
max (nMeasures) {
|
||||||
return nMeasures < 9 ? 2 : 1;
|
return nMeasures < 9 ? 2 : 1;
|
||||||
},
|
},
|
||||||
min: 1,
|
min: 1,
|
||||||
uses: 'dimensions'
|
uses: 'dimensions'
|
||||||
},
|
},
|
||||||
measures: {
|
measures: {
|
||||||
max: function (nDims) {
|
max (nDims) {
|
||||||
return nDims < 2 ? 9 : 8;
|
return nDims < 2 ? 9 : 8;
|
||||||
},
|
},
|
||||||
min: 1,
|
min: 1,
|
||||||
@@ -45,8 +46,10 @@ export default {
|
|||||||
qDimensions: [],
|
qDimensions: [],
|
||||||
qInitialDataFetch: [
|
qInitialDataFetch: [
|
||||||
{
|
{
|
||||||
qHeight: 1,
|
qTop: 0,
|
||||||
qWidth: 10
|
qLeft: 0,
|
||||||
|
qWidth: 50,
|
||||||
|
qHeight: 50
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
qMeasures: [],
|
qMeasures: [],
|
||||||
@@ -58,23 +61,32 @@ export default {
|
|||||||
exportData: true,
|
exportData: true,
|
||||||
snapshot: true
|
snapshot: true
|
||||||
},
|
},
|
||||||
paint: async function ($element, layout) {
|
async paint ($element, layout, requestPage) {
|
||||||
const dataCube = await initializeDataCube(this, layout);
|
const dataCube = await initializeDataCube(this, layout, requestPage);
|
||||||
const designList = await initializeDesignList(this, layout);
|
|
||||||
const state = await initializeStore({
|
|
||||||
$element,
|
|
||||||
component: this,
|
|
||||||
dataCube,
|
|
||||||
designList,
|
|
||||||
layout
|
|
||||||
});
|
|
||||||
const editmodeClass = this.inAnalysisState() ? '' : 'edit-mode';
|
const editmodeClass = this.inAnalysisState() ? '' : 'edit-mode';
|
||||||
|
let state, designList;
|
||||||
|
if (dataCube === null) {
|
||||||
|
state = {
|
||||||
|
$element,
|
||||||
|
component: this,
|
||||||
|
dataCube,
|
||||||
|
designList,
|
||||||
|
layout,
|
||||||
|
error: true
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
designList = await initializeDesignList(this, layout);
|
||||||
|
state = await initializeStore({
|
||||||
|
$element,
|
||||||
|
component: this,
|
||||||
|
dataCube,
|
||||||
|
designList,
|
||||||
|
layout,
|
||||||
|
error: false
|
||||||
|
});
|
||||||
|
}
|
||||||
const jsx = (
|
const jsx = (
|
||||||
<Root
|
<Root editmodeClass={editmodeClass} component={this} state={state} />
|
||||||
editmodeClass={editmodeClass}
|
|
||||||
component={this}
|
|
||||||
state={state}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
ReactDOM.render(jsx, $element[0]);
|
ReactDOM.render(jsx, $element[0]);
|
||||||
@@ -82,30 +94,42 @@ export default {
|
|||||||
snapshot: {
|
snapshot: {
|
||||||
canTakeSnapshot: true
|
canTakeSnapshot: true
|
||||||
},
|
},
|
||||||
setSnapshotData: async function (snapshotLayout) {
|
async setSnapshotData (snapshotLayout) {
|
||||||
snapshotLayout.snapshotData.dataCube = await initializeDataCube(this, snapshotLayout);
|
snapshotLayout.snapshotData.dataCube = await initializeDataCube(
|
||||||
snapshotLayout.snapshotData.designList = await initializeDesignList(this, snapshotLayout);
|
this,
|
||||||
|
snapshotLayout
|
||||||
|
);
|
||||||
|
snapshotLayout.snapshotData.designList = await initializeDesignList(
|
||||||
|
this,
|
||||||
|
snapshotLayout
|
||||||
|
);
|
||||||
return snapshotLayout;
|
return snapshotLayout;
|
||||||
},
|
},
|
||||||
getContextMenu: async function (obj, menu) {
|
async getContextMenu (obj, menu) {
|
||||||
const app = qlik.currApp(this);
|
const app = qlik.currApp(this);
|
||||||
const isPersonalResult = await app.global.isPersonalMode();
|
const isPersonalResult = await app.global.isPersonalMode();
|
||||||
if (!this.$scope.layout.allowexportxls || (isPersonalResult && isPersonalResult.qReturn)) {
|
if (
|
||||||
|
!this.$scope.layout.allowexportxls ||
|
||||||
|
(isPersonalResult && isPersonalResult.qReturn)
|
||||||
|
) {
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.addItem({
|
if (typeof (this.backendApi.model.layout.qMeta.privileges[3]) !== 'undefined' && this.backendApi.model.layout.qMeta.privileges[3] === 'exportdata') {
|
||||||
translation: "Export as XLS",
|
menu.addItem({
|
||||||
tid: "export-excel",
|
translation: 'Export as XLS',
|
||||||
icon: "export",
|
tid: 'export-excel',
|
||||||
select: () => {
|
icon: 'export',
|
||||||
exportXLS(
|
select: () => {
|
||||||
this.$element,
|
exportXLS(
|
||||||
this.$scope.layout.title,
|
this.$element,
|
||||||
this.$scope.layout.subtitle,
|
this.$scope.layout.title,
|
||||||
this.$scope.layout.footnote);
|
this.$scope.layout.subtitle,
|
||||||
}
|
this.$scope.layout.footnote
|
||||||
});
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
return menu;
|
return menu;
|
||||||
},
|
},
|
||||||
version: 1.0
|
version: 1.0
|
||||||
|
|||||||
@@ -72,85 +72,61 @@ function generateMatrixCell ({ cell, dimension1Information, dimension2Informatio
|
|||||||
return matrixCell;
|
return matrixCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastRow = 0;
|
|
||||||
function generateDataSet (
|
|
||||||
component, dimensionsInformation, measurementsInformation, dataCube) {
|
|
||||||
|
|
||||||
|
function generateDataSet (component, dimensionsInformation, measurementsInformation, dataCube) {
|
||||||
const measurements = generateMeasurements(measurementsInformation);
|
const measurements = generateMeasurements(measurementsInformation);
|
||||||
let dimension1 = [];
|
let dimension1 = [];
|
||||||
let dimension2 = [];
|
let dimension2 = [];
|
||||||
let matrix = [];
|
let matrix = [];
|
||||||
|
|
||||||
const hasSecondDimension = dimensionsInformation.length > 1;
|
const hasSecondDimension = dimensionsInformation.length > 1;
|
||||||
dataCube.forEach(row => {
|
// eslint-disable-next-line no-undefined
|
||||||
lastRow += 1;
|
for (let index = 0; dataCube[index] !== undefined; index++) {
|
||||||
const dimension1Entry = generateDimensionEntry(dimensionsInformation[0], row[0]);
|
// eslint-disable-next-line no-loop-func
|
||||||
dimension1.push(dimension1Entry);
|
dataCube[index].forEach(row => {
|
||||||
let dimension2Entry;
|
const dimension1Entry = generateDimensionEntry(dimensionsInformation[0], row[0]);
|
||||||
let firstDataCell = 1;
|
dimension1.push(dimension1Entry);
|
||||||
if (hasSecondDimension) {
|
let dimension2Entry;
|
||||||
dimension2Entry = generateDimensionEntry(dimensionsInformation[1], row[1]);
|
let firstDataCell = 1;
|
||||||
dimension2.push(dimension2Entry);
|
if (hasSecondDimension) {
|
||||||
firstDataCell = 2;
|
dimension2Entry = generateDimensionEntry(dimensionsInformation[1], row[1]);
|
||||||
}
|
dimension2.push(dimension2Entry);
|
||||||
let matrixRow = row
|
firstDataCell = 2;
|
||||||
.slice(firstDataCell, row.length)
|
}
|
||||||
.map((cell, cellIndex) => {
|
let matrixRow = row
|
||||||
const measurementInformation = measurements[cellIndex];
|
.slice(firstDataCell, row.length)
|
||||||
measurementInformation.index = cellIndex;
|
.map((cell, cellIndex) => {
|
||||||
const dimension1Information = row[0]; // eslint-disable-line prefer-destructuring
|
const measurementInformation = measurements[cellIndex];
|
||||||
const dimension2Information = hasSecondDimension ? row[1] : null;
|
measurementInformation.index = cellIndex;
|
||||||
const generatedCell = generateMatrixCell({
|
const dimension1Information = row[0]; // eslint-disable-line prefer-destructuring
|
||||||
cell,
|
const dimension2Information = hasSecondDimension ? row[1] : null;
|
||||||
dimension1Information,
|
const generatedCell = generateMatrixCell({
|
||||||
dimension2Information,
|
cell,
|
||||||
measurementInformation
|
dimension1Information,
|
||||||
|
dimension2Information,
|
||||||
|
measurementInformation
|
||||||
|
});
|
||||||
|
return generatedCell;
|
||||||
});
|
});
|
||||||
|
|
||||||
return generatedCell;
|
let appendToRowIndex = matrix.length;
|
||||||
});
|
if (hasSecondDimension) {
|
||||||
|
|
||||||
let appendToRowIndex = matrix.length;
|
|
||||||
if (hasSecondDimension) {
|
|
||||||
// See if there already is a row for the current dim1
|
// See if there already is a row for the current dim1
|
||||||
for (let i = 0; i < matrix.length; i++) {
|
for (let i = 0; i < matrix.length; i++) {
|
||||||
if (matrix[i][0].parents.dimension1.header === matrixRow[0].parents.dimension1.header) {
|
if (matrix[i][0].parents.dimension1.header === matrixRow[0].parents.dimension1.header) {
|
||||||
appendToRowIndex = i;
|
appendToRowIndex = i;
|
||||||
matrixRow = matrix[i].concat(matrixRow);
|
matrixRow = matrix[i].concat(matrixRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
matrix[appendToRowIndex] = matrixRow;
|
||||||
matrix[appendToRowIndex] = matrixRow;
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
// filter header dimensions to only have distinct values
|
// filter header dimensions to only have distinct values
|
||||||
dimension1 = distinctArray(dimension1);
|
dimension1 = distinctArray(dimension1);
|
||||||
dimension2 = distinctArray(dimension2);
|
dimension2 = distinctArray(dimension2);
|
||||||
|
|
||||||
// Make sure all rows are saturated, otherwise data risks being displayed in the wrong column
|
|
||||||
matrix = matrix.map((row, rowIndex) => {
|
|
||||||
if ((hasSecondDimension && row.length == (dimension2.length * measurements.length))
|
|
||||||
|| (!hasSecondDimension && row.length == measurements.length)) {
|
|
||||||
// Row is saturated
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Row is not saturated, so must add empty cells to fill the gaps
|
|
||||||
let newRow = [];
|
|
||||||
if (hasSecondDimension) {
|
|
||||||
// Got a second dimension, so need to add measurements for all values of the second dimension
|
|
||||||
let rowDataIndex = 0;
|
|
||||||
dimension2.forEach(dim => {
|
|
||||||
rowDataIndex = appendMissingCells(
|
|
||||||
row, newRow, rowDataIndex, measurements, rowIndex, dim, dimension1);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
appendMissingCells(row, newRow, 0, measurements, rowIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newRow;
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
dimension1: dimension1,
|
dimension1: dimension1,
|
||||||
dimension2: dimension2,
|
dimension2: dimension2,
|
||||||
@@ -159,51 +135,10 @@ function generateDataSet (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
function initializeTransformed ({ component, dataCube, designList, layout }) {
|
||||||
* Appends the cells of the source row, as well as those missing, to the destination row, starting
|
|
||||||
* from the given source index. Returns the source index of the next source cell after this has
|
|
||||||
* completed. If there is a second dimension the dim2ElementNumber should be set to the current
|
|
||||||
* index of the dimension2 value being processed.
|
|
||||||
*/
|
|
||||||
function appendMissingCells (
|
|
||||||
sourceRow, destRow, sourceIndex, measurements, matrixIndex, dim2, dim1) {
|
|
||||||
|
|
||||||
let index = sourceIndex;
|
|
||||||
measurements.forEach((measurement, measureIndex) => {
|
|
||||||
if (index < sourceRow.length) {
|
|
||||||
// Source contains the expected cell
|
|
||||||
destRow.push(sourceRow[index]);
|
|
||||||
index++;
|
|
||||||
} else {
|
|
||||||
// Source doesn't contain the expected cell, so add empty
|
|
||||||
destRow.push({
|
|
||||||
displayValue: '',
|
|
||||||
parents: {
|
|
||||||
dimension1: {
|
|
||||||
elementNumber: dim1[matrixIndex].elementNumber,
|
|
||||||
header: dim1[matrixIndex].displayValue
|
|
||||||
},
|
|
||||||
dimension2: {
|
|
||||||
elementNumber: dim2.elementNumber,
|
|
||||||
header: dim2.displayValue
|
|
||||||
},
|
|
||||||
measurement: {
|
|
||||||
header: measurement.name,
|
|
||||||
index: measureIndex
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
function initializeTransformed ({ $element, component, dataCube, designList, layout }) {
|
|
||||||
const dimensionsInformation = component.backendApi.getDimensionInfos();
|
const dimensionsInformation = component.backendApi.getDimensionInfos();
|
||||||
const measurementsInformation = component.backendApi.getMeasureInfos();
|
const measurementsInformation = component.backendApi.getMeasureInfos();
|
||||||
const dimensionCount = layout.qHyperCube.qDimensionInfo.length;
|
const dimensionCount = layout.qHyperCube.qDimensionInfo.length;
|
||||||
const rowCount = component.backendApi.getRowCount();
|
|
||||||
const maxLoops = layout.maxloops;
|
|
||||||
const {
|
const {
|
||||||
dimension1,
|
dimension1,
|
||||||
dimension2,
|
dimension2,
|
||||||
@@ -263,7 +198,6 @@ function initializeTransformed ({ $element, component, dataCube, designList, lay
|
|||||||
cellWidth: cellWidth,
|
cellWidth: cellWidth,
|
||||||
errorMessage: layout.errormessage,
|
errorMessage: layout.errormessage,
|
||||||
footnote: layout.footnote,
|
footnote: layout.footnote,
|
||||||
maxLoops,
|
|
||||||
subtitle: layout.subtitle,
|
subtitle: layout.subtitle,
|
||||||
title: layout.title,
|
title: layout.title,
|
||||||
useColumnSeparator: layout.separatorcols && dimensionCount > 1
|
useColumnSeparator: layout.separatorcols && dimensionCount > 1
|
||||||
@@ -324,20 +258,6 @@ function initializeTransformed ({ $element, component, dataCube, designList, lay
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (rowCount > lastRow && rowCount <= (maxLoops * 1000)) {
|
|
||||||
const requestPage = [
|
|
||||||
{
|
|
||||||
qHeight: Math.min(1000, rowCount - lastRow),
|
|
||||||
qLeft: 0,
|
|
||||||
qTop: matrix.length,
|
|
||||||
qWidth: 10 // should be # of columns
|
|
||||||
}
|
|
||||||
];
|
|
||||||
component.backendApi.getData(requestPage).then(() => {
|
|
||||||
component.paint($element, layout);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return transformedProperties;
|
return transformedProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class LinkedScrollWrapper extends React.PureComponent {
|
|||||||
unlinkComponent (component) {
|
unlinkComponent (component) {
|
||||||
const componentIndex = this.scrollElements.map(element => element.component).indexOf(component);
|
const componentIndex = this.scrollElements.map(element => element.component).indexOf(component);
|
||||||
if (componentIndex !== -1) {
|
if (componentIndex !== -1) {
|
||||||
this.scrollElements.removeAt(componentIndex);
|
this.scrollElements.splice(componentIndex, 1);
|
||||||
// eslint-disable-next-line react/no-find-dom-node
|
// eslint-disable-next-line react/no-find-dom-node
|
||||||
const node = ReactDOM.findDOMNode(component);
|
const node = ReactDOM.findDOMNode(component);
|
||||||
node.onscroll = null;
|
node.onscroll = null;
|
||||||
|
|||||||
@@ -105,6 +105,20 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
position: absolute; /*Define position */
|
||||||
|
width: 100%; /* Full width (cover the whole page) */
|
||||||
|
height: 100%; /* Full height (cover the whole page) */
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 1000; /* Specify a stack order in case you're using a different order for other elements */
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
.kpi-table .fdim-cells,
|
.kpi-table .fdim-cells,
|
||||||
.data-table td {
|
.data-table td {
|
||||||
line-height: 1em !important;
|
line-height: 1em !important;
|
||||||
|
|||||||
131
src/root.jsx
131
src/root.jsx
@@ -1,8 +1,8 @@
|
|||||||
import React from 'react';
|
import React from "react";
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from "prop-types";
|
||||||
import HeadersTable from './headers-table/index.jsx';
|
import HeadersTable from "./headers-table/index.jsx";
|
||||||
import DataTable from './data-table/index.jsx';
|
import DataTable from "./data-table/index.jsx";
|
||||||
import { LinkedScrollWrapper, LinkedScrollSection } from './linked-scroll';
|
import { LinkedScrollWrapper, LinkedScrollSection } from "./linked-scroll";
|
||||||
|
|
||||||
class Root extends React.PureComponent {
|
class Root extends React.PureComponent {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
@@ -12,9 +12,12 @@ class Root extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate () {
|
componentDidUpdate () {
|
||||||
const tableWidth = this.dataTableRef.getBoundingClientRect().width;
|
let tableWidth;
|
||||||
if (this.renderedTableWidth !== tableWidth) {
|
if (this.dataTableRef) {
|
||||||
this.forceUpdate();
|
tableWidth = this.dataTableRef.getBoundingClientRect().width;
|
||||||
|
if (this.renderedTableWidth !== tableWidth) {
|
||||||
|
this.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +28,7 @@ class Root extends React.PureComponent {
|
|||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { editmodeClass, component, state } = this.props;
|
const { editmodeClass, component, state } = this.props;
|
||||||
const { data, general, styling } = state;
|
const { data, general, styling, error } = state;
|
||||||
|
|
||||||
// Determine cell- and column separator width
|
// Determine cell- and column separator width
|
||||||
let cellWidth = '0px';
|
let cellWidth = '0px';
|
||||||
@@ -48,72 +51,80 @@ class Root extends React.PureComponent {
|
|||||||
let separatorWidth = 0;
|
let separatorWidth = 0;
|
||||||
if (general.useColumnSeparator) {
|
if (general.useColumnSeparator) {
|
||||||
separatorCount = data.headers.dimension2.length - 1;
|
separatorCount = data.headers.dimension2.length - 1;
|
||||||
separatorWidth = Math.min(Math.floor(tableWidth * 0.2 / separatorCount), 8);
|
separatorWidth = Math.min(
|
||||||
|
Math.floor((tableWidth * 0.2) / separatorCount),
|
||||||
|
8
|
||||||
|
);
|
||||||
columnSeparatorWidth = `${separatorWidth}px`;
|
columnSeparatorWidth = `${separatorWidth}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const separatorWidthSum = (separatorWidth + borderWidth) * separatorCount;
|
const separatorWidthSum =
|
||||||
cellWidth = `${Math.floor((tableWidth - separatorWidthSum - headerMarginRight - borderWidth)
|
(separatorWidth + borderWidth) * separatorCount;
|
||||||
/ rowCellCount) - borderWidth}px`;
|
cellWidth = `${Math.floor(
|
||||||
|
(tableWidth - separatorWidthSum - headerMarginRight - borderWidth) /
|
||||||
|
rowCellCount) - borderWidth}px`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="root">
|
<div className="root">
|
||||||
<LinkedScrollWrapper>
|
{error ? (
|
||||||
<div className={`kpi-table ${editmodeClass}`}>
|
<div className={`error ${editmodeClass}`}>
|
||||||
<HeadersTable
|
{state.layout.errormessage}
|
||||||
cellWidth={cellWidth}
|
|
||||||
columnSeparatorWidth={columnSeparatorWidth}
|
|
||||||
component={component}
|
|
||||||
data={data}
|
|
||||||
general={general}
|
|
||||||
isKpi
|
|
||||||
styling={styling}
|
|
||||||
/>
|
|
||||||
<LinkedScrollSection linkVertical>
|
|
||||||
<DataTable
|
|
||||||
cellWidth={cellWidth}
|
|
||||||
columnSeparatorWidth={columnSeparatorWidth}
|
|
||||||
component={component}
|
|
||||||
data={data}
|
|
||||||
general={general}
|
|
||||||
renderData={false}
|
|
||||||
styling={styling}
|
|
||||||
/>
|
|
||||||
</LinkedScrollSection>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
) : (
|
||||||
className={`data-table ${editmodeClass}`}
|
<LinkedScrollWrapper>
|
||||||
style={{ width: general.cellWidth ? 'auto' : '100%' }}
|
<div className={`kpi-table ${editmodeClass}`}>
|
||||||
ref={this.onDataTableRefSet}
|
|
||||||
>
|
|
||||||
<LinkedScrollSection linkHorizontal>
|
|
||||||
<HeadersTable
|
<HeadersTable
|
||||||
cellWidth={cellWidth}
|
cellWidth={cellWidth}
|
||||||
columnSeparatorWidth={columnSeparatorWidth}
|
columnSeparatorWidth={columnSeparatorWidth}
|
||||||
component={component}
|
component={component}
|
||||||
data={data}
|
data={data}
|
||||||
general={general}
|
general={general}
|
||||||
isKpi={false}
|
isKpi
|
||||||
styling={styling}
|
styling={styling}
|
||||||
/>
|
/>
|
||||||
</LinkedScrollSection>
|
<LinkedScrollSection linkVertical>
|
||||||
<LinkedScrollSection
|
<DataTable
|
||||||
linkHorizontal
|
cellWidth={cellWidth}
|
||||||
linkVertical
|
columnSeparatorWidth={columnSeparatorWidth}
|
||||||
|
component={component}
|
||||||
|
data={data}
|
||||||
|
general={general}
|
||||||
|
renderData={false}
|
||||||
|
styling={styling}
|
||||||
|
/>
|
||||||
|
</LinkedScrollSection>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className={`data-table ${editmodeClass}`}
|
||||||
|
style={{ width: general.cellWidth ? 'auto' : '100%' }}
|
||||||
|
ref={this.onDataTableRefSet}
|
||||||
>
|
>
|
||||||
<DataTable
|
<LinkedScrollSection linkHorizontal>
|
||||||
cellWidth={cellWidth}
|
<HeadersTable
|
||||||
columnSeparatorWidth={columnSeparatorWidth}
|
cellWidth={cellWidth}
|
||||||
component={component}
|
columnSeparatorWidth={columnSeparatorWidth}
|
||||||
data={data}
|
component={component}
|
||||||
general={general}
|
data={data}
|
||||||
styling={styling}
|
general={general}
|
||||||
/>
|
isKpi={false}
|
||||||
</LinkedScrollSection>
|
styling={styling}
|
||||||
</div>
|
/>
|
||||||
</LinkedScrollWrapper>
|
</LinkedScrollSection>
|
||||||
|
<LinkedScrollSection linkHorizontal linkVertical>
|
||||||
|
<DataTable
|
||||||
|
cellWidth={cellWidth}
|
||||||
|
columnSeparatorWidth={columnSeparatorWidth}
|
||||||
|
component={component}
|
||||||
|
data={data}
|
||||||
|
general={general}
|
||||||
|
styling={styling}
|
||||||
|
/>
|
||||||
|
</LinkedScrollSection>
|
||||||
|
</div>
|
||||||
|
</LinkedScrollWrapper>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -123,9 +134,9 @@ Root.propTypes = {
|
|||||||
component: PropTypes.shape({}).isRequired,
|
component: PropTypes.shape({}).isRequired,
|
||||||
editmodeClass: PropTypes.string.isRequired,
|
editmodeClass: PropTypes.string.isRequired,
|
||||||
state: PropTypes.shape({
|
state: PropTypes.shape({
|
||||||
data: PropTypes.object.isRequired,
|
data: PropTypes.object,
|
||||||
general: PropTypes.object.isRequired,
|
general: PropTypes.object,
|
||||||
styling: PropTypes.object.isRequired
|
styling: PropTypes.object
|
||||||
}).isRequired
|
}).isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user