Skip to content

Commit

Permalink
Add dist version to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
lpirola committed Dec 15, 2015
1 parent 5f77908 commit 418df5b
Show file tree
Hide file tree
Showing 17 changed files with 1,237 additions and 2 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ coverage

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
dist/
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
Expand Down
121 changes: 121 additions & 0 deletions dist/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var _express = require('express');

var _express2 = _interopRequireDefault(_express);

var _path = require('path');

var _path2 = _interopRequireDefault(_path);

var _serveFavicon = require('serve-favicon');

var _serveFavicon2 = _interopRequireDefault(_serveFavicon);

var _morgan = require('morgan');

var _morgan2 = _interopRequireDefault(_morgan);

var _cookieParser = require('cookie-parser');

var _cookieParser2 = _interopRequireDefault(_cookieParser);

var _bodyParser = require('body-parser');

var _bodyParser2 = _interopRequireDefault(_bodyParser);

var _browserifyMiddleware = require('browserify-middleware');

var _browserifyMiddleware2 = _interopRequireDefault(_browserifyMiddleware);

var _stylus = require('stylus');

var _stylus2 = _interopRequireDefault(_stylus);

var _jeet = require('jeet');

var _jeet2 = _interopRequireDefault(_jeet);

var _kue = require('kue');

var _kue2 = _interopRequireDefault(_kue);

var _modulesQueue = require('./modules/queue');

var _modulesQueue2 = _interopRequireDefault(_modulesQueue);

var _routesIndex = require('./routes/index');

var _routesIndex2 = _interopRequireDefault(_routesIndex);

var _routesDatasources = require('./routes/datasources');

var _routesDatasources2 = _interopRequireDefault(_routesDatasources);

_modulesQueue2['default'].init();

var app = (0, _express2['default'])();

// view engine setup
app.set('views', _path2['default'].join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use((0, _morgan2['default'])('dev'));
app.use(_bodyParser2['default'].json());
app.use(_bodyParser2['default'].urlencoded({ extended: false }));
app.use((0, _cookieParser2['default'])());
app.use(_stylus2['default'].middleware({
src: __dirname + '/stylus',
dest: __dirname + '/public',
compile: function compile(str, path) {
return (0, _stylus2['default'])(str).set('filename', path).set('compress', true).use((0, _jeet2['default'])())['import']('jeet');
}
}));
app.use(_express2['default']['static'](_path2['default'].join(__dirname, 'public')));
app.get('/main.js', (0, _browserifyMiddleware2['default'])(__dirname + '/client/index.js'));

app.use('/fila', _kue2['default'].app);
app.use('/', _routesIndex2['default']);
app.use('/datasources', _routesDatasources2['default']);

// catch 404 and forward to error handler
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});

// error handlers

// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}

// production error handler
// no stacktraces leaked to user
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});

exports['default'] = app;
module.exports = exports['default'];
50 changes: 50 additions & 0 deletions dist/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';

var m = require('mithril');

var Datasource = function Datasource(data) {
data = data || { id: '', name: '', key: '', interval_update: '' };
this.id = m.prop(data.id);
this.name = m.prop(data.name);
this.key = m.prop(data.key);
this.interval_update = m.prop(data.interval_update);
};
Datasource.list = function (data) {
return m.request({ method: "GET", url: "/datasources", data: data });
};
Datasource.save = function (data) {
return m.request({ method: "POST", url: "/datasources", data: data });
};

var DatasourceForm = {
controller: function controller(args) {
this.ds = m.prop(args.ds || new Datasource());
},
view: function view(ctrl, args) {
var ds = ctrl.ds();

return m('.teste', [m('h1', 'Processador de inscrições (beta)'), m('.half', [m('.pure-form.pure-form-aligned', [m('h2', 'Adicionar planilha'), m('.pure-control-group', [m('label', 'Nome'), m("input", { onchange: m.withAttr("value", ds.name), value: ds.name() })]), m('.pure-control-group', [m('label', 'Chave da planilha no Google Drive'), m("input[placeholder=Ex.: 1gKGxto-RDqS5k2F3TbLXnOoj6IB6RFp18K_MUzBP_Hw]", { onchange: m.withAttr("value", ds.key), value: ds.key() })]), m('.pure-control-group', [m('label', 'Intervalo atualização (min)'), m("input", { onchange: m.withAttr("value", ds.interval_update), value: ds.interval_update() })]), m('.pure-controls', [m("button.pure-button.pure-button-primary", { onclick: args.onsave.bind(this, ds) }, "Salvar")])])])]);
}
};

