Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / api / userProfileSection / userProfileSection.controller.js
index 24417f5..64e50f2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3958=['body','catch','destroy','find','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','ejs','lodash','squel','crypto','jsforce','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/environment','../../config/license/util','../../mysqldb','end','json','offset','limit','status','set','Content-Range','apply','update','then','sendStatus','stack','name','send','index','map','UserProfileSection','fieldName','type','key','model','query','keys','filters','intersection','length','attributes','hasOwnProperty','nolimit','order','where','filter','VIRTUAL','merge','options','count','includeAll','include','rows','show','params','fields','create'];(function(_0x593fa0,_0x23b388){var _0x452eee=function(_0x450d4e){while(--_0x450d4e){_0x593fa0['push'](_0x593fa0['shift']());}};_0x452eee(++_0x23b388);}(_0x3958,0x172));var _0x8395=function(_0x3df4fb,_0xec4e18){_0x3df4fb=_0x3df4fb-0x0;var _0x408c16=_0x3958[_0x3df4fb];return _0x408c16;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x8395('0x0'));var rimraf=require(_0x8395('0x1'));var zipdir=require(_0x8395('0x2'));var jsonpatch=require(_0x8395('0x3'));var rp=require(_0x8395('0x4'));var moment=require(_0x8395('0x5'));var BPromise=require(_0x8395('0x6'));var Mustache=require(_0x8395('0x7'));var util=require(_0x8395('0x8'));var path=require('path');var sox=require(_0x8395('0x9'));var csv=require('to-csv');var ejs=require(_0x8395('0xa'));var fs=require('fs');var _=require(_0x8395('0xb'));var squel=require(_0x8395('0xc'));var crypto=require(_0x8395('0xd'));var jsforce=require(_0x8395('0xe'));var deskjs=require('desk.js');var toCsv=require(_0x8395('0xf'));var querystring=require('querystring');var Papa=require(_0x8395('0x10'));var Redis=require(_0x8395('0x11'));var authService=require(_0x8395('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0x8395('0x13'));var hardwareService=require(_0x8395('0x14'));var logger=require('../../config/logger')(_0x8395('0x15'));var utils=require('../../config/utils');var config=require(_0x8395('0x16'));var licenseUtil=require(_0x8395('0x17'));var db=require(_0x8395('0x18'))['db'];function respondWithStatusCode(_0x139bf3,_0x27a686){_0x27a686=_0x27a686||0xcc;return function(_0x1a2d0c){if(_0x1a2d0c){return _0x139bf3['sendStatus'](_0x27a686);}return _0x139bf3['status'](_0x27a686)[_0x8395('0x19')]();};}function respondWithResult(_0x2f5a25,_0x7d91ce){_0x7d91ce=_0x7d91ce||0xc8;return function(_0x4edff7){if(_0x4edff7){return _0x2f5a25['status'](_0x7d91ce)[_0x8395('0x1a')](_0x4edff7);}};}function respondWithFilteredResult(_0xfb81e4,_0x3b301c){return function(_0x1f0213){if(_0x1f0213){var _0x18be69=_0x1f0213['count'],_0x4a2cb1=_0x3b301c[_0x8395('0x1b')],_0x5b2272=_0x3b301c[_0x8395('0x1b')]+_0x3b301c[_0x8395('0x1c')],_0x2b4ae7;if(_0x5b2272>=_0x18be69){_0x5b2272=_0x18be69;_0x2b4ae7=0xc8;}else{_0x2b4ae7=0xce;}_0xfb81e4[_0x8395('0x1d')](_0x2b4ae7);return _0xfb81e4[_0x8395('0x1e')](_0x8395('0x1f'),_0x4a2cb1+'-'+_0x5b2272+'/'+_0x18be69)[_0x8395('0x1a')](_0x1f0213);}return null;};}function patchUpdates(_0x298ba6){return function(_0x219ebb){try{jsonpatch[_0x8395('0x20')](_0x219ebb,_0x298ba6,!![]);}catch(_0x144bb9){return BPromise['reject'](_0x144bb9);}return _0x219ebb['save']();};}function saveUpdates(_0x11f6db,_0x597e59){return function(_0x582489){if(_0x582489){return _0x582489[_0x8395('0x21')](_0x11f6db)[_0x8395('0x22')](function(_0x26eddd){return _0x26eddd;});}return null;};}function removeEntity(_0x1f97a2,_0x2fd7ec){return function(_0x20a308){if(_0x20a308){return _0x20a308['destroy']()[_0x8395('0x22')](function(){_0x1f97a2[_0x8395('0x1d')](0xcc)[_0x8395('0x19')]();});}};}function handleEntityNotFound(_0x2a9777,_0x31f938){return function(_0x14f77d){if(!_0x14f77d){_0x2a9777[_0x8395('0x23')](0x194);}return _0x14f77d;};}function handleError(_0x14f078,_0x5929d2){_0x5929d2=_0x5929d2||0x1f4;return function(_0x2a24ef){logger['error'](_0x2a24ef[_0x8395('0x24')]);if(_0x2a24ef[_0x8395('0x25')]){delete _0x2a24ef[_0x8395('0x25')];}_0x14f078[_0x8395('0x1d')](_0x5929d2)[_0x8395('0x26')](_0x2a24ef);};}exports[_0x8395('0x27')]=function(_0x40af7b,_0x2b38c4){var _0x481883={},_0x880997={},_0x45f5b7={'count':0x0,'rows':[]};var _0x405679=_[_0x8395('0x28')](db[_0x8395('0x29')]['rawAttributes'],function(_0x13d906){return{'name':_0x13d906[_0x8395('0x2a')],'type':_0x13d906[_0x8395('0x2b')][_0x8395('0x2c')]};});_0x880997[_0x8395('0x2d')]=_[_0x8395('0x28')](_0x405679,_0x8395('0x25'));_0x880997[_0x8395('0x2e')]=_[_0x8395('0x2f')](_0x40af7b[_0x8395('0x2e')]);_0x880997[_0x8395('0x30')]=_['intersection'](_0x880997[_0x8395('0x2d')],_0x880997[_0x8395('0x2e')]);_0x481883['attributes']=_[_0x8395('0x31')](_0x880997[_0x8395('0x2d')],qs['fields'](_0x40af7b[_0x8395('0x2e')]['fields']));_0x481883['attributes']=_0x481883['attributes'][_0x8395('0x32')]?_0x481883[_0x8395('0x33')]:_0x880997['model'];if(!_0x40af7b[_0x8395('0x2e')][_0x8395('0x34')](_0x8395('0x35'))){_0x481883[_0x8395('0x1c')]=qs[_0x8395('0x1c')](_0x40af7b[_0x8395('0x2e')][_0x8395('0x1c')]);_0x481883[_0x8395('0x1b')]=qs[_0x8395('0x1b')](_0x40af7b[_0x8395('0x2e')][_0x8395('0x1b')]);}_0x481883[_0x8395('0x36')]=qs['sort'](_0x40af7b['query']['sort']);_0x481883[_0x8395('0x37')]=qs[_0x8395('0x30')](_['pick'](_0x40af7b[_0x8395('0x2e')],_0x880997[_0x8395('0x30')]),_0x405679);if(_0x40af7b[_0x8395('0x2e')][_0x8395('0x38')]){_0x481883[_0x8395('0x37')]=_['merge'](_0x481883[_0x8395('0x37')],{'$or':_['map'](_0x405679,function(_0x4aadbf){if(_0x4aadbf[_0x8395('0x2b')]!==_0x8395('0x39')){var _0xe7ef60={};_0xe7ef60[_0x4aadbf[_0x8395('0x25')]]={'$like':'%'+_0x40af7b[_0x8395('0x2e')]['filter']+'%'};return _0xe7ef60;}})});}_0x481883=_[_0x8395('0x3a')]({},_0x481883,_0x40af7b[_0x8395('0x3b')]);var _0x123423={'where':_0x481883[_0x8395('0x37')]};return db[_0x8395('0x29')][_0x8395('0x3c')](_0x123423)['then'](function(_0xe1a5cf){_0x45f5b7[_0x8395('0x3c')]=_0xe1a5cf;if(_0x40af7b[_0x8395('0x2e')][_0x8395('0x3d')]){_0x481883[_0x8395('0x3e')]=[{'all':!![]}];}return db[_0x8395('0x29')]['findAll'](_0x481883);})[_0x8395('0x22')](function(_0x71303e){_0x45f5b7[_0x8395('0x3f')]=_0x71303e;return _0x45f5b7;})[_0x8395('0x22')](respondWithFilteredResult(_0x2b38c4,_0x481883))['catch'](handleError(_0x2b38c4,null));};exports[_0x8395('0x40')]=function(_0x25c407,_0x4145c6){var _0xc330a2={'raw':![],'where':{'id':_0x25c407[_0x8395('0x41')]['id']}},_0x13139c={};_0x13139c[_0x8395('0x2d')]=_[_0x8395('0x2f')](db[_0x8395('0x29')]['rawAttributes']);_0x13139c['query']=_[_0x8395('0x2f')](_0x25c407[_0x8395('0x2e')]);_0x13139c[_0x8395('0x30')]=_[_0x8395('0x31')](_0x13139c[_0x8395('0x2d')],_0x13139c['query']);_0xc330a2[_0x8395('0x33')]=_['intersection'](_0x13139c[_0x8395('0x2d')],qs['fields'](_0x25c407[_0x8395('0x2e')][_0x8395('0x42')]));_0xc330a2[_0x8395('0x33')]=_0xc330a2[_0x8395('0x33')]['length']?_0xc330a2[_0x8395('0x33')]:_0x13139c['model'];if(_0x25c407[_0x8395('0x2e')][_0x8395('0x3d')]){_0xc330a2['include']=[{'all':!![]}];}_0xc330a2=_[_0x8395('0x3a')]({},_0xc330a2,_0x25c407[_0x8395('0x3b')]);return db[_0x8395('0x29')]['find'](_0xc330a2)[_0x8395('0x22')](handleEntityNotFound(_0x4145c6,null))[_0x8395('0x22')](respondWithResult(_0x4145c6,null))['catch'](handleError(_0x4145c6,null));};exports[_0x8395('0x43')]=function(_0x5259fc,_0x12a4ca){return db['UserProfileSection'][_0x8395('0x43')](_0x5259fc[_0x8395('0x44')],{})[_0x8395('0x22')](respondWithResult(_0x12a4ca,0xc9))[_0x8395('0x45')](handleError(_0x12a4ca,null));};exports['update']=function(_0x4328c7,_0xf2ee24){if(_0x4328c7[_0x8395('0x44')]['id']){delete _0x4328c7[_0x8395('0x44')]['id'];}return db['UserProfileSection']['find']({'where':{'id':_0x4328c7[_0x8395('0x41')]['id']}})[_0x8395('0x22')](handleEntityNotFound(_0xf2ee24,null))[_0x8395('0x22')](saveUpdates(_0x4328c7[_0x8395('0x44')],null))[_0x8395('0x22')](respondWithResult(_0xf2ee24,null))[_0x8395('0x45')](handleError(_0xf2ee24,null));};exports[_0x8395('0x46')]=function(_0x5344c7,_0x2d06ae){return db['UserProfileSection'][_0x8395('0x47')]({'where':{'id':_0x5344c7[_0x8395('0x41')]['id']}})[_0x8395('0x22')](handleEntityNotFound(_0x2d06ae,null))[_0x8395('0x22')](removeEntity(_0x2d06ae,null))[_0x8395('0x45')](handleError(_0x2d06ae,null));};exports['describe']=function(_0x27670d,_0x305fda){return db[_0x8395('0x29')][_0x8395('0x48')]()[_0x8395('0x22')](respondWithResult(_0x305fda,null))[_0x8395('0x45')](handleError(_0x305fda,null));};
\ No newline at end of file
+var _0x78e9=['error','name','send','index','rawAttributes','type','key','map','query','filters','intersection','model','attributes','fields','length','nolimit','order','sort','where','filter','VIRTUAL','merge','options','includeAll','include','UserProfileSection','rows','show','params','keys','find','catch','create','body','describe','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','lodash','squel','crypto','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','undefined','limit','count','offset','set','Content-Range','json','save','update','destroy','then'];(function(_0x10d3c2,_0x1f5142){var _0x4208aa=function(_0x2e1ff9){while(--_0x2e1ff9){_0x10d3c2['push'](_0x10d3c2['shift']());}};_0x4208aa(++_0x1f5142);}(_0x78e9,0x190));var _0x978e=function(_0x8cfaba,_0x207ffb){_0x8cfaba=_0x8cfaba-0x0;var _0x2dc0db=_0x78e9[_0x8cfaba];return _0x2dc0db;};'use strict';var emlformat=require(_0x978e('0x0'));var rimraf=require(_0x978e('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x978e('0x2'));var rp=require(_0x978e('0x3'));var moment=require(_0x978e('0x4'));var BPromise=require(_0x978e('0x5'));var Mustache=require(_0x978e('0x6'));var util=require(_0x978e('0x7'));var path=require(_0x978e('0x8'));var sox=require(_0x978e('0x9'));var csv=require(_0x978e('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x978e('0xb'));var squel=require(_0x978e('0xc'));var crypto=require(_0x978e('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x978e('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x978e('0xf'));var Redis=require(_0x978e('0x10'));var authService=require(_0x978e('0x11'));var qs=require(_0x978e('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x978e('0x13'));var logger=require(_0x978e('0x14'))('api');var utils=require(_0x978e('0x15'));var config=require(_0x978e('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0x978e('0x17'))['db'];function respondWithStatusCode(_0x5ec496,_0x5163c8){_0x5163c8=_0x5163c8||0xcc;return function(_0x4f123c){if(_0x4f123c){return _0x5ec496[_0x978e('0x18')](_0x5163c8);}return _0x5ec496[_0x978e('0x19')](_0x5163c8)[_0x978e('0x1a')]();};}function respondWithResult(_0x4301d0,_0x23dde1){_0x23dde1=_0x23dde1||0xc8;return function(_0x574ad8){if(_0x574ad8){return _0x4301d0[_0x978e('0x19')](_0x23dde1)['json'](_0x574ad8);}};}function respondWithFilteredResult(_0x5b2771,_0x202a23){return function(_0x9a35fb){if(_0x9a35fb){var _0x9653b4=typeof _0x202a23['offset']===_0x978e('0x1b')&&typeof _0x202a23[_0x978e('0x1c')]==='undefined';var _0x1bd8de=_0x9a35fb[_0x978e('0x1d')];var _0x4f9e84=_0x9653b4?0x0:_0x202a23[_0x978e('0x1e')];var _0x51ca13=_0x9653b4?_0x9a35fb[_0x978e('0x1d')]:_0x202a23[_0x978e('0x1e')]+_0x202a23['limit'];var _0x5943a8;if(_0x51ca13>=_0x1bd8de){_0x51ca13=_0x1bd8de;_0x5943a8=0xc8;}else{_0x5943a8=0xce;}_0x5b2771[_0x978e('0x19')](_0x5943a8);return _0x5b2771[_0x978e('0x1f')](_0x978e('0x20'),_0x4f9e84+'-'+_0x51ca13+'/'+_0x1bd8de)[_0x978e('0x21')](_0x9a35fb);}return null;};}function patchUpdates(_0x1329e1){return function(_0x4ce4e8){try{jsonpatch['apply'](_0x4ce4e8,_0x1329e1,!![]);}catch(_0x5b0d98){return BPromise['reject'](_0x5b0d98);}return _0x4ce4e8[_0x978e('0x22')]();};}function saveUpdates(_0x328c66,_0x1025c8){return function(_0x7915f7){if(_0x7915f7){return _0x7915f7[_0x978e('0x23')](_0x328c66)['then'](function(_0x4ad091){return _0x4ad091;});}return null;};}function removeEntity(_0x37e3ca,_0x2d43b2){return function(_0x448b60){if(_0x448b60){return _0x448b60[_0x978e('0x24')]()[_0x978e('0x25')](function(){_0x37e3ca[_0x978e('0x19')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4f8cde,_0x3d6fba){return function(_0x564aaa){if(!_0x564aaa){_0x4f8cde[_0x978e('0x18')](0x194);}return _0x564aaa;};}function handleError(_0x1ec313,_0x57cacd){_0x57cacd=_0x57cacd||0x1f4;return function(_0x525c18){logger[_0x978e('0x26')](_0x525c18['stack']);if(_0x525c18[_0x978e('0x27')]){delete _0x525c18[_0x978e('0x27')];}_0x1ec313[_0x978e('0x19')](_0x57cacd)[_0x978e('0x28')](_0x525c18);};}exports[_0x978e('0x29')]=function(_0x482793,_0x544e36){var _0x56b4b0={},_0x247483={},_0x327fff={'count':0x0,'rows':[]};var _0x89a50a=_['map'](db['UserProfileSection'][_0x978e('0x2a')],function(_0xdebb81){return{'name':_0xdebb81['fieldName'],'type':_0xdebb81[_0x978e('0x2b')][_0x978e('0x2c')]};});_0x247483['model']=_[_0x978e('0x2d')](_0x89a50a,_0x978e('0x27'));_0x247483['query']=_['keys'](_0x482793[_0x978e('0x2e')]);_0x247483[_0x978e('0x2f')]=_[_0x978e('0x30')](_0x247483[_0x978e('0x31')],_0x247483[_0x978e('0x2e')]);_0x56b4b0[_0x978e('0x32')]=_[_0x978e('0x30')](_0x247483[_0x978e('0x31')],qs[_0x978e('0x33')](_0x482793[_0x978e('0x2e')][_0x978e('0x33')]));_0x56b4b0['attributes']=_0x56b4b0[_0x978e('0x32')][_0x978e('0x34')]?_0x56b4b0[_0x978e('0x32')]:_0x247483[_0x978e('0x31')];if(!_0x482793['query']['hasOwnProperty'](_0x978e('0x35'))){_0x56b4b0[_0x978e('0x1c')]=qs[_0x978e('0x1c')](_0x482793[_0x978e('0x2e')][_0x978e('0x1c')]);_0x56b4b0['offset']=qs['offset'](_0x482793[_0x978e('0x2e')][_0x978e('0x1e')]);}_0x56b4b0[_0x978e('0x36')]=qs[_0x978e('0x37')](_0x482793[_0x978e('0x2e')][_0x978e('0x37')]);_0x56b4b0[_0x978e('0x38')]=qs[_0x978e('0x2f')](_['pick'](_0x482793[_0x978e('0x2e')],_0x247483[_0x978e('0x2f')]),_0x89a50a);if(_0x482793[_0x978e('0x2e')][_0x978e('0x39')]){_0x56b4b0[_0x978e('0x38')]=_['merge'](_0x56b4b0[_0x978e('0x38')],{'$or':_[_0x978e('0x2d')](_0x89a50a,function(_0x3accbd){if(_0x3accbd['type']!==_0x978e('0x3a')){var _0x1a8737={};_0x1a8737[_0x3accbd[_0x978e('0x27')]]={'$like':'%'+_0x482793['query']['filter']+'%'};return _0x1a8737;}})});}_0x56b4b0=_[_0x978e('0x3b')]({},_0x56b4b0,_0x482793[_0x978e('0x3c')]);var _0x12e1e8={'where':_0x56b4b0[_0x978e('0x38')]};return db['UserProfileSection'][_0x978e('0x1d')](_0x12e1e8)[_0x978e('0x25')](function(_0x37e7ac){_0x327fff['count']=_0x37e7ac;if(_0x482793['query'][_0x978e('0x3d')]){_0x56b4b0[_0x978e('0x3e')]=[{'all':!![]}];}return db[_0x978e('0x3f')]['findAll'](_0x56b4b0);})[_0x978e('0x25')](function(_0x10beee){_0x327fff[_0x978e('0x40')]=_0x10beee;return _0x327fff;})[_0x978e('0x25')](respondWithFilteredResult(_0x544e36,_0x56b4b0))['catch'](handleError(_0x544e36,null));};exports[_0x978e('0x41')]=function(_0x41c3e9,_0x119700){var _0x52403a={'raw':![],'where':{'id':_0x41c3e9[_0x978e('0x42')]['id']}},_0x58b8e3={};_0x58b8e3[_0x978e('0x31')]=_['keys'](db[_0x978e('0x3f')][_0x978e('0x2a')]);_0x58b8e3[_0x978e('0x2e')]=_[_0x978e('0x43')](_0x41c3e9[_0x978e('0x2e')]);_0x58b8e3[_0x978e('0x2f')]=_['intersection'](_0x58b8e3[_0x978e('0x31')],_0x58b8e3[_0x978e('0x2e')]);_0x52403a[_0x978e('0x32')]=_[_0x978e('0x30')](_0x58b8e3['model'],qs[_0x978e('0x33')](_0x41c3e9[_0x978e('0x2e')]['fields']));_0x52403a['attributes']=_0x52403a[_0x978e('0x32')][_0x978e('0x34')]?_0x52403a[_0x978e('0x32')]:_0x58b8e3['model'];if(_0x41c3e9['query'][_0x978e('0x3d')]){_0x52403a[_0x978e('0x3e')]=[{'all':!![]}];}_0x52403a=_[_0x978e('0x3b')]({},_0x52403a,_0x41c3e9[_0x978e('0x3c')]);return db[_0x978e('0x3f')][_0x978e('0x44')](_0x52403a)[_0x978e('0x25')](handleEntityNotFound(_0x119700,null))[_0x978e('0x25')](respondWithResult(_0x119700,null))[_0x978e('0x45')](handleError(_0x119700,null));};exports[_0x978e('0x46')]=function(_0x790dc5,_0x2b9d33){return db[_0x978e('0x3f')][_0x978e('0x46')](_0x790dc5['body'],{})['then'](respondWithResult(_0x2b9d33,0xc9))[_0x978e('0x45')](handleError(_0x2b9d33,null));};exports[_0x978e('0x23')]=function(_0x58ae5d,_0x30c2a5){if(_0x58ae5d[_0x978e('0x47')]['id']){delete _0x58ae5d[_0x978e('0x47')]['id'];}return db[_0x978e('0x3f')][_0x978e('0x44')]({'where':{'id':_0x58ae5d[_0x978e('0x42')]['id']}})[_0x978e('0x25')](handleEntityNotFound(_0x30c2a5,null))[_0x978e('0x25')](saveUpdates(_0x58ae5d['body'],null))['then'](respondWithResult(_0x30c2a5,null))['catch'](handleError(_0x30c2a5,null));};exports[_0x978e('0x24')]=function(_0x58f02d,_0x579368){return db[_0x978e('0x3f')][_0x978e('0x44')]({'where':{'id':_0x58f02d[_0x978e('0x42')]['id']}})[_0x978e('0x25')](handleEntityNotFound(_0x579368,null))['then'](removeEntity(_0x579368,null))[_0x978e('0x45')](handleError(_0x579368,null));};exports['describe']=function(_0x583b9c,_0xe8d551){return db[_0x978e('0x3f')][_0x978e('0x48')]()[_0x978e('0x25')](respondWithResult(_0xe8d551,null))[_0x978e('0x45')](handleError(_0xe8d551,null));};
\ No newline at end of file