@adaptabletools/adaptable-plugin-ipushpull-cjs 18.0.0-canary.4 → 18.0.0-canary.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-plugin-ipushpull-cjs",
3
- "version": "18.0.0-canary.4",
3
+ "version": "18.0.0-canary.6",
4
4
  "description": "",
5
5
  "homepage": "http://www.adaptabletools.com/",
6
6
  "author": {
@@ -18,8 +18,9 @@
18
18
  "rebass": "^3.2.2",
19
19
  "redux": "4.0.5",
20
20
  "styled-components": "^4.4.1",
21
+ "tinycolor2": "^1.4.2",
21
22
  "tslib": "^2.3.0",
22
- "@adaptabletools/adaptable-cjs": "18.0.0-canary.4"
23
+ "@adaptabletools/adaptable-cjs": "18.0.0-canary.6"
23
24
  },
24
25
  "peerDependencies": {}
25
26
  }
@@ -1,4 +1,5 @@
1
1
  import { IAdaptable } from "@adaptabletools/adaptable-cjs/src/AdaptableInterfaces/IAdaptable";
2
+ import { IPPStyle } from "@adaptabletools/adaptable-cjs/src/Utilities/Interface/IPPStyle";
2
3
  import { IPushPullService } from './Interface/IPushPullService';
3
4
  import { IPushPullDomain } from "@adaptabletools/adaptable-cjs/src/PredefinedConfig/SystemState";
4
5
  export declare enum ServiceStatus {
@@ -20,4 +21,6 @@ export declare class PushPullService implements IPushPullService {
20
21
  unloadPage(page: string): void;
21
22
  addNewPage(folderId: number, page: string): Promise<any>;
22
23
  pushData(page: string, data: any[]): Promise<void>;
24
+ getCurrentIPPStyle(): IPPStyle;
25
+ getDefaultIPPStyle(): IPPStyle;
23
26
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PushPullService = exports.ServiceStatus = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const StringExtensions_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/StringExtensions"));
6
+ const tinycolor2_1 = tslib_1.__importDefault(require("tinycolor2"));
6
7
  var ServiceStatus;
7
8
  (function (ServiceStatus) {
8
9
  ServiceStatus["Unknown"] = "Unknown";
@@ -139,9 +140,7 @@ class PushPullService {
139
140
  pushData(page, data) {
140
141
  return new Promise((resolve, reject) => {
141
142
  let newData = [];
142
- const style = data && data.length > 1
143
- ? this.adaptable.getCurrentIPPStyle()
144
- : this.adaptable.getDefaultIPPStyle();
143
+ const style = data && data.length > 1 ? this.getCurrentIPPStyle() : this.getDefaultIPPStyle();
145
144
  newData = data.map((row, i) => row.map((cell, y) => {
146
145
  const col = i == 0
147
146
  ? style.Header.Columns.find((x) => x.columnFriendlyName == data[0][y])
@@ -210,5 +209,96 @@ class PushPullService {
210
209
  });
211
210
  });
212
211
  }
212
+ getCurrentIPPStyle() {
213
+ const headerFirstCol = document
214
+ .querySelectorAll('.ag-header-cell')
215
+ .item(0);
216
+ const header = document.querySelector('.ag-header');
217
+ const headerColStyle = header ? window.getComputedStyle(header, null) : null;
218
+ const firstRow = document.querySelector('.ag-row-even');
219
+ const firstRowStyle = firstRow ? window.getComputedStyle(firstRow, null) : null;
220
+ const secondRow = document.querySelector('.ag-row-odd');
221
+ const secondRowStyle = secondRow
222
+ ? window.getComputedStyle(secondRow, null)
223
+ : {
224
+ backgroundColor: '#fff',
225
+ };
226
+ return {
227
+ Header: {
228
+ headerColor: (0, tinycolor2_1.default)(headerColStyle.color).toHexString(),
229
+ headerBackColor: (0, tinycolor2_1.default)(headerColStyle.backgroundColor).toHexString(),
230
+ headerFontFamily: headerColStyle.fontFamily,
231
+ headerFontSize: headerColStyle.fontSize,
232
+ headerFontStyle: headerColStyle.fontStyle,
233
+ headerFontWeight: headerColStyle.fontWeight,
234
+ height: Number(headerColStyle.height.replace('px', '')),
235
+ Columns: this.adaptable.api.columnApi.getColumns().map((col) => {
236
+ const headerColumn = document.querySelector(`.ag-header-cell[col-id='${col.columnId}']`);
237
+ const headerColumnStyle = window.getComputedStyle(headerColumn || headerFirstCol, null);
238
+ return {
239
+ columnFriendlyName: col.friendlyName,
240
+ width: Number(headerColumnStyle.width.replace('px', '')),
241
+ textAlign: headerColumnStyle.textAlign,
242
+ };
243
+ }),
244
+ },
245
+ Row: {
246
+ color: (0, tinycolor2_1.default)(firstRowStyle.color).toHexString(),
247
+ backColor: (0, tinycolor2_1.default)(firstRowStyle.backgroundColor).toHexString(),
248
+ altBackColor: (0, tinycolor2_1.default)(secondRowStyle.backgroundColor).toHexString(),
249
+ fontFamily: firstRowStyle.fontFamily,
250
+ fontSize: firstRowStyle.fontSize,
251
+ fontStyle: firstRowStyle.fontStyle,
252
+ fontWeight: firstRowStyle.fontWeight,
253
+ height: Number(firstRowStyle.height.replace('px', '')),
254
+ Columns: this.adaptable.api.columnApi.getColumns().map((col) => {
255
+ const cellElement = document.querySelector(`.ag-cell[col-id='${col.columnId}']`);
256
+ const headerColumnStyle = window.getComputedStyle(cellElement || firstRow, null);
257
+ return {
258
+ columnFriendlyName: col.friendlyName,
259
+ width: Number(headerColumnStyle.width.replace('px', '')),
260
+ textAlign: headerColumnStyle.textAlign,
261
+ };
262
+ }),
263
+ },
264
+ };
265
+ }
266
+ getDefaultIPPStyle() {
267
+ return {
268
+ Header: {
269
+ headerColor: '#000000',
270
+ headerBackColor: '#f5f7f7',
271
+ headerFontFamily: 'sans-serif',
272
+ headerFontSize: '12px',
273
+ headerFontStyle: 'normal',
274
+ headerFontWeight: '400',
275
+ height: 65,
276
+ Columns: this.adaptable.api.columnApi.getColumns().map((col) => {
277
+ return {
278
+ columnFriendlyName: col.friendlyName,
279
+ width: 200,
280
+ textAlign: 'start',
281
+ };
282
+ }),
283
+ },
284
+ Row: {
285
+ color: '#000000',
286
+ backColor: '#ffffff',
287
+ altBackColor: '#fcfdfe',
288
+ fontFamily: 'sans-serif',
289
+ fontSize: '12px',
290
+ fontStyle: 'normal',
291
+ fontWeight: '400',
292
+ height: 30,
293
+ Columns: this.adaptable.api.columnApi.getColumns().map((col) => {
294
+ return {
295
+ columnFriendlyName: col.friendlyName,
296
+ width: 200,
297
+ textAlign: 'start',
298
+ };
299
+ }),
300
+ },
301
+ };
302
+ }
213
303
  }
214
304
  exports.PushPullService = PushPullService;