argous 1.2.162 → 1.2.165

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.
@@ -37,7 +37,7 @@ export function endFileUpload(data: any): Promise<any>;
37
37
  export function cancelFileUpload(data: any): Promise<any>;
38
38
  export function getFileInfo(data: any): Promise<any>;
39
39
  export function searchUsers(data: any): Promise<any>;
40
- export function prepareFile(file: any): Promise<any>;
40
+ export function prepareFile(file: any, url: any): Promise<any>;
41
41
  export function createDocument({ idUnidade, cdUnidade, idDocPai, path, dsKeyWords, dtValidade, idTipoDocumento, FileName, title, idRecebimento, tpPrivacidade, description, dsClassificacao, dsCategoria, dsSubCategoria, snSensivel }: {
42
42
  idUnidade: any;
43
43
  cdUnidade: any;
@@ -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
@@ -656,7 +656,7 @@ var searchUsers = function (data) { return __awaiter(void 0, void 0, void 0, fun
656
656
  });
657
657
  }); };
658
658
  exports.searchUsers = searchUsers;
659
- var prepareFile = function (file) { return __awaiter(void 0, void 0, void 0, function () {
659
+ var prepareFile = function (file, url) { return __awaiter(void 0, void 0, void 0, function () {
660
660
  var formData, res, _a, _b;
661
661
  var _c;
662
662
  return __generator(this, function (_d) {
@@ -664,7 +664,7 @@ var prepareFile = function (file) { return __awaiter(void 0, void 0, void 0, fun
664
664
  case 0:
665
665
  formData = new FormData();
666
666
  formData.append('blob', file);
667
- return [4 /*yield*/, fetch(exports.api() + "docs/upload.agdoc", {
667
+ return [4 /*yield*/, fetch(url + "/argous/docs/upload.agdoc", {
668
668
  method: 'POST',
669
669
  headers: exports.headers(),
670
670
  body: formData
@@ -743,11 +743,11 @@ var getLink = function (idDocumento, nrRevisao, timeout) { return __awaiter(void
743
743
  });
744
744
  }); };
745
745
  exports.getLink = getLink;
746
- var scanDocument = function (idDocumento, nrRevisao) { return __awaiter(void 0, void 0, void 0, function () {
746
+ var scanDocument = function (idDocumento, nrRevisao, url) { return __awaiter(void 0, void 0, void 0, function () {
747
747
  var res;
748
748
  return __generator(this, function (_a) {
749
749
  switch (_a.label) {
750
- case 0: return [4 /*yield*/, fetch(exports.api() + "docs/scan.agdoc", {
750
+ case 0: return [4 /*yield*/, fetch(url + "argous/docs/scan.agdoc", {
751
751
  method: 'post',
752
752
  headers: exports.headers(),
753
753
  body: JSON.stringify({ idDocumento: idDocumento, nrRevisao: nrRevisao })
@@ -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 1:
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',
@@ -46,8 +46,14 @@ export interface StepperTypeMap<P ={}, D extends React.ElementType = 'div'> {
46
46
  disableActions?: boolean;
47
47
  /**
48
48
  * Orientação do Stepper
49
+ * default: horizontal
50
+ * opções: horizontal ou vertical
49
51
  */
50
52
  orientation?: string;
53
+ /**
54
+ * Mostra o progresso percorrido
55
+ */
56
+ showProgress?: boolean;
51
57
  };
52
58
  defaultComponent: D;
53
59
  classKey: StepperClassKey;
@@ -53,9 +53,10 @@ var ColorlibConnector = core_1.withStyles(function (theme) { return ({
53
53
  alternativeLabel: function (_a) {
54
54
  var orientation = _a.orientation;
55
55
  return orientation === 'vertical' ? {
56
- top: -30,
56
+ top: -28,
57
57
  transform: 'rotate(90deg)',
58
- left: 'calc(-50% + 50px)',
58
+ left: 'calc(-50% + 40px)',
59
+ right: 'calc(50% + 10px)',
59
60
  '&>span': {
60
61
  minHeight: 3
61
62
  }
@@ -158,7 +159,12 @@ var stepperStyles = function (theme) {
158
159
  selectedCaption: {
159
160
  color: theme.palette.text.secondary
160
161
  },
161
- stepper: (_a = {},
162
+ stepper: (_a = {
163
+ padding: function (_a) {
164
+ var orientation = _a.orientation;
165
+ return orientation === 'vertical' ? '0 0 0 136px' : '';
166
+ }
167
+ },
162
168
  _a[theme.breakpoints.down('sm')] = {
163
169
  padding: 0
164
170
  },
@@ -184,8 +190,8 @@ var stepperStyles = function (theme) {
184
190
  alignItems: 'center',
185
191
  justifyContent: 'end',
186
192
  position: 'absolute',
187
- top: 'calc(50% - 24px)',
188
- left: 'calc(-50% - 83px)',
193
+ top: 17,
194
+ left: -148,
189
195
  },
190
196
  icon: {
191
197
  fontSize: theme.typography.fontSize * 2,
@@ -201,20 +207,26 @@ var stepperStyles = function (theme) {
201
207
  margin: function (_a) {
202
208
  var orientation = _a.orientation;
203
209
  return orientation === 'vertical' ? '0 0 0 8px' : '';
210
+ },
211
+ '&>span:nth-child(1)': {
212
+ margin: function (_a) {
213
+ var orientation = _a.orientation;
214
+ return orientation === 'vertical' ? 0 : '';
215
+ }
204
216
  }
205
- }
217
+ },
206
218
  }
207
219
  });
208
220
  };
209
221
  var Stepper = function (_a) {
210
222
  var children = _a.children, _b = _a.classes, classes = _b === void 0 ? {} : _b, _c = _a.steps, steps = _c === void 0 ? [] : _c, _d = _a.onClick, onClick = _d === void 0 ? function (index) { return function (event) { return void (index, event); }; } : _d, _e = _a.onNext, onNext = _e === void 0 ? function (event) { return void (event); } : _e, _f = _a.onPrevious, onPrevious = _f === void 0 ? function (event) { return void (event); } : _f, _g = _a.onFinish, onFinish = _g === void 0 ? function (event) { return void (event); } : _g, maxStepProps = _a.maxStep, _h = _a.activeStep, activeStep = _h === void 0 ? 0 : _h, _j = _a.errors, errors = _j === void 0 ? [] : _j, _k = _a.component, Component = _k === void 0 ? 'div' : _k, _l = _a.backLabel, backLabel = _l === void 0 ? 'Voltar' : _l, _m = _a.nextLabel, nextLabel = _m === void 0 ? 'Avançar' : _m, _o = _a.finishLabel, finishLabel = _o === void 0 ? 'Finalizar' : _o, _p = _a.disableFinish, disableFinish = _p === void 0 ? false : _p, _q = _a.disableNext, disableNext = _q === void 0 ? false : _q, _r = _a.disablePrevious, disablePrevious = _r === void 0 ? false : _r, _s = _a.showProgress, showProgress = _s === void 0 ? false : _s, _t = _a.disableActions, disableActions = _t === void 0 ? false : _t, _u = _a.orientation, orientation = _u === void 0 ? 'horizontal' : _u, props = __rest(_a, ["children", "classes", "steps", "onClick", "onNext", "onPrevious", "onFinish", "maxStep", "activeStep", "errors", "component", "backLabel", "nextLabel", "finishLabel", "disableFinish", "disableNext", "disablePrevious", "showProgress", "disableActions", "orientation"]);
223
+ var theme = core_1.useTheme();
211
224
  var maxSteps = steps.length;
212
225
  var maxStep = maxStepProps || steps.length - 1;
226
+ var mobile = core_1.useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
227
+ var ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
213
228
  var _v = react_1.useState(-1), initialStep = _v[0], setInitialStep = _v[1];
214
229
  react_1.useEffect(function () { return (activeStep > initialStep && showProgress) && setInitialStep(activeStep); }, [activeStep, initialStep, showProgress]);
215
- var ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
216
- var theme = core_1.useTheme();
217
- var mobile = core_1.useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
218
230
  return react_1.default.createElement(Component, __assign({}, props),
219
231
  mobile && orientation !== 'vertical' ? (react_1.default.createElement(core_1.Paper, { square: true, elevation: 0 },
220
232
  react_1.default.createElement(core_1.ListItem, { dense: true, className: classes.header },
package/lib/api/index.js CHANGED
@@ -335,10 +335,10 @@ 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, url) => {
339
339
  const formData = new FormData();
340
340
  formData.append('blob', file);
341
- const res = await fetch(`${api()}docs/upload.agdoc`, {
341
+ const res = await fetch(`${url}/argous/docs/upload.agdoc`, {
342
342
  method: 'POST',
343
343
  headers: headers(),
344
344
  body: formData
@@ -392,8 +392,8 @@ export const getLink = async (idDocumento, nrRevisao, timeout) => {
392
392
  })).json();
393
393
  };
394
394
 
395
- export const scanDocument = async (idDocumento, nrRevisao) => {
396
- const res = await fetch(`${api()}docs/scan.agdoc`, {
395
+ export const scanDocument = async (idDocumento, nrRevisao, url) => {
396
+ const res = await fetch(`${url}argous/docs/scan.agdoc`, {
397
397
  method: 'post',
398
398
  headers: headers(),
399
399
  body: JSON.stringify({ idDocumento, nrRevisao })
@@ -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,
@@ -46,8 +46,14 @@ export interface StepperTypeMap<P ={}, D extends React.ElementType = 'div'> {
46
46
  disableActions?: boolean;
47
47
  /**
48
48
  * Orientação do Stepper
49
+ * default: horizontal
50
+ * opções: horizontal ou vertical
49
51
  */
50
52
  orientation?: string;
53
+ /**
54
+ * Mostra o progresso percorrido
55
+ */
56
+ showProgress?: boolean;
51
57
  };
52
58
  defaultComponent: D;
53
59
  classKey: StepperClassKey;
@@ -6,9 +6,10 @@ import { MdCheck, MdChevronLeft, MdChevronRight } from 'react-icons/md';
6
6
 
7
7
  const ColorlibConnector = withStyles(theme => ({
8
8
  alternativeLabel: ({ orientation }) => orientation === 'vertical' ? {
9
- top: -30,
9
+ top: -28,
10
10
  transform: 'rotate(90deg)',
11
- left: 'calc(-50% + 50px)',
11
+ left: 'calc(-50% + 40px)',
12
+ right: 'calc(50% + 10px)',
12
13
  '&>span': {
13
14
  minHeight: 3
14
15
  }
@@ -105,6 +106,7 @@ const stepperStyles = theme => ({
105
106
  color: theme.palette.text.secondary
106
107
  },
107
108
  stepper: {
109
+ padding: ({ orientation }) => orientation === 'vertical' ? '0 0 0 136px' : '',
108
110
  [theme.breakpoints.down('sm')]: {
109
111
  padding: 0
110
112
  },
@@ -124,8 +126,8 @@ const stepperStyles = theme => ({
124
126
  alignItems: 'center',
125
127
  justifyContent: 'end',
126
128
  position: 'absolute',
127
- top: 'calc(50% - 24px)',
128
- left: 'calc(-50% - 83px)',
129
+ top: 17,
130
+ left: -148,
129
131
  },
130
132
  icon: {
131
133
  fontSize: theme.typography.fontSize * 2,
@@ -138,8 +140,11 @@ const stepperStyles = theme => ({
138
140
  },
139
141
  stepLabel: {
140
142
  '&>span:nth-child(2)': {
141
- margin: ({ orientation }) => orientation === 'vertical' ? '0 0 0 8px' : ''
142
- }
143
+ margin: ({ orientation }) => orientation === 'vertical' ? '0 0 0 8px' : '',
144
+ '&>span:nth-child(1)': {
145
+ margin: ({ orientation }) => orientation === 'vertical' ? 0 : ''
146
+ }
147
+ },
143
148
  }
144
149
  });
145
150
 
@@ -166,17 +171,14 @@ const Stepper = ({
166
171
  orientation = 'horizontal',
167
172
  ...props
168
173
  }) => {
174
+ const theme = useTheme();
169
175
  const maxSteps = steps.length;
170
176
  const maxStep = maxStepProps || steps.length - 1;
171
-
177
+ const mobile = useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
178
+ const ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
172
179
  const [initialStep, setInitialStep] = useState(-1);
173
180
  useEffect(() => (activeStep > initialStep && showProgress) && setInitialStep(activeStep), [activeStep, initialStep, showProgress]);
174
181
 
175
- const ambienteTeste = JSON.parse(window.localStorage.getItem('ambienteTeste'));
176
-
177
- const theme = useTheme();
178
- const mobile = useMediaQuery(theme.breakpoints.down(Math.max(maxSteps * 100, theme.breakpoints.values.sm)));
179
-
180
182
  return <Component {...props}>
181
183
  {mobile && orientation !== 'vertical' ? (
182
184
  <Paper square elevation={0}>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argous",
3
- "version": "1.2.162",
3
+ "version": "1.2.165",
4
4
  "description": "Argous.",
5
5
  "main": "lib/index.js",
6
6
  "author": "Carlos Schneider",