@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,179 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPushPullReducer = exports.iPushPullInitialState = exports.IPushPullSetCurrentAvailablePages = exports.IPushPullSetCurrentPage = exports.IPushPullSetCurrentFolder = exports.IPushPullSetCurrentReportName = exports.IPushPullLiveReportClear = exports.IPushPullLiveReportSet = exports.IPushPullClearDomainsPages = exports.IPushPullSetDomainsPages = exports.SetIPushPullRunningOff = exports.SetIPushPullRunningOn = exports.SetIPushPullAvailableOff = exports.SetIPushPullAvailableOn = exports.IPushPullAddPage = exports.IPushPullSetLoginErrorMessage = exports.IPushPullSetLoginDetails = exports.IPushPullLogout = exports.IPushPullLogin = exports.IPushPullStopLiveData = exports.IPushPullStartLiveData = exports.IPushPullSendSnapshot = exports.IPushPullSetThrottleTime = void 0;
4
+ const GeneralConstants_1 = require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/GeneralConstants");
5
+ const PluginsRedux_1 = require("@adaptabletools/adaptable-cjs/src/Redux/ActionsReducers/PluginsRedux");
6
+ const IPushPullSetThrottleTime = (throttleTime) => ({
7
+ type: PluginsRedux_1.IPUSHPULL_SET_THROTTLE_TIME,
8
+ throttleTime,
9
+ });
10
+ exports.IPushPullSetThrottleTime = IPushPullSetThrottleTime;
11
+ const IPushPullSendSnapshot = (iPushPullReport) => ({
12
+ type: PluginsRedux_1.IPUSHPULL_SEND_SNAPSHOT,
13
+ iPushPullReport,
14
+ });
15
+ exports.IPushPullSendSnapshot = IPushPullSendSnapshot;
16
+ const IPushPullStartLiveData = (iPushPullReport) => ({
17
+ type: PluginsRedux_1.IPUSHPULL_START_LIVE_DATA,
18
+ iPushPullReport,
19
+ });
20
+ exports.IPushPullStartLiveData = IPushPullStartLiveData;
21
+ const IPushPullStopLiveData = () => ({
22
+ type: PluginsRedux_1.IPUSHPULL_STOP_LIVE_DATA,
23
+ });
24
+ exports.IPushPullStopLiveData = IPushPullStopLiveData;
25
+ const IPushPullLogin = (username, password) => ({
26
+ type: PluginsRedux_1.IPUSHPULL_LOGIN,
27
+ username,
28
+ password,
29
+ });
30
+ exports.IPushPullLogin = IPushPullLogin;
31
+ const IPushPullLogout = () => ({
32
+ type: PluginsRedux_1.IPUSHPULL_LOGOUT,
33
+ });
34
+ exports.IPushPullLogout = IPushPullLogout;
35
+ const IPushPullSetLoginDetails = (username, password) => ({
36
+ type: PluginsRedux_1.IPUSHPULL_SET_LOGIN_DETAILS,
37
+ username,
38
+ password,
39
+ });
40
+ exports.IPushPullSetLoginDetails = IPushPullSetLoginDetails;
41
+ const IPushPullSetLoginErrorMessage = (errorMessage) => ({
42
+ type: PluginsRedux_1.IPUSHPULL_SET_LOGIN_ERROR_MESSAGE,
43
+ errorMessage,
44
+ });
45
+ exports.IPushPullSetLoginErrorMessage = IPushPullSetLoginErrorMessage;
46
+ const IPushPullAddPage = (folder, page) => ({
47
+ type: PluginsRedux_1.IPUSHPULL_ADD_PAGE,
48
+ folder,
49
+ page,
50
+ });
51
+ exports.IPushPullAddPage = IPushPullAddPage;
52
+ const SetIPushPullAvailableOn = () => ({
53
+ type: PluginsRedux_1.IPUSHPULL_SET_AVAILABLE_ON,
54
+ });
55
+ exports.SetIPushPullAvailableOn = SetIPushPullAvailableOn;
56
+ const SetIPushPullAvailableOff = () => ({
57
+ type: PluginsRedux_1.IPUSHPULL_SET_AVAILABLE_OFF,
58
+ });
59
+ exports.SetIPushPullAvailableOff = SetIPushPullAvailableOff;
60
+ const SetIPushPullRunningOn = () => ({
61
+ type: PluginsRedux_1.IPUSHPULL_SET_RUNNING_ON,
62
+ });
63
+ exports.SetIPushPullRunningOn = SetIPushPullRunningOn;
64
+ const SetIPushPullRunningOff = () => ({
65
+ type: PluginsRedux_1.IPUSHPULL_SET_RUNNING_OFF,
66
+ });
67
+ exports.SetIPushPullRunningOff = SetIPushPullRunningOff;
68
+ const IPushPullSetDomainsPages = (IPushPullDomainsPages) => {
69
+ return {
70
+ type: PluginsRedux_1.IPUSHPULL_DOMAIN_PAGES_SET,
71
+ IPushPullDomainsPages,
72
+ };
73
+ };
74
+ exports.IPushPullSetDomainsPages = IPushPullSetDomainsPages;
75
+ const IPushPullClearDomainsPages = () => {
76
+ return {
77
+ type: PluginsRedux_1.IPUSHPULL_DOMAIN_PAGES_CLEAR,
78
+ };
79
+ };
80
+ exports.IPushPullClearDomainsPages = IPushPullClearDomainsPages;
81
+ const IPushPullLiveReportSet = (iPushPullReport) => ({
82
+ type: PluginsRedux_1.IPUSHPULL_LIVE_REPORT_SET,
83
+ iPushPullReport,
84
+ });
85
+ exports.IPushPullLiveReportSet = IPushPullLiveReportSet;
86
+ const IPushPullLiveReportClear = () => ({
87
+ type: PluginsRedux_1.IPUSHPULL_LIVE_REPORT_CLEAR,
88
+ });
89
+ exports.IPushPullLiveReportClear = IPushPullLiveReportClear;
90
+ const IPushPullSetCurrentReportName = (reportName) => ({ type: PluginsRedux_1.IPUSHPULL_SET_CURRENT_REPORTNAME, reportName });
91
+ exports.IPushPullSetCurrentReportName = IPushPullSetCurrentReportName;
92
+ const IPushPullSetCurrentFolder = (folder) => ({
93
+ type: PluginsRedux_1.IPUSHPULL_SET_CURRENT_FOLDER,
94
+ folder,
95
+ });
96
+ exports.IPushPullSetCurrentFolder = IPushPullSetCurrentFolder;
97
+ const IPushPullSetCurrentPage = (page) => ({
98
+ type: PluginsRedux_1.IPUSHPULL_SET_CURRENT_PAGE,
99
+ page,
100
+ });
101
+ exports.IPushPullSetCurrentPage = IPushPullSetCurrentPage;
102
+ const IPushPullSetCurrentAvailablePages = (availablePages) => ({
103
+ type: PluginsRedux_1.IPUSHPULL_SET_CURRENT_AVAILABLE_PAGES,
104
+ availablePages,
105
+ });
106
+ exports.IPushPullSetCurrentAvailablePages = IPushPullSetCurrentAvailablePages;
107
+ exports.iPushPullInitialState = {
108
+ IsIPushPullRunning: false,
109
+ IPushPullDomainsPages: GeneralConstants_1.EMPTY_ARRAY,
110
+ CurrentLiveIPushPullReport: undefined,
111
+ IPushPullLoginErrorMessage: undefined,
112
+ IPushPullCurrentReportName: GeneralConstants_1.EMPTY_STRING,
113
+ IPushPullCurrentFolder: GeneralConstants_1.EMPTY_STRING,
114
+ IPushPullCurrentPage: GeneralConstants_1.EMPTY_STRING,
115
+ IPushPullCurrentAvailablePages: GeneralConstants_1.EMPTY_ARRAY,
116
+ };
117
+ const IPushPullReducer = (
118
+ // initial state is handled in the plugin rootReducer
119
+ state, action) => {
120
+ switch (action.type) {
121
+ case PluginsRedux_1.IPUSHPULL_SET_AVAILABLE_ON:
122
+ return Object.assign({}, state, { IsIPushPullAvailable: true });
123
+ case PluginsRedux_1.IPUSHPULL_SET_AVAILABLE_OFF:
124
+ return Object.assign({}, state, { IsIPushPullAvailable: false });
125
+ case PluginsRedux_1.IPUSHPULL_SET_RUNNING_ON:
126
+ return Object.assign({}, state, { IsIPushPullRunning: true });
127
+ case PluginsRedux_1.IPUSHPULL_SET_RUNNING_OFF:
128
+ return Object.assign({}, state, { IsIPushPullRunning: false });
129
+ case PluginsRedux_1.IPUSHPULL_SET_LOGIN_DETAILS: {
130
+ let loginAction = action;
131
+ return Object.assign(Object.assign({}, state), { CurrentIPushpullUsername: loginAction.username, CurrentIPushpullPassword: loginAction.password });
132
+ }
133
+ case PluginsRedux_1.IPUSHPULL_LOGOUT: {
134
+ return Object.assign(Object.assign({}, state), { CurrentIPushpullUsername: undefined, CurrentIPushpullPassword: undefined });
135
+ }
136
+ case PluginsRedux_1.IPUSHPULL_SET_LOGIN_ERROR_MESSAGE: {
137
+ return Object.assign(Object.assign({}, state), { IPushPullLoginErrorMessage: action.errorMessage });
138
+ }
139
+ case PluginsRedux_1.IPUSHPULL_DOMAIN_PAGES_SET: {
140
+ return Object.assign({}, state, {
141
+ IPushPullDomainsPages: action.IPushPullDomainsPages || [],
142
+ });
143
+ }
144
+ case PluginsRedux_1.IPUSHPULL_DOMAIN_PAGES_CLEAR: {
145
+ return Object.assign({}, state, {
146
+ IPushPullDomainsPages: [],
147
+ });
148
+ }
149
+ case PluginsRedux_1.IPUSHPULL_LIVE_REPORT_SET: {
150
+ const actionType = action;
151
+ return Object.assign({}, state, { CurrentLiveIPushPullReport: actionType.iPushPullReport });
152
+ }
153
+ case PluginsRedux_1.IPUSHPULL_LIVE_REPORT_CLEAR: {
154
+ // const atctionType = action as IPushPullLiveReportSetAction;
155
+ return Object.assign({}, state, { CurrentLiveIPushPullReport: undefined });
156
+ }
157
+ case PluginsRedux_1.IPUSHPULL_SET_CURRENT_REPORTNAME: {
158
+ const actionTyped = action;
159
+ return Object.assign({}, state, { IPushPullCurrentReportName: actionTyped.reportName });
160
+ }
161
+ case PluginsRedux_1.IPUSHPULL_SET_CURRENT_FOLDER: {
162
+ const actionTyped = action;
163
+ return Object.assign({}, state, { IPushPullCurrentFolder: actionTyped.folder });
164
+ }
165
+ case PluginsRedux_1.IPUSHPULL_SET_CURRENT_PAGE: {
166
+ const actionTyped = action;
167
+ return Object.assign({}, state, { IPushPullCurrentPage: actionTyped.page });
168
+ }
169
+ case PluginsRedux_1.IPUSHPULL_SET_CURRENT_AVAILABLE_PAGES: {
170
+ const actionTyped = action;
171
+ return Object.assign({}, state, {
172
+ IPushPullCurrentAvailablePages: actionTyped.availablePages,
173
+ });
174
+ }
175
+ default:
176
+ return state;
177
+ }
178
+ };
179
+ exports.IPushPullReducer = IPushPullReducer;
@@ -0,0 +1,11 @@
1
+ import { ServiceStatus } from '../PushPullService';
2
+ import { IPushPullDomain } from '@adaptabletools/adaptable/src/PredefinedConfig/SystemState';
3
+ export interface IPushPullService {
4
+ login(login: string, password: string): Promise<any>;
5
+ getDomainPages(): Promise<IPushPullDomain[]>;
6
+ loadPage(folderIPP: string, pageIPP: string): Promise<void>;
7
+ unloadPage(page: string): void;
8
+ pushData(page: string, data: any[]): Promise<void>;
9
+ getIPushPullStatus(): ServiceStatus;
10
+ addNewPage(folderId: number, page: string): Promise<any>;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,23 @@
1
+ import { IAdaptable } from '@adaptabletools/adaptable/src/AdaptableInterfaces/IAdaptable';
2
+ import { IPushPullService } from './Interface/IPushPullService';
3
+ import { IPushPullDomain } from '@adaptabletools/adaptable/src/PredefinedConfig/SystemState';
4
+ export declare enum ServiceStatus {
5
+ Unknown = "Unknown",
6
+ Disconnected = "Disconnected",
7
+ Connected = "Connected",
8
+ Error = "Error"
9
+ }
10
+ export declare class PushPullService implements IPushPullService {
11
+ adaptable: IAdaptable;
12
+ private ppInstance;
13
+ private pages;
14
+ constructor(adaptable: IAdaptable);
15
+ getIPushPullStatus(): ServiceStatus;
16
+ private getIPPApi;
17
+ login(login: string, password: string): Promise<any>;
18
+ getDomainPages(): Promise<IPushPullDomain[]>;
19
+ loadPage(folderIPP: string, pageIPP: string): Promise<void>;
20
+ unloadPage(page: string): void;
21
+ addNewPage(folderId: number, page: string): Promise<any>;
22
+ pushData(page: string, data: any[]): Promise<void>;
23
+ }
@@ -0,0 +1,214 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PushPullService = exports.ServiceStatus = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const StringExtensions_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/StringExtensions"));
6
+ var ServiceStatus;
7
+ (function (ServiceStatus) {
8
+ ServiceStatus["Unknown"] = "Unknown";
9
+ ServiceStatus["Disconnected"] = "Disconnected";
10
+ ServiceStatus["Connected"] = "Connected";
11
+ ServiceStatus["Error"] = "Error";
12
+ })(ServiceStatus = exports.ServiceStatus || (exports.ServiceStatus = {}));
13
+ class PushPullService {
14
+ constructor(adaptable) {
15
+ this.adaptable = adaptable;
16
+ this.ppInstance = null;
17
+ this.pages = new Map();
18
+ this.adaptable = adaptable;
19
+ this.adaptable.api.eventApi.on('AdaptableReady', async () => {
20
+ // turn off and clear everything
21
+ this.getIPPApi().clearIPushPullInternalState();
22
+ this.getIPPApi().setIPushPullAvailableOff();
23
+ if (!this.ppInstance) {
24
+ let instance = this.getIPPApi().getIPushPullInstance();
25
+ if (instance) {
26
+ this.ppInstance = instance;
27
+ // set that it is available
28
+ this.getIPPApi().setIPushPullAvailableOn();
29
+ let autoLogin = this.getIPPApi().getAutoLogin();
30
+ if (autoLogin) {
31
+ // get the username and passwrord from the options
32
+ let userName = this.getIPPApi().getIPushPullUsername();
33
+ let password = this.getIPPApi().getIPushPullPassword();
34
+ if (StringExtensions_1.default.IsNotNullOrEmpty(userName) &&
35
+ StringExtensions_1.default.IsNotNullOrEmpty(password)) {
36
+ try {
37
+ // slightly circular but it means tht we do the logic in one go..
38
+ this.getIPPApi().loginToIPushPull(userName, password);
39
+ }
40
+ catch (err) {
41
+ // set that it is not running (but still available)
42
+ this.getIPPApi().setIPushPullRunningOff();
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ });
49
+ }
50
+ getIPushPullStatus() {
51
+ if (!this.ppInstance) {
52
+ return ServiceStatus.Error;
53
+ }
54
+ return this.ppInstance.__status;
55
+ }
56
+ getIPPApi() {
57
+ return this.adaptable.api.pluginsApi.getipushpullPluginApi();
58
+ }
59
+ // Logs in to ipushpull
60
+ login(login, password) {
61
+ if (!this.ppInstance) {
62
+ return Promise.reject('No ipushpull instance found!');
63
+ }
64
+ return this.ppInstance.auth
65
+ .login(login, password)
66
+ .then((result) => {
67
+ this.ppInstance.__status = ServiceStatus.Connected;
68
+ this.adaptable.logger.success('Logged in to ipushpull');
69
+ return result;
70
+ })
71
+ .catch((err) => {
72
+ this.ppInstance.__status = ServiceStatus.Error;
73
+ this.getIPPApi().setIPushPullLoginErrorMessage(err.data ? err.data.error_description || err.message : err.message);
74
+ // prefer a more descriptive error, which IPP generally provides
75
+ throw err.data ? err.data.error_description || err.message : err.message;
76
+ });
77
+ }
78
+ // Retrieves domain pages from ipushpull
79
+ getDomainPages() {
80
+ if (!this.ppInstance) {
81
+ return Promise.reject('No ipushpull instance found!');
82
+ }
83
+ return this.ppInstance.api
84
+ .getDomainsAndPages(this.ppInstance.config.api_key)
85
+ .then((response) => {
86
+ this.adaptable.logger.success('Retrieved ipushpull Folder/Page info');
87
+ return response.data.domains.map((domain) => ({
88
+ Name: domain.name,
89
+ FolderId: domain.id,
90
+ Pages: domain.current_user_domain_page_access.pages
91
+ .filter((page) => page.special_page_type == 0 && page.write_access)
92
+ .map((page) => page.name),
93
+ }));
94
+ })
95
+ .catch((error) => {
96
+ this.adaptable.logger.error("Couldn't get Domain/Pages from ipushpull : ", error);
97
+ throw error.message;
98
+ });
99
+ }
100
+ loadPage(folderIPP, pageIPP) {
101
+ if (!this.ppInstance) {
102
+ return Promise.reject('No ipushpull instance found!');
103
+ }
104
+ return new Promise((resolve, reject) => {
105
+ const page = new this.ppInstance.Page(pageIPP, folderIPP);
106
+ page.on(page.EVENT_NEW_CONTENT, () => {
107
+ this.adaptable.logger.info(`Page Ready : ${pageIPP}`);
108
+ this.pages.set(pageIPP, page);
109
+ resolve(page);
110
+ // we return true so it removes the listener for new content.
111
+ // IPP should add that line to their wiki
112
+ return true;
113
+ });
114
+ });
115
+ }
116
+ unloadPage(page) {
117
+ const pageIPP = this.pages.get(page);
118
+ if (pageIPP) {
119
+ pageIPP.destroy();
120
+ this.pages.delete(page);
121
+ this.adaptable.logger.info(`Page Unloaded : ${page}`);
122
+ }
123
+ }
124
+ addNewPage(folderId, page) {
125
+ if (!this.ppInstance) {
126
+ return Promise.reject('No ipushpull instance found!');
127
+ }
128
+ return this.ppInstance.Page.create(folderId, page)
129
+ .then((createdPage) => {
130
+ let message = page + "' successfully created.";
131
+ this.adaptable.api.alertApi.showAlertSuccess('ipushpull Page', message);
132
+ this.adaptable.api.internalApi.hidePopupScreen();
133
+ return this.getIPPApi().retrieveIPushPullDomainsFromIPushPull();
134
+ })
135
+ .catch((err) => {
136
+ this.adaptable.logger.error("Couldn't create Page: '" + page + "'. Reason: " + err);
137
+ });
138
+ }
139
+ pushData(page, data) {
140
+ return new Promise((resolve, reject) => {
141
+ let newData = [];
142
+ const style = data && data.length > 1
143
+ ? this.adaptable.getCurrentIPPStyle()
144
+ : this.adaptable.getDefaultIPPStyle();
145
+ newData = data.map((row, i) => row.map((cell, y) => {
146
+ const col = i == 0
147
+ ? style.Header.Columns.find((x) => x.columnFriendlyName == data[0][y])
148
+ : style.Row.Columns.find((x) => x.columnFriendlyName == data[0][y]);
149
+ let styleIPP;
150
+ if (i == 0) {
151
+ styleIPP = {
152
+ 'background-color': style.Header.headerBackColor,
153
+ bbc: '000000',
154
+ bbs: 'none',
155
+ bbw: 'none',
156
+ lbc: '000000',
157
+ lbs: 'none',
158
+ lbw: 'none',
159
+ rbc: '000000',
160
+ rbs: 'none',
161
+ rbw: 'none',
162
+ tbc: '000000',
163
+ tbs: 'none',
164
+ tbw: 'none',
165
+ color: style.Header.headerColor,
166
+ 'font-family': style.Header.headerFontFamily,
167
+ 'font-size': style.Header.headerFontSize,
168
+ 'font-style': style.Header.headerFontStyle,
169
+ 'font-weight': style.Header.headerFontWeight,
170
+ height: `${String(style.Header.height / 3)}px`,
171
+ 'text-align': col.textAlign,
172
+ 'vertical-align': 'middle',
173
+ 'white-space': 'nowrap',
174
+ width: `${String(col.width)}px`,
175
+ 'text-wrap': 'normal',
176
+ 'word-wrap': 'normal',
177
+ };
178
+ }
179
+ else if (i == 1) {
180
+ styleIPP = {
181
+ 'background-color': i % 2 ? style.Row.backColor : style.Row.altBackColor,
182
+ color: style.Row.color,
183
+ 'font-family': style.Row.fontFamily,
184
+ 'font-size': style.Row.fontSize,
185
+ 'font-style': style.Row.fontStyle,
186
+ 'font-weight': style.Row.fontWeight,
187
+ 'text-align': col.textAlign,
188
+ };
189
+ }
190
+ else {
191
+ styleIPP = {
192
+ 'background-color': i % 2 ? style.Row.backColor : style.Row.altBackColor,
193
+ };
194
+ }
195
+ return {
196
+ value: cell,
197
+ formatted_value: cell,
198
+ style: styleIPP,
199
+ };
200
+ }));
201
+ const pageIPP = this.pages.get(page);
202
+ pageIPP.Content.canDoDelta = false;
203
+ pageIPP.Content.update(newData, true);
204
+ pageIPP.push().then(() => {
205
+ this.adaptable.logger.success(`Data pushed for ipushpull page : ${page}`);
206
+ resolve();
207
+ }, (err) => {
208
+ this.adaptable.logger.info(`Error pushing data for ipushpull page : ${page}`);
209
+ reject();
210
+ });
211
+ });
212
+ }
213
+ }
214
+ exports.PushPullService = PushPullService;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import * as IPushPullRedux from '../Redux/ActionReducers/IPushPullRedux';
3
+ import { IPushPullDomain } from '@adaptabletools/adaptable/src/PredefinedConfig/IPushPullState';
4
+ interface IPushPullAddPagePopupProps {
5
+ IPushPullDomainsPages: IPushPullDomain[] | undefined;
6
+ onAddPage: (folder: string, page: string) => IPushPullRedux.IPushPullAddPageAction;
7
+ onCancel: () => any;
8
+ }
9
+ export declare let IPushPullAddPagePopup: import("react-redux").ConnectedComponent<(props: IPushPullAddPagePopupProps) => JSX.Element, import("react-redux").Omit<JSX.LibraryManagedAttributes<C, import("react-redux").GetProps<C>>, "IPushPullDomainsPages" | "onCancel" | "onAddPage">>;
10
+ export {};
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPushPullAddPagePopup = 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 PopupRedux = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Redux/ActionsReducers/PopupRedux"));
8
+ const IPushPullRedux = tslib_1.__importStar(require("../Redux/ActionReducers/IPushPullRedux"));
9
+ const StringExtensions_1 = require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/StringExtensions");
10
+ const FormLayout_1 = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/components/FormLayout"));
11
+ const Input_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/Input"));
12
+ const SimpleButton_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/SimpleButton"));
13
+ const FlexWithFooter_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/FlexWithFooter"));
14
+ const PanelWithImage_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Panels/PanelWithImage");
15
+ const PopupContext_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Popups/AdaptablePopup/PopupContext");
16
+ const ErrorBox_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/ErrorBox"));
17
+ const HelpBlock_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/HelpBlock"));
18
+ const rebass_1 = require("rebass");
19
+ const Dropdown_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/Dropdown"));
20
+ const GeneralConstants_1 = require("@adaptabletools/adaptable-cjs/src/Utilities/Constants/GeneralConstants");
21
+ const ArrayExtensions_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/ArrayExtensions"));
22
+ const IPushPullAddPageComponent = (props) => {
23
+ const [state, setState] = React.useState({
24
+ Folder: '',
25
+ Page: '',
26
+ AvailablePages: GeneralConstants_1.EMPTY_ARRAY,
27
+ ErrorMessage: '',
28
+ });
29
+ const { hidePopup } = (0, PopupContext_1.usePopupContext)();
30
+ const onSubmit = () => {
31
+ if (ArrayExtensions_1.default.ContainsItem(state.AvailablePages, state.Page)) {
32
+ setState(Object.assign(Object.assign({}, state), { ErrorMessage: 'A page with that name already exists in the folder' }));
33
+ }
34
+ else {
35
+ props.onAddPage(state.Folder, state.Page);
36
+ }
37
+ };
38
+ const onPageNameChange = (event) => {
39
+ const e = event.target;
40
+ setState(Object.assign(Object.assign({}, state), { Page: e.value }));
41
+ };
42
+ const onFolderChanged = (folderName) => {
43
+ if (StringExtensions_1.StringExtensions.IsNotNullOrEmpty(folderName) && folderName !== 'Select Folder') {
44
+ let avaialablePages = props.IPushPullDomainsPages.find((f) => f.Name == folderName).Pages;
45
+ setState({
46
+ Folder: folderName,
47
+ AvailablePages: avaialablePages,
48
+ Page: GeneralConstants_1.EMPTY_STRING,
49
+ ErrorMessage: GeneralConstants_1.EMPTY_STRING,
50
+ });
51
+ }
52
+ else {
53
+ setState({
54
+ Folder: GeneralConstants_1.EMPTY_STRING,
55
+ AvailablePages: [],
56
+ Page: GeneralConstants_1.EMPTY_STRING,
57
+ ErrorMessage: GeneralConstants_1.EMPTY_STRING,
58
+ });
59
+ }
60
+ };
61
+ const availableFolders = props.IPushPullDomainsPages.map((iPushPullDomain) => {
62
+ return {
63
+ label: iPushPullDomain.Name,
64
+ value: iPushPullDomain.Name,
65
+ };
66
+ });
67
+ return (React.createElement(PanelWithImage_1.PanelWithImage, { header: "Add ipushpull Page", glyphicon: "newpage", variant: "primary", style: { height: '100%' } },
68
+ React.createElement(FlexWithFooter_1.default, { as: "form", onSubmit: (e) => {
69
+ e.preventDefault();
70
+ onSubmit();
71
+ }, footerProps: {
72
+ fontSize: 'var(--ab-font-size-4)',
73
+ }, footer: React.createElement(React.Fragment, null,
74
+ React.createElement(SimpleButton_1.default, { tone: "neutral", variant: "text", tooltip: "Close", onClick: (e) => {
75
+ e.stopPropagation();
76
+ hidePopup();
77
+ } }, "CLOSE"),
78
+ React.createElement("div", { style: { flex: 1 } }),
79
+ React.createElement(SimpleButton_1.default, { tone: "accent", variant: "raised", type: "submit", disabled: StringExtensions_1.StringExtensions.IsNullOrEmpty(state.Folder) ||
80
+ StringExtensions_1.StringExtensions.IsNullOrEmpty(state.Page), icon: 'check' }, "Add Page")) },
81
+ React.createElement(rebass_1.Flex, { flexDirection: "column", padding: 2, margin: 2 },
82
+ React.createElement(HelpBlock_1.default, { marginBottom: 1 }, "Select a folder and then choose the name of the new ipushpull page it should contain."),
83
+ React.createElement(FormLayout_1.default, { margin: 3 },
84
+ React.createElement(FormLayout_1.FormRow, { label: "Folder:" },
85
+ React.createElement(Dropdown_1.default, { disabled: availableFolders.length == 0, style: { minWidth: '50%' }, options: availableFolders, className: "ab-Popup__IPushPull__select", onChange: (folder) => onFolderChanged(folder), value: state.Folder ? state.Folder : null, placeholder: "Select Folder", marginRight: 2 })),
86
+ React.createElement(FormLayout_1.FormRow, { label: "Page" },
87
+ React.createElement(Input_1.default, { width: "50%", type: "text", placeholder: "Page Name", value: state.Page, onChange: onPageNameChange })),
88
+ state.ErrorMessage ? (React.createElement(FormLayout_1.FormRow, { label: "" },
89
+ React.createElement(ErrorBox_1.default, null, state.ErrorMessage))) : null)))));
90
+ };
91
+ function mapStateToProps(state) {
92
+ return {
93
+ IPushPullDomainsPages: state.System.IPushPullDomainsPages,
94
+ };
95
+ }
96
+ function mapDispatchToProps(dispatch) {
97
+ return {
98
+ onAddPage: (folder, page) => dispatch(IPushPullRedux.IPushPullAddPage(folder, page)),
99
+ onCancel: () => {
100
+ dispatch(PopupRedux.PopupHideScreen());
101
+ },
102
+ };
103
+ }
104
+ exports.IPushPullAddPagePopup = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(IPushPullAddPageComponent);
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import * as IPushPullRedux from '../Redux/ActionReducers/IPushPullRedux';
3
+ interface IPushPullLoginPopupProps {
4
+ pushpullLogin: string | undefined;
5
+ pushpullPassword: string | undefined;
6
+ pushpullLoginErrorMessage: string | undefined;
7
+ onLogin: (login: string, password: string) => IPushPullRedux.IPushPullLoginAction;
8
+ onCancel: () => any;
9
+ }
10
+ export declare let IPushPullLoginPopup: import("react-redux").ConnectedComponent<(props: IPushPullLoginPopupProps) => JSX.Element, import("react-redux").Omit<JSX.LibraryManagedAttributes<C, import("react-redux").GetProps<C>>, keyof IPushPullLoginPopupProps>>;
11
+ export {};
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IPushPullLoginPopup = 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 AdaptableContext_1 = require("@adaptabletools/adaptable-cjs/src/View/AdaptableContext");
8
+ const PopupRedux = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/Redux/ActionsReducers/PopupRedux"));
9
+ const IPushPullRedux = tslib_1.__importStar(require("../Redux/ActionReducers/IPushPullRedux"));
10
+ const StringExtensions_1 = require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/StringExtensions");
11
+ const FormLayout_1 = tslib_1.__importStar(require("@adaptabletools/adaptable-cjs/src/components/FormLayout"));
12
+ const Input_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/Input"));
13
+ const SimpleButton_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/SimpleButton"));
14
+ const FlexWithFooter_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/FlexWithFooter"));
15
+ const PanelWithImage_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Panels/PanelWithImage");
16
+ const PopupContext_1 = require("@adaptabletools/adaptable-cjs/src/View/Components/Popups/AdaptablePopup/PopupContext");
17
+ const ErrorBox_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/ErrorBox"));
18
+ const HelpBlock_1 = tslib_1.__importDefault(require("@adaptabletools/adaptable-cjs/src/components/HelpBlock"));
19
+ const rebass_1 = require("rebass");
20
+ const IPushPullLoginComponent = (props) => {
21
+ const adaptable = (0, AdaptableContext_1.useAdaptable)();
22
+ const options = adaptable.getPlugin('ipushpull').options;
23
+ const [state, setState] = React.useState({
24
+ Login: options.username || '',
25
+ Password: options.password || '',
26
+ });
27
+ const { hidePopup } = (0, PopupContext_1.usePopupContext)();
28
+ const onSubmit = () => {
29
+ props.onLogin(state.Login || '', state.Password || '');
30
+ };
31
+ const onLoginChange = (event) => {
32
+ const e = event.target;
33
+ setState(Object.assign(Object.assign({}, state), { Login: e.value }));
34
+ };
35
+ const onPasswordChange = (event) => {
36
+ const e = event.target;
37
+ setState(Object.assign(Object.assign({}, state), { Password: e.value }));
38
+ };
39
+ return (React.createElement(PanelWithImage_1.PanelWithImage, { header: "ipushpull Login Details", glyphicon: "login", variant: "primary", style: { height: '100%' } },
40
+ React.createElement(FlexWithFooter_1.default, { as: "form", onSubmit: (e) => {
41
+ e.preventDefault();
42
+ onSubmit();
43
+ }, footerProps: {
44
+ fontSize: 'var(--ab-font-size-4)',
45
+ }, footer: React.createElement(React.Fragment, null,
46
+ React.createElement(SimpleButton_1.default, { tone: "neutral", variant: "text", tooltip: "Close", onClick: (e) => {
47
+ e.stopPropagation();
48
+ hidePopup();
49
+ } }, "CLOSE"),
50
+ React.createElement("div", { style: { flex: 1 } }),
51
+ React.createElement(SimpleButton_1.default, { tone: "accent", variant: "raised", type: "submit", disabled: StringExtensions_1.StringExtensions.IsNullOrEmpty(state.Password), icon: 'check' }, "Login")) },
52
+ React.createElement(rebass_1.Flex, { flexDirection: "column", padding: 2, margin: 2 },
53
+ React.createElement(HelpBlock_1.default, { marginBottom: 1 }, "Login to ipushpull using your login (email address) and password."),
54
+ React.createElement(FormLayout_1.default, { margin: 3 },
55
+ React.createElement(FormLayout_1.FormRow, { label: "ipushpull login:" },
56
+ React.createElement(Input_1.default, { width: "100%", type: "email", placeholder: "Email address", value: state.Login, onChange: onLoginChange })),
57
+ React.createElement(FormLayout_1.FormRow, { label: "ipushpull password:" },
58
+ React.createElement(Input_1.default, { width: "100%", type: "password", placeholder: "Password", value: state.Password, onChange: onPasswordChange })),
59
+ props.pushpullLoginErrorMessage ? (React.createElement(FormLayout_1.FormRow, { label: "" },
60
+ React.createElement(ErrorBox_1.default, null, props.pushpullLoginErrorMessage))) : null)))));
61
+ };
62
+ function mapStateToProps(state) {
63
+ return {
64
+ // pushpullLogin: state.IPushPull ? state.IPushPull!.Username : undefined,
65
+ // pushpullPassword: state.IPushPull ? state.IPushPull!.Password : undefined,
66
+ // pushpullLoginErrorMessage: state.IPushPull.IPushPullLoginErrorMessage,
67
+ pushpullLoginErrorMessage: state.System.IPushPullLoginErrorMessage,
68
+ };
69
+ }
70
+ function mapDispatchToProps(dispatch) {
71
+ return {
72
+ onLogin: (login, password) => dispatch(IPushPullRedux.IPushPullLogin(login, password)),
73
+ onCancel: () => {
74
+ dispatch(PopupRedux.PopupHideScreen());
75
+ dispatch(IPushPullRedux.IPushPullSetLoginErrorMessage(''));
76
+ },
77
+ };
78
+ }
79
+ exports.IPushPullLoginPopup = (0, react_redux_1.connect)(mapStateToProps, mapDispatchToProps)(IPushPullLoginComponent);