Merge branch 'master' of https://git.xdrm.io/ndli1718/main
This commit is contained in:
commit
3ba539e9de
|
@ -43,9 +43,9 @@ Toujours dans le dossier parent (celui qui contient `ndli1718-web`)
|
||||||
### 3-1. Configuration Apache
|
### 3-1. Configuration Apache
|
||||||
|
|
||||||
> Si vous n'avez pas apache
|
> Si vous n'avez pas apache
|
||||||
> ```bash
|
```bash
|
||||||
> sudo apt-get install apache2 libapache2-mod-php mysql-server php-mysql php;
|
> sudo apt-get install apache2 libapache2-mod-php mysql-server php-mysql php;
|
||||||
> ```
|
```
|
||||||
|
|
||||||
##### 1. Créer l'hôte virtuel
|
##### 1. Créer l'hôte virtuel
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace \kwebsocket\core;
|
||||||
|
|
||||||
|
class wsinterop{
|
||||||
|
|
||||||
|
|
||||||
|
private $socket;
|
||||||
|
private $host;
|
||||||
|
private $port;
|
||||||
|
private $isOpened;
|
||||||
|
|
||||||
|
public function __construct(String $host, int $port){
|
||||||
|
|
||||||
|
$this->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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -23,6 +23,61 @@
|
||||||
"output": {
|
"output": {
|
||||||
"connected": { "description": "Vrai si connecté.", "type": "boolean" }
|
"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" }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"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:bundle": "cross-env NODE_ENV=production webpack --progress --hide-modules",
|
||||||
"build:dev": "cross-env NODE_ENV=development webpack --progress --hide-modules",
|
"build:dev": "cross-env NODE_ENV=development webpack --progress --hide-modules",
|
||||||
"dev": "npm run build:clean; npm run build:dev",
|
"dev": "npm run build:clean; npm run build:dev",
|
||||||
"build": "npm run build:clean; npm run build:bundle"
|
"build": "npm run build:clean; npm run build:bundle"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"vue": "^2.5.9"
|
"vue": "^2.5.9"
|
||||||
|
@ -30,6 +30,7 @@
|
||||||
"file-loader": "^1.1.4",
|
"file-loader": "^1.1.4",
|
||||||
"vue-loader": "^13.0.5",
|
"vue-loader": "^13.0.5",
|
||||||
"vue-template-compiler": "^2.5.9",
|
"vue-template-compiler": "^2.5.9",
|
||||||
|
"vue-router": "^2.5.3",
|
||||||
"webpack": "^3.8.1",
|
"webpack": "^3.8.1",
|
||||||
"webpack-dev-server": "^2.9.5"
|
"webpack-dev-server": "^2.9.5"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,24 @@
|
||||||
/* Card container */
|
/* Card container */
|
||||||
#CONTAINER.message{
|
#CONTAINER.message{
|
||||||
|
height: calc( 100% - 6.3em );
|
||||||
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#CONTAINER.message div{ /* Message item */
|
#CONTAINER.message div,
|
||||||
|
#CONTAINER.message div[data-noauthor='1']{ /* Message item */
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
|
||||||
margin: 1em;
|
margin: 0 1.5em;
|
||||||
|
margin-top: 2.5em;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
|
|
||||||
flex: 1 1 1;
|
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
|
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
|
@ -26,33 +28,119 @@
|
||||||
color: #222;
|
color: #222;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#CONTAINER.message div[data-noauthor='0']{
|
||||||
|
margin-top: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
#CONTAINER.message div.me{ /* Message Item (self) */
|
#CONTAINER.message div.me{ /* Message Item (self) */
|
||||||
background: #13d89d;
|
/* background: #13d89d; */
|
||||||
align-self: flex-end;
|
align-self: flex-end;
|
||||||
|
margin: .5em 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#CONTAINER.message div.end-pad{
|
||||||
|
padding: 0;
|
||||||
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#CONTAINER.message div span.author{ /* Message author */
|
#CONTAINER.message div span.author{ /* Message author */
|
||||||
display: inline-block;
|
display: block;
|
||||||
position: relative;
|
position: absolute;
|
||||||
|
top: -1.8em;
|
||||||
padding: .2em .4em;
|
left: .5em;
|
||||||
margin-right: 1em;
|
|
||||||
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
|
|
||||||
border-radius: 3px;
|
|
||||||
|
|
||||||
background: #eee;
|
background: #eee;
|
||||||
|
|
||||||
color: #666;
|
color: #888;
|
||||||
}
|
|
||||||
|
|
||||||
#CONTAINER.message div span.author:after{ /* Add 'dit' */
|
|
||||||
content: ' dit';
|
|
||||||
|
|
||||||
color: #333;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#CONTAINER.message div.me span.author{ /* Hide message author if self */
|
#CONTAINER.message div.me span.author{ /* Hide message author if self */
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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');
|
||||||
|
}
|
|
@ -44,3 +44,16 @@
|
||||||
font-weight: lighter;
|
font-weight: lighter;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* LIBERATION MONO */
|
||||||
|
|
||||||
|
/* regular */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Liberation Mono';
|
||||||
|
src: url('/font/LiberationMono_Rg.ttf');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
|
@ -140,7 +140,7 @@
|
||||||
padding: .1em .35em;
|
padding: .1em .35em;
|
||||||
|
|
||||||
border-radius: 50% / 50%;
|
border-radius: 50% / 50%;
|
||||||
background: #ed4222;
|
background: #474dff;
|
||||||
|
|
||||||
font-size: .8em;
|
font-size: .8em;
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -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.
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
version="1.1"
|
||||||
|
viewBox="0 0 20.015684 19.959942"
|
||||||
|
xml:space="preserve"
|
||||||
|
id="svg4190"
|
||||||
|
inkscape:version="0.91 r13725"
|
||||||
|
sodipodi:docname="send-msg.svg"
|
||||||
|
width="20.015684"
|
||||||
|
height="19.959942"><metadata
|
||||||
|
id="metadata4199"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs4197" /><sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1056"
|
||||||
|
id="namedview4195"
|
||||||
|
showgrid="false"
|
||||||
|
fit-margin-top="0"
|
||||||
|
fit-margin-left="0"
|
||||||
|
fit-margin-right="0"
|
||||||
|
fit-margin-bottom="0"
|
||||||
|
inkscape:zoom="39.666667"
|
||||||
|
inkscape:cx="9.9906835"
|
||||||
|
inkscape:cy="9.9541575"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="24"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="svg4190" /><path
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
id="fill-edit"
|
||||||
|
d="M 19.490683,9.1057851 1.5906835,0.10578512 c -0.90000002,-0.4 -1.90000002,0.4 -1.50000002,1.29999998 l 2.50000002,6.7 11.3999995,1.8999999 -11.3999995,1.9 -2.50000002,6.7 c -0.3,0.9 0.6,1.7 1.50000002,1.2 l 17.8999995,-9 c 0.7,-0.3 0.7,-1.2999999 0,-1.6999999 z" /></svg>
|
After Width: | Height: | Size: 1.9 KiB |
|
@ -5,15 +5,46 @@
|
||||||
use \api\core\Request;
|
use \api\core\Request;
|
||||||
use \api\core\AuthSystemDefault;
|
use \api\core\AuthSystemDefault;
|
||||||
use \database\core\DatabaseDriver;
|
use \database\core\DatabaseDriver;
|
||||||
|
use \kwebsocket\core\wsinterop;
|
||||||
|
|
||||||
/* (1) Start session */
|
/* (1) Start session */
|
||||||
session_start();
|
session_start();
|
||||||
if( count($_SESSION['USER']) > 0 )
|
if( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 ){
|
||||||
$_SESSION['NAME'] = $_SESSION['USER']['username'];
|
|
||||||
elseif( count($_SESSION['ADMIN']) > 0 )
|
// ask with websocketInterop
|
||||||
$_SESSION['NAME'] = $_SESSION['ADMIN']['username'];
|
$wsi = new wsinterop('localhost', 9998);
|
||||||
elseif( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 )
|
|
||||||
$_SESSION['NAME'] = 'guest'.uniqid();
|
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 */
|
/* (2) Set default Driver for Repos */
|
||||||
Repo::setDriver(DatabaseDriver::get());
|
Repo::setDriver(DatabaseDriver::get());
|
||||||
|
|
|
@ -16,8 +16,6 @@ export class InfoBox{
|
||||||
|
|
||||||
show(msg, type, timeout=2000){
|
show(msg, type, timeout=2000){
|
||||||
|
|
||||||
console.log(this.stack, this.pending);
|
|
||||||
|
|
||||||
/* (1) If pending -> add to stack */
|
/* (1) If pending -> add to stack */
|
||||||
if( this.pending )
|
if( this.pending )
|
||||||
|
|
||||||
|
|
108
view/main.js
108
view/main.js
|
@ -2,11 +2,13 @@
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
/* (1) NPM libs */
|
/* (1) NPM libs */
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
import VueRouter from 'vue-router'
|
||||||
|
|
||||||
/* (2) Internal libs */
|
/* (2) Internal libs */
|
||||||
import {API} from './lib/api-es6'
|
import {API} from './lib/api-es6'
|
||||||
import {InfoBox} from './lib/infobox-es6'
|
import {InfoBox} from './lib/infobox-es6'
|
||||||
import {WSClient,WSClientBuilder} from './lib/ws-client-es6'
|
import {WSClient,WSClientBuilder} from './lib/ws-client-es6'
|
||||||
|
import routes from './routes'
|
||||||
|
|
||||||
/* (3) Vues */
|
/* (3) Vues */
|
||||||
import wrapper_vue from './vue/wrapper.vue'
|
import wrapper_vue from './vue/wrapper.vue'
|
||||||
|
@ -23,66 +25,110 @@ window.wsc = new WSClientBuilder("wss://websocket.xdrm.io");
|
||||||
/* (3) global store init */
|
/* (3) global store init */
|
||||||
require('./vue-config');
|
require('./vue-config');
|
||||||
window.gstore.add('server', window._SERVER);
|
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({
|
new Vue({
|
||||||
el: '#main-vue',
|
el: '#main-vue',
|
||||||
render: h => h(wrapper_vue),
|
router,
|
||||||
data: {
|
render: h => h(wrapper_vue)
|
||||||
gstore: window.gstore.data
|
});
|
||||||
}
|
|
||||||
})
|
/* (6) Navigate at page load (to update notifications count) */
|
||||||
|
gstore.data.func.nav(router, null);
|
||||||
|
|
||||||
|
|
||||||
/* (3) Set WebSocket channels
|
/* (3) Set WebSocket channels
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
/* (1) Connection channel */
|
/* (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 //
|
// {1} Manage error //
|
||||||
if( msg == null && err != null )
|
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 //
|
// {2} Manage wsclient error //
|
||||||
if( typeof msg.error != 'boolean' || msg.error !== false )
|
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 */
|
/* (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 //
|
// {1} Manage error //
|
||||||
if( msg == null && err != null )
|
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 //
|
// {2} Manage wsclient error //
|
||||||
if( typeof msg.error != 'boolean' || msg.error !== false )
|
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 //
|
// {3} If no message -> exit //
|
||||||
if( msg.msg != null ){
|
if( msg.msg == null )
|
||||||
console.log('Received '+msg.msg.length+' new message(s)');
|
return;
|
||||||
window.gstore.data.notif[1].data = window.gstore.data.notif[1].data.concat( msg.msg );
|
|
||||||
window.gstore.data.notif[1].count += msg.msg.length
|
|
||||||
}
|
|
||||||
|
|
||||||
}).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
|
/* (4) Clean sockets before page quit
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
window.onbeforeunload = function() {
|
window.onbeforeunload = function() {
|
||||||
window.wsc_chat.ws.close();
|
wsc_chat.send('{"close": true}');
|
||||||
window.wsc_connect.ws.close();
|
wsc_connect.send('{"close": true}');
|
||||||
};
|
};
|
|
@ -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/'
|
||||||
|
}
|
||||||
|
]}
|
|
@ -3,13 +3,13 @@ import {GlobalStore} from './lib/gstore-es6'
|
||||||
window.gstore = new GlobalStore();
|
window.gstore = new GlobalStore();
|
||||||
|
|
||||||
// Header
|
// Header
|
||||||
window.gstore.add('header_title', 'ndli1718');
|
gstore.add('header_title', 'ndli1718');
|
||||||
window.gstore.add('info', {
|
gstore.add('info', {
|
||||||
active: false,
|
active: false,
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
message: 'Warning! blabla'
|
message: 'Warning! blabla'
|
||||||
});
|
});
|
||||||
window.gstore.add('notif', [
|
gstore.add('notif', [
|
||||||
{ class: 'bell', link: 'notifications', data: [], count: 0 },
|
{ class: 'bell', link: 'notifications', data: [], count: 0 },
|
||||||
{ class: 'message', link: 'inbox', data: [], count: 0 },
|
{ class: 'message', link: 'inbox', data: [], count: 0 },
|
||||||
{ class: 'search', link: 'search', data: [], count: 0 },
|
{ class: 'search', link: 'search', data: [], count: 0 },
|
||||||
|
@ -17,7 +17,7 @@ window.gstore.add('notif', [
|
||||||
])
|
])
|
||||||
|
|
||||||
// Menu
|
// Menu
|
||||||
window.gstore.add('menu_item', {
|
gstore.add('menu_item', {
|
||||||
dashboard: {
|
dashboard: {
|
||||||
label: 'Dashboard',
|
label: 'Dashboard',
|
||||||
icon: 'dashboard'
|
icon: 'dashboard'
|
||||||
|
@ -33,28 +33,60 @@ window.gstore.add('menu_item', {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, ''));
|
gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, ''));
|
||||||
window.gstore.add('min_menu', false);
|
gstore.add('min_menu', false);
|
||||||
|
|
||||||
// Proccess current page from url
|
// Proccess current page from url
|
||||||
if( /^\/(\w+)(?:\/?.*)$/.test(window.gstore.data.URI) ){
|
if( /^\/(\w+)(?:\/?.*)$/.test(gstore.data.URI) ){
|
||||||
var mi_keys = Object.keys( window.gstore.data.menu_item );
|
var mi_keys = Object.keys( gstore.data.menu_item );
|
||||||
|
|
||||||
// if current page exists
|
// if current page exists
|
||||||
if( !!~mi_keys.indexOf(RegExp.$1) ) window.gstore.add('menu_item_active', RegExp.$1);
|
if( !!~mi_keys.indexOf(RegExp.$1) ) gstore.add('menu_item_active', RegExp.$1);
|
||||||
else window.gstore.add('menu_item_active', 'dashboard');
|
else gstore.add('menu_item_active', 'dashboard');
|
||||||
|
|
||||||
}else
|
}else
|
||||||
window.gstore.add('menu_item_active', 'dashboard');
|
gstore.add('menu_item_active', 'dashboard');
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
window.gstore.add('func', {
|
gstore.add('func', {
|
||||||
toggleMenuSize: function(){ window.gstore.data.min_menu=!window.gstore.data.min_menu; },
|
nav: function(router, uri){
|
||||||
sendMessage: function(msg){
|
|
||||||
/* (1) Send message to WebSocket */
|
|
||||||
window.wsc_chat.send(JSON.stringify({message: msg}));
|
|
||||||
|
|
||||||
/* (2) Add locally */
|
// {1} Update view (vue-router) //
|
||||||
window.gstore.data.notif[1].data.push([ window.gstore.data.server.session.name, msg ]);
|
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 ]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// new-message container
|
||||||
|
gstore.add('new_msg', '');
|
|
@ -12,6 +12,6 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'CONTAINER_DASHBOARD',
|
name: 'CONTAINER_DASHBOARD',
|
||||||
data(){ return { gstore: window.gstore.data }; },
|
data(){ return { gstore: gstore.data }; }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -0,0 +1,85 @@
|
||||||
|
<template>
|
||||||
|
|
||||||
|
<div id='CONTAINER' class='message'>
|
||||||
|
|
||||||
|
<div v-for='(msg, id) in gstore.notif[1].data' :class="msg[0] == gstore.server.session.name ? 'me' : ''" :data-noauthor='id == 0 || gstore.notif[1].data[id-1][0] != gstore.notif[1].data[id][0] ? "1" : "0"'>
|
||||||
|
<span class='author' v-text='msg[0]' v-if='id == 0 || gstore.notif[1].data[id-1][0] != msg[0]'></span>
|
||||||
|
<span class='content' v-html='bbcode(msg[1])'></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='end-pad'></div> <!-- End Spacing -->
|
||||||
|
|
||||||
|
<form class='msg-input' @submit.prevent='new_message'>
|
||||||
|
<input type='text' placeholder='Nouveau message..' id='msg-new-content' v-model='gstore.new_msg'>
|
||||||
|
<button></button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'CONTAINER_INBOX',
|
||||||
|
data(){ return { gstore: gstore.data }; },
|
||||||
|
methods: {
|
||||||
|
new_message(msg){
|
||||||
|
|
||||||
|
// {1} Send message //
|
||||||
|
this.gstore.func.sendMessage(this.gstore.new_msg);
|
||||||
|
|
||||||
|
// {2} Empty input //
|
||||||
|
this.gstore.new_msg = '';
|
||||||
|
},
|
||||||
|
bbcode: function(msg){
|
||||||
|
|
||||||
|
/* (1) Escape HTML
|
||||||
|
---------------------------------------------------------*/
|
||||||
|
msg = msg.replace(/&/g, '&');
|
||||||
|
msg = msg.replace(/</g, '<');
|
||||||
|
msg = msg.replace(/>/g, '>');
|
||||||
|
|
||||||
|
|
||||||
|
/* (2) Manage text format
|
||||||
|
---------------------------------------------------------*/
|
||||||
|
/* (1) Manage bold */
|
||||||
|
msg = msg.replace(/\*([^\*]+)\*/g, "<b>$1</b>");
|
||||||
|
|
||||||
|
/* (2) italic */
|
||||||
|
msg = msg.replace(/_([^_]+)_/g, "<i>$1</i>");
|
||||||
|
|
||||||
|
/* (3) underline */
|
||||||
|
msg = msg.replace(/\[([^\]]+)\]/g, "<ins>$1</ins>");
|
||||||
|
|
||||||
|
/* (4) Code */
|
||||||
|
msg = msg.replace(/`([^`]+)`/g, "<span class='code'>$1</span>");
|
||||||
|
|
||||||
|
|
||||||
|
/* (3) Manage emojis
|
||||||
|
---------------------------------------------------------*/
|
||||||
|
/* (1) Smileys */
|
||||||
|
msg = msg.replace(/:D/g, "<span class='utf8'>😃</span>");
|
||||||
|
msg = msg.replace(/:\)/g, "<span class='utf8'>🙂</span>");
|
||||||
|
msg = msg.replace(/:B/g, "<span class='utf8'>😎</span>");
|
||||||
|
msg = msg.replace(/:3/g, "<span class='utf8'>😗</span>");
|
||||||
|
msg = msg.replace(/;\)/g, "<span class='utf8'>😉</span>");
|
||||||
|
msg = msg.replace(/:P/g, "<span class='utf8'>😋</span>");
|
||||||
|
msg = msg.replace(/;P/g, "<span class='utf8'>😜</span>");
|
||||||
|
msg = msg.replace(/xD/g, "<span class='utf8'>😆</span>");
|
||||||
|
msg = msg.replace(/:O/ig, "<span class='utf8'>😲</span>");
|
||||||
|
msg = msg.replace(/:S/g, "<span class='utf8'>😖</span>");
|
||||||
|
msg = msg.replace(/\^\^/g, "<span class='utf8'>😊</span>");
|
||||||
|
|
||||||
|
/* (2) Emojis */
|
||||||
|
msg = msg.replace(/:poop:/g, "<span class='utf8 br'>💩</span>");
|
||||||
|
msg = msg.replace(/:fuck:/g, "<span class='utf8'>🖕</span>");
|
||||||
|
msg = msg.replace(/\+1/g, "<span class='utf8 bl'>👍</span>");
|
||||||
|
msg = msg.replace(/-1/g, "<span class='utf8 bl'>👎</span>");
|
||||||
|
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -1,20 +0,0 @@
|
||||||
<template>
|
|
||||||
|
|
||||||
<div id='CONTAINER' class='message'>
|
|
||||||
|
|
||||||
<div v-for='msg in gstore.notif[1].data' :class="msg[0] == gstore.server.session.name ? 'me' : ''">
|
|
||||||
<span class='author'>{{ msg[0] }}</span>
|
|
||||||
<span class='content'>{{ msg[1] }}</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: 'CONTAINER_MSG',
|
|
||||||
data(){ return { gstore: window.gstore.data }; },
|
|
||||||
}
|
|
||||||
</script>
|
|
|
@ -12,6 +12,6 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'CONTAINER_NOTIFICATIONS',
|
name: 'CONTAINER_NOTIFICATIONS',
|
||||||
data(){ return { gstore: window.gstore.data }; },
|
data(){ return { gstore: gstore.data }; }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -12,6 +12,6 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'CONTAINER_PROFILE',
|
name: 'CONTAINER_PROFILE',
|
||||||
data(){ return { gstore: window.gstore.data }; },
|
data(){ return { gstore: gstore.data }; }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<!-- Header Notif -->
|
<!-- Header Notif -->
|
||||||
<div id='header-notif'>
|
<div id='header-notif'>
|
||||||
<div v-for='(notif, index) in gstore.notif' @click='show_notif(index, notif.link)' :class='"hnotif " + notif.class' :data-count='notif.count'></div>
|
<div v-for='notif in gstore.notif' @click='show_notif(notif.link)' :class='"hnotif " + notif.class' :data-count='notif.count'></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,17 +23,10 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'HEADER',
|
name: 'HEADER',
|
||||||
data(){ return { gstore: window.gstore.data }; },
|
data(){ return { gstore: gstore.data }; },
|
||||||
methods: {
|
methods: {
|
||||||
show_notif(index, link){
|
show_notif(uri){
|
||||||
|
this.gstore.func.nav(this.$router, uri);
|
||||||
// {1} Load link //
|
|
||||||
window.gstore.data.menu_item_active = link;
|
|
||||||
|
|
||||||
// {2} Reset notification count to 0 //
|
|
||||||
window.gstore.data.notif[index].count = 0;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<div v-for='(item, index) in gstore.menu_item' class='menu-item-wrapper'>
|
<div v-for='(item, index) in gstore.menu_item' class='menu-item-wrapper'>
|
||||||
|
|
||||||
<div :class="(index == gstore.menu_item_active) ? 'menu-item active' : 'menu-item'" @click='navigate_menu(index)' :style='"background-image: url(/image/menu/" + item.icon + ".svg@333333"'>
|
<div :class="(index == gstore.menu_item_active) ? 'menu-item active' : 'menu-item'" @click='navigate(index)' :style='"background-image: url(/image/menu/" + item.icon + ".svg@333333"'>
|
||||||
<span>{{ item.label }}</span>
|
<span>{{ item.label }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -18,17 +18,10 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'MENU',
|
name: 'MENU',
|
||||||
data(){ return { gstore: window.gstore.data }; },
|
data(){ return { gstore: gstore.data }; },
|
||||||
methods: {
|
methods: {
|
||||||
navigate_menu(page){
|
navigate(uri){
|
||||||
|
this.gstore.func.nav(this.$router, uri);
|
||||||
// (1) Update URL
|
|
||||||
console.log('Loading page \''+page+'\'');
|
|
||||||
window.history.pushState(page, page, '/'+page+'/');
|
|
||||||
|
|
||||||
// (2) Activate current element
|
|
||||||
this.gstore.menu_item_active = page;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,41 +8,24 @@
|
||||||
<menu-comp></menu-comp>
|
<menu-comp></menu-comp>
|
||||||
|
|
||||||
<!-- Container -->
|
<!-- Container -->
|
||||||
<dashboard-container v-show="gstore.menu_item_active == 'dashboard'" ></dashboard-container>
|
<router-view></router-view>
|
||||||
<profile-container v-show="gstore.menu_item_active == 'profile'" ></profile-container>
|
|
||||||
<message-container v-show="gstore.menu_item_active == 'inbox'" ></message-container>
|
|
||||||
<notifications-container v-show="gstore.menu_item_active == 'notifications'" ></notifications-container>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import header_vue from './header.vue';
|
import header_vue from './header.vue'
|
||||||
import menu_vue from './menu.vue';
|
import menu_vue from './menu.vue'
|
||||||
|
|
||||||
import dashboardContainer_vue from './container/dashboard.vue';
|
export default {
|
||||||
import profileContainer_vue from './container/profile.vue';
|
name: 'wrapper',
|
||||||
import messageContainer_vue from './container/message.vue';
|
data(){ return { gstore: gstore.data }; },
|
||||||
import notificationsContainer_vue from './container/notifications.vue';
|
components: {
|
||||||
|
'HeaderComp': header_vue,
|
||||||
|
'MenuComp': menu_vue
|
||||||
export default {
|
}
|
||||||
name: 'wrapper',
|
|
||||||
data(){ return {
|
|
||||||
gstore: window.gstore.data
|
|
||||||
}; },
|
|
||||||
components: {
|
|
||||||
'HeaderComp': header_vue,
|
|
||||||
'MenuComp': menu_vue,
|
|
||||||
'DashboardContainer': dashboardContainer_vue,
|
|
||||||
'ProfileContainer': profileContainer_vue,
|
|
||||||
'MessageContainer': messageContainer_vue,
|
|
||||||
'NotificationsContainer': notificationsContainer_vue
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue