@adaptabletools/adaptable-plugin-ipushpull-cjs 17.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.
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import * as IPushPullRedux from '../Redux/ActionReducers/IPushPullRedux';
3
+ import { ModuleViewPopupProps } from '@adaptabletools/adaptable/src/View/Components/SharedProps/ModuleViewPopupProps';
4
+ import * as TeamSharingRedux from '@adaptabletools/adaptable/src/Redux/ActionsReducers/TeamSharingRedux';
5
+ import { EditableConfigEntityState } from '@adaptabletools/adaptable/src/View/Components/SharedProps/EditableConfigEntityState';
6
+ import { AdaptableObject } from '@adaptabletools/adaptable/src/PredefinedConfig/Common/AdaptableObject';
7
+ import { IPushPullReport } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
8
+ import { AdaptableSharedEntityConfig } from '@adaptabletools/adaptable/src/PredefinedConfig/TeamSharingState';
9
+ interface IPushPullPopupProps extends ModuleViewPopupProps<IPushPullPopupComponent> {
10
+ onIPushPullSendSnapshot: (iPushPulleport: IPushPullReport) => IPushPullRedux.IPushPullSendSnapshotAction;
11
+ onIPushPullStopLiveData: () => IPushPullRedux.IPushPullStopLiveDataAction;
12
+ onShare: (entity: AdaptableObject, config: AdaptableSharedEntityConfig) => TeamSharingRedux.TeamSharingShareAction;
13
+ }
14
+ declare class IPushPullPopupComponent extends React.Component<IPushPullPopupProps, EditableConfigEntityState> {
15
+ constructor(props: IPushPullPopupProps);
16
+ shouldClosePopupOnFinishWizard: boolean;
17
+ componentDidMount(): void;
18
+ render(): JSX.Element;
19
+ onApplyExport(iPushPullReport: IPushPullReport): void;
20
+ }
21
+ export declare let IPushPullPopup: import("react-redux").ConnectedComponent<typeof IPushPullPopupComponent, import("react-redux").Omit<JSX.LibraryManagedAttributes<C, import("react-redux").GetProps<C>>, keyof IPushPullPopupProps>>;
22
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPushPullPopup = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const React = tslib_1.__importStar(require("react"));
6
+ const react_redux_1 = require("react-redux");
7
+ const PanelWithButton_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Panels/PanelWithButton");
8
+ const IPushPullRedux = tslib_1.__importStar(require("../Redux/ActionReducers/IPushPullRedux"));
9
+ const TeamSharingRedux = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Redux/ActionsReducers/TeamSharingRedux"));
10
+ const ModuleConstants = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/ModuleConstants"));
11
+ const UIHelper_1 = require("@adaptabletools/adaptable-cjs/src/View/UIHelper");
12
+ class IPushPullPopupComponent extends React.Component {
13
+ constructor(props) {
14
+ super(props);
15
+ this.shouldClosePopupOnFinishWizard = false;
16
+ this.state = UIHelper_1.UIHelper.getEmptyConfigState();
17
+ }
18
+ componentDidMount() {
19
+ if (this.props.popupParams) {
20
+ this.shouldClosePopupOnFinishWizard =
21
+ this.props.popupParams.source && this.props.popupParams.source == 'Toolbar';
22
+ }
23
+ }
24
+ render() {
25
+ return (React.createElement(PanelWithButton_1.PanelWithButton, { headerText: this.props.moduleInfo.FriendlyName, bodyProps: { padding: 0 }, glyphicon: this.props.moduleInfo.Glyph, infoLink: this.props.moduleInfo.HelpPage, infoLinkDisabled: !this.props.api.internalApi.isDocumentationLinksDisplayed() }));
26
+ }
27
+ onApplyExport(iPushPullReport) {
28
+ this.props.onIPushPullSendSnapshot(iPushPullReport);
29
+ }
30
+ }
31
+ function mapStateToProps(state) {
32
+ return {};
33
+ }
34
+ function mapDispatchToProps(dispatch) {
35
+ return {
36
+ onIPushPullSendSnapshot: (report) => dispatch(IPushPullRedux.IPushPullSendSnapshot(report)),
37
+ onIPushPullStopLiveData: () => dispatch(IPushPullRedux.IPushPullStopLiveData()),
38
+ onShare: (entity, config) => dispatch(TeamSharingRedux.TeamSharingShare(entity, ModuleConstants.IPushPullModuleId, config)),
39
+ };
40
+ }
41
+ exports.IPushPullPopup = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(IPushPullPopupComponent);
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ import { ViewPanelProps } from '@adaptabletools/adaptable/src/View/Components/SharedProps/ViewPanelProps';
3
+ import { IPushPullDomain, IPushPullReport, IPushPullSchedule } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
4
+ import * as IPushPullRedux from '../Redux/ActionReducers/IPushPullRedux';
5
+ import * as PopupRedux from '@adaptabletools/adaptable/src/Redux/ActionsReducers/PopupRedux';
6
+ import { AdaptableColumn } from '@adaptabletools/adaptable/src/PredefinedConfig/Common/AdaptableColumn';
7
+ import { Report } from '@adaptabletools/adaptable/src/PredefinedConfig/ExportState';
8
+ export interface IPushPullViewPanelComponentProps extends ViewPanelProps {
9
+ onIPushPullSendSnapshot: (iPushPulleport: IPushPullReport) => IPushPullRedux.IPushPullSendSnapshotAction;
10
+ onIPushPullStartLiveData: (iPushPulleport: IPushPullReport) => IPushPullRedux.IPushPullStartLiveDataAction;
11
+ onIPushPullStopLiveData: () => IPushPullRedux.IPushPullStopLiveDataAction;
12
+ onNewIPushPullSchedule: (iPushPullSchedule: IPushPullSchedule) => PopupRedux.PopupShowScreenAction;
13
+ onShowIPushPullLogin: () => PopupRedux.PopupShowScreenAction;
14
+ onShowAddIPushPullPage: () => PopupRedux.PopupShowScreenAction;
15
+ Columns: AdaptableColumn[];
16
+ Reports: Report[] | undefined;
17
+ CurrentLiveIPushPullReport: IPushPullReport | undefined;
18
+ IPushPullDomainsPages: IPushPullDomain[] | undefined;
19
+ IsIPushPullRunning: boolean;
20
+ CurrentIPushPullReportName?: string;
21
+ CurrentIPushPullFolder?: string;
22
+ CurrentIPushPullPage?: string;
23
+ CurrentIPushPullAvailablePages?: string[];
24
+ onCurrentIPushPullReportNameChange: (reportName: string) => IPushPullRedux.IPushPullSetCurrentReportNameAction;
25
+ onCurrentIPushPullFolderChange: (folder: string) => IPushPullRedux.IPushPullSetCurrentFolderAction;
26
+ onCurrentIPushPullPageChange: (page: string) => IPushPullRedux.IPushPullSetCurrentPageAction;
27
+ }
28
+ export declare const IPushPullViewPanelControl: import("react-redux").ConnectedComponent<(props: IPushPullViewPanelComponentProps) => JSX.Element, import("react-redux").Omit<JSX.LibraryManagedAttributes<C, import("react-redux").GetProps<C>>, keyof IPushPullViewPanelComponentProps>>;
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPushPullViewPanelControl = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const IPushPullRedux = tslib_1.__importStar(require("../Redux/ActionReducers/IPushPullRedux"));
6
+ const PopupRedux = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Redux/ActionsReducers/PopupRedux"));
7
+ const React = tslib_1.__importStar(require("react"));
8
+ const ObjectFactory_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/Utilities/ObjectFactory"));
9
+ const StringExtensions_1 = require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/StringExtensions");
10
+ const rebass_1 = require("rebass");
11
+ const DropdownButton_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/DropdownButton"));
12
+ const ButtonExport_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Buttons/ButtonExport");
13
+ const ButtonPause_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Buttons/ButtonPause");
14
+ const ButtonPlay_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Buttons/ButtonPlay");
15
+ const join_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/utils/join"));
16
+ const GeneralConstants = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/GeneralConstants"));
17
+ const ButtonSchedule_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Buttons/ButtonSchedule");
18
+ const ButtonNewPage_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Buttons/ButtonNewPage");
19
+ const ButtonLogout_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Buttons/ButtonLogout");
20
+ const ButtonLogin_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Buttons/ButtonLogin");
21
+ const ModuleConstants = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/ModuleConstants"));
22
+ const react_redux_1 = require("react-redux");
23
+ const IPushPullViewPanelComponent = (props) => {
24
+ var _a, _b, _c, _d;
25
+ const [_, update] = React.useState(0);
26
+ const forceUpdate = () => update((x) => x + 1);
27
+ const onLiveDataChanged = React.useCallback((liveDataChangedInfo) => {
28
+ if (liveDataChangedInfo.reportDestination == 'ipushpull' &&
29
+ (liveDataChangedInfo.liveDataTrigger == 'Connected' ||
30
+ liveDataChangedInfo.liveDataTrigger == 'Disconnected')) {
31
+ forceUpdate();
32
+ }
33
+ }, []);
34
+ const getIPPApi = React.useCallback(() => {
35
+ return props.api.pluginsApi.getipushpullPluginApi();
36
+ }, []);
37
+ React.useEffect(() => {
38
+ props.api.eventApi.on('LiveDataChanged', onLiveDataChanged);
39
+ return () => {
40
+ props.api.eventApi.off('LiveDataChanged', onLiveDataChanged);
41
+ };
42
+ }, []);
43
+ const onSelectedReportChanged = (reportName) => props.onCurrentIPushPullReportNameChange(reportName);
44
+ const onFolderChanged = (folder) => props.onCurrentIPushPullFolderChange(folder);
45
+ const onPageChanged = (page) => props.onCurrentIPushPullPageChange(page);
46
+ const onIPushPullSendSnapshot = () => {
47
+ props.onIPushPullSendSnapshot(createIPushPullReportFromState());
48
+ };
49
+ const onIPushPullStartLiveData = () => {
50
+ props.onIPushPullStartLiveData(createIPushPullReportFromState());
51
+ };
52
+ const onNewIPushPullSchedule = () => {
53
+ let iPushPullSchedule = ObjectFactory_1.default.CreateIPushPullSchedule(createIPushPullReportFromState());
54
+ props.onNewIPushPullSchedule(iPushPullSchedule);
55
+ };
56
+ // perhaps this should be props and in real state?
57
+ const createIPushPullReportFromState = () => {
58
+ return {
59
+ ReportName: props.CurrentIPushPullReportName,
60
+ Folder: props.CurrentIPushPullFolder,
61
+ Page: props.CurrentIPushPullPage,
62
+ };
63
+ };
64
+ let systemReports = getIPPApi().includeSystemReports()
65
+ ? props.api.exportApi.getAvailableSystemReports()
66
+ : [];
67
+ let allReports = systemReports
68
+ .filter((s) => props.api.internalApi.getReportService().IsSystemReportActive(s))
69
+ .concat(props.Reports.map((r) => r.Name));
70
+ let availableReports = allReports.map((report) => {
71
+ return {
72
+ label: report,
73
+ value: report,
74
+ onClick: () => onSelectedReportChanged(report),
75
+ };
76
+ });
77
+ let availableFolders = (_b = (_a = props.IPushPullDomainsPages) === null || _a === void 0 ? void 0 : _a.map((iPushPullDomain) => {
78
+ return {
79
+ label: iPushPullDomain.Name,
80
+ value: iPushPullDomain.Name,
81
+ onClick: () => onFolderChanged(iPushPullDomain.Name),
82
+ };
83
+ })) !== null && _b !== void 0 ? _b : [];
84
+ let availablePages = (_d = (_c = props.CurrentIPushPullAvailablePages) === null || _c === void 0 ? void 0 : _c.map((page) => {
85
+ return {
86
+ label: page,
87
+ value: page,
88
+ onClick: () => onPageChanged(page),
89
+ };
90
+ })) !== null && _d !== void 0 ? _d : [];
91
+ // this is clearly ridiculous!
92
+ // im getting tired...
93
+ let isCompletedReport = StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullReportName) &&
94
+ StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullFolder) &&
95
+ StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullPage);
96
+ let isLiveIPushPullReport = isCompletedReport &&
97
+ props.CurrentLiveIPushPullReport &&
98
+ props.CurrentIPushPullReportName == props.CurrentLiveIPushPullReport.ReportName &&
99
+ props.CurrentIPushPullFolder == props.CurrentLiveIPushPullReport.Folder &&
100
+ props.CurrentIPushPullPage == props.CurrentLiveIPushPullReport.Page;
101
+ const elementType = props.viewType === 'Toolbar' ? 'DashboardToolbar' : 'ToolPanel';
102
+ return props.IsIPushPullRunning ? (React.createElement(rebass_1.Flex, { flexDirection: "row", className: `ab-${elementType}__IPushPull__wrap`, flexWrap: props.viewType === 'ToolPanel' ? 'wrap' : 'nowrap' },
103
+ React.createElement(rebass_1.Flex, null,
104
+ React.createElement(DropdownButton_1.default, { disabled: allReports.length == 0 || isLiveIPushPullReport, style: { minWidth: 140, fontSize: 'small' }, items: availableReports, columns: ['label'], className: `ab-${elementType}__IPushPull__select`, onClear: () => onSelectedReportChanged(''), showClearButton: StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullReportName), variant: "outlined", marginRight: 2 }, StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullReportName)
105
+ ? props.CurrentIPushPullReportName
106
+ : 'Select Report')),
107
+ React.createElement(rebass_1.Flex, null,
108
+ React.createElement(DropdownButton_1.default, { disabled: allReports.length == 0 || isLiveIPushPullReport, style: { minWidth: 140, fontSize: 'small' }, items: availableFolders, columns: ['label'], className: `ab-${elementType}__IPushPull__select`, onClear: () => onFolderChanged(''), showClearButton: StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullFolder), variant: "outlined", marginRight: 2 }, StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullFolder)
109
+ ? props.CurrentIPushPullFolder
110
+ : 'Select Folder')),
111
+ React.createElement(rebass_1.Flex, null,
112
+ React.createElement(DropdownButton_1.default, { disabled: allReports.length == 0 || isLiveIPushPullReport, style: { minWidth: 140, fontSize: 'small' }, items: availablePages, columns: ['label'], className: `ab-${elementType}__IPushPull__select`, onClear: () => onPageChanged(''), showClearButton: StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullPage), variant: "outlined", marginRight: 2 }, StringExtensions_1.StringExtensions.IsNotNullOrEmpty(props.CurrentIPushPullPage)
113
+ ? props.CurrentIPushPullPage
114
+ : 'Select Page')),
115
+ React.createElement(rebass_1.Flex, { style: { minWidth: '148px' } },
116
+ React.createElement(ButtonExport_1.ButtonExport, { marginLeft: 1, className: `ab-${elementType}__IPushPull__export`, onClick: () => onIPushPullSendSnapshot(), tooltip: "Send Snapshot to ipushpull", disabled: isLiveIPushPullReport || !isCompletedReport, accessLevel: props.accessLevel }),
117
+ true ? (React.createElement(ButtonPause_1.ButtonPause, { fillColor: 'red', marginLeft: 1, className: `ab-${elementType}__IPushPull__pause`, onClick: () => props.onIPushPullStopLiveData(), tooltip: "Stop sync with ipushpull", disabled: !isLiveIPushPullReport, accessLevel: props.accessLevel })) : (React.createElement(ButtonPlay_1.ButtonPlay, { marginLeft: 1, className: `ab-${elementType}__IPushPull__play`, onClick: () => onIPushPullStartLiveData(), tooltip: "Start sync with ipushpull", disabled: isLiveIPushPullReport || !isCompletedReport, accessLevel: props.accessLevel })),
118
+ isCompletedReport && (React.createElement(rebass_1.Flex, { className: (0, join_1.default)(props.accessLevel == 'ReadOnly' ? GeneralConstants.READ_ONLY_STYLE : '', `ab-${elementType}__IPushPull__controls`), alignItems: "stretch" }, props.api.internalApi.getEntitlementService().isModuleFullEntitlement('Schedule') && (React.createElement(ButtonSchedule_1.ButtonSchedule, { marginLeft: 1, className: `ab-${elementType}__IPushPull__schedule`, onClick: () => onNewIPushPullSchedule(), tooltip: "Schedule", disabled: isLiveIPushPullReport || !isCompletedReport, accessLevel: props.accessLevel })))),
119
+ ' ',
120
+ React.createElement(ButtonNewPage_1.ButtonNewPage, { marginLeft: 1, className: `ab-${elementType}__IPushPull__newpage`, onClick: () => props.onShowAddIPushPullPage(), tooltip: "New Page", disabled: isLiveIPushPullReport, accessLevel: props.accessLevel }),
121
+ React.createElement(ButtonLogout_1.ButtonLogout, { marginLeft: 1, className: `ab-${elementType}__IPushPull__logout`, onClick: () => getIPPApi().logoutFromIPushPull(), tooltip: "Logout", disabled: isLiveIPushPullReport, accessLevel: props.accessLevel })))) : (React.createElement(ButtonLogin_1.ButtonLogin, { marginLeft: 1, className: `ab-${elementType}__IPushPull__login`, onClick: () => props.onShowIPushPullLogin(), tooltip: "Login to ipushpull", accessLevel: props.accessLevel },
122
+ ' ',
123
+ "Login"));
124
+ };
125
+ function mapStateToProps(state) {
126
+ return {
127
+ CurrentLiveIPushPullReport: state.System.CurrentLiveIPushPullReport,
128
+ Reports: state.Export.Reports,
129
+ IPushPullDomainsPages: state.System.IPushPullDomainsPages,
130
+ IsIPushPullRunning: state.System.IsIPushPullRunning,
131
+ CurrentIPushPullReportName: state.System.IPushPullCurrentReportName,
132
+ CurrentIPushPullFolder: state.System.IPushPullCurrentFolder,
133
+ CurrentIPushPullPage: state.System.IPushPullCurrentPage,
134
+ CurrentIPushPullAvailablePages: state.System.IPushPullCurrentAvailablePages,
135
+ };
136
+ }
137
+ function mapDispatchToProps(dispatch) {
138
+ return {
139
+ onIPushPullSendSnapshot: (iPushPullReport) => dispatch(IPushPullRedux.IPushPullSendSnapshot(iPushPullReport)),
140
+ onIPushPullStartLiveData: (iPushPullReport) => dispatch(IPushPullRedux.IPushPullStartLiveData(iPushPullReport)),
141
+ onIPushPullStopLiveData: () => dispatch(IPushPullRedux.IPushPullStopLiveData()),
142
+ onNewIPushPullSchedule: (iPushPullSchedule) => dispatch(PopupRedux.PopupShowScreen(ModuleConstants.ScheduleModuleId, 'SchedulePopup', {
143
+ action: 'New',
144
+ source: 'Toolbar',
145
+ value: iPushPullSchedule,
146
+ })),
147
+ onShowIPushPullLogin: () => dispatch(PopupRedux.PopupShowScreen(ModuleConstants.IPushPullModuleId, 'IPushPullLoginPopup', undefined, {
148
+ footer: false,
149
+ })),
150
+ onShowAddIPushPullPage: () => dispatch(PopupRedux.PopupShowScreen(ModuleConstants.IPushPullModuleId, 'IPushPullAddPagePopup', undefined, {
151
+ footer: false,
152
+ })),
153
+ onCurrentIPushPullReportNameChange: (reportName) => dispatch(IPushPullRedux.IPushPullSetCurrentReportName(reportName)),
154
+ onCurrentIPushPullFolderChange: (folder) => dispatch(IPushPullRedux.IPushPullSetCurrentFolder(folder)),
155
+ onCurrentIPushPullPageChange: (page) => dispatch(IPushPullRedux.IPushPullSetCurrentPage(page)),
156
+ };
157
+ }
158
+ exports.IPushPullViewPanelControl = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(IPushPullViewPanelComponent);
package/src/env.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ [key: string]: string;
3
+ };
4
+ export default _default;
package/src/env.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {
4
+ IPUSHPULL_API_KEY: "CbBaMaoqHVifScrYwKssGnGyNkv5xHOhQVGm3cYP",
5
+ IPUSHPULL_API_SECRET: "xYzE51kuHyyt9kQCvMe0tz0H2sDSjyEQcF5SOBlPQmcL9em0NqcCzyqLYj5fhpuZxQ8BiVcYl6zoOHeI6GYZj1TkUiiLVFoW3HUxiCdEUjlPS8Vl2YHUMEPD5qkLYnGj",
6
+ };
package/src/index.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { AdaptableModule, AdaptablePlugin } from '@adaptabletools/adaptable/types';
2
+ import * as Redux from 'redux';
3
+ import { IPushPullState } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
4
+ import { IModule } from '@adaptabletools/adaptable/src/Strategy/Interface/IModule';
5
+ import { IPushPullApi } from '@adaptabletools/adaptable/src/Api/IPushPullApi';
6
+ import { IPushPullPluginOptions } from '@adaptabletools/adaptable/src/AdaptableOptions/IPushPullPluginOptions';
7
+ import { IAdaptable } from '@adaptabletools/adaptable/src/AdaptableInterfaces/IAdaptable';
8
+ declare class IPushPullPlugin extends AdaptablePlugin {
9
+ options: IPushPullPluginOptions;
10
+ pluginId: string;
11
+ iPushPullApi?: IPushPullApi;
12
+ private PushPullService?;
13
+ constructor(options?: IPushPullPluginOptions);
14
+ afterInitApi(adaptable: IAdaptable): void;
15
+ rootReducer: (rootReducer: any) => {
16
+ System: (state: IPushPullState, action: Redux.Action) => IPushPullState;
17
+ };
18
+ reduxMiddleware: (adaptable: IAdaptable) => Redux.Middleware;
19
+ afterInitModules(adaptable: IAdaptable, modules: Map<AdaptableModule, IModule>): void;
20
+ }
21
+ declare const _default: (options?: IPushPullPluginOptions) => IPushPullPlugin;
22
+ export default _default;
package/src/index.js ADDED
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const types_1 = require("@adaptabletools/adaptable-cjs/types");
5
+ const env_1 = tslib_1.__importDefault(require("./env"));
6
+ const package_json_1 = require("../package.json");
7
+ const package_json_2 = require("@adaptabletools/adaptable-cjs/package.json");
8
+ const ModuleConstants = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/ModuleConstants"));
9
+ const ModuleConstants_1 = require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/ModuleConstants");
10
+ const PopupRedux = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Redux/ActionsReducers/PopupRedux"));
11
+ const AdaptableViewFactory_1 = require("@adaptabletools/adaptable-cjs/src/View/AdaptableViewFactory");
12
+ const PushPullModule_1 = require("./Module/PushPullModule");
13
+ const IPushPullApiImpl_1 = require("./IPushPullApiImpl");
14
+ const PushPullService_1 = require("./Utilities/Services/PushPullService");
15
+ const ipushpull_js_1 = tslib_1.__importDefault(require("ipushpull-js"));
16
+ const IPushPullRedux_1 = require("./Redux/ActionReducers/IPushPullRedux");
17
+ const IPushPullLoginPopup_1 = require("./View/IPushPullLoginPopup");
18
+ const IPushPullAddPagePopup_1 = require("./View/IPushPullAddPagePopup");
19
+ const PluginsRedux_1 = require("@adaptabletools/adaptable-cjs/src/Redux/ActionsReducers/PluginsRedux");
20
+ const StringExtensions_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/StringExtensions"));
21
+ const IPushPullViewPanel_1 = require("./View/IPushPullViewPanel");
22
+ const suffix = package_json_1.name.endsWith('-cjs') ? '-cjs' : '';
23
+ if (package_json_1.version !== package_json_2.version) {
24
+ console.warn(`
25
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
26
+ !!!!!!! "@adaptabletools/adaptable-plugin-ipushpull${suffix}" (v @${package_json_1.version}) and "@adaptabletools/adaptable${suffix}" (v @${package_json_2.version}) have different versions - they should have the exact same version.
27
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28
+ `);
29
+ }
30
+ const getApiKey = () => {
31
+ let key = env_1.default.IPUSHPULL_API_KEY; // need to make sure that is always there
32
+ return key;
33
+ };
34
+ const getApiSecret = () => {
35
+ let secret = env_1.default.IPUSHPULL_API_SECRET; // need to make sure that is always there
36
+ return secret;
37
+ };
38
+ const defaultOptions = {
39
+ ippConfig: {
40
+ api_secret: getApiSecret() || '',
41
+ api_key: getApiKey() || '',
42
+ api_url: 'https://www.ipushpull.com/api/1.0',
43
+ ws_url: 'https://www.ipushpull.com',
44
+ web_url: 'https://www.ipushpull.com',
45
+ docs_url: 'https://docs.ipushpull.com',
46
+ storage_prefix: 'ipp_local',
47
+ transport: 'polling',
48
+ hsts: false, // strict cors policy
49
+ },
50
+ autoLogin: false,
51
+ throttleTime: 2000,
52
+ includeSystemReports: true,
53
+ };
54
+ class IPushPullPlugin extends types_1.AdaptablePlugin {
55
+ constructor(options) {
56
+ super(options);
57
+ this.pluginId = 'ipushpull';
58
+ this.rootReducer = (rootReducer) => {
59
+ return {
60
+ System: (state, action) => {
61
+ let augmentedState = rootReducer.System(state, action);
62
+ if (!state) {
63
+ // required for store initialization
64
+ // (idiomatic way of default parameter value in reducer is not feasible because the passed argument is already initialized by the System reducer)
65
+ augmentedState = Object.assign({}, augmentedState, IPushPullRedux_1.iPushPullInitialState);
66
+ }
67
+ return (0, IPushPullRedux_1.IPushPullReducer)(augmentedState, action);
68
+ },
69
+ };
70
+ };
71
+ this.reduxMiddleware = (adaptable) => (middlewareAPI) => {
72
+ return (next) => {
73
+ return (action) => {
74
+ switch (action.type) {
75
+ case PluginsRedux_1.IPUSHPULL_LOGIN: {
76
+ const actionTyped = action;
77
+ this.iPushPullApi.loginToIPushPull(actionTyped.username, actionTyped.password);
78
+ return next(action);
79
+ }
80
+ case PluginsRedux_1.IPUSHPULL_SEND_SNAPSHOT: {
81
+ let iPushPullModule = (adaptable.adaptableModules.get(ModuleConstants.IPushPullModuleId));
82
+ const actionTyped = action;
83
+ iPushPullModule.sendSnapshot(actionTyped.iPushPullReport);
84
+ middlewareAPI.dispatch(PopupRedux.PopupHideScreen());
85
+ return next(action);
86
+ }
87
+ case PluginsRedux_1.IPUSHPULL_START_LIVE_DATA: {
88
+ let iPushPullModule = (adaptable.adaptableModules.get(ModuleConstants.IPushPullModuleId));
89
+ const actionTyped = action;
90
+ iPushPullModule.startLiveData(actionTyped.iPushPullReport);
91
+ middlewareAPI.dispatch(PopupRedux.PopupHideScreen());
92
+ return next(action);
93
+ }
94
+ case PluginsRedux_1.IPUSHPULL_STOP_LIVE_DATA: {
95
+ let iPushPullModule = (adaptable.adaptableModules.get(ModuleConstants.IPushPullModuleId));
96
+ iPushPullModule.stopLiveData();
97
+ return next(action);
98
+ }
99
+ case PluginsRedux_1.IPUSHPULL_ADD_PAGE: {
100
+ const actionTyped = action;
101
+ this.iPushPullApi.addNewIPushPullPage(actionTyped.folder, actionTyped.page);
102
+ return next(action);
103
+ }
104
+ case PluginsRedux_1.IPUSHPULL_SET_CURRENT_FOLDER: {
105
+ const actionTyped = action;
106
+ const currentFolder = actionTyped.folder;
107
+ const isFolderValid = StringExtensions_1.default.IsNotNullOrEmpty(currentFolder);
108
+ const availablePages = isFolderValid
109
+ ? adaptable.api.pluginsApi
110
+ .getipushpullPluginApi()
111
+ .getPagesForIPushPullDomain(currentFolder)
112
+ : [];
113
+ middlewareAPI.dispatch((0, IPushPullRedux_1.IPushPullSetCurrentAvailablePages)(availablePages));
114
+ middlewareAPI.dispatch((0, IPushPullRedux_1.IPushPullSetCurrentPage)(''));
115
+ return next(action);
116
+ }
117
+ case PluginsRedux_1.IPUSHPULL_DOMAIN_PAGES_SET: {
118
+ //refresh the available pages
119
+ const currentFolder = middlewareAPI.getState().System.IPushPullCurrentFolder;
120
+ const isFolderValid = StringExtensions_1.default.IsNotNullOrEmpty(currentFolder);
121
+ if (isFolderValid) {
122
+ const availablePages = adaptable.api.pluginsApi
123
+ .getipushpullPluginApi()
124
+ .getPagesForIPushPullDomain(currentFolder);
125
+ middlewareAPI.dispatch((0, IPushPullRedux_1.IPushPullSetCurrentAvailablePages)(availablePages));
126
+ }
127
+ return next(action);
128
+ }
129
+ default: {
130
+ return next(action);
131
+ }
132
+ }
133
+ };
134
+ };
135
+ };
136
+ const ippConfig = Object.assign(Object.assign({}, defaultOptions.ippConfig), (options || {}).ippConfig);
137
+ if (!ippConfig.api_key) {
138
+ ippConfig.api_key = defaultOptions.ippConfig.api_key;
139
+ }
140
+ if (!ippConfig.api_secret) {
141
+ ippConfig.api_secret = defaultOptions.ippConfig.api_secret;
142
+ }
143
+ this.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), options), { ippConfig });
144
+ /**
145
+ * Contains the objects required to export (snapshot or live) data to ipushpull from AdapTable.
146
+ *
147
+ * Includes ipushpull config and objects and, optionally, any ipushpull Reports (including schedules).
148
+ */
149
+ // IPushPull?: IPushPullState;
150
+ ipushpull_js_1.default.config.set(this.options.ippConfig);
151
+ }
152
+ afterInitApi(adaptable) {
153
+ this.iPushPullApi = new IPushPullApiImpl_1.IPushPullApiImpl(adaptable, this.options);
154
+ this.PushPullService = new PushPullService_1.PushPullService(adaptable);
155
+ this.iPushPullApi.setIPushPullInstance(ipushpull_js_1.default);
156
+ this.registerProperty('api', () => this.iPushPullApi);
157
+ this.registerProperty('service', () => this.PushPullService);
158
+ }
159
+ afterInitModules(adaptable, modules) {
160
+ modules.set(ModuleConstants_1.IPushPullModuleId, new PushPullModule_1.PushPullModule(adaptable.api));
161
+ AdaptableViewFactory_1.AdaptableViewFactory.IPushPullLoginPopup = IPushPullLoginPopup_1.IPushPullLoginPopup;
162
+ AdaptableViewFactory_1.AdaptableViewFactory.IPushPullAddPagePopup = IPushPullAddPagePopup_1.IPushPullAddPagePopup;
163
+ AdaptableViewFactory_1.AdaptableViewPanelFactory.set(ModuleConstants_1.IPushPullModuleId, IPushPullViewPanel_1.IPushPullViewPanelControl);
164
+ }
165
+ }
166
+ exports.default = (options) => new IPushPullPlugin(options);