argous 1.2.222 → 1.2.224

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.
Files changed (129) hide show
  1. package/dist/api/index.d.ts +2 -0
  2. package/dist/api/index.js +36 -1
  3. package/dist/components/ArgousComplexTable/ArgousComplexTable.d.ts +9 -1
  4. package/dist/components/ArgousComplexTable/ArgousComplexTable.js +7 -7
  5. package/dist/components/BarraFerramentas/BarraFerramentas.d.ts +4 -1
  6. package/dist/components/BarraFerramentas/BarraFerramentas.js +48 -26
  7. package/dist/components/Document/Icons.d.ts +193 -0
  8. package/dist/components/Document/Icons.js +269 -0
  9. package/dist/components/Document/ModalVisualizacaoDocumentos.d.ts +8 -0
  10. package/dist/components/Document/ModalVisualizacaoDocumentos.js +84 -0
  11. package/dist/components/Document/Visualizacao.d.ts +12 -0
  12. package/dist/components/Document/Visualizacao.js +205 -0
  13. package/dist/components/Document/icons/ai.svg +20 -0
  14. package/dist/components/Document/icons/audio.svg +16 -0
  15. package/dist/components/Document/icons/avi.svg +15 -0
  16. package/dist/components/Document/icons/css.svg +47 -0
  17. package/dist/components/Document/icons/csv.svg +37 -0
  18. package/dist/components/Document/icons/dbf.svg +30 -0
  19. package/dist/components/Document/icons/doc.svg +47 -0
  20. package/dist/components/Document/icons/dwg.svg +32 -0
  21. package/dist/components/Document/icons/exe.svg +20 -0
  22. package/dist/components/Document/icons/file.svg +11 -0
  23. package/dist/components/Document/icons/fla.svg +23 -0
  24. package/dist/components/Document/icons/html.svg +23 -0
  25. package/dist/components/Document/icons/image.svg +16 -0
  26. package/dist/components/Document/icons/iso.svg +40 -0
  27. package/dist/components/Document/icons/jpg.svg +33 -0
  28. package/dist/components/Document/icons/js.svg +40 -0
  29. package/dist/components/Document/icons/json.svg +45 -0
  30. package/dist/components/Document/icons/mod.svg +41 -0
  31. package/dist/components/Document/icons/mp3.svg +36 -0
  32. package/dist/components/Document/icons/mp4.svg +25 -0
  33. package/dist/components/Document/icons/pdf.svg +35 -0
  34. package/dist/components/Document/icons/png.svg +30 -0
  35. package/dist/components/Document/icons/ppt.svg +31 -0
  36. package/dist/components/Document/icons/psd.svg +50 -0
  37. package/dist/components/Document/icons/rtf.svg +35 -0
  38. package/dist/components/Document/icons/search.svg +20 -0
  39. package/dist/components/Document/icons/svg.svg +34 -0
  40. package/dist/components/Document/icons/txt.svg +29 -0
  41. package/dist/components/Document/icons/video.svg +17 -0
  42. package/dist/components/Document/icons/xls.svg +31 -0
  43. package/dist/components/Document/icons/xml.svg +25 -0
  44. package/dist/components/Document/icons/zip.svg +24 -0
  45. package/dist/components/Document/icons/zip1.svg +18 -0
  46. package/dist/components/Document/index.d.ts +3 -0
  47. package/dist/components/Document/index.js +21 -0
  48. package/dist/components/Programa/Annotations/Annotation.d.ts +19 -0
  49. package/dist/components/Programa/Annotations/Annotation.js +316 -0
  50. package/dist/components/Programa/Annotations/AnnotationsList.d.ts +3 -0
  51. package/dist/components/Programa/Annotations/AnnotationsList.js +50 -0
  52. package/dist/components/Programa/Annotations/Input/FileInput.d.ts +6 -0
  53. package/dist/components/Programa/Annotations/Input/FileInput.js +147 -0
  54. package/dist/components/Programa/Annotations/Input/Input.d.ts +3 -0
  55. package/dist/components/Programa/Annotations/Input/Input.js +218 -0
  56. package/dist/components/Programa/Annotations/Input/PrivacySelection.d.ts +7 -0
  57. package/dist/components/Programa/Annotations/Input/PrivacySelection.js +65 -0
  58. package/dist/components/Programa/Annotations/Input/ReplyInformation.d.ts +5 -0
  59. package/dist/components/Programa/Annotations/Input/ReplyInformation.js +78 -0
  60. package/dist/components/Programa/Annotations/Input/UsersAutocomplete.d.ts +7 -0
  61. package/dist/components/Programa/Annotations/Input/UsersAutocomplete.js +139 -0
  62. package/dist/components/Programa/Annotations/index.d.ts +23 -0
  63. package/dist/components/Programa/Annotations/index.js +195 -0
  64. package/dist/components/Programa/Annotations/utils.d.ts +18 -0
  65. package/dist/components/Programa/Annotations/utils.js +46 -0
  66. package/dist/components/Programa/Programa.d.ts +3 -1
  67. package/dist/components/Programa/Programa.js +20 -6
  68. package/dist/components/index.d.ts +3 -1
  69. package/dist/components/index.js +1 -0
  70. package/dist/utils/index.d.ts +47 -0
  71. package/dist/utils/index.js +104 -4
  72. package/lib/api/index.js +24 -6
  73. package/lib/components/ArgousComplexTable/ArgousComplexTable.d.ts +9 -1
  74. package/lib/components/ArgousComplexTable/ArgousComplexTable.js +6 -4
  75. package/lib/components/BarraFerramentas/BarraFerramentas.d.ts +4 -1
  76. package/lib/components/BarraFerramentas/BarraFerramentas.js +92 -50
  77. package/lib/components/Document/Icons.js +169 -0
  78. package/lib/components/Document/ModalVisualizacaoDocumentos.js +64 -0
  79. package/lib/components/Document/Visualizacao.js +104 -0
  80. package/lib/components/Document/icons/ai.svg +20 -0
  81. package/lib/components/Document/icons/audio.svg +16 -0
  82. package/lib/components/Document/icons/avi.svg +15 -0
  83. package/lib/components/Document/icons/css.svg +47 -0
  84. package/lib/components/Document/icons/csv.svg +37 -0
  85. package/lib/components/Document/icons/dbf.svg +30 -0
  86. package/lib/components/Document/icons/doc.svg +47 -0
  87. package/lib/components/Document/icons/dwg.svg +32 -0
  88. package/lib/components/Document/icons/exe.svg +20 -0
  89. package/lib/components/Document/icons/file.svg +11 -0
  90. package/lib/components/Document/icons/fla.svg +23 -0
  91. package/lib/components/Document/icons/html.svg +23 -0
  92. package/lib/components/Document/icons/image.svg +16 -0
  93. package/lib/components/Document/icons/iso.svg +40 -0
  94. package/lib/components/Document/icons/jpg.svg +33 -0
  95. package/lib/components/Document/icons/js.svg +40 -0
  96. package/lib/components/Document/icons/json.svg +45 -0
  97. package/lib/components/Document/icons/mod.svg +41 -0
  98. package/lib/components/Document/icons/mp3.svg +36 -0
  99. package/lib/components/Document/icons/mp4.svg +25 -0
  100. package/lib/components/Document/icons/pdf.svg +35 -0
  101. package/lib/components/Document/icons/png.svg +30 -0
  102. package/lib/components/Document/icons/ppt.svg +31 -0
  103. package/lib/components/Document/icons/psd.svg +50 -0
  104. package/lib/components/Document/icons/rtf.svg +35 -0
  105. package/lib/components/Document/icons/search.svg +20 -0
  106. package/lib/components/Document/icons/svg.svg +34 -0
  107. package/lib/components/Document/icons/txt.svg +29 -0
  108. package/lib/components/Document/icons/video.svg +17 -0
  109. package/lib/components/Document/icons/xls.svg +31 -0
  110. package/lib/components/Document/icons/xml.svg +25 -0
  111. package/lib/components/Document/icons/zip.svg +24 -0
  112. package/lib/components/Document/icons/zip1.svg +18 -0
  113. package/lib/components/Document/index.d.ts +3 -0
  114. package/lib/components/Document/index.js +3 -0
  115. package/lib/components/Programa/Annotations/Annotation.js +274 -0
  116. package/lib/components/Programa/Annotations/AnnotationsList.js +30 -0
  117. package/lib/components/Programa/Annotations/Input/FileInput.js +96 -0
  118. package/lib/components/Programa/Annotations/Input/Input.js +190 -0
  119. package/lib/components/Programa/Annotations/Input/PrivacySelection.js +72 -0
  120. package/lib/components/Programa/Annotations/Input/ReplyInformation.js +86 -0
  121. package/lib/components/Programa/Annotations/Input/UsersAutocomplete.js +122 -0
  122. package/lib/components/Programa/Annotations/index.js +136 -0
  123. package/lib/components/Programa/Annotations/utils.js +30 -0
  124. package/lib/components/Programa/Programa.d.ts +3 -1
  125. package/lib/components/Programa/Programa.js +20 -5
  126. package/lib/components/index.d.ts +3 -1
  127. package/lib/components/index.js +3 -1
  128. package/lib/utils/index.ts +112 -0
  129. package/package.json +3 -1
