2017-12-01 14:45:45 +00:00
|
|
|
import {GlobalStore} from './lib/gstore-es6'
|
|
|
|
|
|
|
|
window.gstore = new GlobalStore();
|
2017-12-03 15:02:18 +00:00
|
|
|
|
|
|
|
// Header
|
2017-12-01 14:45:45 +00:00
|
|
|
window.gstore.add('header_title', 'ndli1718');
|
2017-12-03 15:02:18 +00:00
|
|
|
window.gstore.add('info', {
|
2017-12-04 18:19:15 +00:00
|
|
|
active: false,
|
|
|
|
type: 'warning',
|
2017-12-01 14:45:45 +00:00
|
|
|
message: 'Warning! blabla'
|
|
|
|
});
|
2017-12-03 15:02:18 +00:00
|
|
|
window.gstore.add('notif', [
|
2017-12-04 22:29:02 +00:00
|
|
|
{ class: 'bell', link: 'notifications', data: [], count: 0 },
|
|
|
|
{ class: 'message', link: 'inbox', data: [], count: 0 },
|
|
|
|
{ class: 'search', link: 'search', data: [], count: 0 },
|
|
|
|
{ class: 'menu', link: 'dashboard', data: [], count: 0 }
|
2017-12-03 15:02:18 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
// Menu
|
2017-12-01 14:45:45 +00:00
|
|
|
window.gstore.add('menu_item', {
|
|
|
|
dashboard: {
|
|
|
|
label: 'Dashboard',
|
|
|
|
icon: 'dashboard'
|
|
|
|
}, profile: {
|
|
|
|
label: 'Profil',
|
|
|
|
icon: 'profile'
|
|
|
|
}, inbox: {
|
2017-12-04 21:57:24 +00:00
|
|
|
label: 'Messagerie instantannée',
|
2017-12-01 14:45:45 +00:00
|
|
|
icon: 'messages'
|
2017-12-04 22:29:02 +00:00
|
|
|
}, notifications: {
|
|
|
|
label: 'Notifications',
|
|
|
|
icon: 'bell'
|
2017-12-01 14:45:45 +00:00
|
|
|
}
|
2017-12-03 15:02:18 +00:00
|
|
|
});
|
2017-12-04 10:48:32 +00:00
|
|
|
|
2017-12-04 22:29:02 +00:00
|
|
|
window.gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, ''));
|
|
|
|
window.gstore.add('min_menu', false);
|
|
|
|
|
|
|
|
// Proccess current page from url
|
|
|
|
if( /^\/(\w+)(?:\/?.*)$/.test(window.gstore.data.URI) ){
|
|
|
|
var mi_keys = Object.keys( window.gstore.data.menu_item );
|
|
|
|
|
|
|
|
// if current page exists
|
|
|
|
if( !!~mi_keys.indexOf(RegExp.$1) ) window.gstore.add('menu_item_active', RegExp.$1);
|
|
|
|
else window.gstore.add('menu_item_active', 'dashboard');
|
|
|
|
|
|
|
|
}else
|
|
|
|
window.gstore.add('menu_item_active', 'dashboard');
|
2017-12-04 10:48:32 +00:00
|
|
|
|
|
|
|
// Functions
|
|
|
|
window.gstore.add('func', {
|
2017-12-04 18:19:15 +00:00
|
|
|
toggleMenuSize: function(){ window.gstore.data.min_menu=!window.gstore.data.min_menu; },
|
|
|
|
sendMessage: function(msg){
|
|
|
|
/* (1) Send message to WebSocket */
|
|
|
|
window.wsc_chat.send(JSON.stringify({message: msg}));
|
|
|
|
|
|
|
|
/* (2) Add locally */
|
|
|
|
window.gstore.data.notif[1].data.push([ window.gstore.data.server.session.name, msg ]);
|
|
|
|
}
|
2017-12-04 10:48:32 +00:00
|
|
|
});
|