Commit cd174f25 authored by Nacim Goura's avatar Nacim Goura

add job

parent 1795aaff
......@@ -7,7 +7,7 @@
# base package
meteor-base@1.1.0 # Packages every Meteor app needs to have
mobile-experience@1.0.4 # Packages for a great mobile UX
mongo@1.1.19-rc.3 # The database Meteor supports right now
mongo@1.1.19-rc.4 # The database Meteor supports right now
blaze-html-templates # Compile .html files into Meteor Blaze views
reactive-var@1.0.11 # Reactive variable for tracker
tracker@1.1.3 # Meteor's client-side reactive programming library
......@@ -15,7 +15,7 @@ dynamic-import@0.1.1
# package for compile and minify
standard-minifier-css@1.3.4 # CSS minifier run for production mode
standard-minifier-js@2.1.1-rc.3 # JS minifier run for production mode
standard-minifier-js@2.1.1-rc.4 # JS minifier run for production mode
es5-shim@4.6.15 # ECMAScript 5 compatibility for older browsers.
ecmascript@0.8.1 # Enable ECMAScript2015+ syntax in app code
fourseven:scss@4.5.0 # Compile scss to css
......@@ -39,8 +39,8 @@ aldeed:autoform
matb33:collection-hooks
# package for user
accounts-base@1.3.1-rc.3
accounts-password@1.4.0-rc.3
accounts-base@1.3.1-rc.4
accounts-password@1.4.0-rc.4
alanning:roles
# other packages
......
METEOR@1.5.1-rc.3
METEOR@1.5.1-rc.4
accounts-base@1.3.1-rc.3
accounts-password@1.4.0-rc.3
accounts-base@1.3.1-rc.4
accounts-password@1.4.0-rc.4
alanning:roles@1.2.16
aldeed:autoform@6.2.0
aldeed:collection2-core@2.0.1
aldeed:tabular@2.1.1
aldeed:template-extension@4.1.0
allow-deny@1.0.6-rc.3
allow-deny@1.0.6-rc.4
autoupdate@1.3.12
babel-compiler@6.19.3
babel-compiler@6.19.4-rc.4
babel-runtime@1.0.1
base64@1.0.10
binary-heap@1.0.10
......@@ -22,11 +22,11 @@ check@1.2.5
coffeescript@1.12.6_1
cosmos:browserify@0.10.0
dburles:collection-helpers@1.1.0
ddp@1.3.0-rc.3
ddp-client@2.0.0-rc.3
ddp-common@1.2.9-rc.3
ddp@1.3.0-rc.4
ddp-client@2.0.0-rc.4
ddp-common@1.2.9-rc.4
ddp-rate-limiter@1.0.7
ddp-server@2.0.0-rc.3
ddp-server@2.0.0-rc.4
deanius:promise@3.1.3
deps@1.0.12
diff-sequence@1.0.7
......@@ -56,17 +56,17 @@ livedata@1.0.18
localstorage@1.1.0
logging@1.1.17
matb33:collection-hooks@0.8.4
meteor@1.7.0-rc.3
meteor@1.7.0-rc.4
meteor-base@1.1.0
minifier-css@1.2.16
minifier-js@2.1.1-rc.3
minifier-js@2.1.1-rc.4
minimongo@1.2.1
mobile-experience@1.0.4
mobile-status-bar@1.0.14
modules@0.9.2
modules-runtime@0.8.0
momentjs:moment@2.18.1
mongo@1.1.19-rc.3
mongo@1.1.19-rc.4
mongo-id@1.0.6
npm-bcrypt@0.9.3
npm-mongo@2.2.24
......@@ -96,7 +96,7 @@ spacebars@1.0.15
spacebars-compiler@1.1.2
srp@1.0.10
standard-minifier-css@1.3.4
standard-minifier-js@2.1.1-rc.3
standard-minifier-js@2.1.1-rc.4
templating@1.3.2
templating-compiler@1.3.2
templating-runtime@1.3.2
......@@ -107,5 +107,5 @@ tracker@1.1.3
ui@1.0.13
underscore@1.0.10
url@1.1.0
webapp@1.3.17-rc.3
webapp@1.3.17-rc.4
webapp-hashing@1.0.9
......@@ -12,6 +12,7 @@ export default class crawlWebsite extends CrawlGeneric {
/**
* crawl list urls
* @param data
* @param contextIndex
* @returns {Promise}
*/
constructor(data, contextIndex) {
......
......@@ -18,7 +18,7 @@ export function initIndexElastic() {
export function reIndexElastic() {
this.unblock();
const index = new IndexGeneric();
return index.reIndex();
return index.reIndex(Meteor.userId());
}
export function indexWebsite(data) {
......
......@@ -21,13 +21,15 @@ export default class IndexGeneric {
return elastic.bulk(data, hasFile);
}
reIndex() {
reIndex(esType) {
const body = {
source: {
index: 'idsearch',
type: esType,
},
dest: {
index: 'idsearch2',
index: 'idsearch',
type: esType,
},
};
return elastic.reIndex(body);
......
import SimpleSchema from 'simpl-schema';
import { Mongo } from 'meteor/mongo';
/**
* this collection keep tracks of all notification of this application
* @type {Mongo.Collection}
*/
const jobsCollection = new Mongo.Collection('jobs');
SimpleSchema.jobsCollection = new SimpleSchema({
status: {
type: String,
allowedValues: ['running', 'stop'],
/* autoValue() {
return 'stop';
},*/
defaultValue: 'stop',
},
type: {
type: String,
allowedValues: ['website', 'api', 'network'],
},
name: {
type: String,
},
task: {
type: Object,
blackbox: true,
defaultValue: {},
},
scheduledDate: {
type: Date,
required: false,
},
lastExecutionDate: {
type: Date,
required: false,
},
userId: {
type: String,
},
createdAt: {
type: Date,
autoValue() {
return new Date();
},
},
});
jobsCollection.attachSchema(SimpleSchema.jobsCollection);
export default jobsCollection;
import { Meteor } from 'meteor/meteor';
import jobCollection from '/imports/api/job/jobCollection';
export function addJob(data) {
check(data, Object);
const job = {};
if (data.urlWebsite) {
job.type = 'website';
job.name = data.urlWebsite;
}
job.userId = Meteor.userId();
jobCollection.insert(job);
}
export function startJob(job) {
// start job
}
export function removeJob(id) {
jobCollection.remove({ _id: id });
}
Meteor.methods({
addJob,
removeJob,
});
// methods
import '/imports/api/indexation/methods';
import '/imports/api/job/methods';
import '/imports/api/account/methods';
import '/imports/api/config/methods';
import '/imports/api/notif/methods';
......@@ -16,3 +17,4 @@ import '/imports/tabular/tabularUser';
import '/imports/tabular/tabularTestSearch';
import '/imports/tabular/tabularNotif';
import '/imports/tabular/tabularFile';
import '/imports/tabular/tabularJob';
......@@ -14,3 +14,8 @@
{{/with}}
<button type="button" class="btn btn-xs btn-danger delete-network-file">Supprimer</button>
</template>
<template name="jobActionTable">
<button type="button" class="btn btn-xs btn-primary">Démarrer</button>
<button type="button" class="btn btn-xs btn-danger">Supprimer</button>
</template>
......@@ -7,5 +7,6 @@ import './tabularUser';
import './tabularTestSearch';
import './tabularNotif';
import './tabularFile';
import './tabularJob';
dataTablesBootstrap(window, $);
import Tabular from 'meteor/aldeed:tabular';
import moment from 'moment';
import jobsCollection from '/imports/api/job/jobCollection';
new Tabular.Table({
name: 'Jobs',
collection: jobsCollection,
columns: [
{
data: 'type', title: 'Type',
},
{
data: 'name', title: 'Nom',
},
{
data: 'status',
title: 'Status',
render(val, type, doc) {
return `<span class="label label-default">${val}</span>`;
},
},
{
data: 'task', title: 'Tâche',
},
{
data: 'scheduledDate',
title: 'Date programmé',
render(val, type, doc) {
return val && moment(val).format('LLL');
},
},
{
data: 'lastExecutionDate',
title: 'Date dernière exécution',
render(val, type, doc) {
return val && moment(val).format('LLL');
},
},
{
data: 'createdAt',
title: 'Date de création',
render(val, type, doc) {
return val && moment(val).format('LLL');
},
},
{
title: 'Action',
tmpl: Meteor.isClient && Template.jobActionTable,
},
],
selector() {
return { userId: Meteor.userId() };
},
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',
},
},
});
......@@ -5,6 +5,7 @@ import { Session } from 'meteor/session';
import TabsCollection from '/imports/api/tabs/tabsCollection';
import '/imports/ui/components/tabs/tabs';
import './job/job';
import './main/main';
import './website/website';
import './api/api';
......
<template name="jobIndexationTpl">
<div class="panel panel-default wrapper">
<h3 class="text-center">Liste des jobs</h3>
<div class="panel-body">
{{> tabular table=TabularTables.Jobs class="table table-bordered table-condensed text-center"}}
</div>
</div>
</template>
import '/imports/tabular/configClient';
import './job.html';
......@@ -5,10 +5,10 @@
<div class="panel panel-default wrapper">
<div class="panel-body">
<h4 class="text-center">Gestion de l'indexation des sites</h4>
{{#autoForm id="formWebsiteCrawl" schema=formWebsiteCrawlSchema buttonContent="Indexer" type="method" meteormethod="indexWebsite" }}
{{#autoForm id="formWebsiteCrawl" schema=formWebsiteCrawlSchema type="method" meteormethod="addJob" }}
{{> afQuickField name='urlWebsite'}}
{{> afQuickField name='nameConfig' options=optionSelectConfig }}
<button type="submit" class="btn btn-success">Indexer</button>
<button type="submit" class="btn btn-success">Valider</button>
{{/autoForm}}
<hr>
......
{
"private": {
"elasticsearch": {
"host": "localhost:9201",
"esIndex": "idsearch"
"host": "localhost:9201"
}
},
"public": {
......@@ -17,6 +16,15 @@
"closable": false,
"sort": 1
},
{
"module": "indexation",
"layout": "jobIndexationTpl",
"label": "Job",
"state": {},
"activ": false,
"closable": false,
"sort": 2
},
{
"module": "indexation",
"layout": "siteIndexationTpl",
......@@ -24,7 +32,7 @@
"state": {},
"activ": false,
"closable": false,
"sort": 2
"sort": 3
},
{
"module": "indexation",
......@@ -33,7 +41,7 @@
"state": {},
"activ": false,
"closable": false,
"sort": 3
"sort": 4
},
{
"module": "indexation",
......@@ -42,7 +50,7 @@
"state": {},
"activ": false,
"closable": false,
"sort": 4
"sort": 5
}
],
"account": [
......
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