@@ -176,7 +176,9 @@ const ArgousComplexTable = forwardRef(({
176
176
  tableProps,
177
177
  toolbarProps,
178
178
  externalCtrlPgn,
179
- setExternalCtrlPgn
179
+ setExternalCtrlPgn,
180
+ code = '',
181
+ token = ''
180
182
  }, ref) => {
181
183
  const classes = useStyles();
182
184
  const [state, dispatch] = useReducer(reducer, initialState(defaultRowsPerPage));
@@ -222,15 +224,15 @@ const ArgousComplexTable = forwardRef(({
222
224
  tpOrdem: orderBy >= 0 ? (order === 'asc' ? 'A' : 'D') : undefined,
223
225
  indOrdem: orderBy >= 0 ? orderBy : undefined
224
226
  }, ...methodPrms
225
- }, handleMethodError);
226
- onMethodResponse && onMethodResponse(res);
227
+ }, code, handleMethodError, token);
228
+ onMethodResponse && onMethodResponse(res);
227
229
  if (res.status) {
228
230
  setCtrlPgn({ ...res.ctrlPgn, recordCount: (res.ctrlPgn?.qtPaginas * res.ctrlPgn?.qtRegs) });
229
231
  setLista(res[methodResultList] || []);
230
232
  }
231
233
  dispatch({ type: 'setLoading', value: false });
