Compare commits

...

50 Commits

Author SHA1 Message Date
Purwa Shrivastava
43fa4cd380 fix: Environment Setup not needed for deploy 2022-11-11 14:48:15 +01:00
Purwa Shrivastava
233f2a5c7c Merge pull request #95 from qlik-oss/fix/QB-14863
fix: QB-14863-duplicateKeys
2022-11-11 14:28:12 +01:00
Purwa Shrivastava
ca6893296a fix: permission issue 2022-11-10 14:53:53 +01:00
Purwa Shrivastava
f13312c288 fix: yml file 2022-11-10 14:45:37 +01:00
Purwa Shrivastava
6fc73c4cc8 fix: update docker image 2022-11-10 14:34:46 +01:00
Purwa Shrivastava
9424e847c9 fix: use node v16 instead of v17 2022-11-10 14:09:53 +01:00
Purwa Shrivastava
b86a3ae9c6 fix: generated unique keys for data columns and removed blackduck scan 2022-11-10 10:53:19 +01:00
Jingjing Xie
ed50a8f3d3 Merge pull request #93 from qlik-oss/fix/QB-5202-option-in-QCS
fix: Export as XLS in QCS
2021-07-07 16:42:47 +02:00
Jingjing Xie
cca315efbb fix: check for desktop 2021-07-07 14:15:24 +02:00
Jingjing Xie
c888dd9fe4 fix: Export as XLS in QCS 2021-07-06 10:24:00 +02:00
Jingjing Xie
467948a46c Merge pull request #92 from qlik-oss/fcy/QB-5202
fix: enable Export as XLS option on qcs
2021-06-23 15:56:45 +02:00
Jingjing Xie
315191ccfa fix: comment 2021-06-23 12:29:23 +02:00
Jingjing Xie
80a9fdf2a9 fix: enable Export as XLS option on qcs 2021-06-23 10:26:36 +02:00
Tobias Åström
092b89d69f Merge pull request #91 from qlik-oss/tsm/qb-2727
fix: remove infinite loop
2021-01-14 16:51:40 +01:00
caele
f934fa929d chore: add comment 2021-01-14 10:23:22 +01:00
caele
acf6eb7b26 fix: remove infinite loop 2021-01-13 16:09:38 +01:00
Tobias Åström
d6ae86220e Merge pull request #90 from qlik-oss/tsm/increase-style-rows
Tsm/increase style rows
2021-01-05 09:29:18 +01:00
caele
3397bd419d fix: set style rows to 5000 2021-01-05 09:13:46 +01:00
caele
2dd11ad24c fix: set style rows to 5000 2021-01-05 09:10:39 +01:00
Tobias Åström
1099be87fa chore: add comment to explain export in QCS 2020-09-24 13:29:39 +02:00
Tobias Åström
13c5b9613d Merge pull request #89 from qlik-oss/tsm/QB-1634
fix: correctly check data export privileges
2020-06-09 08:54:31 +02:00
Tobias Åström
32890ba3db fix: correctly check data export privileges 2020-06-08 09:27:36 +02:00
Snigdha
8f7465dd8d Merge pull request #88 from qlik-oss/qb-1147-selection-refresh-pivot
pivot selection refresh fixed
2020-03-27 12:20:46 +05:30
Snigdha Snigdha
be710cb17b pivot selection refresh fixed 2020-03-20 18:29:32 +05:30
Avinash
2729321f40 Merge pull request #87 from qlik-oss/bugfix/QB-980
PL Pivot table Error message not showing
2020-02-26 18:06:04 +05:30
Avinash Shinde
2710d4629f fix: PL Pivot table Error message not showing 2020-02-25 13:17:19 +05:30
Purwa Shrivastava
8c093a4692 Merge pull request #86 from qlik-oss/QLIK-98564/sourceMaps
Removing source maps from production mode.
2020-02-14 11:03:05 +01:00
Avinash
ec822b843b Merge pull request #85 from qlik-oss/bugfix/QB-959
bugfix for  Column separator is misaligned
2020-02-14 11:51:42 +05:30
Purwa Shrivastava
5dc8bb49a4 Removing souce maps from production mode. 2020-02-12 08:06:07 +01:00
Avinash Shinde
0d98553a71 fix: removing .lock file 2020-02-11 16:32:58 +05:30
Avinash Shinde
6513a294b3 fix: Column separator is misaligned 2020-02-10 15:32:43 +05:30
Shiben Dutta
79e753c2b2 Merge pull request #84 from qlik-oss/QB262
fix: disable data export as per QMC
2020-02-04 08:26:39 +05:30
Shiben Dutta
468598540f fix: disable data export as per QMC 2020-01-16 17:22:50 +05:30
snigdhaprasad26
045d0db215 Merge pull request #83 from qlik-oss/QB-285-console-error
console error fixed
2020-01-10 13:43:25 +05:30
Snigdha Snigdha
73011d0388 fix: eslint error fixed and yarn.lock file removed 2020-01-09 16:24:15 +05:30
Snigdha Snigdha
41cf77e8d2 fix: console error fixed of qb-285 2020-01-09 15:49:47 +05:30
Snigdha Snigdha
1355381346 fix: console error fixed of qb-285 2020-01-09 15:18:05 +05:30
Snigdha Snigdha
730f35a83c fix: console error fixed of qb-285 2020-01-09 15:11:11 +05:30
Snigdha Snigdha
71bf25e8fb fix: console error fixed of qb-285 2020-01-09 15:08:57 +05:30
Snigdha Snigdha
9b4fe54239 fix: console error of qb-285 2020-01-09 14:56:56 +05:30
Snigdha Snigdha
e59c594215 console error fixed 2019-12-31 19:44:54 +05:30
Purwa Shrivastava
97a54e6f5a Merge pull request #82 from qlik-oss/qb-612/missingvaluesfix
Fix missing values resulting in data being rendered in wrong columns.
2019-12-10 14:40:45 +01:00
Purwa Shrivastava
eac9fd2a5f Fix missing values resulting in data being rendered in wrong columns. 2019-12-10 12:29:28 +01:00
Purwa Shrivastava
96f09f9323 Merge pull request #81 from qlik-oss/QB-377/errorMessage
React rendering Errors for few apps.
2019-12-09 08:42:31 +01:00
Purwa Shrivastava
2ab340f3f1 React rendering Errors for few apps. 2019-12-06 11:11:25 +01:00
Purwa Shrivastava
58d0f542eb Merge pull request #80 from qlik-oss/QB-377/errorMessage
Corrected the react error when componentDidUpdate is called. So the e…
2019-12-06 10:15:05 +01:00
Purwa Shrivastava
8ba826a0ea Corrected the react error when componentDidUpdate is called. So the error message is uniformly shown in both analysis and edit mode. 2019-12-06 10:12:07 +01:00
Purwa Shrivastava
d2446395e2 Merge pull request #77 from qlik-oss/QB-331/PivotPagination
Pivot Pagination Fix.
2019-12-05 13:41:29 +01:00
Purwa Shrivastava
f17a7b7714 Merge pull request #79 from qlik-oss/QB-493/wrongDataDisplay
Qb 493/wrong data display
2019-12-05 09:15:42 +01:00
Purwa Shrivastava
fd9e645fc1 Pivot Pagination Fix. 2019-11-21 10:59:28 +01:00
18 changed files with 485 additions and 428 deletions

