Added custom notification
This commit is contained in:
parent
bc21934274
commit
a106344dc8
@ -43,7 +43,9 @@ class Api
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($table == 'kategori') {
|
$get['count'] = count($get['data']);
|
||||||
|
|
||||||
|
if ($table == 'kategori' && $get['count'] != 0) {
|
||||||
if (isset($get['data'][0])) {
|
if (isset($get['data'][0])) {
|
||||||
for ($i=0; $i < count($get['data']); $i++) {
|
for ($i=0; $i < count($get['data']); $i++) {
|
||||||
$get['data'][$i]['posts'] = count(\App\Models\Pengumuman::showAll('pengumuman', [
|
$get['data'][$i]['posts'] = count(\App\Models\Pengumuman::showAll('pengumuman', [
|
||||||
@ -58,8 +60,7 @@ class Api
|
|||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$get['count'] = count($get['data']);
|
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($get);
|
echo json_encode($get);
|
||||||
@ -82,6 +83,7 @@ class Api
|
|||||||
$put['status'] = true;
|
$put['status'] = true;
|
||||||
$put['data'] = $update;
|
$put['data'] = $update;
|
||||||
$put['count'] = count($put['data']);
|
$put['count'] = count($put['data']);
|
||||||
|
$put['message'] = ucfirst($table) . ' berhasil diubah';
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
@ -105,6 +107,7 @@ class Api
|
|||||||
$post['status'] = true;
|
$post['status'] = true;
|
||||||
$post['data'] = $entry;
|
$post['data'] = $entry;
|
||||||
$post['count'] = count($post['data']);
|
$post['count'] = count($post['data']);
|
||||||
|
$post['message'] = ucfirst($table) . ' berhasil ditambahkan';
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -39,14 +39,19 @@ class Home
|
|||||||
$password = $args['password'];
|
$password = $args['password'];
|
||||||
|
|
||||||
$user = Access::showAll([
|
$user = Access::showAll([
|
||||||
['username', '=', $username],
|
['username', '=', $username]
|
||||||
['flag', '=', 0]
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($user == false) {
|
if ($user == false) {
|
||||||
$info = "Username/password salah";
|
$info = "Username/password salah";
|
||||||
$logged_in['status'] = $info;
|
$logged_in['status'] = false;
|
||||||
|
$logged_in['message'] = $info;
|
||||||
} else {
|
} else {
|
||||||
|
if ($user['flag'] != 0) {
|
||||||
|
$info = "User telah login";
|
||||||
|
$logged_in['status'] = false;
|
||||||
|
$logged_in['message'] = $info;
|
||||||
|
}
|
||||||
$hash = Hash::compare($password, $user['salt'], $user['password']);
|
$hash = Hash::compare($password, $user['salt'], $user['password']);
|
||||||
|
|
||||||
if ($hash == true) {
|
if ($hash == true) {
|
||||||
@ -66,11 +71,12 @@ class Home
|
|||||||
$info = "Berhasil masuk";
|
$info = "Berhasil masuk";
|
||||||
$logged_in['status'] = true;
|
$logged_in['status'] = true;
|
||||||
$logged_in['redirect_to'] = '/?s='.$session['id']."&u=".$session['uid'];
|
$logged_in['redirect_to'] = '/?s='.$session['id']."&u=".$session['uid'];
|
||||||
|
$logged_in['message'] = 'Berhasil login';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$info = "Username/password salah";
|
$info = "Username/password salah";
|
||||||
$logged_in['status'] = $info;
|
$logged_in['message'] = $info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
||||||
@ -101,16 +107,18 @@ class Home
|
|||||||
|
|
||||||
$info = "Berhasil keluar";
|
$info = "Berhasil keluar";
|
||||||
$logged_out['status'] = true;
|
$logged_out['status'] = true;
|
||||||
$logged_out['redirect_to'] = '/';
|
$logged_out['redirect_to'] = '';
|
||||||
|
$logged_out['message'] = 'Berhasil logout';
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$logged_out['status'] = $e->getMessage();
|
$logged_out['status'] = false;
|
||||||
|
$logged_out['message'] = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
||||||
echo json_encode($logged_out);die();
|
echo json_encode($logged_out);die();
|
||||||
}
|
}
|
||||||
// Session::flash('info', $info);
|
Session::flash('info', $info);
|
||||||
// Redirect::to('/');
|
Redirect::to('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function register()
|
public function register()
|
||||||
@ -131,7 +139,7 @@ class Home
|
|||||||
foreach ($args as $value) {
|
foreach ($args as $value) {
|
||||||
if ($value == '') {
|
if ($value == '') {
|
||||||
$info = 'Semua data harus diisi';
|
$info = 'Semua data harus diisi';
|
||||||
$registered['status'] = 'false';
|
$registered['status'] = false;
|
||||||
$registered['message'] = $info;
|
$registered['message'] = $info;
|
||||||
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
||||||
echo json_encode($registered);die();
|
echo json_encode($registered);die();
|
||||||
@ -183,7 +191,8 @@ class Home
|
|||||||
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'route_to' => ''
|
'route_to' => '',
|
||||||
|
'message' => 'User berhasil ditambahkan'
|
||||||
]);die();
|
]);die();
|
||||||
}
|
}
|
||||||
Session::flash('info', 'Registrasi berhasil');
|
Session::flash('info', 'Registrasi berhasil');
|
||||||
|
@ -338,6 +338,7 @@ class Posts
|
|||||||
}
|
}
|
||||||
$post['status'] = true;
|
$post['status'] = true;
|
||||||
$post['route_to'] = '';
|
$post['route_to'] = '';
|
||||||
|
$post['message'] = 'Pengumuman berhasil ditambahkan';
|
||||||
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
||||||
echo json_encode($post);
|
echo json_encode($post);
|
||||||
die();
|
die();
|
||||||
@ -350,6 +351,7 @@ class Posts
|
|||||||
|
|
||||||
public function put($args)
|
public function put($args)
|
||||||
{
|
{
|
||||||
|
// echo json_encode($args); die();
|
||||||
$update = [];
|
$update = [];
|
||||||
|
|
||||||
if (isset($args['_addon'])) {
|
if (isset($args['_addon'])) {
|
||||||
@ -413,6 +415,7 @@ class Posts
|
|||||||
if ($this->model->update($args, $id)) {
|
if ($this->model->update($args, $id)) {
|
||||||
$update['status'] = true;
|
$update['status'] = true;
|
||||||
$update['route_to'] = '';
|
$update['route_to'] = '';
|
||||||
|
$update['message'] = 'Pengumuman berhasil diubah';
|
||||||
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
if (isset($_SERVER['HTTP_CLIENT']) && $_SERVER['HTTP_CLIENT'] == 'api') {
|
||||||
echo json_encode($update);
|
echo json_encode($update);
|
||||||
die();
|
die();
|
||||||
|
@ -12,21 +12,6 @@
|
|||||||
<body>
|
<body>
|
||||||
<script src="/js/landing.js"></script>
|
<script src="/js/landing.js"></script>
|
||||||
|
|
||||||
<script>
|
<script></script>
|
||||||
function fadeOutEffect() {
|
|
||||||
var fadeTarget = document.getElementById("info");
|
|
||||||
var fadeEffect = setInterval(function () {
|
|
||||||
if (!fadeTarget.style.opacity) {
|
|
||||||
fadeTarget.style.opacity = 1;
|
|
||||||
}
|
|
||||||
if (fadeTarget.style.opacity < 0.1) {
|
|
||||||
clearInterval(fadeEffect);
|
|
||||||
fadeTarget.remove();
|
|
||||||
} else {
|
|
||||||
fadeTarget.style.opacity -= 0.1;
|
|
||||||
}
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
23
assets/js/components/label.js
Normal file
23
assets/js/components/label.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
let m = require('mithril')
|
||||||
|
let fadeOutEffect = require('../others/fadeOutEffect')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
view: function() {
|
||||||
|
return m('.label.top', {
|
||||||
|
style: {
|
||||||
|
position: 'fixed',
|
||||||
|
top: '15px',
|
||||||
|
fontSize: 'small',
|
||||||
|
margin: '0 35%',
|
||||||
|
left: '0',
|
||||||
|
right: '0',
|
||||||
|
overflowY: 'auto',
|
||||||
|
maxWidth: '100%',
|
||||||
|
maxHeight: '100%'
|
||||||
|
},
|
||||||
|
onclick: function() {
|
||||||
|
fadeOutEffect.fade(this)
|
||||||
|
}
|
||||||
|
}, window.message)
|
||||||
|
}
|
||||||
|
}
|
@ -27,7 +27,7 @@ var listAdmin = {
|
|||||||
m('em', [
|
m('em', [
|
||||||
pengumuman.creatorName,
|
pengumuman.creatorName,
|
||||||
' - ',
|
' - ',
|
||||||
fecha.format(fecha.parse(pengumuman.valid_at, 'YYYY-MM-DD H:i:s'), 'DD/MM/YYYY')
|
fecha.format(fecha.parse(pengumuman.created_at, 'YYYY-MM-DD H:i:s'), 'DD/MM/YYYY')
|
||||||
])
|
])
|
||||||
]),
|
]),
|
||||||
m('span.stack', {style:'color:' + pengumuman.foreground + '; overflow-y: auto;'}, m.trust(marked(pengumuman.content))),
|
m('span.stack', {style:'color:' + pengumuman.foreground + '; overflow-y: auto;'}, m.trust(marked(pengumuman.content))),
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
let m = require('mithril')
|
let m = require('mithril')
|
||||||
|
let _ = require('lodash')
|
||||||
let user = require('../models/user')
|
let user = require('../models/user')
|
||||||
|
let fadeOutEffect = require('../others/fadeOutEffect')
|
||||||
|
|
||||||
var login = {
|
var login = {
|
||||||
view: function() {
|
view: function() {
|
||||||
@ -18,7 +20,8 @@ var login = {
|
|||||||
maxlength: '25',
|
maxlength: '25',
|
||||||
autocomplete: 'off',
|
autocomplete: 'off',
|
||||||
oninput: m.withAttr('value', function(value) {user.current.username = value}),
|
oninput: m.withAttr('value', function(value) {user.current.username = value}),
|
||||||
value: user.current.username
|
value: user.current.username,
|
||||||
|
required: 'required'
|
||||||
})),
|
})),
|
||||||
m('.fourth-600.full', m('input', {
|
m('.fourth-600.full', m('input', {
|
||||||
type: 'password',
|
type: 'password',
|
||||||
@ -27,18 +30,32 @@ var login = {
|
|||||||
oninput: m.withAttr('value', function(value) {
|
oninput: m.withAttr('value', function(value) {
|
||||||
user.current.password = value
|
user.current.password = value
|
||||||
}),
|
}),
|
||||||
value: user.current.password
|
value: user.current.password,
|
||||||
|
required: 'required'
|
||||||
})),
|
})),
|
||||||
m('.fourth-600.none'),
|
m('.fourth-600.none'),
|
||||||
m('.fourth-600.none'),
|
m('.fourth-600.none'),
|
||||||
m('div', m('button.half-600.full.pseudo', {
|
m('.half-600.full', m('button.full.pseudo', {
|
||||||
type: 'submit'
|
type: 'submit'
|
||||||
}, [
|
}, [
|
||||||
m('i.fa.fa-check.fa-fw'),
|
m('i.fa.fa-check.fa-fw'),
|
||||||
m('span', {
|
m('span', {
|
||||||
style: 'font-size:smaller;'
|
style: 'font-size:smaller;'
|
||||||
}, 'Masuk')
|
}, 'Masuk')
|
||||||
]))
|
])),
|
||||||
|
m('.fourth-600.none'),
|
||||||
|
m('.fourth-600.none'),
|
||||||
|
_.isNil(window.message) == false ? [
|
||||||
|
m('.half-600.full.label.error', {
|
||||||
|
style: 'margin: 0; font-size: smaller;',
|
||||||
|
onclick: function() {
|
||||||
|
window.message = null
|
||||||
|
}
|
||||||
|
}, window.message),
|
||||||
|
m('.fourth-600.none'),
|
||||||
|
m('.fourth-600.none')
|
||||||
|
]
|
||||||
|
: null
|
||||||
])
|
])
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,8 @@ var registerUser = {
|
|||||||
autocomplete: 'off',
|
autocomplete: 'off',
|
||||||
oninput: m.withAttr('value', function(value) {
|
oninput: m.withAttr('value', function(value) {
|
||||||
user.current.full_name = value
|
user.current.full_name = value
|
||||||
})
|
}),
|
||||||
|
required: 'required'
|
||||||
})),
|
})),
|
||||||
m('.fourth-600.full', m('input', {
|
m('.fourth-600.full', m('input', {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
@ -28,7 +29,8 @@ var registerUser = {
|
|||||||
autocomplete: 'off',
|
autocomplete: 'off',
|
||||||
oninput: m.withAttr('value', function(value) {
|
oninput: m.withAttr('value', function(value) {
|
||||||
user.current.username = value
|
user.current.username = value
|
||||||
})
|
}),
|
||||||
|
required: 'required'
|
||||||
})),
|
})),
|
||||||
m('.fourth-600.full', m('input', {
|
m('.fourth-600.full', m('input', {
|
||||||
type: 'password',
|
type: 'password',
|
||||||
@ -36,7 +38,8 @@ var registerUser = {
|
|||||||
placeholder: 'Password',
|
placeholder: 'Password',
|
||||||
oninput: m.withAttr('value', function(value) {
|
oninput: m.withAttr('value', function(value) {
|
||||||
user.current.password = value
|
user.current.password = value
|
||||||
})
|
}),
|
||||||
|
required: 'required'
|
||||||
})),
|
})),
|
||||||
m('.fourth-600.none'),
|
m('.fourth-600.none'),
|
||||||
m('div', m('button.pseudo.three-fourth-600.full', {
|
m('div', m('button.pseudo.three-fourth-600.full', {
|
||||||
|
@ -10,6 +10,7 @@ let createPost = require('./components/createPost')
|
|||||||
let editPost = require('./components/editPost')
|
let editPost = require('./components/editPost')
|
||||||
let cookie = require('./others/cookie')
|
let cookie = require('./others/cookie')
|
||||||
let idleTimeout = require('./others/idleTimeout')
|
let idleTimeout = require('./others/idleTimeout')
|
||||||
|
let label = require('./components/label')
|
||||||
|
|
||||||
require('../css/index.css')
|
require('../css/index.css')
|
||||||
|
|
||||||
@ -24,13 +25,19 @@ if (page == '') {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
m.route(root, '', {
|
m.route(root, '', {
|
||||||
'': { view: function() { return m('span', [
|
'': { view: function() { return m('span',
|
||||||
|
window.message || window.message != null ?
|
||||||
|
m(label) : null,
|
||||||
|
[
|
||||||
m(nav),
|
m(nav),
|
||||||
m(showPost, { 'status': 3 })
|
m(showPost, { 'status': 3 })
|
||||||
]) } },
|
]) } },
|
||||||
'/kategori': {
|
'/kategori': {
|
||||||
view: function() {
|
view: function() {
|
||||||
return m('span', [
|
return m('span',
|
||||||
|
window.message || window.message != null ?
|
||||||
|
m(label) : null,
|
||||||
|
[
|
||||||
m(nav),
|
m(nav),
|
||||||
m(createCategory, { 'id': 0 })
|
m(createCategory, { 'id': 0 })
|
||||||
])
|
])
|
||||||
@ -38,44 +45,86 @@ if (page == '') {
|
|||||||
},
|
},
|
||||||
'/kategori/:id': {
|
'/kategori/:id': {
|
||||||
view: function(vnode) {
|
view: function(vnode) {
|
||||||
return m('span', [
|
return m('span',
|
||||||
|
window.message || window.message != null ?
|
||||||
|
m(label) : null,
|
||||||
|
[
|
||||||
m(nav),
|
m(nav),
|
||||||
m(editCategory, { 'id': vnode.attrs.id })
|
m(editCategory, { 'id': vnode.attrs.id })
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'/register': { view: function() { return m('span'), [
|
'/register': { view: function() {
|
||||||
m(nav),
|
return m('span',
|
||||||
cookie.get('signal') == 1 ? m(registerUser) : null
|
window.message || window.message != null ?
|
||||||
] }},
|
m(label) : null,
|
||||||
'/posts': { view: function() { return m('span', [
|
[
|
||||||
m(nav),
|
m(nav),
|
||||||
m(showPost, { 'status': 3 })
|
cookie.get('signal') == 1 ? m(registerUser) : null
|
||||||
]) } },
|
])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/posts': { view: function() {
|
||||||
|
return m('span',
|
||||||
|
window.message || window.message != null ?
|
||||||
|
m(label) : null,
|
||||||
|
[
|
||||||
|
m(nav),
|
||||||
|
m(showPost, { 'status': 3 })
|
||||||
|
])
|
||||||
|
}
|
||||||
|
},
|
||||||
'/posts/edit/:id': {
|
'/posts/edit/:id': {
|
||||||
view: function(vnode) {
|
view: function(vnode) {
|
||||||
return m('span', [
|
return m('span',
|
||||||
|
window.message || window.message != null ?
|
||||||
|
m(label) : null,
|
||||||
|
[
|
||||||
m(nav),
|
m(nav),
|
||||||
m(editPost, { 'id': vnode.attrs.id })
|
m(editPost, { 'id': vnode.attrs.id })
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'/posts/active': { view: function() { return m('span', [
|
'/posts/active': { view: function() {
|
||||||
m(nav),
|
return m('span',
|
||||||
m(showPost, { 'status': 1 })
|
window.message || window.message != null ?
|
||||||
]) } },
|
m(label) : null,
|
||||||
'/posts/soon': { view: function() { return m('span', [
|
[
|
||||||
m(nav),
|
m(nav),
|
||||||
m(showPost, { 'status': 2 })
|
m(showPost, { 'status': 1 })
|
||||||
]) } },
|
])
|
||||||
'/posts/inactive': { view: function() { return m('span', [
|
}
|
||||||
m(nav),
|
},
|
||||||
m(showPost, { 'status': 0 })
|
'/posts/soon': { view: function() {
|
||||||
]) } },
|
return m('span',
|
||||||
'/posts/entry': { view: function() { return m('span', [
|
window.message || window.message != null ?
|
||||||
m(nav),
|
m(label) : null,
|
||||||
m(createPost)
|
[
|
||||||
])} }
|
m(nav),
|
||||||
|
m(showPost, { 'status': 2 })
|
||||||
|
])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/posts/inactive': { view: function() {
|
||||||
|
return m('span',
|
||||||
|
window.message || window.message != null ?
|
||||||
|
m(label) : null,
|
||||||
|
[
|
||||||
|
m(nav),
|
||||||
|
m(showPost, { 'status': 0 })
|
||||||
|
])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'/posts/entry': { view: function() {
|
||||||
|
return m('span',
|
||||||
|
window.message || window.message != null ?
|
||||||
|
m(label) : null,
|
||||||
|
[
|
||||||
|
m(nav),
|
||||||
|
m(createPost)
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
idleTimeout.setup();
|
idleTimeout.setup();
|
||||||
|
@ -41,13 +41,13 @@ var category = {
|
|||||||
headers: {'x-query': window.location.search}
|
headers: {'x-query': window.location.search}
|
||||||
})
|
})
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
console.log(result)
|
|
||||||
category.current = {}
|
category.current = {}
|
||||||
if (result.status == true) {
|
if (result.status == true) {
|
||||||
m.route.set('/kategori')
|
m.route.set('/kategori')
|
||||||
} else if (result.status == 401) {
|
} else if (result.status == 401) {
|
||||||
user.logout();
|
user.logout();
|
||||||
}
|
}
|
||||||
|
window.message = result.message
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
entry: function() {
|
entry: function() {
|
||||||
@ -59,20 +59,24 @@ var category = {
|
|||||||
headers: {'x-query': window.location.search}
|
headers: {'x-query': window.location.search}
|
||||||
})
|
})
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
console.log(result);
|
|
||||||
if (result.status == true) {
|
if (result.status == true) {
|
||||||
category.loadList()
|
category.loadList()
|
||||||
} else if (result.status == 401) {
|
} else if (result.status == 401) {
|
||||||
user.logout()
|
user.logout()
|
||||||
}
|
}
|
||||||
|
window.message = result.message
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toggleStatus: function(id){
|
toggleStatus: function(id){
|
||||||
category.current = _.find(category.list, function(o) { return o.id == id })
|
category.current = _.find(category.list, function(o) { return o.id == id })
|
||||||
if (category.current.posts == 0) {
|
if (category.current.posts == 0) {
|
||||||
category.current.status == 1 ? category.current.status = 0 : category.current.status = 1
|
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) {
|
.then(function(response) {
|
||||||
if (response.status) {
|
if (response.status) {
|
||||||
m.route.set(response.route_to)
|
m.route.set(response.route_to)
|
||||||
} else {
|
|
||||||
console.log(response);
|
|
||||||
}
|
}
|
||||||
post.current = {}
|
post.current = {}
|
||||||
post.loading = false
|
post.loading = false
|
||||||
|
window.message = response.message
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
save: function() {
|
save: function() {
|
||||||
@ -61,16 +60,15 @@ var post = {
|
|||||||
url: '/posts/put/' + window.location.search,
|
url: '/posts/put/' + window.location.search,
|
||||||
data: post.current,
|
data: post.current,
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
headers: {client: 'api'}
|
headers: {client: 'api', 'x-query': window.location.search}
|
||||||
})
|
})
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
post.current = {}
|
post.current = {}
|
||||||
if (response.status) {
|
if (response.status) {
|
||||||
m.route.set(response.route_to)
|
m.route.set(response.route_to)
|
||||||
} else {
|
|
||||||
console.log(response);
|
|
||||||
}
|
}
|
||||||
post.loading = false;
|
post.loading = false;
|
||||||
|
window.message = response.message
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
toggleStatus: function(id) {
|
toggleStatus: function(id) {
|
||||||
@ -88,21 +86,23 @@ var post = {
|
|||||||
|
|
||||||
post.current = _.find(post.list, function(o) { return o.id == id })
|
post.current = _.find(post.list, function(o) { return o.id == id })
|
||||||
// console.log(new Date(post.current.valid_at) > new Date());
|
// console.log(new Date(post.current.valid_at) > new Date());
|
||||||
if (new Date(post.current.valid_at) > new Date()) {
|
if (post.current.status != 0) {
|
||||||
status = 2
|
if (new Date(post.current.valid_at) > new Date()) {
|
||||||
// console.log(post.current.id, 'soon');
|
status = 2
|
||||||
} else if (new Date(post.current.valid_at) <= new Date()) {
|
// console.log(post.current.id, 'soon');
|
||||||
if (new Date(post.current.expired_at) < new Date()) {
|
} else if (new Date(post.current.valid_at) <= new Date()) {
|
||||||
status = 0
|
if (new Date(post.current.expired_at) < new Date()) {
|
||||||
// console.log(post.current.id, 'expired');
|
status = 0
|
||||||
} else {
|
// console.log(post.current.id, 'expired');
|
||||||
status = 1
|
} else {
|
||||||
// console.log(post.current.id, 'active');
|
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);
|
// console.log(post.current);
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,8 @@ var user = {
|
|||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
if (response.status == true) {
|
if (response.status == true) {
|
||||||
window.location = response.redirect_to
|
window.location = response.redirect_to
|
||||||
} else {
|
|
||||||
console.log(response.status);
|
|
||||||
}
|
}
|
||||||
|
window.message = response.message
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
logout: function() {
|
logout: function() {
|
||||||
@ -26,26 +25,26 @@ var user = {
|
|||||||
headers: {client: 'api', 'x-query': window.location.search}
|
headers: {client: 'api', 'x-query': window.location.search}
|
||||||
})
|
})
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
console.log(response);
|
|
||||||
if (response.status) {
|
if (response.status) {
|
||||||
window.location = response.redirect_to
|
window.location = response.redirect_to
|
||||||
}
|
}
|
||||||
|
window.message = response.message
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
register: function() {
|
register: function() {
|
||||||
return m.request({
|
return m.request({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/post',
|
url: '/post/' + window.location.search,
|
||||||
data: user.current,
|
data: user.current,
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
headers: {client: 'api', 'x-query': window.location.search}
|
headers: {client: 'api', 'x-query': window.location.search}
|
||||||
})
|
})
|
||||||
.then(function(response) {
|
.then(function(response) {
|
||||||
|
console.log(response);
|
||||||
if (response.status == true) {
|
if (response.status == true) {
|
||||||
m.route.set(response.route_to)
|
m.route.set(response.route_to)
|
||||||
} else {
|
|
||||||
console.log(response);
|
|
||||||
}
|
}
|
||||||
|
window.message = response.message
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
assets/js/others/fadeOutEffect.js
Normal file
18
assets/js/others/fadeOutEffect.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module.exports = {
|
||||||
|
fade: function(target) {
|
||||||
|
// var fadeTarget = document.getElementById(target);
|
||||||
|
var fadeTarget = target
|
||||||
|
var fadeEffect = setInterval(function () {
|
||||||
|
if (!fadeTarget.style.opacity) {
|
||||||
|
fadeTarget.style.opacity = 1;
|
||||||
|
}
|
||||||
|
if (fadeTarget.style.opacity < 0.1) {
|
||||||
|
clearInterval(fadeEffect);
|
||||||
|
fadeTarget.remove();
|
||||||
|
window.message = null;
|
||||||
|
} else {
|
||||||
|
fadeTarget.style.opacity -= 0.1;
|
||||||
|
}
|
||||||
|
}, 50);
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user