barre de recherche et arboresence

anis
Tmadkaud 6 years ago
commit 4f7c77dddb

@ -18,13 +18,17 @@ var upload = require("express-fileupload");
//var morgan = require('morgan');
var mongoose = require('mongoose');
var passport = require('passport');
var session = require('express-session');
//var session = require('express-session');
var config = require('./config/database');
//DB
//mongoose.Promise = require('bluebird');
mongoose.connect(config.database);
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
app.use(session({
secret: 's3cr3t',
resave: true,
@ -45,8 +49,15 @@ app.use(express.static(path.join(__dirname, 'other')));
app.use('/public',express.static(path.join(__dirname, './public')));
app.use('/books', express.static(path.join(__dirname, 'dist')));
app.use('/api', api);
app.use('/home', express.static(path.join(__dirname, 'dist')));
app.use('/main/:id', express.static(path.join(__dirname, 'dist')));
app.use('/login', express.static(path.join(__dirname, 'dist')));
app.use('/signup', express.static(path.join(__dirname, 'dist')));
app.use('/api', api);
app.set('view engine', 'pug');
//app.use('/api', faceBK);
// catch 404 and forward to error handler
app.use(function(req, res, next) {
@ -54,11 +65,7 @@ app.use(function(req, res, next) {
err.status = 404;
next(err);
});
app.use(session({
secret: 's3cr3t',
resave: true,
saveUninitialized: true
}));
// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development

@ -4,34 +4,68 @@ var User = require('../models/user');
// module.exports = function(passport){
//
// };
var mongoose = require('mongoose');
passport.use(new FacebookStrategy({
clientID: "191092458179642",
clientSecret: "964e490d7e49a13ee7a77c9b65419fb3",
callbackURL: "https://localhost:3000/api/facebook/callback"
},
function(accessToken, refreshToken, profile, done) {
console.log('yaaauuu : ' + accessToken + ' ----- ' + profile.displayName + ' ----- ' + profile.id);
done(null, {profile, accessToken});
// User.findOrCreate({username: profile.displayName}, {username: profile.displayName, id: profile.id}, function(err, user) {
// if (err) {
// console.log('yaaauuu err : ' + err);
// return done(err);
// }
// console.log('yaaauuu : ');
// done(null, user);
// });
/*
User.findOrCreate({username: profile.displayName}, {username: profile.displayName, id: profile.id}, function(err, user) {
console.log('yaaauuu err : ' + ' ----- ' + err );
console.log('yaaauuu user : ' + ' ----- ' + JSON.stringify(user));
if (err) { return done(err); }
console.log('facebook findOneOrCreate'+profile.displayName);
User.findOneOrCreate(profile.displayName.toString(), function(err, user, req, res) {
if (err) {
console.log('findOneOrCreate err');
console.log(err);
return done(err);
}
console.log('findOneOrCreate ok'+user.displayName);
//res.json({token: accessToken, user: user.username});
done(null, user);
});*/
});
// Page.findOneOrCreate(pageId, (err, page)=>{
// if(err){
// //if theres an error, do something
// }
// // or do something with the page
// })
//
//
// Page.findOneOrCreate(profile.id, (err, page)=>{
// if(err){
// //if theres an error, do something
// }
// // or do something with the page
// })
}
// function(accessToken, refreshToken, profile, done) {
// console.log('yaaauuu : ' + accessToken + ' ----- ' + profile.displayName + ' ----- ' + profile.id);
// //done(null, {profile, accessToken});
//
//
// var newUser = new User({
// username: req.body.username,
// password: req.body.password
// });
//
// User.save(newUser, function(err, user) {
// if (err) {
// console.log('yaaauuu err : ' + err);
// return done(err);
// }
// console.log('yaaauuu : ');
// done(null, user);
// });
//
//
//
// /*
// User.findOrCreate({username: profile.displayName}, {username: profile.displayName, id: profile.id}, function(err, user) {
// console.log('yaaauuu err : ' + ' ----- ' + err );
//
// console.log('yaaauuu user : ' + ' ----- ' + JSON.stringify(user));
// if (err) { return done(err); }
// done(null, user);
// });*/
// }
));
module.exports = passport;

@ -3,18 +3,36 @@ var Schema = mongoose.Schema;
var bcrypt = require('bcrypt-nodejs');
var UserSchema = new Schema({
username: {
type: String,
unique: true,
required: true
},
password: {
type: String,
required: true
}
name: String,
userid: String,
updated_at: { type: Date, default: Date.now },
username: {
type: String,
unique: true,
required: true
},
password: {
type: String,
required: false
}
});
UserSchema.statics.findOrCreate = require("find-or-create");
// UserSchema.statics.findOrCreate = function findOneOrCreate(condition, callback) {
// console.log(JSON.stringify(condition));
// const self = this;
// self.findOne(condition, (err, result) => {
// return result ? callback(err, result) : self.create(condition, (err, result) => {
// return callback(err, result)
// })
// })
// };
UserSchema.statics.findOneOrCreate = function(displayName, cb){
console.log('findOneOrCreate'+displayName);
return (displayName ? this.find({name: displayName}, cb) : this.findOne({}, cb)).then(page => page ? page : this.create({}, cb))
};
UserSchema.pre('save', function (next) {
var user = this;
@ -45,4 +63,4 @@ UserSchema.methods.comparePassword = function (passw, cb) {
});
};
module.exports = mongoose.model('User', UserSchema);
module.exports = mongoose.model('User', UserSchema);

862
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -59,6 +59,7 @@
"passport-github": "^1.1.0",
"passport-google-oauth": "^1.0.0",
"passport-jwt": "^3.0.1",
"pug": "^2.0.3",
"rxjs": "^6.0.0-rc.1",
"rxjs-compat": "^6.0.0-rc.1",
"screenfull": "3.3.x",

@ -18,8 +18,8 @@ var passportFacebook = require('../auth/facebook');
var passportGoogle = require('../auth/google');
var passportGitHub = require('../auth/github');
//var router = express.Router([options]);
// recuperer l'extention d'un fichier en fonction de son nom, par exemple : exemple.pdf recupera juste ".pdf"
getStringExtention = function(monFile){
return ( monFile.name.indexOf('.') > 0 ) ? '.' + monFile.name.split('.').pop().toLowerCase() : '';
};
@ -38,7 +38,7 @@ getToken = function (headers) {
}
};
/* config multer dossier cible et nom du file */
/* config multer dossier cible et nom du file : enregistrement du fichier dans le dossier public*/
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, './public/')
@ -54,7 +54,7 @@ router.get('/', function(req, res, next) {
res.send('Express RESTful API');
});
//inscription email/password le username est l'email
router.post('/signup', function(req, res) {
if (!req.body.username || !req.body.password) {
res.json({success: false, msg: 'Please pass username and password.'});
@ -272,7 +272,7 @@ router.post('/signin', function(req, res) {
});
});
//////////
/* Multer upload */
router.post('/upload' , multer({storage: storage, limits: {fileSize: 30000000000}}).array("public[]", 12) ,function(req,res,next){
res.send(req.files);
@ -291,8 +291,6 @@ router.get('/getCurrentUser', passport.authenticate('jwt', { session: false}), f
////////////
/* GET users listing. */
@ -304,72 +302,22 @@ function ensureAuthenticated(req, res, next) {
if (req.isAuthenticated()) { return next(); }
res.redirect('/api/login');
}
/* FACEBOOK ROUTER */
router.get('/facebook', passportFacebook.authenticate('facebook'));
router.get('/facebook/callback',
passportFacebook.authenticate('facebook', { failureRedirect: '/' }),
router.get('/facebook', passportFacebook.authenticate('facebook', { session: false}),
function(req, res) {
console.log('fffacebook' + JSON.stringify(tess));
// Successful authentication, redirect home.
res.redirect('/main');
res.json({user: req.user});
});
// router.get('/facebook/callback',
// passportFacebook.authenticate('facebook', { failureRedirect: '/' }),
// function(req, res) {
// console.log('faceeeeboookk !!');
// // Successful authentication, redirect home.
// res.redirect('/main');
// });
// // router.get('/facebook/callback/:id', passport.authenticate('facebook'), function(req, res, err, user, info){
// // console.log('faceeeeboookk !!');
// //
// // //console.log('faceeeeboookk !!' + JSON.stringify(req));
// // //console.log('faceeeeboookk !!' + JSON.stringify(res));
// // //console.log('faceeeeboookk !!' + next);
// //
// // // console.log('yaaaaaaTTTTa ' + JSON.stringify(user));
// // // if(err){
// // // console.log('errrrooor : ' + err);
// // // //if(res){
// // // //res.json({ error: err });
// // // return next(err);
// // // //}
// // //
// // // }
// // // console.log('req.user.username log : ' + err + info);
// // // // Successful authentication, redirect home.
// // // if(user){
// // // User.findOne({username: user.profile.displayName},function(err,result){
// // // if(!result){
// // // var newUser = new User({username: user.profile.displayName, id: user.profile.id, password: 'couille'});
// // // // save the user
// // // console.log('rererer : '+ JSON.stringify(newUser));
// // // newUser.save(function(err) {
// // // if (err) {
// // // console.log('err already exists.' + err);
// // // }
// // // console.log('Successful created new user.');
// // // return req.res.redirect('/main');
// // //
// // // });
// // // }else{
// // // return next(err);
// // // }
// // // });
// // // }else{
// // // return req.res.redirect('/login');
// // // }
// //
// //
// //
// // });
router.get('/facebook/callback',
passportFacebook.authenticate('facebook', { failureRedirect: '/' , session: false}),
function(req, res, user,accessToken, refreshToken, profile, done) {
var tess = {user:user,accessToken:accessToken, refreshToken:refreshToken, profile:profile, done:done};
console.log('fffacebook' + JSON.stringify(tess));
// Successful authentication, redirect home.
res.redirect(['/main/1']);
});
/* GOOGLE ROUTER */

@ -47,7 +47,7 @@ const appRoutes: Routes = [
data: { title: 'home' }
},
{
path: 'main',
path: 'main/:id',
component: MainComponent,
data: { title: 'Main' }
},
@ -67,8 +67,8 @@ const appRoutes: Routes = [
data: { title: 'Sign Up' }
},
{ path: '',
redirectTo: '/home',
pathMatch: 'full'
redirectTo: '/home',
pathMatch: 'full'
}
];
@ -94,7 +94,7 @@ const appRoutes: Routes = [
HttpClientModule,
RouterModule.forRoot(
appRoutes,
{ enableTracing: true } // <-- debugging purposes only
{ enableTracing: false } // <-- debugging purposes only
),
ToastModule.forRoot(),
MDBBootstrapModule.forRoot(),

@ -1,3 +1,10 @@
.topcard {
padding-top: 1%;
}
.topButtons {
margin-top: 2%;
}
.app-title {
font-size: 24px;
}

@ -1,36 +1,60 @@
<div class="md-form">
<i class="fa fa-user prefix grey-text"></i>
<input
#query
(keyup)="filter(query.value)"
type="text" class="form-control" placeholder="Cherchez...">
<div *ngFor="let folder of filterAllUserFolder">
<a (click)="openFolder(folder.path)">{{folder.name}}</a>
<p>
{{folder?.path}}
</p>
</div>
</div>
<div class="box-container align-middle" fxLayout="column" [ngStyle.lt-sm]="'min-height: 400;'">
<dropzone *ngIf="type === 'component'" class="dropzone-container" [config]="config" [disabled]="disabled" fxLayout="row" fxLayoutAlign="start strech" fxFlex="auto" [message]="'Click or drag file here to upload'" (error)="onUploadError($event)" (success)="onUploadSuccess($event)"></dropzone>
</div>
<div class="container-fluid">
<div *ngIf="mainFolder">
<p> Espace utilisé : {{sizeFile.toString() === '0' ? '0' : (sizeFile/ ( 1024 * 1024 ) | number : '1.2-2')}} / 30 Mo</p>
<p> Path : {{mainFolder.path}}</p>
<p> Vous êtes dans le dossier : {{mainFolder.name}}</p>
<button type="button" class="btn btn-sm btn-warning" mdbTooltip="Retour à : {{mainFolder.parent}}" placement="top" (click)="backToParentFolder()" *ngIf="mainFolder.path !== 'Home'"><i class="fa fa-chevron-left" aria-hidden="true"></i> {{mainFolder.parent}}</button>
<div *ngIf="mainFolder" class="card d-print-inline-flex text-center topcard">
<div class="row">
<div class="col-md-4 card-text">
<p> Current Folder : {{mainFolder.name}}</p>
</div>
<div class="col-md-4 card-text">
<p> Used space : {{sizeFile.toString() === '0' ? '0' : (sizeFile/ ( 1024 * 1024 ) | number : '1.2-2')}} / 30 Mo</p>
</div>
<div class="col-md-4 card-text">
<p> Path : {{mainFolder.path}}</p>
</div>
</div>
</div>
<div class="topButtons">
<button type="button" class="btn btn-primary btn-sm" mdbTooltip="Back To : {{mainFolder.parent}}" placement="top" (click)="backToParentFolder()" *ngIf="mainFolder.path !== 'Home'"><i class="fa fa-chevron-left" aria-hidden="true"></i> {{mainFolder.parent}}</button>
<button type="button" class="btn btn-sm btn-warning" mdbTooltip="Nouveau dossier" placement="top" (click)="createBool()" *ngIf="isClickCreateFolder === false">
<i class="fa fa-plus-circle" aria-hidden="true"><i class="fa fa-folder-o" aria-hidden="true"></i></i>
</button>
<button type="button" class="btn btn-primary btn-sm" mdbTooltip="Nouveau dossier" placement="top" (click)="createBool()" *ngIf="isClickCreateFolder === false">
<i class="fa fa-plus-circle" aria-hidden="true"><i class="fa fa-folder-o" aria-hidden="true"></i></i>
</button>
<div class="md-form input-group" *ngIf="isClickCreateFolder === true">
<div class="input-group-btn">
<button class="btn btn-primary btn-sm waves-light" mdbTooltip="Créer : {{inputCreateFolder}}" placement="top" type="button" mdbWavesEffect (click)="createFolder()">Créer</button>
<div class="md-form input-group" *ngIf="isClickCreateFolder === true">
<div class="input-group-btn">
<button class="btn btn-primary btn-sm waves-light" mdbTooltip="Créer : {{inputCreateFolder}}" placement="top" type="button" mdbWavesEffect (click)="createFolder()">Créer</button>
</div>
<input type="search" class="form-control" placeholder="Nom du nouveau dossier..." [(ngModel)]="inputCreateFolder">
</div>
<input type="search" class="form-control" placeholder="Nom du nouveau dossier..." [(ngModel)]="inputCreateFolder">
</div>
<label class="btn btn-danger btn-sm" mdbTooltip="Choisir fichier" placement="top" >
<i class="fa fa-plus-circle" aria-hidden="true"><i class="fa fa-file-o" aria-hidden="true"></i></i>
<input type="file" style="display: none;" #myPicture name="myPicture" (change)="fileChangeEvent($event)">
</label>
<button type="button" class="btn btn-sm btn-warning" mdbTooltip="Ajouter le fichier : {{fileChooseName}}" placement="top" (click)="upload()" >Ajouter le fichier {{fileChooseName}}</button>
<label *ngIf="fileChooseName !== ''"> Vous avez choisi : {{fileChooseName}}</label>
<label class="btn btn-secondary btn-sm" mdbTooltip="Choose a file" placement="top" >
<i class="fa fa-plus-circle" aria-hidden="true"><i class="fa fa-file-o" aria-hidden="true"></i></i>
<input type="file" style="display: none;" #myPicture name="myPicture" (change)="fileChangeEvent($event)">
</label>
<button type="button" class="btn btn-default btn-sm" mdbTooltip="Add File : {{fileChooseName}}" placement="top" (click)="upload()" >Ajouter le fichier {{fileChooseName}}</button>
<label *ngIf="fileChooseName !== ''"> Vous avez choisi : {{fileChooseName}}</label>
</div>
</div>
@ -46,40 +70,66 @@
</thead>
<tbody>
<tr *ngFor="let folder of allUserFolder; let i = index;">
<td>
<button type="button" class="btn btn-sm btn-warning" mdbTooltip="Supprimer : {{folder.name}}" placement="top" (click)="deleteFolder(folder)"><i class="fa fa-close" aria-hidden="true"></i></button>
<button type="button" class="btn btn-sm btn-warning" mdbTooltip="Ouvrir : {{folder.name}}" placement="top" (click)="openFolder(folder.path)"><i class="fa fa-folder-open-o" aria-hidden="true"></i></button>
<!--<button type="button" class="btn btn-warning" (click)="renameFolder(folder)">Rename</button>-->
<div class="btn-group" dropdown>
<button type="button" dropdownToggle class="btn btn-success btn-sm dropdown-toggle-split px-3 waves-light" mdbTooltip="Déplacer : {{folder.name}}" placement="top" mdbWavesEffect>
<i class="fa fa-arrows" aria-hidden="true"></i>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" *ngFor="let folderDest of allUserAppFolder; let i = index;" (click)="moveFolder(folder, folderDest)">{{folderDest.name}}</a>
<td class="row">
<div class="col-md-4">
<i class="fa fa-folder fa-2x" aria-hidden="true"></i>
</div>
<div class="btn-group d-print-inline-flex text-center">
<!--Dropdown primary-->
<div class="dropdown" dropdown>
<!--Trigger-->
<button dropdownToggle class="btn btn-primary y btn-sm dropdown-toggle waves-light" type="button" mdbWavesEffect>
<i class="fa fa fa-folder-open" aria-hidden="true"></i>
</button>
<!--Menu-->
<div class="dropdown-menu dropdown-primary">
<a class="dropdown-item" mdbTooltip="Ouvrir : {{folder.name}}" placement="top" (click)="openFolder(folder.path)">Open Folder</a>
<a class="dropdown-item" mdbTooltip="Supprimer : {{folder.name}}" placement="top" (click)="deleteFolder(folder)">Delete Folder</a>
<h6 class="dropdown-header">Rename</h6>
<div class="d-print-inline-flex text-center">
<input type="search" class="form-control col-xs-2" placeholder= "{{folder.name}}" [(ngModel)]="folder.name">
<button class="btn btn-primary btn-sm waves-light" mdbTooltip="Renommer : {{folder.name}}" placement="top" type="button" mdbWavesEffect (click)="renameFolder(folder)">
<i class="fa fa-pencil prefix"></i>
</button>
</div>
</div>
</div>
<!--/Dropdown primary-->
<div class="btn-group" dropdown>
<button type="button" dropdownToggle class="btn btn-secondary btn-sm dropdown-toggle-split px-3 waves-light" mdbTooltip="Move : {{folder.name}}" placement="top" mdbWavesEffect>
<i class="fa fa-arrows" aria-hidden="true"></i>
</button>
<div class="dropdown-menu dropdown-primary">
<a class="dropdown-item" *ngFor="let folderDest of allUserAppFolder; let i = index;" (click)="moveFolder(folder, folderDest)">{{folderDest.name}}</a>
</div>
</div>
</div>
</td>
<td>
<button class="btn btn-primary btn-sm waves-light" mdbTooltip="Renommer : {{folder.name}}" placement="top" type="button" mdbWavesEffect (click)="renameFolder(folder)">
<i class="fa fa-pencil prefix"></i>
</button>
<input type="search" class="form-control col-xs-2" placeholder= "{{folder.name}}" [(ngModel)]="folder.name">
<label>{{folder.name}}</label>
</td>
<!--<td>{{ folder.name }}</td>-->
<td>{{ folder.taille}} Mo</td>
<td>Folder</td>
<td>{{ folder.owner }}</td>
<i class="fa fa-folder-open-o" aria-hidden="true"></i>
<td><label>{{ folder.taille}} Mo</label></td>
<td><label>Folder</label></td>
<td><label>{{ folder.owner }}</label></td>
</tr>
<tr *ngFor="let file of allUserFile; let i = index;">
<td>
<div class="d-print-inline-flex">
<td class="row">
<div class="col-md-4">
<i class="fa fa-file fa-2x" aria-hidden="true"></i>
</div>
<div class="btn-group d-print-inline-flex text-center">
<!--Dropdown primary-->
<div class="dropdown" dropdown>
<!--Trigger-->
<button dropdownToggle class="btn btn-sm btn-primary dropdown-toggle waves-light" type="button" mdbWavesEffect>
<button dropdownToggle class="btn btn-primary btn-sm dropdown-toggle waves-light" type="button" mdbWavesEffect>
<i class="fa fa-edit" aria-hidden="true"></i>
</button>
@ -87,10 +137,10 @@
<div class="dropdown-menu dropdown-primary">
<a class="dropdown-item" href="{{file.data}}" download="{{ file.name.toString()}}">Download</a>
<a class="dropdown-item" mdbTooltip="Supprimer : {{file.name}}" placement="top" (click)="deleteFile(file)">Delete</a>
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" (click)="basicModal.show()" mdbWavesEffect>Preview</a>
<div class="divider dropdown-divider"></div>
<h6 class="dropdown-header">Rename</h6>
<div class="list-inline-item">
<div class="d-print-inline-flex text-center">
<input type="search" class="form-control col-xs-2" placeholder= "{{file.name}}" [(ngModel)]="file.name">
<button class="btn btn-primary btn-sm waves-light" mdbTooltip="Renommer : {{file.name}}" placement="top" type="button" mdbWavesEffect (click)="renameFile(file)">
<i class="fa fa-pencil prefix"></i>
@ -98,12 +148,95 @@
</div>
</div>
</div>
<!--/Modal-->
<div mdbModal #basicModal="mdb-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myBasicModalLabel" aria-hidden="true" [config]="{backdrop: false, ignoreBackdropClick: true}">
<div class="modal-dialog modal-notify info" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close pull-right" aria-label="Close" (click)="basicModal.hide()">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title w-100" id="myModalLabel">Preview</h4>
</div>
<div class="modal-body img-fluid">
<div *ngIf="file.type === ('image/jpeg')">
<img [src]=file.urlSafe class="img-fluid" width="350" height="200">
</div>
<div *ngIf="file.type === ('image/png')">
<img [src]=file.urlSafe class="img-fluid" width="350" height="200">
</div>
<div *ngIf="file.type === ('application/pdf')">
<!--<i class="fa fa-file-pdf-o" aria-hidden="true"></i>-->
<object [data]=file.urlSafe type="application/pdf"
width="350" height="200" typemustmatch>
</object>
</div>
<div *ngIf="file.type === ('video/mp4')">
<!--<i class="fa fa-file-movie-o" aria-hidden="true"></i>-->
<vg-player style="height: 200px; width: 350px">
<video [vgMedia]="media" #media id="singleVideo" preload="auto" controls>
<source [src]=file.urlSafe type="video/mp4">
</video>
</vg-player>
</div>
<div *ngIf="file.type === ('text/plain')">
<!--<div>{{ reader !== 'undifined' ? reader.result : ''}}</div>
<div>{{test}}</div>
<a href = "../../../public/{{file._id + getStringExtention(file)}}">show me</a>-->
<object [data]=file.urlSafe type="text/plain"
width="350" height="200" typemustmatch>
</object>
</div>
<div *ngIf="file.type === ''">
<i class="fa fa-file-o fa-5x" aria-hidden="true" width="350" height="200"></i>
<!--<object [data]=file.url type="text/plain"
width="350" height="200" typemustmatch>
</object>-->
<!--<div>{{ reader !== 'undifined' ? reader.result : ''}}</div>
<div>{{test}}</div>
<a href = "../../../public/{{file._id + getStringExtention(file)}}">show me</a>-->
</div>
<div *ngIf="(file.type === ('audio/mp3')) || (file.type === ('audio/mpeg'))">
<!--<i class="fa fa-file-audio-o" aria-hidden="true"></i>-->
<vg-player style="height: 50px; width: 350px">
<vg-controls>
<vg-play-pause></vg-play-pause>
<vg-time-display vgProperty="current" vgFormat="mm:ss"></vg-time-display>
<vg-scrub-bar>
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
<vg-scrub-bar-buffering-time></vg-scrub-bar-buffering-time>
</vg-scrub-bar>
<vg-time-display vgProperty="left" vgFormat="mm:ss"></vg-time-display>
<vg-time-display vgProperty="total" vgFormat="mm:ss"></vg-time-display>
<vg-mute></vg-mute>
<vg-fullscreen></vg-fullscreen>
</vg-controls>
<audio #media [vgMedia]="media" id="myAudio" preload="auto">
<source [src]=file.urlSafe type="audio/mp3">
</audio>
</vg-player>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-light" aria-label="Close" (click)="basicModal.hide()" mdbWavesEffect>Close</button>
<!--<button type="button" class="btn btn-primary relative waves-light" mdbWavesEffect>Save changes</button>-->
</div>
</div>
</div>
</div>
<!--/Modal-->
<!--/Dropdown primary-->
<div class="btn-group" dropdown>
<!--Trigger-->
<button type="button" dropdownToggle class="btn btn-success btn-sm dropdown-toggle-split px-3 waves-light" mdbTooltip="Déplacer : {{file.name}}" placement="top" mdbWavesEffect>
<button type="button" dropdownToggle class="btn btn-secondary btn-sm dropdown-toggle-split px-3 waves-light" mdbTooltip="Move : {{file.name}}" placement="top" mdbWavesEffect>
<i class="fa fa-arrows" aria-hidden="true"></i>
</button>
@ -123,76 +256,10 @@
<label>{{file.name}}</label>
</td>
<!--<td>{{ file.name }}</td>-->
<td>{{ file.taille / ( 1024 * 1024 ) | number : '1.2-2'}} Mo</td>
<td>{{ file.type }}</td>
<td>{{ file.lastDate }}</td>
<div *ngIf="file.type === ('image/jpeg')">
<img [src]=file.urlSafe class="img-fluid flex-center" width="350" height="200">
</div>
<div *ngIf="file.type === ('image/png')">
<img [src]=file.urlSafe class="img-fluid flex-center" width="350" height="200">
</div>
<div *ngIf="file.type === ('application/pdf')">
<!--<i class="fa fa-file-pdf-o" aria-hidden="true"></i>-->
<object [data]=file.urlSafe type="application/pdf"
width="350" height="200" typemustmatch>
</object>
</div>
<div *ngIf="file.type === ('video/mp4')">
<!--<i class="fa fa-file-movie-o" aria-hidden="true"></i>-->
<vg-player style="height: 200px; width: 350px">
<video [vgMedia]="media" #media id="singleVideo" preload="auto" controls>
<source [src]=file.urlSafe type="video/mp4">
</video>
</vg-player>
</div>
<div *ngIf="file.type === ('text/plain')">
<!--<div>{{ reader !== 'undifined' ? reader.result : ''}}</div>
<div>{{test}}</div>
<a href = "../../../public/{{file._id + getStringExtention(file)}}">show me</a>-->
<object [data]=file.urlSafe type="text/plain"
width="350" height="200" typemustmatch>
</object>
</div>
<div *ngIf="file.type === ''">
<i class="fa fa-file-o fa-5x" aria-hidden="true" width="350" height="200"></i>
<!--<object [data]=file.url type="text/plain"
width="350" height="200" typemustmatch>
</object>-->
<!--<div>{{ reader !== 'undifined' ? reader.result : ''}}</div>
<div>{{test}}</div>
<a href = "../../../public/{{file._id + getStringExtention(file)}}">show me</a>-->
</div>
<div *ngIf="(file.type === ('audio/mp3')) || (file.type === ('audio/mpeg'))">
<!--<i class="fa fa-file-audio-o" aria-hidden="true"></i>-->
<vg-player style="height: 50px; width: 350px">
<vg-controls>
<vg-play-pause></vg-play-pause>
<vg-time-display vgProperty="current" vgFormat="mm:ss"></vg-time-display>
<vg-scrub-bar>
<vg-scrub-bar-current-time></vg-scrub-bar-current-time>
<vg-scrub-bar-buffering-time></vg-scrub-bar-buffering-time>
</vg-scrub-bar>
<vg-time-display vgProperty="left" vgFormat="mm:ss"></vg-time-display>
<vg-time-display vgProperty="total" vgFormat="mm:ss"></vg-time-display>
<vg-mute></vg-mute>
<vg-fullscreen></vg-fullscreen>
</vg-controls>
<audio #media [vgMedia]="media" id="myAudio" preload="auto">
<source [src]=file.urlSafe type="audio/mp3">
</audio>
</vg-player>
</div>
</tr>
</tbody>

@ -30,7 +30,9 @@ export class BookComponent implements OnInit, OnDestroy {
currentUser: any;
allUserFile: any;
allUserFolder: any;
filterAllUserFolder: any;
allUserAppFolder: any;
allUserAppFile: any;
mainFolder: any;
books: any;
filesToUpload: Array<File>;
@ -106,7 +108,11 @@ export class BookComponent implements OnInit, OnDestroy {
public onUploadError(args: any): void {
console.log('onUploadError:', args);
}
filter(query: string) {
var temp = (this.allUserAppFolder.concat(this.allUserAppFile));
this.filterAllUserFolder = (query) ? temp.filter(p => (p.name.toLowerCase()).includes(query.toLowerCase())) : [];
}
public onUploadSuccess(args: any): void {
this.filesToUpload = args;
this.fileChooseName = args[0].name;
@ -175,6 +181,22 @@ export class BookComponent implements OnInit, OnDestroy {
});
}
getAllUserAppFiles() {
console.log(this.currentUser.username.toString());
this.http.post('/api/getFileAppList', {owner: this.currentUser.username.toString()}).subscribe(files => {
if (files) {
this.allUserAppFile = files;
for (let f of this.allUserAppFile){
console.log(f.name);
//f.fileTab = this.getfiles(f);
}
// return files;
} else {
this.allUserAppFile = [];
}
});
}
getfiles() {
//var preview = document.querySelector('img');
@ -224,6 +246,7 @@ export class BookComponent implements OnInit, OnDestroy {
console.log(this.currentUser.username.toString());
this.setAllUserAppFolder.emit(this.currentUser.username.toString());
this.getAllUserAppFiles();
} else {
this.allUserAppFolder = [];
}
@ -317,7 +340,7 @@ export class BookComponent implements OnInit, OnDestroy {
////////
me.makeFileRequest('http://localhost:3000/api/upload', [], this.filesToUpload, resp).then((result) => {
me.makeFileRequest('https://localhost:3000/api/upload', [], this.filesToUpload, resp).then((result) => {
mee.getfiles();
mee.filesToUpload = null;
mee.fileChooseName = 'None';

@ -68,8 +68,8 @@
</div>
<div class="text-center">
<button class="btn btn-indigo waves-light" mdbWavesEffect (click)="login()">Log In</button>
<button class="btn btn-indigo waves-light" mdbWavesEffect (click)="showregister()">Sign up</button>
<button class="btn btn-primary waves-light" mdbWavesEffect (click)="login()">Log In</button>
<button class="btn btn-secondary waves-light" mdbWavesEffect (click)="showregister()">Sign up</button>
<hr class="hr-light mb-3 mt-4">
<div class="inline-ul text-center d-flex justify-content-center">
<a class="icons-sm fb-ic px-4"><i class="fa fa-facebook white-text"> </i></a>
@ -112,14 +112,14 @@
</div>
<div class="text-center">
<button class="btn btn-indigo waves-light" (click)="signup()" mdbWavesEffect>Sign up</button>
<button class="btn btn-indigo waves-light" mdbWavesEffect (click)="showregister()">Log In</button>
<button class="btn btn-primary waves-light" (click)="signup()" mdbWavesEffect>Sign up</button>
<button class="btn btn-secondary waves-light" mdbWavesEffect (click)="showregister()">Log In</button>
<hr class="hr-light mb-3 mt-4">
<div class="inline-ul text-center d-flex justify-content-center">
<a class="icons-sm fb-ic px-4"><i class="fa fa-facebook white-text"> </i></a>
<a class="icons-sm gplus-ic px-4"><i class="fa fa-google white-text"> </i></a>
<a class="icons-sm px-4"><i class="fa fa-github white-text" aria-hidden="true"></i></a>
<a class="icons-sm fb-ic px-4" (click)="facebook()"><i class="fa fa-facebook white-text"> </i></a>
<a class="icons-sm gplus-ic px-4" onclick="location.href='/api/github'" ><i class="fa fa-google white-text"> </i></a>
<a class="icons-sm px-4" onclick="location.href='/api/google'"><i class="fa fa-github white-text" aria-hidden="true"></i></a>
</div>
</div>
@ -136,6 +136,4 @@
</header>
<!--Main Navigation-->
<app-login></app-login>
<button (click)="facebook()" class="btn-floating btn-fb"><i class="fa fa-facebook"></i></button>

@ -4,7 +4,6 @@ import { Router } from "@angular/router";
import { Observable } from 'rxjs/Observable';
import { tap, catchError } from 'rxjs/operators';
import { of } from 'rxjs/observable/of';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
@ -30,7 +29,7 @@ export class HomeComponent implements OnInit {
this.http.post('/api/signin', this.loginData).subscribe(resp => {
this.data = resp;
localStorage.setItem('jwtToken', this.data.token);
this.router.navigate(['main']);
this.router.navigate(['main', this.data.token]);
}, err => {
this.message = err.error.msg;
});
@ -46,15 +45,22 @@ export class HomeComponent implements OnInit {
});
}
facebook() {
this.http.get('/api/facebook').subscribe(resp => {
this.router.navigate(['main']);
}, err => {
this.message = err.error.msg;
});
}
facebook() {
console.log('tete')
this.http.get('/api/facebook').subscribe(resp => {
console.log('tete');
this.router.navigate(['main']);
}, err => {
this.message = err.error.msg;
});
}
ngOnInit() {
ngOnInit() {
}
}

@ -18,7 +18,7 @@
<button onclick="location.href='/api/facebook'" type="button" class="btn-floating btn-fb"><i class="fa fa-facebook"></i></button>
<button (click)="facebook()" class="btn-floating btn-fb"><i class="fa fa-facebook"></i></button>
<button onclick="location.href='/api/github'" type="button" class="btn-floating btn-git"><i class="fa fa-github"></i></button>
<button onclick="location.href='/api/google'" type="button" class="btn-floating btn-gplus"><i class="fa fa-google"></i></button>
<button type="button" class="btn-floating btn-fb" (click)="facebook()"><i class="fa fa-facebook"></i></button>
<!--<button type="button" class="btn-floating btn-fb" (click)="facebook()"><i class="fa fa-facebook"></i></button>-->

@ -27,7 +27,9 @@ export class LoginComponent implements OnInit {
}
facebook() {
console.log('tete')
this.http.get('/api/facebook').subscribe(resp => {
console.log('tete');
this.router.navigate(['main']);
}, err => {
this.message = err.error.msg;

@ -1,11 +1,11 @@
<body class="grey-skin">
<body class="indigo-skin">
<!--Double navigation-->
<header>
<!-- Sidebar navigation -->
<mdb-sidenav #sidenav class="sn-bg-1 fixed" [fixed]="true">
<mdb-sidenav #sidenav class="sn-bg-4 fixed" [fixed]="true">
<logo>
<!-- Logo -->
@ -29,24 +29,28 @@
</li>
<!--/Social-->
<!--Search Form-->
<li>
<form class="search-form" role="search">
<div class="form-group md-form mt-0 pt-1 waves-light" mdbWavesEffect>
<input type="text" class="form-control" placeholder="Search">
</div>
</form>
</li>
<!--<li>-->
<!--<form class="search-form" role="search">-->
<!--<div class="form-group md-form mt-0 pt-1 waves-light" mdbWavesEffect>-->
<!--<input type="text" class="form-control" placeholder="Search">-->
<!--</div>-->
<!--</form>-->
<!--</li>-->
<!--/.Search Form-->
<!-- Side navigation links -->
<li>
<button class="btn peach-gradient btn-sm btn-rounded waves-light" mdbWavesEffect (click)="getAllUserAppFolder()"><i class="fa fa-refresh" aria-hidden="true"></i></button>
<!--<a class="btn-floating btn-sm blue-gradient waves-light" mdbWavesEffect (click)="getAllUserAppFolder()"><i class="fa fa-refresh" aria-hidden="true"></i></a>-->
<ul class="collapsible collapsible-accordion">
<mdb-squeezebox [multiple]="false" aria-multiselectable="false">
<!-- Collapsible link onclick="function(){ getAllUserAppFolder(); }" -->
<mdb-item *ngFor="let folder of allUserAppFolder; let i = index;">
<mdb-item-head mdbWavesEffect><i class="fa fa-chevron-right"></i>{{folder.name}}</mdb-item-head>
<mdb-item-body>
<mdb-item-body *ngIf="allUserAppFolder">
<ul>
<li><a class="waves-effect" *ngFor="let folderChild of getItemsFolder(folder.name); let i = index;" mdbWavesEffect>{{folderChild.name}}</a></li>
<li><a class="waves-effect" *ngFor="let file of getItems(folder.path); let i = index;" mdbWavesEffect>{{file.name}}</a></li>
</ul>
</mdb-item-body>

@ -40,6 +40,48 @@ export class MainComponent implements OnInit {
});
}
getItems(path) {
var test = [];
if(this.allUserAppFile !== undefined){
test = this.allUserAppFile.filter((file) => file.path === path);
}
return test;
}
setOriginFolder(path) {
//console.log( ' path : ' + path);
//var origin = [];
//for (let f of this.allUserAppFolder){
var pathChunk = path.split('/');
var origin = pathChunk.length === 1 ? pathChunk[0] : pathChunk[pathChunk.length - 2]
//console.log( ' origin : ' + origin);
// for (var i = 0; i < pathChunk.length; i++) {
// console.log(i + ' pathChunk[i] : ' + pathChunk[i]);
// var temp = (pathChunk.length === 1 ? pathChunk[0] : pathChunk[pathChunk.length - 2]);
// console.log(i + ' temp : ' + temp);
// }
//}
return origin;
}
getItemsFolder(name) {
var tempp;
var test = [];
if(this.allUserAppFolder !== undefined) {
tempp = this.allUserAppFolder;
test = tempp.filter((folder) => folder.origin === name);
if(test[0] !== undefined){
console.log(test[0].origin);
}
}
return test;
}
getAllUserAppFiles() {
console.log(this.currentUser.username.toString());
this.http.post('/api/getFileAppList', {owner: this.currentUser.username.toString()}).subscribe(files => {
@ -56,28 +98,23 @@ export class MainComponent implements OnInit {
});
}
getItems(path) {
var test = [];
if(this.allUserAppFile !== undefined){
test = this.allUserAppFile.filter((file) => file.path === path);
}
return test;
}
getAllUserAppFolder(){
this.http.post('/api/getFolderAppList', {owner: this.currentUser.username.toString()}).subscribe(folders => {
if (folders) {
this.allUserAppFolder = folders;
for (let f of this.allUserAppFolder){
f.origin = this.setOriginFolder(f.path);
console.log('origin : ' + f.origin);
}
this.getAllUserAppFiles();
// for (let f of this.allUserAppFolder){
// console.log(f.name);
// //f.fileTab = this.getfiles(f);
// console.log(f.fileTab);
// }
} else {
this.allUserAppFolder = [];
}
});
}
}

@ -0,0 +1,6 @@
extends layout
block content
h1= message
h2= error.status
pre #{error.stack}

@ -0,0 +1,38 @@
extends layout
block content
h1= title
div(class="col-md-4")
h2 Create user
form(action="/users/create", method="post", class="well")
div(class="form-group")
label(for="username")
| Username
input(type="text", name="username", class="form-control")
input(type="submit" class="btn btn-default")
div(class="col-md-6")
h2 Users
ul
each user in users
li
strong
= user.username
| &nbsp;
a(href="/users/" + user.id + "/destroy", class="btn btn-xs btn-warning") delete
ul
li
| Create task
form(action="/users/" + user.id + "/tasks/create", method="post", class="form-inline")
div(class="form-group")
input(type="text", name="title", class="input-sm form-control")
input(type="submit", class="btn btn-sm btn-default")
each task in user.Tasks
li
strong
= task.title
| &nbsp;
a(href="/users/" + user.id + "/tasks/" + task.id + "/destroy", class="btn btn-xs btn-warning") delete

@ -0,0 +1,8 @@
doctype html
html
head
title= title
link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css')
link(rel='stylesheet', href='/stylesheets/style.css')
body
block content
Loading…
Cancel
Save