2018-02-20 14:53:31 +00:00
|
|
|
import {GlobalStore} from '../lib/gstore'
|
2018-02-20 21:57:39 +00:00
|
|
|
import {APIClient} from '../lib/api-client'
|
|
|
|
import {PopUp} from '../lib/pop-up'
|
2018-02-20 14:53:31 +00:00
|
|
|
|
|
|
|
window.gstore = new GlobalStore();
|
|
|
|
|
|
|
|
|
2018-02-20 16:45:46 +00:00
|
|
|
/* (1) Global data
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) Get Full URI */
|
|
|
|
gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, '').split('/').filter(function(i){ return i.length; }));
|
|
|
|
|
|
|
|
/* (2) Get if local version or prod */
|
|
|
|
gstore.add('is_local', document.URL.replace(/^https?:\/\/([^\/:]+).*$/, '$1') == 'ptut.com');
|
|
|
|
|
2018-02-20 21:57:39 +00:00
|
|
|
/* (3) API instance */
|
|
|
|
window.api = new APIClient(gstore.get.is_local ? 'http://ptut.com:8080/api/v/1.0/' : 'https://ptut.xdrm.io/api/v/1.0/');
|
|
|
|
|
|
|
|
/* (4) PopUp instance */
|
|
|
|
window.popup = new PopUp();
|
|
|
|
|
|
|
|
|
2018-02-20 16:45:46 +00:00
|
|
|
|
|
|
|
/* (2) Main components
|
2018-02-20 14:53:31 +00:00
|
|
|
---------------------------------------------------------*/
|
|
|
|
/* (1) Header */
|
|
|
|
gstore.add('header_title', 'ndli1718');
|
|
|
|
|
|
|
|
/* (2) Menu */
|
|
|
|
gstore.add('menu_item', {
|
2018-02-20 16:45:46 +00:00
|
|
|
home: {
|
2018-02-20 14:53:31 +00:00
|
|
|
label: 'Accueil',
|
2018-02-20 16:45:46 +00:00
|
|
|
url: 'home',
|
|
|
|
icon: 'home'
|
|
|
|
}, manage: {
|
|
|
|
label: 'Administration',
|
|
|
|
url: 'manage',
|
|
|
|
icon: 'manage'
|
|
|
|
}, fiche: {
|
|
|
|
label: 'Fiches',
|
|
|
|
url: 'fiche',
|
|
|
|
icon: 'fiche'
|
2018-02-23 19:01:33 +00:00
|
|
|
}, logout: {
|
|
|
|
label: 'Déconnexion',
|
|
|
|
url: 'logout',
|
|
|
|
icon: 'logout'
|
2018-02-20 14:53:31 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-02-20 16:45:46 +00:00
|
|
|
|
2018-02-23 19:01:33 +00:00
|
|
|
/* (3) Set current page active in menu */
|
2018-02-20 16:45:46 +00:00
|
|
|
if( gstore.get.URI.length > 0 && gstore.get.menu_item.hasOwnProperty(gstore.get.URI[0]) )
|
|
|
|
gstore.add('menu_item_active', gstore.get.menu_item[gstore.get.URI[0]].url);
|
|
|
|
else
|
|
|
|
gstore.add('menu_item_active', 'home');
|