View File

@@ -3,7 +3,7 @@ version: 2
defaults: &defaults defaults: &defaults
working_directory: ~/qlik-smart-pivot working_directory: ~/qlik-smart-pivot
docker: docker:
- image: circleci/node:stretch - image: circleci/node:16.13.0
environment: environment:
GITHUB_ORG: "qlik-oss" GITHUB_ORG: "qlik-oss"
GITHUB_REPO: "PLSmartPivot" GITHUB_REPO: "PLSmartPivot"
@@ -12,20 +12,12 @@ defaults: &defaults
jobs: jobs:
test: test:
docker: docker:
- image: circleci/node:stretch-browsers - image: circleci/node:16.13.0-browsers
steps: steps:
- checkout - checkout
- run: - run:
name: Install dependencies name: Install dependencies
command: npm install command: npm install
- run:
name: BlackDuck scan
command: curl -s https://detect.synopsys.com/detect.sh | bash -s -- \
--blackduck.url="https://qliktech.blackducksoftware.com" \
--blackduck.trust.cert=true \
--blackduck.username="svc-blackduck" \
--blackduck.password=${svc_blackduck} \
--detect.project.name="viz-bundle-qlik-smart-pivot"
bump-version: bump-version:
<<: *defaults <<: *defaults
@@ -43,6 +35,10 @@ jobs:
<<: *defaults <<: *defaults
steps: steps:
- checkout - checkout
- run:
name: Setup environment
command: |
sudo chmod +x ./.circleci/upgrade-node.sh
- attach_workspace: - attach_workspace:
at: ~/qlik-smart-pivot at: ~/qlik-smart-pivot
- run: - run:

17
.circleci/upgrade-node.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -eo pipefail
NVM_DIR="/opt/circleci/.nvm"
NODE_VERSION="v16"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
echo "Installing Node $NODE_VERSION"
nvm install $NODE_VERSION
nvm alias default $NODE_VERSION
# Each step uses the same `$BASH_ENV`, so need to modify it
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV

View File

