Commit 62b80078 authored by Nacim Goura's avatar Nacim Goura

add gestion account and update dependencies

parent 7a2af955
......@@ -44,3 +44,4 @@ practicalmeteor:chai
# other packages
deanius:promise
dynamic-import
aldeed:tabular
......@@ -3,6 +3,7 @@ accounts-password@1.3.6
alanning:roles@1.2.16
aldeed:autoform@6.2.0
aldeed:collection2-core@2.0.1
aldeed:tabular@2.1.1
allow-deny@1.0.5
autoupdate@1.3.12
babel-compiler@6.19.2
......
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
Meteor.methods({
addAccount(user) {
check(user, Object);
const id = Accounts.createUser(user);
if (!id) {
throw new Meteor.Error('Error', 'Impossible de se connecter');
}
},
deleteAccount(id) {
check(id, String);
Meteor.users.remove({ _id: id });
},
});
......@@ -60,7 +60,7 @@ export default class IndexGeneric {
query: term,
fuzziness: 'AUTO',
fields: [
'description',
'title.stemmed',
'description.stemmed',
'body',
'body.stemmed',
......@@ -76,7 +76,7 @@ export default class IndexGeneric {
fuzziness: 'AUTO',
fields: [
'title',
'title.stemmed',
'description',
'url',
'breadcrumb',
'h1',
......
......@@ -17,6 +17,17 @@ adminSection.route('/', {
},
});
adminSection.route('/account', {
name: 'account',
action() {
BlazeLayout.render('mainLayoutTpl', {
sidebar: 'sidebarLayoutTpl',
main: 'accountTpl',
navbar: 'navbarLayoutTpl',
});
},
});
adminSection.route('/stat', {
name: 'statistique',
action() {
......
......@@ -12,9 +12,9 @@ import '../../ui/layouts/sidebar/sidebar';
// Import page templates
import '../../ui/pages/home/home';
import '../../ui/pages/login/login';
import '../../ui/pages/register/register';
import '../../ui/pages/not-found/not-found';
import '../../ui/pages/admin/indexation/indexation';
import '../../ui/pages/admin/account/account';
import '../../ui/pages/admin/statistique/statistique';
// Set up all routes in the app
......@@ -54,16 +54,6 @@ FlowRouter.route('/logout', {
},
});
FlowRouter.route('/register', {
name: 'register',
action() {
BlazeLayout.render('mainLayoutTpl', {
main: 'registerTpl',
navbar: 'navbarLayoutTpl',
});
},
});
FlowRouter.notFound = {
action() {
BlazeLayout.render('mainLayoutTpl', {
......
// Register your apis here
import '../../api/indexation/methods';
import '../../api/account/methods';
import '../../tabular/tabularUser';
<template name="accountActionTable">
<button type="button" class="btn btn-xs btn-danger delete-account">Supprimer</button>
</template>
import Tabular from 'meteor/aldeed:tabular';
import { Meteor } from 'meteor/meteor';
new Tabular.Table({
name: 'Accounts',
collection: Meteor.users,
columns: [
{
data: 'username', title: 'Nom',
},
{
data: 'emails[0].address', title: 'Email',
},
{
tmpl: Meteor.isClient && Template.accountActionTable,
},
],
selector() {
return { roles: null };
},
pageLength: 20,
language: {
sProcessing: 'Traitement en cours...',
sSearch: 'Rechercher&nbsp;:',
sLengthMenu: 'Afficher _MENU_ &eacute;l&eacute;ments',
sInfo: "Affichage de l'&eacute;l&eacute;ment _START_ &agrave; _END_ sur _TOTAL_ &eacute;l&eacute;ments",
sInfoEmpty: "Affichage de l'&eacute;l&eacute;ment 0 &agrave; 0 sur 0 &eacute;l&eacute;ment",
sInfoFiltered: '(filtr&eacute; de _MAX_ &eacute;l&eacute;ments au total)',
sInfoPostFix: '',
sLoadingRecords: 'Chargement en cours...',
sZeroRecords: 'Aucun &eacute;l&eacute;ment &agrave; afficher',
sEmptyTable: 'Aucune donn&eacute;e disponible dans le tableau',
oPaginate: {
sFirst: 'Premier',
sPrevious: 'Pr&eacute;c&eacute;dent',
sNext: 'Suivant',
sLast: 'Dernier',
},
oAria: {
sSortAscending: ': activer pour trier la colonne par ordre croissant',
sSortDescending: ': activer pour trier la colonne par ordre d&eacute;croissant',
},
},
});
......@@ -10,6 +10,9 @@
<li>
<a href="/admin"><i class="fa fa-fw fa-etsy fa-20px" aria-hidden="true"></i> Indexation</a>
</li>
<li>
<a href="/admin/account"><i class="fa fa-fw fa-user fa-20px" aria-hidden="true"></i> Comptes</a>
</li>
<li>
<a href="/admin/stat"><i class="fa fa-fw fa-bar-chart-o fa-20px" aria-hidden="true"></i> Statistiques</a>
</li>
......
<template name="accountTpl">
<!-- accountTpl -->
{{> tabsTpl module="account"}}
{{> Template.dynamic template=template}}
</template>
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { Session } from 'meteor/session';
import TabsCollection from '../../../../collections/tabsCollection';
import '../../../components/tabs/tabs';
import './list/list';
import './add/add';
import './account.html';
/**
* define tab depending on session
*/
Template.accountTpl.onCreated(() => {
Session.set('account', null);
const tabs = Meteor.settings.public.tabs.account;
TabsCollection.remove({});
tabs.forEach((tab) => {
TabsCollection.insert(tab);
});
});
/**
* change template dynamically
*/
Template.accountTpl.helpers({
template() {
const currentTab = Session.get('account');
return currentTab.layout;
},
});
<template name="addAccountTpl">
<!-- Template addAccountTpl -->
<div class="panel panel-default wrapper">
<div class="panel-body">
<h3 class="text-center">Ajouter un compte</h3>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-primary">
<form class="register-form">
<div class="panel-body">
<div class="form-group">
<label class="control-label">Nom</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-user fa"></i>
</span>
<input type="text" class="form-control" name="username" placeholder="Nom"/>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label">Email</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-envelope fa"></i>
</span>
<input type="text" class="form-control" name="email" placeholder="Email"/>
</div>
</div>
<div class="form-group">
<label class="control-label">Mot de passe</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-lock fa-lg"></i>
</span>
<input type="password" class="form-control" name="password" placeholder="Mot de passe"/>
</div>
</div>
</div>
<div class="panel-footer">
<div class="form-group ">
<button type="submit" class="btn btn-primary btn-lg btn-block">
Ajouter
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</template>
import { Meteor } from 'meteor/meteor';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Accounts } from 'meteor/accounts-base';
import { Template } from 'meteor/templating';
import displayNotif from '../../components/notifs/notifs';
import displayNotif from '../../../../components/notifs/notifs';
import './register.html';
import './add.html';
Template.registerTpl.helpers({
roles: () => Meteor.roles.find({}),
});
Template.registerTpl.events({
Template.addAccountTpl.events({
'submit form': (event) => {
event.preventDefault();
const user = {
username: event.target.username.value,
email: event.target.email.value,
password: event.target.password.value,
name: event.target.name.value,
username: event.target.username.value,
roles: [],
};
// Ask user creation on server side
Accounts.createUser(user, (err) => {
if (err) {
displayNotif({
type: 'error',
title: 'Erreur : ',
message: 'Impossible de vous inscrire!',
});
} else {
FlowRouter.go('/');
event.target.username.value = '';
event.target.email.value = '';
event.target.password.value = '';
Meteor.callPromise('addAccount', user)
.then(() => {
displayNotif({
type: 'success',
title: 'Succès : ',
message: 'Vous êtes maintenant inscrit!',
message: 'Compte ajouté avec succès!',
});
})
.catch((err) => {
displayNotif({
type: 'error',
title: 'Erreur : ',
message: err.message,
});
}
});
});
},
});
<template name="listAccountTpl">
<!-- Template listAccountTpl -->
<div class="panel panel-default wrapper">
<div class="panel-body">
<h3 class="text-center">Liste des comptes existants</h3>
</div>
{{> tabular table=TabularTables.Accounts class="table table-striped table-bordered table-condensed text-center"}}
</div>
</template>
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import dataTablesBootstrap from 'datatables.net-bs';
import 'datatables.net-bs/css/dataTables.bootstrap.css';
import displayNotif from '../../../../components/notifs/notifs';
import '../../../../../tabular/buttonTabular.html';
import '../../../../../tabular/tabularUser';
import './list.html';
dataTablesBootstrap(window, $);
Template.accountActionTable.events({
'click .delete-account': function () {
Meteor.callPromise('deleteAccount', this._id)
.then(() => {
displayNotif({
type: 'success',
title: 'Succès : ',
message: 'Compte supprimé avec succès!',
});
})
.catch((err) => {
displayNotif({
type: 'error',
title: 'Erreur : ',
message: err.message,
});
});
},
});
import { Template } from 'meteor/templating';
import './api.html';
<template name="registerTpl">
<!-- template registerTpl -->
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="panel-title text-center">
<h3>Inscription</h3>
<small>Déjà inscris ? <a href="/login">Connexion</a></small>
</div>
</div>
<form class="register-form">
<div class="panel-body">
<div class="form-group">
<label class="control-label">Nom</label>
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-user fa"></i>
</span>
<input type="text" class="form-control" name="name" placeholder="Nom"/>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label">Email</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-envelope fa"></i>
</span>
<input type="text" class="form-control" name="email" placeholder="Email"/>
</div>
</div>
<div class="form-group">
<label class="control-label">Login</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-users fa"></i>
</span>
<input type="text" class="form-control" name="username" placeholder="Login"/>
</div>
</div>
<div class="form-group">
<label class="control-label">Mot de passe</label>
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-lock fa-lg"></i>
</span>
<input type="password" class="form-control" name="password" placeholder="Mot de passe"/>
</div>
</div>
</div>
<div class="panel-footer">
<div class="form-group ">
<button type="submit" class="btn btn-primary btn-lg btn-block">
Inscription
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</template>
......@@ -36,6 +36,26 @@
"closable": false,
"sort": 3
}
],
"account": [
{
"module": "account",
"layout": "listAccountTpl",
"label": "Liste des comptes",
"state": {},
"activ": true,
"closable": false,
"sort": 1
},
{
"module": "account",
"layout": "addAccountTpl",
"label": "Ajouter un compte",
"state": {},
"activ": false,
"closable": false,
"sort": 2
}
]
}
}
......
......@@ -55,9 +55,9 @@ amdefine@>=0.0.4:
version "1.0.1"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
ansi-escapes@^1.1.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e"
ansi-escapes@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b"
ansi-regex@^2.0.0:
version "2.1.1"
......@@ -163,7 +163,7 @@ axobject-query@^0.1.0:
dependencies:
ast-types-flow "0.0.7"
babel-code-frame@^6.16.0, babel-code-frame@^6.22.0:
babel-code-frame@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4"
dependencies:
......@@ -554,11 +554,11 @@ circular-json@^0.3.1:
version "0.3.1"
resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d"
cli-cursor@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987"
cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
dependencies:
restore-cursor "^1.0.1"
restore-cursor "^2.0.0"
cli-width@^2.0.0:
version "2.1.0"
......@@ -600,7 +600,7 @@ concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
concat-stream@^1.5.2:
concat-stream@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7"
dependencies:
......@@ -741,6 +741,19 @@ dashdash@^1.12.0:
dependencies:
assert-plus "^1.0.0"
datatables.net-bs@^1.10.15:
version "1.10.15"
resolved "https://registry.yarnpkg.com/datatables.net-bs/-/datatables.net-bs-1.10.15.tgz#b2c2261007d84ca5b5abf56c18edc227e0da1a4d"
dependencies:
datatables.net ">=1.10.9"
jquery ">=1.7"
datatables.net@>=1.10.9:
version "2.1.1"
resolved "https://registry.yarnpkg.com/datatables.net/-/datatables.net-2.1.1.tgz#6f1103ef08054642aecf85e7e25efd592822ee78"
dependencies:
jquery ">=1.7"
date-now@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
......@@ -757,7 +770,7 @@ debug@2.6.7:
dependencies:
ms "2.0.0"
debug@^2.1.1, debug@^2.2.0:
debug@^2.1.1, debug@^2.2.0, debug@^2.6.8:
version "2.6.8"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc"
dependencies:
......@@ -890,9 +903,9 @@ ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
elasticsearch@^13.0.1:
version "13.0.1"
resolved "https://registry.yarnpkg.com/elasticsearch/-/elasticsearch-13.0.1.tgz#fa58204233052c4cd221e8721e48f3906b385b32"
elasticsearch@^13.1.0:
version "13.1.0"
resolved "https://registry.yarnpkg.com/elasticsearch/-/elasticsearch-13.1.0.tgz#f22a2afe01f4c3cde660bdd5b77575c6f8b6a397"
dependencies:
agentkeepalive "^2.2.0"
chalk "^1.0.0"
......@@ -1012,7 +1025,7 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
escope@3.6.0, escope@^3.6.0:
escope@3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/escope/-/escope-3.6.0.tgz#e01975e812781a163a6dadfdd80398dc64c889c3"
dependencies:
......@@ -1110,47 +1123,51 @@ eslint-plugin-react@^7.0.1:
has "^1.0.1"
jsx-ast-utils "^1.3.4"
eslint@^3.19.0:
version "3.19.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.19.0.tgz#c8fc6201c7f40dd08941b87c085767386a679acc"
eslint-scope@^3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
dependencies:
esrecurse "^4.1.0"
estraverse "^4.1.1"
eslint@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.0.0.tgz#7277c01437fdf41dccd168d5aa0e49b75ca1f260"
dependencies:
babel-code-frame "^6.16.0"
babel-code-frame "^6.22.0"
chalk "^1.1.3"
concat-stream "^1.5.2"
debug "^2.1.1"
concat-stream "^1.6.0"
debug "^2.6.8"
doctrine "^2.0.0"
escope "^3.6.0"
espree "^3.4.0"
eslint-scope "^3.7.1"
espree "^3.4.3"
esquery "^1.0.0"
estraverse "^4.2.0"
esutils "^2.0.2"
file-entry-cache "^2.0.0"
glob "^7.0.3"
globals "^9.14.0"
ignore "^3.2.0"
glob "^7.1.2"
globals "^9.17.0"
ignore "^3.3.3"
imurmurhash "^0.1.4"
inquirer "^0.12.0"
is-my-json-valid "^2.10.0"
inquirer "^3.0.6"
is-my-json-valid "^2.16.0"
is-resolvable "^1.0.0"
js-yaml "^3.5.1"
json-stable-stringify "^1.0.0"
js-yaml "^3.8.4"
json-stable-stringify "^1.0.1"
levn "^0.3.0"
lodash "^4.0.0"
mkdirp "^0.5.0"
lodash "^4.17.4"
mkdirp "^0.5.1"
natural-compare "^1.4.0"
optionator "^0.8.2"
path-is-inside "^1.0.1"
pluralize "^1.2.1"
progress "^1.1.8"
require-uncached "^1.0.2"
shelljs "^0.7.5"
strip-bom "^3.0.0"
path-is-inside "^1.0.2"
pluralize "^4.0.0"
progress "^2.0.0"
require-uncached "^1.0.3"
strip-json-comments "~2.0.1"
table "^3.7.8"
table "^4.0.1"
text-table "~0.2.0"
user-home "^2.0.0"
espree@^3.4.0:
espree@^3.4.3:
version "3.4.3"
resolved "https://registry.yarnpkg.com/espree/-/espree-3.4.3.tgz#2910b5ccd49ce893c2ffffaab4fd8b3a31b82374"
dependencies:
......@@ -1203,14 +1220,18 @@ evp_bytestokey@^1.0.0:
dependencies:
create-hash "^1.1.1"
exit-hook@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8"
extend@~3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444"
external-editor@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.0.4.tgz#1ed9199da9cbfe2ef2f7a31b2fde8b0d12368972"
dependencies:
iconv-lite "^0.4.17"
jschardet "^1.4.2"
tmp "^0.0.31"
extsprintf@1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550"
......@@ -1219,12 +1240,11 @@ fast-levenshtein@~2.0.4:
version "2.0.6"
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
figures@^1.3.5:
version "1.7.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e"
figures@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962"
dependencies:
escape-string-regexp "^1.0.5"
object-assign "^4.1.0"
file-entry-cache@^2.0.0:
version "2.0.0"
......@@ -1357,7 +1377,7 @@ glob@^5.0.10:
once "^1.3.0"
path-is-absolute "^1.0.0"
glob@^7.0.0, glob@^7.0.3, glob@^7.0.5:
glob@^7.0.3, glob@^7.0.5, glob@^7.1.2:
version "7.1.2"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
dependencies:
......@@ -1377,7 +1397,7 @@ glob@~4.3.0:
minimatch "^2.0.1"