232
234
  // eslint-disable-next-line react-hooks/exhaustive-deps
233
- }, [method, allowMethodRequest, qtRegs, pgAtl, retornaAcao, ctrlPgn.pgAtl, page, orderBy, order, methodPrms, handleMethodError, methodResultList]);
235
+ }, [method, allowMethodRequest, qtRegs, pgAtl, retornaAcao, ctrlPgn.pgAtl, page, orderBy, order, methodPrms, handleMethodError, methodResultList, code, token]);
234
236
 
235
237
  useEffect(() => {
236
238
  buscaMetodo();
@@ -15,7 +15,10 @@ export interface BarraFerramentasProps {
15
15
  nmExclui?: string,
16
16
  executaFuncao?: (prm: string) => void,
17
17
  habWidget?: boolean,
18
- addWidget?: () => void
18
+ addWidget?: () => void,
19
+ snAnotacaoPrograma: boolean,
20
+ openAnnotations: (event: Event) => void,
21
+ toolbarLoading: object
19
22
  }
20
23
 
21
24
  declare function BarraFerramentas(props: BarraFerramentasProps): JSX.Element
@@ -1,14 +1,15 @@
1
1
  import { Compartilhar } from '..';
2
2
  import ThreadLog from '../../components/ThreadLog';
3
3
  import { usePrevious } from '../../utils';
4
- import { Box, ClickAwayListener, Collapse, Divider, IconButton, makeStyles, MenuItem, MenuList, Paper, Popper, Toolbar, Tooltip, Typography } from '@material-ui/core';
4
+ import { Box, CircularProgress, ClickAwayListener, Collapse, Divider, IconButton, makeStyles, MenuItem, MenuList, Paper, Popper, Toolbar, Tooltip, Typography, withStyles } from '@material-ui/core';
5
5
  import clsx from 'clsx';
6
6
  import { isArray, isNumber, isString, isEqual, isFunction } from 'lodash';
7
7
  import PropTypes from 'prop-types';
8
8
  import React, { useEffect, useRef, useState } from 'react';
9
9
  import { AiOutlineAppstoreAdd } from 'react-icons/ai';
10
10
  import { FaStar } from 'react-icons/fa';
11
- import { MdShare, MdFormatListBulleted, MdArrowBack, MdEdit, MdDelete, MdSave, MdKeyboardArrowRight, MdFirstPage, MdKeyboardArrowLeft, MdLastPage } from 'react-icons/md';
11
+ import { MdShare, MdFormatListBulleted, MdArrowBack, MdEdit, MdDelete, MdSave, MdKeyboardArrowRight, MdFirstPage, MdKeyboardArrowLeft, MdLastPage, MdEditNote } from 'react-icons/md';
12
+
12
13
 
13
14
  const useStyles = makeStyles(theme => ({
14
15
  root: {
@@ -49,7 +50,32 @@ const useStyles = makeStyles(theme => ({
49
50
  }
50
51
  }));
51
52
 
52
- function BarraFerramentas ({
53
+ const ToolbarTooltip = withStyles({
54
+ popper: {
55
+ zIndex: 1300
56
+ }
57
+ })(Tooltip);
58
+
59
+
60
+ const CustomTooltip = ({ disabled, arrow, placement, title, children }) => {
61
+ const [open, setOpen] = useState(false);
62
+ useEffect(() => (disabled && open) && setOpen(false), [disabled, open]);
63
+ return (
64
+ <ToolbarTooltip
65
+ {...{ arrow, placement, title }}
66
+ onOpen={() => (!disabled) && setOpen(true)}
67
+ onClose={() => setOpen(false)}
68
+ open={open}
69
+ >
70
+ {children}
71
+ </ToolbarTooltip>
72
+ );
73
+ };
74
+
75
+ const ButtonLoadingFeedback = ({ size = 24, color = 'secondary' }) => <CircularProgress {...{ size, color }} />;
76
+
77
+
78
+ function BarraFerramentas ({
53
79
  titulo,
54
80
  abas = [],
55
81
  ferramentas = [],
@@ -65,12 +91,16 @@ function BarraFerramentas ({
65
91
  linkCompartilhamento = '',
66
92
  threads,
67
93
  currentProgram,
68
- nmSalva,
69
- nmExclui,
94
+ nmSalva,
95
+ nmExclui,
70
96
  executaFuncao = prm => void(prm),
71
97
  habWidget = false,
72
- addWidget = () => ''
98
+ addWidget = () => '',
99
+ snAnotacaoPrograma = false,
100
+ openAnnotations = () => '',
101
+ toolbarLoading = {}
73
102
  }) {
103
+
74
104
  const classes = useStyles({ habNavegador });
75
105
  const anchorMenu = useRef(null);
76
106
  const anchorCompartilhar = useRef(null);
@@ -80,6 +110,7 @@ function BarraFerramentas ({
80
110
  const [habSalvar, setHabSalvar] = useState(false);
81
111
  const [habExcluir, setHabExcluir] = useState(false);
82
112
  const [openCompartilhar, setOpenCompartilhar] = useState(false);
113
+ const [disableTooltip, setDisableTooltip] = useState(false);
83
114
 
84
115
  useEffect(() => {
85
116
  if (anchorMenu.current) anchorMenu.current.focus();
@@ -127,9 +158,15 @@ function BarraFerramentas ({
127
158
  }
128
159
  }
129
160
 
161
+ function handleAnnotationsClick(event) {
162
+ setDisableTooltip(true);
163
+ openAnnotations(event);
164
+ setTimeout(() => setDisableTooltip(false), 0);
165
+ }
166
+
130
167
  const getFerramentas = (item, index) => {
131
168
  return (
132
- <Tooltip key={index} title={item[1] || ''}>
169
+ <CustomTooltip key={index} title={item[1] || ''}>
133
170
  <IconButton onClick={() => isFunction(item[2]) ? item[2]() : executaFuncao(item[2] || 'F' + index)}>
134
171
  {typeof item[0] === 'string' ? (
135
172
  <i style={{ color: '#999' }} className={item[0]}></i>
@@ -137,7 +174,7 @@ function BarraFerramentas ({
137
174
  item[0]
138
175
  )}
139
176
  </IconButton>
140
- </Tooltip>
177
+ </CustomTooltip>
141
178
  );
142
179
  };
143
180
 
@@ -146,7 +183,7 @@ function BarraFerramentas ({
146
183
  {(isArray(abas) && abas.length > 0) && (
147
184
  <IconButton id='botaoAbasBarraFerramentas' ref={anchorMenu} onClick={toggleAbas} className={classes.menuButton}>
148
185
  <MdFormatListBulleted />
149
- </IconButton>
186
+ </IconButton>
150
187
  )}
151
188
  <Popper open={open} anchorEl={anchorMenu.current} role={undefined} transition keepMounted style={{ zIndex: 2, marginLeft: 10 }}>
152
189
  {({ TransitionProps }) => (
@@ -164,50 +201,50 @@ function BarraFerramentas ({
164
201
  )}
165
202
  </Popper>
166
203
  <Typography component='div' variant='h6' className={classes.title}>
167
- {abaAtual ? (
168
- <Typography variant='subtitle1'>{abaAtual} <Typography variant='caption'>( {titulo} )</Typography></Typography>
204
+ {(abaAtual) ? (
205
+ <Typography variant='subtitle1'>{abaAtual} <Typography variant='caption'>( {titulo} )</Typography></Typography>
169
206
  ) : (
170
207
  <Typography variant='subtitle1'>{titulo}</Typography>
171
208
  )}
172
209
  </Typography>
173
210
 
174
- {habNavegador && (
211
+ {(habNavegador) && (
175
212
  <Box className={classes.navigator}>
176
- <Tooltip title='Primeiro registro'>
213
+ <CustomTooltip title='Primeiro registro'>
177
214
  <IconButton size='small' onClick={() => executaFuncao('NF')}>
178
215
  <MdFirstPage />
179
216
  </IconButton>
180
- </Tooltip>
181
- <Tooltip title='Registro anterior'>
217
+ </CustomTooltip>
218
+ <CustomTooltip title='Registro anterior'>
182
219
  <IconButton size='small' onClick={() => executaFuncao('NP')}>
183
220
  <MdKeyboardArrowLeft/>
184
221
  </IconButton>
185
- </Tooltip>
186
- <Tooltip title='Próximo registro'>
222
+ </CustomTooltip>
223
+ <CustomTooltip title='Próximo registro'>
187
224
  <IconButton size='small' onClick={() => executaFuncao('NN')}>
188
225
  <MdKeyboardArrowRight/>
189
226
  </IconButton>
190
- </Tooltip>
191
- <Tooltip title='Último registro'>
227
+ </CustomTooltip>
228
+ <CustomTooltip title='Último registro'>
192
229
  <IconButton size='small' onClick={() => executaFuncao('NL')}>
193
230
  <MdLastPage />
194
231
  </IconButton>
195
- </Tooltip>
232
+ </CustomTooltip>
196
233
  </Box>
197
234
  )}
198
235
 
199
- {isArray(ferramentas) && ferramentas.map(g => g.map((item, index) => getFerramentas(item, index)))}
236
+ {(isArray(ferramentas)) && ferramentas.map(g => g.map((item, index) => getFerramentas(item, index)))}
200
237
 
201
- {nmFuncaoVoltar && (
202
- <Tooltip title='Voltar'>
238
+ {(nmFuncaoVoltar) && (
239
+ <CustomTooltip title='Voltar'>
203
240
  <IconButton onClick={() => executaFuncao(nmFuncaoVoltar)}>
204
241
  <MdArrowBack/>
205
242
  </IconButton>
206
- </Tooltip>
243
+ </CustomTooltip>
207
244
  )}
208
- {habCrud && <>
209
- {habEditar ? (
210
- <Tooltip title='Editar'>
245
+ {(habCrud) && <>
246
+ {(habEditar) ? (
247
+ <CustomTooltip title='Editar'>
211
248
  <IconButton onClick={() => {
212
249
  setHabEditar(false);
213
250
  setHabSalvar(true);
@@ -215,7 +252,7 @@ function BarraFerramentas ({
215
252
  }}>
216
253
  <MdEdit/>
217
254
  </IconButton>
218
- </Tooltip>
255
+ </CustomTooltip>
219
256
  ) : (
220
257
  <ClickAwayListener onClickAway={() => {
221
258
  setHabEditar(true);
@@ -223,30 +260,30 @@ function BarraFerramentas ({
223
260
  setHabExcluir(false);
224
261
  }}>
225
262
  <Box>
226
- {habSalvar && (
227
- <Tooltip title='Salvar Registro'>
263
+ {(habSalvar) && (
264
+ <CustomTooltip title='Salvar Registro'>
228
265
  <IconButton onClick={() => executaFuncao(nmSalva)}>
229
266
  <MdSave/>
230
267
  </IconButton>
231
- </Tooltip>
268
+ </CustomTooltip>
232
269
  )}
233
- {habExcluir && (
234
- <Tooltip title='Excluir Registro'>
270
+ {(habExcluir) && (
271
+ <CustomTooltip title='Excluir Registro'>
235
272
  <IconButton onClick={() => executaFuncao(nmExclui)}>
236
273
  <MdDelete/>
237
274
  </IconButton>
238
- </Tooltip>
275
+ </CustomTooltip>
239
276
  )}
240
277
  </Box>
241
278
  </ClickAwayListener>
242
279
  )}
243
280
  </>}
244
- {nmCompartilhar && (
245
- <Tooltip title='Compartilhar'>
281
+ {(nmCompartilhar) && (
282
+ <CustomTooltip title='Compartilhar'>
246
283
  <IconButton ref={anchorCompartilhar} onClick={toggleCompartilhar}>
247
284
  <MdShare />
248
285
  </IconButton>
249
- </Tooltip>
286
+ </CustomTooltip>
250
287
  )}
251
288
  <Popper open={openCompartilhar} anchorEl={anchorCompartilhar.current} role={undefined} transition keepMounted style={{ zIndex: 2, marginRight: 10 }}>
252
289
  {({ TransitionProps }) => (
@@ -257,24 +294,29 @@ function BarraFerramentas ({
257
294
  </Collapse>
258
295
  )}
259
296
  </Popper>
260
- {isArray(threads) && threads.map((thread, key) => <ThreadLog {...{ key, thread, currentProgram }} />)}
261
- {habWidget &&
262
- (
263
- <Tooltip title='Adicionar widget'>
264
- <IconButton onClick={addWidget}>
265
- <AiOutlineAppstoreAdd />
266
- </IconButton>
267
- </Tooltip>
268
- )
269
- }
270
- {habFavorito && checkIfIsFavorite && (
271
- <Tooltip title='Favorito'>
297
+ {(isArray(threads)) && threads.map((thread, key) => <ThreadLog {...{ key, thread, currentProgram }} />)}
298
+ {(habWidget) && (
299
+ <CustomTooltip title='Adicionar widget'>
300
+ <IconButton onClick={addWidget}>
301
+ <AiOutlineAppstoreAdd />
302
+ </IconButton>
303
+ </CustomTooltip>
304
+ )}
305
+ {(snAnotacaoPrograma) && (
306
+ <CustomTooltip title='Anotações' disabled={disableTooltip}>
307
+ <IconButton disabled={toolbarLoading?.annotations} onClick={handleAnnotationsClick}>
308
+ {(toolbarLoading?.annotations) ? <ButtonLoadingFeedback /> : <MdEditNote />}
309
+ </IconButton>
310
+ </CustomTooltip>
311
+ )}
312
+ {(habFavorito && checkIfIsFavorite) && (
313
+ <CustomTooltip title='Favorito'>
272
314
  <IconButton onClick={addFavorite}>
273
315
  <FaStar className={`pg-fav-start ${checkIfIsFavorite()}`}></FaStar>
274
316
  {favoriteAnimationInsert && <FaStar className='pg-fav-start active insertion-star-fav' />}
275
317
  {favoriteAnimationRemove && <FaStar className='pg-fav-start active removing-star-fav' />}
276
318
  </IconButton>
277
- </Tooltip>
319
+ </CustomTooltip>
278
320
  )}
279
321
  </Toolbar>
280
322
  <Divider style={{ marginBottom: 10 }}/>
@@ -0,0 +1,169 @@
1
+ import { getFileFromLink, getLink } from '../../api';
2
+ import { CircularProgress } from '@material-ui/core';
3
+ import React, { useCallback, useEffect, useMemo, useState } from 'react';
4
+
5
+ const reqSvgs = require.context ('./icons', true, /\.svg$/);
6
+
7
+ const loadSvg = async (svg, path) => ({ [path.replace(/.\/|.svg/g, '')]: URL.createObjectURL(await (await fetch(svg?.default || svg)).blob()) });
8
+
9
+ const iconClasses = {
10
+ 'application/pdf': 'pdf',
11
+ 'application/msword': 'doc',
12
+ 'application/vnd.ms-word': 'doc',
13
+ 'application/vnd.oasis.opendocument.text': 'doc',
14
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml': 'doc',
15
+ 'application/vnd.ms-excel': 'xls',
16
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml': 'xls',
17
+ 'application/vnd.oasis.opendocument.spreadsheet': 'xls',
18
+ 'application/vnd.ms-powerpoint': 'ppt',
19
+ 'application/vnd.openxmlformats-officedocument.presentationml': 'ppt',
20
+ 'application/vnd.oasis.opendocument.presentation': 'ppt',
21
+ 'text/rtf': 'rtf',
22
+ 'text/plain': 'txt',
23
+ 'text/html': 'html',
24
+ 'text/css': 'css',
25
+ 'text/csv': 'csv',
26
+ 'application/json': 'json',
27
+ 'image/vnd.adobe.photoshop': 'psd',
28
+ 'image/photoshop': 'psd',
29
+ 'image/x-photoshop': 'psd',
30
+ 'image/psd': 'psd',
31
+ 'application/photoshop': 'psd',
32
+ 'application/psd': 'psd',
33
+ 'zz-application/zz-winassoc-psd': 'psd',
34
+ 'video/x-msvideo': 'avi',
35
+ 'application/gzip': 'zip1',
36
+ 'application/zip': 'zip',
37
+ 'application/acad': 'dwg',
38
+ 'image/vnd.dwg': 'dwg',
39
+ 'image/x-dwg': 'dwg',
40
+ 'application/octet-stream': 'exe',
41
+ 'audio/flac': 'fla',
42
+ 'image/jpeg': 'jpg',
43
+ 'image/jpg': 'jpg',
44
+ 'text/javascript': 'js',
45
+ 'audio/mpeg': 'mp3',
46
+ 'video/mpeg': 'mp4',
47
+ 'audio/mp4': 'mp4',
48
+ 'image/png': 'png',
49
+ 'application/xml': 'xml',
50
+ 'application/x-7z-compressed': 'zip1',
51
+ 'application/x-compressed-tar': 'zip1',
52
+ 'application/vnd.rar': 'zip1',
53
+ 'modelo/contrato': 'mod',
54
+ image: 'image',
55
+ audio: 'audio',
56
+ video: 'video'
57
+ };
58
+
59
+ let icones;
60
+
61
+ (async () => {
62
+ icones = await (await Promise.all(reqSvgs.keys()
63
+ .map(path => loadSvg(reqSvgs(path), path))
64
+ )).reduce((acc, item) => ({ ...acc, ...item }), {});
65
+ })();
66
+
67
+ // eslint-disable-next-line valid-jsdoc
68
+ /**
69
+ * @typedef {'ai'|'audio'|'avi'|'css'|'csv'|'dbf'|'doc'|'dwg'|'exe'|'file'|'fla'|'html'|'image'|'iso'|'jpg'|'js'|'json'|'mod'|'mp3'|'mp4'|'pdf'|'png'|'ppt'|'psd'|'rtf'|'search'|'svg'|'txt'|'video'|'xls'|'xml'|'zip'|'zip1'} Extencoes
70
+ *
71
+ * @typedef {object} Tipos
72
+ * @property {Extencoes} type - Tipos de arquivos suportados
73
+ * @property {string} mimeType - MimeType do arquivo
74
+ * @property {string} fileName - Nome do arquivo
75
+ *
76
+ * @param {React.ImgHTMLAttributes<HTMLImageElement> & Tipos} props - props
77
+ * @returns {JSX.Element} retorno
78
+ */
79
+
80
+ export const IconsComponent = ({ type, fileName, mimeType, idDocumento, link, ...props }) => {
81
+ /** @type {[FileIcons, React.Dispatch<FileIcons>]} */
82
+ const [state, setState] = useState(icones);
83
+ const [preview, setPreview] = useState();
84
+
85
+
86
+ const setarState = useCallback(() => {
87
+ if (state) return;
88
+ if (icones) setState(icones);
89
+ else setTimeout(setarState, 200);
90
+ }, [state]);
91
+
92
+ useEffect(setarState, [setarState]);
93
+
94
+ const selectedImage = useMemo(() => {
95
+ if (type) return type;
96
+ /** @type {Extencoes} */
97
+ const extension = fileName?.match(/\.([^.]*)$/)?.at(1);
98
+ if (!state) return '';
99
+ if (Object.keys(state).includes(extension)) return extension;
100
+ for (let key in iconClasses)
101
+ if (Object.prototype.hasOwnProperty.call(iconClasses, key))
102
+ if (mimeType?.search(key) === 0)
103
+ return iconClasses[key];
104
+ return 'file';
105
+ }, [type, mimeType, fileName, state]);
106
+
107
+ const buscaImagemPreview = useCallback(async () => {
108
+ if (idDocumento && (mimeType?.includes('image'))) {
109
+ const file = await getFileFromLink(await getLink(idDocumento));
110
+ setPreview(file);
111
+ }
112
+ }, [mimeType, idDocumento]);
113
+ useEffect(() => void(buscaImagemPreview()), [buscaImagemPreview]);
114
+
115
+ if (!state) return <CircularProgress disableShrink/>;
116
+ return <>
117
+ {(preview) ? (
118
+ <img src={preview} alt={type} {...props} style={{ position: 'absolute', left: 0, right: 0, top: 0, bottom: 0, width: '100%', height: '100%', objectFit: 'contain' }} />
119
+ ) : (
120
+ <img src={state[selectedImage]} alt={type} {...props} />
121
+ )}
122
+ </>;
123
+ };
124
+
125
+ /**
126
+ * @typedef {object} FileIcons - Objeto de icones
127
+ * @property {JSX.Element} ai -Icone de arquivos do Ilustrator
128
+ * @property {JSX.Element} audio -Icone genérico de Audio
129
+ * @property {JSX.Element} avi -Icone de videos AVI
130
+ * @property {JSX.Element} css -Icone de arquivos CSS
131
+ * @property {JSX.Element} csv -Icone de arquivos CSV
132
+ * @property {JSX.Element} dbf -Icone de arquivos DBF
133
+ * @property {JSX.Element} doc -Icone de arquivos Word
134
+ * @property {JSX.Element} dwg -Icone de arquivos DWG
135
+ * @property {JSX.Element} exe -Icone de arquivos EXE
136
+ * @property {JSX.Element} file -Icone de arquivos genéricos
137
+ * @property {JSX.Element} fla -Icone de arquivos FLA
138
+ * @property {JSX.Element} html -Icone de arquivos HTML
139
+ * @property {JSX.Element} image -Icone genérico de Imagens
140
+ * @property {JSX.Element} iso -Icone de imagens ISO
141
+ * @property {JSX.Element} jpg -Icone de imagens JPG
142
+ * @property {JSX.Element} js -Icone de arquivos Javascript
143
+ * @property {JSX.Element} json -Icone de arquivos JSON
144
+ * @property {JSX.Element} mod -Icone de modelos de documentos
145
+ * @property {JSX.Element} mp3 -Icone de músicas MP3
146
+ * @property {JSX.Element} mp4 -Icone de vídeos MP4
147
+ * @property {JSX.Element} pdf -Icone de arquivos PDP
148
+ * @property {JSX.Element} png -Icone de imagens PNG
149
+ * @property {JSX.Element} ppt -Icone de arquivos do Power Point
150
+ * @property {JSX.Element} psd -Icone de arquivos do Photoshop
151
+ * @property {JSX.Element} rtf -Icone de arquivos RTF
152
+ * @property {JSX.Element} search -Icone genérico de Busca
153
+ * @property {JSX.Element} svg -Icone de arquivos SVG
154
+ * @property {JSX.Element} txt -Icone de arquivos de Texto
155
+ * @property {JSX.Element} video -Icone genérico de Vídeo
156
+ * @property {JSX.Element} xls -Icone de arquivos do Excel
157
+ * @property {JSX.Element} xml -Icone de arquivos XML
158
+ * @property {JSX.Element} zip -Icone de arquivos ZIP
159
+ * @property {JSX.Element} zip1 -Icone genérico de arquivos comprimidos
160
+ */
161
+
162
+ /** @type {FileIcons} */
163
+ export const Icons = reqSvgs.keys().reduce((images, path) => {
164
+ const key = path.replace(/.\/|.svg/g, '');
165
+ images[key] = <IconsComponent type={key}/>;
166
+ return images;
167
+ }, {});
168
+
169
+ export default Icons;
@@ -0,0 +1,64 @@
1
+ import Visualizacao from './Visualizacao';
2
+ import { downloadBase64, downloadFromUrl, geraLog, printUrl, stopPrntScr } from '../../utils/index';
3
+ import { Typography, IconButton, Dialog, Toolbar, AppBar, Box } from '@material-ui/core';
4
+ import React, { useState } from 'react';
5
+ import { MdClose, MdFileDownload, MdPrint } from 'react-icons/md';
6
+
7
+ const ModalVisualizacaoDocumentos = ({ open, proceed, tokenSistema, ...props }) => {
8
+ const [visualizando, setVisualizando] = useState(props);
9
+ return (
10
+ <Dialog
11
+ fullScreen
12
+ open={open}
13
+ onClose={() => proceed(undefined)}
14
+ onKeyDown={stopPrntScr}
15
+ onContextMenu={(e) => e.preventDefault()}
16
+ >
17
+ <AppBar style={{ position: 'relative' }}>
18
+ <Toolbar>
19
+ <IconButton edge='start' color='inherit' onClick={() => proceed(undefined)}>
20
+ <MdClose />
21
+ </IconButton>
22
+ <Typography variant='h6' style={{ flexGrow: '1' }}>
23
+ {visualizando?.nome}
24
+ </Typography>
25
+ {!visualizando?.sensible && (
26
+ <>
27
+ <IconButton
28
+ onClick={(_) => {
29
+ if (!visualizando?.linkPronto?.length) {
30
+ geraLog(visualizando.idDocumento, 'Impressão do documento', '3', tokenSistema);
31
+ }
32
+ printUrl(visualizando.URL ? visualizando.URL : visualizando.linkPronto);
33
+ }}
34
+ color='inherit'
35
+ title='Imprimir arquivo'
36
+ >
37
+ <MdPrint />
38
+ </IconButton>
39
+ <IconButton
40
+ onClick={() => {
41
+ if (!visualizando?.linkPronto?.length) {
42
+ geraLog(visualizando.idDocumento, 'Download do documento', '3', tokenSistema);
43
+ downloadFromUrl(visualizando?.URL, visualizando?.nome);
44
+ } else {
45
+ downloadBase64(visualizando?.linkPronto, visualizando?.nome);
46
+ }
47
+ }}
48
+ color='inherit'
49
+ title='Baixar arquivo'
50
+ >
51
+ <MdFileDownload />
52
+ </IconButton>
53
+ </>
54
+ )}
55
+ </Toolbar>
56
+ </AppBar>
57
+ <Box display='flex' justifyContent='center' alignItems='center' width='100%' height='100%'>
58
+ <Visualizacao {...{ setVisualizando, ...visualizando, tokenSistema, proceed }} />
59
+ </Box>
60
+ </Dialog>
61
+ );
62
+ };
63
+
64
+ export default ModalVisualizacaoDocumentos;
@@ -0,0 +1,104 @@
1
+ import { serverAction, setError } from '../../utils/api';
2
+ import { Box, CircularProgress, makeStyles } from '@material-ui/core';
3
+ import React, { useEffect, useRef, useState } from 'react';
4
+
5
+
6
+ const useStyles = makeStyles(theme => ({
7
+ iframe: {
8
+ width: '100%',
9
+ height: '100%',
10
+ border: 'none',
11
+ background: theme.palette.background.default,
12
+ '&:focus': {
13
+ outline: 'none'
14
+ },
15
+ '&[seamless]': {
16
+ display: 'block'
17
+ }
18
+ },
19
+ restricSize: {
20
+ maxWidth: '100%',
21
+ maxHeight: '100%'
22
+ }
23
+ }));
24
+
25
+ let onchange = () => undefined;
26
+
27
+
28
+ const Visualizacao = ({ idDocumento, nrRevisao, setVisualizando, proceed, URL: documento, linkPronto, tokenSistema, ariaLabel }) => {
29
+
30
+ const classes = useStyles();
31
+ const blockLoop = useRef(null);
32
+ const [{ type }, setArquivo] = useState({});
33
+ const tagType = type?.match(/^[^/]+/)?.at(0);
34
+ const [link, setLink] = useState(linkPronto);
35
+
36
+ const preparaLink = async () => {
37
+ if (!linkPronto && ((!idDocumento && !documento) || (documento === blockLoop.current))) {
38
+ return;
39
+ }
40
+
41
+ const objGetLinkDocumento = { idDocumento, nrRevisao, dsToken: tokenSistema?.toString() };
42
+ const { link: res } = linkPronto ? { link: { URL: linkPronto } } : documento ? { link: { URL: documento } } : await serverAction('getLinkDocumento', objGetLinkDocumento, 'CtrlDocumentos', true);
43
+ try {
44
+ const file = await (await fetch(res?.URL, {
45
+ method: 'post',
46
+ headers: { lgTkn: tokenSistema }
47
+ })).blob();
48
+ const url = URL.createObjectURL(file);
49
+ setVisualizando(v => ({ ...v, URL: url }));
50
+ blockLoop.current = url;
51
+ setLink(url);
52
+ setArquivo({ ...res, type: file?.type });
53
+ } catch (error) {
54
+ setError('Não foi possível visualizar este documento.');
55
+ }
56
+ };
57
+
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ useEffect(() => preparaLink(), []);
60
+
61
+ useEffect(() => {
62
+ onchange = function(evt) {
63
+ let v = 'visible', h = 'hidden', evtMap = { focus: v, focusin: v, pageshow: v, blur: h, focusout: h, pagehide: h };
64
+ evt = evt || window.event;
65
+ if (evt.type in evtMap) document.body.style.opacity = evtMap[evt.type];
66
+ else document.body.style.opacity = this[hidden] ? 0 : 1;
67
+ };
68
+ let hidden = 'hidden';
69
+ if (hidden in document) document.addEventListener('visibilitychange', onchange);
70
+ else if ((hidden = 'mozHidden') in document) document.addEventListener('mozvisibilitychange', onchange);
71
+ else if ((hidden = 'webkitHidden') in document) document.addEventListener('webkitvisibilitychange', onchange);
72
+ else if ((hidden = 'msHidden') in document) document.addEventListener('msvisibilitychange', onchange);
73
+ else if ('onfocusin' in document) document.onfocusin = document.onfocusout = onchange;
74
+ else window.onpageshow = window.onpagehide = window.onfocus = window.onblur = onchange;
75
+ if (document[hidden] !== undefined) onchange({ type: document[hidden] ? 'blur' : 'focus' });
76
+
77
+ window.onkeydown = e => {
78
+ if (e.key === 'Escape') proceed(undefined);
79
+ if (e.key === 'F12') return false;
80
+ if (e.ctrlKey && e.shiftKey && e.key === 'I') return false;
81
+ if (e.ctrlKey && e.shiftKey && e.key === 'C') return false;
82
+ if (e.ctrlKey && e.shiftKey && e.key === 'J') return false;
83
+ if (e.ctrlKey && e.key === 'u') return false;
84
+ };
85
+ return () => {
86
+ window.onkeydown = undefined;
87
+ onchange = () => undefined;
88
+ };
89
+ }, [proceed]);
90
+
91
+ switch (tagType) {
92
+ case 'audio':
93
+ return <audio className={classes.restricSize} aria-label={ariaLabel} src={link} controls controlsList='nodownload' />;
94
+ case 'image':
95
+ return <img className={classes.restricSize} alt={ariaLabel || 'Imagem'} aria-label={ariaLabel} src={link} onClick={e => e.preventDefault()}/>;
96
+ case 'video':
97
+ return <video className={classes.restricSize} aria-label={ariaLabel} controls controlsList='nodownload' autoPlay src={link}/>;
98
+ default:
99
+ return link ? <iframe className={classes.iframe} aria-label={ariaLabel} title='Iframe' src={`${link}#toolbar=0`}/> : <Box justifyContent='center' alignItems='center' display='flex'><CircularProgress disableShrink/></Box>;
100
+ }
101
+ };
102
+
103
+
104
+ export default Visualizacao;