-
Notifications
You must be signed in to change notification settings - Fork 0
/
adduser.html
137 lines (123 loc) · 5.7 KB
/
adduser.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document 3</title>
</head>
<link href="https://cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-grids/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-buttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-popups/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-navigations/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-dropdowns/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-lists/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-calendars/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-splitbuttons/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-base/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-inputs/styles/material.css" rel="stylesheet">
<link href="https://cdn.syncfusion.com/ej2/ej2-dropdowns/styles/material.css" rel="stylesheet">
<style>
.e-row[aria-selected="true"] .e-customizedExpandcell {
background-color: #e0e0e0;
}
.e-grid.e-gridhover tr[role='row']:hover {
background-color: #eee;
}
.e-expand::before {
content: '\e5b8';
}
.loader {
border: 16px solid #f3f3f3;
border-radius: 50%;
border-top: 16px solid #3498db;
width: 120px;
height: 120px;
-webkit-animation: spin 2s linear infinite; /* Safari */
animation: spin 2s linear infinite;
}
</style>
<body>
<div id="container">
<div id="Grid"></div>
</div>
<script src="https://cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
<script>
var ele = document.getElementById('container');
if(ele) {
ele.style.visibility = "visible";
}
function fetchDataAndUpdateGrid() {
fetch('https://web.reprico.work/fmasinv/Inventory/GetAllInventoryUsers')
.then(response => response.json())
.then(data => {
var grid = new ej.grids.Grid({
dataSource: data,
editSettings: { allowEditing: true, allowAdding: true, mode: 'Normal' },
columns: [
{ field: 'id', headerText: 'ID', textAlign: 'Left', width: 120, type: 'number', allowEditing: false },
{ field: 'fullName', width: 140, headerText: 'Nombre Completo', type: 'string',width: 220 },
{ field: 'userName', headerText: 'Usuario', textAlign: 'Left', width: 120 },
{ field: 'password', headerText: 'Contrasena', textAlign: 'Left', width: 120, editType: 'passwordedit' },
{
field: 'active', // make sure the field name matches the data source field exactly
headerText: 'Activo',
textAlign: 'Center',
type: 'boolean',
width: 100,
editType: 'booleanedit',
displayAsCheckBox: true // displays the content as a checkbox
},
{
headerText: 'Accion',
width: 120,
commands: [
{ type: 'Edit', buttonOption: { iconCss: 'e-icons e-edit', cssClass: 'e-flat' } },
{ type: 'Save', buttonOption: { iconCss: 'e-icons e-update', cssClass: 'e-flat' } },
{ type: 'Cancel', buttonOption: { iconCss: 'e-icons e-cancel-icon', cssClass: 'e-flat' } }
]
}
],
actionBegin: function (args) {
if (args.requestType === 'save') {
const confirmation = window.confirm("Estas seguro?");
if (!confirmation) {
args.cancel = true;
return;
}
const userData = {
id : args.data.id,
fullName: args.data.fullName,
userName: args.data.userName,
password: args.data.password,
active: args.data.active
};
args.cancel = true;
fetch('https://web.reprico.work/fmasinv/Inventory/UpsertInventoryUser', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(userData)
})
.then(res => res.json())
.then(updatedData => {
location.reload();
})
.catch(err => {
console.error("Error updating data:", err);
});
}
}
});
grid.appendTo('#Grid');
})
.catch(error => {
console.error("Error fetching data:", error);
});
}
fetchDataAndUpdateGrid();
</script>
</body>
</html>