浏览代码

change op edit method alternative

amenpunk 2 年之前
父节点
当前提交
4642323bbe

+ 0 - 1
src/App.css

@@ -373,7 +373,6 @@
373 373
 }
374 374
 
375 375
 #search_plaza_input{
376
-  width:200px;
377 376
   padding-left:20px !important;
378 377
   margin-left:20px !important;
379 378
 }

+ 2 - 89
src/Components/Password/Operation.jsx

@@ -1,6 +1,4 @@
1 1
 import * as React from 'react';
2
-
3
-import { Edit as EditIcon, Send as SendIcon } from '@mui/icons-material'
4 2
 import {
5 3
   Button, Dialog, DialogActions, DialogContent, //DialogTitle,
6 4
   FormControlLabel, Checkbox,
@@ -20,55 +18,18 @@ import { AdapterDateFns as DateFnsUtils } from '@mui/x-date-pickers/AdapterDateF
20 18
 import { DesktopDatePicker } from '@mui/x-date-pickers/DesktopDatePicker';
21 19
 import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
22 20
 
23
-
24
-export function Operation(props) {
25
-
26
-  let [open, setOpen] = React.useState(false);
27
-  const handleOpen = (status) => setOpen(status);
28
-
29
-  return (
30
-    <div>
31
-      <div className="operation_buttons">
32
-        <EditIcon onClick={() => setOpen(true)} className="icon_op" />
33
-        <SendIcon className="icon_op" />
34
-      </div>
35
-      {
36
-        open ?
37
-          <ModalEdit
38
-            password={props}
39
-            open={open}
40
-            handleOpen={handleOpen}
41
-          />
42
-          : null
43
-      }
44
-    </div>
45
-  )
46
-}
47
-
48
-function ModalEdit(props) {
49
-
21
+export function ModalEdit(props) {
50 22
   let { password, open, handleOpen } = props
51
-  const now = React.useRef(new Date());
52 23
   let { pwd, plz } = password
53 24
   const auth = useSelector((state) => state.token)
54 25
   const getPassword = async () => {
55
-    let rest = new Service(`/contrasenia/${pwd}/${plz}`)
26
+    let rest = new Service(`/contrasenia/${btoa(pwd)}/${plz}`)
56 27
     return await rest.getQuery(auth.token)
57 28
   }
58 29
 
59 30
   let { data: result } = useQuery('contra', getPassword);
60 31
   console.log('PWD INFO ', result)
61 32
 
62
-  let initialValues = {
63
-    id: result?.data?.id,
64
-    pwd: result?.data?.pwd,
65
-    deadpwd: result?.data?.deadpwd ? new Date(result?.data?.deadpwd) : now.current,
66
-    state: result?.data?.state,
67
-    dateToActived: result?.data.dateToActived ? new Date(result?.data?.dateToActived) : now.current,
68
-    plaza_id: result?.data?.plaza_id,
69
-    candidato_id: result?.data?.candidato_id
70
-  }
71
-
72 33
   return (
73 34
     <Dialog
74 35
       open={open}
@@ -78,8 +39,6 @@ function ModalEdit(props) {
78 39
     >
79 40
       <DialogContent>
80 41
         <ModalForm
81
-          //puestos={puestos}
82
-          initialValues={initialValues}
83 42
           handleOpen={handleOpen}
84 43
           token={auth.token}
85 44
         />
@@ -140,21 +99,6 @@ function ModalForm(props) {
140 99
 
141 100
   const { errors, touched, handleSubmit, getFieldProps, values, setValues } = formik;
142 101
 
143
-  function fromBase64(text){
144
-    try{
145
-      return atob(text)
146
-    }catch(_e){
147
-      return text
148
-    }
149
-  }
150
-
151
-  React.useEffect(() => {
152
-    setValues({
153
-      ...props.initialValues,
154
-      pwd: props.initialValues.pwd ? fromBase64(props.initialValues.pwd) : 'loading'
155
-    })
156
-  }, [props, setValues])
157
-
158 102
   return (
159 103
     <FormikProvider value={formik}>
160 104
       <Form style={{ padding: 20, maxWidth: 950 }} autoComplete="off" noValidate onSubmit={handleSubmit}>
@@ -193,7 +137,6 @@ function ModalForm(props) {
193 137
               }
194 138
               label="Activa"
195 139
             />
196
-
197 140
           </Stack>
198 141
 
199 142
 
@@ -239,36 +182,6 @@ function ModalForm(props) {
239 182
                 />}
240 183
             />
241 184
           </LocalizationProvider>
242
-
243
-
244
-          {/*
245
-                    <Autocomplete
246
-                        {...getFieldProps('plaza_id')}
247
-                        onChange={(_a,current_list,_c,_individual,_f) => {
248
-                            console.log("CURRENT LIST : ",current_list)
249
-                            setValues({
250
-                                ...values,
251
-                                plaza_id:current_list
252
-                            })
253
-                        }}
254
-                        value={props.puestos.filter(p=> p.id=== values.plaza_id ).shift()}
255
-                        id="combo-box-demo"
256
-                        options={props.puestos}
257
-                        isOptionEqualToValue={
258
-                            (option, value) => option.nombrepuesto === value.nombrepuesto
259
-                        }
260
-                        getOptionLabel={(option) => {
261
-                            return option.nombrepuesto
262
-                        }}
263
-                        renderInput={(params) =>
264
-                            <TextField
265
-                                {...params}
266
-                                label="Puesto"
267
-                            />
268
-                        }
269
-                    />
270
-*/}
271
-
272 185
           <DialogActions>
273 186
             <Button onClick={() => props.handleOpen(false)}>
274 187
               Cerrar

+ 21 - 13
src/Components/Password/Rows.js

@@ -1,5 +1,3 @@
1
-import { Operation } from './Operation'
2
-
3 1
 function fromBase64(text){
4 2
   try{
5 3
     return atob(text)
@@ -11,6 +9,14 @@ function fromBase64(text){
11 9
 
12 10
 export const Encabezados = [
13 11
   {
12
+    name: 'id',
13
+    numeric: true,
14
+    label: 'ID',
15
+    options:{
16
+      display:false
17
+    }
18
+  },
19
+  {
14 20
     name: 'name',
15 21
     numeric: false,
16 22
     disablePadding: true,
@@ -28,16 +34,16 @@ export const Encabezados = [
28 34
     disablePadding: true,
29 35
     label: 'Fecha vencimiento',
30 36
   },
31
-  {
32
-    name: 'op',
33
-    numeric: false,
34
-    disablePadding: true,
35
-    label: 'Operación',
36
-    options: {
37
-      filter: false,
38
-      sort: false,
39
-    }
40
-  },
37
+  // {
38
+  //   name: 'op',
39
+  //   numeric: false,
40
+  //   disablePadding: true,
41
+  //   label: 'Operación',
42
+  //   options: {
43
+  //     filter: false,
44
+  //     sort: false,
45
+  //   }
46
+  // },
41 47
 ]
42 48
 
43 49
 export const niveles_educativos = [
@@ -54,13 +60,15 @@ export const niveles_educativos = [
54 60
 ]
55 61
 
56 62
 export function Build(pwds) {
63
+
57 64
   return pwds.map(password => {
65
+    console.log(password)
58 66
     let { pwd, plaza_id } = password
59 67
     return {
68
+      id: plaza_id,
60 69
       name: fromBase64( pwd ),//atob( pwd ),
61 70
       activacion: new Date().toUTCString(),//dateToActived, 
62 71
       dead: new Date().toUTCString(), //deadpwd,
63
-      op: <Operation plz={plaza_id} pwd={pwd} />
64 72
     }
65 73
   })
66 74
 }

+ 27 - 26
src/Components/Password/Steps/password.jsx

@@ -52,32 +52,33 @@ export function Password(props) {
52 52
     <FormikProvider style={{ padding: 25, paddingTop: 5 }} value={formik}>
53 53
       <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
54 54
         <Stack spacing={3}>
55
-
56
-          <TextField
57
-            value={uid ? uid : btoa(values.pwd)}
58
-            disabled
59
-            fullWidth
60
-            type="text"
61
-            label="Identificador Codificado"
62
-            variant="standard"
63
-          />
64
-
65
-          <TextField
66
-            fullWidth
67
-            type="text"
68
-            label="Nombre o identificador"
69
-            {...getFieldProps('pwd')}
70
-            onChange={(event) => {
71
-              let value = event.target.value
72
-              setUID(btoa(value));
73
-              setValues({
74
-                ...values,
75
-                pwd: value
76
-              })
77
-            }}
78
-            error={Boolean(touched.pwd && errors.pwd)}
79
-            helperText={touched.pwd && errors.pwd}
80
-          />
55
+          <Stack spacing={2}>
56
+            <TextField
57
+              fullWidth
58
+              type="text"
59
+              label="Nombre o identificador"
60
+              {...getFieldProps('pwd')}
61
+              onChange={(event) => {
62
+                let value = event.target.value
63
+                setUID(btoa(value));
64
+                setValues({
65
+                  ...values,
66
+                  pwd: value
67
+                })
68
+              }}
69
+              error={Boolean(touched.pwd && errors.pwd)}
70
+              helperText={touched.pwd && errors.pwd}
71
+            />
72
+
73
+            <TextField
74
+              value={uid ? uid : btoa(values.pwd)}
75
+              disabled
76
+              fullWidth
77
+              type="text"
78
+              label="Identificador Codificado"
79
+              variant="standard"
80
+            />
81
+          </Stack>
81 82
 
82 83
 
83 84
           <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>

+ 119 - 58
src/Components/Password/TableStyle.js

@@ -1,71 +1,132 @@
1 1
 import { createTheme } from '@mui/material';
2 2
 
3
+
4
+// MuiTableCell-root MuiTableCell-body MuiTableCell-paddingCheckbox MuiTableCell-sizeMedium tss-12o2szd-MUIDataTableSelectCell-root tss-1fz4yw6-MUIDataTableSelectCell-fixedLeft css-1nf681w-MuiTableCell-root
5
+
3 6
 export const TableStyle = () => createTheme({
4
-    components: {
5
-        MUIDataTableToolbar: {
6
-            styleOverrides: {
7
-                root: {
8
-                    paddingLeft: 15
9
-                }
10
-            }
11
-        },
12
-        MuiPaper: {
13
-            styleOverrides: {
14
-                root: {
15
-                    boxShadow: 'none'
16
-                }
17
-            }
7
+  components: {
18 8
 
19
-        },
20
-        MUIDataTableBodyCell: {
21
-            styleOverrides: {
22
-                root: {
23
-                    backgroundColor: "#FFF"
24
-                }
25
-            }
26
-        },
27
-        MuiTablePagination: {
28
-            styleOverrides: {
29
-                toolbar: {
30
-                    paddingTop: 7,
31
-                    alignItems: 'baseline'
32
-                }
33
-            }
9
+    MuiSvgIcon: {
10
+      styleOverrides: {
11
+        root: {
12
+          color: 'var(--main)'
34 13
         }
35
-    }
36
-})
14
+      }
15
+    },
37 16
 
38
-export const TextLabels = {
39
-    body: {
40
-        noMatch: "No se encontró ningún elemento",
41
-        toolTip: "Ordenar",
42
-        columnHeaderTooltip: column => `Ordenar por ${column.label}`
17
+    MUIDataTableSelectCell: {
18
+      styleOverrides: {
19
+        root: {
20
+          backgroundColor: '#FFF'
21
+        }
22
+      }
23
+    },
24
+    MuiCheckbox: {
25
+      styleOverrides: {
26
+        root: {
27
+          color: 'var(--main)'
28
+        }
29
+      }
30
+    },
31
+    MuiChecked: {
32
+      styleOverrides: {
33
+        root: {
34
+          color: 'red'
35
+        }
36
+      }
37
+    },
38
+    MUIDataTableToolbar: {
39
+      styleOverrides: {
40
+        root: {
41
+          paddingLeft: 15
42
+        }
43
+      }
43 44
     },
44
-    pagination: {
45
-        next: "Siguiente Pagina",
46
-        previous: "Pagina Anterior",
47
-        rowsPerPage: "Elementos por Página",
48
-        displayRows: "de",
45
+    MuiRowSelected: {
46
+      styleOverrides: {
47
+        root: {
48
+          backgroundColor: "#FFF"
49
+        }
50
+      }
49 51
     },
50
-    toolbar: {
51
-        search: "Buscar",
52
-        downloadCsv: "Descargar CSV",
53
-        print: "Imprimir",
54
-        viewColumns: "Seleccionar Columnas",
55
-        filterTable: "Filtrar Tabla",
52
+    MuiPaper: {
53
+      styleOverrides: {
54
+        root: {
55
+          boxShadow: 'none'
56
+        }
57
+      }
58
+
56 59
     },
57
-    filter: {
58
-        all: "Todos",
59
-        title: "FILTROS",
60
-        reset: "Limpiar",
60
+    MUIDataTableSelectedCell: {
61
+      styleOverrides: {
62
+        root: {
63
+          backgroundColor: "#FFF"
64
+        }
65
+      }
61 66
     },
62
-    viewColumns: {
63
-        title: "Mostrar Columnas",
64
-        titleAria: "Mostrar/Ocultar Columnas",
67
+    MUITableCell: {
68
+      styleOverrides: {
69
+        root: {
70
+          backgroundColor: "#FFF"
71
+        }
72
+      }
65 73
     },
66
-    selectedRows: {
67
-        text: "Elemento(s) selecionado",
68
-        delete: "Eliminar",
69
-        deleteAria: "Eliminar Columnas Seleccionadas",
74
+    MUIDataTableBodyRow: {
75
+      styleOverrides: {
76
+        root: {
77
+          backgroundColor: "#FFF"
78
+        }
79
+      }
70 80
     },
81
+    MUIDataTableBodyCell: {
82
+      styleOverrides: {
83
+        root: {
84
+          backgroundColor: "#FFF"
85
+        }
86
+      }
87
+    },
88
+    MuiTablePagination: {
89
+      styleOverrides: {
90
+        toolbar: {
91
+          paddingTop: 7,
92
+          alignItems: 'baseline'
93
+        }
94
+      }
95
+    }
96
+  }
97
+})
98
+
99
+export const TextLabels = {
100
+  body: {
101
+    noMatch: "No se encontró ningún elemento",
102
+    toolTip: "Ordenar",
103
+    columnHeaderTooltip: column => `Ordenar por ${column.label}`
104
+  },
105
+  pagination: {
106
+    next: "Siguiente Pagina",
107
+    previous: "Pagina Anterior",
108
+    rowsPerPage: "Elementos por Página",
109
+    displayRows: "de",
110
+  },
111
+  toolbar: {
112
+    search: "Buscar",
113
+    downloadCsv: "Descargar CSV",
114
+    print: "Imprimir",
115
+    viewColumns: "Seleccionar Columnas",
116
+    filterTable: "Filtrar Tabla",
117
+  },
118
+  filter: {
119
+    all: "Todos",
120
+    title: "FILTROS",
121
+    reset: "Limpiar",
122
+  },
123
+  viewColumns: {
124
+    title: "Mostrar Columnas",
125
+    titleAria: "Mostrar/Ocultar Columnas",
126
+  },
127
+  selectedRows: {
128
+    text: "Elemento(s) selecionado",
129
+    delete: "Eliminar",
130
+    deleteAria: "Eliminar Columnas Seleccionadas",
131
+  },
71 132
 }

+ 26 - 5
src/Pages/ContrasV2.jsx

@@ -9,17 +9,21 @@ import { TableStyle, TextLabels } from '../Components/Password/TableStyle'
9 9
 import { useQuery } from 'react-query';
10 10
 import { Service } from '../Utils/HTTP.js'
11 11
 import { useSelector } from 'react-redux';
12
+import {  ModalEdit } from '../Components/Password/Operation'
12 13
 
13 14
 export function Contrasv2() {
14 15
 
15 16
   const auth = useSelector((state) => state.token)
17
+  const [visible,setVisible] = React.useState(false)
18
+  const [password,setPassword] = React.useState(null)
16 19
 
17 20
   const getAllPwd = async () => {
18 21
     let rest = new Service('/contrasenia/getallbyidUsr');
19 22
     return await rest.getQuery(auth.token)
20 23
   }
21
-  
22
-  const { data, status  } = useQuery('passwords', getAllPwd );
24
+
25
+  const { data, status } = useQuery('passwords', getAllPwd);
26
+
23 27
   const options = {
24 28
     filterType: 'checkbox',
25 29
     customToolbar: () => {
@@ -27,7 +31,14 @@ export function Contrasv2() {
27 31
         <CustomToolbar />
28 32
       );
29 33
     },
30
-    textLabels: TextLabels
34
+    textLabels: TextLabels,
35
+    onRowClick: (password) => {
36
+      let [plaza, pwd] = password;
37
+      setPassword({pwd,plz:plaza});
38
+      console.log('password: ',password)
39
+      setVisible(true);
40
+    },
41
+    elevation:9
31 42
   };
32 43
 
33 44
   return (
@@ -39,13 +50,23 @@ export function Contrasv2() {
39 50
               <MUIDataTable
40 51
                 sx={{ '& MuiPaper': { elevation: 0, boxShadow: 'none', color: "red" } }}
41 52
                 title={"Contraseñas"}
42
-                data={Build( status ==='success' ? data.data : [])}
53
+                data={Build(status === 'success' ? data.data : [])}
43 54
                 columns={Encabezados}
44 55
                 options={options}
45
-                />
56
+              />
46 57
             </ThemeProvider>
47 58
           </Paper>
48 59
         </Box>
60
+        {
61
+          password ?
62
+            (
63
+              <ModalEdit
64
+                password={password}
65
+                open={visible}
66
+                handleOpen={setVisible}
67
+              />
68
+            ): null
69
+        }
49 70
       </div>
50 71
     </div>
51 72
   );

+ 0 - 1
src/Pages/Home.jsx

@@ -11,7 +11,6 @@ import { useQuery } from 'react-query';
11 11
 export function Home() {
12 12
 
13 13
   const auth = useSelector((state) => state.token)
14
-  // const profile = useSelector((state) => state.user.profile)
15 14
 
16 15
   const getAllPwd = async () => {
17 16
     let rest = new Service('/contrasenia/getallbyidUsr');