Bläddra i källkod

user permis config

amenpunk 1 år sedan
förälder
incheckning
ed87383082
3 ändrade filer med 199 tillägg och 3 borttagningar
  1. 28 0
      src/App.css
  2. 164 0
      src/Components/Password/Steps/TypePwd.jsx
  3. 7 3
      src/Css/all.css

+ 28 - 0
src/App.css

@@ -433,3 +433,31 @@
433 433
   object-position: left top;
434 434
   border: 2px solid black;
435 435
 }
436
+.seluser_type{
437
+  margin:3px solid black;
438
+  margin-bottom: 5px;
439
+}
440
+.rolelist{
441
+  display: flex;
442
+  flex-direction: row;
443
+  flex-wrap: wrap;
444
+  justify-content: space-between;
445
+  align-items: flex-start;
446
+  align-content: flex-start;
447
+}
448
+#demo-radio-buttons-group-label{
449
+  font-weight: bold;
450
+}
451
+.typepwdlist{
452
+  border-bottom: 1px solid gainsboro;
453
+  padding: 15px;
454
+}
455
+.titleMarked{
456
+  /* color : gray; */
457
+}
458
+.gapwdrole{
459
+  display: flex;
460
+  flex-direction: column;
461
+  flex-wrap: wrap;
462
+  gap: 10px;
463
+}

+ 164 - 0
src/Components/Password/Steps/TypePwd.jsx

