Commit e0544ebf authored by Nacim Goura's avatar Nacim Goura

add crawl reseau

parent f0279c46
......@@ -48,3 +48,4 @@ aldeed:tabular
ajduke:bootstrap-tagsinput
percolate:synced-cron
matb33:collection-hooks
qnipp:treeview
......@@ -79,6 +79,8 @@ practicalmeteor:mocha@2.4.5_6
practicalmeteor:mocha-core@1.0.1
practicalmeteor:sinon@1.14.1_2
promise@0.8.9
qnipp:jstree@3.3.0
qnipp:treeview@1.0.0
raix:eventemitter@0.1.3
random@1.0.10
rate-limit@1.0.8
......
import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);
export default new SimpleSchema({
pathDirectory: {
type: String,
label: 'Url du chemin :',
},
fileType: {
type: Array,
required: false,
label: 'Type de fichier :',
autoform: {
type: 'select-checkbox-inline',
options: [
{ label: 'pdf', value: 'pdf' },
{ label: 'doc', value: 'doc' },
{ label: 'docx', value: 'docx' },
{ label: 'txt', value: 'txt' },
],
},
},
'fileType.$': {
type: String,
},
}, { tracker: Tracker });
import { Mongo } from 'meteor/mongo';
/**
* this collection is local
* @type {Mongo.Collection}
*/
export default new Mongo.Collection('TreeData');
......@@ -2,10 +2,15 @@
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import formApiCrawlSchema from '/imports/api/crawl/api/formApiCrawlSchema';
import formReseauCrawlSchema from '/imports/api/crawl/reseau/formReseauCrawlSchema';
import IndexGeneric from '/imports/api/indexation/server/indexGeneric';
import IndexWebsite from '/imports/api/indexation/server/indexWebsite';
import IndexApi from '/imports/api/indexation/server/indexApi';
import IndexReseau from '/imports/api/indexation/server/indexReseau';
import { addNotif } from '/imports/api/notif/methods';
import TreeData from '/imports/api/crawl/reseau/reseauCollection';
import dirTree from 'directory-tree';
import _ from 'lodash';
Meteor.methods({
initIndexElastic() {
......@@ -115,4 +120,46 @@ Meteor.methods({
});
}
},
indexReseau(data) {
check(data, Object);
formReseauCrawlSchema.validate(data);
this.unblock();
const extensions = data.fileType ? data.fileType.join('|') : '';
const regexExtensions = new RegExp(`(${extensions})`);
const filteredTree = dirTree(data.pathDirectory, { extensions: regexExtensions });
console.log(filteredTree);
function insertTestData(parent, children) {
_.forEach(children, (item) => {
const idParent = TreeData.insert({
name: item.name,
parent,
type: item.type,
path: item.path,
extension: item.extension,
});
if (item.children && item.children.length) {
insertTestData(idParent, item.children);
}
});
}
TreeData.remove({});
if (filteredTree) {
const idParent = TreeData.insert({
name: filteredTree.name,
parent: null,
type: filteredTree.type,
path: filteredTree.path,
extension: null,
});
insertTestData(idParent, filteredTree.children);
} else {
throw new Meteor.Error('Chemin invalide!');
}
},
});
import { Meteor } from 'meteor/meteor';
import TreeData from '/imports/api/crawl/reseau/reseauCollection';
Meteor.publish('TreeData', () => TreeData.find());
......@@ -2,7 +2,6 @@
import { Meteor } from 'meteor/meteor';
import indexationElastic from '/imports/libs/elasticsearch/elasticsearch';
import configElastic from '/imports/libs/elasticsearch/elasticSearchConfig';
import { addNotif } from '/imports/api/notif/methods';
const esIndex = Meteor.settings.private.elasticsearch.esIndex;
const esType = Meteor.settings.private.elasticsearch.esType;
......
import fs from 'fs';
import dirTree from 'directory-tree';
import IndexGeneric from './indexGeneric';
export default class IndexReseau extends IndexGeneric {
initIndexation() {
// console.log(this.walkSync('/home/ngoura/', []));
/* const filteredTree = dirTree('/home/ngoura/Documents', { extensions: /\.pdf/ }, (item, PATH) => {
console.log(item);
});*/
}
walkSync(dir, filelist) {
const files = fs.readdirSync(dir);
filelist = filelist || [];
files.forEach((file) => {
// ne pas parcourir les fichiers cachés
if (file[0] !== '.') {
if (fs.statSync(dir + file).isDirectory()) {
filelist = this.walkSync(`${dir + file}/`, filelist);
} else {
filelist.push(file);
}
}
});
return filelist;
}
}
// Register your apis here
import '/imports/api/indexation/methods';
import '/imports/api/indexation/publications';
import '/imports/api/account/methods';
import '/imports/api/config/methods';
import '/imports/api/notif/methods';
......
<template name="reseauIndexationTpl">
<!-- template reseauIndexationTpl -->
<div class="panel panel-default wrapper">
<div class="panel-body">
<h4 class="text-center">Gestion de l'indexation des réseaux</h4>
{{> quickForm id="formReseauCrawl" schema=formReseauCrawlSchema type="insert" type="method" meteormethod="indexReseau"}}
<hr>
<h4 class="text-center">Arborescence</h4>
{{> TreeView treeArgs }}
</div>
</div>
......
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import TreeData from '/imports/api/crawl/reseau/reseauCollection';
import formReseauCrawlSchema from '/imports/api/crawl/reseau/formReseauCrawlSchema';
import './reseau.html';
Template.reseauIndexationTpl.events({
});
Template.reseauIndexationTpl.helpers({
treeArgs: {
collection: TreeData,
subscription: 'TreeData',
parent: null,
select: '',
openAll: true,
selectAll: false,
mapping: {
text: 'name',
aAttr(item) {},
},
jstree: {
plugins: [
'checkbox',
'sort',
'state',
],
},
events: {
changed(e, item, data) {},
},
},
formReseauCrawlSchema() {
return formReseauCrawlSchema;
},
});
......@@ -840,6 +840,10 @@ diffie-hellman@^5.0.0:
miller-rabin "^4.0.0"
randombytes "^2.0.0"
directory-tree@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/directory-tree/-/directory-tree-2.0.0.tgz#c0a5fa0d642a1b1b7d10351b3c1db429770d8946"
doctrine@1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment