How to use updateItem method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

MySqlProc.ts

Source:MySqlProc.ts Github

copy

Full Screen

1import {sorm} from "@simplism/orm-query";2import {DateTime} from "@simplism/core";3import {MainDbContext} from "../MainDbContext";4import {SdSocketProvider} from "@simplism/angular";5export class MySqlProc {6 public static async syncEmployees(db: MainDbContext, socket: SdSocketProvider): Promise<void> {7 const lastModifyDate = await db.erpSync8 .where(item =>9 [sorm.equal(item.code, "Employee")]10 )11 .select(item => ({12 syncDate: item.syncDate13 }))14 .singleAsync();15 const employeeList = await socket.sendAsync("ErpMysqlQueryService.executeQueryAsync", [`16 SELECT17 TBL.m_idx AS id,18 TBL.m_id AS userId,19 TBL.m_pw AS password,20 TBL.m_name AS name,21 TBL.m_sex AS sex,22 TBL.m_email AS emailAddress,23 TBL.m_mobile AS phoneNumber,24 TBL.m_addr1 AS addr1,25 TBL.m_addr2 AS addr2,26 TBL.m_block AS isDisabled,27 TBL.m_lastmodify_date AS lastModifyDate,28 TBL.m_position AS position,29 department.title AS department30FROM breed_member AS TBL31 LEFT OUTER JOIN newgratech.breed_organization AS department32ON (department.cateno= TBL.m_organization)33WHERE IFNULL(TBL.m_lastmodify_date, NOW()) > '${lastModifyDate!.syncDate.toFormatString("yyyy-MM-dd hh:mm:ss")}'34OR IFNULL(TBL.m_join_date, NOW()) > '${lastModifyDate!.syncDate.toFormatString("yyyy-MM-dd hh:mm:ss")}'`.trim()]);35 const mesEmployeeList = await db.employee.select(item => ({id: item.id, syncCode: item.code})).resultAsync();36 for (const updateItem of employeeList) {37 if (mesEmployeeList.some(item => item.syncCode === String(updateItem.id))) {38 db.employee39 .where(item => [40 sorm.equal(item.code, updateItem.id)41 ])42 .updatePrepare(() => ({43 companyId: 1,44 code: updateItem.id,45 name: updateItem.name,46 encryptedPassword: updateItem.password,47 department: updateItem.department,48 position: updateItem.position,49 sex: sorm.cast(updateItem.sex, Number),50 emailAddress: updateItem.email,51 phoneNumber: updateItem.phoneNumber,52 isDisabled: sorm.cast(updateItem.isDisabled, Boolean)53 }));54 }55 else {56 db.employee.insertPrepare({57 companyId: 1,58 code: updateItem.id,59 userId: updateItem.userId,60 name: updateItem.name,61 encryptedPassword: updateItem.password,62 department: updateItem.department,63 position: updateItem.position,64 sex: updateItem.sex,65 emailAddress: updateItem.emailAddress,66 phoneNumber: updateItem.phoneNumber,67 isDisabled: updateItem.isDisabled68 });69 }70 }71 await db.executePreparedAsync();72 await db.erpSync73 .where(item =>74 [sorm.equal(item.code, "Employee")]75 )76 .updateAsync(item => ({77 syncDate: new DateTime()78 }));79 }80 public static async syncPartner(db: MainDbContext, socket: SdSocketProvider): Promise<void> {81 const lastModifyDate = await db.erpSync82 .where(item =>83 [sorm.equal(item.code, "Partner")]84 )85 .select(item => ({86 syncDate: item.syncDate87 }))88 .singleAsync();89 const partnerList = await socket.sendAsync("ErpMysqlQueryService.executeQueryAsync", [`90 SELECT91 TBL.customer_idx AS id,92 TBL.customer_company_type AS companyType,93 TBL.customer_name AS name,94 TBL.customer_code AS partnerCode,95 TBL.customer_ceo AS representative,96 TBL.customer_number AS registrationNumber,97 TBL.customer_corporate_number AS businessRegistrationNumber,98 TBL.customer_tel AS tel,99 TBL.customer_mobile AS phoneNumber,100 TBL.customer_fax AS faxNumber,101 TBL.customer_email AS emailAddress,102 TBL.customer_homepage AS homePage,103 TBL.customer_business_type AS businessConditions,104 TBL.customer_business_item AS event,105 TBL.customer_addr1 AS address,106 TBL.customer_addr2 AS addressDetail,107 TBL.customer_zip AS postcode,108 TBL.customer_buy_type AS type,109 TBL.is_export AS isExport,110 TBL.is_customer_delete AS isDisabled,111 TBL.customer_modifydate AS lastModifyDate112FROM breed_customer AS TBL113 WHERE IFNULL(TBL.customer_modifydate, NOW()) > '${lastModifyDate!.syncDate.toFormatString("yyyy-MM-dd hh:mm:ss")}'114 OR IFNULL(TBL.customer_regdate, NOW()) > '${lastModifyDate!.syncDate.toFormatString("yyyy-MM-dd hh:mm:ss")}'`.trim()]);115 const mesPartnerList = await db.partner.select(item => ({id: item.id, syncCode: item.erpSyncCode})).resultAsync();116 for (const updateItem of partnerList) {117 if (mesPartnerList.some(item => item.syncCode === updateItem.id)) {118 db.partner119 .where(item => [120 sorm.equal(item.erpSyncCode, updateItem.id)121 ])122 .updatePrepare(() => ({123 companyType: updateItem.companyType === 1 ? "법인" : "개인",124 name: updateItem.name,125 partnerCode: updateItem.partnerCode,126 representative: updateItem.representative,127 registrationNumber: updateItem.registrationNumber,128 businessRegistrationNumber: updateItem.businessRegistrationNumber,129 tel: updateItem.tel,130 phoneNumber: updateItem.phoneNumber,131 faxNumber: updateItem.faxNumber,132 emailAddress: updateItem.emailAddress,133 homePage: updateItem.homePage,134 businessConditions: updateItem.businessConditions,135 event: updateItem.event,136 address: updateItem.address,137 addressDetail: updateItem.addressDetail,138 postcode: updateItem.postcode,139 type: updateItem.type === 1 ? "매출처" : updateItem.type === 2 ? "매입처" : "본사",140 isExport: updateItem.isExport === "1",141 isDisabled: updateItem.isDisabled === 1142 }));143 }144 else {145 db.partner.insertPrepare({146 companyId: 1,147 erpSyncCode: updateItem.id,148 companyType: updateItem.companyType === 1 ? "법인" : "개인",149 name: updateItem.name,150 partnerCode: updateItem.partnerCode,151 representative: updateItem.representative,152 registrationNumber: updateItem.registrationNumber,153 businessRegistrationNumber: updateItem.businessRegistrationNumber,154 tel: updateItem.tel,155 phoneNumber: updateItem.phoneNumber,156 faxNumber: updateItem.faxNumber,157 emailAddress: updateItem.emailAddress,158 homePage: updateItem.homePage,159 businessConditions: updateItem.businessConditions,160 event: updateItem.event,161 address: updateItem.address,162 addressDetail: updateItem.addressDetail,163 postcode: updateItem.postcode,164 type: updateItem.type === 1 ? "매출처" : updateItem.type === 2 ? "매입처" : "본사",165 isExport: updateItem.isExport === "1",166 isDisabled: updateItem.isDisabled === 1167 });168 }169 }170 await db.executePreparedAsync();171 await db.erpSync172 .where(item =>173 [sorm.equal(item.code, "Partner")]174 )175 .updateAsync(item => ({176 syncDate: new DateTime()177 }));178 }179 public static async syncGoods(db: MainDbContext, socket: SdSocketProvider): Promise<void> {180 const lastModifyDate = await db.erpSync181 .where(item =>182 [sorm.equal(item.code, "Goods")]183 )184 .select(item => ({185 syncDate: item.syncDate186 }))187 .singleAsync();188 const goodsList = await socket.sendAsync("ErpMysqlQueryService.executeQueryAsync", [`189 SELECT TBL.sp_key AS id,190 TBL.sp_name AS name,191 CAST(TBL.sp_stand AS CHAR(255)) AS specification,192 TBL.sp_thick AS thick,193 TBL.sp_weight AS weight,194 TBL.sbu_name AS unitName,195 TBL.sp_price AS unitPrice,196 TBL.sp_int AS stockQuantity,197 TBL.sp_loss AS lossQuantity,198 TBL.sp_length AS length,199 TBL.sp_stock AS adequateStock,200 TBL.sp_stock_per AS adequateStockRate,201 TBL.sp_text AS remark,202 TBL.sp_use AS isDisabled,203 TBL.mod_date AS lastModifyDate,204 TBL.sp_date AS standardDate,205 goodsType.sbpc_name AS type,206 goodsCategory.sbpi_name AS category207FROM ss_product AS TBL208 LEFT OUTER JOIN newgratech.ss_basic_product_code AS goodsType ON (goodsType.sbpc_key = TBL.sbpc_key)209 LEFT OUTER JOIN newgratech.ss_basic_product_index AS goodsCategory ON (goodsCategory.sbpi_key = TBL.sbpi_key)210 WHERE IFNULL(TBL.mod_date, NOW()) > '${lastModifyDate!.syncDate.toFormatString("yyyy-MM-dd hh:mm:ss")}'211 OR IFNULL(TBL.reg_date, NOW()) > '${lastModifyDate!.syncDate.toFormatString("yyyy-MM-dd hh:mm:ss")}'212 ORDER BY goodsType.sbpc_name DESC, goodsCategory.sbpi_name ASC, TBL.sp_name ASC, TBL.sp_stand ASC`.trim()]);213 const mesGoodsList = await db.goods.select(item => ({id: item.id, syncCode: item.erpSyncCode})).resultAsync();214 for (const updateItem of goodsList) {215 if ((mesGoodsList.some(item => item.syncCode === updateItem.id))) {216 db.goods217 .where(item => [218 sorm.equal(item.erpSyncCode, updateItem.id)219 ])220 .updatePrepare(() => ({221 specification: sorm.cast(updateItem.specification, String),222 type: updateItem.type,223 category: updateItem.category,224 thick: updateItem.thick,225 weight: updateItem.weight,226 unitId: updateItem.unitId,227 unitName: updateItem.unitName,228 unitPrice: updateItem.unitPrice,229 stockQuantity: updateItem.stockQuantity,230 lossQuantity: updateItem.lossQuantity,231 length: updateItem.length,232 adequateStock: updateItem.adequateStock,233 adequateStockRate: updateItem.adequateStockRate,234 remark: updateItem.remark,235 createdAtDateTime: updateItem.standardDate,236 isDisabled: updateItem.isDisabled === 1237 }));238 }239 else {240 db.goods.insertPrepare({241 companyId: 1,242 erpSyncCode: updateItem.id,243 name: updateItem.name,244 specification: sorm.cast(updateItem.specification, String),245 type: updateItem.type,246 category: updateItem.category,247 thick: updateItem.thick,248 weight: updateItem.weight,249 unitId: updateItem.unitId,250 unitName: updateItem.unitName,251 unitPrice: updateItem.unitPrice,252 stockQuantity: updateItem.stockQuantity,253 lossQuantity: updateItem.lossQuantity,254 length: updateItem.length,255 adequateStock: updateItem.adequateStock,256 adequateStockRate: updateItem.adequateStockRate,257 createdAtDateTime: updateItem.standardDate,258 remark: updateItem.remark,259 isDisabled: updateItem.isDisabled === 1260 });261 }262 }263 await db.executePreparedAsync();264 await db.erpSync265 .where(item =>266 [sorm.equal(item.code, "Goods")]267 )268 .updateAsync(item => ({269 syncDate: new DateTime()270 }));271 }272 public static async syncEquipments(db: MainDbContext, socket: SdSocketProvider): Promise<void> {273 const lastModifyDate = await db.erpSync274 .where(item =>275 [sorm.equal(item.code, "Equipment")]276 )277 .select(item => ({278 syncDate: item.syncDate279 }))280 .singleAsync();281 const equipmentList = await socket.sendAsync("ErpMysqlQueryService.executeQueryAsync", [`282 SELECT TBL.sbma_key AS id,283 TBL.sbma_name AS name,284 TBL.sbma_order AS seq,285 TBL.sbma_symbol AS code,286 TBL.reg_date AS createDate,287 TBL.sbma_report AS isCount288FROM ss_basic_machine AS TBL`.trim()]);289 for (const updateItem of equipmentList) {290 if ((await db.equipment.where(item => [sorm.equal(item.erpSyncCode, updateItem.id)]).countAsync()) > 0) {291 if (updateItem.lastModifyDate > lastModifyDate!.syncDate!) {292 await db.equipment293 .where(item => [294 sorm.equal(item.erpSyncCode, updateItem.id)295 ])296 .upsertAsync({297 seq: updateItem.seq,298 name: updateItem.name,299 code: updateItem.code,300 equipmentCode: await this._getEquipmentCode(updateItem.name),301 isCount: updateItem.isCount === "Y",302 isDisabled: updateItem.isCount !== "Y",303 createdAtDateTime: updateItem.createDate304 });305 }306 }307 else {308 await db.equipment.insertAsync({309 companyId: 1,310 seq: updateItem.seq,311 erpSyncCode: updateItem.id,312 name: updateItem.name,313 code: updateItem.code,314 equipmentCode: await this._getEquipmentCode(updateItem.name),315 isCount: updateItem.isCount === "Y",316 isDisabled: updateItem.isCount !== "Y",317 createdAtDateTime: updateItem.createDate318 });319 }320 }321 //TODO: erp에서 비가동 시간 가져와야 할 경우 추가322 /*323 const equipmentStopList = await socket.sendAsync("ErpMysqlQueryService.executeQueryAsync", [`324 SELECT TBL.sbma_key AS id,325 TBL.sbma_name AS name,326 TBL.sbma_order AS seq,327 TBL.sbma_symbol AS code,328 TBL.reg_date AS createDate,329 TBL.sbma_report AS isCount330 FROM ss_off_time AS TBL`.trim()]);331 */332 await db.erpSync333 .where(item =>334 [sorm.equal(item.code, "Equipment")]335 )336 .updateAsync(item => ({337 syncDate: new DateTime()338 }));339 }340 public static async _getEquipmentCode(name: string): Promise<any> {341 if (name.includes("리와인더1호기")) {342 return "R001";343 }344 else if (name.includes("리와인더2호기")) {345 return "R002";346 }347 else if (name.includes("리와인더3호기")) {348 return "R003";349 }350 else if (name.includes("3호기")) {351 return "M003";352 }353 else if (name.includes("싱글호기")) {354 return "S001";355 }356 else if (name.includes("1호기")) {357 return "M001";358 }359 else if (name.includes("2호기")) {360 return "M002";361 }362 }...

Full Screen

Full Screen

state-operators.update-item.lint.ts

Source:state-operators.update-item.lint.ts Github

copy

Full Screen

...17 arrs: [[1, 2], [3], []],18 objs: [{ name: '1' }, { name: '2' }, { name: '3' }]19 };20 patch<Original>({ nums: updateItem<number>(0, 123) })(original); // $ExpectType Original21 patch<Original>({ nums: updateItem(0, 123) })(original); // $ExpectType Original22 patch<Original>({ nums: updateItem(0, 0) })(original); // $ExpectType Original23 patch<Original>({ nums: updateItem<number>(0, 123) })(original); // $ExpectType Original24 patch<Original>({ nums: updateItem(0, 123) })(original); // $ExpectType Original25 patch<Original>({ nums: updateItem(0, 0) })(original); // $ExpectType Original26 patch<Original>({ nums: updateItem(0, null!) })(original); // $ExpectType Original27 patch<Original>({ nums: updateItem(0, undefined!) })(original); // $ExpectType Original28 patch<Original>({ strs: updateItem<string>(0, '123') })(original); // $ExpectType Original29 patch<Original>({ strs: updateItem(0, '123') })(original); // $ExpectType Original30 patch<Original>({ strs: updateItem(0, '') })(original); // $ExpectType Original31 patch<Original>({ strs: updateItem<string>(0, '123') })(original); // $ExpectType Original32 patch<Original>({ strs: updateItem(0, '123') })(original); // $ExpectType Original33 patch<Original>({ strs: updateItem(0, '') })(original); // $ExpectType Original34 patch<Original>({ strs: updateItem(0, null!) })(original); // $ExpectType Original35 patch<Original>({ strs: updateItem(0, undefined!) })(original); // $ExpectType Original36 patch<Original>({ bools: updateItem<boolean>(0, true) })(original); // $ExpectType Original37 patch<Original>({ bools: updateItem<boolean>(0, true) })(original); // $ExpectType Original38 patch<Original>({ bools: updateItem(0, true) })(original); // $ExpectType Original39 patch<Original>({ bools: updateItem(0, true) })(original); // $ExpectType Original40 patch<Original>({ bools: updateItem(0, false) })(original); // $ExpectType Original41 patch<Original>({ bools: updateItem(0, false) })(original); // $ExpectType Original42 patch<Original>({ bools: updateItem(0, null!) })(original); // $ExpectType Original43 patch<Original>({ bools: updateItem(0, undefined!) })(original); // $ExpectType Original44 patch<Original>({ arrs: updateItem(0, null!) })(original); // $ExpectType Original45 patch<Original>({ arrs: updateItem(0, undefined!) })(original); // $ExpectType Original46 patch<Original>({ objs: updateItem(0, null!) })(original); // $ExpectType Original47 patch<Original>({ objs: updateItem(0, undefined!) })(original); // $ExpectType Original48 });49 it('should have the following valid complex usage', () => {50 interface Stock {51 beer: Beer[];52 controller: string[];53 nestedStock?: {54 wine: Wine[];55 nestedStock?: {56 whiskey: Whiskey[];57 };58 };59 }60 interface Beer {61 name: string;62 quantity: number;63 }64 interface Wine {65 name: string;66 quantity: number;67 }68 interface Whiskey {69 name: string;70 }71 const original: Stock = {72 beer: [73 {74 name: 'Colessi',75 quantity: 1076 },77 {78 name: 'BUNK!',79 quantity: 580 }81 ],82 controller: ['Artur Androsovych', 'Mark Whitfield']83 };84 patch<Stock>({85 beer: updateItem(0, { name: 'Alchemist', quantity: 10 }),86 controller: updateItem(0, 'Max Ivanov'),87 nestedStock: {88 wine: [{ name: 'Centine', quantity: 10 }],89 nestedStock: {90 whiskey: [{ name: 'Jack Daniels' }]91 }92 }93 })(original); // $ExpectType Stock94 patch<Stock>({95 nestedStock: patch({96 wine: updateItem(0, { name: 'Chablis', quantity: 20 }),97 nestedStock: patch({98 whiskey: updateItem(0, { name: 'Chivas' })99 })100 })101 })(original); // $ExpectType Stock102 });103 it('should not accept the following usages', () => {104 interface Original {105 nums: number[];106 strs: string[];107 bools: boolean[];108 arrs: number[][];109 objs: Array<{ name: string }>;110 }111 const original: Original = {112 nums: [1, 2, 3],113 strs: ['1', '2', '3'],114 bools: [true, false],115 arrs: [[1, 2], [3], []],116 objs: [{ name: '1' }, { name: '2' }, { name: '3' }]117 };118 patch<Original>({ nums: updateItem(0, '1') })(original); // $ExpectError119 patch<Original>({ nums: updateItem(0, true) })(original); // $ExpectError120 patch<Original>({ nums: updateItem(0, []) })(original); // $ExpectError121 patch<Original>({ nums: updateItem(0, {}) })(original); // $ExpectError122 patch<Original>({ nums: updateItem<string>(0, '1') })(original); // $ExpectError123 patch<Original>({ nums: updateItem<boolean>(0, true) })(original); // $ExpectError124 patch<Original>({ nums: updateItem<number[]>(0, []) })(original); // $ExpectError125 patch<Original>({ nums: updateItem<object>(0, {}) })(original); // $ExpectError126 patch<Original>({ strs: updateItem(0, 1) })(original); // $ExpectError127 patch<Original>({ strs: updateItem(0, true) })(original); // $ExpectError128 patch<Original>({ strs: updateItem(0, []) })(original); // $ExpectError129 patch<Original>({ strs: updateItem(0, {}) })(original); // $ExpectError130 patch<Original>({ strs: updateItem<number>(0, 1) })(original); // $ExpectError131 patch<Original>({ strs: updateItem<boolean>(0, true) })(original); // $ExpectError132 patch<Original>({ strs: updateItem<number[]>(0, []) })(original); // $ExpectError133 patch<Original>({ strs: updateItem<object>(0, {}) })(original); // $ExpectError134 patch<Original>({ bools: updateItem(0, 1) })(original); // $ExpectError135 patch<Original>({ bools: updateItem(0, '1') })(original); // $ExpectError136 patch<Original>({ bools: updateItem(0, []) })(original); // $ExpectError137 patch<Original>({ bools: updateItem(0, {}) })(original); // $ExpectError138 patch<Original>({ bools: updateItem<number>(0, 1) })(original); // $ExpectError139 patch<Original>({ bools: updateItem<string>(0, '1') })(original); // $ExpectError140 patch<Original>({ bools: updateItem<number[]>(0, []) })(original); // $ExpectError141 patch<Original>({ bools: updateItem<object>(0, {}) })(original); // $ExpectError142 patch<Original>({ arrs: updateItem(0, 1) })(original); // $ExpectError143 patch<Original>({ arrs: updateItem(0, '1') })(original); // $ExpectError144 patch<Original>({ arrs: updateItem(0, true) })(original); // $ExpectError145 patch<Original>({ arrs: updateItem(0, ['123']) })(original); // $ExpectError146 patch<Original>({ arrs: updateItem(0, {}) })(original); // $ExpectError147 patch<Original>({ arrs: updateItem<number>(0, 1) })(original); // $ExpectError148 patch<Original>({ arrs: updateItem<boolean>(0, true) })(original); // $ExpectError149 patch<Original>({ arrs: updateItem<string>(0, '1') })(original); // $ExpectError150 patch<Original>({ arrs: updateItem<string[]>(0, []) })(original); // $ExpectError151 patch<Original>({ arrs: updateItem<object>(0, {}) })(original); // $ExpectError152 patch<Original>({ objs: updateItem(0, 1) })(original); // $ExpectError153 patch<Original>({ objs: updateItem(0, '1') })(original); // $ExpectError154 patch<Original>({ objs: updateItem(0, true) })(original); // $ExpectError155 patch<Original>({ objs: updateItem(0, []) })(original); // $ExpectError156 patch<Original>({ objs: updateItem(0, { desc: '' }) })(original); // $ExpectError157 patch<Original>({ objs: updateItem<number>(0, 1) })(original); // $ExpectError158 patch<Original>({ objs: updateItem<boolean>(0, true) })(original); // $ExpectError159 patch<Original>({ objs: updateItem<string>(0, '1') })(original); // $ExpectError160 patch<Original>({ objs: updateItem<number[]>(0, []) })(original); // $ExpectError161 patch<Original>({ objs: updateItem<Original['objs'][0]>(0, { desc: '' }) })(original); // $ExpectError162 });...

Full Screen

Full Screen

LayoutElements.js

Source:LayoutElements.js Github

copy

Full Screen

1'use strict';2var url = require('url');3var LayoutModel = require("../models/LayoutModel").LayoutModel;4var LayoutElementModel = require("../models/LayoutElementModel").LayoutElementModel;5function updateConnectIQLayoutLastModifiedDate(connectIQLayoutId) {6 LayoutModel.findById(connectIQLayoutId, function(err, updateItem) {7 if (err)8 console.log(err);9 updateItem.lastUpdatedDate = new Date(); 10 // save 11 updateItem.save(function(err) {12 if (err) {13 console.log(err);14 }15 });16 });17};18module.exports.getLayoutElements = function getLayoutElements(req, res, next) {19 var connectIQLayoutId = req.swagger.params['connectIQLayoutId'].value;20 LayoutElementModel.find({connectiqlayout_ref: connectIQLayoutId},function(err, results) {21 if (err) {22 res.send(err);23 }24 res.setHeader('Content-Type', 'application/json');25 res.status(200).end(results);26 });27};28module.exports.addLayoutElement = function addLayoutElement (req, res, next) {29 var connectIQLayoutId = req.swagger.params['connectIQLayoutId'].value;30 var body = req.swagger.params['body'].value;31 var newLayoutElement = new LayoutElementModel(body);32 newLayoutElement.connectiqlayout_ref = connectIQLayoutId;33 newLayoutElement.save(function (err, createdItem) {34 if (err) {35 console.log('db error');36 res.setHeader('Content-Type', 'application/json');37 res.status(500).end(JSON.stringify({}, null, 2));38 }39 updateConnectIQLayoutLastModifiedDate(connectIQLayoutId);40 res.setHeader('Content-Type', 'application/json');41 res.status(201).end(JSON.stringify(createdItem, null, 2));42 })43 44};45module.exports.getLayoutElement = function getLayoutElement (req, res, next) {46 var connectIQLayoutId = req.swagger.params['connectIQLayoutId'].value;47 var layoutElementsId = req.swagger.params['layoutElementsId'].value;48 LayoutElementModel.findOne({connectiqlayout_ref: connectIQLayoutId, _id:layoutElementsId},function(err, results) {49 if (err) {50 res.send(err);51 }52 res.setHeader('Content-Type', 'application/json');53 res.status(200).end(results);54 });55};56module.exports.updateLayoutElement = function updateLayoutElement (req, res, next) {57 var connectIQLayoutId = req.swagger.params['connectIQLayoutId'].value;58 var layoutElementsId = req.swagger.params['layoutElementsId'].value;59 var body = req.swagger.params['body'].value;60 LayoutElementModel.findById(layoutElementsId, function(err, updateItem) {61 if (err)62 res.send(err);63 updateItem.name = body.name; 64 updateItem.description = body.description; 65 updateItem.displayText = body.displayText; 66 updateItem.elementtype = body.elementtype;67 updateItem.font = body.font;68 updateItem.justification = body.justification;69 updateItem.arcType = body.arcType;70 updateItem.filled = body.filled;71 updateItem.color = body.color;72 updateItem.degreeStart = body.degreeStart;73 updateItem.degreeEnd = body.degreeEnd;74 updateItem.xRadius = body.xRadius;75 updateItem.yRadius = body.yRadius;76 updateItem.rectangleWidth = body.rectangleWidth;77 updateItem.rectangleHeight = body.rectangleHeight;78 updateItem.lineWidth = body.lineWidth;79 updateItem.coordinates = body.coordinates;80 81 // save 82 updateItem.save(function(err) {83 if (err) {84 console.log('db error');85 res.setHeader('Content-Type', 'application/json');86 res.status(500).end(JSON.stringify(err, null, 2));87 }88 updateConnectIQLayoutLastModifiedDate(connectIQLayoutId);89 res.setHeader('Content-Type', 'application/json');90 res.status(201).end(JSON.stringify(updateItem, null, 2));91 });92 });93};94module.exports.deleteLayoutElement = function deleteLayoutElement (req, res, next) {95 var connectIQLayoutId = req.swagger.params['connectIQLayoutId'].value;96 var layoutElementsId = req.swagger.params['layoutElementsId'].value;97 LayoutElementModel.findById(layoutElementsId, function(err, deleteObject) {98 if (err) return next(err);99 if (!deleteObject) {100 res.setHeader('Content-Type', 'application/json');101 res.status(404).end();102 }103 else {104 deleteObject.remove();105 res.setHeader('Content-Type', 'application/json');106 res.status(200).end();107 }108 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2var client = new stf.Client();3var device = new stf.Device(client);4var deviceID = "deviceID";5device.updateItem(deviceID, {owner: "ownerID"}, function(err, item) {6 if (err) {7 console.log("Error: " + err);8 } else {9 console.log("Device updated");10 }11});12var properties = {13}14device.updateItem(deviceID, properties, function(err, item) {15 if (err) {16 console.log("Error: " + err);17 } else {18 console.log("Device updated");19 }20});21var properties = {22}23device.updateItem(deviceID, properties, function(err, item) {24 if (err) {25 console.log("Error: " + err);26 } else {27 console.log("Device updated");28 }29});30var properties = {31}32device.updateItem(deviceID, properties, function(err, item) {33 if (err) {34 console.log("Error: " + err);35 } else {36 console.log("Device updated");37 }38});39var properties = {40}41device.updateItem(deviceID, properties, function(err, item) {42 if (err) {43 console.log("Error: " + err);44 } else {45 console.log("Device updated");46 }47});48var properties = {49}50device.updateItem(deviceID, properties, function(err, item) {51 if (err) {52 console.log("Error: " + err);53 } else {54 console.log("Device updated");55 }56});57var properties = {58}59device.updateItem(deviceID, properties, function(err, item) {60 if (err) {61 console.log("Error: " +

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2var device = new client.Device('your device id');3device.updateItem('your item name', 'your item value');4var client = require('devicefarmer-stf-client');5var device = new client.Device('your device id');6var items = {7};8device.updateItems(items);9var client = require('devicefarmer-stf-client');10var device = new client.Device('your device id');11device.removeItem('your item name');12var client = require('devicefarmer-stf-client');13var device = new client.Device('your device id');14device.removeItems(['your item name', 'your item name']);15var client = require('devicefarmer-stf-client');16var device = new client.Device('your device id');17device.getDisplay(function (err, display) {18 if (err) {19 console.log(err);20 } else {21 console.log(display);22 }23});24var client = require('devicefarmer-stf-client');25var device = new client.Device('your device id');26device.getDisplay(function (err, display) {27 if (err) {28 console.log(err);29 } else {30 console.log(display);31 }32});33var client = require('devicefarmer-stf-client');34var device = new client.Device('your device id');35device.getDisplay(function (err, display) {36 if (err) {37 console.log(err);38 } else {39 console.log(display);40 }41});42var client = require('devicefarmer-stf-client');43var device = new client.Device('your device id');

Full Screen

Using AI Code Generation

copy

Full Screen

1var Client = require('devicefarmer-stf-client');2client.updateItem('device', 'serial', {3}).then(function() {4 console.log('Device updated');5}).catch(function(err) {6 console.error('Something went wrong', err.stack);7});8var Client = require('devicefarmer-stf-client');9client.updateItem('device', 'serial', {10}).then(function() {11 console.log('Device updated');12}).catch(function(err) {13 console.error('Something went wrong', err.stack);14});

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('./index.js');2stf.updateItem("serial", {owner: "testOwner"}, function(error, response, body){3 if(error){4 console.log(error);5 }else{6 console.log(body);7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2var device = client.getDevice('1234567890');3var path = '/sdcard/Download/test.txt';4var content = 'test';5device.updateItem(path, content, function (err, res) {6 if (err) {7 console.log('error', err);8 } else {9 console.log('result', res);10 }11});12var client = require('devicefarmer-stf-client');13var device = client.getDevice('1234567890');14var path = '/sdcard/Download/test.txt';15device.deleteItem(path, function (err, res) {16 if (err) {17 console.log('error', err);18 } else {19 console.log('result', res);20 }21});22var client = require('devicefarmer-stf-client');23var device = client.getDevice('1234567890');24var path = '/sdcard/Download/test.txt';25device.getItem(path, function (err, res) {26 if (err) {27 console.log('error', err);28 } else {29 console.log('result', res);30 }31});32var client = require('devicefarmer-stf-client');33var device = client.getDevice('1234567890');34var path = '/sdcard/Download/test.txt';35device.createDir(path, function (err, res) {36 if (err) {37 console.log('error', err);38 } else {39 console.log('result', res);40 }41});42var client = require('devicefarmer-stf-client');43var device = client.getDevice('1234567890');44var path = '/sdcard/Download/test.txt';

Full Screen

Using AI Code Generation

copy

Full Screen

1var Client = require('devicefarmer-stf-client');2var client = new Client();3client.updateItem('STF device serial', 'STF device token', { note: 'Note to be displayed on STF web UI' }, function(err, res) {4 if (err) {5 console.log(err);6 } else {7 console.log(res);8 }9});10var Client = require('devicefarmer-stf-client');11var client = new Client();12client.getDevices(function(err, res) {13 if (err) {14 console.log(err);15 } else {16 console.log(res);17 }18});19var Client = require('devicefarmer-stf-client');20var client = new Client();21client.getDevice('STF device serial', function(err, res) {22 if (err) {23 console.log(err);24 } else {25 console.log(res);26 }27});

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devicefarmer-stf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful