Added custom notification
This commit is contained in:
@@ -41,13 +41,13 @@ var category = {
|
||||
headers: {'x-query': window.location.search}
|
||||
})
|
||||
.then(function(result) {
|
||||
console.log(result)
|
||||
category.current = {}
|
||||
if (result.status == true) {
|
||||
m.route.set('/kategori')
|
||||
} else if (result.status == 401) {
|
||||
user.logout();
|
||||
}
|
||||
window.message = result.message
|
||||
})
|
||||
},
|
||||
entry: function() {
|
||||
@@ -59,20 +59,24 @@ var category = {
|
||||
headers: {'x-query': window.location.search}
|
||||
})
|
||||
.then(function(result) {
|
||||
console.log(result);
|
||||
if (result.status == true) {
|
||||
category.loadList()
|
||||
} else if (result.status == 401) {
|
||||
user.logout()
|
||||
}
|
||||
window.message = result.message
|
||||
})
|
||||
},
|
||||
toggleStatus: function(id){
|
||||
category.current = _.find(category.list, function(o) { return o.id == id })
|
||||
if (category.current.posts == 0) {
|
||||
category.current.status == 1 ? category.current.status = 0 : category.current.status = 1
|
||||
category.save()
|
||||
} else {
|
||||
category.current = {}
|
||||
m.redraw()
|
||||
window.message = 'Kategori memiliki pengumuman aktif'
|
||||
}
|
||||
category.save()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,10 @@ var post = {
|
||||
.then(function(response) {
|
||||
if (response.status) {
|
||||
m.route.set(response.route_to)
|
||||
} else {
|
||||
console.log(response);
|
||||
}
|
||||
post.current = {}
|
||||
post.loading = false
|
||||
window.message = response.message
|
||||
})
|
||||
},
|
||||
save: function() {
|
||||
@@ -61,16 +60,15 @@ var post = {
|
||||
url: '/posts/put/' + window.location.search,
|
||||
data: post.current,
|
||||
withCredentials: true,
|
||||
headers: {client: 'api'}
|
||||
headers: {client: 'api', 'x-query': window.location.search}
|
||||
})
|
||||
.then(function(response) {
|
||||
post.current = {}
|
||||
if (response.status) {
|
||||
m.route.set(response.route_to)
|
||||
} else {
|
||||
console.log(response);
|
||||
}
|
||||
post.loading = false;
|
||||
window.message = response.message
|
||||
})
|
||||
},
|
||||
toggleStatus: function(id) {
|
||||
@@ -88,21 +86,23 @@ var post = {
|
||||
|
||||
post.current = _.find(post.list, function(o) { return o.id == id })
|
||||
// console.log(new Date(post.current.valid_at) > new Date());
|
||||
if (new Date(post.current.valid_at) > new Date()) {
|
||||
status = 2
|
||||
// console.log(post.current.id, 'soon');
|
||||
} else if (new Date(post.current.valid_at) <= new Date()) {
|
||||
if (new Date(post.current.expired_at) < new Date()) {
|
||||
status = 0
|
||||
// console.log(post.current.id, 'expired');
|
||||
} else {
|
||||
status = 1
|
||||
// console.log(post.current.id, 'active');
|
||||
if (post.current.status != 0) {
|
||||
if (new Date(post.current.valid_at) > new Date()) {
|
||||
status = 2
|
||||
// console.log(post.current.id, 'soon');
|
||||
} else if (new Date(post.current.valid_at) <= new Date()) {
|
||||
if (new Date(post.current.expired_at) < new Date()) {
|
||||
status = 0
|
||||
// console.log(post.current.id, 'expired');
|
||||
} else {
|
||||
status = 1
|
||||
// console.log(post.current.id, 'active');
|
||||
}
|
||||
}
|
||||
if (post.current.status != status) {
|
||||
post.current.status = status
|
||||
post.save()
|
||||
}
|
||||
}
|
||||
if (post.current.status != status) {
|
||||
post.current.status = status
|
||||
post.save()
|
||||
}
|
||||
// console.log(post.current);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,8 @@ var user = {
|
||||
.then(function(response) {
|
||||
if (response.status == true) {
|
||||
window.location = response.redirect_to
|
||||
} else {
|
||||
console.log(response.status);
|
||||
}
|
||||
window.message = response.message
|
||||
})
|
||||
},
|
||||
logout: function() {
|
||||
@@ -26,26 +25,26 @@ var user = {
|
||||
headers: {client: 'api', 'x-query': window.location.search}
|
||||
})
|
||||
.then(function(response) {
|
||||
console.log(response);
|
||||
if (response.status) {
|
||||
window.location = response.redirect_to
|
||||
}
|
||||
window.message = response.message
|
||||
})
|
||||
},
|
||||
register: function() {
|
||||
return m.request({
|
||||
method: 'POST',
|
||||
url: '/post',
|
||||
url: '/post/' + window.location.search,
|
||||
data: user.current,
|
||||
withCredentials: true,
|
||||
headers: {client: 'api', 'x-query': window.location.search}
|
||||
})
|
||||
.then(function(response) {
|
||||
console.log(response);
|
||||
if (response.status == true) {
|
||||
m.route.set(response.route_to)
|
||||
} else {
|
||||
console.log(response);
|
||||
}
|
||||
window.message = response.message
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user