Commit d288374b authored by Muhamad's avatar Muhamad

benerin switch user status

parent a56718c6
...@@ -2958,7 +2958,8 @@ def user_data(request): ...@@ -2958,7 +2958,8 @@ def user_data(request):
ag.name, ag.name,
au.is_staff, au.is_staff,
au.is_superuser, au.is_superuser,
au.file_path au.file_path,
au.phone
FROM FROM
auth_user au, auth_user au,
auth_user_groups aug, auth_user_groups aug,
...@@ -2982,7 +2983,8 @@ def user_data(request): ...@@ -2982,7 +2983,8 @@ def user_data(request):
ag.name, ag.name,
au.is_staff, au.is_staff,
au.is_superuser, au.is_superuser,
au.file_path au.file_path,
au.phone
FROM FROM
auth_user au, auth_user au,
auth_user_groups aug, auth_user_groups aug,
...@@ -2999,6 +3001,13 @@ def user_data(request): ...@@ -2999,6 +3001,13 @@ def user_data(request):
user_res = [] user_res = []
for rows in allUser: for rows in allUser:
if rows[8] == True and rows[9] == True:
jabatan = 'Super user'
elif rows[8] == True and rows[9] == False:
jabatan = 'Staff'
elif rows[8] == False and rows[9] == False:
jabatan = 'User'
datas = { datas = {
"id": rows[0], "id": rows[0],
"username": rows[1], "username": rows[1],
...@@ -3007,7 +3016,9 @@ def user_data(request): ...@@ -3007,7 +3016,9 @@ def user_data(request):
"isactive": rows[4], "isactive": rows[4],
"last": rows[5], "last": rows[5],
"group": rows[7], "group": rows[7],
"filepath": rows[10] "filepath": rows[10],
"phone": rows[11],
"jabatan": jabatan
} }
user_res.append(datas) user_res.append(datas)
......
...@@ -364,7 +364,7 @@ def deactivateUser(request): ...@@ -364,7 +364,7 @@ def deactivateUser(request):
# # print(type(status)+status) # # print(type(status)+status)
# # print(type(True)) # # print(type(True))
# print(status == 'True') # print(status == 'True')
if status == 'True': if status == 'true':
sql = "f" sql = "f"
else: else:
sql = "t" sql = "t"
......
#map-jalan>div.leaflet-control-container>div.leaflet-top.leaflet-left>div>div { #map-jalan>div.leaflet-control-container>div.leaflet-top.leaflet-left>div>div {
display: none; display: none;
}
#tbody_user_list>tr>td.text-center>div>div.col-md-6.text-right>a>i {
font-size: 16px!important;
top: -3px;
}
.switch_custom {
position: relative;
display: inline-block;
width: 36px;
height: 20px;
}
.switch_custom input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgb(59, 62, 71);
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 18px;
width: 18px;
left: 1px;
bottom: 1px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked+.slider {
background-color: #2196F3;
}
input:focus+.slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked+.slider:before {
-webkit-transform: translateX(16px);
-ms-transform: translateX(16px);
transform: translateX(16px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
#user_profile>.table-sm>thead>tr>th,
.table-sm>tbody>tr>th,
.table-sm>tfoot>tr>th,
.table-sm>thead>tr>td,
.table-sm>tbody>tr>td,
.table-sm>tfoot>tr>td {
padding: 13px 20px;
} }
\ No newline at end of file
...@@ -168,8 +168,8 @@ function load_manage() { ...@@ -168,8 +168,8 @@ function load_manage() {
var last = data['data'][i]['last']; var last = data['data'][i]['last'];
var isactive = data['data'][i]['isactive']; var isactive = data['data'][i]['isactive'];
var no_telp = +6281234567890 var no_telp = data['data'][i]['phone'];
var jabatan = 'Support' var jabatan = data['data'][i]['jabatan'];
if (isactive == true) { if (isactive == true) {
var isac = 'checked' var isac = 'checked'
...@@ -186,13 +186,14 @@ function load_manage() { ...@@ -186,13 +186,14 @@ function load_manage() {
<td>` + last + `</td> <td>` + last + `</td>
<td class="text-center" style='padding:0px;'> <td class="text-center" style='padding:0px;'>
<div class='row'> <div class='row'>
<div class='col-md-6 text-right' style='margin-top:5px'> <div class='col-md-6 text-right' style='margin-top:8px'>
<a onclick="loaduserbyid('` + id + `')"><i class=" icon-pencil7"></i>Edit</a> <a onclick="loaduserbyid('` + id + `')"><i class=" icon-pencil7"></i>Edit</a>
</div> </div>
<div class='col-md-6 text-left'> <div class='col-md-6 text-left'>
<div class="checkbox checkbox-switchery"> <div class="checkbox switch_custom">
<label> <label>
<input type="checkbox" class="switchery-custom-x" id="checkbox` + id + `" onclick="switchuserstatus('` + id + `, ` + isactive + `','` + id + `')" ` + isac + ` > <input type="checkbox" class="slider round" id="checkbox` + id + `" onclick="switchuserstatus('` + id + `, ` + isactive + `','` + id + `')" ` + isac + ` >
<span class="slider round"></span>
</label> </label>
</div> </div>
</div> </div>
...@@ -481,7 +482,7 @@ function download_point_list(type, fn, dl) { ...@@ -481,7 +482,7 @@ function download_point_list(type, fn, dl) {
function loadGroups(isSelect) { function loadGroups(isSelect) {
var isObject = {} var isObject = {}
console.log(isSelect)
isObject.func_name = "loadGroups"; isObject.func_name = "loadGroups";
$.ajax({ $.ajax({
...@@ -492,7 +493,7 @@ function loadGroups(isSelect) { ...@@ -492,7 +493,7 @@ function loadGroups(isSelect) {
success: function(data) { success: function(data) {
let response = data; let response = data;
console.log(response)
if (response.code == 0) { if (response.code == 0) {
var groups = response.data; var groups = response.data;
var html = `<option value="null" selected disabled>-- Pilih Group --</option>`; var html = `<option value="null" selected disabled>-- Pilih Group --</option>`;
...@@ -502,7 +503,7 @@ function loadGroups(isSelect) { ...@@ -502,7 +503,7 @@ function loadGroups(isSelect) {
for (j in isSelect) { for (j in isSelect) {
if (isSelect[j] == groups[i]) { if (isSelect[j] == groups[i]) {
html += `<option value="` + groups[i] + `" selected>` + groups[i] + `</option>`; html += `<option value="` + groups[i] + `" selected>` + groups[i] + `</option>`;
console.log(groups[i])
} else { } else {
html += `<option value="` + groups[i] + `">` + groups[i] + `</option>`; html += `<option value="` + groups[i] + `">` + groups[i] + `</option>`;
} }
...@@ -521,7 +522,7 @@ function loadGroups(isSelect) { ...@@ -521,7 +522,7 @@ function loadGroups(isSelect) {
$("#select_group").html(html); $("#select_group").html(html);
$("#select_group_parent").html(html); $("#select_group_parent").html(html);
console.log(html)
} else { } else {
$("#select_group").html("group tidak tersedia"); $("#select_group").html("group tidak tersedia");
$("#select_group_parent").html("group tidak tersedia"); $("#select_group_parent").html("group tidak tersedia");
...@@ -531,8 +532,15 @@ function loadGroups(isSelect) { ...@@ -531,8 +532,15 @@ function loadGroups(isSelect) {
}); });
} }
function swal_switch(isConfirm) { function swal_switch(isConfirm, c, isObject) {
var checkbox = document.getElementById("checkbox" + c);
if (isConfirm == true) { if (isConfirm == true) {
if (checkbox.checked == true) {
checkbox.checked = true
} else {
checkbox.checked = false
}
$.ajax({ $.ajax({
url: "/switchStatus/", url: "/switchStatus/",
...@@ -543,7 +551,7 @@ function swal_switch(isConfirm) { ...@@ -543,7 +551,7 @@ function swal_switch(isConfirm) {
let response = data; let response = data;
if (isObject.stat == "True") { if (isObject.stat == "true") {
var inf = "dinonaktifkan" var inf = "dinonaktifkan"
} else { } else {
var inf = "diaktifkan" var inf = "diaktifkan"
...@@ -570,6 +578,11 @@ function swal_switch(isConfirm) { ...@@ -570,6 +578,11 @@ function swal_switch(isConfirm) {
} }
}); });
} else { } else {
if (checkbox.checked == true) {
checkbox.checked = false
} else {
checkbox.checked = true
}
swal("Dibatalkan", "User status tidak berubah", "error"); swal("Dibatalkan", "User status tidak berubah", "error");
} }
} }
...@@ -578,13 +591,13 @@ function swal_switch(isConfirm) { ...@@ -578,13 +591,13 @@ function swal_switch(isConfirm) {
function switchuserstatus(id, c) { function switchuserstatus(id, c) {
var isObject = {} var isObject = {}
var params = id.split(","); var params = id.split(",");
var checkbox = document.getElementById("checkbox" + c);
console.log(checkbox);
isObject.id = params[0]; isObject.id = params[0];
isObject.stat = params[1].replace(" ", ""); isObject.stat = params[1].replace(" ", "");
if (isObject.stat == "True") {
if (isObject.stat == "true") {
var title = "Nonaktifkan"; var title = "Nonaktifkan";
var text = "User tidak akan bisa login jika dinonaktifkan!"; var text = "User tidak akan bisa login jika dinonaktifkan!";
} else { } else {
...@@ -592,7 +605,6 @@ function switchuserstatus(id, c) { ...@@ -592,7 +605,6 @@ function switchuserstatus(id, c) {
var text = "User dapat kembali login jika diaktifkan!"; var text = "User dapat kembali login jika diaktifkan!";
} }
swal({ swal({
title: title + " user?", title: title + " user?",
text: text, text: text,
...@@ -604,26 +616,7 @@ function switchuserstatus(id, c) { ...@@ -604,26 +616,7 @@ function switchuserstatus(id, c) {
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false closeOnCancel: false
}, function(isConfirm) { }, function(isConfirm) {
swal_switch(isConfirm) swal_switch(isConfirm, c, isObject)
// if (cb == 'b') {
// alert('b')
//check it
// if (cb == true) {
// checkbox.checked = false;
// } else {
// checkbox.checked = true
// }
// } else {
// alert('a')
// if (cb == true) {
// checkbox.checked = true;
// } else {
// checkbox.checked = false;
// }
// }
}); });
} }
...@@ -649,7 +642,7 @@ function loaduserbyid(id) { ...@@ -649,7 +642,7 @@ function loaduserbyid(id) {
if (response.code == 0) { if (response.code == 0) {
var user = response.data; var user = response.data;
console.log(user)
$("#inUsername").val(user.username); $("#inUsername").val(user.username);
$("#inNameF").val(user.firstname); $("#inNameF").val(user.firstname);
$("#inNameL").val(user.lastname); $("#inNameL").val(user.lastname);
......
...@@ -645,7 +645,7 @@ ...@@ -645,7 +645,7 @@
<h6 class="modal-title">Delete Point</h6> <h6 class="modal-title">Delete Point</h6>
</div> </div>
<div class="modal-body" style="overflow-x: hidden;max-height: 300px;overflow-y: scroll;padding-left: 15px;"> <div class="modal-body" style="overflow-x: hidden;max-height: 300px;overflow-y: scroll;padding-left: 15px;">
<div id="map-for-delete" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-delete" style="width: 400px;height: 300px;position: relative;margin: 10px;"></div>
<input style="display:none;" id="id_adm_del" type="text" class="form-control" value="` + feature.administrasi.f15 + `"required> <input style="display:none;" id="id_adm_del" type="text" class="form-control" value="` + feature.administrasi.f15 + `"required>
<input style="display:none;" id="nama_table" type="text" class="form-control" value="geo_kantor_administrasi" required> <input style="display:none;" id="nama_table" type="text" class="form-control" value="geo_kantor_administrasi" required>
...@@ -698,7 +698,7 @@ ...@@ -698,7 +698,7 @@
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane active" id="left-tab1-feas-upli"> <div class="tab-pane active" id="left-tab1-feas-upli">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -1221,7 +1221,7 @@ ...@@ -1221,7 +1221,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -1637,7 +1637,7 @@ ...@@ -1637,7 +1637,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -2052,7 +2052,7 @@ ...@@ -2052,7 +2052,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -2499,7 +2499,7 @@ ...@@ -2499,7 +2499,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -2987,7 +2987,7 @@ ...@@ -2987,7 +2987,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -3328,7 +3328,7 @@ ...@@ -3328,7 +3328,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -3706,7 +3706,7 @@ ...@@ -3706,7 +3706,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -4101,7 +4101,7 @@ ...@@ -4101,7 +4101,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -4489,7 +4489,7 @@ ...@@ -4489,7 +4489,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
...@@ -4879,7 +4879,7 @@ ...@@ -4879,7 +4879,7 @@
<div class="tab-pane active" id="right-tab2-feas-upli"> <div class="tab-pane active" id="right-tab2-feas-upli">
<div class="form-group"> <div class="form-group">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin: 10px;"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
......
...@@ -708,7 +708,7 @@ ...@@ -708,7 +708,7 @@
<div class="modal fade" id="user_profile" tabindex="-1" role="dialog" style="margin-left: 50px;padding-left:0px;"> <div class="modal fade" id="user_profile" tabindex="-1" role="dialog" style="margin-left: 50px;padding-left:0px;">
<div class="modal-dialog" style="width: 100%; <div class="modal-dialog" style="width: 100%;
margin: 0px; margin: 0px;
height: 100vh;"> height: 100vh;overflow-y: scroll;">
<div class="modal-content"> <div class="modal-content">
<div class="modal-body"> <div class="modal-body">
...@@ -1984,7 +1984,7 @@ ...@@ -1984,7 +1984,7 @@
<div class="tab-content"> <div class="tab-content">
<div class="tab-pane active" id="left-tab1-feas-upli"> <div class="tab-pane active" id="left-tab1-feas-upli">
<div id="map-for-edit" style="width: 400px;height: 300px;position: relative;margin-left: 100px;"></div> <div id="map-for-edit" style="height: 300px;position: relative;margin:10px"></div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-2 control-label" style="margin-top:10px">Image</label> <label class="col-lg-2 control-label" style="margin-top:10px">Image</label>
<div class="col-lg-9" style="margin-top:10px"> <div class="col-lg-9" style="margin-top:10px">
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
<div class="overlay"> <div class="overlay">
<div class="textover"> <div class="textover">
<i class="icon-camera" style="position: absolute;background-color: white;border-radius: 10px;top: 25%;right: 46%;width: 20px;height: 20px;" title="Ganti Foto Profil"></i> <i class="icon-camera" style="position: absolute;background-color: white;border-radius: 10px;top: 35%;right: 46%;width: 20px;height: 20px;" title="Ganti Foto Profil"></i>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment