@adaptabletools/adaptable-plugin-nocode-aggrid 17.0.6 → 18.0.0-canary.1
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/README.md +63 -0
- package/package.json +5 -4
- package/src/index.d.ts +1 -0
- package/src/index.js +23 -27
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# AdapTable 'No Code' Plugin
|
|
2
|
+
|
|
3
|
+
The No Code Plugin allows end users to create an AdapTable instance at runtime from any JSON or Excel file that they provide.
|
|
4
|
+
|
|
5
|
+
It will dynamically instantiate a fully functional AdapTable including advanced features like state management and audit log, enabling Users to attach to the same source daily or multiple different sources.
|
|
6
|
+
|
|
7
|
+
## No Code Wizard
|
|
8
|
+
Once a JSON or Excel file has been selected (or dragged and droppped), the AdapTable No Code Wizard will appear.
|
|
9
|
+
|
|
10
|
+
It has 2 steps:
|
|
11
|
+
|
|
12
|
+
1. The Wizard will read the input file / JSON and list the available columns it contains, together with options for each column to change the DataType, and set editing, filtering, sorting, grouping and other properties.
|
|
13
|
+
|
|
14
|
+
2. A second (optional) step allows Users to set up many of the [Adaptable Options](https://docs.adaptabletools.com/guide/reference-options-overview) that would normally be configured at design-time, in order to ensure that the AdapTable instance suits their precise requirements.
|
|
15
|
+
|
|
16
|
+
> The source data must have one column that contains **unique values** which will be set as the Primary Key column (by convention this is the first column).
|
|
17
|
+
|
|
18
|
+
## Code Required
|
|
19
|
+
There is minimum code required to set up the No Code plugin.
|
|
20
|
+
|
|
21
|
+
A full example would be as follows:
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import "@adaptabletools/adaptable/index.css";
|
|
25
|
+
import "@ag-grid-community/all-modules/dist/styles/ag-grid.css";
|
|
26
|
+
import "@ag-grid-community/all-modules/dist/styles/ag-theme-balham.css";
|
|
27
|
+
import nocode from "@adaptabletools/adaptable-plugin-nocode-aggrid";
|
|
28
|
+
import { AdaptableOptions} from "@adaptabletools/adaptable/types";
|
|
29
|
+
import { AllEnterpriseModules } from "@ag-grid-enterprise/all-modules";
|
|
30
|
+
import Adaptable from "@adaptabletools/adaptable/agGrid";
|
|
31
|
+
|
|
32
|
+
const adaptableOptions: AdaptableOptions = {
|
|
33
|
+
primaryKey: "",
|
|
34
|
+
userName: "Demo User",
|
|
35
|
+
adaptableId: "Nocode Plugin Demo",
|
|
36
|
+
plugins: [
|
|
37
|
+
nocode({
|
|
38
|
+
onInit: adaptableOptions => {
|
|
39
|
+
adaptableOptions.modules = AllEnterpriseModules;
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
]
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
Adaptable.init(adaptableOptions).then((api) => {
|
|
46
|
+
console.log(api, "!!!");
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Example Project
|
|
51
|
+
Visit the [No Code Example Project](https://github.com/AdaptableTools/example-adaptable-nocode-aggrid) to see a basic example of how to set up the No Code plugin.
|
|
52
|
+
|
|
53
|
+
## Demo
|
|
54
|
+
Visit the [No Code Demo](https://demo.adaptabletools.com/admin/aggridnocodedemo) to see AdapTable running the No Code plugin.
|
|
55
|
+
|
|
56
|
+
## Help
|
|
57
|
+
Developers can learn how to access AdapTable programmatically at [AdapTable Documentation](https://docs.adaptabletools.com).
|
|
58
|
+
|
|
59
|
+
## Other AdapTable Resources
|
|
60
|
+
General information about Adaptable Tools is available at our [Website](http://www.adaptabletools.com)
|
|
61
|
+
|
|
62
|
+
## Support
|
|
63
|
+
For all support enquiries please email [`support@adaptabletools.com`](mailto:support@adaptabletools.com) or [raise a Support Ticket](https://adaptabletools.zendesk.com/hc/en-us/requests/new).
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptabletools/adaptable-plugin-nocode-aggrid",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "18.0.0-canary.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "http://www.adaptabletools.com/",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Jonny Wolfson",
|
|
8
8
|
"email": "jonny.wolfson@adaptabletools.com"
|
|
9
9
|
},
|
|
10
|
-
"main": "src/index.js",
|
|
11
10
|
"typings": "src/index.d.ts",
|
|
12
11
|
"dependencies": {
|
|
13
12
|
"tslib": "^2.3.0",
|
|
14
13
|
"xlsx": "^0.15.5",
|
|
15
|
-
"@adaptabletools/adaptable": "
|
|
16
|
-
}
|
|
14
|
+
"@adaptabletools/adaptable": "18.0.0-canary.1"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"module": "src/index.js"
|
|
17
18
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { AdaptableOptions, AdaptablePlugin, AgGridConfig } from '@adaptabletools/adaptable/types';
|
|
2
3
|
export declare const readJSONFile: (file: File, toJSON?: (str: string) => Promise<any> | any) => Promise<unknown>;
|
|
3
4
|
export declare const readExcelFile: (file: File) => Promise<any>;
|
package/src/index.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
const readJSONFile = async (file, toJSON) => {
|
|
1
|
+
import { read as XLSXRead, utils as XLSXUtils } from 'xlsx';
|
|
2
|
+
import { AdaptableNoCodeWizard } from '@adaptabletools/adaptable/agGrid';
|
|
3
|
+
import { AdaptablePlugin } from '@adaptabletools/adaptable/types';
|
|
4
|
+
// TODO in the future, try to put back the version check
|
|
5
|
+
// import { version, name } from '../package.json';
|
|
6
|
+
// import { version as coreVersion } from '@adaptabletools/adaptable/package.json';
|
|
7
|
+
// const suffix = name.endsWith('-cjs') ? '-cjs' : '';
|
|
8
|
+
// if (version !== coreVersion) {
|
|
9
|
+
// console.warn(`
|
|
10
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
11
|
+
// !!!!!!! "@adaptabletools/adaptable-plugin-nocode${suffix}" (v @${version}) and "@adaptabletools/adaptable${suffix}" (v @${coreVersion}) have different versions - they should have the exact same version.
|
|
12
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
13
|
+
// `);
|
|
14
|
+
// }
|
|
15
|
+
export const readJSONFile = async (file, toJSON) => {
|
|
18
16
|
const reader = new FileReader();
|
|
19
17
|
return new Promise((resolve, reject) => {
|
|
20
18
|
reader.onload = function (e) {
|
|
@@ -33,14 +31,13 @@ const readJSONFile = async (file, toJSON) => {
|
|
|
33
31
|
reader.readAsText(file);
|
|
34
32
|
});
|
|
35
33
|
};
|
|
36
|
-
|
|
37
|
-
const readExcelFile = (file) => {
|
|
34
|
+
export const readExcelFile = (file) => {
|
|
38
35
|
/* Boilerplate to set up FileReader */
|
|
39
36
|
const reader = new FileReader();
|
|
40
37
|
const asBinary = !!reader.readAsBinaryString;
|
|
41
38
|
return new Promise((resolve, reject) => {
|
|
42
39
|
reader.onload = (e) => {
|
|
43
|
-
const wb = (
|
|
40
|
+
const wb = XLSXRead(e.target.result, {
|
|
44
41
|
type: asBinary ? 'binary' : 'array',
|
|
45
42
|
cellDates: true,
|
|
46
43
|
});
|
|
@@ -48,7 +45,7 @@ const readExcelFile = (file) => {
|
|
|
48
45
|
const wsname = wb.SheetNames[0];
|
|
49
46
|
const ws = wb.Sheets[wsname];
|
|
50
47
|
// Convert array of arrays
|
|
51
|
-
const data =
|
|
48
|
+
const data = XLSXUtils.sheet_to_json(ws, { header: 1 });
|
|
52
49
|
resolve(data);
|
|
53
50
|
};
|
|
54
51
|
reader.onerror = reject;
|
|
@@ -60,9 +57,8 @@ const readExcelFile = (file) => {
|
|
|
60
57
|
}
|
|
61
58
|
});
|
|
62
59
|
};
|
|
63
|
-
exports.readExcelFile = readExcelFile;
|
|
64
60
|
const defaultOptions = {};
|
|
65
|
-
class NoCodePlugin extends
|
|
61
|
+
class NoCodePlugin extends AdaptablePlugin {
|
|
66
62
|
constructor(options) {
|
|
67
63
|
super(options);
|
|
68
64
|
this.pluginId = 'nocode-aggrid';
|
|
@@ -80,7 +76,7 @@ class NoCodePlugin extends types_1.AdaptablePlugin {
|
|
|
80
76
|
}
|
|
81
77
|
let isJSON;
|
|
82
78
|
return new Promise((resolve) => {
|
|
83
|
-
new
|
|
79
|
+
new AdaptableNoCodeWizard(adaptableOptions, {
|
|
84
80
|
fileAccept: '.json,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel',
|
|
85
81
|
helpText: this.options.headerMessage,
|
|
86
82
|
defaultActionMessage: this.options.actionMessage ||
|
|
@@ -93,9 +89,9 @@ class NoCodePlugin extends types_1.AdaptablePlugin {
|
|
|
93
89
|
readFile: (file) => {
|
|
94
90
|
isJSON = (file.type && file.type.indexOf('json')) != -1 || file.name.endsWith('.json');
|
|
95
91
|
if (isJSON) {
|
|
96
|
-
return
|
|
92
|
+
return readJSONFile(file);
|
|
97
93
|
}
|
|
98
|
-
return
|
|
94
|
+
return readExcelFile(file);
|
|
99
95
|
},
|
|
100
96
|
onInit: ({ gridOptions, adaptableOptions: newAdaptableOptions }) => {
|
|
101
97
|
Object.keys(newAdaptableOptions).forEach((key) => {
|
|
@@ -128,4 +124,4 @@ class NoCodePlugin extends types_1.AdaptablePlugin {
|
|
|
128
124
|
});
|
|
129
125
|
}
|
|
130
126
|
}
|
|
131
|
-
|
|
127
|
+
export default (options) => new NoCodePlugin(options);
|