Built motion from commit 57474b6.|0.0.99
[motion.git] / server / api / widget / widget.controller.js
index f9bc793..546a6bc 100644 (file)
@@ -1,181 +1 @@
-'use strict';
-
-var _ = require('lodash');
-var util = require('util');
-var sequelize = require('../../models').sequelize;
-
-// var ReportAgent = require('../../models').ReportAgent;
-// var ReportCall = require('../../models').ReportCall;
-// var ReportDial = require('../../models').ReportDial;
-// var ReportMember = require('../../models').ReportMember;
-// var ReportQueue = require('../../models').ReportQueue;
-
-
-
-exports.counter = function(req, res) {
-  var table = util.format('report_%s', req.query.table);
-  sequelize.query(util.format("SELECT COUNT(*) as count FROM %s WHERE %s", table, decodeURIComponent(req.query.condition)), {
-      type: sequelize.QueryTypes.SELECT
-    })
-    .then(function(result) {
-      return res.status(200).send(result);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.table = function(req, res) {
-  var columns = [];
-  var elem;
-  if (req.query.fields) {
-    if (_.isArray(req.query.fields)) {
-      req.query.fields.forEach(function(element) {
-        elem = JSON.parse(element);
-        if (elem.column && elem.alias) {
-          columns.push(elem.column + ' AS "' + elem.alias + '"');
-        }
-      });
-    } else if (_.isString(req.query.fields)) {
-      elem = JSON.parse(req.query.fields);
-      if (elem.column && elem.alias) {
-        columns.push(elem.column + ' AS "' + elem.alias + '"');
-      }
-    }
-  }
-  var select = columns.length ? columns.join(',') : '*';
-  var table = util.format('report_%s', req.query.table);
-  sequelize.query(util.format("SELECT %s FROM %s WHERE %s", select, table, decodeURIComponent(req.query.condition)), {
-      type: sequelize.QueryTypes.SELECT
-    })
-    .then(function(result) {
-      return res.status(200).send(result);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-exports.piechart = function(req, res) {
-  var columns = [];
-  var elem;
-  if (req.query.fields) {
-    if (_.isArray(req.query.fields)) {
-      req.query.fields.forEach(function(element) {
-        elem = JSON.parse(element);
-        if (elem.column && elem.alias) {
-          columns.push(elem.column + ' AS "' + elem.alias + '"');
-        }
-      });
-    } else if (_.isString(req.query.fields)) {
-      elem = JSON.parse(req.query.fields);
-      if (elem.column && elem.alias) {
-        columns.push(elem.column + ' AS "' + elem.alias + '"');
-      }
-    }
-  }
-  var select = columns.length ? columns.join(',') : '*';
-  var table = util.format('report_%s', req.query.table);
-  var where = '';
-  if (req.query.condition !== 'undefined') {
-    where = util.format(' WHERE %s', decodeURIComponent(req.query.condition));
-  }
-  sequelize.query(util.format("SELECT %s FROM %s%s", select, table, where), {
-      type: sequelize.QueryTypes.SELECT
-    })
-    .then(function(result) {
-      return res.status(200).send(result);
-    })
-    .catch(function(err) {
-      return handleError(res, err);
-    });
-};
-
-// // Get list of widgets
-// exports.index = function(req, res) {
-//   Widget
-//   .findAll()
-//   .then(function (widgets) {
-//     return res.status(200).send(widgets);
-//   })
-//   .catch(function(err) {
-//     return handleError(res, err);
-//   });
-// };
-//
-// // Get a single widget
-// exports.show = function(req, res) {
-//   Widget
-//   .findById(req.params.id)
-//   .then(function (widget) {
-//     if(!widget) { return res.sendStatus(404); }
-//     return res.send(widget);
-//   })
-//   .catch(function(err){
-//     return handleError(res, err);
-//   });
-// };
-//
-// // Creates a new widget in the DB.
-// exports.create = function(req, res) {
-//   Widget
-//   .create(req.body)
-//   .then(function(widget) {
-//     return res.status(201).send(widget);
-//   })
-//   .catch(function(err) {
-//     return handleError(res, err);
-//   });
-// };
-//
-// // Updates an existing widget in the DB.
-// exports.update = function(req, res) {
-//   if(req.body.id) { delete req.body.id; }
-//   Widget
-//   .find({
-//     where: {
-//       id: req.params.id
-//     }
-//   })
-//   .then(function (widget) {
-//     if(!widget) { return res.sendStatus(404); }
-//     var updated = _.merge(widget, req.body);
-//     updated.save()
-//     .then(function () {
-//       return res.status(200).send(widget);
-//     })
-//     .catch(function(err) {
-//       return handleError(res, err);
-//     });
-//   })
-//   .catch(function(err) {
-//     return handleError(res, err);
-//   });
-// };
-//
-// // Deletes a widget from the DB.
-// exports.destroy = function(req, res) {
-//   Widget
-//   .find({
-//     where: {
-//       id: req.params.id
-//     }
-//   })
-//   .then(function (widget) {
-//     if(!widget) { return res.sendStatus(404); }
-//     widget.destroy()
-//     .then(function() {
-//       return res.sendStatus(204);
-//     })
-//     .catch(function(err) {
-//       return handleError(res, err);
-//     });
-//   })
-//   .catch(function(err) {
-//     return handleError(res, err);
-//   });
-// };
-
-function handleError(res, err) {
-  return res.status(500).send(err);
-}
+var _0x8ffc=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x75\x74\x69\x6C","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x2E\x2E\x2F\x2E\x2E\x2F\x75\x74\x69\x6C\x73\x2F\x72\x65\x70\x6F\x72\x74\x5F\x62\x75\x69\x6C\x64","\x62\x6C\x75\x65\x62\x69\x72\x64","\x63\x6F\x75\x6E\x74\x65\x72","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x53\x45\x4C\x45\x43\x54\x20\x25\x73\x20\x46\x52\x4F\x4D\x20\x25\x73","\x73\x65\x6C\x65\x63\x74","\x71\x75\x65\x72\x79","\x74\x61\x62\x6C\x65","\x66\x6F\x72\x6D\x61\x74","\x63\x6F\x6E\x64\x69\x74\x69\x6F\x6E","\x20\x57\x48\x45\x52\x45\x20\x25\x73","\x65\x6D\x70\x74\x79","\x20\x41\x4E\x44\x20","\x20\x57\x48\x45\x52\x45\x20","\x20\x3D\x3D\x3D\x3D\x20\x52\x45\x53\x55\x4C\x54\x49\x4E\x47\x20\x51\x55\x45\x52\x59\x20\x3D\x3D\x3D\x3D","\x20\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D\x3D","\x53\x45\x4C\x45\x43\x54","\x51\x75\x65\x72\x79\x54\x79\x70\x65\x73","\x4E\x4F\x20\x53\x55\x46\x46\x49\x43\x49\x45\x4E\x54\x20\x50\x45\x52\x4D\x49\x53\x53\x49\x4F\x4E\x53","\x75\x73\x65\x72","\x62\x75\x69\x6C\x64\x46\x69\x6C\x74\x65\x72","\x61\x6C\x6C","\x66\x69\x65\x6C\x64\x73","\x69\x73\x41\x72\x72\x61\x79","\x70\x61\x72\x73\x65","\x63\x6F\x6C\x75\x6D\x6E","\x61\x6C\x69\x61\x73","\x20\x41\x53\x20\x22","\x22","\x70\x75\x73\x68","\x66\x6F\x72\x45\x61\x63\x68","\x69\x73\x53\x74\x72\x69\x6E\x67","\x6C\x65\x6E\x67\x74\x68","\x2C","\x6A\x6F\x69\x6E","\x2A","\x53\x45\x4C\x45\x43\x54\x20\x25\x73\x20\x46\x52\x4F\x4D\x20\x25\x73\x20\x57\x48\x45\x52\x45\x20\x25\x73","\x72\x65\x70\x6F\x72\x74","\x70\x69\x65\x63\x68\x61\x72\x74","","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x53\x45\x4C\x45\x43\x54\x20\x25\x73\x20\x46\x52\x4F\x4D\x20\x25\x73\x25\x73"];_0x8ffc[0];var _=require(_0x8ffc[1]);var util=require(_0x8ffc[2]);var sequelize=require(_0x8ffc[4])[_0x8ffc[3]];var reportBuildUtils=require(_0x8ffc[5]);var Promise=require(_0x8ffc[6]);exports[_0x8ffc[7]]=function(_0x96e1x6,_0x96e1x7){return Promise[_0x8ffc[30]]([])[_0x8ffc[12]](function(){return _0x96e1x6[_0x8ffc[15]][_0x8ffc[16]]})[_0x8ffc[12]](reportBuildUtils[_0x8ffc[29]](_0x96e1x6[_0x8ffc[28]]))[_0x8ffc[12]](function(_0x96e1xa){var _0x96e1xb=util[_0x8ffc[17]](_0x8ffc[13],_0x96e1x6[_0x8ffc[15]][_0x8ffc[14]],_0x96e1x6[_0x8ffc[15]][_0x8ffc[16]]);if(_0x96e1x6[_0x8ffc[15]][_0x8ffc[18]]){_0x96e1xb+=util[_0x8ffc[17]](_0x8ffc[19],decodeURIComponent(_0x96e1x6[_0x8ffc[15]][_0x8ffc[18]]))};if(!_0x96e1xa||_0x96e1xa!==_0x8ffc[20]){if(_0x96e1xa){_0x96e1xb+=_0x96e1x6[_0x8ffc[15]][_0x8ffc[18]]?_0x8ffc[21]+_0x96e1xa:_0x8ffc[22]+_0x96e1xa};console[_0x8ffc[8]](_0x8ffc[23]);console[_0x8ffc[8]](_0x96e1xb);console[_0x8ffc[8]](_0x8ffc[24]);return sequelize[_0x8ffc[15]](_0x96e1xb,{type:sequelize[_0x8ffc[26]][_0x8ffc[25]]})}else {console[_0x8ffc[8]](_0x8ffc[23]);console[_0x8ffc[8]](_0x8ffc[27]);console[_0x8ffc[8]](_0x8ffc[24]);return []}})[_0x8ffc[12]](function(_0x96e1x9){return _0x96e1x7[_0x8ffc[11]](200)[_0x8ffc[10]]({result:_0x96e1x9})})[_0x8ffc[9]](function(_0x96e1x8){console[_0x8ffc[8]](_0x96e1x8);return handleError(_0x96e1x7,_0x96e1x8)})};exports[_0x8ffc[16]]=function(_0x96e1x6,_0x96e1x7){var _0x96e1xc=[];var _0x96e1xd;if(_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]]){if(_[_0x8ffc[32]](_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]])){_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]][_0x8ffc[39]](function(_0x96e1xe){_0x96e1xd=JSON[_0x8ffc[33]](_0x96e1xe);if(_0x96e1xd[_0x8ffc[34]]&&_0x96e1xd[_0x8ffc[35]]){_0x96e1xc[_0x8ffc[38]](_0x96e1xd[_0x8ffc[34]]+_0x8ffc[36]+_0x96e1xd[_0x8ffc[35]]+_0x8ffc[37])}})}else {if(_[_0x8ffc[40]](_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]])){_0x96e1xd=JSON[_0x8ffc[33]](_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]]);if(_0x96e1xd[_0x8ffc[34]]&&_0x96e1xd[_0x8ffc[35]]){_0x96e1xc[_0x8ffc[38]](_0x96e1xd[_0x8ffc[34]]+_0x8ffc[36]+_0x96e1xd[_0x8ffc[35]]+_0x8ffc[37])}}}};var _0x96e1xf=_0x96e1xc[_0x8ffc[41]]?_0x96e1xc[_0x8ffc[43]](_0x8ffc[42]):_0x8ffc[44];sequelize[_0x8ffc[15]](util[_0x8ffc[17]](_0x8ffc[45],_0x96e1xf,_0x8ffc[46]+_0x96e1x6[_0x8ffc[15]][_0x8ffc[16]],decodeURIComponent(_0x96e1x6[_0x8ffc[15]][_0x8ffc[18]])),{type:sequelize[_0x8ffc[26]][_0x8ffc[25]]})[_0x8ffc[12]](function(_0x96e1x9){return _0x96e1x7[_0x8ffc[11]](200)[_0x8ffc[10]](_0x96e1x9)})[_0x8ffc[9]](function(_0x96e1x8){return handleError(_0x96e1x7,_0x96e1x8)})};exports[_0x8ffc[47]]=function(_0x96e1x6,_0x96e1x7){return Promise[_0x8ffc[30]]([])[_0x8ffc[12]](function(){return _0x96e1x6[_0x8ffc[15]][_0x8ffc[16]]})[_0x8ffc[12]](reportBuildUtils[_0x8ffc[29]](_0x96e1x6[_0x8ffc[28]]))[_0x8ffc[12]](function(_0x96e1xa){var _0x96e1xc=[];var _0x96e1xd;if(_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]]){if(_[_0x8ffc[32]](_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]])){_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]][_0x8ffc[39]](function(_0x96e1xe){_0x96e1xd=JSON[_0x8ffc[33]](_0x96e1xe);if(_0x96e1xd[_0x8ffc[34]]&&_0x96e1xd[_0x8ffc[35]]){_0x96e1xc[_0x8ffc[38]](_0x96e1xd[_0x8ffc[34]]+_0x8ffc[36]+_0x96e1xd[_0x8ffc[35]]+_0x8ffc[37])}})}else {if(_[_0x8ffc[40]](_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]])){_0x96e1xd=JSON[_0x8ffc[33]](_0x96e1x6[_0x8ffc[15]][_0x8ffc[31]]);if(_0x96e1xd[_0x8ffc[34]]&&_0x96e1xd[_0x8ffc[35]]){_0x96e1xc[_0x8ffc[38]](_0x96e1xd[_0x8ffc[34]]+_0x8ffc[36]+_0x96e1xd[_0x8ffc[35]]+_0x8ffc[37])}}}};var _0x96e1xf=_0x96e1xc[_0x8ffc[41]]?_0x96e1xc[_0x8ffc[43]](_0x8ffc[42]):_0x8ffc[44];var _0x96e1x10=_0x8ffc[48];if(_0x96e1x6[_0x8ffc[15]][_0x8ffc[18]]!==_0x8ffc[49]){_0x96e1x10=util[_0x8ffc[17]](_0x8ffc[19],decodeURIComponent(_0x96e1x6[_0x8ffc[15]][_0x8ffc[18]]))};if(!_0x96e1xa||_0x96e1xa!==_0x8ffc[20]){if(_0x96e1xa){_0x96e1x10+=_0x8ffc[21]+_0x96e1xa};var _0x96e1xb=util[_0x8ffc[17]](_0x8ffc[50],_0x96e1xf,_0x96e1x6[_0x8ffc[15]][_0x8ffc[16]],_0x96e1x10);console[_0x8ffc[8]](_0x8ffc[23]);console[_0x8ffc[8]](_0x96e1xb);console[_0x8ffc[8]](_0x8ffc[24]);return sequelize[_0x8ffc[15]](_0x96e1xb,{type:sequelize[_0x8ffc[26]][_0x8ffc[25]]})}else {console[_0x8ffc[8]](_0x8ffc[23]);console[_0x8ffc[8]](_0x8ffc[27]);console[_0x8ffc[8]](_0x8ffc[24]);return []}})[_0x8ffc[12]](function(_0x96e1x9){return _0x96e1x7[_0x8ffc[11]](200)[_0x8ffc[10]]({result:_0x96e1x9})})[_0x8ffc[9]](function(_0x96e1x8){return handleError(_0x96e1x7,_0x96e1x8)})};function handleError(_0x96e1x7,_0x96e1x8){return _0x96e1x7[_0x8ffc[11]](500)[_0x8ffc[10]](_0x96e1x8)}
\ No newline at end of file