argous 1.2.164 → 1.2.167
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/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +19 -14
- package/dist/components/ArgousComplexTable/ArgousComplexTable.d.ts +1 -1
- package/dist/components/ArgousComplexTable/ArgousComplexTable.js +4 -4
- package/dist/components/FilePreparer/FilePreparer.js +15 -10
- package/lib/api/index.js +6 -4
- package/lib/components/ArgousComplexTable/ArgousComplexTable.d.ts +1 -1
- package/lib/components/ArgousComplexTable/ArgousComplexTable.js +1 -2
- package/lib/components/FilePreparer/FilePreparer.js +13 -14
- package/package.json +1 -1
package/dist/api/index.d.ts
CHANGED
|
@@ -60,4 +60,4 @@ export function getFileFromLink({ URL: link }?: {
|
|
|
60
60
|
URL?: string | undefined;
|
|
61
61
|
}): Promise<string>;
|
|
62
62
|
export function getLink(idDocumento: any, nrRevisao: any, timeout: any): Promise<any>;
|
|
63
|
-
export function scanDocument(idDocumento: any, nrRevisao: any): Promise<any>;
|
|
63
|
+
export function scanDocument(idDocumento: any, nrRevisao: any, url: any): Promise<any>;
|
package/dist/api/index.js
CHANGED
|
@@ -657,27 +657,32 @@ var searchUsers = function (data) { return __awaiter(void 0, void 0, void 0, fun
|
|
|
657
657
|
}); };
|
|
658
658
|
exports.searchUsers = searchUsers;
|
|
659
659
|
var prepareFile = function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
660
|
-
var formData, res,
|
|
661
|
-
var
|
|
662
|
-
return __generator(this, function (
|
|
663
|
-
switch (
|
|
660
|
+
var formData, _a, status, docsUrl, res, _b, _c;
|
|
661
|
+
var _d;
|
|
662
|
+
return __generator(this, function (_e) {
|
|
663
|
+
switch (_e.label) {
|
|
664
664
|
case 0:
|
|
665
665
|
formData = new FormData();
|
|
666
|
+
return [4 /*yield*/, exports.fetchToArgous('agdocsurl', {})];
|
|
667
|
+
case 1:
|
|
668
|
+
_a = _e.sent(), status = _a.status, docsUrl = _a.docsUrl;
|
|
669
|
+
if (!status)
|
|
670
|
+
return [2 /*return*/];
|
|
666
671
|
formData.append('blob', file);
|
|
667
|
-
return [4 /*yield*/, fetch(
|
|
672
|
+
return [4 /*yield*/, fetch(docsUrl + "/argous/docs/upload.agdoc", {
|
|
668
673
|
method: 'POST',
|
|
669
674
|
headers: exports.headers(),
|
|
670
675
|
body: formData
|
|
671
676
|
})];
|
|
672
|
-
case 1:
|
|
673
|
-
res = _d.sent();
|
|
674
|
-
_a = [{}];
|
|
675
|
-
return [4 /*yield*/, res.json()];
|
|
676
677
|
case 2:
|
|
677
|
-
|
|
678
|
-
|
|
678
|
+
res = _e.sent();
|
|
679
|
+
_b = [{}];
|
|
680
|
+
return [4 /*yield*/, res.json()];
|
|
681
|
+
case 3:
|
|
682
|
+
_c = [__assign.apply(void 0, _b.concat([_e.sent()]))];
|
|
683
|
+
_d = { lastModified: file.lastModified, lastModifiedDate: file.lastModifiedDate, name: file.name, size: file.size, type: file.type, webkitRelativePath: file.webkitRelativePath };
|
|
679
684
|
return [4 /*yield*/, file.arrayBuffer()];
|
|
680
|
-
case
|
|
685
|
+
case 4: return [2 /*return*/, __assign.apply(void 0, _c.concat([(_d.arrayBuffer = _e.sent(), _d)]))];
|
|
681
686
|
}
|
|
682
687
|
});
|
|
683
688
|
}); };
|
|
@@ -743,11 +748,11 @@ var getLink = function (idDocumento, nrRevisao, timeout) { return __awaiter(void
|
|
|
743
748
|
});
|
|
744
749
|
}); };
|
|
745
750
|
exports.getLink = getLink;
|
|
746
|
-
var scanDocument = function (idDocumento, nrRevisao) { return __awaiter(void 0, void 0, void 0, function () {
|
|
751
|
+
var scanDocument = function (idDocumento, nrRevisao, url) { return __awaiter(void 0, void 0, void 0, function () {
|
|
747
752
|
var res;
|
|
748
753
|
return __generator(this, function (_a) {
|
|
749
754
|
switch (_a.label) {
|
|
750
|
-
case 0: return [4 /*yield*/, fetch(
|
|
755
|
+
case 0: return [4 /*yield*/, fetch(url + "argous/docs/scan.agdoc", {
|
|
751
756
|
method: 'post',
|
|
752
757
|
headers: exports.headers(),
|
|
753
758
|
body: JSON.stringify({ idDocumento: idDocumento, nrRevisao: nrRevisao })
|
|
@@ -165,13 +165,13 @@ var initialState = function (defaultRowsPerPage) { return ({
|
|
|
165
165
|
loading: false
|
|
166
166
|
}); };
|
|
167
167
|
var ArgousComplexTable = react_1.forwardRef(function (_a, ref) {
|
|
168
|
-
var _b = _a.ToolbarComponent, ToolbarComponent = _b === void 0 ? __1.ArgousComplexTableToolbar : _b, _c = _a.HeadComponent, HeadComponent = _c === void 0 ? __1.ArgousComplexTableHead : _c, _d = _a.BodyComponent, BodyComponent = _d === void 0 ? __1.ArgousComplexTableBody : _d, _e = _a.PaginationComponent, PaginationComponent = _e === void 0 ? __1.ArgousComplexPagination : _e, _f = _a.
|
|
168
|
+
var _b = _a.ToolbarComponent, ToolbarComponent = _b === void 0 ? __1.ArgousComplexTableToolbar : _b, _c = _a.HeadComponent, HeadComponent = _c === void 0 ? __1.ArgousComplexTableHead : _c, _d = _a.BodyComponent, BodyComponent = _d === void 0 ? __1.ArgousComplexTableBody : _d, _e = _a.PaginationComponent, PaginationComponent = _e === void 0 ? __1.ArgousComplexPagination : _e, _f = _a.FooterComponent, FooterComponent = _f === void 0 ? undefined : _f, footerProps = _a.footerProps, dados = _a.dados, _g = _a.head, head = _g === void 0 ? [] : _g, _h = _a.line, line = _h === void 0 ? function (i) { return i; } : _h, actions = _a.actions, title = _a.title, _j = _a.defaultRowsPerPage, defaultRowsPerPage = _j === void 0 ? 10 : _j, _k = _a.rowsPerPageOptions, rowsPerPageOptions = _k === void 0 ? [10, 25, 50] : _k, checkEnabled = _a.enableCheck, disableCheckIf = _a.disableCheckIf, showCount = _a.showCount, lineStyle = _a.lineStyle, _l = _a.lineClass, lineClass = _l === void 0 ? function () { return undefined; } : _l, onClick = _a.onClick, onDoubleClick = _a.onDoubleClick, _m = _a.children, children = _m === void 0 ? undefined : _m, style = _a.style, className = _a.className, columnStyles = _a.columnStyles, headerColumnStyles = _a.headerColumnStyles, columnOptions = _a.columnOptions, disableFilter = _a.disableFilter, _o = _a.filterLabel, filterLabel = _o === void 0 ? 'Filtro' : _o, _p = _a.indexToSelect, indexToSelect = _p === void 0 ? 0 : _p, _q = _a.disableSorting, disableSorting = _q === void 0 ? [] : _q, _r = _a.size, size = _r === void 0 ? 'small' : _r, onOpen = _a.onOpen, lineTitle = _a.lineTitle, onClose = _a.onClose, method = _a.method, methodPrms = _a.methodPrms, _s = _a.methodResultList, methodResultList = _s === void 0 ? 'lista' : _s, onMethodResponse = _a.onMethodResponse, field = _a.field, fixedToolbar = _a.fixedToolbar, onSelect = _a.onSelect, customKey = _a.customKey, _t = _a.columnProps, columnProps = _t === void 0 ? function () { return ''; } : _t, _u = _a.rowProps, rowProps = _u === void 0 ? function () { return ''; } : _u, _v = _a.savedState, savedState = _v === void 0 ? {} : _v, containerProps = _a.containerProps, _w = _a.onClickAway, onClickAway = _w === void 0 ? function () { return undefined; } : _w, enableCheckIfSelected = _a.enableCheckIfSelected, enableDrag = _a.enableDrag, onDrop = _a.onDrop, tableProps = _a.tableProps, toolbarProps = _a.toolbarProps;
|
|
169
169
|
var classes = useStyles();
|
|
170
|
-
var
|
|
170
|
+
var _x = react_1.useReducer(reducer, initialState(defaultRowsPerPage)), state = _x[0], dispatch = _x[1];
|
|
171
171
|
var memoState = react_1.useMemo(function () { return (__assign(__assign({}, state), { dispatch: dispatch })); }, [state, dispatch]);
|
|
172
172
|
var selected = memoState.selected, page = memoState.page, rowsPerPage = memoState.rowsPerPage, order = memoState.order, orderBy = memoState.orderBy, filter = memoState.filter, open = memoState.open;
|
|
173
|
-
var
|
|
174
|
-
var
|
|
173
|
+
var _y = react_1.useState(dados /*.map(linha => isArray(linha) ? linha : Object.values(linha))*/ || []), lista = _y[0], setLista = _y[1];
|
|
174
|
+
var _z = react_1.useState({ qtRegs: defaultRowsPerPage, pgAtl: 1 }), ctrlPgn = _z[0], setCtrlPgn = _z[1];
|
|
175
175
|
var qtRegs = ctrlPgn.qtRegs, pgAtl = ctrlPgn.pgAtl, ordCols = ctrlPgn.ordCols;
|
|
176
176
|
var enableCheck = checkEnabled || (enableCheckIfSelected && !!selected.length);
|
|
177
177
|
react_1.useEffect(function () {
|
|
@@ -189,26 +189,38 @@ var FilePreparer = function (_a, ref) {
|
|
|
189
189
|
var inputRef = react_1.useRef();
|
|
190
190
|
var _f = react_1.useState(false), loading = _f[0], setLoading = _f[1];
|
|
191
191
|
var _g = react_1.useState(initialFiles), files = _g[0], setFiles = _g[1];
|
|
192
|
+
var _h = react_1.useState(), motivo = _h[0], setMotivo = _h[1];
|
|
192
193
|
react_1.useEffect(function () {
|
|
193
194
|
if (valuePlaceHolder && !multiple)
|
|
194
195
|
setFiles(function (f) { return [__assign(__assign({}, f[0]), { name: valuePlaceHolder })]; });
|
|
195
196
|
}, [valuePlaceHolder, multiple]);
|
|
197
|
+
var handleChange = function (_, v, reason) {
|
|
198
|
+
setMotivo(reason);
|
|
199
|
+
inputRef.current.value = '';
|
|
200
|
+
setFiles(v || []);
|
|
201
|
+
onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
|
|
202
|
+
};
|
|
196
203
|
var preparaArquivo = react_1.useCallback(function (file) { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
-
var reqs, i, res, resps;
|
|
204
|
+
var resultUrl, reqs, i, res, resps;
|
|
198
205
|
return __generator(this, function (_a) {
|
|
199
206
|
switch (_a.label) {
|
|
200
207
|
case 0:
|
|
201
208
|
if (!file)
|
|
202
209
|
return [2 /*return*/];
|
|
203
210
|
setLoading(true);
|
|
211
|
+
return [4 /*yield*/, api_1.fetchToArgous('agdocsurl', {})];
|
|
212
|
+
case 1:
|
|
213
|
+
resultUrl = _a.sent();
|
|
214
|
+
if (!resultUrl.status)
|
|
215
|
+
return [2 /*return*/];
|
|
204
216
|
reqs = [];
|
|
205
217
|
if (file.map)
|
|
206
218
|
reqs = file;
|
|
207
219
|
else
|
|
208
220
|
for (i = 0; i < file.length; i++)
|
|
209
221
|
reqs.push(file[i]);
|
|
210
|
-
return [4 /*yield*/, Promise.all(reqs.map(function (item) { return api_1.prepareFile(item.fileObject || item); }))];
|
|
211
|
-
case
|
|
222
|
+
return [4 /*yield*/, Promise.all(reqs.map(function (item) { return api_1.prepareFile(item.fileObject || item, resultUrl.docsUrl); }))];
|
|
223
|
+
case 2:
|
|
212
224
|
res = _a.sent();
|
|
213
225
|
resps = [];
|
|
214
226
|
res.forEach(function (item, i) {
|
|
@@ -224,18 +236,11 @@ var FilePreparer = function (_a, ref) {
|
|
|
224
236
|
}
|
|
225
237
|
});
|
|
226
238
|
}); }, [concat, files, motivo, multiple, onChange]);
|
|
227
|
-
var _h = react_1.useState(), motivo = _h[0], setMotivo = _h[1];
|
|
228
239
|
// useUpdateEffect(() => {
|
|
229
240
|
// onChange && onChange(multiple ? files : files[0], motivo);
|
|
230
241
|
// setMotivo(undefined);
|
|
231
242
|
// }, [files]);
|
|
232
243
|
react_1.useImperativeHandle(ref, function () { return ({ preparaArquivo: preparaArquivo, loading: loading, setLoading: setLoading }); }, [preparaArquivo, loading]);
|
|
233
|
-
var handleChange = function (_, v, reason) {
|
|
234
|
-
setMotivo(reason);
|
|
235
|
-
inputRef.current.value = '';
|
|
236
|
-
setFiles(v || []);
|
|
237
|
-
onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
|
|
238
|
-
};
|
|
239
244
|
var _j = lab_1.useAutocomplete({
|
|
240
245
|
value: files,
|
|
241
246
|
inputValue: files.length ? '' : placeholder || 'Selecione um arquivo',
|
package/lib/api/index.js
CHANGED
|
@@ -335,10 +335,12 @@ export const searchUsers = async (data) => {
|
|
|
335
335
|
return await res.json();
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
-
export const prepareFile = async file => {
|
|
338
|
+
export const prepareFile = async (file) => {
|
|
339
339
|
const formData = new FormData();
|
|
340
|
+
const { status, docsUrl } = await fetchToArgous('agdocsurl', { });
|
|
341
|
+
if (!status) return;
|
|
340
342
|
formData.append('blob', file);
|
|
341
|
-
const res = await fetch(`${
|
|
343
|
+
const res = await fetch(`${docsUrl}/argous/docs/upload.agdoc`, {
|
|
342
344
|
method: 'POST',
|
|
343
345
|
headers: headers(),
|
|
344
346
|
body: formData
|
|
@@ -392,8 +394,8 @@ export const getLink = async (idDocumento, nrRevisao, timeout) => {
|
|
|
392
394
|
})).json();
|
|
393
395
|
};
|
|
394
396
|
|
|
395
|
-
export const scanDocument = async (idDocumento, nrRevisao) => {
|
|
396
|
-
const res = await fetch(`${
|
|
397
|
+
export const scanDocument = async (idDocumento, nrRevisao, url) => {
|
|
398
|
+
const res = await fetch(`${url}argous/docs/scan.agdoc`, {
|
|
397
399
|
method: 'post',
|
|
398
400
|
headers: headers(),
|
|
399
401
|
body: JSON.stringify({ idDocumento, nrRevisao })
|
|
@@ -125,7 +125,6 @@ const ArgousComplexTable = forwardRef(({
|
|
|
125
125
|
HeadComponent = ArgousComplexTableHead,
|
|
126
126
|
BodyComponent = ArgousComplexTableBody,
|
|
127
127
|
PaginationComponent = ArgousComplexPagination,
|
|
128
|
-
paginationControl = {},
|
|
129
128
|
FooterComponent = undefined,
|
|
130
129
|
footerProps,
|
|
131
130
|
dados,
|
|
@@ -181,7 +180,7 @@ const ArgousComplexTable = forwardRef(({
|
|
|
181
180
|
const { selected, page, rowsPerPage, order, orderBy, filter, open } = memoState;
|
|
182
181
|
|
|
183
182
|
const [lista, setLista] = useState(dados/*.map(linha => isArray(linha) ? linha : Object.values(linha))*/ || []);
|
|
184
|
-
const [ctrlPgn, setCtrlPgn] = useState({
|
|
183
|
+
const [ctrlPgn, setCtrlPgn] = useState({ qtRegs: defaultRowsPerPage, pgAtl: 1 });
|
|
185
184
|
const { qtRegs, pgAtl, ordCols } = ctrlPgn;
|
|
186
185
|
|
|
187
186
|
const enableCheck = checkEnabled || (enableCheckIfSelected && !!selected.length);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { prepareFile } from '../../api';
|
|
1
|
+
import { fetchToArgous, prepareFile } from '../../api';
|
|
2
2
|
import { setError } from '../../utils/api';
|
|
3
3
|
import { Chip, CircularProgress, FilledInput, IconButton, makeStyles, TextField } from '@material-ui/core';
|
|
4
4
|
import { useAutocomplete } from '@material-ui/lab';
|
|
@@ -116,18 +116,28 @@ const FilePreparer = ({
|
|
|
116
116
|
|
|
117
117
|
const [loading, setLoading] = useState(false);
|
|
118
118
|
const [files, setFiles] = useState(initialFiles);
|
|
119
|
+
const [motivo, setMotivo] = useState();
|
|
119
120
|
|
|
120
121
|
useEffect(() => {
|
|
121
122
|
if (valuePlaceHolder && !multiple) setFiles(f => [{ ...f[0], name: valuePlaceHolder }]);
|
|
122
123
|
}, [valuePlaceHolder, multiple]);
|
|
123
124
|
|
|
125
|
+
const handleChange = (_, v, reason) => {
|
|
126
|
+
setMotivo(reason);
|
|
127
|
+
inputRef.current.value = '';
|
|
128
|
+
setFiles(v || []);
|
|
129
|
+
onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
|
|
130
|
+
};
|
|
131
|
+
|
|
124
132
|
const preparaArquivo = useCallback(async file => {
|
|
125
133
|
if (!file) return;
|
|
126
134
|
setLoading(true);
|
|
135
|
+
const resultUrl = await fetchToArgous('agdocsurl', { });
|
|
136
|
+
if (!resultUrl.status) return;
|
|
127
137
|
let reqs = [];
|
|
128
138
|
if (file.map) reqs = file;
|
|
129
|
-
else for (let i = 0; i < file.length; i++) reqs.push(file[i]);
|
|
130
|
-
const res = await Promise.all(reqs.map(item => prepareFile(item.fileObject || item)));
|
|
139
|
+
else for (let i = 0; i < file.length; i++) reqs.push(file[i]);
|
|
140
|
+
const res = await Promise.all(reqs.map(item => prepareFile(item.fileObject || item, resultUrl.docsUrl)));
|
|
131
141
|
let resps = [];
|
|
132
142
|
res.forEach((item, i) => {
|
|
133
143
|
if (item.idRecebimento) resps.push({ ...item, path: file[i].fullPath });
|
|
@@ -135,26 +145,15 @@ const FilePreparer = ({
|
|
|
135
145
|
});
|
|
136
146
|
setFiles(f => concat && multiple ? ([...f, ...resps]) : resps);
|
|
137
147
|
setLoading(false);
|
|
138
|
-
|
|
139
148
|
onChange && onChange(multiple ? concat ? [...files, ...resps] : resps : resps[0], motivo);
|
|
140
149
|
}, [concat, files, motivo, multiple, onChange]);
|
|
141
150
|
|
|
142
|
-
const [motivo, setMotivo] = useState();
|
|
143
|
-
|
|
144
151
|
// useUpdateEffect(() => {
|
|
145
152
|
// onChange && onChange(multiple ? files : files[0], motivo);
|
|
146
153
|
// setMotivo(undefined);
|
|
147
154
|
// }, [files]);
|
|
148
155
|
|
|
149
156
|
useImperativeHandle(ref, () => ({ preparaArquivo, loading, setLoading }), [preparaArquivo, loading]);
|
|
150
|
-
|
|
151
|
-
const handleChange = (_, v, reason) => {
|
|
152
|
-
setMotivo(reason);
|
|
153
|
-
inputRef.current.value = '';
|
|
154
|
-
setFiles(v || []);
|
|
155
|
-
|
|
156
|
-
onChange && onChange(multiple ? v || [] : (v || [])[0], motivo);
|
|
157
|
-
};
|
|
158
157
|
|
|
159
158
|
const {
|
|
160
159
|
getInputProps,
|