Best JavaScript code snippet using wpt
server_er_body_parsers_test.js
Source:server_er_body_parsers_test.js
1const { assert, test, helpers, Mocker, Mock } = require( '../test_helper' );2const path = require( 'path' );3const { Server } = require( './../../index' );4const fs = require( 'fs' );5const querystring = require( 'querystring' );6const JsonBodyParser = require( './../../server/components/body_parsers/json_body_parser' );7const BodyParserPlugin = require( './../../server/plugins/available_plugins/body_parser_plugin' );8test({9 message : 'Server.test.er_body_parser_json.does.not.parse.anything.but.application/json',10 test : ( done ) => {11 const name = 'testErJsonBodyParserParsesApplicationJson';12 const formDataKey = 'testErJsonBodyParserParsesApplicationJson';13 const formDataValue = 'value';14 const app = new Server();15 app.apply( app.er_body_parser_json, { maxPayloadLength: 60 } );16 app.get( `/${name}`, ( event ) => {17 if (18 typeof event.body === 'undefined'19 || typeof event.body[formDataKey] === 'undefined'20 || ! event.body[formDataKey].includes( formDataValue )21 ) {22 event.sendError( 'Body was not parsed', 400 );23 }24 event.send( 'ok' );25 } );26 const responses = [];27 responses.push(28 helpers.sendServerRequest(29 `/${name}`,30 'GET',31 200,32 JSON.stringify( { [formDataKey]: formDataValue } ),33 { 'content-type': 'application/json' },34 333735 )36 );37 responses.push(38 helpers.sendServerRequest(39 `/${name}`,40 'GET',41 200,42 JSON.stringify( { [formDataKey]: formDataValue } ),43 { ['content-type'.toUpperCase()]: 'application/json' },44 333745 )46 );47 // Above the limit of 60 bytes48 responses.push(49 helpers.sendServerRequest(50 `/${name}`,51 'GET',52 400,53 JSON.stringify( { [formDataKey]: formDataValue + formDataValue + formDataValue } ),54 { 'content-type': 'application/json' },55 333756 )57 );58 responses.push(59 helpers.sendServerRequest(60 `/${name}`,61 'GET',62 400,63 JSON.stringify( { [formDataKey]: formDataValue } ),64 { 'content-type': 'application/*' },65 333766 )67 );68 responses.push(69 helpers.sendServerRequest(70 `/${name}`,71 'GET',72 400,73 JSON.stringify( { [formDataKey]: formDataValue } ),74 { 'content-type': '*/*' },75 333776 )77 );78 responses.push(79 helpers.sendServerRequest(80 `/${name}`,81 'GET',82 400,83 JSON.stringify( { [formDataKey]: formDataValue } ),84 { 'content-type': 'json' },85 333786 )87 );88 responses.push(89 helpers.sendServerRequest(90 `/${name}`,91 'GET',92 400,93 JSON.stringify( { [formDataKey]: formDataValue } ),94 { 'content-type': '*' },95 333796 )97 );98 responses.push(99 helpers.sendServerRequest(100 `/${name}`,101 'GET',102 400,103 JSON.stringify( { [formDataKey]: formDataValue } ),104 {},105 3337106 )107 );108 responses.push(109 helpers.sendServerRequest(110 `/${name}`,111 'GET',112 400,113 '{wrongJson',114 {},115 3337116 )117 );118 const server = app.listen( 3337, () => {119 Promise.all( responses ).then(() => {120 server.close();121 done();122 }).catch( done );123 } );124 }125});126test({127 message : 'Server.test.er_body_parser_json.does.not.parse.anything.but.application/json.setting.options',128 test : ( done ) => {129 const name = 'testErJsonBodyParserParsesApplicationJson';130 const formDataKey = 'testErJsonBodyParserParsesApplicationJson';131 const formDataValue = 'value';132 const app = new Server();133 app.er_body_parser_json.setOptions({134 maxPayloadLength: 60135 });136 app.apply( app.er_body_parser_json );137 app.get( `/${name}`, ( event ) => {138 if (139 typeof event.body === 'undefined'140 || typeof event.body[formDataKey] === 'undefined'141 || ! event.body[formDataKey].includes( formDataValue )142 ) {143 event.sendError( 'Body was not parsed', 400 );144 }145 event.send( 'ok' );146 } );147 const responses = [];148 responses.push(149 helpers.sendServerRequest(150 `/${name}`,151 'GET',152 200,153 JSON.stringify( { [formDataKey]: formDataValue } ),154 { 'content-type': 'application/json' },155 3337156 )157 );158 responses.push(159 helpers.sendServerRequest(160 `/${name}`,161 'GET',162 200,163 JSON.stringify( { [formDataKey]: formDataValue } ),164 { ['content-type'.toUpperCase()]: 'application/json' },165 3337166 )167 );168 // Above the limit of 60 bytes169 responses.push(170 helpers.sendServerRequest(171 `/${name}`,172 'GET',173 400,174 JSON.stringify( { [formDataKey]: formDataValue + formDataValue + formDataValue } ),175 { 'content-type': 'application/json' },176 3337177 )178 );179 responses.push(180 helpers.sendServerRequest(181 `/${name}`,182 'GET',183 400,184 JSON.stringify( { [formDataKey]: formDataValue } ),185 { 'content-type': 'application/*' },186 3337187 )188 );189 responses.push(190 helpers.sendServerRequest(191 `/${name}`,192 'GET',193 400,194 JSON.stringify( { [formDataKey]: formDataValue } ),195 { 'content-type': '*/*' },196 3337197 )198 );199 responses.push(200 helpers.sendServerRequest(201 `/${name}`,202 'GET',203 400,204 JSON.stringify( { [formDataKey]: formDataValue } ),205 { 'content-type': 'json' },206 3337207 )208 );209 responses.push(210 helpers.sendServerRequest(211 `/${name}`,212 'GET',213 400,214 JSON.stringify( { [formDataKey]: formDataValue } ),215 { 'content-type': '*' },216 3337217 )218 );219 responses.push(220 helpers.sendServerRequest(221 `/${name}`,222 'GET',223 400,224 JSON.stringify( { [formDataKey]: formDataValue } ),225 {},226 3337227 )228 );229 responses.push(230 helpers.sendServerRequest(231 `/${name}`,232 'GET',233 400,234 '{wrongJson',235 {},236 3337237 )238 );239 const server = app.listen( 3337, () => {240 Promise.all( responses ).then(() => {241 server.close();242 done();243 }).catch( done );244 } );245 }246});247test({248 message : 'Server.test.er_body_parser_json.does.not.parse.above.the.maxPayload.if.strict',249 test : ( done ) => {250 const name = 'testErJsonBodyParserParsesApplicationJson';251 const formDataKey = 'testErJsonBodyParserParsesApplicationJson';252 const formDataValue = 'value';253 const app = new Server();254 app.apply( app.er_body_parser_json, { maxPayloadLength: 60, strict: true } );255 app.get( `/${name}`, ( event ) => {256 assert.deepStrictEqual( event.body, {} );257 assert.deepStrictEqual( event.rawBody, {} );258 event.send( 'ok' );259 } );260 const responses = [];261 responses.push(262 helpers.sendServerRequest(263 `/${name}`,264 'GET',265 200,266 JSON.stringify( { [formDataKey]: formDataValue + formDataValue + formDataValue } ),267 { 'content-type': 'application/json' },268 3338269 )270 );271 const server = app.listen( 3338, () => {272 Promise.all( responses ).then(() => {273 server.close();274 done();275 }).catch( done );276 } );277 }278});279test({280 message : 'Server.test.er_body_parser_form.parser.above.the.maxPayload.if.not.strict',281 test : ( done ) => {282 const name = 'testErBodyParserFormParsesApplicationXWwwFormUrlencoded';283 const formDataKey = 'testErBodyParserFormParsesApplicationXWwwFormUrlencoded';284 const formDataValue = 'value';285 const app = new Server();286 app.apply( app.er_body_parser_form, { maxPayloadLength: 60, strict: false } );287 app.get( `/${name}`, ( event ) => {288 if (289 typeof event.body === 'undefined'290 || typeof event.body[formDataKey] === 'undefined'291 || ! event.body[formDataKey].includes( formDataValue )292 ) {293 event.sendError( 'Body was not parsed', 400 );294 }295 event.send( 'ok' );296 } );297 const responses = [];298 responses.push(299 helpers.sendServerRequest(300 `/${name}`,301 'GET',302 400,303 querystring.stringify( { [formDataKey]: formDataValue } ),304 { 'content-type': 'application/x-www-form-urlencoded' },305 3339306 )307 );308 responses.push(309 helpers.sendServerRequest(310 `/${name}`,311 'GET',312 400,313 querystring.stringify( { [formDataKey]: formDataValue + formDataValue + formDataValue } ),314 { 'content-type': 'application/x-www-form-urlencoded' },315 3339316 )317 );318 responses.push(319 helpers.sendServerRequest(320 `/${name}`,321 'GET',322 400,323 querystring.stringify( { [formDataKey]: formDataValue } ),324 { 'content-type' : '' },325 3339326 )327 );328 responses.push(329 helpers.sendServerRequest(330 `/${name}`,331 'GET',332 400,333 querystring.stringify( { [formDataKey]: formDataValue } ),334 { 'content-type': 'application/*' },335 3339336 )337 );338 responses.push(339 helpers.sendServerRequest(340 `/${name}`,341 'GET',342 400,343 querystring.stringify( { [formDataKey]: formDataValue } ),344 { 'content-type': '*' },345 3339346 )347 );348 const server = app.listen( 3339, () => {349 Promise.all( responses ).then(() => {350 server.close();351 done();352 }).catch( done );353 } );354 }355});356test({357 message : 'Server.test.er_body_parser_form.does.parse.not.above.the.maxPayload.if.strict',358 test : ( done ) => {359 const name = 'testErBodyParserFormParsesApplicationXWwwFormUrlencoded';360 const formDataKey = 'testErBodyParserFormParsesApplicationXWwwFormUrlencoded';361 const formDataValue = 'value';362 const app = new Server();363 app.apply( app.er_body_parser_form, { maxPayloadLength: 60, strict: true } );364 app.get( `/${name}`, ( event ) => {365 assert.deepStrictEqual( event.body, {} );366 event.send( 'ok' );367 } );368 const responses = [];369 responses.push(370 helpers.sendServerRequest(371 `/${name}`,372 'GET',373 200,374 querystring.stringify( { [formDataKey]: formDataValue + formDataValue + formDataValue } ),375 { 'content-type': 'application/x-www-form-urlencoded' },376 3340377 )378 );379 const server = app.listen( 3340, () => {380 Promise.all( responses ).then(() => {381 server.close();382 done();383 }).catch( done );384 } );385 }386});387test({388 message : 'Server.test.er_body_parser_multipart.parses.only.multipart/form-data',389 test : ( done ) => {390 const name = 'testErBodyParserMultipartParsesMultipartFormData';391 const multipartDataCR = fs.readFileSync( path.join( __dirname, './fixture/body_parser/multipart/multipart_data_CR' ) );392 const multipartDataCRLF = fs.readFileSync( path.join( __dirname, './fixture/body_parser/multipart/multipart_data_CRLF' ) );393 const multipartDataLF = fs.readFileSync( path.join( __dirname, './fixture/body_parser/multipart/multipart_data_LF' ) );394 const tempDir = path.join( __dirname, `./fixture/body_parser/multipart` );395 const app = new Server();396 app.apply( app.er_body_parser_multipart, { tempDir } );397 app.get( `/${name}`, ( event ) => {398 if (399 typeof event.body === 'undefined'400 || typeof event.body.$files === 'undefined'401 || event.body.text !== 'text default'402 || event.body.$files.length !== 2403 || event.body.$files[0].type !== 'file'404 || event.body.$files[0].size !== 17405 || event.body.$files[0].contentType !== 'text/plain'406 || event.body.$files[0].name !== 'a.txt'407 || ! event.body.$files[0].path.includes( tempDir )408 || event.body.$files[1].type !== 'file'409 || event.body.$files[1].size !== 48410 || event.body.$files[1].contentType !== 'text/html'411 || event.body.$files[1].name !== 'a.html'412 || ! event.body.$files[1].path.includes( tempDir )413 ) {414 event.sendError( 'Body was not parsed', 400 );415 }416 event.send( 'ok' );417 } );418 const responses = [];419 responses.push(420 helpers.sendServerRequest(421 `/${name}`,422 'GET',423 200,424 multipartDataCRLF,425 { 'content-type': 'multipart/form-data; boundary=---------------------------9051914041544843365972754266' },426 3341427 )428 );429 responses.push(430 helpers.sendServerRequest(431 `/${name}`,432 'GET',433 200,434 multipartDataCR,435 { 'content-type': 'multipart/form-data; boundary=---------------------------9051914041544843365972754266' },436 3341437 )438 );439 responses.push(440 helpers.sendServerRequest(441 `/${name}`,442 'GET',443 200,444 multipartDataLF,445 { 'content-type': 'multipart/form-data; boundary=---------------------------9051914041544843365972754266' },446 3341447 )448 );449 responses.push(450 helpers.sendServerRequest(451 `/${name}`,452 'GET',453 400,454 multipartDataCRLF,455 { 'content-type': 'multipart/form-data; boundary=---------------------------9041544843365972754266' },456 3341457 )458 );459 responses.push(460 helpers.sendServerRequest(461 `/${name}`,462 'GET',463 500,464 multipartDataCRLF,465 { 'content-type': 'multipart/form-data' },466 3341467 )468 );469 responses.push(470 helpers.sendServerRequest(471 `/${name}`,472 'GET',473 400,474 multipartDataCRLF,475 {},476 3341477 )478 );479 responses.push(480 helpers.sendServerRequest(481 `/${name}`,482 'GET',483 400,484 '',485 { 'content-type': 'multipart/form-data; boundary=---------------------------9051914041544843365972754266' },486 3341487 )488 );489 const server = app.listen( 3341, () => {490 Promise.all( responses ).then(() => {491 setTimeout(() => {492 server.close();493 done();494 }, 500 );495 }).catch( done );496 } );497 }498});499test({500 message : 'Server.test.er_body_parser_multipart.will.not.parse.if.limit.is.reached',501 test : ( done ) => {502 const name = 'testErBodyParserMultipartParsesMultipartFormData';503 const multipartData = fs.readFileSync( path.join( __dirname, `./fixture/body_parser/multipart/multipart_data_CRLF` ) );504 const tempDir = path.join( __dirname, './fixture/body_parser/multipart' );505 const app = new Server();506 app.apply( app.er_body_parser_multipart, { tempDir, maxPayload: 10 } );507 app.get( `/${name}`, ( event ) => {508 event.send( 'ok' );509 } );510 const responses = [];511 responses.push(512 helpers.sendServerRequest(513 `/${name}`,514 'GET',515 500,516 multipartData,517 { 'content-type': 'multipart/form-data; boundary=---------------------------9051914041544843365972754266' },518 3342519 )520 );521 const server = app.listen( 3342, () => {522 Promise.all( responses ).then(() => {523 setTimeout(() => {524 server.close();525 done();526 }, 500 );527 }).catch( done );528 } );529 }530});531test({532 message : 'Server.test.er_body_parser.setOptions.without.anything',533 test : ( done ) => {534 const app = new Server();535 app.apply( app.er_body_parser_json, { maxPayloadLength: 1 } );536 assert.deepStrictEqual( app.er_body_parser_json.options, { maxPayloadLength: 1 } );537 app.er_body_parser_json.setOptions();538 app.apply( app.er_body_parser_json );539 assert.deepStrictEqual( app.er_body_parser_json.options, {} );540 done();541 }542});543test({544 message : 'Server.test.er_body_parser.when.event.body.already.exists.does.not.parse',545 test : ( done ) => {546 const name = 'testErBodyParserDoesNotParseIfBodyExists';547 const app = new Server();548 app.get( `/${name}`, ( event ) => {549 event.body = 'TEST';550 event.rawBody = 'TEST';551 event.next();552 });553 app.apply( app.er_body_parser_json );554 app.get( `/${name}`, ( event ) => {555 event.send( { body: event.body, rawBody: event.rawBody } );556 });557 const responses = [];558 responses.push(559 helpers.sendServerRequest(560 `/${name}`,561 'GET',562 200,563 JSON.stringify( { key: 123 } ),564 { 'content-type': 'application/json' },565 4300,566 JSON.stringify( { body: 'TEST', rawBody: 'TEST' } )567 )568 );569 const server = app.listen( 4300, () => {570 Promise.all( responses ).then(() => {571 server.close();572 done();573 }).catch( done );574 });575 }576});577test({578 message : 'Server.test.er_body_parser.when.parsed.data.is.invalid',579 test : ( done ) => {580 const name = 'testErBodyParserIfInvalidParserData';581 const app = new Server();582 const MockBodyParser = Mock( JsonBodyParser );583 Mocker( MockBodyParser, {584 method : 'parse',585 shouldReturn : () => {586 return new Promise(( resolve ) => {587 resolve( 'wrongData' );588 });589 }590 });591 Mocker( MockBodyParser, {592 method : 'supports',593 shouldReturn : () => {594 return true;595 }596 });597 app.apply( new BodyParserPlugin( MockBodyParser, 'er_test' ) );598 app.get( `/${name}`, ( event ) => {599 event.send( { body: event.body, rawBody: event.rawBody } );600 });601 const responses = [];602 responses.push(603 helpers.sendServerRequest(604 `/${name}`,605 'GET',606 200,607 '',608 { 'content-type': '*/*' },609 4301,610 JSON.stringify( { body: {}, rawBody: {} } )611 )612 );613 const server = app.listen( 4301, () => {614 Promise.all( responses ).then(() => {615 server.close();616 done();617 }).catch( done );618 });619 }620});621test({622 message : 'Server.test.er_body_parser_raw.handles.anything',623 test : ( done ) => {624 const name = 'testErBodyParserRaw';625 const app = new Server();626 app.apply( app.er_body_parser_raw, { maxPayloadLength: 15 } );627 app.get( `/${name}`, ( event ) => {628 event.send( { body: event.body, rawBody: event.rawBody } );629 } );630 const responses = [];631 responses.push(632 helpers.sendServerRequest(633 `/${name}`,634 'GET',635 200,636 'SomeRandomData',637 { 'content-type': 'somethingDoesntMatter' },638 3902,639 JSON.stringify( { body: 'SomeRandomData', rawBody: 'SomeRandomData' } )640 )641 );642 // Returns 200 and an empty body due to limit reached643 responses.push(644 helpers.sendServerRequest(645 `/${name}`,646 'GET',647 200,648 'SomeRandomDataSomeRandomData',649 { 'content-type': 'somethingDoesntMatter' },650 3902,651 JSON.stringify( { body: {}, rawBody: {} } )652 )653 );654 const server = app.listen( 3902, () => {655 Promise.all( responses ).then(() => {656 setTimeout(() => {657 server.close();658 done();659 }, 500 );660 }).catch( done );661 } );662 }...
FollowUpList.js
Source:FollowUpList.js
1/**2 * é访å表3 * 4 * @author zhouw5 */6$package("chis.application.fhr.script");7$import("chis.script.BizSimpleListView", "chis.script.EHRView",8 "chis.application.fhr.script.AllVisitModels");9chis.application.fhr.script.FollowUpList = function(cfg) {10 cfg.westWidth = 150;11 chis.application.fhr.script.FollowUpList.superclass.constructor.apply(this,12 [cfg]);13 Ext.apply(this, chis.application.fhr.script.AllVisitModels)14}15Ext.extend(chis.application.fhr.script.FollowUpList,16 chis.script.BizSimpleListView, {17 loadData : function() {18 // this.requestData.cnd||19 var formDataValue = this.cndField.getValue();20 var toDataValue = this.cndField1.getValue();21 if (this.requestData.formDataValue) {22 delete this.requestData.formDataValue;23 }24 if (this.requestData.toDataValue) {25 delete this.requestData.toDataValue;26 }27 if (formDataValue != null && formDataValue !== ""28 && formDataValue !== 0) {29 formDataValue = formDataValue.format('Y-m-d');30 this.requestData.formDataValue = formDataValue;31 }32 if (toDataValue != null && toDataValue !== ""33 && toDataValue != 0) {34 toDataValue = toDataValue.format('Y-m-d');35 this.requestData.toDataValue = toDataValue;36 }37 this.requestData.cnd = ["eq", ["$", "familyId"],38 ["s", this.exContext.args.initDataId || '']];39 chis.application.fhr.script.FollowUpList.superclass.loadData40 .call(this);41 },42 onDblClick : function(){43 this.doUpdateInfo();44 },45 doUpdateInfo : function() {46 var r = this.getSelectedRecord();47 if (r == null) {48 return;49 }50 this.empiId = r.get("empiId");51 this.recordId = r.get("recordId");52 this.visitId = r.get("visitId");53 var businessType = r.get("businessType");54 // åç§ä¸æ¡£é访çæ
åµ55 // é«è¡å//HypertensionRecordListView56 if (businessType == "1") {57 this.recordStatus = r.get("status");58 var result = util.rmi.miniJsonRequestSync({59 serviceId : "chis.hypertensionService",60 serviceAction : "checkUpGroupRecord",61 method : "execute",62 empiId : this.empiId63 });64 if (result.code != 200) {65 this.processReturnMsg(result.code, result.msg);66 return null;67 }68 if (result.json.haveRecord) {69 this.activeTab = 2;70 } else {71 this.activeTab = 1;72 }73 this.showEhrViewWinGXY();74 }75 // ç³å°¿ç
é访//DiabetesRecordListView76 if (businessType == "2") {77 this.activeTab = 2;78 this.showEhrViewWinTNB();79 }80 if (businessType == "3") {//èçæ¬è¿ç¤æ¨¡åï¼è¯¥ç¼å·å·²ç»æ ç¨81 //æ 82 }83 // è年人 OldPeopleVisitList.js84 if (businessType == "4") {85 this.showModuleLNR(r.data);86 }87 // å¿ç«¥è¯¢é®88 if (businessType == "5") {89 this.activeTab = 2;90 this.birthday = r.get("birthday");91 this.showEHRViewChildrenCheck(this.empiId);92 }93 if(businessType == "6"){//å¿ç«¥ä½æ ¼æ£æ¥94 this.activeTab = 3;95 this.birthday = r.get("birthday");96 this.showEHRViewChildrenCheck(this.empiId);97 }98 if(businessType == "7"){//ä½å¼±å¿ç«¥é访99 this.activeTab = 1;100 this.showEhrViewDebilityChildrenVisit();101 }102 // åå¦é访103 if (businessType == "8") {104 this.showModuleYFSF(this.empiId,this.recordId,this.visitId);105 }106 if(businessType == "9"){//åå¦é«å±é访107 //æ缺é·ï¼ä¸å¡ä¸æï¼108 }109 // ç²¾ç¥é访 TumourHighRiskVisitView.js//å·²ç»å¼å¥½äº110 if (businessType == "10") {111 var data = {};112 data.empiId = r.get("empiId");113 data.manaDoctorId = r.get("manaDoctorId");114 data.op = "update";115 this.onEmpiSelected(data);116 }117 if(businessType == "11"){//é«è¡å询é®118 //æ 119 }120 if(businessType == "12"){//ç³å°¿ç
çä¼¼é访121 //æ 122 }123 if(businessType == "13"){//é«è¡åé«å±é访124 this.ShowEHRViewHypertensionRiskVisit(this.empiId);125 }126 // 离ä¼å¹²é¨é访 rvc.app127 if (businessType == "14") {128 this.showModuleLXGB(this.empiId);129 }130 if(businessType == "15"){//è¿ç¤é«å±é访131 this.empiId = r.get("empiId");132 this.recordStatus = r.get("status");133 this.highRiskType = r.get("highRiskType")||'';134 this.activeTab = 2;135 var planId = r.get("planId");136 this.THRID = r.get("recordId");137 if(this.empiId == ''){138 MyMessageTip.msg("æ示","计åä¸empiId为空ï¼",true);139 return;140 }141 this.showEhrViewWinTHRVisit(planId);142 }143 if(businessType == "16"){//è¿ç¤ç°æ£é访144 this.empiId = r.get("empiId");145 this.TPRCID = r.get("recordId");146 this.highRiskType = r.get("highRiskType") ||'';147 var dieFlag = r.get("dieFlag");148 this.recordStatus = r.get("status");149 this.activeTab = 1;150 this.showEhrViewWinTPRVisit();151 }152 if(businessType == "17"){//ç³å°¿ç
é«å±ç®¡ç153 this.ShowEHRViewDiabetesOGTTVisit(this.empiId);154 }155 },156 getCndBar : function(items) {157 var fields = [];158 if (!this.enableCnd) {159 return []160 }161 for (var i = 0; i < items.length; i++) {162 var it = items[i]163 if (!(it.queryable == "true")) {164 continue165 }166 fields.push({167 value : i,168 text : it.alias169 })170 }171 if (fields.length == 0) {172 return fields;173 }174 var store = new Ext.data.JsonStore({175 fields : ['value', 'text'],176 data : fields177 });178 var combox = new Ext.form.ComboBox({179 store : store,180 valueField : "value",181 displayField : "text",182 mode : 'local',183 triggerAction : 'all',184 emptyText : 'éæ©æ¥è¯¢å段',185 selectOnFocus : true,186 editable : false,187 width : 120,188 hidden : true189 });190 combox.on("select", this.onCndFieldSelect, this)191 this.cndFldCombox = combox192 var curDate = Date.parseDate(this.mainApp.serverDate,'Y-m-d');193 var startDateValue = new Date(curDate.getFullYear(),0,1);194 var cndField = new Ext.form.DateField({195 width : 100,196 selectOnFocus : true,197 id : 'fromData',198 name : "fromData",199 xtype : 'datefield',200 emptyText : "请éæ©æ¥æ",201 value : startDateValue,202 format : 'Y-m-d'203 })204 var cndField1 = new Ext.form.DateField({205 width : 100,206 selectOnFocus : true,207 id : 'toData',208 name : "toData",209 xtype : 'datefield',210 emptyText : "请éæ©æ¥æ",211 value : curDate,212 format : 'Y-m-d'213 })214 var texth = new Ext.form.Label({215 xtype : "label",216 forId : "window",217 text : "â"218 });219 var texth1 = new Ext.form.Label({220 xtype : "label",221 forId : "window",222 text : "计åå¼å§æ¥æ:"223 });224 this.texth1 = texth1;225 this.texth = texth;226 this.cndField = cndField227 this.cndField1 = cndField1228 var queryBtn = new Ext.Toolbar.Button({229 iconCls : "query"230 })231 this.queryBtn = queryBtn;232 queryBtn.on("click", this.doCndQuery, this);233 return [texth1, " ", cndField, texth,234 cndField1, queryBtn, " "]235 },236 doCndQuery : function() {237 var formDataValue = this.cndField.getValue();238 var toDataValue = this.cndField1.getValue();239 var data = {};240 if (this.requestData.formDataValue) {241 delete this.requestData.formDataValue;242 }243 if (this.requestData.toDataValue) {244 delete this.requestData.toDataValue;245 }246 if (formDataValue != null && formDataValue !== ""247 && formDataValue !== 0) {248 formDataValue = formDataValue.format('Y-m-d');249 this.requestData.formDataValue = formDataValue;250 }251 if (toDataValue != null && toDataValue !== ""252 && toDataValue != 0) {253 toDataValue = toDataValue.format('Y-m-d');254 this.requestData.toDataValue = toDataValue;255 }256 this.requestData.cnd = this.requestData.cnd257 || ["eq", ["$", "familyId"],258 ["s", this.exContext.args.initDataId || '']];259 chis.application.fhr.script.FollowUpList.superclass.loadData260 .call(this);261 },262 onEmpiSelected : function(data) {263 this.empiId = data.empiId;264 if (data.op && data.op == "update") {265 var manaDoctorId = data.manaDoctorId;266 if (manaDoctorId != this.mainApp.uid && !this.mainApp.fd267 && this.mainApp.uid != 'system') {268 Ext.MessageBox.alert("æ示", "é该精ç¥ç
æ¡£æ¡è´£ä»»å»çï¼æ²¡ææéæ¥çï¼");269 return;270 }271 if (this.mainApp.fd && manaDoctorId != this.mainApp.fd272 && manaDoctorId != this.mainApp.uid) {273 Ext.MessageBox274 .alert("æ示", "é该精ç¥ç
æ¡£æ¡è´£ä»»å»çæç¸å
³å»çå©çï¼æ²¡ææéæ¥çï¼");275 return;276 }277 }278 // æ¾ç¤ºEHRView279 this.showEHRViewMuleJSB();280 }...
profile.component.ts
Source:profile.component.ts
1import { Component, OnInit, ElementRef } from '@angular/core';2import { UserService } from 'src/app/service/user.service';3import { Project } from 'src/app/models/Project';4import { ProjectService } from 'src/app/service/project.service';5import { ResTpl } from 'src/app/models/ResTpl';6import { User } from 'src/app/models/User';7import { ActivatedRoute, Router } from '@angular/router';8import { FormGroup, FormBuilder, AbstractControl, Validators, ValidationErrors } from '@angular/forms';9import { NzModalService, NzMessageService, UploadFile } from 'ng-zorro-antd';10import { SkillService } from 'src/app/service/skill.service';11import { Observable, Observer } from 'rxjs';12import { UploadService } from 'src/app/service/upload.service';13import { map } from 'rxjs/operators';14@Component({15 selector: 'app-profile',16 templateUrl: './profile.component.html',17 styleUrls: ['./profile.component.scss', '../../project/list/list.component.scss']18})19export class ProfileComponent implements OnInit {20 FormData1: FormGroup;21 FormData2 = this.fb.group({22 oldPwd: [''],23 pwd1: [''],24 pwd2: ['']25 });26 projects: Project[];27 userInfo: User;28 skills = [];29 loading = false;30 avatarUrl: string;31 get name(): AbstractControl {32 return this.FormData1.get('name')33 }34 get phone(): AbstractControl {35 return this.FormData1.get('phone')36 }37 get skill(): AbstractControl {38 return this.FormData1.get('skill')39 }40 constructor(41 public userSrv: UserService,42 private projectSrv: ProjectService,43 private route: ActivatedRoute,44 private fb: FormBuilder,45 private modal: NzModalService,46 private skillSrv: SkillService,47 private router: Router,48 private message: NzMessageService,49 private elementRef: ElementRef,50 private uploadSrv: UploadService,51 ) { }52 ngOnInit() {53 this.getUserInfo()54 }55 // è·åç¨æ·ä¿¡æ¯56 getUserInfo() {57 this.route.params.subscribe(params => {58 const id = params['_id']59 this.userSrv.getUserInfo(id).subscribe((resTpl: ResTpl) => {60 if (resTpl.code === 0) {61 this.userInfo = resTpl.data62 this.handleGetProjects()63 // æ¯èªå·±ï¼åå§å表å64 if (id == this.userSrv.userInfo._id) {65 this.initForm()66 }67 }68 })69 })70 }71 // è·åå
¨é¨é¡¹ç®72 handleGetProjects() {73 this.projectSrv.getProjects().subscribe(74 (resTpl: ResTpl) => {75 if (resTpl.code === 0) {76 this.projects = resTpl.data.filter(item => {77 // æªådesc78 item.desc = item.desc.substr(0, 100) + '...'79 const user_id = this.userInfo._id80 if (item.dev_user) {81 return item.demand_user._id == user_id || item.dev_user._id == user_id82 } else {83 return item.demand_user._id == user_id84 }85 }).reverse()86 }87 }88 )89 }90 // -------------å¦ææ¯èªå·±ä¸»é¡µåå¯æä½-----------91 // 表ååå§å92 initForm() {93 this.handleGetSkills()94 const skillValue = this.userInfo.skill.map(item => item.id)95 this.FormData1 = this.fb.group({96 skillValue: [skillValue],97 skill: [[]],98 desc: [this.userInfo.profile.desc],99 name: [this.userInfo.profile.name, [100 Validators.required,101 Validators.maxLength(10)102 ]],103 phone: [this.userInfo.profile.phone, [104 Validators.required,105 Validators.pattern(/^1(3|4|5|6|7|8|9)\d{9}$/)106 ]],107 })108 }109 // è·åå
¨é¨skill110 handleGetSkills() {111 this.skillSrv.getSkills().subscribe((res: ResTpl) => {112 this.skills = res.data113 })114 }115 // æ交116 submitForm1() {117 const formDataValue = this.FormData1.value118 // å¤çskill119 formDataValue.skill = []120 formDataValue.skillValue.forEach(sv => {121 this.skills.forEach(item => {122 if (item.id == sv) {123 formDataValue.skill.push(item)124 }125 });126 });127 this.userInfo.profile.name = formDataValue.name128 this.userInfo.profile.phone = formDataValue.phone129 this.userInfo.profile.desc = formDataValue.desc130 this.userInfo.skill = formDataValue.skill131 console.log('formDataValue: ', formDataValue);132 this.userSrv.updateUserInfo(this.userInfo).subscribe(res => {133 if (res.code === 0) {134 this.modal.info({135 nzContent: 'ä¿®æ¹æå'136 })137 this.getUserInfo()138 }139 })140 }141 // ä¿®æ¹å¯ç 142 submitForm2() {143 const form = this.FormData2.value144 if (form.pwd1 !== form.pwd2) {145 return this.modal.warning({146 nzContent: '两次å¯ç ä¸ä¸è´'147 })148 }149 this.userSrv.updatePassword(form.oldPwd, form.pwd1).subscribe(150 (res: ResTpl) => {151 if (res.code === 0) {152 this.modal.info({153 nzContent: 'ä¿®æ¹æåï¼è¯·éæ°ç»å½',154 nzOnOk: () => {155 localStorage.removeItem('ph-token')156 this.router.navigate(['/user/login'])157 }158 })159 }160 }161 )162 }163 // éæ©å¾ç164 handleChooseImg() {165 const input = this.elementRef.nativeElement.querySelector(`#avatar-input`)166 input.click()167 }168 // 头åä¸ä¼ 169 uploadImg(e): void {170 const input = this.elementRef.nativeElement.querySelector(`#avatar-input`)171 const file = e.target.files[0]172 console.log('file: ', file);173 this.uploadSrv.uploadImg(file).pipe(174 map((res: ResTpl) => {175 if (res.code === 0) return res.data176 })177 ).subscribe(path => {178 // 设置头åè·¯å¾179 this.userInfo.profile.avatar = '/api/' + path180 this.userSrv.updateUserInfo(this.userInfo).subscribe(181 (res: ResTpl) => {182 if (res.code === 0) {183 // æ¸
空input184 if (input) input.value = '';185 this.message.info('头åæ´æ°æå')186 }187 }188 )189 })190 }...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 wpt.getTestStatus(data.data.testId, function(err, data) {5 if (err) return console.error(err);6 wpt.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log(data);9 });10 });11});
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3}, function(err, data) {4 if (err) return console.error(err);5 console.log('Test Results: %j', data.data);6 wpt.getTestResults(data.data.testId, function(err, data) {7 if (err) return console.error(err);8 console.log('Test Results: %j', data.data);9 });10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13}, function(err, data) {14 if (err) return console.error(err);15 console.log('Test Results: %j', data.data);16 wpt.getTestResults(data.data.testId, function(err, data) {17 if (err) return console.error(err);18 console.log('Test Results: %j', data.data);19 });20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23}, function(err, data) {24 if (err) return console.error(err);25 console.log('Test Results: %j', data.data);26 wpt.getTestResults(data.data.testId, function(err, data) {27 if (err) return console.error(err);28 console.log('Test Results: %j', data.data);29 });30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');33wpt.runTest('
Using AI Code Generation
1var wpt = require('wpt.js');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getLocations(function(err, data) {4 if (err) return console.log(err);5 console.log(data);6});7### WebPageTest(host, apiKey)8### .getLocations(callback)9### .getTesters(callback)10### .getTestStatus(testId, callback)11### .getTestResults(testId, callback)12### .getTestResultsByUrl(url, callback)13### .getTestResultsByLocation(url, location, callback)14### .getTestResultsByLocationAndConnectivity(url, location, connectivity, callback)15### .getTestResultsByLocationAndConnectivityAndBrowser(url, location, connectivity, browser, callback)
Using AI Code Generation
1var formDataValue = wpt.formDataValue;2var data = formDataValue("data");3var data2 = formDataValue("data2");4var data3 = formDataValue("data3");5var data4 = formDataValue("data4");6var data5 = formDataValue("data5");7var data6 = formDataValue("data6");8var data7 = formDataValue("data7");9var data8 = formDataValue("data8");10var data9 = formDataValue("data9");11var data10 = formDataValue("data10");12var data11 = formDataValue("data11");13var data12 = formDataValue("data12");14var data13 = formDataValue("data13");15var data14 = formDataValue("data14");16var data15 = formDataValue("data15");17var data16 = formDataValue("data16");18var data17 = formDataValue("data17");19var data18 = formDataValue("data18");20var data19 = formDataValue("data19");21var data20 = formDataValue("data20");22var data21 = formDataValue("data21");23var data22 = formDataValue("data22");24var data23 = formDataValue("data23");25var data24 = formDataValue("data24");26var data25 = formDataValue("data25");27var data26 = formDataValue("data26");28var data27 = formDataValue("data27");29var data28 = formDataValue("data28");30var data29 = formDataValue("data29");31var data30 = formDataValue("data30");32var data31 = formDataValue("data31");33var data32 = formDataValue("data32");34var data33 = formDataValue("data33");35var data34 = formDataValue("data34");36var data35 = formDataValue("data35");37var data36 = formDataValue("data36");38var data37 = formDataValue("data37");39var data38 = formDataValue("data38");40var data39 = formDataValue("data39");41var data40 = formDataValue("data40");42var data41 = formDataValue("data41");43var data42 = formDataValue("data42");44var data43 = formDataValue("data43");45var data44 = formDataValue("data44");46var data45 = formDataValue("data45");47var data46 = formDataValue("data46");48var data47 = formDataValue("data47");49var data48 = formDataValue("data48");50var data49 = formDataValue("data49");
Using AI Code Generation
1var wptdriver = require('wptdriver');2var driver = new wptdriver.Driver();3driver.findElement(wptdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(wptdriver.By.name('btnG')).click();5driver.wait(function() {6 return driver.getTitle().then(function(title) {7 return title === 'webdriver - Google Search';8 });9}, 1000);10driver.quit();
Using AI Code Generation
1var formElement = new wptbFormElement();2var formDataValue = formElement.formDataValue( 'test' );3console.log( formDataValue );4var formElement = new wptbFormElement();5var formDataValue = formElement.formDataValue( 'test', 'test' );6console.log( formDataValue );7var formElement = new wptbFormElement();8var formDataValue = formElement.formDataValue( 'test', 'test', 'test' );9console.log( formDataValue );10var formElement = new wptbFormElement();11var formDataValue = formElement.formDataValue( 'test', 'test', 'test', 'test' );12console.log( formDataValue );13var formElement = new wptbFormElement();14var formDataValue = formElement.formDataValue( 'test', 'test', 'test', 'test', 'test' );15console.log( formDataValue );16var formElement = new wptbFormElement();17var formDataValue = formElement.formDataValue( 'test', 'test', 'test', 'test', 'test', 'test' );18console.log( formDataValue );19var formElement = new wptbFormElement();20var formDataValue = formElement.formDataValue( 'test', 'test', 'test', 'test', 'test', 'test', 'test' );21console.log( formDataValue );22var formElement = new wptbFormElement();23var formDataValue = formElement.formDataValue( 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test' );24console.log( formDataValue );
Using AI Code Generation
1function formDataValue() {2 var myform = document.forms[0];3 var myValue = wpt.formDataValue(myform, "myText");4 wpt.log(myValue);5}6function formDataValues() {7 var myform = document.forms[0];8 var myValues = wpt.formDataValues(myform);9 var myJSON = JSON.stringify(myValues);10 wpt.log(myJSON);11}12function formData() {13 var myform = document.forms[0];14 var myValues = wpt.formData(myform);15 var myJSON = JSON.stringify(myValues);16 wpt.log(myJSON);17}18function formData2() {19 var myform = document.forms[0];20 var myValues = wpt.formData(myform, true);21 var myJSON = JSON.stringify(myValues);22 wpt.log(myJSON);23}24function formData3() {25 var myform = document.forms[0];26 var myValues = wpt.formData(myform, true, true);27 var myJSON = JSON.stringify(myValues);28 wpt.log(myJSON);29}30function formData4() {31 var myform = document.forms[0];32 var myValues = wpt.formData(myform, true, true, true);33 var myJSON = JSON.stringify(myValues);34 wpt.log(myJSON);35}36function formData5() {37 var myform = document.forms[0];38 var myValues = wpt.formData(myform, true, true, true, true);39 var myJSON = JSON.stringify(myValues);40 wpt.log(myJSON);41}
Using AI Code Generation
1var form = wpt.formDataValue("form1");2var input = form.input1;3var data = {4};5wpt.log("data: " + JSON.stringify(data));6wpt.log("data.input1: " + data.input1);7wpt.log("data.input1.length: " + data.input1.length);8wpt.log("data.input1[0]: " + data.input1[0]);9wpt.log("data.input1[0].name: " + data.input1[0].name);10wpt.log("data.input1[0].value: " + data.input1[0].value);11var form = wpt.formData("form1");12var input = form.input1;13var data = {14};15wpt.log("data: " + JSON.stringify(data));16wpt.log("data.input1: " + data.input1);17wpt.log("data.input1.length: " + data.input1.length);18wpt.log("data.input1[0]: " + data.input1[0]);19wpt.log("data.input1[0].name: " + data.input1[0].name);20wpt.log("data.input1[0].value: " + data.input1[0].value);21var form = wpt.formData("form1");22var data = {23};24wpt.log("data: " + JSON.stringify(data));25wpt.log("data.input1: " + data.input1);26wpt.log("data.input1.length: " + data.input1.length);27wpt.log("data.input1[0]: " + data.input1[0]);28wpt.log("data.input1[0].name: " + data.input1[0].name);29wpt.log("data.input1[0].value: " + data.input1[0].value);30wpt.log("data.input2: " + data.input2);31wpt.log("data.input2.length: " + data.input2.length);32wpt.log("data.input2[0]: " + data.input2[0]);
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!!