@@ -0,0 +1,164 @@
1
+import { useEffect, useState } from 'react'
2
+import { Service } from '../../../Utils/HTTP.js'
3
+import { useSelector } from 'react-redux'
4
+import {
5
+  FormControl, RadioGroup, FormControlLabel, Radio, FormLabel, Checkbox,
6
+  TextField, Box
7
+} from '@mui/material'
8
+
9
+import { Simple as Loading } from '../../Generics/loading.jsx'
10
+
11
+function Marked({ step }) {
12
+  return (<strong className="important_marked">{step}</strong>)
13
+}
14
+
15
+function Title({ title, step }) {
16
+  return (<h5 className="titleMarked">{title}</h5>)
17
+}
18
+
19
+function PasswordInfoForm() {
20
+  return (
21
+    <Box
22
+      component="form"
23
+      sx={{
24
+        '& > :not(style)': { m: 1, width: '25ch' },
25
+      }}
26
+      noValidate
27
+      autoComplete="off"
28
+    >
29
+      <TextField id="outlined-basic" label="Outlined" variant="outlined" />
30
+      <TextField id="filled-basic" label="Filled" variant="filled" />
31
+      <TextField id="standard-basic" label="Standard" variant="standard" />
32
+    </Box>
33
+  );
34
+}
35
+
36
+
37
+
38
+export default function PermisosList(props) {
39
+  return (
40
+    <FormControl className="rolelist" >
41
+      <FormLabel id="demo-radio-buttons-group-label">{props.label}</FormLabel>
42
+      <RadioGroup
43
+        aria-labelledby="demo-radio-buttons-group-label"
44
+        defaultValue="female"
45
+        name="radio-buttons-group"
46
+      >
47
+        {
48
+
49
+          props.data.length === 0 ? <Loading /> :
50
+            props.data.map((r) => {
51
+              console.log(r)
52
+              return (
53
+                <FormControlLabel value={r.id} control={<Checkbox />} label={r.nombre} />
54
+              )
55
+            })
56
+        }
57
+      </RadioGroup>
58
+    </FormControl>
59
+  );
60
+}
61
+
62
+function TipoUsuarios(props) {
63
+  let { type, setType } = props
64
+  const handleChange = (event) => {
65
+    setType(event.target.value);
66
+  };
67
+
68
+  return (
69
+    <FormControl>
70
+      <FormLabel id="demo-radio-buttons-group-label">Nivel de Acceso</FormLabel>
71
+      <RadioGroup
72
+        className="seluser_type"
73
+        row
74
+        aria-labelledby="demo-row-radio-buttons-group-label"
75
+        name="row-radio-buttons-group"
76
+        value={type}
77
+        onChange={handleChange}
78
+      >
79
+        <FormControlLabel value={0} control={<Checkbox />} label="Administrador" />
80
+        <FormControlLabel value={1} control={<Checkbox />} label="Asistente" />
81
+        <FormControlLabel value={2} control={<Checkbox />} label="Candidato" />
82
+      </RadioGroup>
83
+    </FormControl>
84
+  );
85
+}
86
+
87
+
88
+export function TypePwd(props) {
89
+
90
+  let auth = useSelector(state => state.token)
91
+  let [recursos, setRecursos] = useState(null)
92
+  let [userType, setUserType] = useState(1)
93
+
94
+
95
+  useEffect(() => {
96
+
97
+    const getRecursos = () => {
98
+      let rest = new Service('/recursos/allow')
99
+      return rest.getQuery(auth.token);
100
+    }
101
+    const groupRecursos = (recursos) => {
102
+      let groups = {};
103
+      recursos.forEach((r) => {
104
+        if (groups[r.grupo]) {
105
+          groups[r.grupo].push(r)
106
+        } else {
107
+          groups[r.grupo] = [r]
108
+        }
109
+      })
110
+
111
+      assignRecursos(groups)
112
+    }
113
+
114
+    const assignRecursos = (recursos_api) => {
115
+      let templete = {
116
+        1: { "label": 'Puestos', data: [] },
117
+        2: { "label": 'Varios', data: [] },
118
+        3: { "label": 'General', data: [] }
119
+      }
120
+
121
+      Object.keys(recursos_api)
122
+        .forEach((k) => {
123
+          templete[k].data = recursos_api[k];
124
+        })
125
+      console.log('BUILD:', templete)
126
+      setRecursos(templete)
127
+    }
128
+
129
+    getRecursos()
130
+      .then(({ data }) => groupRecursos(data))
131
+      .catch((err) => console.log('ERROR:', err))
132
+
133
+  }, [auth.token])
134
+
135
+  console.log("USER TYPE:", userType)
136
+
137
+  return (
138
+    <div class="gapwdrole">
139
+      <Title title="Seleciona el tipo de contraseña" step={"A"} />
140
+
141
+      <div className="typepwdlist">
142
+        <TipoUsuarios type={userType} setType={setUserType} />
143
+      </div>
144
+
145
+      {
146
+        parseInt(userType) === 1 && (
147
+          <div>
148
+            <div className="typepwdlist">
149
+              <Title title="Informacion de la contraseña" step={"B"} />
150
+              <PasswordInfoForm />
151
+            </div>
152
+
153
+            <div className="typepwdlist">
154
+              <Title title="Selecciona los privilegios" step={"C"} />
155
+              {recursos && Object.keys(recursos).map((k) => PermisosList( recursos[k] )) }
156
+            </div>
157
+          </div>
158
+        )
159
+      }
160
+
161
+    </div>
162
+  )
163
+
164
+}

+ 7 - 3
src/Css/all.css

@@ -827,6 +827,8 @@ table.dataTable tbody th, table.dataTable tbody td {
827 827
 .btn_add_producto span {
828 828
     display: block;
829 829
     padding: 6px;
830
+    font-weight: bold;
831
+    font-size:11px;
830 832
 }
831 833
 .modal-header {
832 834
     display: -ms-flexbox;
@@ -4023,6 +4025,8 @@ All this is done for any sub-level being entered.
4023 4025
     padding: 5px;
4024 4026
     padding-bottom: 5px;
4025 4027
 }
4026
-
4027
-
4028
-
4028
+.important_marked{
4029
+  font-weight: bold;
4030
+  font-size: 20px;
4031
+  color : red;
4032
+}