@@ -3,15 +3,15 @@ module.exports = {
ecmaVersion: 6, ecmaVersion: 6,
ecmaFeatures: { ecmaFeatures: {
jsx: true, jsx: true,
modules: true modules: true,
}, },
sourceType: "module" sourceType: "module",
}, },
parser: "babel-eslint", parser: "babel-eslint",
env: { env: {
browser: true, browser: true,
es6: true, es6: true,
node: true node: true,
}, },
globals: { globals: {
angular: false, angular: false,
@@ -21,49 +21,63 @@ module.exports = {
document: false, document: false,
expect: false, expect: false,
it: false, it: false,
require: false require: false,
}, },
rules: { rules: {
"indent": ["error", 2, { "SwitchCase": 1 }], indent: ["warn", 2, { SwitchCase: 1 }],
"linebreak-style": ["error", "unix"], "linebreak-style": ["error", "unix"],
"object-curly-spacing": ["error", "always"], "object-curly-spacing": ["error", "always"],
"max-lines": ["warn", 300], "max-lines": ["warn", 300],
"max-len": ["warn", { "code": 120, "ignoreComments": true, "ignoreTrailingComments": false }], "max-len": [
"warn",
{ code: 120, ignoreComments: true, ignoreTrailingComments: false },
],
"no-console": ["warn"], "no-console": ["warn"],
"no-mixed-operators": ["warn", { "no-mixed-operators": [
"groups": [ "warn",
["==", "!=", "===", "!==", ">", ">=", "<", "<="], {
["&&", "||"], groups: [
["in", "instanceof"] ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
], ["&&", "||"],
"allowSamePrecedence": true ["in", "instanceof"],
}], ],
allowSamePrecedence: true,
},
],
"comma-dangle": ["off"],
"space-before-function-paren": ["off"],
"no-multi-spaces": ["error"], "no-multi-spaces": ["error"],
"no-cond-assign": ["warn"], "no-cond-assign": ["warn"],
"no-fallthrough": ["warn"], "no-fallthrough": ["warn"],
"no-undef": ["error"], "no-undef": ["error"],
"no-unused-vars": ["error"], "no-unused-vars": ["error"],
"no-use-before-define": ["error", { "functions": false, "classes": false, "variables": false }], "no-use-before-define": [
"error",
{ functions: false, classes: false, variables: false },
],
"no-useless-escape": ["warn"], "no-useless-escape": ["warn"],
"no-useless-return": ["warn"], "no-useless-return": ["warn"],
"no-underscore-dangle": ["warn", { "allow": ["_id"] }], "no-underscore-dangle": ["warn", { allow: ["_id"] }],
"no-redeclare": ["error"], "no-redeclare": ["error"],
"no-restricted-syntax": ["warn"], "no-restricted-syntax": ["warn"],
"operator-linebreak": ["warn", "before"], "operator-linebreak": ["warn", "before"],
"prefer-promise-reject-errors": ["warn"], "prefer-promise-reject-errors": ["warn"],
"padded-blocks": ["warn", { "blocks": "never", "switches": "never", "classes": "never" }], "padded-blocks": [
"semi": ["error", "always"], "warn",
{ blocks: "never", switches: "never", classes: "never" },
],
semi: ["error", "always"],
"valid-typeof": ["warn"], "valid-typeof": ["warn"],
"no-eval": ["error"], "no-eval": ["error"],
"no-implied-eval": ["error"], "no-implied-eval": ["error"],
"no-debugger": ["warn"], "no-debugger": ["warn"],
"no-unreachable": ["warn"], "no-unreachable": ["warn"],
"quotes": ["warn", "single", { "avoidEscape": true }], quotes: ["warn", "single", { avoidEscape: true }],
"sort-imports": ["off"], "sort-imports": ["off"],
"max-lines-per-function": ["off"], // marks the entire functions, a bit too noisy "max-lines-per-function": ["off"], // marks the entire functions, a bit too noisy
"complexity": ["warn"], complexity: ["warn"],
"camelcase": ["warn"], camelcase: ["warn"],
"max-statements": ["off"], // marks the entire functions, a bit too noisy "max-statements": ["off"], // marks the entire functions, a bit too noisy
"sort-vars": ["off"], // not much value for the work "sort-vars": ["off"], // not much value for the work
"init-declarations": ["off"], "init-declarations": ["off"],
"capitalized-comments": ["off"], "capitalized-comments": ["off"],
@@ -99,13 +113,13 @@ module.exports = {
"array-bracket-newline": ["warn"], "array-bracket-newline": ["warn"],
"array-element-newline": ["warn"], "array-element-newline": ["warn"],
"object-shorthand": ["warn"], "object-shorthand": ["warn"],
"eqeqeq": ["warn"], eqeqeq: ["warn"],
"no-empty-function": ["off"], "no-empty-function": ["off"],
"function-paren-newline": ["warn"], "function-paren-newline": ["warn"],
"no-invalid-this": ["warn"], "no-invalid-this": ["warn"],
"newline-per-chained-call": ["warn"], "newline-per-chained-call": ["warn"],
"no-unused-expressions": ["warn"], "no-unused-expressions": ["warn"],
"strict": ["warn"], strict: ["warn"],
"no-ternary": ["off"], "no-ternary": ["off"],
"multiline-ternary": ["off"], "multiline-ternary": ["off"],
"no-param-reassign": ["error"], "no-param-reassign": ["error"],
@@ -115,9 +129,9 @@ module.exports = {
"default-case": ["warn"], "default-case": ["warn"],
"no-alert": ["warn"], "no-alert": ["warn"],
"max-params": ["warn"], "max-params": ["warn"],
"brace-style": ["warn", "1tbs", { "allowSingleLine": true }], "brace-style": ["warn", "1tbs", { allowSingleLine: true }],
"prefer-const": ["warn"], "prefer-const": ["warn"],
"class-methods-use-this":["warn"], "class-methods-use-this": ["warn"],
// plugin:react // plugin:react
"react/jsx-indent": ["warn", 2], "react/jsx-indent": ["warn", 2],
"react/jsx-indent-props": ["warn", 2], "react/jsx-indent-props": ["warn", 2],
@@ -131,10 +145,7 @@ module.exports = {
"react/jsx-max-depth": ["off"], // rule throws exception in single-dimension-measure "react/jsx-max-depth": ["off"], // rule throws exception in single-dimension-measure
"react/jsx-filename-extension": ["warn"], "react/jsx-filename-extension": ["warn"],
"react/prefer-stateless-function": ["warn"], "react/prefer-stateless-function": ["warn"],
"react/no-set-state": ["warn"] "react/no-set-state": ["warn"],
}, },
extends: [ extends: ["eslint:all", "plugin:react/all"],
"eslint:all", };
"plugin:react/all"
]
}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"json.format.enable": false
}

View File

@@ -24,7 +24,8 @@ gulp.task('qext', function () {
repository: pkg.repository, repository: pkg.repository,
dependencies: { dependencies: {
'qlik-sense': '>=5.5.x' 'qlik-sense': '>=5.5.x'
} },
__next: true
}; };
if (pkg.contributors) { if (pkg.contributors) {
qext.contributors = pkg.contributors; qext.contributors = pkg.contributors;

View File

@@ -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;
} }

View File

@@ -33,35 +33,69 @@ class DataTable extends React.PureComponent {
}; };
const renderMeasurementData = (dimIndex, atEvery) => { const renderMeasurementData = (dimIndex, atEvery) => {
const injectSeparatorsArray = injectSeparators(
matrix[dimIndex],
columnSeparatorWidth,
atEvery
);
if (dimension2.length <= 0) { if (dimension2.length <= 0) {
return injectSeparatorsArray; return injectSeparators(
matrix[dimIndex],
columnSeparatorWidth,
atEvery
);
} }
const measurementDataRow = [];
let measurementDataRow = [], let index = 0,
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 < matrix[dimIndex].length; index++) {
if (dimension1[dimIndex].displayValue === injectSeparatorsArray[index].parents.dimension1.header) { match = false;
if (dim2.displayValue === injectSeparatorsArray[index].parents.dimension2.header) { if (
if (measure.name === injectSeparatorsArray[index].parents.measurement.header) { matrix[dimIndex][index].parents &&
measurementDataRow.push(injectSeparatorsArray[index]); dimension1[dimIndex].displayValue ===
matrix[dimIndex][index].parents.dimension1.header
) {
if (
dim2.displayValue ===
matrix[dimIndex][index].parents.dimension2.header
) {
if (
measure.name ===
matrix[dimIndex][index].parents.measurement.header
) {
measurementDataRow.push(matrix[dimIndex][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 injectSeparators(
measurementDataRow,
columnSeparatorWidth,
atEvery
);
}; };
return ( return (
<div className="row-wrapper"> <div className="row-wrapper">
<table> <table>
@@ -87,7 +121,7 @@ class DataTable extends React.PureComponent {
}; };
return ( return (
<tr key={dimensionEntry.displayValue}> <tr key={`${dimensionEntry.displayValue}-${dimensionIndex}-separator`}>
{!renderData ? {!renderData ?
<RowHeader <RowHeader
component={component} component={component}
@@ -109,15 +143,13 @@ class DataTable extends React.PureComponent {
} }
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
const { dimension1: dimension1Info, dimension2, measurement } = measurementData.parents;
const id = `${dimension1Info.elementNumber}-${dimension2 && dimension2.elementNumber}-${measurement.header}-${measurement.index}`;
return ( return (
<DataCell <DataCell
cellWidth={cellWidth} cellWidth={cellWidth}
component={component} component={component}
data={data} data={data}
general={general} general={general}
key={`${dimensionEntry.displayValue}-${id}`} key={`${Math.random()}-${new Date().getTime()}`}
measurement={measurementData} measurement={measurementData}
styleBuilder={styleBuilder} styleBuilder={styleBuilder}
styling={styling} styling={styling}

View File

@@ -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

View File

@@ -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) {
@@ -63,6 +86,6 @@ export function initializeDesignList (component, layout) {
resolve(data); resolve(data);
}; };
stylingField.OnData.bind(listener); stylingField.OnData.bind(listener);
stylingField.getData(); stylingField.getData({ rows: 5000 });
}); });
} }

View File

@@ -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.`
} }
} }
}; };

View File

@@ -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;

View File

@@ -77,7 +77,7 @@ class HeadersTable extends React.PureComponent {
colSpan={measurements.length} colSpan={measurements.length}
component={component} component={component}
entry={entry} entry={entry}
key={entry.displayValue} key={`${entry.displayValue}-${index}-separator`}
styling={styling} styling={styling}
/> />
); );

View File

@@ -1,18 +1,18 @@
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 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 ({ flags }) => ({
design: { design: {
dimensions: { dimensions: {
max: 1, max: 1,
@@ -21,14 +21,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 +45,10 @@ export default {
qDimensions: [], qDimensions: [],
qInitialDataFetch: [ qInitialDataFetch: [
{ {
qHeight: 1, qTop: 0,
qWidth: 10 qLeft: 0,
qWidth: 50,
qHeight: 50
} }
], ],
qMeasures: [], qMeasures: [],
@@ -58,23 +60,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,31 +93,48 @@ 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); if (!this.$scope.layout.allowexportxls) {
const isPersonalResult = await app.global.isPersonalMode();
if (!this.$scope.layout.allowexportxls || (isPersonalResult && isPersonalResult.qReturn)) {
return menu; return menu;
} }
menu.addItem({ const app = this.backendApi.model.app;
translation: "Export as XLS", const isPersonalResult = await app.global.isPersonalMode();
tid: "export-excel",
icon: "export", // Export as XLS option is removed from desktop because the desktop wrapper blocks downloads.
select: () => { // Enabled for windows and QCS
exportXLS( // isPersonalMode returns true for both desktop and QCS
this.$element, // By checking both if has download dialog and if is QCS can enable Export as XLS option on QCS
this.$scope.layout.title, if (
this.$scope.layout.subtitle, (this.backendApi.model.layout.qMeta.privileges.includes('exportdata') && !isPersonalResult) ||
this.$scope.layout.footnote); (flags.isEnabled('DOWNLOAD_USE_REPORTING') && isPersonalResult)
} ) {
}); menu.addItem({
translation: 'Export as XLS',
tid: 'export-excel',
icon: 'export',
select: () => {
exportXLS(
this.$element,
this.$scope.layout.title,
this.$scope.layout.subtitle,
this.$scope.layout.footnote
);
}
});
}
return menu; return menu;
}, },
version: 1.0 version: 1.0
}; });

View File

@@ -1,50 +1,55 @@
import { distinctArray } from './utilities'; import { distinctArray } from "./utilities";
export const HEADER_FONT_SIZE = { export const HEADER_FONT_SIZE = {
SMALL: -1, SMALL: -1,
MEDIUM: 1 MEDIUM: 1,
}; };
function getAlignment (option) { function getAlignment(option) {
const alignmentOptions = { const alignmentOptions = {
1: 'left', 1: "left",
2: 'center', 2: "center",
3: 'right' 3: "right",
}; };
return alignmentOptions[option] || 'left'; return alignmentOptions[option] || "left";
} }
function getFontSizeAdjustment (option) { function getFontSizeAdjustment(option) {
const fontSizeAdjustmentOptions = { const fontSizeAdjustmentOptions = {
1: HEADER_FONT_SIZE.SMALL, 1: HEADER_FONT_SIZE.SMALL,
2: HEADER_FONT_SIZE.MEDIUM 2: HEADER_FONT_SIZE.MEDIUM,
}; };
return fontSizeAdjustmentOptions[option] || 0; return fontSizeAdjustmentOptions[option] || 0;
} }
function generateMeasurements (information) { function generateMeasurements(information) {
return information.map(measurement => { return information.map((measurement) => {
const transformedMeasurement = { const transformedMeasurement = {
format: measurement.qNumFormat.qFmt || '#.##0', format: measurement.qNumFormat.qFmt || "#.##0",
name: measurement.qFallbackTitle name: measurement.qFallbackTitle,
}; };
return transformedMeasurement; return transformedMeasurement;
}); });
} }
function generateDimensionEntry (information, data) { function generateDimensionEntry(information, data) {
return { return {
displayValue: data.qText || data.qNum, displayValue: data.qText || data.qNum,
elementNumber: data.qElemNumber, elementNumber: data.qElemNumber,
name: information.qFallbackTitle, name: information.qFallbackTitle,
value: data.qNum value: data.qNum,
}; };
} }
function generateMatrixCell ({ cell, dimension1Information, dimension2Information, measurementInformation }) { function generateMatrixCell({
cell,
dimension1Information,
dimension2Information,
measurementInformation,
}) {
const matrixCell = { const matrixCell = {
displayValue: cell.qText, displayValue: cell.qText,
format: measurementInformation.format, format: measurementInformation.format,
@@ -52,178 +57,136 @@ function generateMatrixCell ({ cell, dimension1Information, dimension2Informatio
parents: { parents: {
dimension1: { dimension1: {
elementNumber: dimension1Information.qElemNumber, elementNumber: dimension1Information.qElemNumber,
header: dimension1Information.qText header: dimension1Information.qText,
}, },
measurement: { measurement: {
header: measurementInformation.name, header: measurementInformation.name,
index: measurementInformation.index index: measurementInformation.index,
} },
}, },
value: cell.qNum value: cell.qNum,
}; };
if (dimension2Information) { if (dimension2Information) {
matrixCell.parents.dimension2 = { matrixCell.parents.dimension2 = {
elementNumber: dimension2Information.qElemNumber, elementNumber: dimension2Information.qElemNumber,
header: dimension2Information.qText header: dimension2Information.qText,
}; };
} }
return matrixCell; return matrixCell;
} }
let lastRow = 0; function generateDataSet(
function generateDataSet ( component,
component, dimensionsInformation, measurementsInformation, dataCube) { 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(
let firstDataCell = 1; dimensionsInformation[0],
if (hasSecondDimension) { row[0]
dimension2Entry = generateDimensionEntry(dimensionsInformation[1], row[1]); );
dimension2.push(dimension2Entry); dimension1.push(dimension1Entry);
firstDataCell = 2; let dimension2Entry;
} let firstDataCell = 1;
let matrixRow = row if (hasSecondDimension) {
.slice(firstDataCell, row.length) dimension2Entry = generateDimensionEntry(
.map((cell, cellIndex) => { dimensionsInformation[1],
const measurementInformation = measurements[cellIndex]; row[1]
measurementInformation.index = cellIndex; );
const dimension1Information = row[0]; // eslint-disable-line prefer-destructuring dimension2.push(dimension2Entry);
const dimension2Information = hasSecondDimension ? row[1] : null; firstDataCell = 2;
const generatedCell = generateMatrixCell({ }
cell, let matrixRow = row
dimension1Information, .slice(firstDataCell, row.length)
dimension2Information, .map((cell, cellIndex) => {
measurementInformation const measurementInformation = measurements[cellIndex];
measurementInformation.index = cellIndex;
const dimension1Information = row[0]; // eslint-disable-line prefer-destructuring
const dimension2Information = hasSecondDimension ? row[1] : null;
const generatedCell = generateMatrixCell({
cell,
dimension1Information,
dimension2Information,
measurementInformation,
});
return generatedCell;
}); });
return generatedCell; let appendToRowIndex = matrix.length;
}); if (hasSecondDimension) {
// See if there already is a row for the current dim1
let appendToRowIndex = matrix.length; for (let i = 0; i < matrix.length; i++) {
if (hasSecondDimension) { if (
// See if there already is a row for the current dim1 matrix[i][0].parents.dimension1.header ===
for (let i = 0; i < matrix.length; i++) { 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,
matrix, matrix,
measurements measurements,
}; };
} }
/* function initializeTransformed({
* Appends the cells of the source row, as well as those missing, to the destination row, starting $element,
* from the given source index. Returns the source index of the next source cell after this has component,
* completed. If there is a second dimension the dim2ElementNumber should be set to the current dataCube,
* index of the dimension2 value being processed. designList,
*/ layout,
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 { dimension1, dimension2, measurements, matrix } = generateDataSet(
const maxLoops = layout.maxloops; component,
const { dimensionsInformation,
dimension1, measurementsInformation,
dimension2, dataCube
measurements, );
matrix
} = generateDataSet(component, dimensionsInformation, measurementsInformation, dataCube);
const customSchemaBasic = []; const customSchemaBasic = [];
const customSchemaFull = []; const customSchemaFull = [];
let customHeadersCount = 0; let customHeadersCount = 0;
if (designList && designList.length > 0) { if (designList && designList.length > 0) {
const headers = designList[0].split(';'); const headers = designList[0].split(";");
customHeadersCount = headers.length; customHeadersCount = headers.length;
for (let lineNumber = 0; lineNumber < designList.length; lineNumber += 1) { for (let lineNumber = 0; lineNumber < designList.length; lineNumber += 1) {
customSchemaFull[lineNumber] = new Array(headers.length); customSchemaFull[lineNumber] = new Array(headers.length);
const data = designList[lineNumber].split(';'); const data = designList[lineNumber].split(";");
if (data.length === headers.length) { if (data.length === headers.length) {
for (let headerIndex = 0; headerIndex < headers.length; headerIndex += 1) { for (
let headerIndex = 0;
headerIndex < headers.length;
headerIndex += 1
) {
[customSchemaBasic[lineNumber]] = data; [customSchemaBasic[lineNumber]] = data;
customSchemaFull[lineNumber][headerIndex] = data[headerIndex]; customSchemaFull[lineNumber][headerIndex] = data[headerIndex];
} }
@@ -237,25 +200,28 @@ function initializeTransformed ({ $element, component, dataCube, designList, lay
// the widths as percentages of the available width. However, this often results in random // the widths as percentages of the available width. However, this often results in random
// columns getting 1px wider than the others because of rounding necessary to fill the width. // columns getting 1px wider than the others because of rounding necessary to fill the width.
// This 1px causes missalignment between the data- and header tables. // This 1px causes missalignment between the data- and header tables.
cellWidth = ''; cellWidth = "";
} else { } else {
// If using the previous solution just set 60px // If using the previous solution just set 60px
cellWidth = `${layout.columnwidthslider > 10 ? layout.columnwidthslider : 60}px`; cellWidth = `${
layout.columnwidthslider > 10 ? layout.columnwidthslider : 60
}px`;
} }
// top level properties could be reducers and then components connect to grab what they want, // top level properties could be reducers and then components connect to grab what they want,
// possibly with reselect for some presentational transforms (moving some of the presentational logic like formatting and such) // possibly with reselect for some presentational transforms (moving some of the presentational logic like formatting and such)
const transformedProperties = { const transformedProperties = {
element: $element[0],
data: { data: {
headers: { headers: {
dimension1, // column headers dimension1, // column headers
dimension2, // parent row headers if exists dimension2, // parent row headers if exists
measurements // row headers, looped for each dimension2 if exists measurements, // row headers, looped for each dimension2 if exists
}, },
matrix, // 2d array of all rows/cells to render in body of datatable matrix, // 2d array of all rows/cells to render in body of datatable
meta: { meta: {
dimensionCount: dimensionsInformation.length dimensionCount: dimensionsInformation.length,
} },
}, },
general: { general: {
allowExcelExport: layout.allowexportxls, allowExcelExport: layout.allowexportxls,
@@ -263,26 +229,27 @@ 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,
}, },
selection: { selection: {
dimensionSelectionCounts: dimensionsInformation.map(dimensionInfo => dimensionInfo.qStateCounts.qSelected) dimensionSelectionCounts: dimensionsInformation.map(
(dimensionInfo) => dimensionInfo.qStateCounts.qSelected
),
}, },
styling: { styling: {
customCSV: { customCSV: {
basic: customSchemaBasic, basic: customSchemaBasic,
count: customHeadersCount, count: customHeadersCount,
full: customSchemaFull full: customSchemaFull,
}, },
hasCustomFileStyle: Boolean(designList), hasCustomFileStyle: Boolean(designList),
headerOptions: { headerOptions: {
alignment: getAlignment(layout.HeaderAlign), alignment: getAlignment(layout.HeaderAlign),
colorSchema: layout.HeaderColorSchema.color, colorSchema: layout.HeaderColorSchema.color,
fontSizeAdjustment: getFontSizeAdjustment(layout.lettersizeheader), fontSizeAdjustment: getFontSizeAdjustment(layout.lettersizeheader),
textColor: layout.HeaderTextColorSchema.color textColor: layout.HeaderTextColorSchema.color,
}, },
options: { options: {
backgroundColor: layout.rowEvenBGColor, backgroundColor: layout.rowEvenBGColor,
@@ -290,54 +257,44 @@ function initializeTransformed ({ $element, component, dataCube, designList, lay
color: layout.BodyTextColorSchema, color: layout.BodyTextColorSchema,
fontFamily: layout.FontFamily, fontFamily: layout.FontFamily,
fontSizeAdjustment: getFontSizeAdjustment(layout.lettersize), fontSizeAdjustment: getFontSizeAdjustment(layout.lettersize),
textAlignment: layout.cellTextAlignment textAlignment: layout.cellTextAlignment,
}, },
conditionalColoring: { conditionalColoring: {
enabled: layout.conditionalcoloring.enabled, enabled: layout.conditionalcoloring.enabled,
colorAllRows: layout.conditionalcoloring.colorall, colorAllRows: layout.conditionalcoloring.colorall,
rows: layout.conditionalcoloring.rows.map(row => row.rowname), rows: layout.conditionalcoloring.rows.map((row) => row.rowname),
colorAllMeasures: typeof layout.conditionalcoloring.colorallmeasures === 'undefined' colorAllMeasures:
|| layout.conditionalcoloring.colorallmeasures, typeof layout.conditionalcoloring.colorallmeasures === "undefined" ||
layout.conditionalcoloring.colorallmeasures,
measures: !layout.conditionalcoloring.measures measures: !layout.conditionalcoloring.measures
? [] : layout.conditionalcoloring.measures.split(',').map(index => Number(index)), ? []
: layout.conditionalcoloring.measures
.split(",")
.map((index) => Number(index)),
threshold: { threshold: {
poor: layout.conditionalcoloring.threshold_poor, poor: layout.conditionalcoloring.threshold_poor,
fair: layout.conditionalcoloring.threshold_fair fair: layout.conditionalcoloring.threshold_fair,
}, },
colors: { colors: {
poor: { poor: {
color: layout.conditionalcoloring.color_poor, color: layout.conditionalcoloring.color_poor,
textColor: layout.conditionalcoloring.textcolor_poor textColor: layout.conditionalcoloring.textcolor_poor,
}, },
fair: { fair: {
color: layout.conditionalcoloring.color_fair, color: layout.conditionalcoloring.color_fair,
textColor: layout.conditionalcoloring.textcolor_fair textColor: layout.conditionalcoloring.textcolor_fair,
}, },
good: { good: {
color: layout.conditionalcoloring.color_good, color: layout.conditionalcoloring.color_good,
textColor: layout.conditionalcoloring.textcolor_good textColor: layout.conditionalcoloring.textcolor_good,
} },
} },
}, },
symbolForNulls: layout.symbolfornulls, symbolForNulls: layout.symbolfornulls,
usePadding: layout.indentbool usePadding: layout.indentbool,
} },
}; };
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;
} }

View File

@@ -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;

View File

@@ -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;

View File

@@ -1,38 +1,19 @@
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) {
super(props);
this.onDataTableRefSet = this.onDataTableRefSet.bind(this);
this.renderedTableWidth = 0;
}
componentDidUpdate () {
const tableWidth = this.dataTableRef.getBoundingClientRect().width;
if (this.renderedTableWidth !== tableWidth) {
this.forceUpdate();
}
}
onDataTableRefSet (element) {
this.dataTableRef = element;
this.forceUpdate();
}
render () { render () {
const { editmodeClass, component, state } = this.props; const { editmodeClass, component, state } = this.props;
const { data, general, styling } = state; const { data, general, styling, error, element } = state;
// Determine cell- and column separator width // Determine cell- and column separator width
let cellWidth = '0px'; let cellWidth = '0px';
let columnSeparatorWidth = ''; let columnSeparatorWidth = '';
if (this.dataTableRef) { if (!error && element) {
const tableWidth = this.dataTableRef.getBoundingClientRect().width; const tableWidth = element.getBoundingClientRect().width;
this.renderedTableWidth = tableWidth;
if (general.cellWidth) { if (general.cellWidth) {
cellWidth = general.cellWidth; cellWidth = general.cellWidth;
@@ -40,7 +21,8 @@ class Root extends React.PureComponent {
columnSeparatorWidth = '8px'; columnSeparatorWidth = '8px';
} }
} else { } else {
const headerMarginRight = 8; // 230 is the left "header", rest is magic margins
const headerMarginRight = 8 + 230 + 20;
const borderWidth = 1; const borderWidth = 1;
const rowCellCount = data.matrix[0].length; const rowCellCount = data.matrix[0].length;
@@ -48,72 +30,79 @@ 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%' }}
> >
<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 +112,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
}; };

View File

@@ -3,12 +3,15 @@ const packageJSON = require('./package.json');
const path = require('path'); const path = require('path');
const DIST = path.resolve("./dist"); const DIST = path.resolve("./dist");
// eslint-disable-next-line no-process-env
const MODE = process.env.NODE_ENV || 'development'; const MODE = process.env.NODE_ENV || 'development';
const SOURCE_MAP = 'source-map';
const DEVTOOL = MODE === 'development' ? SOURCE_MAP : false;
console.log('Webpack mode:', MODE); // eslint-disable-line no-console console.log('Webpack mode:', MODE); // eslint-disable-line no-console
const config = { const config = {
devtool: 'source-map', devtool: DEVTOOL,
entry: ['./src/index.js'], entry: ['./src/index.js'],
externals: { externals: {
jquery: { jquery: {