@evergis/common 0.0.112 → 0.0.113
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/LICENSE +0 -21
- package/README.md +0 -29
- package/dist/ApiProvider.d.ts +0 -7
- package/dist/common.cjs.development.js +0 -310
- package/dist/common.cjs.development.js.map +0 -1
- package/dist/common.cjs.production.min.js +0 -2
- package/dist/common.cjs.production.min.js.map +0 -1
- package/dist/common.esm.js +0 -298
- package/dist/common.esm.js.map +0 -1
- package/dist/components/Politics/PolicyItem.d.ts +0 -3
- package/dist/components/Politics/hooks/usePolitics.d.ts +0 -8
- package/dist/components/Politics/index.d.ts +0 -3
- package/dist/components/Politics/styled.d.ts +0 -11
- package/dist/components/Politics/types.d.ts +0 -24
- package/dist/components/index.d.ts +0 -1
- package/dist/i18n/index.d.ts +0 -24
- package/dist/index.d.ts +0 -5
- package/dist/resources/index.d.ts +0 -1
- package/dist/resources/limits.d.ts +0 -2
- package/dist/utils/formatNumber.d.ts +0 -1
- package/dist/utils/index.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.113",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@babel/core": "^7.17.5",
|
|
48
48
|
"@babel/plugin-transform-classes": "^7.16.7",
|
|
49
49
|
"@babel/preset-env": "^7.16.11",
|
|
50
|
-
"@evergis/api": "^3.0.
|
|
50
|
+
"@evergis/api": "^3.0.215",
|
|
51
51
|
"@evergis/react-fetching": "0.1.8",
|
|
52
52
|
"@evergis/sgis": "0.5.0-alpha.68",
|
|
53
53
|
"@evergis/ui": "2.0.116-alpha.25",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"styled-components": "5.3.5",
|
|
65
65
|
"ts-loader": "^8.0.5"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "f71807a4cab41dbd7b5f6d5a6047a69029ec540e"
|
|
68
68
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Kirill Protasov
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# @evergis/common
|
|
2
|
-
|
|
3
|
-
## Commands
|
|
4
|
-
|
|
5
|
-
```
|
|
6
|
-
npm start # or yarn start
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
|
|
10
|
-
|
|
11
|
-
Then run either example playground or storybook:
|
|
12
|
-
|
|
13
|
-
### Storybook
|
|
14
|
-
|
|
15
|
-
Run inside another terminal:
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
yarn storybook
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
This loads the stories from `./stories`.
|
|
22
|
-
|
|
23
|
-
> NOTE: Stories should reference the components as if using the library. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.
|
|
24
|
-
|
|
25
|
-
### Tests
|
|
26
|
-
|
|
27
|
-
Jest tests are set up to run with `npm test` or `yarn test`. This runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
|
|
28
|
-
|
|
29
|
-
> TODO: MOVE style to separate @evergis/style
|
package/dist/ApiProvider.d.ts
DELETED
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
|
6
|
-
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var React__default = _interopDefault(React);
|
|
9
|
-
var api = require('@evergis/api');
|
|
10
|
-
var react = require('@evergis/react');
|
|
11
|
-
var reactI18next = require('react-i18next');
|
|
12
|
-
var reactFetching = require('@evergis/react-fetching');
|
|
13
|
-
var ui = require('@evergis/ui');
|
|
14
|
-
var styled = _interopDefault(require('styled-components'));
|
|
15
|
-
|
|
16
|
-
const ApiContext = /*#__PURE__*/React.createContext({});
|
|
17
|
-
const ApiProvider = (_ref) => {
|
|
18
|
-
let {
|
|
19
|
-
api,
|
|
20
|
-
children
|
|
21
|
-
} = _ref;
|
|
22
|
-
return React__default.createElement(ApiContext.Provider, {
|
|
23
|
-
value: {
|
|
24
|
-
api
|
|
25
|
-
}
|
|
26
|
-
}, children);
|
|
27
|
-
};
|
|
28
|
-
const useApi = () => {
|
|
29
|
-
return React.useContext(ApiContext);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
let resource;
|
|
33
|
-
const checkLimits = evergisApi => {
|
|
34
|
-
if (!resource) {
|
|
35
|
-
resource = reactFetching.createResource(params => async api => ({
|
|
36
|
-
data: await api.resourceCatalog.checkLimits(params)
|
|
37
|
-
}), {
|
|
38
|
-
injected: evergisApi
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return resource;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const usePolitics = (_ref) => {
|
|
46
|
-
let {
|
|
47
|
-
username,
|
|
48
|
-
onError,
|
|
49
|
-
initialLimits
|
|
50
|
-
} = _ref;
|
|
51
|
-
const {
|
|
52
|
-
t
|
|
53
|
-
} = reactI18next.useTranslation('politics');
|
|
54
|
-
const {
|
|
55
|
-
api: api$1
|
|
56
|
-
} = useApi();
|
|
57
|
-
const {
|
|
58
|
-
data: limits,
|
|
59
|
-
refetch,
|
|
60
|
-
error
|
|
61
|
-
} = checkLimits(api$1).use({
|
|
62
|
-
input: {
|
|
63
|
-
userName: username
|
|
64
|
-
},
|
|
65
|
-
waitInput: true
|
|
66
|
-
});
|
|
67
|
-
React.useEffect(() => {
|
|
68
|
-
if (error && onError) {
|
|
69
|
-
onError(error);
|
|
70
|
-
}
|
|
71
|
-
}, [error, onError]);
|
|
72
|
-
const politics = React.useMemo(() => {
|
|
73
|
-
const currentLimits = limits || initialLimits;
|
|
74
|
-
return currentLimits ? [{
|
|
75
|
-
name: t('maps'),
|
|
76
|
-
used: currentLimits.currentProjectCount,
|
|
77
|
-
max: currentLimits.maxProjectsCount,
|
|
78
|
-
type: api.PolicyType.CreateProject,
|
|
79
|
-
icon: 'map'
|
|
80
|
-
}, {
|
|
81
|
-
name: t('layers'),
|
|
82
|
-
used: currentLimits.currentServiceCount,
|
|
83
|
-
max: currentLimits.maxServicesCount,
|
|
84
|
-
type: api.PolicyType.CreateLayer,
|
|
85
|
-
icon: 'layers'
|
|
86
|
-
}, {
|
|
87
|
-
name: t('tables'),
|
|
88
|
-
used: currentLimits.currentTableCount,
|
|
89
|
-
max: currentLimits.maxTablesCount,
|
|
90
|
-
type: api.PolicyType.CreateTable,
|
|
91
|
-
icon: 'table'
|
|
92
|
-
}, {
|
|
93
|
-
name: t('maxFeaturesInLayerLimit'),
|
|
94
|
-
max: currentLimits.maxFeaturesInOneTable,
|
|
95
|
-
type: api.PolicyType.MaxFeaturesInOneTable,
|
|
96
|
-
icon: 'points'
|
|
97
|
-
}, {
|
|
98
|
-
name: t('maxFileSize'),
|
|
99
|
-
max: currentLimits.maxUploadContentSize,
|
|
100
|
-
type: api.PolicyType.MaxUploadContentSize,
|
|
101
|
-
icon: 'textfile'
|
|
102
|
-
}, {
|
|
103
|
-
name: t('maxObjectsToExport'),
|
|
104
|
-
max: currentLimits.maxObjectsToExport,
|
|
105
|
-
type: api.PolicyType.MaxObjectsToExport,
|
|
106
|
-
icon: 'points'
|
|
107
|
-
}] : [];
|
|
108
|
-
}, [t, limits, initialLimits]);
|
|
109
|
-
const updatePolicy = React.useCallback(async (value, type) => {
|
|
110
|
-
await api$1.security.setPolicy({
|
|
111
|
-
value,
|
|
112
|
-
type,
|
|
113
|
-
role: "__" + username
|
|
114
|
-
});
|
|
115
|
-
await refetch();
|
|
116
|
-
}, [api$1]);
|
|
117
|
-
return [politics, updatePolicy];
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const numberWithSpaces = function numberWithSpaces(input, maximumFractionDigits) {
|
|
121
|
-
if (maximumFractionDigits === void 0) {
|
|
122
|
-
maximumFractionDigits = 10;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (input === null || input === undefined) {
|
|
126
|
-
return '';
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return parseFloat((typeof input === 'string' ? parseFloat(input) : input).toString()).toLocaleString('ru-RU', {
|
|
130
|
-
maximumFractionDigits
|
|
131
|
-
});
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
function _taggedTemplateLiteralLoose(strings, raw) {
|
|
135
|
-
if (!raw) {
|
|
136
|
-
raw = strings.slice(0);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
strings.raw = raw;
|
|
140
|
-
return strings;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
144
|
-
const PoliticsContainer = /*#__PURE__*/styled(ui.Flex)(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-top: 3rem;\n flex-direction: column;\n"])));
|
|
145
|
-
const PoliticsTitle = /*#__PURE__*/styled(ui.H2)(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0;\n"])));
|
|
146
|
-
const PoliticsItems = /*#__PURE__*/styled(ui.Flex)(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex-wrap: wrap;\n margin-top: 0.5rem;\n margin-bottom: 0.75rem;\n"])));
|
|
147
|
-
const PoliticsItemContainer = /*#__PURE__*/styled(ui.Flex)(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-top: 1rem;\n margin-right: 1rem;\n width: 14.5rem;\n height: 10.5rem;\n border-radius: 2px;\n background-color: #f6f6f6;\n flex-direction: column;\n"])));
|
|
148
|
-
const PoliticsItemContent = /*#__PURE__*/styled(ui.Flex)(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex-direction: column;\n align-items: center;\n padding: 1rem 1rem 0;\n width: 100%;\n box-sizing: border-box;\n"])));
|
|
149
|
-
const PoliticsItemIcon = /*#__PURE__*/styled(ui.Icon)(_templateObject6 || (_templateObject6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n opacity: 0.28;\n"])));
|
|
150
|
-
const PoliticsItemLimit = /*#__PURE__*/styled.span(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 18px;\n font-weight: bold;\n margin-top: 0.75rem;\n"])));
|
|
151
|
-
const PoliticsItemType = /*#__PURE__*/styled.span(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 12px;\n color: ", ";\n text-align: center;\n"])), (_ref) => {
|
|
152
|
-
let {
|
|
153
|
-
theme: {
|
|
154
|
-
palette
|
|
155
|
-
}
|
|
156
|
-
} = _ref;
|
|
157
|
-
return palette.textSecondary;
|
|
158
|
-
});
|
|
159
|
-
const PoliticsRatioContainer = /*#__PURE__*/styled.div(_templateObject9 || (_templateObject9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: auto 0 0;\n height: 0.5rem;\n width: 100%;\n"])));
|
|
160
|
-
const PoliticsRatio = /*#__PURE__*/styled(ui.RatioLine)(_templateObject10 || (_templateObject10 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n margin: 0;\n"])));
|
|
161
|
-
const PoliticsLimit = /*#__PURE__*/styled(ui.Flex)(_templateObject11 || (_templateObject11 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex-direction: column;\n width: 100%;\n margin-top: 0.75rem;\n background: white;\n"])));
|
|
162
|
-
|
|
163
|
-
const WARN_ENTITY_COUNT_THRESHOLD = 75;
|
|
164
|
-
const ERROR_ENTITY_COUNT_THRESHOLD = 90;
|
|
165
|
-
|
|
166
|
-
function getRatioLineVariant(used, max) {
|
|
167
|
-
const ratioUsed = used / max * 100;
|
|
168
|
-
|
|
169
|
-
if (ratioUsed >= ERROR_ENTITY_COUNT_THRESHOLD) {
|
|
170
|
-
return {
|
|
171
|
-
error: true
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (ratioUsed >= WARN_ENTITY_COUNT_THRESHOLD) {
|
|
176
|
-
return {
|
|
177
|
-
secondary: true
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return {
|
|
182
|
-
primary: true
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const PolicyItem = (_ref) => {
|
|
187
|
-
let {
|
|
188
|
-
item,
|
|
189
|
-
updatePolicyItem,
|
|
190
|
-
canUpdate
|
|
191
|
-
} = _ref;
|
|
192
|
-
const {
|
|
193
|
-
t
|
|
194
|
-
} = reactI18next.useTranslation('politics');
|
|
195
|
-
const {
|
|
196
|
-
name,
|
|
197
|
-
used,
|
|
198
|
-
max,
|
|
199
|
-
type,
|
|
200
|
-
disabled,
|
|
201
|
-
icon
|
|
202
|
-
} = item;
|
|
203
|
-
const onMaxLimitChange = React.useCallback(value => {
|
|
204
|
-
updatePolicyItem(value || 0, type);
|
|
205
|
-
}, [updatePolicyItem]);
|
|
206
|
-
const maxValue = // @ts-ignore
|
|
207
|
-
type === api.PolicyType.MaxUploadContentSize ? (max / (1024 * 1024)).toFixed(6) : max;
|
|
208
|
-
const formattedMaxValue = numberWithSpaces(maxValue, 6);
|
|
209
|
-
return React__default.createElement(PoliticsItemContainer, {
|
|
210
|
-
key: name
|
|
211
|
-
}, React__default.createElement(PoliticsItemContent, null, React__default.createElement(PoliticsItemIcon, {
|
|
212
|
-
kind: icon
|
|
213
|
-
}), React__default.createElement(PoliticsItemLimit, null, used !== undefined ? used + " " + t('from') + " " + (max === -1 ? '∞' : formattedMaxValue) : (max === -1 ? '∞' : formattedMaxValue) + " " + ( // @ts-ignore
|
|
214
|
-
type === api.PolicyType.MaxUploadContentSize ? 'mb' : '')), React__default.createElement(PoliticsItemType, null, name), canUpdate && React__default.createElement(PoliticsLimit, null, React__default.createElement(ui.NumberInput, {
|
|
215
|
-
required: true,
|
|
216
|
-
disabled: disabled,
|
|
217
|
-
counter: false,
|
|
218
|
-
width: '100%',
|
|
219
|
-
value: +maxValue,
|
|
220
|
-
onChange: onMaxLimitChange
|
|
221
|
-
}))), React__default.createElement(PoliticsRatioContainer, null, used !== undefined && React__default.createElement(PoliticsRatio, Object.assign({
|
|
222
|
-
ratio: used / max * 100
|
|
223
|
-
}, getRatioLineVariant(used, max)))));
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const Politics = (_ref) => {
|
|
227
|
-
let {
|
|
228
|
-
username,
|
|
229
|
-
canUpdate,
|
|
230
|
-
title,
|
|
231
|
-
className,
|
|
232
|
-
initialLimits,
|
|
233
|
-
onError
|
|
234
|
-
} = _ref;
|
|
235
|
-
const [politics, updatePolicy] = usePolitics({
|
|
236
|
-
username,
|
|
237
|
-
onError,
|
|
238
|
-
initialLimits
|
|
239
|
-
});
|
|
240
|
-
const debounce = react.useDebouncedCallback(500);
|
|
241
|
-
const updatePolicyItem = React.useCallback((value, type) => {
|
|
242
|
-
debounce(async () => {
|
|
243
|
-
const fixedValue = // max file size in mb
|
|
244
|
-
// @ts-ignore
|
|
245
|
-
type === api.PolicyType.MaxUploadContentSize ? value * 1024 * 1024 : value;
|
|
246
|
-
await updatePolicy(fixedValue, type);
|
|
247
|
-
});
|
|
248
|
-
}, [username]);
|
|
249
|
-
return React__default.createElement(PoliticsContainer, {
|
|
250
|
-
className: className
|
|
251
|
-
}, title && React__default.createElement(PoliticsTitle, null, title), React__default.createElement(PoliticsItems, null, politics.map(item => React__default.createElement(PolicyItem, {
|
|
252
|
-
key: item.name,
|
|
253
|
-
canUpdate: canUpdate,
|
|
254
|
-
item: item,
|
|
255
|
-
updatePolicyItem: updatePolicyItem
|
|
256
|
-
}))));
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
var maps = "Maps";
|
|
260
|
-
var layers = "Layers";
|
|
261
|
-
var maxFeaturesInLayerLimit = "Max objects count in layer";
|
|
262
|
-
var maxFileSize = "Max file size";
|
|
263
|
-
var maxObjectsToExport = "Max objects to export";
|
|
264
|
-
var tables = "Tables";
|
|
265
|
-
var from = "from";
|
|
266
|
-
var politics_en = {
|
|
267
|
-
maps: maps,
|
|
268
|
-
layers: layers,
|
|
269
|
-
maxFeaturesInLayerLimit: maxFeaturesInLayerLimit,
|
|
270
|
-
maxFileSize: maxFileSize,
|
|
271
|
-
maxObjectsToExport: maxObjectsToExport,
|
|
272
|
-
tables: tables,
|
|
273
|
-
"in": "in",
|
|
274
|
-
from: from
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
var maps$1 = "Карты";
|
|
278
|
-
var layers$1 = "Слои";
|
|
279
|
-
var maxFeaturesInLayerLimit$1 = "Макс. количество объектов в слое";
|
|
280
|
-
var maxFileSize$1 = "Макс. размер файла";
|
|
281
|
-
var maxObjectsToExport$1 = "Макс. количество объектов для экспорта";
|
|
282
|
-
var tables$1 = "Таблицы";
|
|
283
|
-
var from$1 = "из";
|
|
284
|
-
var politics_ru = {
|
|
285
|
-
maps: maps$1,
|
|
286
|
-
layers: layers$1,
|
|
287
|
-
maxFeaturesInLayerLimit: maxFeaturesInLayerLimit$1,
|
|
288
|
-
maxFileSize: maxFileSize$1,
|
|
289
|
-
maxObjectsToExport: maxObjectsToExport$1,
|
|
290
|
-
tables: tables$1,
|
|
291
|
-
"in": "в",
|
|
292
|
-
from: from$1
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
const resources = {
|
|
296
|
-
en: {
|
|
297
|
-
politics: politics_en
|
|
298
|
-
},
|
|
299
|
-
ru: {
|
|
300
|
-
politics: politics_ru
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
exports.ApiProvider = ApiProvider;
|
|
305
|
-
exports.Politics = Politics;
|
|
306
|
-
exports.checkLimits = checkLimits;
|
|
307
|
-
exports.numberWithSpaces = numberWithSpaces;
|
|
308
|
-
exports.resources = resources;
|
|
309
|
-
exports.useApi = useApi;
|
|
310
|
-
//# sourceMappingURL=common.cjs.development.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.cjs.development.js","sources":["../src/ApiProvider.tsx","../src/resources/limits.ts","../src/components/Politics/hooks/usePolitics.ts","../src/utils/formatNumber.ts","../src/components/Politics/styled.ts","../src/components/Politics/PolicyItem.tsx","../src/components/Politics/index.tsx","../src/i18n/index.ts"],"sourcesContent":["import React, { createContext, FC, useContext } from 'react';\nimport { Api } from '@evergis/api';\n\nexport type ApiContextProps = {\n api?: Api;\n};\n\nconst ApiContext = createContext<ApiContextProps>({});\n\nexport const ApiProvider: FC<ApiContextProps> = ({ api, children }) => {\n return <ApiContext.Provider value={{ api }}>{children}</ApiContext.Provider>;\n};\n\nexport const useApi = (): ApiContextProps => {\n return useContext(ApiContext);\n};\n","import { Api, CheckLimitsParams } from '@evergis/api';\nimport { createResource } from '@evergis/react-fetching';\n\nlet resource: any;\n\nexport const checkLimits = (evergisApi: Api) => {\n if (!resource) {\n resource = createResource(\n (params: CheckLimitsParams) => async api => ({\n data: await api.resourceCatalog.checkLimits(params),\n }),\n { injected: evergisApi }\n );\n }\n\n return resource;\n};\n","import { Api, PolicyType, WorkspaceLimitsDc } from '@evergis/api';\nimport { useCallback, useEffect, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useApi } from '../../../ApiProvider';\nimport { checkLimits } from '../../../resources/limits';\nimport { PoliticsItem, UpdatePolicy } from '../types';\n\nexport type UsePoliticsConfig = {\n initialLimits?: WorkspaceLimitsDc;\n username?: string;\n onError?: (error: any) => void;\n};\n\nexport const usePolitics = ({\n username,\n onError,\n initialLimits,\n}: UsePoliticsConfig): [PoliticsItem[], UpdatePolicy] => {\n const { t } = useTranslation('politics');\n const { api } = useApi();\n\n const { data: limits, refetch, error } = checkLimits(api as Api).use({\n input: { userName: username },\n waitInput: true,\n });\n\n useEffect(() => {\n if (error && onError) {\n onError(error);\n }\n }, [error, onError]);\n\n const politics = useMemo<PoliticsItem[]>(() => {\n const currentLimits = limits || initialLimits;\n\n return currentLimits\n ? [\n {\n name: t('maps'),\n used: currentLimits.currentProjectCount as number,\n max: currentLimits.maxProjectsCount as number,\n type: PolicyType.CreateProject,\n icon: 'map',\n },\n {\n name: t('layers'),\n used: currentLimits.currentServiceCount as number,\n max: currentLimits.maxServicesCount as number,\n type: PolicyType.CreateLayer,\n icon: 'layers',\n },\n {\n name: t('tables'),\n used: currentLimits.currentTableCount as number,\n max: currentLimits.maxTablesCount as number,\n type: PolicyType.CreateTable,\n icon: 'table',\n },\n {\n name: t('maxFeaturesInLayerLimit'),\n max: currentLimits.maxFeaturesInOneTable as number,\n type: PolicyType.MaxFeaturesInOneTable,\n icon: 'points',\n },\n {\n name: t('maxFileSize'),\n max: currentLimits.maxUploadContentSize as number,\n type: PolicyType.MaxUploadContentSize,\n icon: 'textfile',\n },\n {\n name: t('maxObjectsToExport'),\n max: currentLimits.maxObjectsToExport as number,\n type: PolicyType.MaxObjectsToExport,\n icon: 'points',\n },\n ]\n : [];\n }, [t, limits, initialLimits]);\n\n const updatePolicy: UpdatePolicy = useCallback(\n async (value, type) => {\n await (api as Api).security.setPolicy({\n value,\n type,\n role: `__${username}`,\n });\n\n await refetch();\n },\n [api]\n );\n\n return [politics, updatePolicy];\n};\n","export const numberWithSpaces = (\n input: number | string | null,\n maximumFractionDigits = 10\n): string => {\n if (input === null || input === undefined) {\n return '';\n }\n\n return parseFloat(\n (typeof input === 'string' ? parseFloat(input) : input).toString()\n ).toLocaleString('ru-RU', {\n maximumFractionDigits,\n });\n};\n","import { Flex, H2, Icon, RatioLine } from '@evergis/ui';\nimport styled from 'styled-components';\n\nexport const PoliticsContainer = styled(Flex)`\n margin-top: 3rem;\n flex-direction: column;\n`;\n\nexport const PoliticsTitle = styled(H2)`\n margin: 0;\n`;\n\nexport const PoliticsItems = styled(Flex)`\n flex-wrap: wrap;\n margin-top: 0.5rem;\n margin-bottom: 0.75rem;\n`;\n\nexport const PoliticsItemContainer = styled(Flex)`\n margin-top: 1rem;\n margin-right: 1rem;\n width: 14.5rem;\n height: 10.5rem;\n border-radius: 2px;\n background-color: #f6f6f6;\n flex-direction: column;\n`;\n\nexport const PoliticsItemContent = styled(Flex)`\n flex-direction: column;\n align-items: center;\n padding: 1rem 1rem 0;\n width: 100%;\n box-sizing: border-box;\n`;\n\nexport const PoliticsItemIcon = styled(Icon)`\n opacity: 0.28;\n`;\n\nexport const PoliticsItemLimit = styled.span`\n font-size: 18px;\n font-weight: bold;\n margin-top: 0.75rem;\n`;\n\nexport const PoliticsItemType = styled.span`\n font-size: 12px;\n color: ${({ theme: { palette } }) => palette.textSecondary};\n text-align: center;\n`;\n\nexport const PoliticsRatioContainer = styled.div`\n margin: auto 0 0;\n height: 0.5rem;\n width: 100%;\n`;\n\nexport const PoliticsRatio = styled(RatioLine)`\n width: 100%;\n margin: 0;\n`;\n\nexport const PoliticsLimit = styled(Flex)`\n flex-direction: column;\n width: 100%;\n margin-top: 0.75rem;\n background: white;\n`;\n","import { PolicyType } from '@evergis/api';\nimport { NumberInput } from '@evergis/ui';\nimport React, { FC, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { numberWithSpaces } from '../../utils';\nimport {\n PoliticsItemContainer,\n PoliticsItemContent,\n PoliticsItemIcon,\n PoliticsItemLimit,\n PoliticsItemType,\n PoliticsLimit,\n PoliticsRatio,\n PoliticsRatioContainer,\n} from './styled';\nimport { PolicyItemProps } from './types';\n\ntype RatioLineVariant = Partial<\n Record<'primary' | 'secondary' | 'error', boolean>\n>;\n\nconst WARN_ENTITY_COUNT_THRESHOLD = 75;\nconst ERROR_ENTITY_COUNT_THRESHOLD = 90;\n\nfunction getRatioLineVariant(used: number, max: number): RatioLineVariant {\n const ratioUsed = (used / max) * 100;\n\n if (ratioUsed >= ERROR_ENTITY_COUNT_THRESHOLD) {\n return { error: true };\n }\n\n if (ratioUsed >= WARN_ENTITY_COUNT_THRESHOLD) {\n return { secondary: true };\n }\n\n return { primary: true };\n}\n\nexport const PolicyItem: FC<PolicyItemProps> = ({\n item,\n updatePolicyItem,\n canUpdate,\n}) => {\n const { t } = useTranslation('politics');\n const { name, used, max, type, disabled, icon } = item;\n const onMaxLimitChange = useCallback(\n (value: number | null) => {\n updatePolicyItem(value || 0, type);\n },\n [updatePolicyItem]\n );\n\n const maxValue =\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize\n ? (max / (1024 * 1024)).toFixed(6)\n : max;\n const formattedMaxValue = numberWithSpaces(maxValue, 6);\n\n return (\n <PoliticsItemContainer key={name}>\n <PoliticsItemContent>\n <PoliticsItemIcon kind={icon} />\n <PoliticsItemLimit>\n {used !== undefined\n ? `${used} ${t('from')} ${max === -1 ? '∞' : formattedMaxValue}`\n : `${max === -1 ? '∞' : formattedMaxValue} ${\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize ? 'mb' : ''\n }`}\n </PoliticsItemLimit>\n <PoliticsItemType>{name}</PoliticsItemType>\n {canUpdate && (\n <PoliticsLimit>\n <NumberInput\n required\n disabled={disabled}\n counter={false}\n width={'100%'}\n value={+maxValue}\n onChange={onMaxLimitChange}\n />\n </PoliticsLimit>\n )}\n </PoliticsItemContent>\n <PoliticsRatioContainer>\n {used !== undefined && (\n <PoliticsRatio\n ratio={(used / max) * 100}\n {...getRatioLineVariant(used, max)}\n />\n )}\n </PoliticsRatioContainer>\n </PoliticsItemContainer>\n );\n};\n","import React, { FC, useCallback } from 'react';\nimport { PolicyType } from '@evergis/api';\nimport { useDebouncedCallback } from '@evergis/react';\n\nimport { usePolitics } from './hooks/usePolitics';\nimport { PolicyItem } from './PolicyItem';\nimport { PoliticsContainer, PoliticsItems, PoliticsTitle } from './styled';\nimport { PoliticsProps } from './types';\n\nexport const Politics: FC<PoliticsProps> = ({\n username,\n canUpdate,\n title,\n className,\n initialLimits,\n onError,\n}) => {\n const [politics, updatePolicy] = usePolitics({\n username,\n onError,\n initialLimits,\n });\n const debounce = useDebouncedCallback(500);\n const updatePolicyItem = useCallback(\n (value: number, type: PolicyType) => {\n debounce(async () => {\n const fixedValue =\n // max file size in mb\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize\n ? value * 1024 * 1024\n : value;\n\n await updatePolicy(fixedValue, type);\n });\n },\n [username]\n );\n\n return (\n <PoliticsContainer className={className}>\n {title && <PoliticsTitle>{title}</PoliticsTitle>}\n <PoliticsItems>\n {politics.map(item => (\n <PolicyItem\n key={item.name}\n canUpdate={canUpdate}\n item={item}\n updatePolicyItem={updatePolicyItem}\n />\n ))}\n </PoliticsItems>\n </PoliticsContainer>\n );\n};\n","import politics_en from './en/politics.json';\nimport politics_ru from './ru/politics.json';\n\nexport const resources = {\n en: {\n politics: politics_en,\n },\n ru: {\n politics: politics_ru,\n },\n} as const;\n"],"names":["ApiContext","createContext","ApiProvider","api","children","React","Provider","value","useApi","useContext","resource","checkLimits","evergisApi","createResource","params","data","resourceCatalog","injected","usePolitics","username","onError","initialLimits","t","useTranslation","limits","refetch","error","use","input","userName","waitInput","useEffect","politics","useMemo","currentLimits","name","used","currentProjectCount","max","maxProjectsCount","type","PolicyType","CreateProject","icon","currentServiceCount","maxServicesCount","CreateLayer","currentTableCount","maxTablesCount","CreateTable","maxFeaturesInOneTable","MaxFeaturesInOneTable","maxUploadContentSize","MaxUploadContentSize","maxObjectsToExport","MaxObjectsToExport","updatePolicy","useCallback","security","setPolicy","role","numberWithSpaces","maximumFractionDigits","undefined","parseFloat","toString","toLocaleString","PoliticsContainer","styled","Flex","PoliticsTitle","H2","PoliticsItems","PoliticsItemContainer","PoliticsItemContent","PoliticsItemIcon","Icon","PoliticsItemLimit","span","PoliticsItemType","theme","palette","textSecondary","PoliticsRatioContainer","div","PoliticsRatio","RatioLine","PoliticsLimit","WARN_ENTITY_COUNT_THRESHOLD","ERROR_ENTITY_COUNT_THRESHOLD","getRatioLineVariant","ratioUsed","secondary","primary","PolicyItem","item","updatePolicyItem","canUpdate","disabled","onMaxLimitChange","maxValue","toFixed","formattedMaxValue","key","kind","NumberInput","required","counter","width","onChange","ratio","Politics","title","className","debounce","useDebouncedCallback","fixedValue","map","resources","en","politics_en","ru","politics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AAR;AAUD,GAZiC,EAalC,CAACrB,QAAD,CAbkC,CAApC;AAgBA,SACEd,4BAAA,CAAC8D,iBAAD;AAAmB8C,IAAAA,SAAS,EAAEA;GAA9B,EACGD,KAAK,IAAI3G,4BAAA,CAACiE,aAAD,MAAA,EAAgB0C,KAAhB,CADZ,EAEE3G,4BAAA,CAACmE,aAAD,MAAA,EACGxC,QAAQ,CAACqF,GAAT,CAAatB,IAAI,IAChB1F,4BAAA,CAACyF,UAAD;AACES,IAAAA,GAAG,EAAER,IAAI,CAAC5D;AACV8D,IAAAA,SAAS,EAAEA;AACXF,IAAAA,IAAI,EAAEA;AACNC,IAAAA,gBAAgB,EAAEA;GAJpB,CADD,CADH,CAFF,CADF;AAeD,CA7CM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MCNMsB,SAAS,GAAG;AACvBC,EAAAA,EAAE,EAAE;AACFvF,IAAAA,QAAQ,EAAEwF;AADR,GADmB;AAIvBC,EAAAA,EAAE,EAAE;AACFzF,IAAAA,QAAQ,EAAE0F;AADR;AAJmB,CAAlB;;;;;;;;;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=e(t),r=require("@evergis/api"),a=require("@evergis/react"),i=require("react-i18next"),o=require("@evergis/react-fetching"),l=require("@evergis/ui"),c=e(require("styled-components"));const s=t.createContext({}),m=()=>t.useContext(s);let u;const p=e=>(u||(u=o.createResource(e=>async t=>({data:await t.resourceCatalog.checkLimits(e)}),{injected:e})),u),x=function(e,t){return void 0===t&&(t=10),null==e?"":parseFloat(("string"==typeof e?parseFloat(e):e).toString()).toLocaleString("ru-RU",{maximumFractionDigits:t})};function d(e,t){return t||(t=e.slice(0)),e.raw=t,e}var y,b,g,f,E,C,T,h,P,v,F;const w=c(l.Flex)(y||(y=d(["\n margin-top: 3rem;\n flex-direction: column;\n"]))),L=c(l.H2)(b||(b=d(["\n margin: 0;\n"]))),j=c(l.Flex)(g||(g=d(["\n flex-wrap: wrap;\n margin-top: 0.5rem;\n margin-bottom: 0.75rem;\n"]))),S=c(l.Flex)(f||(f=d(["\n margin-top: 1rem;\n margin-right: 1rem;\n width: 14.5rem;\n height: 10.5rem;\n border-radius: 2px;\n background-color: #f6f6f6;\n flex-direction: column;\n"]))),z=c(l.Flex)(E||(E=d(["\n flex-direction: column;\n align-items: center;\n padding: 1rem 1rem 0;\n width: 100%;\n box-sizing: border-box;\n"]))),M=c(l.Icon)(C||(C=d(["\n opacity: 0.28;\n"]))),k=c.span(T||(T=d(["\n font-size: 18px;\n font-weight: bold;\n margin-top: 0.75rem;\n"]))),I=c.span(h||(h=d(["\n font-size: 12px;\n color: ",";\n text-align: center;\n"])),e=>{let{theme:{palette:t}}=e;return t.textSecondary}),O=c.div(P||(P=d(["\n margin: auto 0 0;\n height: 0.5rem;\n width: 100%;\n"]))),U=c(l.RatioLine)(v||(v=d(["\n width: 100%;\n margin: 0;\n"]))),q=c(l.Flex)(F||(F=d(["\n flex-direction: column;\n width: 100%;\n margin-top: 0.75rem;\n background: white;\n"]))),N=e=>{let{item:a,updatePolicyItem:o,canUpdate:c}=e;const{t:s}=i.useTranslation("politics"),{name:m,used:u,max:p,type:d,disabled:y,icon:b}=a,g=t.useCallback(e=>{o(e||0,d)},[o]),f=d===r.PolicyType.MaxUploadContentSize?(p/1048576).toFixed(6):p,E=x(f,6);return n.createElement(S,{key:m},n.createElement(z,null,n.createElement(M,{kind:b}),n.createElement(k,null,void 0!==u?u+" "+s("from")+" "+(-1===p?"∞":E):(-1===p?"∞":E)+" "+(d===r.PolicyType.MaxUploadContentSize?"mb":"")),n.createElement(I,null,m),c&&n.createElement(q,null,n.createElement(l.NumberInput,{required:!0,disabled:y,counter:!1,width:"100%",value:+f,onChange:g}))),n.createElement(O,null,void 0!==u&&n.createElement(U,Object.assign({ratio:u/p*100},function(e,t){const n=e/t*100;return n>=90?{error:!0}:n>=75?{secondary:!0}:{primary:!0}}(u,p)))))};exports.ApiProvider=e=>{let{api:t,children:r}=e;return n.createElement(s.Provider,{value:{api:t}},r)},exports.Politics=e=>{let{username:o,canUpdate:l,title:c,className:s,initialLimits:u,onError:x}=e;const[d,y]=(e=>{let{username:n,onError:a,initialLimits:o}=e;const{t:l}=i.useTranslation("politics"),{api:c}=m(),{data:s,refetch:u,error:x}=p(c).use({input:{userName:n},waitInput:!0});return t.useEffect(()=>{x&&a&&a(x)},[x,a]),[t.useMemo(()=>{const e=s||o;return e?[{name:l("maps"),used:e.currentProjectCount,max:e.maxProjectsCount,type:r.PolicyType.CreateProject,icon:"map"},{name:l("layers"),used:e.currentServiceCount,max:e.maxServicesCount,type:r.PolicyType.CreateLayer,icon:"layers"},{name:l("tables"),used:e.currentTableCount,max:e.maxTablesCount,type:r.PolicyType.CreateTable,icon:"table"},{name:l("maxFeaturesInLayerLimit"),max:e.maxFeaturesInOneTable,type:r.PolicyType.MaxFeaturesInOneTable,icon:"points"},{name:l("maxFileSize"),max:e.maxUploadContentSize,type:r.PolicyType.MaxUploadContentSize,icon:"textfile"},{name:l("maxObjectsToExport"),max:e.maxObjectsToExport,type:r.PolicyType.MaxObjectsToExport,icon:"points"}]:[]},[l,s,o]),t.useCallback(async(e,t)=>{await c.security.setPolicy({value:e,type:t,role:"__"+n}),await u()},[c])]})({username:o,onError:x,initialLimits:u}),b=a.useDebouncedCallback(500),g=t.useCallback((e,t)=>{b(async()=>{const n=t===r.PolicyType.MaxUploadContentSize?1024*e*1024:e;await y(n,t)})},[o]);return n.createElement(w,{className:s},c&&n.createElement(L,null,c),n.createElement(j,null,d.map(e=>n.createElement(N,{key:e.name,canUpdate:l,item:e,updatePolicyItem:g}))))},exports.checkLimits=p,exports.numberWithSpaces=x,exports.resources={en:{politics:{maps:"Maps",layers:"Layers",maxFeaturesInLayerLimit:"Max objects count in layer",maxFileSize:"Max file size",maxObjectsToExport:"Max objects to export",tables:"Tables",in:"in",from:"from"}},ru:{politics:{maps:"Карты",layers:"Слои",maxFeaturesInLayerLimit:"Макс. количество объектов в слое",maxFileSize:"Макс. размер файла",maxObjectsToExport:"Макс. количество объектов для экспорта",tables:"Таблицы",in:"в",from:"из"}}},exports.useApi=m;
|
|
2
|
-
//# sourceMappingURL=common.cjs.production.min.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.cjs.production.min.js","sources":["../src/ApiProvider.tsx","../src/resources/limits.ts","../src/utils/formatNumber.ts","../src/components/Politics/styled.ts","../src/components/Politics/PolicyItem.tsx","../src/components/Politics/index.tsx","../src/components/Politics/hooks/usePolitics.ts","../src/i18n/index.ts"],"sourcesContent":["import React, { createContext, FC, useContext } from 'react';\nimport { Api } from '@evergis/api';\n\nexport type ApiContextProps = {\n api?: Api;\n};\n\nconst ApiContext = createContext<ApiContextProps>({});\n\nexport const ApiProvider: FC<ApiContextProps> = ({ api, children }) => {\n return <ApiContext.Provider value={{ api }}>{children}</ApiContext.Provider>;\n};\n\nexport const useApi = (): ApiContextProps => {\n return useContext(ApiContext);\n};\n","import { Api, CheckLimitsParams } from '@evergis/api';\nimport { createResource } from '@evergis/react-fetching';\n\nlet resource: any;\n\nexport const checkLimits = (evergisApi: Api) => {\n if (!resource) {\n resource = createResource(\n (params: CheckLimitsParams) => async api => ({\n data: await api.resourceCatalog.checkLimits(params),\n }),\n { injected: evergisApi }\n );\n }\n\n return resource;\n};\n","export const numberWithSpaces = (\n input: number | string | null,\n maximumFractionDigits = 10\n): string => {\n if (input === null || input === undefined) {\n return '';\n }\n\n return parseFloat(\n (typeof input === 'string' ? parseFloat(input) : input).toString()\n ).toLocaleString('ru-RU', {\n maximumFractionDigits,\n });\n};\n","import { Flex, H2, Icon, RatioLine } from '@evergis/ui';\nimport styled from 'styled-components';\n\nexport const PoliticsContainer = styled(Flex)`\n margin-top: 3rem;\n flex-direction: column;\n`;\n\nexport const PoliticsTitle = styled(H2)`\n margin: 0;\n`;\n\nexport const PoliticsItems = styled(Flex)`\n flex-wrap: wrap;\n margin-top: 0.5rem;\n margin-bottom: 0.75rem;\n`;\n\nexport const PoliticsItemContainer = styled(Flex)`\n margin-top: 1rem;\n margin-right: 1rem;\n width: 14.5rem;\n height: 10.5rem;\n border-radius: 2px;\n background-color: #f6f6f6;\n flex-direction: column;\n`;\n\nexport const PoliticsItemContent = styled(Flex)`\n flex-direction: column;\n align-items: center;\n padding: 1rem 1rem 0;\n width: 100%;\n box-sizing: border-box;\n`;\n\nexport const PoliticsItemIcon = styled(Icon)`\n opacity: 0.28;\n`;\n\nexport const PoliticsItemLimit = styled.span`\n font-size: 18px;\n font-weight: bold;\n margin-top: 0.75rem;\n`;\n\nexport const PoliticsItemType = styled.span`\n font-size: 12px;\n color: ${({ theme: { palette } }) => palette.textSecondary};\n text-align: center;\n`;\n\nexport const PoliticsRatioContainer = styled.div`\n margin: auto 0 0;\n height: 0.5rem;\n width: 100%;\n`;\n\nexport const PoliticsRatio = styled(RatioLine)`\n width: 100%;\n margin: 0;\n`;\n\nexport const PoliticsLimit = styled(Flex)`\n flex-direction: column;\n width: 100%;\n margin-top: 0.75rem;\n background: white;\n`;\n","import { PolicyType } from '@evergis/api';\nimport { NumberInput } from '@evergis/ui';\nimport React, { FC, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { numberWithSpaces } from '../../utils';\nimport {\n PoliticsItemContainer,\n PoliticsItemContent,\n PoliticsItemIcon,\n PoliticsItemLimit,\n PoliticsItemType,\n PoliticsLimit,\n PoliticsRatio,\n PoliticsRatioContainer,\n} from './styled';\nimport { PolicyItemProps } from './types';\n\ntype RatioLineVariant = Partial<\n Record<'primary' | 'secondary' | 'error', boolean>\n>;\n\nconst WARN_ENTITY_COUNT_THRESHOLD = 75;\nconst ERROR_ENTITY_COUNT_THRESHOLD = 90;\n\nfunction getRatioLineVariant(used: number, max: number): RatioLineVariant {\n const ratioUsed = (used / max) * 100;\n\n if (ratioUsed >= ERROR_ENTITY_COUNT_THRESHOLD) {\n return { error: true };\n }\n\n if (ratioUsed >= WARN_ENTITY_COUNT_THRESHOLD) {\n return { secondary: true };\n }\n\n return { primary: true };\n}\n\nexport const PolicyItem: FC<PolicyItemProps> = ({\n item,\n updatePolicyItem,\n canUpdate,\n}) => {\n const { t } = useTranslation('politics');\n const { name, used, max, type, disabled, icon } = item;\n const onMaxLimitChange = useCallback(\n (value: number | null) => {\n updatePolicyItem(value || 0, type);\n },\n [updatePolicyItem]\n );\n\n const maxValue =\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize\n ? (max / (1024 * 1024)).toFixed(6)\n : max;\n const formattedMaxValue = numberWithSpaces(maxValue, 6);\n\n return (\n <PoliticsItemContainer key={name}>\n <PoliticsItemContent>\n <PoliticsItemIcon kind={icon} />\n <PoliticsItemLimit>\n {used !== undefined\n ? `${used} ${t('from')} ${max === -1 ? '∞' : formattedMaxValue}`\n : `${max === -1 ? '∞' : formattedMaxValue} ${\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize ? 'mb' : ''\n }`}\n </PoliticsItemLimit>\n <PoliticsItemType>{name}</PoliticsItemType>\n {canUpdate && (\n <PoliticsLimit>\n <NumberInput\n required\n disabled={disabled}\n counter={false}\n width={'100%'}\n value={+maxValue}\n onChange={onMaxLimitChange}\n />\n </PoliticsLimit>\n )}\n </PoliticsItemContent>\n <PoliticsRatioContainer>\n {used !== undefined && (\n <PoliticsRatio\n ratio={(used / max) * 100}\n {...getRatioLineVariant(used, max)}\n />\n )}\n </PoliticsRatioContainer>\n </PoliticsItemContainer>\n );\n};\n","import React, { FC, useCallback } from 'react';\nimport { PolicyType } from '@evergis/api';\nimport { useDebouncedCallback } from '@evergis/react';\n\nimport { usePolitics } from './hooks/usePolitics';\nimport { PolicyItem } from './PolicyItem';\nimport { PoliticsContainer, PoliticsItems, PoliticsTitle } from './styled';\nimport { PoliticsProps } from './types';\n\nexport const Politics: FC<PoliticsProps> = ({\n username,\n canUpdate,\n title,\n className,\n initialLimits,\n onError,\n}) => {\n const [politics, updatePolicy] = usePolitics({\n username,\n onError,\n initialLimits,\n });\n const debounce = useDebouncedCallback(500);\n const updatePolicyItem = useCallback(\n (value: number, type: PolicyType) => {\n debounce(async () => {\n const fixedValue =\n // max file size in mb\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize\n ? value * 1024 * 1024\n : value;\n\n await updatePolicy(fixedValue, type);\n });\n },\n [username]\n );\n\n return (\n <PoliticsContainer className={className}>\n {title && <PoliticsTitle>{title}</PoliticsTitle>}\n <PoliticsItems>\n {politics.map(item => (\n <PolicyItem\n key={item.name}\n canUpdate={canUpdate}\n item={item}\n updatePolicyItem={updatePolicyItem}\n />\n ))}\n </PoliticsItems>\n </PoliticsContainer>\n );\n};\n","import { Api, PolicyType, WorkspaceLimitsDc } from '@evergis/api';\nimport { useCallback, useEffect, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useApi } from '../../../ApiProvider';\nimport { checkLimits } from '../../../resources/limits';\nimport { PoliticsItem, UpdatePolicy } from '../types';\n\nexport type UsePoliticsConfig = {\n initialLimits?: WorkspaceLimitsDc;\n username?: string;\n onError?: (error: any) => void;\n};\n\nexport const usePolitics = ({\n username,\n onError,\n initialLimits,\n}: UsePoliticsConfig): [PoliticsItem[], UpdatePolicy] => {\n const { t } = useTranslation('politics');\n const { api } = useApi();\n\n const { data: limits, refetch, error } = checkLimits(api as Api).use({\n input: { userName: username },\n waitInput: true,\n });\n\n useEffect(() => {\n if (error && onError) {\n onError(error);\n }\n }, [error, onError]);\n\n const politics = useMemo<PoliticsItem[]>(() => {\n const currentLimits = limits || initialLimits;\n\n return currentLimits\n ? [\n {\n name: t('maps'),\n used: currentLimits.currentProjectCount as number,\n max: currentLimits.maxProjectsCount as number,\n type: PolicyType.CreateProject,\n icon: 'map',\n },\n {\n name: t('layers'),\n used: currentLimits.currentServiceCount as number,\n max: currentLimits.maxServicesCount as number,\n type: PolicyType.CreateLayer,\n icon: 'layers',\n },\n {\n name: t('tables'),\n used: currentLimits.currentTableCount as number,\n max: currentLimits.maxTablesCount as number,\n type: PolicyType.CreateTable,\n icon: 'table',\n },\n {\n name: t('maxFeaturesInLayerLimit'),\n max: currentLimits.maxFeaturesInOneTable as number,\n type: PolicyType.MaxFeaturesInOneTable,\n icon: 'points',\n },\n {\n name: t('maxFileSize'),\n max: currentLimits.maxUploadContentSize as number,\n type: PolicyType.MaxUploadContentSize,\n icon: 'textfile',\n },\n {\n name: t('maxObjectsToExport'),\n max: currentLimits.maxObjectsToExport as number,\n type: PolicyType.MaxObjectsToExport,\n icon: 'points',\n },\n ]\n : [];\n }, [t, limits, initialLimits]);\n\n const updatePolicy: UpdatePolicy = useCallback(\n async (value, type) => {\n await (api as Api).security.setPolicy({\n value,\n type,\n role: `__${username}`,\n });\n\n await refetch();\n },\n [api]\n );\n\n return [politics, updatePolicy];\n};\n","import politics_en from './en/politics.json';\nimport politics_ru from './ru/politics.json';\n\nexport const resources = {\n en: {\n politics: politics_en,\n },\n ru: {\n politics: politics_ru,\n },\n} as const;\n"],"names":["ApiContext","createContext","useApi","useContext","resource","checkLimits","evergisApi","createResource","params","async","data","api","resourceCatalog","injected","numberWithSpaces","input","maximumFractionDigits","parseFloat","toString","toLocaleString","PoliticsContainer","styled","Flex","PoliticsTitle","H2","PoliticsItems","PoliticsItemContainer","PoliticsItemContent","PoliticsItemIcon","Icon","PoliticsItemLimit","span","PoliticsItemType","theme","palette","textSecondary","PoliticsRatioContainer","div","PoliticsRatio","RatioLine","PoliticsLimit","PolicyItem","item","updatePolicyItem","canUpdate","t","useTranslation","name","used","max","type","disabled","icon","onMaxLimitChange","useCallback","value","maxValue","PolicyType","MaxUploadContentSize","toFixed","formattedMaxValue","React","key","kind","undefined","NumberInput","required","counter","width","onChange","ratio","ratioUsed","error","secondary","primary","getRatioLineVariant","children","Provider","username","title","className","initialLimits","onError","politics","updatePolicy","limits","refetch","use","userName","waitInput","useEffect","useMemo","currentLimits","currentProjectCount","maxProjectsCount","CreateProject","currentServiceCount","maxServicesCount","CreateLayer","currentTableCount","maxTablesCount","CreateTable","maxFeaturesInOneTable","MaxFeaturesInOneTable","maxUploadContentSize","maxObjectsToExport","MaxObjectsToExport","security","setPolicy","role","usePolitics","debounce","useDebouncedCallback","fixedValue","map","en","ru"],"mappings":"yVAOA,MAAMA,EAAaC,gBAA+B,IAMrCC,EAAS,IACbC,aAAWH,GCXpB,IAAII,QAESC,EAAeC,IACrBF,IACHA,EAAWG,iBACRC,GAA8BC,MAAAA,KAC7BC,WAAYC,EAAIC,gBAAgBP,YAAYG,KAE9C,CAAEK,SAAUP,KAITF,GCfIU,EAAmB,SAC9BC,EACAC,mBAAAA,IAAAA,EAAwB,IAEpBD,MAAAA,EACK,GAGFE,YACa,iBAAVF,EAAqBE,WAAWF,GAASA,GAAOG,YACxDC,eAAe,QAAS,CACxBH,sBAAAA,wFCRSI,EAAoBC,EAAOC,OAAPD,mEAKpBE,EAAgBF,EAAOG,KAAPH,iCAIhBI,EAAgBJ,EAAOC,OAAPD,yFAMhBK,EAAwBL,EAAOC,OAAPD,sLAUxBM,EAAsBN,EAAOC,OAAPD,0IAQtBO,EAAmBP,EAAOQ,OAAPR,qCAInBS,EAAoBT,EAAOU,yFAM3BC,EAAmBX,EAAOU,wFAEzBE,OAAOC,QAAEA,aAAgBA,EAAQC,gBAIlCC,EAAyBf,EAAOgB,8EAMhCC,EAAgBjB,EAAOkB,YAAPlB,iDAKhBmB,EAAgBnB,EAAOC,OAAPD,4GCzBhBoB,UAAmCC,KAC9CA,EAD8CC,iBAE9CA,EAF8CC,UAG9CA,WAEMC,EAAEA,GAAMC,iBAAe,aACvBC,KAAEA,EAAFC,KAAQA,EAARC,IAAcA,EAAdC,KAAmBA,EAAnBC,SAAyBA,EAAzBC,KAAmCA,GAASV,EAC5CW,EAAmBC,cACtBC,IACCZ,EAAiBY,GAAS,EAAGL,IAE/B,CAACP,IAGGa,EAEJN,IAASO,aAAWC,sBACfT,WAAqBU,QAAQ,GAC9B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0 @@
|
|
|
1
|
-
import React, { useContext, createContext, useEffect, useMemo, useCallback } from 'react';
|
|
2
|
-
import { PolicyType } from '@evergis/api';
|
|
3
|
-
import { useDebouncedCallback } from '@evergis/react';
|
|
4
|
-
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import { createResource } from '@evergis/react-fetching';
|
|
6
|
-
import { Flex, H2, Icon, RatioLine, NumberInput } from '@evergis/ui';
|
|
7
|
-
import styled from 'styled-components';
|
|
8
|
-
|
|
9
|
-
const ApiContext = /*#__PURE__*/createContext({});
|
|
10
|
-
const ApiProvider = (_ref) => {
|
|
11
|
-
let {
|
|
12
|
-
api,
|
|
13
|
-
children
|
|
14
|
-
} = _ref;
|
|
15
|
-
return React.createElement(ApiContext.Provider, {
|
|
16
|
-
value: {
|
|
17
|
-
api
|
|
18
|
-
}
|
|
19
|
-
}, children);
|
|
20
|
-
};
|
|
21
|
-
const useApi = () => {
|
|
22
|
-
return useContext(ApiContext);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
let resource;
|
|
26
|
-
const checkLimits = evergisApi => {
|
|
27
|
-
if (!resource) {
|
|
28
|
-
resource = createResource(params => async api => ({
|
|
29
|
-
data: await api.resourceCatalog.checkLimits(params)
|
|
30
|
-
}), {
|
|
31
|
-
injected: evergisApi
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return resource;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const usePolitics = (_ref) => {
|
|
39
|
-
let {
|
|
40
|
-
username,
|
|
41
|
-
onError,
|
|
42
|
-
initialLimits
|
|
43
|
-
} = _ref;
|
|
44
|
-
const {
|
|
45
|
-
t
|
|
46
|
-
} = useTranslation('politics');
|
|
47
|
-
const {
|
|
48
|
-
api
|
|
49
|
-
} = useApi();
|
|
50
|
-
const {
|
|
51
|
-
data: limits,
|
|
52
|
-
refetch,
|
|
53
|
-
error
|
|
54
|
-
} = checkLimits(api).use({
|
|
55
|
-
input: {
|
|
56
|
-
userName: username
|
|
57
|
-
},
|
|
58
|
-
waitInput: true
|
|
59
|
-
});
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (error && onError) {
|
|
62
|
-
onError(error);
|
|
63
|
-
}
|
|
64
|
-
}, [error, onError]);
|
|
65
|
-
const politics = useMemo(() => {
|
|
66
|
-
const currentLimits = limits || initialLimits;
|
|
67
|
-
return currentLimits ? [{
|
|
68
|
-
name: t('maps'),
|
|
69
|
-
used: currentLimits.currentProjectCount,
|
|
70
|
-
max: currentLimits.maxProjectsCount,
|
|
71
|
-
type: PolicyType.CreateProject,
|
|
72
|
-
icon: 'map'
|
|
73
|
-
}, {
|
|
74
|
-
name: t('layers'),
|
|
75
|
-
used: currentLimits.currentServiceCount,
|
|
76
|
-
max: currentLimits.maxServicesCount,
|
|
77
|
-
type: PolicyType.CreateLayer,
|
|
78
|
-
icon: 'layers'
|
|
79
|
-
}, {
|
|
80
|
-
name: t('tables'),
|
|
81
|
-
used: currentLimits.currentTableCount,
|
|
82
|
-
max: currentLimits.maxTablesCount,
|
|
83
|
-
type: PolicyType.CreateTable,
|
|
84
|
-
icon: 'table'
|
|
85
|
-
}, {
|
|
86
|
-
name: t('maxFeaturesInLayerLimit'),
|
|
87
|
-
max: currentLimits.maxFeaturesInOneTable,
|
|
88
|
-
type: PolicyType.MaxFeaturesInOneTable,
|
|
89
|
-
icon: 'points'
|
|
90
|
-
}, {
|
|
91
|
-
name: t('maxFileSize'),
|
|
92
|
-
max: currentLimits.maxUploadContentSize,
|
|
93
|
-
type: PolicyType.MaxUploadContentSize,
|
|
94
|
-
icon: 'textfile'
|
|
95
|
-
}, {
|
|
96
|
-
name: t('maxObjectsToExport'),
|
|
97
|
-
max: currentLimits.maxObjectsToExport,
|
|
98
|
-
type: PolicyType.MaxObjectsToExport,
|
|
99
|
-
icon: 'points'
|
|
100
|
-
}] : [];
|
|
101
|
-
}, [t, limits, initialLimits]);
|
|
102
|
-
const updatePolicy = useCallback(async (value, type) => {
|
|
103
|
-
await api.security.setPolicy({
|
|
104
|
-
value,
|
|
105
|
-
type,
|
|
106
|
-
role: "__" + username
|
|
107
|
-
});
|
|
108
|
-
await refetch();
|
|
109
|
-
}, [api]);
|
|
110
|
-
return [politics, updatePolicy];
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const numberWithSpaces = function numberWithSpaces(input, maximumFractionDigits) {
|
|
114
|
-
if (maximumFractionDigits === void 0) {
|
|
115
|
-
maximumFractionDigits = 10;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if (input === null || input === undefined) {
|
|
119
|
-
return '';
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return parseFloat((typeof input === 'string' ? parseFloat(input) : input).toString()).toLocaleString('ru-RU', {
|
|
123
|
-
maximumFractionDigits
|
|
124
|
-
});
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
function _taggedTemplateLiteralLoose(strings, raw) {
|
|
128
|
-
if (!raw) {
|
|
129
|
-
raw = strings.slice(0);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
strings.raw = raw;
|
|
133
|
-
return strings;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
|
|
137
|
-
const PoliticsContainer = /*#__PURE__*/styled(Flex)(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-top: 3rem;\n flex-direction: column;\n"])));
|
|
138
|
-
const PoliticsTitle = /*#__PURE__*/styled(H2)(_templateObject2 || (_templateObject2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: 0;\n"])));
|
|
139
|
-
const PoliticsItems = /*#__PURE__*/styled(Flex)(_templateObject3 || (_templateObject3 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex-wrap: wrap;\n margin-top: 0.5rem;\n margin-bottom: 0.75rem;\n"])));
|
|
140
|
-
const PoliticsItemContainer = /*#__PURE__*/styled(Flex)(_templateObject4 || (_templateObject4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-top: 1rem;\n margin-right: 1rem;\n width: 14.5rem;\n height: 10.5rem;\n border-radius: 2px;\n background-color: #f6f6f6;\n flex-direction: column;\n"])));
|
|
141
|
-
const PoliticsItemContent = /*#__PURE__*/styled(Flex)(_templateObject5 || (_templateObject5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex-direction: column;\n align-items: center;\n padding: 1rem 1rem 0;\n width: 100%;\n box-sizing: border-box;\n"])));
|
|
142
|
-
const PoliticsItemIcon = /*#__PURE__*/styled(Icon)(_templateObject6 || (_templateObject6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n opacity: 0.28;\n"])));
|
|
143
|
-
const PoliticsItemLimit = /*#__PURE__*/styled.span(_templateObject7 || (_templateObject7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 18px;\n font-weight: bold;\n margin-top: 0.75rem;\n"])));
|
|
144
|
-
const PoliticsItemType = /*#__PURE__*/styled.span(_templateObject8 || (_templateObject8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n font-size: 12px;\n color: ", ";\n text-align: center;\n"])), (_ref) => {
|
|
145
|
-
let {
|
|
146
|
-
theme: {
|
|
147
|
-
palette
|
|
148
|
-
}
|
|
149
|
-
} = _ref;
|
|
150
|
-
return palette.textSecondary;
|
|
151
|
-
});
|
|
152
|
-
const PoliticsRatioContainer = /*#__PURE__*/styled.div(_templateObject9 || (_templateObject9 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin: auto 0 0;\n height: 0.5rem;\n width: 100%;\n"])));
|
|
153
|
-
const PoliticsRatio = /*#__PURE__*/styled(RatioLine)(_templateObject10 || (_templateObject10 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 100%;\n margin: 0;\n"])));
|
|
154
|
-
const PoliticsLimit = /*#__PURE__*/styled(Flex)(_templateObject11 || (_templateObject11 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n flex-direction: column;\n width: 100%;\n margin-top: 0.75rem;\n background: white;\n"])));
|
|
155
|
-
|
|
156
|
-
const WARN_ENTITY_COUNT_THRESHOLD = 75;
|
|
157
|
-
const ERROR_ENTITY_COUNT_THRESHOLD = 90;
|
|
158
|
-
|
|
159
|
-
function getRatioLineVariant(used, max) {
|
|
160
|
-
const ratioUsed = used / max * 100;
|
|
161
|
-
|
|
162
|
-
if (ratioUsed >= ERROR_ENTITY_COUNT_THRESHOLD) {
|
|
163
|
-
return {
|
|
164
|
-
error: true
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (ratioUsed >= WARN_ENTITY_COUNT_THRESHOLD) {
|
|
169
|
-
return {
|
|
170
|
-
secondary: true
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
primary: true
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const PolicyItem = (_ref) => {
|
|
180
|
-
let {
|
|
181
|
-
item,
|
|
182
|
-
updatePolicyItem,
|
|
183
|
-
canUpdate
|
|
184
|
-
} = _ref;
|
|
185
|
-
const {
|
|
186
|
-
t
|
|
187
|
-
} = useTranslation('politics');
|
|
188
|
-
const {
|
|
189
|
-
name,
|
|
190
|
-
used,
|
|
191
|
-
max,
|
|
192
|
-
type,
|
|
193
|
-
disabled,
|
|
194
|
-
icon
|
|
195
|
-
} = item;
|
|
196
|
-
const onMaxLimitChange = useCallback(value => {
|
|
197
|
-
updatePolicyItem(value || 0, type);
|
|
198
|
-
}, [updatePolicyItem]);
|
|
199
|
-
const maxValue = // @ts-ignore
|
|
200
|
-
type === PolicyType.MaxUploadContentSize ? (max / (1024 * 1024)).toFixed(6) : max;
|
|
201
|
-
const formattedMaxValue = numberWithSpaces(maxValue, 6);
|
|
202
|
-
return React.createElement(PoliticsItemContainer, {
|
|
203
|
-
key: name
|
|
204
|
-
}, React.createElement(PoliticsItemContent, null, React.createElement(PoliticsItemIcon, {
|
|
205
|
-
kind: icon
|
|
206
|
-
}), React.createElement(PoliticsItemLimit, null, used !== undefined ? used + " " + t('from') + " " + (max === -1 ? '∞' : formattedMaxValue) : (max === -1 ? '∞' : formattedMaxValue) + " " + ( // @ts-ignore
|
|
207
|
-
type === PolicyType.MaxUploadContentSize ? 'mb' : '')), React.createElement(PoliticsItemType, null, name), canUpdate && React.createElement(PoliticsLimit, null, React.createElement(NumberInput, {
|
|
208
|
-
required: true,
|
|
209
|
-
disabled: disabled,
|
|
210
|
-
counter: false,
|
|
211
|
-
width: '100%',
|
|
212
|
-
value: +maxValue,
|
|
213
|
-
onChange: onMaxLimitChange
|
|
214
|
-
}))), React.createElement(PoliticsRatioContainer, null, used !== undefined && React.createElement(PoliticsRatio, Object.assign({
|
|
215
|
-
ratio: used / max * 100
|
|
216
|
-
}, getRatioLineVariant(used, max)))));
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
const Politics = (_ref) => {
|
|
220
|
-
let {
|
|
221
|
-
username,
|
|
222
|
-
canUpdate,
|
|
223
|
-
title,
|
|
224
|
-
className,
|
|
225
|
-
initialLimits,
|
|
226
|
-
onError
|
|
227
|
-
} = _ref;
|
|
228
|
-
const [politics, updatePolicy] = usePolitics({
|
|
229
|
-
username,
|
|
230
|
-
onError,
|
|
231
|
-
initialLimits
|
|
232
|
-
});
|
|
233
|
-
const debounce = useDebouncedCallback(500);
|
|
234
|
-
const updatePolicyItem = useCallback((value, type) => {
|
|
235
|
-
debounce(async () => {
|
|
236
|
-
const fixedValue = // max file size in mb
|
|
237
|
-
// @ts-ignore
|
|
238
|
-
type === PolicyType.MaxUploadContentSize ? value * 1024 * 1024 : value;
|
|
239
|
-
await updatePolicy(fixedValue, type);
|
|
240
|
-
});
|
|
241
|
-
}, [username]);
|
|
242
|
-
return React.createElement(PoliticsContainer, {
|
|
243
|
-
className: className
|
|
244
|
-
}, title && React.createElement(PoliticsTitle, null, title), React.createElement(PoliticsItems, null, politics.map(item => React.createElement(PolicyItem, {
|
|
245
|
-
key: item.name,
|
|
246
|
-
canUpdate: canUpdate,
|
|
247
|
-
item: item,
|
|
248
|
-
updatePolicyItem: updatePolicyItem
|
|
249
|
-
}))));
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
var maps = "Maps";
|
|
253
|
-
var layers = "Layers";
|
|
254
|
-
var maxFeaturesInLayerLimit = "Max objects count in layer";
|
|
255
|
-
var maxFileSize = "Max file size";
|
|
256
|
-
var maxObjectsToExport = "Max objects to export";
|
|
257
|
-
var tables = "Tables";
|
|
258
|
-
var from = "from";
|
|
259
|
-
var politics_en = {
|
|
260
|
-
maps: maps,
|
|
261
|
-
layers: layers,
|
|
262
|
-
maxFeaturesInLayerLimit: maxFeaturesInLayerLimit,
|
|
263
|
-
maxFileSize: maxFileSize,
|
|
264
|
-
maxObjectsToExport: maxObjectsToExport,
|
|
265
|
-
tables: tables,
|
|
266
|
-
"in": "in",
|
|
267
|
-
from: from
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
var maps$1 = "Карты";
|
|
271
|
-
var layers$1 = "Слои";
|
|
272
|
-
var maxFeaturesInLayerLimit$1 = "Макс. количество объектов в слое";
|
|
273
|
-
var maxFileSize$1 = "Макс. размер файла";
|
|
274
|
-
var maxObjectsToExport$1 = "Макс. количество объектов для экспорта";
|
|
275
|
-
var tables$1 = "Таблицы";
|
|
276
|
-
var from$1 = "из";
|
|
277
|
-
var politics_ru = {
|
|
278
|
-
maps: maps$1,
|
|
279
|
-
layers: layers$1,
|
|
280
|
-
maxFeaturesInLayerLimit: maxFeaturesInLayerLimit$1,
|
|
281
|
-
maxFileSize: maxFileSize$1,
|
|
282
|
-
maxObjectsToExport: maxObjectsToExport$1,
|
|
283
|
-
tables: tables$1,
|
|
284
|
-
"in": "в",
|
|
285
|
-
from: from$1
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
const resources = {
|
|
289
|
-
en: {
|
|
290
|
-
politics: politics_en
|
|
291
|
-
},
|
|
292
|
-
ru: {
|
|
293
|
-
politics: politics_ru
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
export { ApiProvider, Politics, checkLimits, numberWithSpaces, resources, useApi };
|
|
298
|
-
//# sourceMappingURL=common.esm.js.map
|
package/dist/common.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.esm.js","sources":["../src/ApiProvider.tsx","../src/resources/limits.ts","../src/components/Politics/hooks/usePolitics.ts","../src/utils/formatNumber.ts","../src/components/Politics/styled.ts","../src/components/Politics/PolicyItem.tsx","../src/components/Politics/index.tsx","../src/i18n/index.ts"],"sourcesContent":["import React, { createContext, FC, useContext } from 'react';\nimport { Api } from '@evergis/api';\n\nexport type ApiContextProps = {\n api?: Api;\n};\n\nconst ApiContext = createContext<ApiContextProps>({});\n\nexport const ApiProvider: FC<ApiContextProps> = ({ api, children }) => {\n return <ApiContext.Provider value={{ api }}>{children}</ApiContext.Provider>;\n};\n\nexport const useApi = (): ApiContextProps => {\n return useContext(ApiContext);\n};\n","import { Api, CheckLimitsParams } from '@evergis/api';\nimport { createResource } from '@evergis/react-fetching';\n\nlet resource: any;\n\nexport const checkLimits = (evergisApi: Api) => {\n if (!resource) {\n resource = createResource(\n (params: CheckLimitsParams) => async api => ({\n data: await api.resourceCatalog.checkLimits(params),\n }),\n { injected: evergisApi }\n );\n }\n\n return resource;\n};\n","import { Api, PolicyType, WorkspaceLimitsDc } from '@evergis/api';\nimport { useCallback, useEffect, useMemo } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { useApi } from '../../../ApiProvider';\nimport { checkLimits } from '../../../resources/limits';\nimport { PoliticsItem, UpdatePolicy } from '../types';\n\nexport type UsePoliticsConfig = {\n initialLimits?: WorkspaceLimitsDc;\n username?: string;\n onError?: (error: any) => void;\n};\n\nexport const usePolitics = ({\n username,\n onError,\n initialLimits,\n}: UsePoliticsConfig): [PoliticsItem[], UpdatePolicy] => {\n const { t } = useTranslation('politics');\n const { api } = useApi();\n\n const { data: limits, refetch, error } = checkLimits(api as Api).use({\n input: { userName: username },\n waitInput: true,\n });\n\n useEffect(() => {\n if (error && onError) {\n onError(error);\n }\n }, [error, onError]);\n\n const politics = useMemo<PoliticsItem[]>(() => {\n const currentLimits = limits || initialLimits;\n\n return currentLimits\n ? [\n {\n name: t('maps'),\n used: currentLimits.currentProjectCount as number,\n max: currentLimits.maxProjectsCount as number,\n type: PolicyType.CreateProject,\n icon: 'map',\n },\n {\n name: t('layers'),\n used: currentLimits.currentServiceCount as number,\n max: currentLimits.maxServicesCount as number,\n type: PolicyType.CreateLayer,\n icon: 'layers',\n },\n {\n name: t('tables'),\n used: currentLimits.currentTableCount as number,\n max: currentLimits.maxTablesCount as number,\n type: PolicyType.CreateTable,\n icon: 'table',\n },\n {\n name: t('maxFeaturesInLayerLimit'),\n max: currentLimits.maxFeaturesInOneTable as number,\n type: PolicyType.MaxFeaturesInOneTable,\n icon: 'points',\n },\n {\n name: t('maxFileSize'),\n max: currentLimits.maxUploadContentSize as number,\n type: PolicyType.MaxUploadContentSize,\n icon: 'textfile',\n },\n {\n name: t('maxObjectsToExport'),\n max: currentLimits.maxObjectsToExport as number,\n type: PolicyType.MaxObjectsToExport,\n icon: 'points',\n },\n ]\n : [];\n }, [t, limits, initialLimits]);\n\n const updatePolicy: UpdatePolicy = useCallback(\n async (value, type) => {\n await (api as Api).security.setPolicy({\n value,\n type,\n role: `__${username}`,\n });\n\n await refetch();\n },\n [api]\n );\n\n return [politics, updatePolicy];\n};\n","export const numberWithSpaces = (\n input: number | string | null,\n maximumFractionDigits = 10\n): string => {\n if (input === null || input === undefined) {\n return '';\n }\n\n return parseFloat(\n (typeof input === 'string' ? parseFloat(input) : input).toString()\n ).toLocaleString('ru-RU', {\n maximumFractionDigits,\n });\n};\n","import { Flex, H2, Icon, RatioLine } from '@evergis/ui';\nimport styled from 'styled-components';\n\nexport const PoliticsContainer = styled(Flex)`\n margin-top: 3rem;\n flex-direction: column;\n`;\n\nexport const PoliticsTitle = styled(H2)`\n margin: 0;\n`;\n\nexport const PoliticsItems = styled(Flex)`\n flex-wrap: wrap;\n margin-top: 0.5rem;\n margin-bottom: 0.75rem;\n`;\n\nexport const PoliticsItemContainer = styled(Flex)`\n margin-top: 1rem;\n margin-right: 1rem;\n width: 14.5rem;\n height: 10.5rem;\n border-radius: 2px;\n background-color: #f6f6f6;\n flex-direction: column;\n`;\n\nexport const PoliticsItemContent = styled(Flex)`\n flex-direction: column;\n align-items: center;\n padding: 1rem 1rem 0;\n width: 100%;\n box-sizing: border-box;\n`;\n\nexport const PoliticsItemIcon = styled(Icon)`\n opacity: 0.28;\n`;\n\nexport const PoliticsItemLimit = styled.span`\n font-size: 18px;\n font-weight: bold;\n margin-top: 0.75rem;\n`;\n\nexport const PoliticsItemType = styled.span`\n font-size: 12px;\n color: ${({ theme: { palette } }) => palette.textSecondary};\n text-align: center;\n`;\n\nexport const PoliticsRatioContainer = styled.div`\n margin: auto 0 0;\n height: 0.5rem;\n width: 100%;\n`;\n\nexport const PoliticsRatio = styled(RatioLine)`\n width: 100%;\n margin: 0;\n`;\n\nexport const PoliticsLimit = styled(Flex)`\n flex-direction: column;\n width: 100%;\n margin-top: 0.75rem;\n background: white;\n`;\n","import { PolicyType } from '@evergis/api';\nimport { NumberInput } from '@evergis/ui';\nimport React, { FC, useCallback } from 'react';\nimport { useTranslation } from 'react-i18next';\nimport { numberWithSpaces } from '../../utils';\nimport {\n PoliticsItemContainer,\n PoliticsItemContent,\n PoliticsItemIcon,\n PoliticsItemLimit,\n PoliticsItemType,\n PoliticsLimit,\n PoliticsRatio,\n PoliticsRatioContainer,\n} from './styled';\nimport { PolicyItemProps } from './types';\n\ntype RatioLineVariant = Partial<\n Record<'primary' | 'secondary' | 'error', boolean>\n>;\n\nconst WARN_ENTITY_COUNT_THRESHOLD = 75;\nconst ERROR_ENTITY_COUNT_THRESHOLD = 90;\n\nfunction getRatioLineVariant(used: number, max: number): RatioLineVariant {\n const ratioUsed = (used / max) * 100;\n\n if (ratioUsed >= ERROR_ENTITY_COUNT_THRESHOLD) {\n return { error: true };\n }\n\n if (ratioUsed >= WARN_ENTITY_COUNT_THRESHOLD) {\n return { secondary: true };\n }\n\n return { primary: true };\n}\n\nexport const PolicyItem: FC<PolicyItemProps> = ({\n item,\n updatePolicyItem,\n canUpdate,\n}) => {\n const { t } = useTranslation('politics');\n const { name, used, max, type, disabled, icon } = item;\n const onMaxLimitChange = useCallback(\n (value: number | null) => {\n updatePolicyItem(value || 0, type);\n },\n [updatePolicyItem]\n );\n\n const maxValue =\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize\n ? (max / (1024 * 1024)).toFixed(6)\n : max;\n const formattedMaxValue = numberWithSpaces(maxValue, 6);\n\n return (\n <PoliticsItemContainer key={name}>\n <PoliticsItemContent>\n <PoliticsItemIcon kind={icon} />\n <PoliticsItemLimit>\n {used !== undefined\n ? `${used} ${t('from')} ${max === -1 ? '∞' : formattedMaxValue}`\n : `${max === -1 ? '∞' : formattedMaxValue} ${\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize ? 'mb' : ''\n }`}\n </PoliticsItemLimit>\n <PoliticsItemType>{name}</PoliticsItemType>\n {canUpdate && (\n <PoliticsLimit>\n <NumberInput\n required\n disabled={disabled}\n counter={false}\n width={'100%'}\n value={+maxValue}\n onChange={onMaxLimitChange}\n />\n </PoliticsLimit>\n )}\n </PoliticsItemContent>\n <PoliticsRatioContainer>\n {used !== undefined && (\n <PoliticsRatio\n ratio={(used / max) * 100}\n {...getRatioLineVariant(used, max)}\n />\n )}\n </PoliticsRatioContainer>\n </PoliticsItemContainer>\n );\n};\n","import React, { FC, useCallback } from 'react';\nimport { PolicyType } from '@evergis/api';\nimport { useDebouncedCallback } from '@evergis/react';\n\nimport { usePolitics } from './hooks/usePolitics';\nimport { PolicyItem } from './PolicyItem';\nimport { PoliticsContainer, PoliticsItems, PoliticsTitle } from './styled';\nimport { PoliticsProps } from './types';\n\nexport const Politics: FC<PoliticsProps> = ({\n username,\n canUpdate,\n title,\n className,\n initialLimits,\n onError,\n}) => {\n const [politics, updatePolicy] = usePolitics({\n username,\n onError,\n initialLimits,\n });\n const debounce = useDebouncedCallback(500);\n const updatePolicyItem = useCallback(\n (value: number, type: PolicyType) => {\n debounce(async () => {\n const fixedValue =\n // max file size in mb\n // @ts-ignore\n type === PolicyType.MaxUploadContentSize\n ? value * 1024 * 1024\n : value;\n\n await updatePolicy(fixedValue, type);\n });\n },\n [username]\n );\n\n return (\n <PoliticsContainer className={className}>\n {title && <PoliticsTitle>{title}</PoliticsTitle>}\n <PoliticsItems>\n {politics.map(item => (\n <PolicyItem\n key={item.name}\n canUpdate={canUpdate}\n item={item}\n updatePolicyItem={updatePolicyItem}\n />\n ))}\n </PoliticsItems>\n </PoliticsContainer>\n );\n};\n","import politics_en from './en/politics.json';\nimport politics_ru from './ru/politics.json';\n\nexport const resources = {\n en: {\n politics: politics_en,\n },\n ru: {\n politics: politics_ru,\n },\n} as const;\n"],"names":["ApiContext","createContext","ApiProvider","api","children","React","Provider","value","useApi","useContext","resource","checkLimits","evergisApi","createResource","params","data","resourceCatalog","injected","usePolitics","username","onError","initialLimits","t","useTranslation","limits","refetch","error","use","input","userName","waitInput","useEffect","politics","useMemo","currentLimits","name","used","currentProjectCount","max","maxProjectsCount","type","PolicyType","CreateProject","icon","currentServiceCount","maxServicesCount","CreateLayer","currentTableCount","maxTablesCount","CreateTable","maxFeaturesInOneTable","MaxFeaturesInOneTable","maxUploadContentSize","MaxUploadContentSize","maxObjectsToExport","MaxObjectsToExport","updatePolicy","useCallback","security","setPolicy","role","numberWithSpaces","maximumFractionDigits","undefined","parseFloat","toString","toLocaleString","PoliticsContainer","styled","Flex","PoliticsTitle","H2","PoliticsItems","PoliticsItemContainer","PoliticsItemContent","PoliticsItemIcon","Icon","PoliticsItemLimit","span","PoliticsItemType","theme","palette","textSecondary","PoliticsRatioContainer","div","PoliticsRatio","RatioLine","PoliticsLimit","WARN_ENTITY_COUNT_THRESHOLD","ERROR_ENTITY_COUNT_THRESHOLD","getRatioLineVariant","ratioUsed","secondary","primary","PolicyItem","item","updatePolicyItem","canUpdate","disabled","onMaxLimitChange","maxValue","toFixed","formattedMaxValue","key","kind","NumberInput","required","counter","width","onChange","ratio","Politics","title","className","debounce","useDebouncedCallback","fixedValue","map","resources","en","politics_en","ru","politics_ru"],"mappings":";;;;;;;;AAOA,MAAMA,UAAU,gBAAGC,aAAa,CAAkB,EAAlB,CAAhC;MAEaC,WAAW,GAAwB;MAAC;AAAEC,IAAAA,GAAF;AAAOC,IAAAA;AAAP;AAC/C,SAAOC,mBAAA,CAACL,UAAU,CAACM,QAAZ;AAAqBC,IAAAA,KAAK,EAAE;AAAEJ,MAAAA;AAAF;GAA5B,EAAsCC,QAAtC,CAAP;AACD;MAEYI,MAAM,GAAG;AACpB,SAAOC,UAAU,CAACT,UAAD,CAAjB;AACD;;ACZD,IAAIU,QAAJ;AAEA,MAAaC,WAAW,GAAIC,UAAD;AACzB,MAAI,CAACF,QAAL,EAAe;AACbA,IAAAA,QAAQ,GAAGG,cAAc,CACtBC,MAAD,IAA+B,MAAMX,GAAN,KAAc;AAC3CY,MAAAA,IAAI,EAAE,MAAMZ,GAAG,CAACa,eAAJ,CAAoBL,WAApB,CAAgCG,MAAhC;AAD+B,KAAd,CADR,EAIvB;AAAEG,MAAAA,QAAQ,EAAEL;AAAZ,KAJuB,CAAzB;AAMD;;AAED,SAAOF,QAAP;AACD,CAXM;;ACQA,MAAMQ,WAAW,GAAG;MAAC;AAC1BC,IAAAA,QAD0B;AAE1BC,IAAAA,OAF0B;AAG1BC,IAAAA;AAH0B;AAK1B,QAAM;AAAEC,IAAAA;AAAF,MAAQC,cAAc,CAAC,UAAD,CAA5B;AACA,QAAM;AAAEpB,IAAAA;AAAF,MAAUK,MAAM,EAAtB;AAEA,QAAM;AAAEO,IAAAA,IAAI,EAAES,MAAR;A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AAW,CAClC,CAAClD,KAAD,EAAgBiC,IAAhB;AACE0E,IAAAA,QAAQ,CAAC;AACP,YAAME,UAAU;AAEd;AACA5E,MAAAA,IAAI,KAAKC,UAAU,CAACY,oBAApB,GACI9C,KAAK,GAAG,IAAR,GAAe,IADnB,GAEIA,KALN;AAOA,YAAMiD,YAAY,CAAC4D,UAAD,EAAa5E,IAAb,CAAlB;AACD,KATO,CAAR;AAUD,GAZiC,EAalC,CAACrB,QAAD,CAbkC,CAApC;AAgBA,SACEd,mBAAA,CAAC8D,iBAAD;AAAmB8C,IAAAA,SAAS,EAAEA;GAA9B,EACGD,KAAK,IAAI3G,mBAAA,CAACiE,aAAD,MAAA,EAAgB0C,KAAhB,CADZ,EAEE3G,mBAAA,CAACmE,aAAD,MAAA,EACGxC,QAAQ,CAACqF,GAAT,CAAatB,IAAI,IAChB1F,mBAAA,CAACyF,UAAD;AACES,IAAAA,GAAG,EAAER,IAAI,CAAC5D;AACV8D,IAAAA,SAAS,EAAEA;AACXF,IAAAA,IAAI,EAAEA;AACNC,IAAAA,gBAAgB,EAAEA;GAJpB,CADD,CADH,CAFF,CADF;AAeD,CA7CM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MCNMsB,SAAS,GAAG;AACvBC,EAAAA,EAAE,EAAE;AACFvF,IAAAA,QAAQ,EAAEwF;AADR,GADmB;AAIvBC,EAAAA,EAAE,EAAE;AACFzF,IAAAA,QAAQ,EAAE0F;AADR;AAJmB,CAAlB;;;;"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { WorkspaceLimitsDc } from '@evergis/api';
|
|
2
|
-
import { PoliticsItem, UpdatePolicy } from '../types';
|
|
3
|
-
export declare type UsePoliticsConfig = {
|
|
4
|
-
initialLimits?: WorkspaceLimitsDc;
|
|
5
|
-
username?: string;
|
|
6
|
-
onError?: (error: any) => void;
|
|
7
|
-
};
|
|
8
|
-
export declare const usePolitics: ({ username, onError, initialLimits, }: UsePoliticsConfig) => [PoliticsItem[], UpdatePolicy];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare const PoliticsContainer: import("styled-components").StyledComponent<"div", any, import("@evergis/ui").IFlexProps, never>;
|
|
2
|
-
export declare const PoliticsTitle: import("styled-components").StyledComponent<"h2", any, {}, never>;
|
|
3
|
-
export declare const PoliticsItems: import("styled-components").StyledComponent<"div", any, import("@evergis/ui").IFlexProps, never>;
|
|
4
|
-
export declare const PoliticsItemContainer: import("styled-components").StyledComponent<"div", any, import("@evergis/ui").IFlexProps, never>;
|
|
5
|
-
export declare const PoliticsItemContent: import("styled-components").StyledComponent<"div", any, import("@evergis/ui").IFlexProps, never>;
|
|
6
|
-
export declare const PoliticsItemIcon: import("styled-components").StyledComponent<"span", any, import("@evergis/ui").IIconProps, never>;
|
|
7
|
-
export declare const PoliticsItemLimit: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
8
|
-
export declare const PoliticsItemType: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
9
|
-
export declare const PoliticsRatioContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
|
-
export declare const PoliticsRatio: import("styled-components").StyledComponent<import("react").FC<import("@evergis/ui").RatioLineProps>, any, {}, never>;
|
|
11
|
-
export declare const PoliticsLimit: import("styled-components").StyledComponent<"div", any, import("@evergis/ui").IFlexProps, never>;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { PolicyType, WorkspaceLimitsDc } from '@evergis/api';
|
|
2
|
-
import { IconTypesKeys } from '@evergis/ui';
|
|
3
|
-
export declare type PoliticsItem = {
|
|
4
|
-
name: string;
|
|
5
|
-
used?: number;
|
|
6
|
-
max: number;
|
|
7
|
-
type: PolicyType;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
icon: IconTypesKeys;
|
|
10
|
-
};
|
|
11
|
-
export declare type PoliticsProps = {
|
|
12
|
-
username?: string;
|
|
13
|
-
canUpdate: boolean;
|
|
14
|
-
title?: string;
|
|
15
|
-
className?: string;
|
|
16
|
-
initialLimits?: WorkspaceLimitsDc;
|
|
17
|
-
onError?: (error: any) => void;
|
|
18
|
-
};
|
|
19
|
-
export declare type UpdatePolicy = (value: number, type: PolicyType) => void;
|
|
20
|
-
export declare type PolicyItemProps = {
|
|
21
|
-
item: PoliticsItem;
|
|
22
|
-
updatePolicyItem: UpdatePolicy;
|
|
23
|
-
canUpdate: boolean;
|
|
24
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Politics';
|
package/dist/i18n/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare const resources: {
|
|
2
|
-
readonly en: {
|
|
3
|
-
readonly politics: {
|
|
4
|
-
maps: string;
|
|
5
|
-
layers: string;
|
|
6
|
-
maxFeaturesInLayerLimit: string;
|
|
7
|
-
maxFileSize: string;
|
|
8
|
-
tables: string;
|
|
9
|
-
in: string;
|
|
10
|
-
from: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
readonly ru: {
|
|
14
|
-
readonly politics: {
|
|
15
|
-
maps: string;
|
|
16
|
-
layers: string;
|
|
17
|
-
maxFeaturesInLayerLimit: string;
|
|
18
|
-
maxFileSize: string;
|
|
19
|
-
tables: string;
|
|
20
|
-
in: string;
|
|
21
|
-
from: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
};
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './limits';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const numberWithSpaces: (input: number | string | null, maximumFractionDigits?: number) => string;
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './formatNumber';
|