@adaptabletools/adaptable 18.0.0-canary.10 → 18.0.0-canary.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base.css +4 -0
- package/base.css.map +1 -1
- package/index.css +6 -0
- package/index.css.map +1 -1
- package/package.json +1 -1
- package/src/AdaptableOptions/AdaptableOptions.d.ts +2 -2
- package/src/AdaptableOptions/ColumnOptions.d.ts +7 -4
- package/src/AdaptableOptions/CommentOptions.d.ts +9 -7
- package/src/AdaptableOptions/NoteOptions.d.ts +4 -1
- package/src/Api/AdaptableApi.d.ts +2 -2
- package/src/Api/ColumnApi.d.ts +4 -0
- package/src/Api/CommentApi.d.ts +11 -12
- package/src/Api/ConfigApi.d.ts +2 -2
- package/src/Api/EventApi.d.ts +7 -9
- package/src/Api/Events/CommentChanged.d.ts +11 -0
- package/src/Api/GridApi.d.ts +4 -0
- package/src/Api/Implementation/AdaptableApiImpl.d.ts +2 -2
- package/src/Api/Implementation/AdaptableApiImpl.js +2 -2
- package/src/Api/Implementation/ApiBase.d.ts +2 -2
- package/src/Api/Implementation/ApiBase.js +1 -1
- package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
- package/src/Api/Implementation/ColumnApiImpl.js +10 -0
- package/src/Api/Implementation/CommentsApiImpl.d.ts +1 -2
- package/src/Api/Implementation/ConfigApiImpl.d.ts +2 -2
- package/src/Api/Implementation/ConfigApiImpl.js +2 -2
- package/src/Api/Implementation/GridApiImpl.d.ts +1 -0
- package/src/Api/Implementation/GridApiImpl.js +9 -0
- package/src/Api/Implementation/{NotesApiImpl.d.ts → NoteApiImpl.d.ts} +7 -7
- package/src/Api/Implementation/{NotesApiImpl.js → NoteApiImpl.js} +5 -5
- package/src/Api/Implementation/OptionsApiImpl.d.ts +4 -5
- package/src/Api/Implementation/OptionsApiImpl.js +2 -12
- package/src/Api/Internal/AdaptableInternalApi.d.ts +1 -1
- package/src/Api/Internal/ExportInternalApi.d.ts +2 -1
- package/src/Api/Internal/ExportInternalApi.js +4 -1
- package/src/Api/Internal/NotesInternalApi.d.ts +1 -1
- package/src/Api/Internal/NotesInternalApi.js +1 -1
- package/src/Api/{NotesApi.d.ts → NoteApi.d.ts} +14 -14
- package/src/Api/OptionsApi.d.ts +8 -12
- package/src/PredefinedConfig/AdaptableState.d.ts +2 -2
- package/src/PredefinedConfig/CommentState.d.ts +13 -13
- package/src/PredefinedConfig/Common/RowSummary.d.ts +6 -0
- package/src/PredefinedConfig/{NotesState.d.ts → NoteState.d.ts} +2 -2
- package/src/PredefinedConfig/PredefinedConfig.d.ts +2 -2
- package/src/PredefinedConfig/Selection/GridCell.d.ts +13 -0
- package/src/PredefinedConfig/SystemState.d.ts +2 -3
- package/src/Redux/ActionsReducers/NotesRedux.d.ts +6 -6
- package/src/Redux/ActionsReducers/NotesRedux.js +1 -1
- package/src/Redux/ActionsReducers/SystemRedux.js +3 -3
- package/src/Redux/Store/AdaptableStore.js +4 -10
- package/src/Strategy/CommentsModule.js +4 -4
- package/src/Strategy/NotesModule.js +5 -5
- package/src/Utilities/Services/CellPopupService.js +2 -2
- package/src/Utilities/Services/Interface/IReportService.d.ts +1 -4
- package/src/Utilities/Services/LicenseService/index.js +1 -193
- package/src/Utilities/Services/ReportService.d.ts +7 -5
- package/src/Utilities/Services/ReportService.js +238 -22
- package/src/Utilities/license/decode.js +1 -65
- package/src/Utilities/license/hashing.js +1 -43
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.d.ts +1 -1
- package/src/View/CalculatedColumn/Wizard/CalculatedColumnWizard.js +2 -2
- package/src/View/Components/NewScopeComponent.js +2 -2
- package/src/View/Components/Popups/GridCellPopup/GridCellPopup.js +1 -1
- package/src/View/GridFilter/GridFilterViewPanel.js +1 -1
- package/src/View/Layout/LayoutViewPanel.js +2 -1
- package/src/View/Layout/Wizard/LayoutWizard.js +3 -2
- package/src/View/License/LicenseWatermark.js +1 -61
- package/src/View/Notes/NotesPopup.js +3 -3
- package/src/View/SpecialColumnSettingsWizardStep.js +1 -1
- package/src/agGrid/AdaptableAgGrid.d.ts +2 -0
- package/src/agGrid/AdaptableAgGrid.js +93 -54
- package/src/agGrid/AgGridAdapter.d.ts +1 -0
- package/src/agGrid/AgGridAdapter.js +3 -0
- package/src/agGrid/AgGridColumnAdapter.d.ts +1 -1
- package/src/agGrid/AgGridColumnAdapter.js +2 -2
- package/src/agGrid/AgGridOptionsService.d.ts +4 -1
- package/src/agGrid/AgGridOptionsService.js +22 -0
- package/src/env.js +2 -2
- package/src/metamodel/adaptable.metamodel.d.ts +41 -3
- package/src/metamodel/adaptable.metamodel.js +1 -9426
- package/src/types.d.ts +22 -20
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/src/Api/Events/CommentsChangedInfo.d.ts +0 -5
- package/src/PredefinedConfig/CellAddress.d.ts +0 -13
- package/src/PredefinedConfig/CellAddress.js +0 -4
- /package/src/Api/Events/{CommentsChangedInfo.js → CommentChanged.js} +0 -0
- /package/src/Api/{NotesApi.js → NoteApi.js} +0 -0
- /package/src/PredefinedConfig/{NotesState.js → NoteState.js} +0 -0
|
@@ -1,193 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PopupShowAlert } from '../../../Redux/ActionsReducers/PopupRedux';
|
|
3
|
-
import ObjectFactory from '../../ObjectFactory';
|
|
4
|
-
import clamp from 'lodash/clamp';
|
|
5
|
-
import { LicenseDocsLink } from '../../Constants/DocumentationLinkConstants';
|
|
6
|
-
import { decode as decodeLicense, GENERIC_APP_NAME } from '../../license/decode';
|
|
7
|
-
import { shouldLogThankYouMessage } from './shouldLogThankYouMessage';
|
|
8
|
-
const EMAIL = 'sales@adaptabletools.com';
|
|
9
|
-
const COMMERCIAL_LICENSE_SHOW_INFO_DAYS_BEFORE_EXPIRE = 10;
|
|
10
|
-
const DAY_IN_MS = 1000 * 60 * 60 * 24;
|
|
11
|
-
export var LicenseValidityType;
|
|
12
|
-
(function (LicenseValidityType) {
|
|
13
|
-
LicenseValidityType["INVALID_LICENSE"] = "INVALID_LICENSE";
|
|
14
|
-
LicenseValidityType["NO_LICENSE"] = "NO_LICENSE";
|
|
15
|
-
LicenseValidityType["NON_PRODUCTION_VALID"] = "NON_PRODUCTION_VALID";
|
|
16
|
-
LicenseValidityType["NON_PRODUCTION_EXPIRED_IN_SCOPE"] = "NON_PRODUCTION_EXPIRED_IN_SCOPE";
|
|
17
|
-
LicenseValidityType["NON_PRODUCTION_EXPIRED_OUT_OF_SCOPE"] = "NON_PRODUCTION_EXPIRED_OUT_OF_SCOPE";
|
|
18
|
-
LicenseValidityType["COMMERCIAL_VALID"] = "COMMERCIAL_VALID";
|
|
19
|
-
LicenseValidityType["COMMERCIAL_EXPIRED_IN_SCOPE"] = "COMMERCIAL_EXPIRED_IN_SCOPE";
|
|
20
|
-
LicenseValidityType["COMMERCIAL_EXPIRED_OUT_OF_SCOPE"] = "COMMERCIAL_EXPIRED_OUT_OF_SCOPE";
|
|
21
|
-
})(LicenseValidityType || (LicenseValidityType = {}));
|
|
22
|
-
const SANDPACK_REGEX = /(https):\/\/\d+\-\d+\-\d+\-(sandpack\.codesandbox\.io)/g;
|
|
23
|
-
const SANDBOX_REGEX = /(https):\/\/\S+(\.csb\.app)/g;
|
|
24
|
-
const DEMO_REGEX = /(https):\/\/\S+(\.adaptabletools\.com)/g;
|
|
25
|
-
const getOrigin = () => {
|
|
26
|
-
return typeof window !== 'undefined' ? window.location.origin : '';
|
|
27
|
-
};
|
|
28
|
-
const isInsideSandpack = () => {
|
|
29
|
-
const [_fullUrl, protocol, sandpackUrl] = Array.from(SANDPACK_REGEX.exec(getOrigin()) || []);
|
|
30
|
-
return protocol === 'https' && sandpackUrl === 'sandpack.codesandbox.io';
|
|
31
|
-
};
|
|
32
|
-
const isInsideSandbox = () => {
|
|
33
|
-
const [_fullUrl, protocol, sandboxUrl] = Array.from(SANDBOX_REGEX.exec(getOrigin()) || []);
|
|
34
|
-
return protocol === 'https' && sandboxUrl === '.csb.app';
|
|
35
|
-
};
|
|
36
|
-
const isDemoApp = () => {
|
|
37
|
-
const [_fullUrl, protocol, demoAppUrl] = Array.from(DEMO_REGEX.exec(getOrigin()) || []);
|
|
38
|
-
return protocol === 'https' && demoAppUrl === '.adaptabletools.com';
|
|
39
|
-
};
|
|
40
|
-
export class LicenseService {
|
|
41
|
-
constructor(adaptable, licenseKey, packageDetails) {
|
|
42
|
-
this.adaptable = adaptable;
|
|
43
|
-
this.licenseKey = licenseKey;
|
|
44
|
-
this.packageDetails = packageDetails;
|
|
45
|
-
this.adaptable = adaptable;
|
|
46
|
-
this.adaptable.api.eventApi.on('AdaptableReady', () => {
|
|
47
|
-
requestAnimationFrame(() => {
|
|
48
|
-
// using a rAF because we want to make sure that the window.location.origin is available (Master/Detail is fidgity sometimes)
|
|
49
|
-
this.init();
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
init() {
|
|
54
|
-
let details = null;
|
|
55
|
-
if (this.licenseKey) {
|
|
56
|
-
try {
|
|
57
|
-
details = decodeLicense(this.licenseKey);
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
details = error;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (!isInsideSandpack() && !isInsideSandbox() && !isDemoApp()) {
|
|
64
|
-
this.handleLicenseValidation(details, this.getValidityType(details, this.packageDetails));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
getValidityType(details, packageDetails) {
|
|
68
|
-
if (!details) {
|
|
69
|
-
return LicenseValidityType.NO_LICENSE;
|
|
70
|
-
}
|
|
71
|
-
if (details instanceof Error) {
|
|
72
|
-
return LicenseValidityType.INVALID_LICENSE;
|
|
73
|
-
}
|
|
74
|
-
const currentVersionReleaseDate = new Date(packageDetails.publishedAt);
|
|
75
|
-
const licenseEndDate = new Date(details.end);
|
|
76
|
-
const currentDate = new Date();
|
|
77
|
-
const isExpired = licenseEndDate < currentDate;
|
|
78
|
-
const isTrial = details.trial;
|
|
79
|
-
const isScope = licenseEndDate > currentVersionReleaseDate;
|
|
80
|
-
let validityType = null;
|
|
81
|
-
if (isExpired) {
|
|
82
|
-
if (isScope) {
|
|
83
|
-
if (isTrial) {
|
|
84
|
-
validityType = LicenseValidityType.NON_PRODUCTION_EXPIRED_IN_SCOPE;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
validityType = LicenseValidityType.COMMERCIAL_EXPIRED_IN_SCOPE;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
if (isTrial) {
|
|
92
|
-
validityType = LicenseValidityType.NON_PRODUCTION_EXPIRED_OUT_OF_SCOPE;
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
validityType = LicenseValidityType.COMMERCIAL_EXPIRED_OUT_OF_SCOPE;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
if (isTrial) {
|
|
101
|
-
validityType = LicenseValidityType.NON_PRODUCTION_VALID;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
validityType = LicenseValidityType.COMMERCIAL_VALID;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return validityType;
|
|
108
|
-
}
|
|
109
|
-
handleLicenseValidation(details, validityType) {
|
|
110
|
-
var _a;
|
|
111
|
-
const nowAtMidnight = new Date();
|
|
112
|
-
nowAtMidnight.setHours(0, 0, 0, 0);
|
|
113
|
-
let daysLeft = 0;
|
|
114
|
-
if (!(details instanceof Error) && (details === null || details === void 0 ? void 0 : details.end)) {
|
|
115
|
-
daysLeft = Math.floor((((_a = details === null || details === void 0 ? void 0 : details.end) === null || _a === void 0 ? void 0 : _a.getTime()) - nowAtMidnight.getTime()) / DAY_IN_MS);
|
|
116
|
-
daysLeft = clamp(daysLeft, 0, Infinity);
|
|
117
|
-
}
|
|
118
|
-
let APP_NAME = '';
|
|
119
|
-
let forApp = '';
|
|
120
|
-
if (details &&
|
|
121
|
-
!(details instanceof Error) &&
|
|
122
|
-
details.appName &&
|
|
123
|
-
details.appName != GENERIC_APP_NAME) {
|
|
124
|
-
APP_NAME = details.appName;
|
|
125
|
-
forApp = ` for application [APP_NAME]`;
|
|
126
|
-
}
|
|
127
|
-
const annotateMessage = (message, link = LicenseDocsLink, email = EMAIL, days = daysLeft, appName = APP_NAME) => {
|
|
128
|
-
return message
|
|
129
|
-
.replace('[LINK]', link)
|
|
130
|
-
.replace('[EMAIL]', email)
|
|
131
|
-
.replace('[APP_NAME]', appName)
|
|
132
|
-
.replace('[DAYS]', `${days}`);
|
|
133
|
-
};
|
|
134
|
-
switch (validityType) {
|
|
135
|
-
case 'NO_LICENSE':
|
|
136
|
-
case 'NON_PRODUCTION_EXPIRED_OUT_OF_SCOPE':
|
|
137
|
-
this.adaptable.logger.consoleLogByMessageType(annotateMessage('This instance of AdapTable does not have a license, and some functionality has therefore been removed. In order to use a fully-featured version of AdapTable, please contact [EMAIL]. You can learn more about the different AdapTable license options at [LINK].'), 'Error');
|
|
138
|
-
this.showNotification('No AdapTable License found.');
|
|
139
|
-
this.showWatermark('This instance of AdapTable does not have a license, and some functionality has therefore been removed.');
|
|
140
|
-
this.disableStatePersistence();
|
|
141
|
-
break;
|
|
142
|
-
case 'INVALID_LICENSE':
|
|
143
|
-
this.adaptable.logger.consoleLogByMessageType(annotateMessage('This instance of AdapTable seems to use a corrupted License, and some functionality has therefore been removed. In order to use a fully-featured version of AdapTable, please contact [EMAIL]. You can learn more about the different AdapTable license options at [LINK].'), 'Error');
|
|
144
|
-
this.showNotification('Corrupted AdapTable License found.');
|
|
145
|
-
this.showWatermark(`This instance of AdapTable has a corrupted License, and some functionality has therefore been removed.`);
|
|
146
|
-
this.disableStatePersistence();
|
|
147
|
-
break;
|
|
148
|
-
case 'NON_PRODUCTION_VALID':
|
|
149
|
-
this.adaptable.logger.consoleLogByMessageType(annotateMessage('This AdapTable trial license expires in [DAYS] days. Please contact [EMAIL] to upgrade to a commercial version of AdapTable. You can learn more about the different AdapTable license options at [LINK].'), 'Info');
|
|
150
|
-
break;
|
|
151
|
-
case 'NON_PRODUCTION_EXPIRED_IN_SCOPE':
|
|
152
|
-
this.adaptable.logger.consoleLogByMessageType(annotateMessage('This AdapTable trial license has now expired. Please contact [EMAIL] to upgrade to a commercial version of AdapTable. You can learn more about the different AdapTable license options at [LINK].'), 'Warning');
|
|
153
|
-
this.showWatermark('AdapTable License has expired');
|
|
154
|
-
break;
|
|
155
|
-
case 'COMMERCIAL_VALID':
|
|
156
|
-
if (daysLeft <= COMMERCIAL_LICENSE_SHOW_INFO_DAYS_BEFORE_EXPIRE) {
|
|
157
|
-
this.adaptable.logger.consoleLogByMessageType(annotateMessage(`This AdapTable license${forApp} expires in [DAYS] days. Please contact [EMAIL] to renew (giving you access to Support and Updates)`), 'Info');
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
try {
|
|
161
|
-
if (shouldLogThankYouMessage()) {
|
|
162
|
-
this.adaptable.logger.consoleLogByMessageType(annotateMessage(`Thank you for using a valid AdapTable license${forApp}. Your license will expire in [DAYS] days.`), 'Info');
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
catch (ex) { }
|
|
166
|
-
}
|
|
167
|
-
break;
|
|
168
|
-
case 'COMMERCIAL_EXPIRED_IN_SCOPE':
|
|
169
|
-
this.adaptable.logger.consoleLogByMessageType(annotateMessage(`This AdapTable license${forApp} has expired. Please contact [EMAIL] if you wish to renew (giving you access to Support and Updates)`), 'Warning');
|
|
170
|
-
break;
|
|
171
|
-
case 'COMMERCIAL_EXPIRED_OUT_OF_SCOPE':
|
|
172
|
-
this.adaptable.logger.consoleLogByMessageType(annotateMessage(`This AdapTable license${forApp} has expired. Adaptable version was published after the license expired. Please contact [EMAIL] if you wish to renew your license.`), 'Error');
|
|
173
|
-
this.showNotification('Adaptable License has expired');
|
|
174
|
-
this.showWatermark('Adaptable License has expired');
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
showNotification(text) {
|
|
179
|
-
this.adaptable.api.internalApi.dispatchReduxAction(PopupShowAlert({
|
|
180
|
-
alertType: 'generic',
|
|
181
|
-
header: 'License Error',
|
|
182
|
-
message: text,
|
|
183
|
-
alertDefinition: ObjectFactory.CreateInternalAlertDefinitionForMessages('Error'),
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
|
-
showWatermark(text) {
|
|
187
|
-
this.adaptable.api.internalApi.dispatchReduxAction(SystemLicenseShowWatermark(text));
|
|
188
|
-
}
|
|
189
|
-
disableStatePersistence() {
|
|
190
|
-
this.adaptable.api.internalApi.dispatchReduxAction(SystemLicenseDisablePersistence());
|
|
191
|
-
}
|
|
192
|
-
destroy() { }
|
|
193
|
-
}
|
|
1
|
+
import{SystemLicenseDisablePersistence as e,SystemLicenseShowWatermark as a}from"../../../Redux/ActionsReducers/SystemRedux";import{PopupShowAlert as t}from"../../../Redux/ActionsReducers/PopupRedux";import i from"../../ObjectFactory";import s from"lodash/clamp";import{LicenseDocsLink as o}from"../../Constants/DocumentationLinkConstants";import{decode as n,GENERIC_APP_NAME as r}from"../../license/decode";import{shouldLogThankYouMessage as l}from"./shouldLogThankYouMessage";const c="sales@adaptabletools.com",d=10,p=864e5;export var LicenseValidityType;!function(e){e.INVALID_LICENSE="INVALID_LICENSE",e.NO_LICENSE="NO_LICENSE",e.NON_PRODUCTION_VALID="NON_PRODUCTION_VALID",e.NON_PRODUCTION_EXPIRED_IN_SCOPE="NON_PRODUCTION_EXPIRED_IN_SCOPE",e.NON_PRODUCTION_EXPIRED_OUT_OF_SCOPE="NON_PRODUCTION_EXPIRED_OUT_OF_SCOPE",e.COMMERCIAL_VALID="COMMERCIAL_VALID",e.COMMERCIAL_EXPIRED_IN_SCOPE="COMMERCIAL_EXPIRED_IN_SCOPE",e.COMMERCIAL_EXPIRED_OUT_OF_SCOPE="COMMERCIAL_EXPIRED_OUT_OF_SCOPE"}(LicenseValidityType||(LicenseValidityType={}));const h=/(https):\/\/\d+\-\d+\-\d+\-(sandpack\.codesandbox\.io)/g,E=/(https):\/\/\S+(\.csb\.app)/g,I=/(https):\/\/\S+(\.adaptabletools\.com)/g,_=()=>"undefined"!=typeof window?window.location.origin:"",O=()=>{const[e,a,t]=Array.from(h.exec(_())||[]);return"https"===a&&"sandpack.codesandbox.io"===t},A=()=>{const[e,a,t]=Array.from(E.exec(_())||[]);return"https"===a&&".csb.app"===t},L=()=>{const[e,a,t]=Array.from(I.exec(_())||[]);return"https"===a&&".adaptabletools.com"===t};export class LicenseService{constructor(e,a,t){this.adaptable=e,this.licenseKey=a,this.packageDetails=t,this.adaptable=e,this.adaptable.api.eventApi.on("AdaptableReady",(()=>{requestAnimationFrame((()=>{this.init()}))}))}init(){let e=null;if(this.licenseKey)try{e=n(this.licenseKey)}catch(a){e=a}O()||A()||L()||this.handleLicenseValidation(e,this.getValidityType(e,this.packageDetails))}getValidityType(e,a){if(!e)return LicenseValidityType.NO_LICENSE;if(e instanceof Error)return LicenseValidityType.INVALID_LICENSE;const t=new Date(a.publishedAt),i=new Date(e.end),s=i<new Date,o=e.trial;let n=null;return n=s?i>t?o?LicenseValidityType.NON_PRODUCTION_EXPIRED_IN_SCOPE:LicenseValidityType.COMMERCIAL_EXPIRED_IN_SCOPE:o?LicenseValidityType.NON_PRODUCTION_EXPIRED_OUT_OF_SCOPE:LicenseValidityType.COMMERCIAL_EXPIRED_OUT_OF_SCOPE:o?LicenseValidityType.NON_PRODUCTION_VALID:LicenseValidityType.COMMERCIAL_VALID,n}handleLicenseValidation(e,a){var t;const i=new Date;i.setHours(0,0,0,0);let n=0;e instanceof Error||!(null==e?void 0:e.end)||(n=Math.floor(((null===(t=null==e?void 0:e.end)||void 0===t?void 0:t.getTime())-i.getTime())/p),n=s(n,0,1/0));let h="",E="";!e||e instanceof Error||!e.appName||e.appName==r||(h=e.appName,E=" for application [APP_NAME]");const I=(e,a=o,t=c,i=n,s=h)=>e.replace("[LINK]",a).replace("[EMAIL]",t).replace("[APP_NAME]",s).replace("[DAYS]",`${i}`);switch(a){case"NO_LICENSE":case"NON_PRODUCTION_EXPIRED_OUT_OF_SCOPE":this.adaptable.logger.consoleLogByMessageType(I("This instance of AdapTable does not have a license, and some functionality has therefore been removed. In order to use a fully-featured version of AdapTable, please contact [EMAIL]. You can learn more about the different AdapTable license options at [LINK]."),"Error"),this.showNotification("No AdapTable License found."),this.showWatermark("This instance of AdapTable does not have a license, and some functionality has therefore been removed."),this.disableStatePersistence();break;case"INVALID_LICENSE":this.adaptable.logger.consoleLogByMessageType(I("This instance of AdapTable seems to use a corrupted License, and some functionality has therefore been removed. In order to use a fully-featured version of AdapTable, please contact [EMAIL]. You can learn more about the different AdapTable license options at [LINK]."),"Error"),this.showNotification("Corrupted AdapTable License found."),this.showWatermark("This instance of AdapTable has a corrupted License, and some functionality has therefore been removed."),this.disableStatePersistence();break;case"NON_PRODUCTION_VALID":this.adaptable.logger.consoleLogByMessageType(I("This AdapTable trial license expires in [DAYS] days. Please contact [EMAIL] to upgrade to a commercial version of AdapTable. You can learn more about the different AdapTable license options at [LINK]."),"Info");break;case"NON_PRODUCTION_EXPIRED_IN_SCOPE":this.adaptable.logger.consoleLogByMessageType(I("This AdapTable trial license has now expired. Please contact [EMAIL] to upgrade to a commercial version of AdapTable. You can learn more about the different AdapTable license options at [LINK]."),"Warning"),this.showWatermark("AdapTable License has expired");break;case"COMMERCIAL_VALID":if(n<=d)this.adaptable.logger.consoleLogByMessageType(I(`This AdapTable license${E} expires in [DAYS] days. Please contact [EMAIL] to renew (giving you access to Support and Updates)`),"Info");else try{l()&&this.adaptable.logger.consoleLogByMessageType(I(`Thank you for using a valid AdapTable license${E}. Your license will expire in [DAYS] days.`),"Info")}catch(e){}break;case"COMMERCIAL_EXPIRED_IN_SCOPE":this.adaptable.logger.consoleLogByMessageType(I(`This AdapTable license${E} has expired. Please contact [EMAIL] if you wish to renew (giving you access to Support and Updates)`),"Warning");break;case"COMMERCIAL_EXPIRED_OUT_OF_SCOPE":this.adaptable.logger.consoleLogByMessageType(I(`This AdapTable license${E} has expired. Adaptable version was published after the license expired. Please contact [EMAIL] if you wish to renew your license.`),"Error"),this.showNotification("Adaptable License has expired"),this.showWatermark("Adaptable License has expired")}}showNotification(e){this.adaptable.api.internalApi.dispatchReduxAction(t({alertType:"generic",header:"License Error",message:e,alertDefinition:i.CreateInternalAlertDefinitionForMessages("Error")}))}showWatermark(e){this.adaptable.api.internalApi.dispatchReduxAction(a(e))}disableStatePersistence(){this.adaptable.api.internalApi.dispatchReduxAction(e())}destroy(){}}
|
|
@@ -10,11 +10,8 @@ export declare class ReportService implements IReportService {
|
|
|
10
10
|
private cellClassKey2excelStyleIdMap;
|
|
11
11
|
private excelStylesWithFormattedDate;
|
|
12
12
|
constructor(adaptableApi: AdaptableApi);
|
|
13
|
-
|
|
14
|
-
registerExcelStyle(excelStyle: Partial<ExcelStyle>, cellClassKey: string): void;
|
|
15
|
-
getRegisteredExcelStyles(): ExcelStyle[];
|
|
13
|
+
destroy(): void;
|
|
16
14
|
getExcelStyleIdForCellClassKey(cellClassKey: string): string;
|
|
17
|
-
registerExcelStyleWithFormattedDate(cellClassId: string, isoFormattedValue: string): void;
|
|
18
15
|
getExcelStyleWithFormattedDate(cellClassId: string): string;
|
|
19
16
|
CreateSystemReport(systemReportName: SystemReportName): Report;
|
|
20
17
|
IsSystemReport(reportName: string): boolean;
|
|
@@ -33,7 +30,12 @@ export declare class ReportService implements IReportService {
|
|
|
33
30
|
getCellExportValueFromRowNode(rowNode: IRowNode, columnId: string): any;
|
|
34
31
|
getCellExportValueFromRawValue(rowNode: IRowNode, cellRawValue: any, columnId: string): any;
|
|
35
32
|
getReportFileName(reportName: string, destination: SystemExportDestination | CustomDestination): string;
|
|
36
|
-
destroy(): void;
|
|
37
33
|
private getCustomExportDateFormat;
|
|
38
34
|
private getCellExportValueFromRawValueByType;
|
|
35
|
+
buildExcelStylesForVisualReports(): ExcelStyle[];
|
|
36
|
+
createExcelStyleMemoization(): void;
|
|
37
|
+
private convertCSSToExcelStyle;
|
|
38
|
+
private resetExcelStyleMemoization;
|
|
39
|
+
private registerExcelStyle;
|
|
40
|
+
private registerExcelStyleWithFormattedDate;
|
|
39
41
|
}
|
|
@@ -7,6 +7,8 @@ import StringExtensions from '../Extensions/StringExtensions';
|
|
|
7
7
|
import { ExportModuleId } from '../Constants/ModuleConstants';
|
|
8
8
|
import { createUuid } from '../../components/utils/uuid';
|
|
9
9
|
import { createBaseContext } from '../ObjectFactory';
|
|
10
|
+
import { convertCSSAbsoluteFontSizeToPt, getVariableColor, sanitizeStyle, } from '../Helpers/StyleHelper';
|
|
11
|
+
import tinycolor from 'tinycolor2';
|
|
10
12
|
export class ReportService {
|
|
11
13
|
constructor(adaptableApi) {
|
|
12
14
|
this.adaptableApi = adaptableApi;
|
|
@@ -15,29 +17,12 @@ export class ReportService {
|
|
|
15
17
|
this.excelStylesWithFormattedDate = {};
|
|
16
18
|
this.adaptableApi = adaptableApi;
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.cellClassKey2excelStyleIdMap = {};
|
|
21
|
-
this.excelStylesWithFormattedDate = {};
|
|
22
|
-
}
|
|
23
|
-
registerExcelStyle(excelStyle, cellClassKey) {
|
|
24
|
-
const excelStyleKey = JSON.stringify(excelStyle);
|
|
25
|
-
if (!this.excelStylesCache[excelStyleKey]) {
|
|
26
|
-
const excelStyleId = createUuid();
|
|
27
|
-
const excelStyleWithId = Object.assign(Object.assign({}, excelStyle), { id: excelStyleId });
|
|
28
|
-
this.excelStylesCache[excelStyleKey] = excelStyleWithId;
|
|
29
|
-
}
|
|
30
|
-
this.cellClassKey2excelStyleIdMap[cellClassKey] = this.excelStylesCache[excelStyleKey].id;
|
|
31
|
-
}
|
|
32
|
-
getRegisteredExcelStyles() {
|
|
33
|
-
return Object.values(this.excelStylesCache);
|
|
20
|
+
destroy() {
|
|
21
|
+
// TO DO
|
|
34
22
|
}
|
|
35
23
|
getExcelStyleIdForCellClassKey(cellClassKey) {
|
|
36
24
|
return this.cellClassKey2excelStyleIdMap[cellClassKey];
|
|
37
25
|
}
|
|
38
|
-
registerExcelStyleWithFormattedDate(cellClassId, isoFormattedValue) {
|
|
39
|
-
this.excelStylesWithFormattedDate[cellClassId] = isoFormattedValue;
|
|
40
|
-
}
|
|
41
26
|
getExcelStyleWithFormattedDate(cellClassId) {
|
|
42
27
|
return this.excelStylesWithFormattedDate[cellClassId];
|
|
43
28
|
}
|
|
@@ -365,9 +350,6 @@ export class ReportService {
|
|
|
365
350
|
}
|
|
366
351
|
return fileName;
|
|
367
352
|
}
|
|
368
|
-
destroy() {
|
|
369
|
-
// TO DO
|
|
370
|
-
}
|
|
371
353
|
getCustomExportDateFormat() {
|
|
372
354
|
return this.adaptableApi.optionsApi.getExportOptions().exportDateFormat;
|
|
373
355
|
}
|
|
@@ -379,4 +361,238 @@ export class ReportService {
|
|
|
379
361
|
: // type === formattedValue
|
|
380
362
|
this.adaptableApi.gridApi.getDisplayValueFromRawValue(rowNode, columnId, cellRawValue);
|
|
381
363
|
}
|
|
364
|
+
// aggregate and merge all acive Adaptable styles with the user proviided ExcelStyles
|
|
365
|
+
buildExcelStylesForVisualReports() {
|
|
366
|
+
// for historical reasons, the styles are merged as class variables
|
|
367
|
+
// we could/should refactor this to be more functional
|
|
368
|
+
this.createExcelStyleMemoization();
|
|
369
|
+
return Object.values(this.excelStylesCache);
|
|
370
|
+
}
|
|
371
|
+
createExcelStyleMemoization() {
|
|
372
|
+
this.resetExcelStyleMemoization();
|
|
373
|
+
// we memoize as much as possible, as this is called quite A LOT
|
|
374
|
+
const adaptableColumnMap = {};
|
|
375
|
+
const getAdaptableColumnWithColumnId = (columnId) => {
|
|
376
|
+
const memoizedColumn = adaptableColumnMap[columnId];
|
|
377
|
+
if (memoizedColumn) {
|
|
378
|
+
return memoizedColumn;
|
|
379
|
+
}
|
|
380
|
+
const abColumn = this.adaptableApi.columnApi.getColumnWithColumnId(columnId);
|
|
381
|
+
adaptableColumnMap[columnId] = abColumn;
|
|
382
|
+
return abColumn;
|
|
383
|
+
};
|
|
384
|
+
const formatColumnsWithDisplayFormatForColumn = {};
|
|
385
|
+
const getFormatColumnsWithDisplayFormatForColumn = (columnId) => {
|
|
386
|
+
const memoizedFormatColumns = formatColumnsWithDisplayFormatForColumn[columnId];
|
|
387
|
+
if (memoizedFormatColumns) {
|
|
388
|
+
return memoizedFormatColumns;
|
|
389
|
+
}
|
|
390
|
+
const abColumn = getAdaptableColumnWithColumnId(columnId);
|
|
391
|
+
const formatColumns = this.adaptableApi.formatColumnApi.internalApi.getFormatColumnsWithDisplayFormatForColumn(abColumn);
|
|
392
|
+
formatColumnsWithDisplayFormatForColumn[columnId] = formatColumns;
|
|
393
|
+
return formatColumns;
|
|
394
|
+
};
|
|
395
|
+
const isDateCellExportedAsFormattedValue = this.adaptableApi.exportApi.internalApi.isDateCellExportedAsFormattedValue();
|
|
396
|
+
const displayedColumns = this.adaptableApi.agGridApi.getAllDisplayedColumns();
|
|
397
|
+
const colDefs = displayedColumns.map((column) => {
|
|
398
|
+
return column.getColDef();
|
|
399
|
+
});
|
|
400
|
+
const forAllVisibleRowNodesDoConfig = { includeGroupRows: true };
|
|
401
|
+
const agGridApi = this.adaptableApi.agGridApi;
|
|
402
|
+
const userExcelStyles = this.adaptableApi.internalApi
|
|
403
|
+
.getAdaptableInstance()
|
|
404
|
+
.agGridAdapter.getUserGridOptionsProperty('excelStyles') || [];
|
|
405
|
+
this.adaptableApi.internalApi.forAllVisibleRowNodesDo((node, rowIndex) => {
|
|
406
|
+
var _a;
|
|
407
|
+
const rowParams = {
|
|
408
|
+
node,
|
|
409
|
+
data: node.data,
|
|
410
|
+
rowIndex,
|
|
411
|
+
api: agGridApi,
|
|
412
|
+
columnApi: null,
|
|
413
|
+
context: ((_a = agGridApi.__getContext) === null || _a === void 0 ? void 0 : _a.call(agGridApi)) || {},
|
|
414
|
+
};
|
|
415
|
+
const getRowStyleFn = agGridApi.getGridOption('getRowStyle');
|
|
416
|
+
const rowStyle = getRowStyleFn ? getRowStyleFn(rowParams) : {};
|
|
417
|
+
displayedColumns.forEach((column, columnIndex) => {
|
|
418
|
+
var _a, _b, _c;
|
|
419
|
+
const colDef = colDefs[columnIndex];
|
|
420
|
+
let cellClassParams;
|
|
421
|
+
const getLazyCellClassParams = () => {
|
|
422
|
+
if (!cellClassParams) {
|
|
423
|
+
cellClassParams = {
|
|
424
|
+
colDef,
|
|
425
|
+
node,
|
|
426
|
+
column,
|
|
427
|
+
data: node.data,
|
|
428
|
+
value: this.adaptableApi.gridApi.getRawValueFromRowNode(node, column.getId()),
|
|
429
|
+
rowIndex,
|
|
430
|
+
api: agGridApi,
|
|
431
|
+
columnApi: null,
|
|
432
|
+
context: {},
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
return cellClassParams;
|
|
436
|
+
};
|
|
437
|
+
const cellStyle = typeof colDef.cellStyle === 'function' ? colDef.cellStyle(getLazyCellClassParams()) : {};
|
|
438
|
+
const excelStyles = [];
|
|
439
|
+
// add user defined excel styles
|
|
440
|
+
let userColDefCellClass = this.adaptableApi.internalApi
|
|
441
|
+
.getAdaptableInstance()
|
|
442
|
+
.agGridColumnAdapter.getUserColDefProperty(column.getColId(), 'cellClass');
|
|
443
|
+
const userDefinedCellClass = typeof userColDefCellClass === 'function'
|
|
444
|
+
? userColDefCellClass(getLazyCellClassParams())
|
|
445
|
+
: userColDefCellClass;
|
|
446
|
+
const userDefinedExcelStyle = userDefinedCellClass &&
|
|
447
|
+
userExcelStyles.find((excelStyle) => {
|
|
448
|
+
var _a;
|
|
449
|
+
return typeof userDefinedCellClass === 'string'
|
|
450
|
+
? userDefinedCellClass === excelStyle.id
|
|
451
|
+
: (_a = userDefinedCellClass === null || userDefinedCellClass === void 0 ? void 0 : userDefinedCellClass.includes) === null || _a === void 0 ? void 0 : _a.call(userDefinedCellClass, excelStyle.id);
|
|
452
|
+
});
|
|
453
|
+
if (userDefinedExcelStyle) {
|
|
454
|
+
excelStyles.push(userDefinedExcelStyle);
|
|
455
|
+
}
|
|
456
|
+
// add adaptable derived styles (format column etc.)
|
|
457
|
+
const adaptableStyle = Object.assign(Object.assign({}, rowStyle), Object.keys(cellStyle).reduce((result, key) => {
|
|
458
|
+
if (cellStyle[key] !== null) {
|
|
459
|
+
result[key] = cellStyle[key];
|
|
460
|
+
}
|
|
461
|
+
return result;
|
|
462
|
+
}, {}));
|
|
463
|
+
const sanitizedAdaptableStyle = sanitizeStyle(adaptableStyle);
|
|
464
|
+
if (Object.values(sanitizedAdaptableStyle).some((style) => style != null)) {
|
|
465
|
+
excelStyles.push(this.convertCSSToExcelStyle(sanitizedAdaptableStyle));
|
|
466
|
+
}
|
|
467
|
+
const excelDataType = this.adaptableApi.exportApi.internalApi.getExcelDataType(colDef === null || colDef === void 0 ? void 0 : colDef.type);
|
|
468
|
+
const rawValue = this.adaptableApi.gridApi.getRawValueFromRowNode(node, column.getId());
|
|
469
|
+
// don't add the cell style if it has no adaptable custom styles
|
|
470
|
+
if (!excelStyles.length &&
|
|
471
|
+
// if this is a formatted Date value, we still need to add the AG GRID specific type & numberFormat below
|
|
472
|
+
!(excelDataType === 'DateTime' && isDateCellExportedAsFormattedValue)) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
const cellClassId = this.adaptableApi.internalApi
|
|
476
|
+
.getAdaptableInstance()
|
|
477
|
+
.agGridColumnAdapter.getExcelClassNameForCell(column.getId(), this.adaptableApi.internalApi
|
|
478
|
+
.getAdaptableInstance()
|
|
479
|
+
.getPrimaryKeyValueFromRowNode(node), userDefinedCellClass);
|
|
480
|
+
const finalCellExcelStyle = Object.assign({}, ...excelStyles);
|
|
481
|
+
if (excelDataType === 'DateTime' && isDateCellExportedAsFormattedValue) {
|
|
482
|
+
let dateFormatPattern = this.adaptableApi.optionsApi.getExportOptions().exportDateFormat;
|
|
483
|
+
const abColumn = getAdaptableColumnWithColumnId(column.getColId());
|
|
484
|
+
if (!dateFormatPattern) {
|
|
485
|
+
const mostRelevantFormatColumn = this.adaptableApi.formatColumnApi.internalApi.getMostRelevantFormatColumnForColumn(getFormatColumnsWithDisplayFormatForColumn(column.getColId()), abColumn, { node, value: rawValue });
|
|
486
|
+
dateFormatPattern =
|
|
487
|
+
((_a = mostRelevantFormatColumn === null || mostRelevantFormatColumn === void 0 ? void 0 : mostRelevantFormatColumn.DisplayFormat) === null || _a === void 0 ? void 0 : _a.Formatter) === 'DateFormatter' &&
|
|
488
|
+
((_c = (_b = mostRelevantFormatColumn === null || mostRelevantFormatColumn === void 0 ? void 0 : mostRelevantFormatColumn.DisplayFormat) === null || _b === void 0 ? void 0 : _b.Options) === null || _c === void 0 ? void 0 : _c.Pattern);
|
|
489
|
+
}
|
|
490
|
+
if (dateFormatPattern) {
|
|
491
|
+
const normalisedValue = this.adaptableApi.internalApi
|
|
492
|
+
.getAdaptableInstance()
|
|
493
|
+
.getNormalisedValueFromRawValue(rawValue, abColumn);
|
|
494
|
+
if (normalisedValue) {
|
|
495
|
+
// we have to pass the date in the ISO format to Excel
|
|
496
|
+
// see https://www.ag-grid.com/javascript-data-grid/excel-export-data-types/#dates
|
|
497
|
+
// we can NOT use Date.toISOString() because we don't want the timezone corrections to kick in
|
|
498
|
+
const isoFormattedValue = DateFormatter(normalisedValue, {
|
|
499
|
+
Pattern: `yyyy-MM-dd'T'HH:mm:ss.SSS`,
|
|
500
|
+
});
|
|
501
|
+
if (isoFormattedValue) {
|
|
502
|
+
finalCellExcelStyle.dataType = 'DateTime';
|
|
503
|
+
finalCellExcelStyle.numberFormat = { format: dateFormatPattern };
|
|
504
|
+
// create a new cell key to ensure any user provided className does not interfere
|
|
505
|
+
const cellKey = this.adaptableApi.internalApi
|
|
506
|
+
.getAdaptableInstance()
|
|
507
|
+
.agGridColumnAdapter.getExcelClassNameForCell(column.getColId(), this.adaptableApi.internalApi
|
|
508
|
+
.getAdaptableInstance()
|
|
509
|
+
.getPrimaryKeyValueFromRowNode(node));
|
|
510
|
+
// we need to register so that later the cellProcessor will put the isoFormattedValue through (thus giving the formatting responsability to Excel)
|
|
511
|
+
this.registerExcelStyleWithFormattedDate(cellKey, isoFormattedValue);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
this.registerExcelStyle(finalCellExcelStyle, cellClassId);
|
|
517
|
+
});
|
|
518
|
+
}, forAllVisibleRowNodesDoConfig);
|
|
519
|
+
}
|
|
520
|
+
convertCSSToExcelStyle(style) {
|
|
521
|
+
const getHexColor = (color) => {
|
|
522
|
+
const preparedColor = getVariableColor(color);
|
|
523
|
+
const t = tinycolor(preparedColor);
|
|
524
|
+
const a = t.getAlpha();
|
|
525
|
+
return tinycolor.mix(tinycolor('white'), t, a * 100).toHexString();
|
|
526
|
+
};
|
|
527
|
+
let result = {};
|
|
528
|
+
if (style.backgroundColor != null) {
|
|
529
|
+
result.interior = {
|
|
530
|
+
color: getHexColor(style.backgroundColor),
|
|
531
|
+
pattern: 'Solid',
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
if (style.borderColor != null) {
|
|
535
|
+
const excelBorder = {
|
|
536
|
+
color: style.borderColor,
|
|
537
|
+
lineStyle: 'Continuous',
|
|
538
|
+
weight: 1,
|
|
539
|
+
};
|
|
540
|
+
result.borders = {
|
|
541
|
+
borderBottom: excelBorder,
|
|
542
|
+
borderLeft: excelBorder,
|
|
543
|
+
borderRight: excelBorder,
|
|
544
|
+
borderTop: excelBorder,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
if (style.textAlign) {
|
|
548
|
+
result.alignment = {
|
|
549
|
+
horizontal: StringExtensions.CapitaliseFirstLetter(style.textAlign),
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
if (style.color != null) {
|
|
553
|
+
if (!result.font) {
|
|
554
|
+
result.font = {};
|
|
555
|
+
}
|
|
556
|
+
result.font = {
|
|
557
|
+
color: getHexColor(style.color),
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
if (style.fontStyle === 'italic') {
|
|
561
|
+
if (!result.font) {
|
|
562
|
+
result.font = {};
|
|
563
|
+
}
|
|
564
|
+
result.font.italic = true;
|
|
565
|
+
}
|
|
566
|
+
if (style.fontWeight != null &&
|
|
567
|
+
(style.fontWeight === 'bold' || Number(style.fontWeight) >= 600)) {
|
|
568
|
+
if (!result.font) {
|
|
569
|
+
result.font = {};
|
|
570
|
+
}
|
|
571
|
+
result.font.bold = true;
|
|
572
|
+
}
|
|
573
|
+
if (style.fontSize != null) {
|
|
574
|
+
if (!result.font) {
|
|
575
|
+
result.font = {};
|
|
576
|
+
}
|
|
577
|
+
result.font.size = convertCSSAbsoluteFontSizeToPt(style.fontSize);
|
|
578
|
+
}
|
|
579
|
+
return result;
|
|
580
|
+
}
|
|
581
|
+
resetExcelStyleMemoization() {
|
|
582
|
+
this.excelStylesCache = {};
|
|
583
|
+
this.cellClassKey2excelStyleIdMap = {};
|
|
584
|
+
this.excelStylesWithFormattedDate = {};
|
|
585
|
+
}
|
|
586
|
+
registerExcelStyle(excelStyle, cellClassKey) {
|
|
587
|
+
const excelStyleKey = JSON.stringify(excelStyle);
|
|
588
|
+
if (!this.excelStylesCache[excelStyleKey]) {
|
|
589
|
+
const excelStyleId = createUuid();
|
|
590
|
+
const excelStyleWithId = Object.assign(Object.assign({}, excelStyle), { id: excelStyleId });
|
|
591
|
+
this.excelStylesCache[excelStyleKey] = excelStyleWithId;
|
|
592
|
+
}
|
|
593
|
+
this.cellClassKey2excelStyleIdMap[cellClassKey] = this.excelStylesCache[excelStyleKey].id;
|
|
594
|
+
}
|
|
595
|
+
registerExcelStyleWithFormattedDate(cellClassId, isoFormattedValue) {
|
|
596
|
+
this.excelStylesWithFormattedDate[cellClassId] = isoFormattedValue;
|
|
597
|
+
}
|
|
382
598
|
}
|
|
@@ -1,65 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
const getGenericError = () => new Error('Invalid License');
|
|
3
|
-
export const GENERIC_APP_NAME = 'GenericAdaptableApp';
|
|
4
|
-
export const fieldsToLicenseDetails = (fields) => {
|
|
5
|
-
var _a;
|
|
6
|
-
const fieldsMap = fields.reduce((acc, field) => {
|
|
7
|
-
acc.set(field.name, field.value);
|
|
8
|
-
return acc;
|
|
9
|
-
}, new Map());
|
|
10
|
-
const details = {
|
|
11
|
-
start: new Date(fieldsMap.get('StartDate')),
|
|
12
|
-
end: new Date(fieldsMap.get('EndDate')),
|
|
13
|
-
owner: fieldsMap.get('Owner'),
|
|
14
|
-
appName: fieldsMap.get('AppName') || GENERIC_APP_NAME,
|
|
15
|
-
timestamp: fieldsMap.get('TS') ? Number(fieldsMap.get('TS')) : 0,
|
|
16
|
-
trial: fieldsMap.get('Trial') === 'true' ? true : false,
|
|
17
|
-
ref: (_a = fieldsMap.get('Ref')) !== null && _a !== void 0 ? _a : '',
|
|
18
|
-
};
|
|
19
|
-
if (!details.start ||
|
|
20
|
-
!details.end ||
|
|
21
|
-
!details.owner ||
|
|
22
|
-
typeof details.trial !== 'boolean' ||
|
|
23
|
-
!details.ref) {
|
|
24
|
-
throw getGenericError();
|
|
25
|
-
}
|
|
26
|
-
return details;
|
|
27
|
-
};
|
|
28
|
-
export const decode = (licenseKey) => {
|
|
29
|
-
let crc = '';
|
|
30
|
-
let fields = licenseKey.split('|').map((part) => {
|
|
31
|
-
let [name, value] = part.split('=');
|
|
32
|
-
if (name === 'C') {
|
|
33
|
-
crc = value;
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
name,
|
|
37
|
-
value,
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
if (!crc) {
|
|
41
|
-
throw getGenericError();
|
|
42
|
-
}
|
|
43
|
-
const crcParts = crc.split(',').reverse();
|
|
44
|
-
const overallCrc = crcParts.pop();
|
|
45
|
-
crcParts.forEach((fieldCrc, index) => {
|
|
46
|
-
const field = fields[index];
|
|
47
|
-
if (compute_string(field.value) !== fieldCrc) {
|
|
48
|
-
throw getGenericError();
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
const fieldsWithoutC = [...fields];
|
|
52
|
-
fieldsWithoutC.pop();
|
|
53
|
-
const fieldsWithoutCString = fieldsWithoutC
|
|
54
|
-
.map((field) => {
|
|
55
|
-
return `${field.name}=${field.value}`;
|
|
56
|
-
})
|
|
57
|
-
.join('|');
|
|
58
|
-
if (compute_string(fieldsWithoutCString) !== overallCrc) {
|
|
59
|
-
throw getGenericError();
|
|
60
|
-
}
|
|
61
|
-
fields = fields.map((f) => {
|
|
62
|
-
return Object.assign(Object.assign({}, f), { value: decodeURI(f.value) });
|
|
63
|
-
});
|
|
64
|
-
return fieldsToLicenseDetails(fields);
|
|
65
|
-
};
|
|
1
|
+
import{compute_string as e}from"./hashing";const t=()=>new Error("Invalid License");export const GENERIC_APP_NAME="GenericAdaptableApp";export const fieldsToLicenseDetails=e=>{var a;const r=e.reduce(((e,t)=>(e.set(t.name,t.value),e)),new Map),n={start:new Date(r.get("StartDate")),end:new Date(r.get("EndDate")),owner:r.get("Owner"),appName:r.get("AppName")||GENERIC_APP_NAME,timestamp:r.get("TS")?Number(r.get("TS")):0,trial:"true"===r.get("Trial"),ref:null!==(a=r.get("Ref"))&&void 0!==a?a:""};if(!(n.start&&n.end&&n.owner&&"boolean"==typeof n.trial&&n.ref))throw t();return n};export const decode=a=>{let r="",n=a.split("|").map((e=>{let[t,a]=e.split("=");return"C"===t&&(r=a),{name:t,value:a}}));if(!r)throw t();const o=r.split(",").reverse(),s=o.pop();o.forEach(((a,r)=>{const o=n[r];if(e(o.value)!==a)throw t()}));const i=[...n];i.pop();const p=i.map((e=>`${e.name}=${e.value}`)).join("|");if(e(p)!==s)throw t();return n=n.map((e=>Object.assign(Object.assign({},e),{value:decodeURI(e.value)}))),fieldsToLicenseDetails(n)};
|
|
@@ -1,43 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
/*
|
|
3
|
-
* CRC-32 implementation
|
|
4
|
-
*/
|
|
5
|
-
function generate(reversedPolynomial = DEFAULT_ReversedPolynomial) {
|
|
6
|
-
var table = new Array();
|
|
7
|
-
var i, j, n;
|
|
8
|
-
for (i = 0; i < 256; i++) {
|
|
9
|
-
n = i;
|
|
10
|
-
for (j = 8; j > 0; j--) {
|
|
11
|
-
if ((n & 1) == 1) {
|
|
12
|
-
n = (n >>> 1) ^ reversedPolynomial;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
n = n >>> 1;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
table[i] = n;
|
|
19
|
-
}
|
|
20
|
-
return table;
|
|
21
|
-
}
|
|
22
|
-
function crc32_initial() {
|
|
23
|
-
return 0xffffffff;
|
|
24
|
-
}
|
|
25
|
-
function crc32_add_byte(table, crc, byte) {
|
|
26
|
-
crc = (crc >>> 8) ^ table[byte ^ (crc & 0x000000ff)];
|
|
27
|
-
return crc;
|
|
28
|
-
}
|
|
29
|
-
function crc32_final(crc) {
|
|
30
|
-
crc = ~crc;
|
|
31
|
-
crc = crc < 0 ? 0xffffffff + crc + 1 : crc;
|
|
32
|
-
return crc;
|
|
33
|
-
}
|
|
34
|
-
export function compute_string(str, reversedPolynomial = DEFAULT_ReversedPolynomial) {
|
|
35
|
-
var table = generate(reversedPolynomial);
|
|
36
|
-
var crc = 0;
|
|
37
|
-
var i;
|
|
38
|
-
crc = crc32_initial();
|
|
39
|
-
for (i = 0; i < str.length; i++)
|
|
40
|
-
crc = crc32_add_byte(table, crc, str.charCodeAt(i));
|
|
41
|
-
crc = crc32_final(crc);
|
|
42
|
-
return `${crc}`;
|
|
43
|
-
}
|
|
1
|
+
const r=3988292384;function n(n=r){var t,o,u,e=new Array;for(t=0;t<256;t++){for(u=t,o=8;o>0;o--)1&~u?u>>>=1:u=u>>>1^n;e[t]=u}return e}function t(){return 4294967295}function o(r,n,t){return n=n>>>8^r[t^255&n]}function u(r){return r=(r=~r)<0?4294967295+r+1:r}export function compute_string(e,c=r){var f,i=n(c),a=0;for(a=t(),f=0;f<e.length;f++)a=o(i,a,e.charCodeAt(f));return`${a=u(a)}`}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { CalculatedColumn } from '../../../types';
|
|
3
3
|
import { AdaptableOnePageWizardProps } from '../../Wizard/Interface/IAdaptableWizard';
|
|
4
4
|
export declare const calculatedColumnTypes: readonly ["ScalarExpression", "AggregatedScalarExpression", "CumulativeAggregatedExpression", "QuantileAggregatedExpression"];
|
|
5
|
-
export type ExpressionType = typeof calculatedColumnTypes[number];
|
|
5
|
+
export type ExpressionType = (typeof calculatedColumnTypes)[number];
|
|
6
6
|
export interface CalculatedColumnWizardProps extends AdaptableOnePageWizardProps<CalculatedColumn> {
|
|
7
7
|
}
|
|
8
8
|
export declare const CalculatedColumnWizard: (props: CalculatedColumnWizardProps) => JSX.Element;
|
|
@@ -33,7 +33,7 @@ export const CalculatedColumnWizard = (props) => {
|
|
|
33
33
|
if ((_a = props.popupParams) === null || _a === void 0 ? void 0 : _a.column) {
|
|
34
34
|
const calculatedColumn = allCalculatedColumns.find((calculatedColumn) => calculatedColumn.ColumnId === props.popupParams.column.columnId);
|
|
35
35
|
if (calculatedColumn) {
|
|
36
|
-
return calculatedColumn;
|
|
36
|
+
return cloneObject(calculatedColumn);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
return ObjectFactory.CreateEmptyCalculatedColumn();
|
|
@@ -51,7 +51,7 @@ export const CalculatedColumnWizard = (props) => {
|
|
|
51
51
|
};
|
|
52
52
|
const [expressionType, setExpressionType] = useState(() => {
|
|
53
53
|
var _a;
|
|
54
|
-
return (_a = getExpressionType(
|
|
54
|
+
return (_a = getExpressionType(calculatedColumn, adaptable.api)) !== null && _a !== void 0 ? _a : 'ScalarExpression';
|
|
55
55
|
});
|
|
56
56
|
const handleExpressionTypeChange = (type) => {
|
|
57
57
|
setExpressionType(type);
|