Best JavaScript code snippet using appium-xcuitest-driver
api.js
Source:api.js
1// const domain = 'https://qinyuan-test.yunext.com'2var apiConfig = {3 // *****产å管ç*****4 // è·å产åä¿¡æ¯5 manage_product_getInfo: 'manage/product/getInfo',6 // 产åå表信æ¯7 manage_product_list: 'manage/product/list',8 // ä¿®æ¹äº§åä¿¡æ¯9 manage_product_update: 'manage/product/update',10 // 产åé
ç½®æ件å¾ç11 manage_productFile_getProductFileInfo: 'manage/productFile/getProductFileInfo',12 // ä¿åé
ç½®æ件13 manage_productFile_saveProductFile: 'manage/productFile/saveProductFile',14 // ä¿®æ¹è®¾å¤æµéä¿®æ£15 manage_waterConfig_saveWaterCorrectConfig: 'manage/waterConfig/saveWaterCorrectConfig',16 // ä¸è½½æ件17 getFilesAfterDelete: '/web/api/common/getFilesAfterDelete',18 // *****设å¤ç®¡ç*****19 // 设å¤è¯¦æ
20 manage_device_detail: 'manage/device/detail',21 // 设å¤å表22 manage_device_list: 'manage/device/list',23 // è·å设å¤æ»æ°24 manage_device_deviceCount: 'manage/device/deviceCount',25 // 设å¤æ°å¢è¶å¿æ¦åµ26 manage_device_trend_deviceCount: 'manage/device/trend/deviceCount',27 // 解ç»è®¾å¤28 manage_user_unbind_device: 'manage/user/unbind/device',29 // è·å设å¤ç§æ详æ
30 manage_deviceLease_getDeviceLeaseInfo: 'manage/deviceLease/getDeviceLeaseInfo',31 // ä¿å设å¤ç§æ32 manage_deviceLease_saveDeviceLease: 'manage/deviceLease/saveDeviceLease',33 // æ¸
é¤2G设å¤æ
é34 manage_device_cleanIOTDeviceError: 'manage/device/cleanIOTDeviceError',35 // æ¸
é¤wifi设å¤æ
é36 manage_device_cleanIlopDeviceError: 'manage/device/cleanIlopDeviceError',37 // 设置设å¤èè½æ¶é´38 manage_deviceSaveEnergy_saveDeviceSaveEnergy: 'manage/deviceSaveEnergy/saveDeviceSaveEnergy',39 // 设å¤è¶å¿å表40 manage_device_trend_list: 'manage/device/trend/list',41 // è·åæ°´è´¨ä¿¡æ¯ TDS æµåº¦ ä½æ°¯42 manage_deviceProperties_getDevicePropertiesInfo: 'manage/deviceProperties/getDevicePropertiesInfo',43 // 设å¤è¯¦æ
顶é¨æ°æ®44 manage_device_getIoTDeviceLeaseAndTraffic: 'manage/device/getIoTDeviceLeaseAndTraffic',45 // ç»å®ç¨æ·å表46 manage_device_detail_bindDeviceList: 'manage/device/detail/bindDeviceList',47 // ç¨æ·å享å表48 manage_device_detail_shareUser_list: 'manage/device/detail/shareUser/list',49 // è·åæ
éæ¥è¦å表50 manage_device_detail_deviceError_trend_list: 'manage/device/detail/deviceError/trend/list',51 // è·åè°è¯åå²52 manage_deviceAuth_getDeviceLeaseAuthList: 'manage/deviceAuth/getDeviceLeaseAuthList',53 // åééç½®è°è¯æ¬¡æ°54 manage_deviceDebug_resetDeviceLeaseDebug: 'manage/deviceDebug/resetDeviceLeaseDebug',55 // 2G设å¤è§£ç»56 manage_device_iotRemoveBindUser: 'manage/device/iotRemoveBindUser',57 // 解ç»å享ç¨æ·è®¾å¤58 manage_device_unbind_shareUser: 'manage/device/unbind/shareUser',59 // è·å设å¤TDSå°å¾æ°æ®60 manage_device_tds_map: 'manage/device/tds/map',61 // ç¨æ·ç»å®è®¾å¤62 manage_device_iotBind: 'manage/device/iotBind',63 // ç¼è¾è®¾å¤å±æ§64 manage_deviceProperties_saveDeviceProperties: 'manage/deviceProperties/saveDeviceProperties',65 // ç¼è¾è®¾å¤è°è¯æ¬¡æ°66 manage_deviceDebug_saveDeviceLeaseDebug: 'manage/deviceDebug/saveDeviceLeaseDebug',67 // å®¡æ ¸è®¾å¤è°è¯è¯·æ±68 manage_deviceAuth_authDeviceLeaseDebug: 'manage/deviceAuth/authDeviceLeaseDebug',69 // ä¿®æ£è®¾å¤ä½ç½®70 manage_device_reviseDeviceLocation: 'manage/device/reviseDeviceLocation',71 // *****ç³»ç»ç®¡ç*****72 // æ°å¢ç®¡çå73 manage_userAccount_create: 'manage/userAccount/create',74 // å é¤ç®¡çå75 manage_userAccount_delete: 'manage/userAccount/delete',76 // ç¦ç¨ç®¡çå77 manage_userAccount_forbidden: 'manage/userAccount/forbidden',78 // 管çåå表79 manage_userAccount_list: 'manage/userAccount/list',80 // éç½®å¯ç 81 manage_userAccount_reset_password: 'manage/userAccount/reset/password',82 // æ°å¢è§è²83 manage_role_create: 'manage/role/create',84 // å é¤è§è²85 manage_role_delete: 'manage/role/delete',86 // è§è²è¯¦æ
87 manage_role_detail: 'manage/role/detail',88 // è§è²å表89 manage_role_list: 'manage/role/list',90 // ä¿®æ¹è§è²91 manage_role_update: 'manage/role/update',92 // æéå表93 common_account_permission_list: 'common/account/permission/list',94 // è§è²å表95 common_account_role_list: 'common/account/role/list',96 // éªè¯ææºå·æ¯å¦åå¨97 common_account_checkPhone: 'common/account/checkPhone',98 // éªè¯ç¨æ·åæ¯å¦åå¨99 common_account_checkUserName: 'common/account/checkUserName',100 // ******æ
é*****101 // æ
éå表102 manage_breakdowns_getDeviceCurrentErrorList: 'manage/breakdowns/getDeviceCurrentErrorList',103 // æ
é驱å¿104 manage_breakdowns_getDeviceCurrentErrorTrent: 'manage/breakdowns/getDeviceCurrentErrorTrent',105 // æ ¹æ®æ¶é´æ¥è¯¢è®¾å¤æ
éæ»æ°106 manage_breakdowns_getDeviceCurrentErrorCount: 'manage/breakdowns/getDeviceCurrentErrorCount',107 //è·åæ
é详æ
108 manage_breakdowns_getBreakdownAndDealInfo: 'manage/breakdowns/getBreakdownAndDealInfo',109 // æ
é设置å表110 manage_breakdown_getBreakdownList: 'manage/breakdown/getBreakdownList',111 // å é¤è¡é¿å表112 manage_breakdown_deleteDeviceError: 'manage/breakdown/deleteDeviceError',113 // æ
é设置ç¼è¾114 manage_breakdown_updateBreakdown: 'manage/breakdown/updateBreakdown',115 // æ°å¢æ
é设置116 manage_breakdown_createBreakdown: 'manage/breakdown/createBreakdown',117 //æ
éç¦ç¨ãå¯ç¨ç¶æ118 manage_breakdown_forbidden: 'manage/breakdown/forbidden',119 // å é¤æ
é设置120 manage_breakdown_deleteBreakdown: 'manage/breakdown/deleteBreakdown',121 // æ
éé¢å¤ç页é¢æ¥å£122 manage_breakdown_getPretreatmentList: 'manage/breakdown/getPretreatmentList',123 // æ°å¢é¢å¤çæ¹æ¡124 manage_breakdown_createPretreatment: 'manage/breakdown/createPretreatment',125 // ç¼è¾/åç¨å¤çæ¹æ¡126 manage_breakdown_updatePretreatment: 'manage/breakdown/updatePretreatment',127 // å é¤å¤çæ¹æ¡128 manage_breakdown_deletePretreatment: 'manage/breakdown/deletePretreatment',129 // ä¿ä¿®å表130 manage_breakdowns_getBreakdownDealList: 'manage/breakdowns/getBreakdownDealList',131 // ******ç¨æ·******132 // ç¨æ·å表133 manage_user_list: 'manage/user/list',134 // æ¥è¯¢ç¨æ·è¯¦æ
135 manage_user_detail: 'manage/user/detail',136 // ç¨æ·è¶å¿137 manage_user_trend_list: 'manage/user/trend/list',138 // å é¤ç¨æ·139 manage_user_delete: 'manage/user/delete',140 // ç¨æ·è®¾å¤å表141 manage_user_detail_deviceList: 'manage/user/detail/deviceList',142 // æ¥è¯¢ç»å®è®¾å¤çç¨æ·æ°é143 manage_user_bind_device_count: 'manage/user/bind/device/count',144 // æ¥è¯¢ç¨æ·æ°å¢æ°145 manage_user_trend_count: 'manage/user/trend/count',146 // ******æ¶æ¯******147 // æ¶æ¯å表148 manage_messageRecord_getMessageRecordList: 'manage/messageRecord/getMessageRecordList',149 // æ¶æ¯æ¨éåå²150 manage_messageRecord_getMessageHistoryList: 'manage/messageRecord/getMessageHistoryList',151 // æ¶æ¯è¯¦æ
å表æ°æ®152 manage_messageRecord_getMessageRecordList: 'manage/messageRecord/getMessageRecordList',153 // æ¶æ¯è¯¦æ
154 manage_messageRecord_getMessageHistoryinfo: 'manage/messageRecord/getMessageHistoryinfo',155 // æ¶æ¯ç±»åå表156 manage_messageType_getMessageTypeList: 'manage/messageType/getMessageTypeList',157 // å é¤æ¶æ¯è®°å½158 manage_messageRecord_deleteMessageRecord: 'manage/messageRecord/deleteMessagePushHistory',159 // æ¨éè§åå表160 manage_message_getMessageConfigList: 'manage/message/getMessageConfigList',161 // å¯ç¨/åç¨æ¨éè§å162 manage_message_updateMessageConfigStatus: 'manage/message/updateMessageConfigStatus',163 // æ¨éè§åå é¤164 manage_message_deleteMessageConfig: 'manage/message/deleteMessageConfig',165 // æ¨éè§åä¿®æ¹/æ°å¢166 manage_message_saveMessageConfig: 'manage/message/saveMessageConfig',167 // æ¶æ¯ç±»åå表168 manage_messageType_getMessageTypeList: 'manage/messageType/getMessageTypeList',169 // æ°å»º/ä¿®æ¹æ¶æ¯ç±»å170 manage_messageType_saveMessageType: 'manage/messageType/saveMessageType',171 // å é¤æ¶æ¯ç±»å172 manage_messageType_deleteMessageType: 'manage/messageType/deleteMessageType',173 // åé¦å表æ¥å£174 manage_feedBack_list: 'manage/feedBack/list',175 // åå¤åé¦æ¥å£176 manage_feedBack_updateFeedBackFeedContent: 'manage/feedBack/updateFeedBackFeedContent',177 // æ¨é对象å表178 manage_messageSystem_getMessageSystemList: 'manage/messageSystem/getMessageSystemList',179 // å é¤æ¨é对象å表180 manage_messageSystem_deleteMessageSystem: 'manage/messageSystem/deleteMessageSystem',181 // æ°å¢/ç¼è¾æ¨å¨å¯¹è±¡182 manage_messageSystem_saveMessageSystem: 'manage/messageSystem/saveMessageSystem',183 // æ¨éæ¶æ¯184 manage_messageRecord_systemMessagePush: 'manage/messageRecord/systemMessagePush',185 // è·ååé¦è¯¦æ
186 manage_feedBack_detail: 'manage/feedBack/detail',187 // ******广å******188 // 广åç¼è¾189 manage_advertise_update: 'manage/advertise/update',190 // 广åå¯ç¨/åç¨191 manage_advertise_change: 'manage/advertise/change',192 // 广åå表193 manage_advertise_list: 'manage/advertise/list',194 // 广åæ·»å 195 manage_advertise_add: 'manage/advertise/add',196 // 广åå é¤197 manage_advertise_delete: 'manage/advertise/delete',198 // è·ååæ¡è¯¦ç»æ°æ®199 manage_advertise_selectOne: 'manage/advertise/selectOne',200 // ******æ¥å¿******201 // appç¨æ·æä½æ¥å¿å表202 manage_log_app_list: 'manage/log/app/list',203 // ç¨æ·æä½æ¥å¿è¯¦æ
204 manage_log_app_detail: 'manage/log/app/detail',205 // 管çåå°æä½æ¥å¿å表206 manage_log_list: 'manage/log/list',207 // 管çåå°ææ¥å¿è¯¦æ
208 manage_log_detail: 'manage/log/detail',209 // æ
éæ¥å¿210 manage_breakdown_getBreakdownRecordList: 'manage/breakdown/getBreakdownRecordList',211 // æ
éæ¥å¿å é¤212 manage_breakdown_deleteHistoryDeviceError: 'manage/breakdown/deleteHistoryDeviceError',213 // ******æµéå¡******214 // æµéå¡å表215 manage_simCard_getSimCardList: 'manage/simCard/getSimCardList',216 // æµéå¡å表V2217 manage_simCard_getSimCardV2List: 'manage/simCard/getSimCardV2List',218 // æµéå¡å表V2219 manage_v2_simCard_getSimCardList: '/manage/v2/simCard/getSimCardList',220 // æµéå¡è¯¦æ
221 manage_simCard_getSimCardInfo: 'manage/simCard/getSimCardInfo',222 // åç¨å¯ç¨223 manage_simCard_closeSimCardGPRS: 'manage/simCard/closeSimCardGPRS',224 // åæºå¤æº225 manage_simCard_shutAndResetSimCard: 'manage/simCard/shutAndResetSimCard',226 // æ¥è¯¢ç©èç½å¡å¥é¤å表227 manage_v2_simCard_getPackageList: 'manage/v2/simCard/getPackageList',228 // æ¥è¯¢ç©èç½å¡å¥é¤è¯¦æ
229 manage_simCard_getGPGSPackageInfo: 'manage/simCard/getGPGSPackageInfo',230 // è·åæä½è®°å½231 manage_simOperateRecord_getSimOperateRecordList: 'manage/simOperateRecord/getSimOperateRecordList',232 // è·åæµéæ± æ°æ®233 manage_v2_simCard_getGroupFlowPool: 'manage/v2/simCard/getGroupFlowPool',234 // å·æ°æµéæ°æ®235 manage_v2_simCard_refresh: 'manage/v2/simCard/refresh',236 // è·åsimå¡237 manage_v2_simCard_getSimCardInfo: 'manage/v2/simCard/getSimCardInfo',238 // è·åå¥é¤ä¿¡æ¯239 manage_v2_simCard_getPackageInfo: 'manage/v2/simCard/getPackageInfo',240 // simå¡è¿å
ææµéèµ°å¿241 manage_v2_simCard_getSimCardRecentFlowCount: 'manage/v2/simCard/getSimCardRecentFlowCount',242 // åæº243 manage_v2_simCard_closeSim: 'manage/v2/simCard/closeSim',244 // å¤æº245 manage_v2_simCard_openSim: 'manage/v2/simCard/openSim',246 // åå°å¼å§å¯¼åºæ°æ®247 manage_exportSim: 'manage/v2/simCard/exportSim',248 // çæµåå°æ°æ®å¯¼åºè¿åº¦249 manage_progress: 'manage/v2/simCard/export/progress',250 // ******å
Œ
±é¨å******251 // 产åå表252 common_getProductName_list: 'common/getProductName/list',253 // æ
éå称å表 ä¸ææ¡254 common_getErrorName_list: 'common/getErrorName/list',255 // 管çåä¿®æ¹å¯ç 256 account_change_password: 'account/change/password',257 // 管çåç»é258 account_login: 'account/login',259 // 管çåç»åº260 account_logout: 'account/logout',261 // è·åéªè¯ç å¾ç262 common_code_getCheckCode: 'common/code/getCheckCode',263 // å¾çä¸ä¼ æ¥å£264 common_uploadImg: 'common/uploadImg',265 // æ¹éæä½266 getBatchOperateConfigPage: "manage/batch/operate/config/getBatchOperateConfigPage",267 // ä¿åæ¹éæä½é
ç½®268 saveBatchOperateConfig: 'manage/batch/operate/config/saveBatchOperateConfig',269 // ç¦ç¨æä½270 batch_operate_config_forbidden: 'manage/batch/operate/config/forbidden',271 // è·åæ¹éæä½è¯¦æ
272 getBatchOperateConfigInfo: "manage/batch/operate/config/getBatchOperateConfigInfo",273 // å é¤æ¹éæä½274 batch_operate_config_delete: 'manage/batch/operate/config/delete',275 // æ ¹æ®äº§åè·åæ¹éæä½å表276 getProductBatchOperateList: 'manage/product/operate/config/getProductBatchOperateList',277 // è·å产åå·²ç»é
ç½®çæ¹éæä½278 getBatchOperateConfigByPK: 'manage/batch/operate/config/getBatchOperateConfigByPK',279 // ä¿å产åé
ç½®çæ¹éæä½280 saveProductBatchOperate: 'manage/product/operate/config/saveProductBatchOperate',281 // ä¿åç³»ç»ç»´æ¤ä¿¡æ¯282 saveSystemMaintainConfig: 'manage/maintain/saveSystemMaintainConfig',283 // è·åå·²åéçç³»ç»ç»´æ¤æ¶æ¯å
容284 getSystemMaintainConfigInfo: 'manage/maintain/getSystemMaintainConfigInfo',...
deviceInfoList.js
Source:deviceInfoList.js
1jQuery(function($) {2 $("#submenu-menu-device-info").addClass("active");3 $("#menu-device").addClass("active");4 $("#menu-device").addClass("open");5 initOrgTree();6 $("#searchGoodsBtn").click(function () {7 searchDevice();8 });9 $("#keyword").keyup(function () {10 oTable.fnDraw();11 });12 13// $('#deviceInfo_list tbody').on('click','tr td:nth-child(3)', function (e) {14// var name = $(this).text();15// alert(name);16// } );17});18oTable = null;19function initTable() {20 if(oTable == null) {21 oTable = $("#deviceInfo_list").dataTable({22 "bAutoWidth":false,23 "bLengthChange" :false,24 "bProcessing": false,25 "bInfo": true,26 "bFilter" : false,// æç´¢æ 27 "bServerSide" : true,//å¼æ¥è¯·æ±å¿
须设置 28 "sAjaxSource": ROOT_PATH +"/view/device/deviceInfo/queryDeviceInfo.action", //å¼æ¥è¯·æ±å°å29 "aoColumns" : [ 30 {"mDataProp":"deviceNo","sClass":"center"},31 {"mDataProp":"deviceName","sClass":"center"},32 {"mDataProp":"deviceTypeName","sClass":"center"},33 {"mDataProp":"deviceAddress","sClass":"left"},34 {"mDataProp":"createDate","sClass":"center"},35 {"mDataProp":"deviceStatus","sClass":"center", "mRender": function (data, type, full) {36 var deviceStatus = '';37 if (data == '1') {38 deviceStatus = '<input title="å¯ç¨" class="ace ace-switch ace-switch-6" type="checkbox" onclick="changeStatus(this,'+full.deviceId+')" checked/><span class="lbl"></span>';39 }40 else if (data == '0' || data == '2' || data == '3') {41 deviceStatus = '<input title="ç¦ç¨" class="ace ace-switch ace-switch-6" type="checkbox" onclick="changeStatus(this,'+full.deviceId+')" /><span class="lbl"></span>';42 }43 return deviceStatus;44 }},45 {"sDefaultContent": "","sClass":"center","mRender": function(data, type, full) { 46 var actionDiv = '';47 actionDiv = '<div class="hidden-sm hidden-xs btn-group">'+48 '<a class="tooltip-info" data-rel="tooltip" title="ç»´ä¿®">'+49 '<button class="btn btn-xs btn-info" onclick="deviceMaintenance(\'' + full.deviceId + '\')" >ç»´ä¿®</button>'+50 '</a> '+51 '<a class="tooltip-info" data-rel="tooltip" title="æ¸
æ´">'+52 '<button class="btn btn-xs btn-info" onclick="deviceClean(\'' + full.deviceId + '\')" >æ¸
æ´</button>'+53 '</a> '+54 '<a class="tooltip-info" data-rel="tooltip" title="éå®" onclick="sell(\'' + full.deviceId + '\')">'+55 '<button class="btn btn-xs btn-info">éå®</button>'+56 '</a>';57 58 actionDiv += '</div>';59 return actionDiv;60 }},61 {"sDefaultContent": "","sClass":"center","mRender": function(data, type, full) { 62 var actionDiv = '';63 actionDiv = '<div class="hidden-sm hidden-xs btn-group">'+64 '<button onclick="deviceDtl(\'' + full.deviceId + '\')" class="btn btn-xs btn-success"><i class="ace-icon fa fa-search-plus bigger-120"></i></button>' +65 '<button class="btn btn-xs btn-info" onclick="modifyDeviceInfo(\'' + full.deviceId + '\')"><i class="ace-icon fa fa-pencil bigger-120"></i></button>'+66 '<button class="btn btn-xs btn-danger" onclick="deleteDeviceInfo(\'' + full.deviceId + '\')"><i class="ace-icon fa fa-trash-o bigger-120"></i></button>';67 actionDiv += '</div>';68 return actionDiv;69 }}70 ],71 "oLanguage": {72 "sProcessing": "æ£å¨å è½½ä¸......",73 "sLengthMenu": "æ¯é¡µæ¾ç¤º _MENU_ æ¡è®°å½",74 "sZeroRecords": "没ææ°æ®ï¼",75 "sEmptyTable": "表ä¸æ æ°æ®åå¨ï¼",76 "sInfo": "å½åæ¾ç¤º _START_ å° _END_ æ¡ï¼å
± _TOTAL_ æ¡è®°å½",77 "sInfoEmpty": "æ¾ç¤º0å°0æ¡è®°å½",78 "sInfoFiltered": "æ°æ®è¡¨ä¸å
±ä¸º _MAX_ æ¡è®°å½",79 zeroRecords: "没æå
容",80 "sSearch": "æç´¢",81 "oPaginate": {82 "sFirst": "é¦é¡µ",83 "sPrevious": "ä¸ä¸é¡µ",84 "sNext": "ä¸ä¸é¡µ",85 "sLast": "æ«é¡µ"86 }87 },88 "aoColumnDefs": [//åaoColums类似ï¼ä½ä»å¯ä»¥ç»æå®åéè¿ç±å±æ§89 {90 sDefaultContent: '',91 aTargets: [ '_all' ]92 },93 {"bSortable": false, "aTargets": [0, 1, 2, 3, 4, 5, 6,7]}, //è¿å¥è¯æææ¯ç¬¬1,3,6,7,8,9åï¼ä»0å¼å§ç®ï¼ ä¸è½æåº94 95 {"aTargets":[0],"mRender":function(data,type,full){96 return "<a onclick='deviceMapInfo(\"" + full.deviceId + "\")'>" + data + "</a>"}97 }98 ],99 "fnServerData": retrieveData,100 101 });102 } else {103 oTable.fnDraw(); //éæ°å è½½æ°æ®104 }105}106/**107* sSource æ¥è¯¢é¾æ¥108* aoData åæ°109* fnCallback è¿åæ°æ®å¡«å
æ¹æ³110*/111function retrieveData(sSource, aoData, fnCallback) { 112 //ååå称æç¼å·113 var keyword = $("#keyword").val();114 //ååç¶æ115 var deviceStatus = $("#status_sele").val();116 var param = {"keyword": keyword};117 param.deviceStatus = deviceStatus;118 var selectNodes = $.fn.zTree.getZTreeObj("org_tree");119 if(selectNodes!=null){120 if(selectNodes.getSelectedNodes() != ""){121 var id=selectNodes.getSelectedNodes()[0].id; 122 var pid=selectNodes.getSelectedNodes()[0].pid; 123 var level = selectNodes.getSelectedNodes()[0].level;124 param.id = id;125 param.pid = pid;126 param.level = level;127 } 128 } 129 for(var i = 0;i < aoData.length;i++) {130 var _aoData = aoData[i];131 if(_aoData.name == "iDisplayStart") {132 /*å¼å§é¡µæ°*/133 param.iDisplayStart = _aoData.value;134 }else if(_aoData.name == "iDisplayLength"){135 /*è®°å½æ¡æ°*/136 param.iDisplayLength = _aoData.value;137 }else if(_aoData.name == "sEcho"){138 /*æä½æ¬¡æ°*/139 param.sEcho = _aoData.value;140 }141 }142 //æ交访é®143 $.ajax( { 144 type: "POST", 145 url: sSource, 146 dataType: "json", 147 data: param, // 以jsonæ ¼å¼ä¼ é 148 success: function(resp) {149 fnCallback(resp);150// removeMask($('.goods-container'));151 } 152 }); 153}154//æç´¢åå155function searchDevice() {156 if(oTable){157 oTable.fnDraw();158 }159}160function modifyDeviceInfo(id){161 window.location.href = ROOT_PATH +"/view/device/deviceInfo/addOrModifyDeviceInfo.action?deviceId="+id;162}163function deleteDeviceInfo(id){164 var isAdmin = $("#isAdmin").val();165 alert(isAdmin);166 if(isAdmin != null && isAdmin == '1'){167 if (confirm("ç¡®å®å é¤æ¤æ¡è®¾å¤ä¿¡æ¯å?")) {168 window.location.href = ROOT_PATH +"/view/device/deviceInfo/delDeviceById.action?deviceId="+id;169 }170 }171 else{172 alert("æ¨æ²¡ææéå é¤è¯¥è®¾å¤ï¼");173 }174 175}176function add(id){177 window.location.href = ROOT_PATH +"/view/device/deviceInfo/addOrModifyDeviceInfo.action?deviceId="+id;178}179function deviceMaintenance(id){180 var url = ROOT_PATH +"/view/device/deviceMain/queryDeviceMaintenance.action?deviceId="+id;181 window.location.href = url;182}183function deviceClean(id){184 window.location.href = ROOT_PATH +"/view/device/deviceClean/queryDeviceCleanList.action?deviceId="+id;185}186function sell(id){187 //window.location.href = ROOT_PATH +"/view/device/deviceInfo/deviceMap.action?deviceId="+id;188}189function deviceMapInfo(id){190 window.location.href = ROOT_PATH +"/view/device/deviceInfo/deviceMap.action?deviceId="+id;191}192function allDeviceMap(){193 $.ajax({194 url: ROOT_PATH + '/view/device/deviceInfo/checkDevice.action',195 type:'POST',196 dataType:'json',197 success:function(data){ 198 if(data){199 window.location.href = ROOT_PATH +"/view/device/deviceInfo/queryAllDevice.action";200 }201 else{202 alert("请添å 设å¤ï¼");203 }204 }205 });206}207function carMap(){208 window.location.href = ROOT_PATH +"/view/device/testMap.jsp";209}210//设å¤è¯¦æ
211function deviceDtl(id){212 window.location.href = ROOT_PATH +"/view/device/deviceInfo/queryDeviceById.action?deviceId="+id;213}214/**215 * å¯ç¨ç¦æ¢216 * @param deviceId 设å¤ID217 */218function changeStatus(checkbox,deviceId) {219 if(deviceId){220 var isDisable = null;221 if($(checkbox).prop("checked")) {222 isDisable = '1';223 } else {224 isDisable = '0';225 }226 $.ajax({227 type : "POST",228 url : ROOT_PATH + "/view/device/deviceInfo/changeDeviceStatus.action",229 data : { "deviceId" : deviceId,"isDisable":isDisable}, 230 success : function(data) {231 if(!data) {232 alert("ç³»ç»é误ï¼è¯·è系管çå!");233 }234 //initTable();235 }236 });237 }238}239//åå§åæºææ 240function initOrgTree() {241 var setting = {242 data: {243 simpleData: {244 enable: true245 }246 },247 callback: {248 onClick: function(){249 searchDevice();250 }251 }252 };253 var treeObj = $("#org_tree");254 var zNodes;255 $.ajax({256 url: ROOT_PATH + '/view/inventory/warehouse/getMulSubDictDataByPcode.action',257 type:'POST',258 data:{"dictPcode" : "AL_POSITION" ,"dictLevel":"5"},259 dataType:'json',260 success:function(data){261 zNodes = data;262 $.fn.zTree.init($("#org_tree"), setting, zNodes);263 }264 });265 treeObj.hover(function () {266 if (!treeObj.hasClass("showIcon")) {267 treeObj.addClass("showIcon");268 }269 }, function() {270 treeObj.removeClass("showIcon");271 });272 initTable();273}274function showMenu() {275 var gtObj = $("#dict_provice_id");276 //alert(gtObj);277 if($("#gt_combobox").css("display") == "none"){278 var gtOffset = $("#dict_provice_id").offset();279 $("#gt_combobox").css({width:gtObj.css("width"),left:gtOffset.left + "px", top:gtOffset.top + gtObj.outerHeight() + "px"}).slideDown("fast");280 }281 $("body").bind("mousedown", onBodyDown);282}283function hideMenu() {284 $("#gt_combobox").fadeOut("fast");285 $("body").unbind("mousedown", onBodyDown);286}287function onBodyDown(event) {288 if (!(event.target.id == "menuBtn" || event.target.id == "gt_combobox" || $(event.target).parents("#gt_combobox").length>0)) {289 hideMenu();290 }291}292function show(){293 var selectNodes = $.fn.zTree.getZTreeObj("org_tree").getSelectedNodes();...
deviceCleanList.js
Source:deviceCleanList.js
1jQuery(function($) {2 $("#submenu-menu-device-clean").addClass("active");3 $("#menu-device").addClass("active");4 $("#menu-device").addClass("open");5 6 initTable();7 $("#keyword").keyup(function () {8 initTable();9 });10 11 $("#dp_quoteStartDate").datetimepicker({12 minView: "month",13 format: 'yyyy-mm-dd',14 language: 'zh-CN',15 weekStart: 1,16 todayBtn: 1,17 autoclose: true,18 todayHighlight: 1,19 startView: 2,20 minView: 2,21 forceParse: 022 });23 24 $("#dp_quoteEndDate").datetimepicker({25 minView: "month",26 format: 'yyyy-mm-dd',27 language: 'zh-CN',28 weekStart: 1,29 todayBtn: 1,30 autoclose: true,31 todayHighlight: 1,32 startView: 2,33 minView: 2,34 forceParse: 035 });36});37oTable = null;38function initTable() {39 var deviceId = $("#deviceId").val();40 if(oTable == null) {41 oTable = $("#deviceClean_list").dataTable({42 "bAutoWidth":false,43 "bLengthChange" :false,44 "bProcessing": false,45 "bFilter" : false,// æç´¢æ 46 "bServerSide" : true,//å¼æ¥è¯·æ±å¿
须设置 47 "sAjaxSource": ROOT_PATH +"/view/device/deviceClean/queryDeviceClean.action?deviceId="+deviceId, //å¼æ¥è¯·æ±å°å48 "aoColumns" : [ 49 {"mDataProp":"cleanNo","sClass":"center"},50 {"mDataProp":"deviceInfo.deviceNo","sClass":"center"},51 {"mDataProp":"deviceInfo.deviceName","sClass":"center"},52 {"mDataProp":"deviceInfo.deviceType.deviceTypeName","sClass":"center"},53 {"mDataProp":"cleanEndTiem","sClass":"center"},54 {"mDataProp":"finishTime","sClass":"center"},55 {"mDataProp":"cleanDate","sClass":"center"},56 {"mDataProp":"sysUser.realName","sClass":"center"},57 {"mDataProp":"cleanStatus","sClass":"center" ,"mRender": function (data, type, full) {58 var cleanStatus = '';59 if (data == '0') {60 cleanStatus = '<span class="lbl">å®æ</span>';61 62 }63 else if (data == '1') {64 cleanStatus = '<span class="lbl">æªå®æ</span>';65 }66 return cleanStatus;67 }},68// {"mDataProp":"cleanStatus","sClass":"center" ,"mRender": function (data, type, full) {69// var cleanStatus = '';70// if (data == '0') {71// cleanStatus = '<input title="å®æ" class="ace ace-switch ace-switch-6" type="checkbox" onclick="changeStatus(this,'+full.cleanId+')" checked /><span class="lbl"></span>';72// 73// }74// else if (data == '1') {75// cleanStatus = '<input title="æªå®æ" class="ace ace-switch ace-switch-6" type="checkbox" onclick="changeStatus(this,'+full.cleanId+')" /><span class="lbl"></span>';76// }77// return cleanStatus;78// }},79 {"sDefaultContent": "","sClass":"center","mRender": function(data, type, full) { 80 var actionDiv = '';81 actionDiv = '<div class="hidden-sm hidden-xs btn-group">'+82 '<button class="btn btn-xs btn-success" onclick="deviceCleanDtl(\'' + full.cleanId + '\')"><i class="ace-icon fa fa-search-plus bigger-120"></i></button>' +83 '<button class="btn btn-xs btn-danger" onclick="deleteType(\'' + full.cleanId + '\')"><i class="ace-icon fa fa-trash-o bigger-120"></i></button>';84 actionDiv += '</div>';85 return actionDiv;86 }}87 ],88 "oLanguage": {89 "sProcessing": "æ£å¨å è½½ä¸......",90 "sLengthMenu": "æ¯é¡µæ¾ç¤º _MENU_ æ¡è®°å½",91 "sZeroRecords": "没ææ°æ®ï¼",92 "sEmptyTable": "表ä¸æ æ°æ®åå¨ï¼",93 "sInfo": "å½åæ¾ç¤º _START_ å° _END_ æ¡ï¼å
± _TOTAL_ æ¡è®°å½",94 "sInfoEmpty": "æ¾ç¤º0å°0æ¡è®°å½",95 "sInfoFiltered": "æ°æ®è¡¨ä¸å
±ä¸º _MAX_ æ¡è®°å½",96 zeroRecords: "没æå
容",97 "sSearch": "æç´¢",98 "oPaginate": {99 "sFirst": "é¦é¡µ",100 "sPrevious": "ä¸ä¸é¡µ",101 "sNext": "ä¸ä¸é¡µ",102 "sLast": "æ«é¡µ"103 }104 },105 "aoColumnDefs": [//åaoColums类似ï¼ä½ä»å¯ä»¥ç»æå®åéè¿ç±å±æ§106 {"bSortable": false, "aTargets": [0, 1, 2, 3, 4, 5, 6 ,7 ,8 ,9]} //è¿å¥è¯æææ¯ç¬¬1,3,6,7,8,9åï¼ä»0å¼å§ç®ï¼ ä¸è½æåº107 ],108 "fnServerData": retrieveData,109 110 });111 } else {112 oTable.fnDraw(); //éæ°å è½½æ°æ®113 }114}115/**116* sSource æ¥è¯¢é¾æ¥117* aoData åæ°118* fnCallback è¿åæ°æ®å¡«å
æ¹æ³119*/120function retrieveData(sSource, aoData, fnCallback) { 121 //ååå称æç¼å·122 var keyword = $("#keyword").val();123 124 //ææèµ·å§æ¥æ125 var startDate = $("#dp_quoteStartDate").val();126 //ææç»æ¢æ¥æ127 var endDate = $("#dp_quoteEndDate").val();128 var deviceId = $("#deviceId").val(); 129 var param = {130 "keyword":keyword,131 "deviceId" : deviceId,132 "startDate":startDate,133 "endDate":endDate134 };135 for(var i = 0;i < aoData.length;i++) {136 var _aoData = aoData[i];137 if(_aoData.name == "iDisplayStart") {138 /*å¼å§é¡µæ°*/139 param.iDisplayStart = _aoData.value;140 }else if(_aoData.name == "iDisplayLength"){141 /*è®°å½æ¡æ°*/142 param.iDisplayLength = _aoData.value;143 }else if(_aoData.name == "sEcho"){144 /*æä½æ¬¡æ°*/145 param.sEcho = _aoData.value;146 }147 }148 //æ交访é®149 $.ajax( { 150 type: "POST", 151 url: sSource, 152 dataType: "json", 153 data: param, // 以jsonæ ¼å¼ä¼ é 154 success: function(resp) {155 fnCallback(resp);156// removeMask($('.goods-container'));157 } 158 }); 159}160//æç´¢åå161function searchGoods() {162 if(oTable){163 oTable.fnDraw();164 }165}166/**167 * 设å¤æ¸
æ´æ¯å¦å®æ168 * @param checkbox169 * @param deviceId170 */171function changeStatus(checkbox,cleanId) {172 if(cleanId){173 var isDisable = null;174 if($(checkbox).prop("checked")) {175 isDisable = '0';176 } else {177 isDisable = '1';178 }179 $.ajax({180 type : "POST",181 url : ROOT_PATH + "/view/device/deviceClean/changeCleanStatus.action",182 data : { "cleanId" : cleanId,"isDisable":isDisable}, 183 success : function(data) {184 if(!data) {185 alert("ç³»ç»é误ï¼è¯·è系管çå!");186 }187 initTable();188 }189 });190 }191}192function deleteType(id){193 if (confirm("ç¡®å®å é¤æ¤æ¡è®¾å¤æ¸
æ´ä¿¡æ¯å?")) {194 window.location.href = ROOT_PATH +"/view/device/deviceClean/delDeviceCleanById.action?cleanId="+id;195 }196}197function deviceCleanDtl(cleanId){198 window.location.href = ROOT_PATH +"/view/device/deviceClean/deviceCleanDtl.action?cleanId="+cleanId;199}200function add(){201 window.location.href = ROOT_PATH +"/view/device/deviceClean/addOrModifyDeviceClean.action?cleanId=add";202}203function dateFind(){204 if($("#dp_quoteStartDate").val() != "" && $("#dp_quoteEndDate").val() != ""){205 initTable();206 }207}208function quickSearch(type) {209 var startDate = "";210 var endDate = "";211 if (type == 1) { //æ¬å¨212 startDate = DateUtil.dateToStr('yyyy-MM-dd', DateUtil.weekStartDate());213 endDate = DateUtil.dateToStr('yyyy-MM-dd', DateUtil.weekEndDate());214 } else if (type == 2) { //ä¸å¨215 startDate = DateUtil.dateToStr('yyyy-MM-dd', DateUtil.lastWeekStartDate());216 endDate = DateUtil.dateToStr('yyyy-MM-dd', DateUtil.lastWeekEndDate());217 } else if (type == 3) { //æ¬æ218 startDate = DateUtil.dateToStr('yyyy-MM-dd', DateUtil.monthStartDate());219 endDate = DateUtil.dateToStr('yyyy-MM-dd', DateUtil.monthEndDate());220 } else if (type == 4) { //ä¸æ221 startDate = DateUtil.dateToStr('yyyy-MM-dd', DateUtil.lastMonthStartDate());222 endDate = DateUtil.dateToStr('yyyy-MM-dd', DateUtil.lastMonthEndDate());223 }224 $("#dp_quoteStartDate").val(startDate);225 $("#dp_quoteEndDate").val(endDate);226 initTable();...
yubikey.js
Source:yubikey.js
1var webusb = {};2var lightsParent;3const REPORT_TYPE_FEATURE = 0x034const REPORT_TYPE_SIZE = 85const HID_GET_REPORT = 16const HMAC_CHALRESP_SLOT2 = 0x387const SLOT_WRITE_FLAG = 0x80 // send by the host, cleared by the device8const RESP_PENDING_FLAG = 0x40 /* Response pending flag */ 9const SHA1_HASH_LENGTH = 4010function sleep(ms) {11 return new Promise(resolve => setTimeout(resolve, ms));12}13function str2ab(str) {14 var buf = new Array(64); 15 for (var i=0, strLen=str.length; i<strLen; i++) {16 buf[i] = str.charCodeAt(i) & 0xFF;17 }18 for (var i = str.length; i < 64; i++) {19 buf[i] = 0;20 }21 return buf;22}23function yk_endian_swap_16(x) {24 console.log("Big endian is not supported, so this function is a NO-OP");25 return x;26}27function _create_report_size_message() {28 return {29 recipient: "interface",30 requestType: "class",31 request: HID_GET_REPORT,32 value: REPORT_TYPE_FEATURE << 8,33 index: 0,34 length: REPORT_TYPE_SIZE,35 timeout: 100036 }37}38function _wait_for_key_status(device, boolean_and, flag, sleeptime) {39 return new Promise(async function(resolve, reject) {40 await sleep(sleeptime);41 device.controlTransferIn(_create_report_size_message(), REPORT_TYPE_SIZE)42 .then(data => {43 var status_flag = data.data.getUint8(data.data.byteLength -1);44 if ((status_flag & flag) == boolean_and) {45 resolve(data.data);46 } else {47 _wait_for_key_status(device, boolean_and, flag)48 .then((wanted_data) => {resolve(wanted_data)});49 }50 });51 });52}53function _read_hash_from_key(device, acc) {54 return new Promise(function(resolve, reject) {55 result = acc56 _wait_for_key_status(device, RESP_PENDING_FLAG, RESP_PENDING_FLAG, 100)57 .then(data => {58 for (var i = 0; i < data.byteLength -1; i++)59 result += data.getUint8(i).toString(16);60 if (result.length > SHA1_HASH_LENGTH) {61 resolve(result);62 return 63 } 64 return _read_hash_from_key(device, result)65 .then((final_result) => resolve(final_result));66 });67 });68}69function yubikey_crc16 (buf) {70 var m_crc = 0xffff;71 buf.forEach(function (value, index) {72 var i, j;73 m_crc ^= value & 0xFF;74 for (i = 0; i < 8; i++) {75 j = m_crc & 1;76 m_crc >>= 1;77 if (j)78 m_crc ^= 0x8408;79 }80 m_crc &= 0xFFFF;81 });82 return m_crc;83}84function chunk_buffer(data) {85 // slice the data on nine different chunks86 var data_chunks = [];87 var start, end;88 for (var i = 0; i < 9; i ++) {89 start = i * 7;90 end = (i + 1) * 7;91 thischunk = data.slice(start, end);92 if (thischunk.reduce((acc, value) => {return acc += value}) == 0) {93 continue; // this was all zero's, no need to send this chunk94 }95 thischunk.push(SLOT_WRITE_FLAG | (i & 0x0F));96 data_chunks.push(thischunk);97 }98 // now we prepare the header.99 header = new Array(8); 100 crc = yubikey_crc16(data);101 header[0] = 0;102 // we could probably make this work using a toggle in the interface103 header[1] = HMAC_CHALRESP_SLOT2;104 header[2] = crc & 0xff;105 header[3] = (crc & 0xff00) >> 8;106 header[4] = 0107 header[5] = 0108 header[6] = 0109 header[7] = SLOT_WRITE_FLAG | (i & 0x0F);110 data_chunks.push(header);111 result = []112 data_chunks.forEach((value, i) => {113 arrayChunk = new Uint8Array(8);114 value.forEach((value, i) => {115 arrayChunk[i] = value;116 })117 result.push(arrayChunk);118 });119 return result;120}121(function() {122 'use strict';123 webusb.devices = {};124 function findOrCreateDevice(rawDevice) {125 let device = webusb.getDevice(rawDevice);126 if (device === undefined)127 device = new webusb.Device(rawDevice);128 return device;129 }130 webusb.getDevices = function() {131 return navigator.usb.getDevices().then(devices => {132 return devices.map(device => findOrCreateDevice(device));133 });134 };135 webusb.requestDevice = function() {136 var filters = [137 { vendorId: 0x1050, productId: 0x0111 }138 ];139 return navigator.usb.requestDevice({filters: filters}).then(device => {140 return findOrCreateDevice(device);141 });142 };143 webusb.Device = function(device) {144 this.device_ = device;145 webusb.devices[device.serialNumber] = this;146 };147 webusb.deleteDevice = function(device) {148 delete webusb.devices[device.device_.serialNumber];149 };150 webusb.getDevice = function(device) {151 return webusb.devices[device.serialNumber];152 };153 webusb.Device.prototype.connect = function() {154 return this.device_.open()155 .then(() => {156 if (this.device_.configuration === null) {157 return this.device_.selectConfiguration(1);158 }159 })160 .then(() => this.device_.claimInterface(0));161 };162 webusb.Device.prototype.disconnect = function() {163 return this.device_.close();164 };165 webusb.Device.prototype.controlTransferOut = function(setup, data) {166 return this.device_.controlTransferOut(setup, data);167 };168 webusb.Device.prototype.controlTransferIn = function(setup, length) {169 return this.device_.controlTransferIn(setup, length);170 };171 webusb.Device.prototype.challengeResponse = function (challenge) {172 var challenge_buffer = str2ab(challenge);173 var data_chunks = chunk_buffer(challenge_buffer);174 var thispromise;175 data_chunks.reduce((acc, value) => {176 return acc.then(() => {return _wait_for_key_status(this.device_, 0, SLOT_WRITE_FLAG, 200)})177 .then((ayylmao) => {this.controlTransferOut(this._prepare_transfer_info(), 178 value)});179 }, this.connect())180 .then(() => {return _read_hash_from_key(this.device_, "")})181 .then((hash) => {hash = hash.slice(0, SHA1_HASH_LENGTH);182 document.getElementById("response-field").value = hash;})183 .then(() => {this.disconnect();});184 }185 webusb.Device.prototype._prepare_transfer_info = function(data) {186 return {187 recipient: "interface",188 requestType: "class",189 request: 9,190 value: 0x0300,191 index: 0,192 }193 };194})();195function logDeviceStrings(device) {196 console.log("Connection:",197 device.device_.manufacturerName,198 device.device_.productName,199 device.device_.serialNumber);200}201function setElementDeviceInfo(e, text) {202 //e.getElementsByClassName("lightTitle")[0].innerText = text;203}204function connectDevice(device) {205 var e = document.getElementById("lightCardTemplate");206 e.style.display = "block";207 device.element = e;208 var s = device.device_.productName + "\n" +209 device.device_.serialNumber;210 setElementDeviceInfo(device.element, s);211 var sendButton = document.getElementById("send-challenge");212 sendButton.addEventListener('click', challengeResponse.bind(this, device));213}214function handleConnectEvent(event) {215 var rawDevice = event.device;216 console.log('connect event', rawDevice);217 var device = new webusb.Device(rawDevice);218 connectDevice(device);219}220function cleanUpDevice(device) {221 clearInterval(device.intervalId);222 webusb.deleteDevice(device);223}224function disconnectDevice(rawDevice) {225 var device = webusb.getDevice(rawDevice);226 if (device) { // This can fail if the I/O code already threw an exception227 console.log("removing!");228 lightsParent.removeChild(device.element);229 device.disconnect()230 .then(s => {231 console.log("disconnected", device);232 cleanUpDevice(device);233 }, e => {234 console.log("nothing to disconnect", device);235 cleanUpDevice(device);236 });237 }238}239function handleDisconnectEvent(event) {240 console.log('disconnect event', event.device);241 disconnectDevice(event.device);242}243function registerEventListeners() {244 navigator.usb.addEventListener('connect', handleConnectEvent);245 navigator.usb.addEventListener('disconnect', handleDisconnectEvent);246}247function startInitialConnections() {248 webusb.getDevices().then(devices => {249 for (var i in devices) {250 var device = devices[i];251 connectDevice(device);252 }253 });254}255function requestConnection(event) {256 webusb.requestDevice().then(device => {257 console.log(device);258 connectDevice(device);259 });260 event.preventDefault();261}262function challengeResponse(device) {263 var challenge = document.getElementById("challenge-field").value264 response = device.challengeResponse(challenge);265 document.getElementById("response-field").innerHTML = response;266}267function start() {268 registerEventListeners();269 var lightsConnect = document.getElementById("lightConnect");270 lightsConnect.addEventListener("click", requestConnection);271 lightsParent = document.getElementById("lightsParent");272 startInitialConnections();273}...
EventStoreService.js
Source:EventStoreService.js
1const Rx = require('rxjs');2const device = require('../../domain/Device')();3const eventSourcing = require('../../tools/EventSourcing')();4const mbeKey = "ms-devices-location_mbe_devices-location";5/**6 * Singleton instance7 */8let instance;9class EventStoreService {10 constructor() {11 this.functionMap = this.generateFunctionMap();12 this.subscriptions = [];13 this.aggregateEventsArray = this.generateAggregateEventsArray();14 }15 /**16 * Starts listening to the EventStore17 * Returns observable that resolves to each subscribe agregate/event18 * emit value: { aggregateType, eventType, handlerName}19 */20 start$() {21 //default error handler22 const onErrorHandler = (error) => {23 console.error('Error handling EventStore incoming event', error);24 process.exit(1);25 };26 //default onComplete handler27 const onCompleteHandler = () => {28 () => console.log('EventStore incoming event subscription completed');29 }30 return Rx.Observable.from(this.aggregateEventsArray)31 .map(aggregateEvent => ({ ...aggregateEvent, onErrorHandler, onCompleteHandler }))32 .map(params => this.subscribeEventHandler(params));33 }34 /**35 * Stops listening to the Event store36 * Returns observable that resolves to each unsubscribed subscription as string 37 */38 stop$() {39 return Rx.Observable.from(this.subscriptions)40 .map(subscription => {41 subscription.subscription.unsubscribe();42 return `Unsubscribed: aggregateType=${aggregateType}, eventType=${eventType}, handlerName=${handlerName}`;43 })44 }45/**46 * Create a subscrition to the event store and returns the subscription info 47 * @param {{aggregateType, eventType, onErrorHandler, onCompleteHandler}} params48 * @return { aggregateType, eventType, handlerName }49 */50 subscribeEventHandler({ aggregateType, eventType, onErrorHandler, onCompleteHandler }) {51 const handler = this.functionMap[eventType];52 const subscription =53 //MANDATORY: AVOIDS ACK REGISTRY DUPLICATIONS54 eventSourcing.eventStore.ensureAcknowledgeRegistry$(aggregateType)55 .mergeMap(() => eventSourcing.eventStore.getEventListener$(aggregateType,mbeKey))56 .filter(evt => evt.et === eventType)57 .mergeMap(evt => Rx.Observable.concat(58 handler.fn.call(handler.obj, evt),59 //MANDATORY: ACKWOWLEDGE THIS EVENT WAS PROCESSED60 eventSourcing.eventStore.acknowledgeEvent$(evt, mbeKey),61 ))62 .subscribe(63 (evt) => {64 //console.log(`EventStoreService: ${eventType} process: ${JSON.stringify(evt)}`);65 },66 onErrorHandler,67 onCompleteHandler68 );69 this.subscriptions.push({ aggregateType, eventType, handlerName: handler.fn.name, subscription });70 return { aggregateType, eventType, handlerName: `${handler.obj.name}.${handler.fn.name}` };71 }72 /**73 * Starts listening to the EventStore74 * Returns observable that resolves to each subscribe agregate/event75 * emit value: { aggregateType, eventType, handlerName}76 */77 syncState$() {78 return Rx.Observable.from(this.aggregateEventsArray)79 .concatMap(params => this.subscribeEventRetrieval$(params))80 }81 /**82 * Create a subscrition to the event store and returns the subscription info 83 * @param {{aggregateType, eventType, onErrorHandler, onCompleteHandler}} params84 * @return { aggregateType, eventType, handlerName }85 */86 subscribeEventRetrieval$({ aggregateType, eventType }) {87 const handler = this.functionMap[eventType];88 //MANDATORY: AVOIDS ACK REGISTRY DUPLICATIONS89 return eventSourcing.eventStore.ensureAcknowledgeRegistry$(aggregateType)90 .switchMap(() => eventSourcing.eventStore.retrieveUnacknowledgedEvents$(aggregateType, mbeKey))91 .filter(evt => evt.et === eventType)92 .concatMap(evt => Rx.Observable.concat(93 handler.fn.call(handler.obj, evt),94 //MANDATORY: ACKWOWLEDGE THIS EVENT WAS PROCESSED95 eventSourcing.eventStore.acknowledgeEvent$(evt, mbeKey)96 ));97 }98 /**99 * Generates a map that assocs each Event with its handler100 */101 generateFunctionMap() {102 return {103 'DeviceLocationReported': { fn: device.updateDeviceLocation$, obj: device },104 'DeviceDeviceStateReported': { fn: device.updateDeviceData$, obj: device },105 'DeviceRamuUsageAlarmActivated': { fn: device.updateDeviceAlarmsState$, obj: device },106 'DeviceRamUsageAlarmDeactivated': { fn: device.updateDeviceAlarmsState$, obj: device },107 'DeviceSdUsageAlarmActivated': { fn: device.updateDeviceAlarmsState$, obj: device },108 'DeviceSdUsageAlarmDeactivated': { fn: device.updateDeviceAlarmsState$, obj: device },109 'DeviceCpuUsageAlarmActivated': { fn: device.updateDeviceAlarmsState$, obj: device },110 'DeviceCpuUsageAlarmDeactivated': { fn: device.updateDeviceAlarmsState$, obj: device },111 'DeviceTemperatureAlarmActivated': { fn: device.updateDeviceAlarmsState$, obj: device },112 'DeviceTemperatureAlarmDeactivated': { fn: device.updateDeviceAlarmsState$, obj: device },113 'DeviceConnected': { fn: device.updateDeviceAlarmsState$, obj: device },114 'DeviceDisconnected': { fn: device.updateDeviceAlarmsState$, obj: device },115 'CleanDeviceLocationHistoryJobTriggered': { fn: device.cleanDeviceLocationHistory$, obj: device },116 'CleanGroupNamesJobTriggered': { fn: device.cleanGroupNames$, obj: device }117 };118 }119 /**120 * Generates a map that assocs each AggretateType withs its events121 */122 generateAggregateEventsArray() {123 return [124 { aggregateType: 'Device', eventType: 'DeviceDeviceStateReported' },125 { aggregateType: 'Device', eventType: 'DeviceLocationReported' },126 { aggregateType: 'Device', eventType: 'DeviceRamuUsageAlarmActivated' },127 { aggregateType: 'Device', eventType: 'DeviceRamUsageAlarmDeactivated' },128 { aggregateType: 'Device', eventType: 'DeviceSdUsageAlarmActivated' },129 { aggregateType: 'Device', eventType: 'DeviceSdUsageAlarmDeactivated' },130 { aggregateType: 'Device', eventType: 'DeviceCpuUsageAlarmActivated' },131 { aggregateType: 'Device', eventType: 'DeviceCpuUsageAlarmDeactivated' },132 { aggregateType: 'Device', eventType: 'DeviceTemperatureAlarmActivated' },133 { aggregateType: 'Device', eventType: 'DeviceTemperatureAlarmDeactivated', },134 { aggregateType: 'Device', eventType: 'DeviceConnected' },135 { aggregateType: 'Device', eventType: 'DeviceDisconnected' },136 { aggregateType: 'Cronjob', eventType: 'CleanDeviceLocationHistoryJobTriggered' },137 { aggregateType: 'Cronjob', eventType: 'CleanGroupNamesJobTriggered' },138 ];139 }140}141/**142 * @returns {EventStoreService}143 */144module.exports = () => {145 if (!instance) {146 instance = new EventStoreService();147 console.log('EventStoreService Singleton created');148 }149 return instance;...
simulator-management.js
Source:simulator-management.js
...58 }59}60async function fullResetSimulator (device) {61 if (device) {62 await device.clean();63 }64}65async function resetSimulator (device, opts) {66 if (!device) return;67 log.debug('Cleaning simulator state.');68 try {69 await clearAppData(device, opts);70 await device.clean();71 } catch (err) {72 log.warn(err);73 log.warn('Could not reset simulator. Leaving as is.');74 }75}76async function endSimulator (device) {77 if (!device) return;78 log.debug('Shutting down simulator');79 await device.shutdown();80}81async function clearAppData (device, opts) {82 if (opts.app && opts.bundleId) {83 await device.cleanCustomApp(path.basename(opts.app), opts.bundleId);84 }...
app2.js
Source:app2.js
1var express = require('express');2var bodyParser = require('body-parser');3var app = express();4var exec = require('child_process').exec;56app.use(bodyParser.urlencoded({ extended: false }));7app.use(bodyParser.json());89app.get('/', function (req, res) {10 res.sendFile(__dirname + '/index.htm');11 console.log('get /');12});1314app.get('/payload', function (req, res) {15 res.sendStatus(200);16 console.log('get /payload');17});1819app.post('/payload', function (req, res) {20 //verify that the payload is a push from the correct repo21 //verify repository.name == 'wackcoon-device' or repository.full_name = 'DanielEgan/wackcoon-device'22 console.log(req.body.pusher.name + ' just pushed to ' + req.body.repository.name);2324 console.log('pulling code from GitHub...');2526 // reset any changes that have been made locally27 exec('pwd && git -C /home/leo/GitHub-webhooks-integrations-example reset --hard', execCallback);2829 // and ditch any files that have been added locally too30 //exec('git -C ~/projects/wackcoon-device clean -df', execCallback);3132 // now pull down the latest33 exec('pwd && git -C /home/leo/GitHub-webhooks-integrations-example pull -f', execCallback);34 35 // run36 exec('pwd && chmod 744 /home/leo/GitHub-webhooks-integrations-example/mvnw');37 exec('cd /home/leo/GitHub-webhooks-integrations-example');38 exec('pwd && ./mvnw spring-boot:run', execCallback);3940});4142app.listen(19569, function () {43 console.log('listening on port 19569')44});45function execCallback(err, stdout, stderr) {46 if(stdout) console.log(stdout);47 if(stderr) console.log(stderr);
...
app.js
Source:app.js
1var express = require('express');2var bodyParser = require('body-parser');3var app = express();4var exec = require('child_process').exec;56app.use(bodyParser.urlencoded({ extended: false }));7app.use(bodyParser.json());89app.get('/', function (req, res) {10 res.sendFile(__dirname + '/index.htm');11 console.log('get /');12});1314app.get('/payload', function (req, res) {15 res.sendStatus(200);16 console.log('get /payload');17});1819app.post('/payload', function (req, res) {20 //verify that the payload is a push from the correct repo21 //verify repository.name == 'wackcoon-device' or repository.full_name = 'DanielEgan/wackcoon-device'22 console.log(req.body.pusher.name + ' just pushed to ' + req.body.repository.name);2324 console.log('pulling code from GitHub...');2526 // reset any changes that have been made locally27 exec('git -C ~/projects/wackcoon-device reset --hard', execCallback);2829 // and ditch any files that have been added locally too30 exec('git -C ~/projects/wackcoon-device clean -df', execCallback);3132 // now pull down the latest33 exec('git -C ~/projects/wackcoon-device pull -f', execCallback);3435 // and npm install with --production36 exec('npm -C ~/projects/wackcoon-device install --production', execCallback);3738 // and run tsc39 exec('tsc', execCallback);40});4142app.listen(5000, function () {43 console.log('listening on port 5000')44});4546function execCallback(err, stdout, stderr) {47 if(stdout) console.log(stdout);48 if(stderr) console.log(stderr);
...
Using AI Code Generation
1var wd = require('wd');2var assert = require('assert');3var chai = require('chai');4var chaiAsPromised = require('chai-as-promised');5chai.use(chaiAsPromised);6var expect = chai.expect;7var desired = {8};9var driver = wd.promiseChainRemote('localhost', 4723);10driver.init(desired)11 .then(function() {12 return driver.clean();13 })14 .then(function() {15 return driver.quit();16 })17 .done();18var wd = require('wd');19var assert = require('assert');20var chai = require('chai');21var chaiAsPromised = require('chai-as-promised');22chai.use(chaiAsPromised);23var expect = chai.expect;24var desired = {25};26var driver = wd.promiseChainRemote('localhost', 4723);27driver.init(desired)28 .then(function() {29 return driver.installApp('/Users/username/Downloads/MyApp.app');30 })31 .then(function() {32 return driver.quit();33 })34 .done();35var wd = require('wd');36var assert = require('assert');37var chai = require('chai');38var chaiAsPromised = require('chai-as-promised');39chai.use(chaiAsPromised);40var expect = chai.expect;41var desired = {42};43var driver = wd.promiseChainRemote('localhost', 4723);44driver.init(desired)
Using AI Code Generation
1const { remote } = require('webdriverio');2const opts = {3 capabilities: {4 }5};6(async () => {7 const client = await remote(opts);8 await client.clean();9})();
Using AI Code Generation
1const wd = require('wd');2const assert = require('assert');3const {exec} = require('child_process');4const PORT = 4723;5const HOST = 'localhost';6const config = {7};8async function main() {9 const driver = wd.promiseChainRemote(URL);10 await driver.init(config);11 await driver.sleep(10000);12 await driver.execute('mobile: deviceClean', {bundleId: 'com.my.app'});13 await driver.quit();14}15main();16const wd = require('wd');17const assert = require('assert');18const {exec} = require('child_process');19const PORT = 4723;20const HOST = 'localhost';21const config = {22};23async function main() {24 const driver = wd.promiseChainRemote(URL);25 await driver.init(config);26 await driver.sleep(10000);27 await driver.execute('mobile: deviceClean', {bundleId: 'com.my.app'});28 await driver.quit();29}30main();31const wd = require('wd');32const assert = require('assert');33const {exec} = require('child_process');34const PORT = 4723;35const HOST = 'localhost';36const config = {37};38async function main() {39 const driver = wd.promiseChainRemote(URL);40 await driver.init(config);41 await driver.sleep(10000);42 await driver.execute('mobile: deviceClean',
Using AI Code Generation
1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4const expect = chai.expect;5chai.use(chaiAsPromised);6chai.should();7describe('Test', function () {8 this.timeout(300000);9 let driver;10 before(async () => {11 const desiredCaps = {12 };13 await driver.init(desiredCaps);14 });15 after(async () => {16 await driver.quit();17 });18 it('should clean the device', async () => {19 await driver.clean();20 });21});
Using AI Code Generation
1const wdio = require('webdriverio');2const opts = {3 desiredCapabilities: {4 }5};6const client = wdio.remote(opts);7 .init()8 .then(() => client.deviceClean())9 .then(() => client.end());10const wdio = require('webdriverio');11const opts = {12 desiredCapabilities: {13 }14};15const client = wdio.remote(opts);16 .init()17 .then(() => client.deviceLaunchApp())18 .then(() => client.end());19const wdio = require('webdriverio');20const opts = {21 desiredCapabilities: {
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var By = webdriver.By;3var until = webdriver.until;4var fs = require('fs');5var path = require('path');6var driver = new webdriver.Builder().forBrowser('chrome').build();7driver.findElement(By.name('q')).sendKeys('webdriver');8driver.findElement(By.name('btnK')).click();9driver.wait(until.titleIs('webdriver - Google Search'), 1000);10driver.manage().window().maximize();11driver.quit();12driver.executeScript("mobile: device: clean", { "deviceName": "iPhone 8" });13driver.quit();14driver.executeScript("mobile: device: clean", { "deviceName": "iPhone 8" });15driver.quit();16driver.executeScript("mobile: device: clean", { "deviceName": "iPhone 8" });17driver.quit();18driver.executeScript("mobile: device: clean", { "deviceName": "iPhone 8" });19driver.quit();20driver.executeScript("mobile: device: clean", { "deviceName": "iPhone 8" });21driver.quit();22driver.executeScript("mobile: device: clean", { "deviceName": "iPhone 8" });23driver.quit();24driver.executeScript("mobile: device: clean", { "deviceName": "iPhone 8" });25driver.quit();26driver.executeScript("mobile: device: clean", { "deviceName": "iPhone 8" });27driver.quit();
Using AI Code Generation
1const wdio = require("webdriverio");2const opts = {3 capabilities: {4 }5};6(async () => {7 const client = await wdio.remote(opts);8 await client.pause(5000);9 await client.deviceClean();10 await client.pause(5000);11 await client.deleteSession();12})();13const wdio = require("webdriverio");14const opts = {15 capabilities: {16 }17};18(async () => {19 const client = await wdio.remote(opts);20 await client.pause(5000);21 await client.deviceLaunchApp({22 environment: {
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!