Added users page, function to delete user and function to count number of location inserted by user
Repository
https://github.com/sogatanco/nebeng
About NEBENG
NEBENG (Nemu-Bengkel) is an application to find the nearest car workshop and motorcycle workshop. When your vehicle is damaged in transit, you don't know where it is closest to repairing it. Nebeng is the solution.
What feature(s) did you add?
Users Page
It is a page to display all registered users on Nebeng Aplication. Each users consists of user full name, email, cellphone number, gender and number of locations entered by the user.Function to Delete User
It is a function to remove users who violates the rules. This function accessed by pressing trash button on right-top of user card view.Count number of location inserted by user
Then Number of location that inputed by user not available when request USER API. So here we need to request another API to get the location number. There is an API to get the Location with parameter is user
How did you implement it/them?
All processes in this added features are made using the PHP (Codeigniter), Bootstrap and jQuery programming languages. data and action requested from the Rest API that we made yesterday. Here's a little code snippet:
- Users Page
function getUser(){
$("#content").html("")
$.ajax({
type:'get',
url:'../../api/general/user?token=1234567',
success:function(response){
console.log(response)
$.each(response.data, function(i,user){
var profil=user.us_profil;
if(profil==null||profil==""){
profil="profil_null.png"
}
var nama=ifUnknown(user.us_nama);
var email=user.us_email;
var hp=ifUnknown(user.us_nomorhp);
var sex=ifUnknown(user.us_jk);
var join=user.us_gabung;
$("#content").append(`
`+capitalFirst(nama)+`
`+email.substring(0,22)+`
`+hp+`
+email+`">
Bengkel
+i+`">000
Join
`+prettyDate(join)+`
Gender
`+sex.toUpperCase()+`
`)
}
- Function to Delete Users
$("#content").on("click","#hapus", function(){
var conf=confirm("Are you sure to Delete it ?");
if(conf==true){
console.log($(this).data("email"))
$.ajax({
type:"DELETE",
url:"../../api/admin/deleteuser",
data:{
token:Cookies.get('token'),
username:$(this).data("email")
},
success:function(res){
alert("Deleted")
getUser()
},
error:function(err){
alert("failed to delete")
}
})
}
})
- function to count number of location inserted by user
this function added ingetUser()function
$.ajax({
type:'get',
url:'../../nebeng/api/general/bengkel?token=1234567&pemilik='+email,
success:function(response){
jbengkel=response.data.length
$("#count"+i).html(addZero(jbengkel,3))
},
error:function(err){
jbengkel=0
$("#count"+i).html(addZero(jbengkel,3))
}
})
To Convert date to pretty word like 1 MIN, 3 DAYS, 1 WEEKS, 2 MONTHS, etc I used this following function :
function prettyDate(time){
var date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ")),
diff = (((new Date()).getTime() - date.getTime()) / 1000),
day_diff = Math.floor(diff / 86400);
if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
return;
return day_diff == 0 && (
diff < 60 && "NOW" ||
diff < 3600 && Math.floor( diff / 60 ) + " MIN" ||
diff < 7200 && "1 hour ago" ||
diff < 86400 && Math.floor( diff / 3600 ) + " H") ||
day_diff < 7 && day_diff + " D" ||
day_diff < 31 && Math.ceil( day_diff / 7 ) + " W";
}
// funtion add leading zero
function addZero(num, size) {
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
}
Commits on Github
https://github.com/sogatanco/nebeng/compare/master@%7B06-20-19%7D...master
Github Account
Leave Added users page, function to delete user and function to count number of location inserted by user to:
Read more #utopian-io posts
Best Posts From sogata
We have not curated any of sogata's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From sogata
- [Nemu-Bengkel] Added Option to sort list by rating and by category
- Portfolio - Programer Portfolio Website
- Bagaimana Cara Menampilkan Maps Google Di Android
- Added List Location Activity and Sort Data by Distance with Bubble Sort Algorithm
- Added users page, function to delete user and function to count number of location inserted by user
- deleted
- Added Unapprove Page, Detail Modal and function to delete and approve Mechanic Location (bengkel)
- Added Admin Page for NEBENG app
- Created REST API for NEBENG - Android Application for searching nearest car or motorcycle workshop
- Introducing NEBENG - Android Application for searching nearest car or motorcycle workshop