@axelor/aos-mobile-core 7.0.3 → 7.0.4
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/lib/api/metafile-api.d.ts +3 -1
- package/lib/api/metafile-api.js +10 -2
- package/lib/api/metafile-api.js.map +1 -1
- package/lib/apiProviders/utils.d.ts +7 -7
- package/lib/apiProviders/utils.js +18 -22
- package/lib/apiProviders/utils.js.map +1 -1
- package/lib/app/Module.d.ts +15 -2
- package/lib/auth/api/user-api.js +5 -3
- package/lib/auth/api/user-api.js.map +1 -1
- package/lib/auth/features/userSlice.js +7 -1
- package/lib/auth/features/userSlice.js.map +1 -1
- package/lib/auth/i18n/en.json +0 -16
- package/lib/auth/i18n/fr.json +0 -16
- package/lib/auth/index.js +1 -0
- package/lib/auth/index.js.map +1 -1
- package/lib/auth/models/objectFields.js +14 -0
- package/lib/auth/models/objectFields.js.map +1 -1
- package/lib/components/molecules/UploadFileInput/UploadFileInput.d.ts +11 -2
- package/lib/components/molecules/UploadFileInput/UploadFileInput.js +128 -19
- package/lib/components/molecules/UploadFileInput/UploadFileInput.js.map +1 -1
- package/lib/components/molecules/index.d.ts +0 -3
- package/lib/components/molecules/index.js +0 -3
- package/lib/components/molecules/index.js.map +1 -1
- package/lib/components/organisms/DateInput/DateInput.d.ts +2 -1
- package/lib/components/organisms/DateInput/DateInput.js +8 -5
- package/lib/components/organisms/DateInput/DateInput.js.map +1 -1
- package/lib/components/organisms/index.d.ts +1 -6
- package/lib/components/organisms/index.js +1 -6
- package/lib/components/organisms/index.js.map +1 -1
- package/lib/components/templates/index.d.ts +0 -3
- package/lib/components/templates/index.js +0 -3
- package/lib/components/templates/index.js.map +1 -1
- package/lib/header/HeaderActionsProvider.d.ts +3 -4
- package/lib/header/HeaderActionsProvider.js +16 -10
- package/lib/header/HeaderActionsProvider.js.map +1 -1
- package/lib/header/index.d.ts +2 -1
- package/lib/header/index.js +2 -1
- package/lib/header/index.js.map +1 -1
- package/lib/i18n/hooks/use-translator.d.ts +1 -1
- package/lib/i18n/translations/en.json +34 -4
- package/lib/i18n/translations/fr.json +34 -4
- package/lib/navigator/Navigator.js +19 -7
- package/lib/navigator/Navigator.js.map +1 -1
- package/lib/navigator/drawer/DrawerContent.js +39 -21
- package/lib/navigator/drawer/DrawerContent.js.map +1 -1
- package/lib/navigator/drawer/Header.js +26 -6
- package/lib/navigator/drawer/Header.js.map +1 -1
- package/lib/navigator/drawer/Menu.d.ts +2 -1
- package/lib/navigator/drawer/Menu.js +42 -17
- package/lib/navigator/drawer/Menu.js.map +1 -1
- package/lib/navigator/drawer/MenuItem.d.ts +8 -5
- package/lib/navigator/drawer/MenuItem.js +11 -51
- package/lib/navigator/drawer/MenuItem.js.map +1 -1
- package/lib/navigator/drawer/MenuItemEntry.d.ts +12 -0
- package/lib/navigator/drawer/MenuItemEntry.js +89 -0
- package/lib/navigator/drawer/MenuItemEntry.js.map +1 -0
- package/lib/navigator/drawer/SubMenuItem.d.ts +7 -0
- package/lib/navigator/drawer/SubMenuItem.js +34 -0
- package/lib/navigator/drawer/SubMenuItem.js.map +1 -0
- package/lib/navigator/drawer/SubMenuItemList.d.ts +10 -0
- package/lib/navigator/drawer/SubMenuItemList.js +46 -0
- package/lib/navigator/drawer/SubMenuItemList.js.map +1 -0
- package/lib/navigator/menu.helper.d.ts +9 -0
- package/lib/navigator/menu.helper.js +92 -0
- package/lib/navigator/menu.helper.js.map +1 -1
- package/lib/navigator/module.helper.d.ts +5 -0
- package/lib/navigator/module.helper.js +37 -1
- package/lib/navigator/module.helper.js.map +1 -1
- package/lib/screens/LoginScreen.js +47 -73
- package/lib/screens/LoginScreen.js.map +1 -1
- package/lib/screens/SessionManagementScreen.js +41 -21
- package/lib/screens/SessionManagementScreen.js.map +1 -1
- package/lib/sessions/SessionStorage.d.ts +4 -5
- package/lib/sessions/SessionStorage.js +30 -22
- package/lib/sessions/SessionStorage.js.map +1 -1
- package/lib/{components/templates/PopupCreateSession → sessions/components/alerts}/PopupCreateSession.d.ts +2 -2
- package/lib/sessions/components/alerts/PopupCreateSession.js +128 -0
- package/lib/sessions/components/alerts/PopupCreateSession.js.map +1 -0
- package/lib/sessions/components/alerts/PopupEditSession.d.ts +8 -0
- package/lib/sessions/components/alerts/PopupEditSession.js +83 -0
- package/lib/sessions/components/alerts/PopupEditSession.js.map +1 -0
- package/lib/sessions/components/alerts/PopupSession.d.ts +9 -0
- package/lib/sessions/components/alerts/PopupSession.js +84 -0
- package/lib/sessions/components/alerts/PopupSession.js.map +1 -0
- package/lib/sessions/components/alerts/index.d.ts +3 -0
- package/lib/sessions/components/alerts/index.js +21 -0
- package/lib/sessions/components/alerts/index.js.map +1 -0
- package/lib/sessions/components/buttons/DisabledButton.d.ts +7 -0
- package/lib/{components/molecules/LoginButton/LoginButton.js → sessions/components/buttons/DisabledButton.js} +5 -5
- package/lib/sessions/components/buttons/DisabledButton.js.map +1 -0
- package/lib/sessions/components/buttons/LoginButton.js +24 -0
- package/lib/sessions/components/buttons/LoginButton.js.map +1 -0
- package/lib/sessions/components/buttons/UpdateButton.d.ts +6 -0
- package/lib/sessions/components/buttons/UpdateButton.js +24 -0
- package/lib/sessions/components/buttons/UpdateButton.js.map +1 -0
- package/lib/sessions/components/buttons/index.d.ts +3 -0
- package/lib/sessions/components/buttons/index.js +21 -0
- package/lib/sessions/components/buttons/index.js.map +1 -0
- package/lib/sessions/components/display/LogoImage.js.map +1 -0
- package/lib/sessions/components/display/SessionCard.d.ts +9 -0
- package/lib/sessions/components/display/SessionCard.js +185 -0
- package/lib/sessions/components/display/SessionCard.js.map +1 -0
- package/lib/sessions/components/display/SessionListCard.d.ts +10 -0
- package/lib/sessions/components/display/SessionListCard.js +78 -0
- package/lib/sessions/components/display/SessionListCard.js.map +1 -0
- package/lib/sessions/components/display/index.d.ts +3 -0
- package/lib/sessions/components/display/index.js +21 -0
- package/lib/sessions/components/display/index.js.map +1 -0
- package/lib/{components/molecules/ErrorText → sessions/components/error}/ErrorText.js +2 -2
- package/lib/sessions/components/error/ErrorText.js.map +1 -0
- package/lib/sessions/components/error/index.d.ts +1 -0
- package/lib/sessions/components/error/index.js +19 -0
- package/lib/sessions/components/error/index.js.map +1 -0
- package/lib/sessions/components/index.d.ts +5 -0
- package/lib/sessions/components/index.js +23 -0
- package/lib/sessions/components/index.js.map +1 -0
- package/lib/sessions/components/inputs/DefaultCheckbox.d.ts +8 -0
- package/lib/sessions/components/inputs/DefaultCheckbox.js +36 -0
- package/lib/sessions/components/inputs/DefaultCheckbox.js.map +1 -0
- package/lib/{components/organisms/PasswordInput → sessions/components/inputs}/PasswordInput.d.ts +2 -1
- package/lib/{components/organisms/PasswordInput → sessions/components/inputs}/PasswordInput.js +5 -2
- package/lib/sessions/components/inputs/PasswordInput.js.map +1 -0
- package/lib/sessions/components/inputs/SessionInputs.d.ts +12 -0
- package/lib/sessions/components/inputs/SessionInputs.js +177 -0
- package/lib/sessions/components/inputs/SessionInputs.js.map +1 -0
- package/lib/{components/organisms/SessionNameInput → sessions/components/inputs}/SessionNameInput.d.ts +2 -1
- package/lib/{components/organisms/SessionNameInput → sessions/components/inputs}/SessionNameInput.js +5 -2
- package/lib/sessions/components/inputs/SessionNameInput.js.map +1 -0
- package/lib/{components/organisms/UrlInput → sessions/components/inputs}/UrlInput.d.ts +2 -1
- package/lib/{components/organisms/UrlInput → sessions/components/inputs}/UrlInput.js +14 -3
- package/lib/sessions/components/inputs/UrlInput.js.map +1 -0
- package/lib/{components/organisms/UsernameInput → sessions/components/inputs}/UsernameInput.js +10 -2
- package/lib/sessions/components/inputs/UsernameInput.js.map +1 -0
- package/lib/sessions/components/inputs/index.d.ts +6 -0
- package/lib/sessions/components/inputs/index.js +24 -0
- package/lib/sessions/components/inputs/index.js.map +1 -0
- package/lib/sessions/hook.d.ts +1 -1
- package/lib/sessions/hook.js +5 -5
- package/lib/sessions/hook.js.map +1 -1
- package/lib/sessions/index.d.ts +2 -1
- package/lib/sessions/index.js +2 -1
- package/lib/sessions/index.js.map +1 -1
- package/lib/sessions/type.d.ts +2 -1
- package/lib/sessions/type.js.map +1 -1
- package/lib/sessions/utils.d.ts +2 -1
- package/lib/sessions/utils.js +26 -7
- package/lib/sessions/utils.js.map +1 -1
- package/lib/tools/ContactProvider.d.ts +9 -0
- package/lib/tools/ContactProvider.js +98 -0
- package/lib/tools/ContactProvider.js.map +1 -0
- package/lib/tools/contact.helper.d.ts +21 -0
- package/lib/tools/contact.helper.js +136 -0
- package/lib/tools/contact.helper.js.map +1 -0
- package/lib/tools/index.d.ts +1 -0
- package/lib/tools/index.js +1 -0
- package/lib/tools/index.js.map +1 -1
- package/lib/utils/date.d.ts +16 -0
- package/lib/utils/date.js +41 -0
- package/lib/utils/date.js.map +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +8 -5
- package/lib/components/molecules/ErrorText/ErrorText.js.map +0 -1
- package/lib/components/molecules/LoginButton/LoginButton.js.map +0 -1
- package/lib/components/molecules/SessionNumberIndicator/SessionNumberIndicator.d.ts +0 -4
- package/lib/components/molecules/SessionNumberIndicator/SessionNumberIndicator.js +0 -44
- package/lib/components/molecules/SessionNumberIndicator/SessionNumberIndicator.js.map +0 -1
- package/lib/components/organisms/LogoImage/LogoImage.js.map +0 -1
- package/lib/components/organisms/PasswordInput/PasswordInput.js.map +0 -1
- package/lib/components/organisms/SessionButtons/SessionButtons.d.ts +0 -17
- package/lib/components/organisms/SessionButtons/SessionButtons.js +0 -93
- package/lib/components/organisms/SessionButtons/SessionButtons.js.map +0 -1
- package/lib/components/organisms/SessionNameInput/SessionNameInput.js.map +0 -1
- package/lib/components/organisms/UrlInput/UrlInput.js.map +0 -1
- package/lib/components/organisms/UsernameInput/UsernameInput.js.map +0 -1
- package/lib/components/templates/PopupCreateSession/PopupCreateSession.js +0 -171
- package/lib/components/templates/PopupCreateSession/PopupCreateSession.js.map +0 -1
- package/lib/components/templates/PopupSession/PopupSession.d.ts +0 -8
- package/lib/components/templates/PopupSession/PopupSession.js +0 -135
- package/lib/components/templates/PopupSession/PopupSession.js.map +0 -1
- package/lib/components/templates/PopupSessionList/PopupSessionList.d.ts +0 -7
- package/lib/components/templates/PopupSessionList/PopupSessionList.js +0 -107
- package/lib/components/templates/PopupSessionList/PopupSessionList.js.map +0 -1
- /package/lib/{components/molecules/LoginButton → sessions/components/buttons}/LoginButton.d.ts +0 -0
- /package/lib/{components/organisms/LogoImage → sessions/components/display}/LogoImage.d.ts +0 -0
- /package/lib/{components/organisms/LogoImage → sessions/components/display}/LogoImage.js +0 -0
- /package/lib/{components/molecules/ErrorText → sessions/components/error}/ErrorText.d.ts +0 -0
- /package/lib/{components/organisms/UsernameInput → sessions/components/inputs}/UsernameInput.d.ts +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Axelor Business Solutions
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Axelor (<http://axelor.com>).
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License, version 3,
|
|
8
|
+
* as published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
19
|
+
import { ActivityIndicator, StyleSheet, View } from 'react-native';
|
|
20
|
+
import { useDispatch } from 'react-redux';
|
|
21
|
+
import DeviceInfo from 'react-native-device-info';
|
|
22
|
+
import { WarningCard, checkNullString, useThemeColor, } from '@axelor/aos-mobile-ui';
|
|
23
|
+
import { DefaultCheckbox, SessionNameInput, UrlInput, UsernameInput, PasswordInput, } from '../inputs';
|
|
24
|
+
import { useScanActivator, useScannerDeviceActivator, } from '../../../hooks/use-scan-activator';
|
|
25
|
+
import { useScannedValueByKey, useScannerSelector, } from '../../../features/scannerSlice';
|
|
26
|
+
import { useCameraScannerValueByKey } from '../../../features/cameraScannerSlice';
|
|
27
|
+
import { isUrlValid } from '../../../features/authSlice';
|
|
28
|
+
import { LoginButton, UpdateButton } from '../buttons';
|
|
29
|
+
import { useTranslator } from '../../../i18n';
|
|
30
|
+
const getScanKey = mode => `urlUsername_${mode}_inputs`;
|
|
31
|
+
const MODE = {
|
|
32
|
+
creation: 'creation',
|
|
33
|
+
edition: 'edition',
|
|
34
|
+
connection: 'connection',
|
|
35
|
+
unique: 'unique',
|
|
36
|
+
};
|
|
37
|
+
const FIELDS = {
|
|
38
|
+
name: 'name',
|
|
39
|
+
url: 'url',
|
|
40
|
+
username: 'username',
|
|
41
|
+
password: 'password',
|
|
42
|
+
isDefault: 'isDefault',
|
|
43
|
+
};
|
|
44
|
+
const SessionInputs = ({ style, sessionList, session, showUrlInput, loading, mode, showPopup, onValidation, hidden, }) => {
|
|
45
|
+
const Colors = useThemeColor();
|
|
46
|
+
const I18n = useTranslator();
|
|
47
|
+
const dispatch = useDispatch();
|
|
48
|
+
const _scanKey = useMemo(() => getScanKey(mode), [mode]);
|
|
49
|
+
const { enable: onScanPress } = useScanActivator(_scanKey);
|
|
50
|
+
const { enable: enableScanner } = useScannerDeviceActivator(_scanKey);
|
|
51
|
+
const { isEnabled, scanKey } = useScannerSelector();
|
|
52
|
+
const scannedValue = useScannedValueByKey(_scanKey);
|
|
53
|
+
const scanData = useCameraScannerValueByKey(_scanKey);
|
|
54
|
+
const [showRequiredFields, setShowRequiredFields] = useState(false);
|
|
55
|
+
const [form, setForm] = useState({
|
|
56
|
+
name: session?.name,
|
|
57
|
+
url: session?.url,
|
|
58
|
+
username: session?.username,
|
|
59
|
+
password: session?.password,
|
|
60
|
+
isDefault: session?.isDefault,
|
|
61
|
+
});
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (session != null &&
|
|
64
|
+
!loading &&
|
|
65
|
+
mode !== MODE.creation &&
|
|
66
|
+
mode !== MODE.unique) {
|
|
67
|
+
setForm({ ...session });
|
|
68
|
+
}
|
|
69
|
+
}, [loading, mode, session]);
|
|
70
|
+
const handleFieldChange = useCallback((value, fieldName) => {
|
|
71
|
+
setForm(_current => {
|
|
72
|
+
const old = _current == null ? {} : { ..._current };
|
|
73
|
+
if (mode === MODE.unique) {
|
|
74
|
+
return { ...old, [fieldName]: value };
|
|
75
|
+
}
|
|
76
|
+
if (fieldName !== FIELDS.password && mode !== MODE.connection) {
|
|
77
|
+
return { ...old, [fieldName]: value };
|
|
78
|
+
}
|
|
79
|
+
if (fieldName === FIELDS.password && mode !== MODE.edition) {
|
|
80
|
+
return { ...old, [fieldName]: value };
|
|
81
|
+
}
|
|
82
|
+
return _current;
|
|
83
|
+
});
|
|
84
|
+
}, [mode]);
|
|
85
|
+
const parseQrCode = useCallback(scanValue => {
|
|
86
|
+
if (scanValue.includes('username') === true) {
|
|
87
|
+
const parseScannnedData = JSON.parse(scanValue);
|
|
88
|
+
handleFieldChange(parseScannnedData.url, FIELDS.url);
|
|
89
|
+
handleFieldChange(parseScannnedData.username, FIELDS.username);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
handleFieldChange(scanValue, FIELDS.url);
|
|
93
|
+
}
|
|
94
|
+
showPopup(true);
|
|
95
|
+
}, [handleFieldChange, showPopup]);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (scannedValue) {
|
|
98
|
+
parseQrCode(scannedValue);
|
|
99
|
+
}
|
|
100
|
+
else if (scanData?.value != null) {
|
|
101
|
+
parseQrCode(scanData?.value);
|
|
102
|
+
}
|
|
103
|
+
}, [parseQrCode, scanData, scannedValue]);
|
|
104
|
+
const handleScanPress = useCallback(() => {
|
|
105
|
+
DeviceInfo.getManufacturer()
|
|
106
|
+
.then(manufacturer => {
|
|
107
|
+
if (manufacturer !== 'Zebra Technologies') {
|
|
108
|
+
showPopup(false);
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
.then(() => onScanPress());
|
|
112
|
+
}, [onScanPress, showPopup]);
|
|
113
|
+
const handleTestUrl = useCallback(() => {
|
|
114
|
+
dispatch(isUrlValid({ url: form?.url }));
|
|
115
|
+
}, [dispatch, form?.url]);
|
|
116
|
+
const nameSessionAlreadyExist = useMemo(() => {
|
|
117
|
+
if (!Array.isArray(sessionList) || sessionList?.length === 0) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
return sessionList.some(_session => _session.name === form?.name && _session.id !== form?.id);
|
|
121
|
+
}, [form, sessionList]);
|
|
122
|
+
const disabled = useMemo(() => {
|
|
123
|
+
if (loading ||
|
|
124
|
+
checkNullString(form?.name) ||
|
|
125
|
+
checkNullString(form?.url) ||
|
|
126
|
+
checkNullString(form?.username) ||
|
|
127
|
+
nameSessionAlreadyExist) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
else if (mode !== MODE.edition) {
|
|
131
|
+
return checkNullString(form?.password);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
}, [
|
|
137
|
+
loading,
|
|
138
|
+
form?.name,
|
|
139
|
+
form?.url,
|
|
140
|
+
form?.username,
|
|
141
|
+
form?.password,
|
|
142
|
+
mode,
|
|
143
|
+
nameSessionAlreadyExist,
|
|
144
|
+
]);
|
|
145
|
+
if (hidden) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
return (<View style={style}>
|
|
149
|
+
<View>
|
|
150
|
+
{!loading && nameSessionAlreadyExist && (<WarningCard style={styles.warningCard} errorMessage={I18n.t('Base_Connection_SessionNameAlreadyExist')}/>)}
|
|
151
|
+
</View>
|
|
152
|
+
<SessionNameInput value={form?.name} onChange={_value => handleFieldChange(_value, FIELDS.name)} style={styles.input} showRequiredFields={showRequiredFields} hidden={mode === MODE.connection || mode === MODE.unique}/>
|
|
153
|
+
<UrlInput value={form?.url} onChange={_value => handleFieldChange(_value, FIELDS.url)} readOnly={mode === MODE.connection} onScanPress={handleScanPress} onSelection={enableScanner} onEndFocus={handleTestUrl} scanIconColor={isEnabled && scanKey === _scanKey
|
|
154
|
+
? Colors.primaryColor.background
|
|
155
|
+
: Colors.secondaryColor_dark.background} style={styles.input} showRequiredFields={showRequiredFields} hidden={!showUrlInput}/>
|
|
156
|
+
<UsernameInput value={form?.username} onChange={_value => handleFieldChange(_value, FIELDS.username)} readOnly={mode === MODE.connection} showScanIcon={!showUrlInput} onScanPress={handleScanPress} onSelection={enableScanner} scanIconColor={isEnabled && scanKey === getScanKey(mode)
|
|
157
|
+
? Colors.primaryColor.background
|
|
158
|
+
: Colors.secondaryColor_dark.background} style={styles.input} showRequiredFields={showRequiredFields}/>
|
|
159
|
+
<PasswordInput value={form?.password} onChange={_value => handleFieldChange(_value, FIELDS.password)} readOnly={loading} style={styles.input} showRequiredFields={showRequiredFields} hidden={mode === MODE.edition}/>
|
|
160
|
+
<DefaultCheckbox value={form?.isDefault} onChange={_value => handleFieldChange(_value, FIELDS.isDefault)} hidden={mode === MODE.connection || mode === MODE.unique}/>
|
|
161
|
+
{loading ? (<ActivityIndicator size="large"/>) : ((mode === MODE.edition ? UpdateButton : LoginButton)({
|
|
162
|
+
onPress: () => onValidation(form),
|
|
163
|
+
onDisabledPress: () => setShowRequiredFields(true),
|
|
164
|
+
disabled,
|
|
165
|
+
}))}
|
|
166
|
+
</View>);
|
|
167
|
+
};
|
|
168
|
+
const styles = StyleSheet.create({
|
|
169
|
+
input: {
|
|
170
|
+
width: '100%',
|
|
171
|
+
},
|
|
172
|
+
warningCard: {
|
|
173
|
+
width: '90%',
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
export default SessionInputs;
|
|
177
|
+
//# sourceMappingURL=SessionInputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionInputs.js","sourceRoot":"","sources":["../../../../src/sessions/components/inputs/SessionInputs.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvE,OAAO,EAAC,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAClD,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,aAAa,GACd,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAC,0BAA0B,EAAC,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,eAAe,CAAC;AAE5C,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,CAAC,eAAe,IAAI,SAAS,CAAC;AAExD,MAAM,IAAI,GAAG;IACX,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;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CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;YACnD,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC;YACjC,eAAe,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,IAAI,CAAC;YAClD,QAAQ;SACT,CAAC,CACH,CACH;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,KAAK,EAAE;QACL,KAAK,EAAE,MAAM;KACd;IACD,WAAW,EAAE;QACX,KAAK,EAAE,KAAK;KACb;CACF,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export default SessionNameInput;
|
|
2
|
-
declare function SessionNameInput({ style, value, onChange, readOnly, showRequiredFields, }: {
|
|
2
|
+
declare function SessionNameInput({ style, value, onChange, readOnly, showRequiredFields, hidden, }: {
|
|
3
3
|
style: any;
|
|
4
4
|
value: any;
|
|
5
5
|
onChange: any;
|
|
6
6
|
readOnly: any;
|
|
7
7
|
showRequiredFields?: boolean;
|
|
8
|
+
hidden?: boolean;
|
|
8
9
|
}): JSX.Element;
|
package/lib/{components/organisms/SessionNameInput → sessions/components/inputs}/SessionNameInput.js
RENAMED
|
@@ -20,11 +20,14 @@ import { StyleSheet } from 'react-native';
|
|
|
20
20
|
import { getCommonStyles, Icon, IconInput, useThemeColor, } from '@axelor/aos-mobile-ui';
|
|
21
21
|
import useTranslator from '../../../i18n/hooks/use-translator';
|
|
22
22
|
import { checkNullString } from '../../../utils';
|
|
23
|
-
const SessionNameInput = ({ style, value, onChange, readOnly, showRequiredFields = false, }) => {
|
|
23
|
+
const SessionNameInput = ({ style, value, onChange, readOnly, showRequiredFields = false, hidden = false, }) => {
|
|
24
24
|
const I18n = useTranslator();
|
|
25
25
|
const Colors = useThemeColor();
|
|
26
26
|
const commonStyles = useMemo(() => getCommonStyles(Colors, checkNullString(value)), [Colors, value]);
|
|
27
|
-
|
|
27
|
+
if (hidden) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return (<IconInput style={[style, showRequiredFields ? commonStyles.inputFocused : null]} value={value} onChange={onChange} readOnly={readOnly} placeholder={I18n.t('Base_Connection_SessionName')} leftIconsList={[<Icon name="tag" size={17} style={styles.icon}/>]}/>);
|
|
28
31
|
};
|
|
29
32
|
const styles = StyleSheet.create({
|
|
30
33
|
icon: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionNameInput.js","sourceRoot":"","sources":["../../../../src/sessions/components/inputs/SessionNameInput.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,eAAe,EACf,IAAI,EACJ,SAAS,EACT,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,aAAa,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAE/C,MAAM,gBAAgB,GAAG,CAAC,EACxB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,kBAAkB,GAAG,KAAK,EAC1B,MAAM,GAAG,KAAK,GACf,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAE/B,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,EACrD,CAAC,MAAM,EAAE,KAAK,CAAC,CAChB,CAAC;IAEF,IAAI,MAAM,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,CAAC,SAAS,CACR,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CACtE,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,QAAQ,CAAC,CAAC,QAAQ,CAAC,CACnB,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CACnD,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAAG,CAAC,CAAC,EACnE,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,IAAI,EAAE;QACJ,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,CAAC;KACV;CACF,CAAC,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default UrlInput;
|
|
2
|
-
declare function UrlInput({ style, value, onChange, readOnly, onScanPress, onSelection, onEndFocus, scanIconColor, showRequiredFields, }: {
|
|
2
|
+
declare function UrlInput({ style, value, onChange, readOnly, onScanPress, onSelection, onEndFocus, scanIconColor, showRequiredFields, hidden, }: {
|
|
3
3
|
style: any;
|
|
4
4
|
value: any;
|
|
5
5
|
onChange: any;
|
|
@@ -9,4 +9,5 @@ declare function UrlInput({ style, value, onChange, readOnly, onScanPress, onSel
|
|
|
9
9
|
onEndFocus?: () => void;
|
|
10
10
|
scanIconColor: any;
|
|
11
11
|
showRequiredFields?: boolean;
|
|
12
|
+
hidden?: boolean;
|
|
12
13
|
}): JSX.Element;
|
|
@@ -17,14 +17,20 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import React, { useMemo } from 'react';
|
|
19
19
|
import { StyleSheet } from 'react-native';
|
|
20
|
-
import { getCommonStyles, Icon, IconInput, useThemeColor, } from '@axelor/aos-mobile-ui';
|
|
20
|
+
import { getCommonStyles, Icon, IconInput, LabelText, useThemeColor, } from '@axelor/aos-mobile-ui';
|
|
21
21
|
import useTranslator from '../../../i18n/hooks/use-translator';
|
|
22
22
|
import { checkNullString } from '../../../utils';
|
|
23
|
-
const UrlInput = ({ style, value, onChange, readOnly, onScanPress, onSelection = () => { }, onEndFocus = () => { }, scanIconColor, showRequiredFields = false, }) => {
|
|
23
|
+
const UrlInput = ({ style, value, onChange, readOnly, onScanPress, onSelection = () => { }, onEndFocus = () => { }, scanIconColor, showRequiredFields = false, hidden = false, }) => {
|
|
24
24
|
const Colors = useThemeColor();
|
|
25
25
|
const I18n = useTranslator();
|
|
26
26
|
const commonStyles = useMemo(() => getCommonStyles(Colors, checkNullString(value)), [Colors, value]);
|
|
27
|
-
|
|
27
|
+
if (hidden) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (readOnly) {
|
|
31
|
+
return (<LabelText iconName="link" title={value} style={styles.labText} size={20}/>);
|
|
32
|
+
}
|
|
33
|
+
return (<IconInput style={[style, showRequiredFields ? commonStyles.inputFocused : null]} value={value} onChange={onChange} readOnly={readOnly} required={true} onSelection={onSelection} onEndFocus={onEndFocus} placeholder={I18n.t('Base_Connection_Url')} leftIconsList={[<Icon name="link" size={17} style={styles.icon}/>]} rightIconsList={[
|
|
28
34
|
<Icon name="qrcode" size={20} color={scanIconColor == null
|
|
29
35
|
? Colors.secondaryColor_dark.background
|
|
30
36
|
: scanIconColor} touchable={true} style={styles.icon} onPress={onScanPress} FontAwesome5={false}/>,
|
|
@@ -35,6 +41,11 @@ const styles = StyleSheet.create({
|
|
|
35
41
|
width: '7%',
|
|
36
42
|
margin: 3,
|
|
37
43
|
},
|
|
44
|
+
labText: {
|
|
45
|
+
width: '95%',
|
|
46
|
+
marginVertical: 10,
|
|
47
|
+
marginLeft: 20,
|
|
48
|
+
},
|
|
38
49
|
});
|
|
39
50
|
export default UrlInput;
|
|
40
51
|
//# sourceMappingURL=UrlInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UrlInput.js","sourceRoot":"","sources":["../../../../src/sessions/components/inputs/UrlInput.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,eAAe,EACf,IAAI,EACJ,SAAS,EACT,SAAS,EACT,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,aAAa,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAE/C,MAAM,QAAQ,GAAG,CAAC,EAChB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,WAAW,EACX,WAAW,GAAG,GAAG,EAAE,GAAE,CAAC,EACtB,UAAU,GAAG,GAAG,EAAE,GAAE,CAAC,EACrB,aAAa,EACb,kBAAkB,GAAG,KAAK,EAC1B,MAAM,GAAG,KAAK,GACf,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAE7B,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,EACrD,CAAC,MAAM,EAAE,KAAK,CAAC,CAChB,CAAC;IAEF,IAAI,MAAM,EAAE;QACV,OAAO,IAAI,CAAC;KACb;IAED,IAAI,QAAQ,EAAE;QACZ,OAAO,CACL,CAAC,SAAS,CACR,QAAQ,CAAC,MAAM,CACf,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACtB,IAAI,CAAC,CAAC,EAAE,CA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EAAE,EAAE;QAClB,UAAU,EAAE,EAAE;KACf;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC"}
|
package/lib/{components/organisms/UsernameInput → sessions/components/inputs}/UsernameInput.js
RENAMED
|
@@ -17,14 +17,17 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import React, { useMemo } from 'react';
|
|
19
19
|
import { StyleSheet } from 'react-native';
|
|
20
|
-
import { getCommonStyles, Icon, IconInput, useThemeColor, } from '@axelor/aos-mobile-ui';
|
|
20
|
+
import { getCommonStyles, Icon, IconInput, LabelText, useThemeColor, } from '@axelor/aos-mobile-ui';
|
|
21
21
|
import useTranslator from '../../../i18n/hooks/use-translator';
|
|
22
22
|
import { checkNullString } from '../../../utils';
|
|
23
23
|
const UsernameInput = ({ value, onChange, readOnly, showScanIcon = true, onScanPress, onSelection = () => { }, scanIconColor, style, showRequiredFields = false, }) => {
|
|
24
24
|
const Colors = useThemeColor();
|
|
25
25
|
const I18n = useTranslator();
|
|
26
26
|
const commonStyles = useMemo(() => getCommonStyles(Colors, checkNullString(value)), [Colors, value]);
|
|
27
|
-
|
|
27
|
+
if (readOnly) {
|
|
28
|
+
return (<LabelText iconName="user" title={value} style={styles.labText} size={20}/>);
|
|
29
|
+
}
|
|
30
|
+
return (<IconInput style={[style, showRequiredFields ? commonStyles.inputFocused : null]} value={value} onChange={onChange} readOnly={readOnly} required={true} onSelection={showScanIcon ? onSelection : () => { }} placeholder={I18n.t('Base_Connection_Username')} leftIconsList={[<Icon name="user" size={17} style={styles.icon}/>]} rightIconsList={showScanIcon
|
|
28
31
|
? [
|
|
29
32
|
<Icon name="qrcode" size={20} color={scanIconColor == null
|
|
30
33
|
? Colors.secondaryColor_dark.background
|
|
@@ -37,6 +40,11 @@ const styles = StyleSheet.create({
|
|
|
37
40
|
width: '7%',
|
|
38
41
|
margin: 3,
|
|
39
42
|
},
|
|
43
|
+
labText: {
|
|
44
|
+
width: '95%',
|
|
45
|
+
marginVertical: 10,
|
|
46
|
+
marginLeft: 20,
|
|
47
|
+
},
|
|
40
48
|
});
|
|
41
49
|
export default UsernameInput;
|
|
42
50
|
//# sourceMappingURL=UsernameInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UsernameInput.js","sourceRoot":"","sources":["../../../../src/sessions/components/inputs/UsernameInput.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,eAAe,EACf,IAAI,EACJ,SAAS,EACT,SAAS,EACT,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,aAAa,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAE/C,MAAM,aAAa,GAAG,CAAC,EACrB,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,YAAY,GAAG,IAAI,EACnB,WAAW,EACX,WAAW,GAAG,GAAG,EAAE,GAAE,CAAC,EACtB,aAAa,EACb,KAAK,EACL,kBAAkB,GAAG,KAAK,GAC3B,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAE7B,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,EACrD,CAAC,MAAM,EAAE,KAAK,CAAC,CAChB,CAAC;IAEF,IAAI,QAAQ,EAAE;QACZ,OAAO,CACL,CAAC,SAAS,CACR,QAAQ,CAAC,MAAM,CACf,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CACtB,IAAI,CAAC,CAAC,EAAE,CAAC,EACT,CACH,CAAC;KACH;IAED,OAAO,C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E;QACP,KAAK,EAAE,KAAK;QACZ,cAAc,EAAE,EAAE;QAClB,UAAU,EAAE,EAAE;KACf;CACF,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as DefaultCheckbox } from './DefaultCheckbox';
|
|
2
|
+
export { default as PasswordInput } from './PasswordInput';
|
|
3
|
+
export { default as SessionInputs } from './SessionInputs';
|
|
4
|
+
export { default as SessionNameInput } from './SessionNameInput';
|
|
5
|
+
export { default as UrlInput } from './UrlInput';
|
|
6
|
+
export { default as UsernameInput } from './UsernameInput';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Axelor Business Solutions
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Axelor (<http://axelor.com>).
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License, version 3,
|
|
8
|
+
* as published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
export { default as DefaultCheckbox } from './DefaultCheckbox';
|
|
19
|
+
export { default as PasswordInput } from './PasswordInput';
|
|
20
|
+
export { default as SessionInputs } from './SessionInputs';
|
|
21
|
+
export { default as SessionNameInput } from './SessionNameInput';
|
|
22
|
+
export { default as UrlInput } from './UrlInput';
|
|
23
|
+
export { default as UsernameInput } from './UsernameInput';
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/sessions/components/inputs/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAC,OAAO,IAAI,aAAa,EAAC,MAAM,iBAAiB,CAAC"}
|
package/lib/sessions/hook.d.ts
CHANGED
package/lib/sessions/hook.js
CHANGED
|
@@ -19,10 +19,10 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
|
19
19
|
import { sessionStorage } from './SessionStorage';
|
|
20
20
|
export const useSessions = () => {
|
|
21
21
|
const [sessionList, setSessionList] = useState(sessionStorage.getSessionList());
|
|
22
|
-
const [
|
|
23
|
-
const refreshData = useCallback(({ sessionList: sessions,
|
|
24
|
-
setSessionActive(activeSession);
|
|
22
|
+
const [sessionDefault, setSessionDefault] = useState(sessionStorage.getDefaultSession());
|
|
23
|
+
const refreshData = useCallback(({ sessionList: sessions, defaultSession }) => {
|
|
25
24
|
setSessionList(sessions);
|
|
25
|
+
setSessionDefault(defaultSession);
|
|
26
26
|
}, []);
|
|
27
27
|
useEffect(() => {
|
|
28
28
|
sessionStorage.register(refreshData);
|
|
@@ -30,8 +30,8 @@ export const useSessions = () => {
|
|
|
30
30
|
return useMemo(() => {
|
|
31
31
|
return {
|
|
32
32
|
sessionList: sessionList,
|
|
33
|
-
|
|
33
|
+
sessionDefault: sessionDefault,
|
|
34
34
|
};
|
|
35
|
-
}, [
|
|
35
|
+
}, [sessionList, sessionDefault]);
|
|
36
36
|
};
|
|
37
37
|
//# sourceMappingURL=hook.js.map
|
package/lib/sessions/hook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/sessions/hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAGhD,MAAM,CAAC,MAAM,WAAW,GAAG,GAGzB,EAAE;IACF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAC5C,cAAc,CAAC,cAAc,EAAE,CAChC,CAAC;IAEF,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"hook.js","sourceRoot":"","sources":["../../src/sessions/hook.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAGhD,MAAM,CAAC,MAAM,WAAW,GAAG,GAGzB,EAAE;IACF,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAC5C,cAAc,CAAC,cAAc,EAAE,CAChC,CAAC;IAEF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAClD,cAAc,CAAC,iBAAiB,EAAE,CACnC,CAAC;IAEF,MAAM,WAAW,GAAG,WAAW,CAAC,CAAC,EAAC,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAC,EAAE,EAAE;QAC1E,cAAc,CAAC,QAAQ,CAAC,CAAC;QACzB,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACpC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,OAAO;YACL,WAAW,EAAE,WAAW;YACxB,cAAc,EAAE,cAAc;SAC/B,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;AACpC,CAAC,CAAC"}
|
package/lib/sessions/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { useSessions } from './hook';
|
|
2
2
|
export { Session, URL_STORAGE_KEY } from './type';
|
|
3
3
|
export { sessionStorage } from './SessionStorage';
|
|
4
|
-
export {
|
|
4
|
+
export { getStorageUrl, saveUrlInStorage } from './utils';
|
|
5
|
+
export * from './components';
|
package/lib/sessions/index.js
CHANGED
|
@@ -18,5 +18,6 @@
|
|
|
18
18
|
export { useSessions } from './hook';
|
|
19
19
|
export { URL_STORAGE_KEY } from './type';
|
|
20
20
|
export { sessionStorage } from './SessionStorage';
|
|
21
|
-
export {
|
|
21
|
+
export { getStorageUrl, saveUrlInStorage } from './utils';
|
|
22
|
+
export * from './components';
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sessions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAU,eAAe,EAAC,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sessions/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAU,eAAe,EAAC,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAC,aAAa,EAAE,gBAAgB,EAAC,MAAM,SAAS,CAAC;AACxD,cAAc,cAAc,CAAC"}
|
package/lib/sessions/type.d.ts
CHANGED
package/lib/sessions/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/sessions/type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/sessions/type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAUH,MAAM,CAAC,MAAM,eAAe,GAAG,mBAAmB,CAAC"}
|
package/lib/sessions/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Session } from './type';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const manageDefaultSession: (sessionList: Session[], session: Session) => Session[];
|
|
3
3
|
export declare const getStorageUrl: () => string;
|
|
4
4
|
export declare const saveUrlInStorage: (url: string) => void;
|
|
5
|
+
export declare const migrateOldSessionToNewSystem: (data: any[]) => Session[];
|
package/lib/sessions/utils.js
CHANGED
|
@@ -17,13 +17,16 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { storage } from '../storage/Storage';
|
|
19
19
|
import { URL_STORAGE_KEY } from './type';
|
|
20
|
-
export const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export const manageDefaultSession = (sessionList, session) => {
|
|
21
|
+
if (session.isDefault) {
|
|
22
|
+
return sessionList.map(_session => {
|
|
23
|
+
if (_session.id === session.id) {
|
|
24
|
+
return { ..._session, isDefault: true };
|
|
25
|
+
}
|
|
26
|
+
return { ..._session, isDefault: false };
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return sessionList;
|
|
27
30
|
};
|
|
28
31
|
export const getStorageUrl = () => {
|
|
29
32
|
return storage.getItem(URL_STORAGE_KEY);
|
|
@@ -31,4 +34,20 @@ export const getStorageUrl = () => {
|
|
|
31
34
|
export const saveUrlInStorage = (url) => {
|
|
32
35
|
storage.setItem(URL_STORAGE_KEY, url);
|
|
33
36
|
};
|
|
37
|
+
export const migrateOldSessionToNewSystem = (data) => {
|
|
38
|
+
return data.map((_item, index) => {
|
|
39
|
+
if (_item?.name == null) {
|
|
40
|
+
return {
|
|
41
|
+
id: `session-${Date.now()}-${index}`,
|
|
42
|
+
name: _item.id,
|
|
43
|
+
url: _item.url,
|
|
44
|
+
username: _item.username,
|
|
45
|
+
isDefault: _item.isActive,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return _item;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
34
53
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/sessions/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAC,eAAe,EAAC,MAAM,QAAQ,CAAC;AAGvC,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/sessions/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAC,eAAe,EAAC,MAAM,QAAQ,CAAC;AAGvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,WAAsB,EACtB,OAAgB,EACL,EAAE;IACb,IAAI,OAAO,CAAC,SAAS,EAAE;QACrB,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAChC,IAAI,QAAQ,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,EAAE;gBAC9B,OAAO,EAAC,GAAG,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;aACvC;YAED,OAAO,EAAC,GAAG,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;QACzC,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAW,EAAE;IACxC,OAAO,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAC1C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAQ,EAAE;IACpD,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,IAAW,EAAa,EAAE;IACrE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QAC/B,IAAI,KAAK,EAAE,IAAI,IAAI,IAAI,EAAE;YACvB,OAAO;gBACL,EAAE,EAAE,WAAW,IAAI,CAAC,GAAG,EAAE,IAAI,KAAK,EAAE;gBACpC,IAAI,EAAE,KAAK,CAAC,EAAE;gBACd,GAAG,EAAE,KAAK,CAAC,GAAG;gBACd,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,SAAS,EAAE,KAAK,CAAC,QAAQ;aAC1B,CAAC;SACH;aAAM;YACL,OAAO,KAAgB,CAAC;SACzB;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ContactData } from './contact.helper';
|
|
2
|
+
declare class ContactProvider {
|
|
3
|
+
constructor();
|
|
4
|
+
private _getContactsPermission;
|
|
5
|
+
private _showToast;
|
|
6
|
+
saveContact: (contactData: ContactData) => Promise<boolean>;
|
|
7
|
+
}
|
|
8
|
+
export declare const contactProvider: ContactProvider;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Axelor Business Solutions
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Axelor (<http://axelor.com>).
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License, version 3,
|
|
8
|
+
* as published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { PermissionsAndroid, Platform } from 'react-native';
|
|
19
|
+
import Toast from 'react-native-toast-message';
|
|
20
|
+
import * as Contacts from 'react-native-contacts';
|
|
21
|
+
import { PermissionResult, parseContactData, } from './contact.helper';
|
|
22
|
+
class ContactProvider {
|
|
23
|
+
constructor() { }
|
|
24
|
+
_getContactsPermission = async () => {
|
|
25
|
+
try {
|
|
26
|
+
switch (Platform.OS) {
|
|
27
|
+
case 'ios':
|
|
28
|
+
const _permIOS = await Contacts.requestPermission();
|
|
29
|
+
switch (_permIOS) {
|
|
30
|
+
case 'authorized':
|
|
31
|
+
return PermissionResult.GRANTED;
|
|
32
|
+
default:
|
|
33
|
+
return PermissionResult.DENIED;
|
|
34
|
+
}
|
|
35
|
+
case 'android':
|
|
36
|
+
const _permAndroid = await PermissionsAndroid.requestMultiple([
|
|
37
|
+
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
|
|
38
|
+
PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS,
|
|
39
|
+
]);
|
|
40
|
+
if (Object.values(_permAndroid).every(_perm => _perm === PermissionsAndroid.RESULTS.GRANTED)) {
|
|
41
|
+
return PermissionResult.GRANTED;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
return PermissionResult.DENIED;
|
|
45
|
+
}
|
|
46
|
+
default:
|
|
47
|
+
throw new Error('Unsupported device.');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.error('Error requesting contacts permission:', error);
|
|
52
|
+
return PermissionResult.DENIED;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
_showToast = (type, message) => {
|
|
56
|
+
Toast.show({
|
|
57
|
+
type,
|
|
58
|
+
position: 'bottom',
|
|
59
|
+
bottomOffset: 20,
|
|
60
|
+
text1: type === 'success' ? 'Success' : 'Error',
|
|
61
|
+
text2: message,
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
saveContact = async (contactData) => {
|
|
65
|
+
try {
|
|
66
|
+
if (!contactData.firstName) {
|
|
67
|
+
throw new Error('Required contact data is missing.');
|
|
68
|
+
}
|
|
69
|
+
const permissionResult = await this._getContactsPermission();
|
|
70
|
+
switch (permissionResult) {
|
|
71
|
+
case PermissionResult.GRANTED:
|
|
72
|
+
const contactAdded = await Contacts.openContactForm(parseContactData(contactData)).then(_contact => {
|
|
73
|
+
if (_contact != null) {
|
|
74
|
+
this._showToast('success', `Contact ${_contact.givenName} added successfully.`);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this._showToast('error', 'Contact addition was canceled.');
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
return contactAdded;
|
|
83
|
+
case PermissionResult.DENIED:
|
|
84
|
+
this._showToast('error', 'Contacts permission denied.');
|
|
85
|
+
return false;
|
|
86
|
+
default:
|
|
87
|
+
this._showToast('error', 'Unknown permission result.');
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
this._showToast('error', `Error adding contact: ${error}`);
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
export const contactProvider = new ContactProvider();
|
|
98
|
+
//# sourceMappingURL=ContactProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContactProvider.js","sourceRoot":"","sources":["../../src/tools/ContactProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,kBAAkB,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,MAAM,4BAA4B,CAAC;AAC/C,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAEL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,eAAe;IACnB,gBAAe,CAAC;IAER,sBAAsB,GAAG,KAAK,IAAI,EAAE;QAC1C,IAAI;YACF,QAAQ,QAAQ,CAAC,EAAE,EAAE;gBACnB,KAAK,KAAK;oBACR,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,iBAAiB,EAAE,CAAC;oBACpD,QAAQ,QAAQ,EAAE;wBAChB,KAAK,YAAY;4BACf,OAAO,gBAAgB,CAAC,OAAO,CAAC;wBAClC;4BACE,OAAO,gBAAgB,CAAC,MAAM,CAAC;qBAClC;gBACH,KAAK,SAAS;oBACZ,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC,eAAe,CAAC;wBAC5D,kBAAkB,CAAC,WAAW,CAAC,aAAa;wBAC5C,kBAAkB,CAAC,WAAW,CAAC,cAAc;qBAC9C,CAAC,CAAC;oBAEH,IACE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,KAAK,CAC/B,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,k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