@adaptabletools/adaptable-plugin-ipushpull 18.0.0-canary.3 → 18.0.0-canary.5

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