var DatasourceList = {
view: function view(ctrl, args) {
return m('.half.active-spreadsheets', [m('h2', 'Planilhas ativas'), m("table", [args.ds().map(function (ds) {
return m("tr", [m("td", ds.id), m("td", ds.name), m("td", ds.key), m("td", ds.interval_update)]);
})])]);
}
};

var Home = {
controller: function update() {
this.datasources = Datasource.list();
this.save = (function (ds) {
Datasource.save(ds).then(update.bind(this));
}).bind(this);
},
view: function view(ctrl) {
return [m.component(DatasourceForm, { onsave: ctrl.save }), m.component(DatasourceList, { ds: ctrl.datasources })];
}
};

m.mount(document.body, Home);
23 changes: 23 additions & 0 deletions dist/models/datasource.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";

module.exports = function (sequelize, DataTypes) {
var Datasource = sequelize.define("Datasource", {
name: DataTypes.STRING,
key: DataTypes.STRING,
interval_update: DataTypes.INTEGER,
user_id: DataTypes.STRING
}, {
// classMethods: {
// associate: function(models) {
// Task.belongsTo(models.User, {
// onDelete: "CASCADE",
// foreignKey: {
// allowNull: false
// }
// });
// }
// }
});

return Datasource;
};
44 changes: 44 additions & 0 deletions dist/models/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

var _fs = require("fs");

var _fs2 = _interopRequireDefault(_fs);

var _path = require("path");

var _path2 = _interopRequireDefault(_path);

var _sequelize = require("sequelize");

var _sequelize2 = _interopRequireDefault(_sequelize);

// https://github.com/sequelize/express-example/blob/master/models/index.js

var db_url = process.env.DATABASE_URL || "mysql://[email protected]:/processador-inscricao-evento";
var sequelize = new _sequelize2["default"](db_url);
var db = {};

_fs2["default"].readdirSync(__dirname).filter(function (file) {
return file.indexOf(".") !== 0 && file !== "index.js";
}).forEach(function (file) {
var model = sequelize["import"](_path2["default"].join(__dirname, file));
db[model.name] = model;
});

Object.keys(db).forEach(function (modelName) {
if ("associate" in db[modelName]) {
db[modelName].associate(db);
}
});

db.sequelize = sequelize;
db.Sequelize = _sequelize2["default"];

exports["default"] = db;
module.exports = exports["default"];
74 changes: 74 additions & 0 deletions dist/modules/check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
'use strict';

Object.defineProperty(exports, '__esModule', {
value: true
});

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

var _datasource = require('./datasource');

var _datasource2 = _interopRequireDefault(_datasource);

var _mailer = require('./mailer');

var _mailer2 = _interopRequireDefault(_mailer);

var _async = require('async');

var _async2 = _interopRequireDefault(_async);

var Check = (function () {
function Check() {
_classCallCheck(this, Check);

this.DS = new _datasource2['default']();
this.ML = new _mailer2['default']();
this.validate = false;
}

_createClass(Check, [{
key: 'setMailer',
value: function setMailer(mailer) {
this.ML = mailer;
}
}, {
key: 'isValid',
value: function isValid() {
var callback = arguments.length <= 0 || arguments[0] === undefined ? function (err, results) {} : arguments[0];

var that = this;

if (!this.DS.isConfigEmpty()) {
callback('As configurações da fonte de dados não foram informados');
} else if (!this.ML.isConfigEmpty()) {
callback('As configurações do envio do email não foram informados');
} else {
// valida datasource
_async2['default'].series([function (done) {
that.DS.testConnection(done);
}, function (done) {
that.DS.readContent(done);
}, function (done) {
that.ML.testSend(done);
}], function (err, results) {
if (!err) {
that.validate = true;
callback(null, ['-> Checagem de conexão com a planilha ok.', '-> Checagem de envio de e-mail ok.'].join('\n'));
} else {
callback(err.toString());
}
});
}
}
}]);

return Check;
})();

exports['default'] = Check;
module.exports = exports['default'];
Loading

0 comments on commit 418df5b

Please sign in to comment.