diff --git a/README.md b/README.md index 2025897..28e3bfb 100755 --- a/README.md +++ b/README.md @@ -43,9 +43,9 @@ Toujours dans le dossier parent (celui qui contient `ndli1718-web`) ### 3-1. Configuration Apache > Si vous n'avez pas apache -> ```bash +```bash > sudo apt-get install apache2 libapache2-mod-php mysql-server php-mysql php; -> ``` +``` ##### 1. Créer l'hôte virtuel diff --git a/build/kwebsocket/core/wsinterop.php b/build/kwebsocket/core/wsinterop.php new file mode 100644 index 0000000..8867421 --- /dev/null +++ b/build/kwebsocket/core/wsinterop.php @@ -0,0 +1,54 @@ +socket = socket_create(AF_INET, SOCK_STREAM, 0); + $this->isOpened = socket_connect($this->socket,$host,$port); + $this->host = $host; + $this->port = $port; + + socket_set_block($this->socket); + + } + + public function send(array $data) : bool{ + + if( !$this->isOpened ) return false; + + $toSend = json_encode($data); + $size = strlen($toSend); + + socket_write($this->socket,pack('N',$size)); + $success = socket_write($this->socket,$toSend); + + return $success == $size; + } + + public function receive() : array{ + $size = unpack("N",socket_read($this->socket,4))[1]; + $read = 0; + $data = ""; + $tmp = ""; + + while($read != $size){ + + $remaining = ($size - $read); + $read += socket_recv($this->socket,$tmp,$remaining,MSG_DONTWAIT); + $data .= $tmp; + + } + + return json_decode($data,true); + } + + } \ No newline at end of file diff --git a/config/modules.json b/config/modules.json index 5d301fa..0940e7c 100755 --- a/config/modules.json +++ b/config/modules.json @@ -23,6 +23,61 @@ "output": { "connected": { "description": "Vrai si connecté.", "type": "boolean" } } + }, + + "POST signup": { + "description": "Formulaire d'inscription", + "permissions": [], + "parameters": { + "username": { "description": "Identifiant de l'utilisateur", "type": "varchar(3,20,alphanumeric)" }, + "mail": { "description": "Adresse mail de l'utilisateur", "type": "text" }, + "password": { "description": "Mot de passe de l'utilisateur", "type": "text" } + }, + "output": { + "sent": { "description": "Etat de l'inscription, VRAI si le mail de confirmation a été envoyé", "type": "boolean" } + } + }, + + "GET signup_token": { + "description": "Validation de l'inscription par lien envoyé par mail", + "permissions": [], + "parameters": { + "URL_0": { "description": "Token de confirmation URL", "type": "hash" } + }, + "output": { + "confirmed": { "description": "Etat de la validité du token", "type": "boolean" } + } + }, + + "POST pass": { + "description": "Demande de nouveau mot de passe", + "permissions": ["user"], + "parameters": {}, + "output": { + "sent": { "description": "Etat de la demande de nouveau mot de passe, VRAI si le mail de confirmation a été envoyé", "type": "boolean" } + } + }, + + "POST pass_token": { + "description": "Changement de mot de passe", + "permissions": [], + "parameters": { + "URL_0": { "description": "Token de confirmation URL", "type": "hash" } + }, + "output": { + "confirmed": { "description": "Etat de la validité du token", "type": "boolean" } + } + }, + + "POST pass_update": { + "description": "Changement de mot de passe", + "permissions": [], + "parameters": { + "password": { "description": "Nouveau mot de passe", "type": "text" } + }, + "output": { + "updated": { "description": "Vrai si mot de passe mis à jour", "type": "boolean" } + } } }, diff --git a/package.json b/package.json index 5d50f98..dab4121 100755 --- a/package.json +++ b/package.json @@ -6,11 +6,11 @@ "license": "MIT", "private": true, "scripts": { - "build:clean": "rm ./public_html/js/bundle@*.js*", + "build:clean": "rm ./public_html/js/bundle@*.js*", "build:bundle": "cross-env NODE_ENV=production webpack --progress --hide-modules", - "build:dev": "cross-env NODE_ENV=development webpack --progress --hide-modules", - "dev": "npm run build:clean; npm run build:dev", - "build": "npm run build:clean; npm run build:bundle" + "build:dev": "cross-env NODE_ENV=development webpack --progress --hide-modules", + "dev": "npm run build:clean; npm run build:dev", + "build": "npm run build:clean; npm run build:bundle" }, "dependencies": { "vue": "^2.5.9" @@ -30,6 +30,7 @@ "file-loader": "^1.1.4", "vue-loader": "^13.0.5", "vue-template-compiler": "^2.5.9", + "vue-router": "^2.5.3", "webpack": "^3.8.1", "webpack-dev-server": "^2.9.5" } diff --git a/public_html/css/container.css b/public_html/css/container.css index 4790a49..69a8ed8 100644 --- a/public_html/css/container.css +++ b/public_html/css/container.css @@ -1,22 +1,24 @@ /* Card container */ #CONTAINER.message{ + height: calc( 100% - 6.3em ); + flex-direction: column; justify-content: flex-start; flex-wrap: nowrap; - } - #CONTAINER.message div{ /* Message item */ + #CONTAINER.message div, + #CONTAINER.message div[data-noauthor='1']{ /* Message item */ display: inline-block; position: relative; top: 0; left: 0; height: auto; - margin: 1em; + margin: 0 1.5em; + margin-top: 2.5em; padding: 1em; - flex: 1 1 1; align-self: flex-start; border-radius: 3px; @@ -26,33 +28,119 @@ color: #222; } + #CONTAINER.message div[data-noauthor='0']{ + margin-top: .5em; + } + #CONTAINER.message div.me{ /* Message Item (self) */ - background: #13d89d; + /* background: #13d89d; */ align-self: flex-end; + margin: .5em 1.5em; + } + + #CONTAINER.message div.end-pad{ + padding: 0; + opacity: 0; } #CONTAINER.message div span.author{ /* Message author */ - display: inline-block; - position: relative; - - padding: .2em .4em; - margin-right: 1em; - - border: 1px solid #ddd; - - border-radius: 3px; + display: block; + position: absolute; + top: -1.8em; + left: .5em; background: #eee; - color: #666; - } - - #CONTAINER.message div span.author:after{ /* Add 'dit' */ - content: ' dit'; - - color: #333; + color: #888; } #CONTAINER.message div.me span.author{ /* Hide message author if self */ display: none; - } \ No newline at end of file + } + + #CONTAINER.message div span span.code{ /* Code block */ + display: inline-block; + position: relative; + + padding: .2em .3em; + + border-radius: 3px; + + background: #f0f0f0; + + font-family: 'Liberation Mono'; + font-size: .9em; + + } + + #CONTAINER.message div span span.utf8{ /* Smileys */ + font-family: 'Liberation Mono'; + font-size: 1.3em; + + color: #ea921f; + } + + #CONTAINER.message div span span.utf8.bl{ color: #338be0; } + #CONTAINER.message div span span.utf8.br{ color: #773c22; } + + + #CONTAINER.message form.msg-input{ /* Message Input */ + display: block; + position: fixed; + top: calc( 100% - 3em ); + left: 15em; + width: calc( 100% - 15em - 2*1px ); + height: 3em; + + border-top: 1px solid #ddd; + + background: #fff; + + overflow: hidden; + + transition: left .2s ease-in-out, + width .2s ease-in-out; + } + + #WRAPPER.min #CONTAINER.message form.msg-input{ + left: 3.5em; + width: calc( 100% - 3.5em - 2*1px ); + } + + #CONTAINER.message form.msg-input input{ /* form Input */ + display: inline-block; + position: absolute; + top: 0; + left: 0; + width: calc( 100% - 2em - 3em ); + height: calc( 100% - 2*.5em ); + + padding: .5em 1em; + + border: none; + + font-size: inherit; + font-family: inherit; + } + + #CONTAINER.message form.msg-input button{ /* form send button */ + display: inline-block; + position: absolute; + top: 0; + left: calc( 100% - 3em ); + width: 3em; + height: 3em; + + background: url('/image/container/send-msg.svg@777777') center center no-repeat; + background-size: 50%; + + border: none; + + font-size: inherit; + + cursor: pointer; + } + + #CONTAINER.message form.msg-input button:hover{ + background-image: url('/image/container/send-msg.svg@000000'); + } \ No newline at end of file diff --git a/public_html/css/font-loader.css b/public_html/css/font-loader.css index 058b50c..3e8cc3f 100644 --- a/public_html/css/font-loader.css +++ b/public_html/css/font-loader.css @@ -43,4 +43,17 @@ src: url('/font/Aller_LtIt.ttf'); font-weight: lighter; font-style: italic; +} + + + + +/* LIBERATION MONO */ + +/* regular */ +@font-face { + font-family: 'Liberation Mono'; + src: url('/font/LiberationMono_Rg.ttf'); + font-weight: normal; + font-style: normal; } \ No newline at end of file diff --git a/public_html/css/header.css b/public_html/css/header.css index 9722a69..ab0ef18 100644 --- a/public_html/css/header.css +++ b/public_html/css/header.css @@ -140,7 +140,7 @@ padding: .1em .35em; border-radius: 50% / 50%; - background: #ed4222; + background: #474dff; font-size: .8em; diff --git a/public_html/font/LiberationMono_Rg.ttf b/public_html/font/LiberationMono_Rg.ttf new file mode 100644 index 0000000..1a39bc7 Binary files /dev/null and b/public_html/font/LiberationMono_Rg.ttf differ diff --git a/public_html/font/SIL Open Font License.txt b/public_html/font/SIL Open Font License.txt new file mode 100644 index 0000000..f2473f9 --- /dev/null +++ b/public_html/font/SIL Open Font License.txt @@ -0,0 +1,46 @@ +Digitized data copyright (c) 2010 Google Corporation + with Reserved Font Arimo, Tinos and Cousine. +Copyright (c) 2012 Red Hat, Inc. + with Reserved Font Name Liberation. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the copyright statement(s). + +"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission. + +5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file diff --git a/public_html/image/container/send-msg.svg b/public_html/image/container/send-msg.svg new file mode 100644 index 0000000..b380911 --- /dev/null +++ b/public_html/image/container/send-msg.svg @@ -0,0 +1,47 @@ + + \ No newline at end of file diff --git a/public_html/index.php b/public_html/index.php index f1270f9..12ea6cf 100755 --- a/public_html/index.php +++ b/public_html/index.php @@ -5,15 +5,46 @@ use \api\core\Request; use \api\core\AuthSystemDefault; use \database\core\DatabaseDriver; + use \kwebsocket\core\wsinterop; /* (1) Start session */ session_start(); - if( count($_SESSION['USER']) > 0 ) - $_SESSION['NAME'] = $_SESSION['USER']['username']; - elseif( count($_SESSION['ADMIN']) > 0 ) - $_SESSION['NAME'] = $_SESSION['ADMIN']['username']; - elseif( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 ) - $_SESSION['NAME'] = 'guest'.uniqid(); + if( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 ){ + + // ask with websocketInterop + $wsi = new wsinterop('localhost', 9998); + + if( count($_SESSION['USER']) > 0 ){ + + // get/send name to web socket + $wsi->send(['type' => 'user', 'name' => $_SESSION['USER']['username']]); + $check = $wsi->receive(); + + if( $check['error'] == false ) + $_SESSION['NAME'] = $check['name']; + + }elseif( count($_SESSION['ADMIN']) > 0 ){ + + // get/send name to web socket + $wsi->send(['type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]); + $check = $wsi->receive(); + + if( $check['error'] == false ) + $_SESSION['NAME'] = $check['name']; + + }else{ + + // get/send name to web socket + $wsi->send(['type' => 'guest', 'name' => null]); + $check = $wsi->receive(); + + if( $check['error'] == false ) + $_SESSION['NAME'] = $check['name']; + } + + $wsi = null; + + } /* (2) Set default Driver for Repos */ Repo::setDriver(DatabaseDriver::get()); diff --git a/view/lib/infobox-es6.js b/view/lib/infobox-es6.js index fdbebaa..ed9999c 100644 --- a/view/lib/infobox-es6.js +++ b/view/lib/infobox-es6.js @@ -16,8 +16,6 @@ export class InfoBox{ show(msg, type, timeout=2000){ - console.log(this.stack, this.pending); - /* (1) If pending -> add to stack */ if( this.pending ) diff --git a/view/main.js b/view/main.js index 7c0d973..6484cb3 100755 --- a/view/main.js +++ b/view/main.js @@ -2,11 +2,13 @@ ---------------------------------------------------------*/ /* (1) NPM libs */ import Vue from 'vue' +import VueRouter from 'vue-router' /* (2) Internal libs */ -import {API} from './lib/api-es6' -import {InfoBox} from './lib/infobox-es6' +import {API} from './lib/api-es6' +import {InfoBox} from './lib/infobox-es6' import {WSClient,WSClientBuilder} from './lib/ws-client-es6' +import routes from './routes' /* (3) Vues */ import wrapper_vue from './vue/wrapper.vue' @@ -23,66 +25,110 @@ window.wsc = new WSClientBuilder("wss://websocket.xdrm.io"); /* (3) global store init */ require('./vue-config'); window.gstore.add('server', window._SERVER); -window.infobox = new InfoBox(window.gstore.data.info); +window.infobox = new InfoBox(gstore.data.info); -/* (4) Render view */ +/* (4) Init vue router */ +Vue.use(VueRouter); +const router = new VueRouter({ + mode: 'history', + routes: routes[0] +}); + +/* (5) Render view */ new Vue({ - el: '#main-vue', - render: h => h(wrapper_vue), - data: { - gstore: window.gstore.data - } -}) + el: '#main-vue', + router, + render: h => h(wrapper_vue) +}); + +/* (6) Navigate at page load (to update notifications count) */ +gstore.data.func.nav(router, null); /* (3) Set WebSocket channels ---------------------------------------------------------*/ /* (1) Connection channel */ -window.wsc_connect = window.wsc.channel('connect').listen(function(msg, err){ +window.wsc_connect = wsc.channel('connect').listen(function(msg, err){ // {1} Manage error // if( msg == null && err != null ) - return window.infobox.show('Erreur de connexion WebSocket@connect ('+err+')', 'error', 3000); + return infobox.show('Erreur de connexion WebSocket@connect ('+err+')', 'error', 3000); // {2} Manage wsclient error // if( typeof msg.error != 'boolean' || msg.error !== false ) - return window.infobox.show('Erreur de connexion WebSocket@connect', 'warning', 3000); + return infobox.show('Erreur de connexion WebSocket@connect', 'warning', 3000); + + // {3} If no data -> exit // + if( msg.connected == null && msg.disconnected == null ) + return; + + // {4} Add connected users to stack // + if( msg.connected instanceof Array ){ + + // -1- add connected users + console.log('Detected '+msg.connected.length+' connected user(s)'); + var lastLen = gstore.data.notif[0].data.length; + gstore.data.notif[0].data = gstore.data.notif[0].data.concat( msg.connected ); + + // -2- make each user unique + gstore.data.notif[0].data = gstore.data.notif[0].data.filter(function(item, i, arr){ return arr.indexOf(item) === i; }); + + // -3- Update count if not already on page + if( router.app.$route.path != 'notifications' ) + gstore.data.notif[0].count += gstore.data.notif[0].data.length - lastLen; - // {3} Manage notification // - if( msg.connected != null ){ - console.log('Detected '+msg.connected.length+' new user(s)'); - window.gstore.data.notif[0].data = window.gstore.data.notif[0].data.concat( msg.connected ); - window.gstore.data.notif[0].count += msg.connected.length; } -}).send({name: window._SERVER.session.name}); + // {5} Add disconnected users to stack // + if( msg.disconnected instanceof Array ){ + + // -1- Remove each disconnected user + console.log('Detected '+msg.disconnected.length+' disconnected user(s)'); + var lastLen = gstore.data.notif[0].data.length; + gstore.data.notif[0].data = gstore.data.notif[0].data.filter(function(item){ return msg.disconnected.indexOf(item) === -1; }); + + // -2- Update count if not already on page + if( router.app.$route.path != 'notifications' ) + gstore.data.notif[0].count += lastLen - gstore.data.notif[0].data.length; + + } + +}).send({name: _SERVER.session.name}); /* (2) Message channel */ -window.wsc_chat = window.wsc.channel('chat').listen(function(msg, err){ +window.wsc_chat = wsc.channel('chat').listen(function(msg, err){ // {1} Manage error // if( msg == null && err != null ) - return window.infobox.show('Erreur de connexion WebSocket@chat ('+err+')', 'error', 3000); + return infobox.show('Erreur de connexion WebSocket@chat ('+err+')', 'error', 3000); // {2} Manage wsclient error // if( typeof msg.error != 'boolean' || msg.error !== false ) - return window.infobox.show('Erreur de connexion WebSocket@chat', 'warning', 3000); + return infobox.show('Erreur de connexion WebSocket@chat', 'warning', 3000); - // {3} Manage notification // - if( msg.msg != null ){ - console.log('Received '+msg.msg.length+' new message(s)'); - window.gstore.data.notif[1].data = window.gstore.data.notif[1].data.concat( msg.msg ); - window.gstore.data.notif[1].count += msg.msg.length - } + // {3} If no message -> exit // + if( msg.msg == null ) + return; -}).send({name: window._SERVER.session.name}); + // {4} Play sound if 1msg received + not already on page // + if( msg.msg.length == 1 && router.app.$route.path != 'inbox' ) + ( new Audio('/sound/notification.mp3') ).play(); + + // {5} Add messages to stack // + gstore.data.notif[1].data = gstore.data.notif[1].data.concat( msg.msg ); + + // {6} Add notification count if not already on page // + if( router.app.$route.path != 'inbox' ) + gstore.data.notif[1].count += msg.msg.length + +}).send({name: _SERVER.session.name}); /* (4) Clean sockets before page quit ---------------------------------------------------------*/ window.onbeforeunload = function() { - window.wsc_chat.ws.close(); - window.wsc_connect.ws.close(); + wsc_chat.send('{"close": true}'); + wsc_connect.send('{"close": true}'); }; \ No newline at end of file diff --git a/view/routes.js b/view/routes.js new file mode 100644 index 0000000..2b77d41 --- /dev/null +++ b/view/routes.js @@ -0,0 +1,19 @@ +export default { 0: [ + + { + path: '/dashboard/', + component: require('./vue/container/dashboard.vue').default + }, { + path: '/profile/', + component: require('./vue/container/profile.vue').default + }, { + path: '/inbox/', + component: require('./vue/container/inbox.vue').default + }, { + path: '/notifications/', + component: require('./vue/container/notifications.vue').default + }, { + path: '*', + redirect: '/dashboard/' + } +]} \ No newline at end of file diff --git a/view/vue-config.js b/view/vue-config.js index 0117b5f..2ea0a30 100644 --- a/view/vue-config.js +++ b/view/vue-config.js @@ -3,13 +3,13 @@ import {GlobalStore} from './lib/gstore-es6' window.gstore = new GlobalStore(); // Header -window.gstore.add('header_title', 'ndli1718'); -window.gstore.add('info', { +gstore.add('header_title', 'ndli1718'); +gstore.add('info', { active: false, type: 'warning', message: 'Warning! blabla' }); -window.gstore.add('notif', [ +gstore.add('notif', [ { class: 'bell', link: 'notifications', data: [], count: 0 }, { class: 'message', link: 'inbox', data: [], count: 0 }, { class: 'search', link: 'search', data: [], count: 0 }, @@ -17,7 +17,7 @@ window.gstore.add('notif', [ ]) // Menu -window.gstore.add('menu_item', { +gstore.add('menu_item', { dashboard: { label: 'Dashboard', icon: 'dashboard' @@ -33,28 +33,60 @@ window.gstore.add('menu_item', { } }); -window.gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, '')); -window.gstore.add('min_menu', false); +gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, '')); +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( /^\/(\w+)(?:\/?.*)$/.test(gstore.data.URI) ){ + var mi_keys = Object.keys( 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'); + if( !!~mi_keys.indexOf(RegExp.$1) ) gstore.add('menu_item_active', RegExp.$1); + else gstore.add('menu_item_active', 'dashboard'); }else - window.gstore.add('menu_item_active', 'dashboard'); + gstore.add('menu_item_active', 'dashboard'); // Functions -window.gstore.add('func', { - 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})); +gstore.add('func', { + nav: function(router, uri){ - /* (2) Add locally */ - window.gstore.data.notif[1].data.push([ window.gstore.data.server.session.name, msg ]); + // {1} Update view (vue-router) // + if( typeof uri == 'string' ) + router.push('/'+uri); + + // {2} if no @uri -> Extract route from @router // + else if( /^\/([^\/]+).*$/.test( router.app.$route.path ) ) + uri = RegExp.$1; + + // {3} If no @uri -> exit // + else + return; + + // {4} Activate current menu_item // + gstore.data.menu_item_active = uri; + + // {5} Manage notifications // + for( var notif of gstore.data.notif ) + if( notif.link == uri ) // if notif links to current page + notif.count = 0; + + }, + toggleMenuSize: function(){ gstore.data.min_menu=!gstore.data.min_menu; }, + sendMessage: function(msg){ + + /* (1) If empty message -> abort */ + if( msg.trim().length == 0 ) + return; + + /* (2) Send message to WebSocket */ + wsc_chat.send(JSON.stringify({message: msg})); + + /* (3) Add locally */ + gstore.data.notif[1].data.push([ gstore.data.server.session.name, msg ]); } -}); \ No newline at end of file +}); + + +// new-message container +gstore.add('new_msg', ''); \ No newline at end of file diff --git a/view/vue/container/dashboard.vue b/view/vue/container/dashboard.vue index 6fc5afe..54108ce 100644 --- a/view/vue/container/dashboard.vue +++ b/view/vue/container/dashboard.vue @@ -12,6 +12,6 @@ \ No newline at end of file diff --git a/view/vue/container/inbox.vue b/view/vue/container/inbox.vue new file mode 100644 index 0000000..ead07db --- /dev/null +++ b/view/vue/container/inbox.vue @@ -0,0 +1,85 @@ + + +
+ + + + + + \ No newline at end of file diff --git a/view/vue/container/message.vue b/view/vue/container/message.vue deleted file mode 100644 index 9dab11f..0000000 --- a/view/vue/container/message.vue +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/view/vue/container/notifications.vue b/view/vue/container/notifications.vue index a032520..05534b6 100644 --- a/view/vue/container/notifications.vue +++ b/view/vue/container/notifications.vue @@ -12,6 +12,6 @@ \ No newline at end of file diff --git a/view/vue/container/profile.vue b/view/vue/container/profile.vue index a61c94a..460dba0 100644 --- a/view/vue/container/profile.vue +++ b/view/vue/container/profile.vue @@ -12,6 +12,6 @@ \ No newline at end of file diff --git a/view/vue/header.vue b/view/vue/header.vue index 745135d..ddf6399 100644 --- a/view/vue/header.vue +++ b/view/vue/header.vue @@ -12,7 +12,7 @@