How to use valueFrom method in mountebank

Best JavaScript code snippet using mountebank

testEditor.dialog.ts

Source:testEditor.dialog.ts Github

copy

Full Screen

1import {OnInit, Input, Component} from "@angular/core";2import {NgbModal, NgbActiveModal} from "@ng-bootstrap/ng-bootstrap";3import {CodePickerDialog} from "../coding/codePicker.dialog";4import {TermPickerDialog} from "../coding/termPicker.dialog";5import {Test} from "./models/Test";6import {CodeSetValue} from "../codeSet/models/CodeSetValue";7import {Restriction} from "../expressions/models/Restriction";8import {ValueTo} from "./models/ValueTo";9import {Filter} from "./models/Filter";10import {CodeSet} from "../codeSet/models/CodeSet";11import {ValueFrom} from "./models/ValueFrom";12import {ValueSet} from "./models/ValueSet";13import {CodingService} from "../coding/coding.service";14import {QueryPickerDialog} from "../query/queryPicker.dialog";15import {QuerySelection} from "../query/models/QuerySelection";16import {EnterpriseLibraryItem} from "../enterpriseLibrary/models/EnterpriseLibraryItem";17import {LibraryService, LoggerService} from "eds-common-js";18@Component({19 selector: 'ngbd-modal-content',20 template: require('./testEditor.html'),21 entryComponents : [22 QueryPickerDialog23 ]24})25export class TestEditDialog implements OnInit{26 public static open(modalService: NgbModal, test : Test, type : any, restrictions : any) {27 const modalRef = modalService.open(TestEditDialog, { backdrop : "static", size : "lg"});28 modalRef.componentInstance.resultData = test;29 modalRef.componentInstance.type = type;30 modalRef.componentInstance.restrictions = restrictions;31 return modalRef;32 }33 @Input() resultData : any;34 @Input() type : any;35 @Input() restrictions = <any>[];36 showConceptResults : boolean = false;37 title : string;38 filterValueFrom : string;39 filterValueTo : string;40 dateEditor : boolean = false;41 problemEditor : boolean = false;42 problem : boolean = false;43 activeEditor : boolean = false;44 active : boolean;45 authTypeEditor : boolean = false;46 acute : boolean;47 repeat : boolean;48 repeatDispensing : boolean;49 automatic : boolean;50 datetype: String = '';51 filterDateFrom : String;52 filterDateTo : String;53 filterDateFromRelativeValue : String;54 filterDateToRelativeValue : String;55 filterDateFromRelativePeriod : String;56 filterDateToRelativePeriod : String;57 restriction: string;58 restrictionCount: string = "1";59 fieldPrefix: string;60 editMode : boolean = false;61 showRestriction : boolean = false;62 codeSelection : CodeSetValue[] = [];63 codeCompareSelection : CodeSetValue[] = [];64 fields = <any>[];65 restrictionTypes = ['','ALL','LATEST','EARLIEST','HIGHEST','LOWEST'];66 periods = ['','DAY','WEEK','MONTH','YEAR'];67 keepFields = ['CLINICAL_DATE','VALUE','CODE'];68 libraryItem : EnterpriseLibraryItem;69 constructor(70 protected $modal : NgbModal,71 protected activeModal : NgbActiveModal,72 private codingService : CodingService,73 protected libraryService : LibraryService,74 protected logger : LoggerService) {75 }76 ngOnInit(): void {77 var newTest : Test = {78 filter: [],79 restriction: null80 };81 if (!this.resultData||!this.resultData.filter)82 this.resultData = newTest;83 else84 this.initialiseEditMode(this.resultData);85 if (this.type=="1")86 this.title = "Feature";87 else if (this.type=="3")88 this.title = "Test";89 }90 initialiseEditMode(resultData : Test) {91 var vm = this;92 vm.editMode = true;93 if (resultData.filter === null) {94 resultData.filter = [];95 }96 for (var f = 0; f < resultData.filter.length; ++f) {97 var filter = resultData.filter[f];98 var field = filter.field;99 switch(field) {100 case "CONCEPT":101 vm.codeSelection = filter.codeSet.codeSetValue;102 vm.showConceptResults = true;103 if (filter.codeSet.codeSetValue[0].baseType=="Observation"||104 filter.codeSet.codeSetValue[0].baseType=="Medication Statement"||105 filter.codeSet.codeSetValue[0].baseType=="Medication Order"||106 filter.codeSet.codeSetValue[0].baseType=="Referral"||107 filter.codeSet.codeSetValue[0].baseType=="Allergy"||108 filter.codeSet.codeSetValue[0].baseType=="Encounter")109 vm.dateEditor = true;110 if (filter.codeSet.codeSetValue[0].baseType=="Observation")111 vm.problemEditor = true;112 if (filter.codeSet.codeSetValue[0].baseType=="Medication Statement") {113 vm.activeEditor = true;114 vm.authTypeEditor = true;115 }116 break;117 case "EFFECTIVE_DATE":118 if (filter.valueFrom) {119 if (filter.valueFrom.absoluteUnit) {120 vm.filterDateFrom = filter.valueFrom.constant;121 vm.datetype = "absolute";122 }123 else if (filter.valueFrom.relativeUnit) {124 vm.filterDateFromRelativeValue = filter.valueFrom.constant;125 vm.filterDateFromRelativePeriod = filter.valueFrom.relativeUnit;126 vm.datetype = "relative";127 }128 }129 if (filter.valueTo) {130 if (filter.valueTo.absoluteUnit) {131 vm.filterDateTo = filter.valueTo.constant;132 vm.datetype = "absolute";133 }134 else if (filter.valueTo.relativeUnit) {135 vm.filterDateToRelativeValue = filter.valueTo.constant;136 vm.filterDateToRelativePeriod = filter.valueTo.relativeUnit;137 vm.datetype = "relative";138 }139 }140 break;141 case "VALUE":142 if (filter.valueFrom)143 vm.filterValueFrom = filter.valueFrom.constant;144 if (filter.valueTo)145 vm.filterValueTo = filter.valueTo.constant;146 break;147 case "OBSERVATION_PROBLEM":148 for (var i = 0, len = filter.valueSet.value.length; i < len; i++) {149 if (filter.valueSet.value[i]=="PROBLEM")150 vm.problem = true;151 }152 break;153 case "MEDICATION_STATUS":154 for (var i = 0, len = filter.valueSet.value.length; i < len; i++) {155 if (filter.valueSet.value[i]=="ACTIVE")156 vm.active = true;157 }158 break;159 case "MEDICATION_TYPE":160 for (var i = 0, len = filter.valueSet.value.length; i < len; i++) {161 if (filter.valueSet.value[i]=="ACUTE")162 vm.acute = true;163 else if (filter.valueSet.value[i]=="REPEAT")164 vm.repeat = true;165 else if (filter.valueSet.value[i]=="REPEAT_DISPENSING")166 vm.repeatDispensing = true;167 else if (filter.valueSet.value[i]=="AUTOMATIC")168 vm.automatic = true;169 }170 break;171 default :172 if (vm.type=="3") {173 if (filter.valueFrom) {174 for (var i = vm.restrictions.length-1; i >= 0; --i) {175 if (field==vm.restrictions[i].field) {176 vm.restrictions[i].filter.valueFrom.constant = filter.valueFrom.constant;177 if (filter.valueFrom.relativeUnit) {178 vm.restrictions[i].filter.valueFrom.relativeUnit = filter.valueFrom.relativeUnit;179 vm.restrictions[i].filter.valueFrom.testField = filter.valueFrom.testField;180 }181 }182 }183 }184 if (filter.valueTo) {185 for (var i = vm.restrictions.length-1; i >= 0; --i) {186 if (field==vm.restrictions[i].field) {187 vm.restrictions[i].filter.valueTo.constant = filter.valueTo.constant;188 if (filter.valueTo.relativeUnit) {189 vm.restrictions[i].filter.valueTo.relativeUnit = filter.valueTo.relativeUnit;190 vm.restrictions[i].filter.valueTo.testField = filter.valueTo.testField;191 }192 }193 }194 }195 if (filter.codeSet) {196 for (var i = vm.restrictions.length-1; i >= 0; --i) {197 if (field==vm.restrictions[i].field) {198 vm.restrictions[i].filter.codeSet = filter.codeSet;199 }200 }201 }202 }203 break;204 }205 }206 if (resultData.restriction) {207 vm.showRestriction = true;208 vm.restriction = resultData.restriction.restriction;209 vm.restrictionCount = resultData.restriction.count;210 vm.fieldPrefix = resultData.restriction.prefix;211 vm.fields = resultData.restriction.field;212 }213 }214 formatDate(inputDate : Date) {215 return this.zeroFill(inputDate.getDate(),2) + "-" + this.zeroFill((inputDate.getMonth()+1),2) + "-" + inputDate.getFullYear();216 }217 pickCompareCodeSet(field) {218 let querySelection: QuerySelection;219 let vm = this;220 QueryPickerDialog.open(this.$modal, querySelection)221 .result.then(function (resultData: QuerySelection) {222 vm.libraryService.getLibraryItem<EnterpriseLibraryItem>(resultData.id)223 .subscribe(224 (libraryItem) => {225 vm.libraryItem = libraryItem;226 var codeSet : CodeSet = {227 codingSystem : "ENDEAVOUR",228 codeSetValue : libraryItem.codeSet.codeSetValue229 }230 var filter: Filter = {231 field: "CONCEPT",232 valueFrom: null,233 valueTo: null,234 codeSet: null,235 valueSet: null,236 codeSetLibraryItemUuid: null,237 negate: false238 };239 filter.codeSet = codeSet;240 for (var i = 0; i < vm.restrictions.length; ++i) {241 if (vm.restrictions[i].field == field) {242 vm.restrictions[i].filter = filter;243 break;244 }245 }246 }247 );248 });249 }250 pickCompareCode(field) {251 let vm = this;252 vm.codeCompareSelection = [];253 for (var i = 0; i < vm.restrictions.length; ++i) {254 if (vm.restrictions[i].field == field) {255 if (vm.restrictions[i].filter.codeSet!=null) {256 vm.codeCompareSelection = vm.restrictions[i].filter.codeSet.codeSetValue;257 break;258 }259 }260 }261 TermPickerDialog.open(this.$modal, vm.codeCompareSelection)262 .result.then(function(result : CodeSetValue[]) {263 var codeSet : CodeSet = {264 codingSystem : "ENDEAVOUR",265 codeSetValue : result266 }267 var filter: Filter = {268 field: "CONCEPT",269 valueFrom: null,270 valueTo: null,271 codeSet: null,272 valueSet: null,273 codeSetLibraryItemUuid: null,274 negate: false275 };276 filter.codeSet = codeSet;277 for (var i = 0; i < vm.restrictions.length; ++i) {278 if (vm.restrictions[i].field == field) {279 vm.restrictions[i].filter = filter;280 break;281 }282 }283 });284 }285 showCodeSetPicker() {286 let querySelection: QuerySelection;287 let vm = this;288 QueryPickerDialog.open(this.$modal, querySelection)289 .result.then(function (resultData: QuerySelection) {290 vm.libraryService.getLibraryItem<EnterpriseLibraryItem>(resultData.id)291 .subscribe(292 (libraryItem) => {293 vm.libraryItem = libraryItem;294 if (vm.codeSelection.length>0) {295 for (var i = 0; i < vm.resultData.filter.length; ++i) {296 var flt = vm.resultData.filter[i];297 if (flt.field=="CONCEPT")298 vm.resultData.filter.splice(i, 1);299 }300 }301 vm.codeSelection = libraryItem.codeSet.codeSetValue;302 var codeSet : CodeSet = {303 codingSystem : "ENDEAVOUR",304 codeSetValue : libraryItem.codeSet.codeSetValue305 }306 var filter: Filter = {307 field: "CONCEPT",308 valueFrom: null,309 valueTo: null,310 codeSet: null,311 valueSet: null,312 codeSetLibraryItemUuid: null,313 negate: false314 };315 filter.codeSet = codeSet;316 vm.resultData.filter.push(filter);317 vm.showConceptResults = true;318 if (libraryItem.codeSet.codeSetValue[0].baseType=="Observation"||319 libraryItem.codeSet.codeSetValue[0].baseType=="Medication Statement"||320 libraryItem.codeSet.codeSetValue[0].baseType=="Medication Order"||321 libraryItem.codeSet.codeSetValue[0].baseType=="Referral"||322 libraryItem.codeSet.codeSetValue[0].baseType=="Allergy"||323 libraryItem.codeSet.codeSetValue[0].baseType=="Encounter")324 vm.dateEditor = true;325 if (libraryItem.codeSet.codeSetValue[0].baseType=="Observation")326 vm.problemEditor = true;327 if (libraryItem.codeSet.codeSetValue[0].baseType=="Medication Statement") {328 vm.activeEditor = true;329 vm.authTypeEditor = true;330 }331 }332 );333 });334 }335 showCodePicker() {336 var vm = this;337 TermPickerDialog.open(this.$modal, vm.codeSelection)338 .result.then(function(resultData : CodeSetValue[]){339 if (vm.codeSelection.length>0) {340 for (var i = 0; i < vm.resultData.filter.length; ++i) {341 var flt = vm.resultData.filter[i];342 if (flt.field=="CONCEPT")343 vm.resultData.filter.splice(i, 1);344 }345 }346 vm.codeSelection = resultData;347 if (resultData.length==0) {348 return;349 }350 var codeSet : CodeSet = {351 codingSystem : "ENDEAVOUR",352 codeSetValue : resultData353 }354 var filter: Filter = {355 field: "CONCEPT",356 valueFrom: null,357 valueTo: null,358 codeSet: null,359 valueSet: null,360 codeSetLibraryItemUuid: null,361 negate: false362 };363 filter.codeSet = codeSet;364 vm.resultData.filter.push(filter);365 vm.showConceptResults = true;366 if (resultData[0].baseType=="Observation"||367 resultData[0].baseType=="Medication Statement"||368 resultData[0].baseType=="Medication Order"||369 resultData[0].baseType=="Referral"||370 resultData[0].baseType=="Allergy"||371 resultData[0].baseType=="Encounter")372 vm.dateEditor = true;373 if (resultData[0].baseType=="Observation")374 vm.problemEditor = true;375 if (resultData[0].baseType=="Medication Statement") {376 vm.activeEditor = true;377 vm.authTypeEditor = true;378 }379 });380 }381 removeFilter(filter: any) {382 var vm = this;383 for (var i = vm.resultData.filter.length-1; i >= 0; --i) {384 var f = vm.resultData.filter[i];385 switch(filter) {386 case "date":387 if (f.field=="EFFECTIVE_DATE") {388 vm.dateEditor = false;389 vm.resultData.filter.splice(i, 1);390 vm.datetype = "";391 }392 break;393 case "value":394 if (f.field=="VALUE") {395 vm.resultData.filter.splice(i, 1);396 }397 break;398 case "restriction":399 vm.showRestriction = false;400 vm.resultData.restriction = null;401 break;402 }403 }404 }405 zeroFill( number : any, width : any ) {406 width -= number.toString().length;407 if ( width > 0 )408 {409 return new Array( width + (/\./.test( number ) ? 2 : 1) ).join( '0' ) + number;410 }411 return number + ""; // always return a string412 }413 filterValueFromChange(value : any, valueField : any, testField : any) {414 var vm = this;415 if (!value)416 value="";417 var valueFrom : ValueFrom = {418 constant: value,419 absoluteUnit: "NUMERIC",420 relativeUnit: null,421 operator: "GREATER_THAN_OR_EQUAL_TO",422 testField: testField423 }424 var filter: Filter = {425 field: valueField,426 valueFrom: valueFrom,427 valueTo: null,428 codeSet: null,429 valueSet: null,430 codeSetLibraryItemUuid: null,431 negate: false432 };433 for (var i = 0; i < vm.resultData.filter.length; ++i) {434 var flt = vm.resultData.filter[i];435 if (flt.field==valueField && flt.valueFrom) {436 vm.resultData.filter.splice(i, 1);437 }438 }439 if (value!="")440 vm.resultData.filter.push(filter);441 }442 filterValueToChange(value : any, valueField : any, testField : any) {443 var vm = this;444 if (!value)445 value="";446 var valueTo : ValueTo = {447 constant: value,448 absoluteUnit: "NUMERIC",449 relativeUnit: null,450 operator: "LESS_THAN_OR_EQUAL_TO",451 testField: testField452 }453 var filter: Filter = {454 field: valueField,455 valueFrom: null,456 valueTo: valueTo,457 codeSet: null,458 valueSet: null,459 codeSetLibraryItemUuid: null,460 negate: false461 };462 for (var i = 0; i < vm.resultData.filter.length; ++i) {463 var flt = vm.resultData.filter[i];464 if (flt.field==valueField && flt.valueTo) {465 vm.resultData.filter.splice(i, 1);466 }467 }468 if (value!="")469 vm.resultData.filter.push(filter);470 }471 filterDateFromChange(value : any) {472 var vm = this;473 if (!value)474 value="";475 var datestring : string = value;476 var dateField : string = "EFFECTIVE_DATE";477 var valueFrom : ValueFrom = {478 constant: datestring,479 absoluteUnit: "DATE",480 relativeUnit: null,481 operator: "GREATER_THAN_OR_EQUAL_TO",482 testField: ""483 }484 var filter: Filter = {485 field: dateField,486 valueFrom: valueFrom,487 valueTo: null,488 codeSet: null,489 valueSet: null,490 codeSetLibraryItemUuid: null,491 negate: false492 };493 for (var i = 0; i < vm.resultData.filter.length; ++i) {494 var flt = vm.resultData.filter[i];495 if (flt.field==dateField && flt.valueFrom)496 vm.resultData.filter.splice(i, 1);497 }498 if (value!="") {499 vm.resultData.filter.push(filter);500 }501 }502 filterRelativeDateFromChange(value : any, period : any, dateField : any, testField : any) {503 var vm = this;504 if (!value)505 value="";506 var valueFrom : ValueFrom = {507 constant: value,508 absoluteUnit: null,509 relativeUnit: period,510 operator: "GREATER_THAN_OR_EQUAL_TO",511 testField: testField512 }513 var filter: Filter = {514 field: dateField,515 valueFrom: valueFrom,516 valueTo: null,517 codeSet: null,518 valueSet: null,519 codeSetLibraryItemUuid: null,520 negate: false521 };522 for (var i = 0; i < vm.resultData.filter.length; ++i) {523 var flt = vm.resultData.filter[i];524 if (flt.field==dateField && flt.valueFrom)525 vm.resultData.filter.splice(i, 1);526 }527 if (value!="") {528 vm.resultData.filter.push(filter);529 }530 }531 filterDateToChange(value : any) {532 var vm = this;533 if (!value)534 value="";535 var datestring : string = value;536 var dateField : string = "EFFECTIVE_DATE";537 var valueTo : ValueTo = {538 constant: datestring,539 absoluteUnit: "DATE",540 relativeUnit: null,541 operator: "LESS_THAN_OR_EQUAL_TO",542 testField: ""543 }544 var filter: Filter = {545 field: dateField,546 valueFrom: null,547 valueTo: valueTo,548 codeSet: null,549 valueSet: null,550 codeSetLibraryItemUuid: null,551 negate: false552 };553 for (var i = 0; i < vm.resultData.filter.length; ++i) {554 var flt = vm.resultData.filter[i];555 if (flt.field==dateField && flt.valueTo)556 vm.resultData.filter.splice(i, 1);557 }558 if (value!="") {559 vm.resultData.filter.push(filter);560 }561 }562 filterRelativeDateToChange(value : any, period : any, dateField : any, testField : any) {563 var vm = this;564 if (!value)565 value="";566 var valueTo : ValueTo = {567 constant: value,568 absoluteUnit: null,569 relativeUnit: period,570 operator: "LESS_THAN_OR_EQUAL_TO",571 testField: testField572 }573 var filter: Filter = {574 field: dateField,575 valueFrom: null,576 valueTo: valueTo,577 codeSet: null,578 valueSet: null,579 codeSetLibraryItemUuid: null,580 negate: false581 };582 for (var i = 0; i < vm.resultData.filter.length; ++i) {583 var flt = vm.resultData.filter[i];584 if (flt.field==dateField && flt.valueTo)585 vm.resultData.filter.splice(i, 1);586 }587 if (value!="") {588 vm.resultData.filter.push(filter);589 }590 }591 filterCompareCodeChange(valueField : any, codeSet : any) {592 var vm = this;593 if (codeSet==null)594 return;595 var filter: Filter = {596 field: valueField,597 valueFrom: null,598 valueTo: null,599 codeSet: codeSet,600 valueSet: null,601 codeSetLibraryItemUuid: null,602 negate: false603 };604 for (var i = 0; i < vm.resultData.filter.length; ++i) {605 var flt = vm.resultData.filter[i];606 if (flt.field==valueField) {607 vm.resultData.filter.splice(i, 1);608 }609 }610 vm.resultData.filter.push(filter);611 }612 problemChange(e) {613 var vm = this;614 vm.problem = e.target.checked;615 }616 activeChange(e) {617 var vm = this;618 vm.active = e.target.checked;619 }620 acuteChange(e) {621 var vm = this;622 vm.acute = e.target.checked;623 }624 repeatChange(e) {625 var vm = this;626 vm.repeat = e.target.checked;627 }628 repeatDispensingChange(e) {629 var vm = this;630 vm.repeatDispensing = e.target.checked;631 }632 automaticChange(e) {633 var vm = this;634 vm.automatic = e.target.checked;635 }636 toggleRestriction() {637 var vm = this;638 vm.showRestriction = !vm.showRestriction;639 };640 save() {641 var vm = this;642 if (vm.type=="3") {643 for (var i = vm.restrictions.length-1; i >= 0; --i) {644 var f = vm.restrictions[i].filter;645 if (vm.restrictions[i].field.indexOf("DATE") >= 0) {646 vm.filterRelativeDateFromChange(f.valueFrom.constant, f.valueFrom.relativeUnit, vm.restrictions[i].field, f.valueFrom.testField)647 vm.filterRelativeDateToChange(f.valueTo.constant, f.valueTo.relativeUnit, vm.restrictions[i].field, f.valueTo.testField)648 } else if (vm.restrictions[i].field.indexOf("VALUE") >= 0) {649 vm.filterValueFromChange(f.valueFrom.constant, vm.restrictions[i].field, f.valueFrom.testField)650 vm.filterValueToChange(f.valueTo.constant, vm.restrictions[i].field, f.valueTo.testField)651 } else if (vm.restrictions[i].field.indexOf("CODE") >= 0) {652 vm.filterCompareCodeChange(vm.restrictions[i].field, f.codeSet);653 }654 }655 }656 if (vm.datetype == 'absolute') {657 vm.filterDateFromChange(vm.filterDateFrom);658 vm.filterDateToChange(vm.filterDateTo);659 } else if (vm.datetype == 'relative') {660 vm.filterRelativeDateFromChange(vm.filterDateFromRelativeValue, vm.filterDateFromRelativePeriod,"EFFECTIVE_DATE", "")661 vm.filterRelativeDateToChange(vm.filterDateToRelativeValue, vm.filterDateToRelativePeriod, "EFFECTIVE_DATE", "")662 }663 vm.removeAttributes("OBSERVATION_PROBLEM");664 vm.removeAttributes("MEDICATION_STATUS");665 vm.removeAttributes("MEDICATION_TYPE");666 if (vm.problem)667 vm.filterValueChange(["PROBLEM"],"OBSERVATION_PROBLEM");668 if (vm.active)669 vm.filterValueChange(["ACTIVE"],"MEDICATION_STATUS");670 let medTypes = <any>[];671 if (vm.acute)672 medTypes.push("ACUTE");673 if (vm.repeat)674 medTypes.push("REPEAT");675 if (vm.repeatDispensing)676 medTypes.push("REPEAT_DISPENSING");677 if (vm.automatic)678 medTypes.push("AUTOMATIC");679 if (medTypes.length>0)680 vm.filterValueChange(medTypes,"MEDICATION_TYPE");681 console.log(vm.resultData);682 this.ok();683 }684 removeAttributes(filter: any) {685 var vm = this;686 for (var i = vm.resultData.filter.length-1; i >= 0; --i) {687 var f = vm.resultData.filter[i];688 if (f.field==filter) {689 vm.resultData.filter.splice(i, 1);690 }691 }692 }693 filterValueChange(values : any[], valueField : any) {694 var vm = this;695 var valueSet : ValueSet = {696 value: []697 }698 var value = "";699 for (var i = values.length-1; i >= 0; --i) {700 value = values[i];701 valueSet.value.push(value);702 }703 var filter : Filter = {704 field: valueField,705 valueFrom: null,706 valueTo: null,707 codeSet: null,708 valueSet: valueSet,709 codeSetLibraryItemUuid: null,710 negate: false711 };712 var foundEntry : boolean = false;713 for (var i = 0; i < vm.resultData.filter.length; ++i) {714 var flt = vm.resultData.filter[i];715 if (flt.field==valueField && flt.valueSet && value!="") {716 foundEntry = true;717 filter.valueSet = valueSet;718 break;719 }720 else if (flt.field==valueField && flt.valueSet && value=="")721 vm.resultData.filter.splice(i, 1);722 }723 if (!foundEntry && value!="")724 vm.resultData.filter.push(filter);725 }726 setSelectedFields(option, event) {727 var vm = this;728 for (var i = 0; i < vm.keepFields.length; i++) {729 if (event.target.checked&&vm.keepFields[i]==option){730 vm.fields.push(vm.keepFields[i]);731 } else if (!event.target.checked&&vm.keepFields[i]==option) {732 let j = vm.fields.indexOf(option);733 vm.fields.splice(j,1);734 }735 }736 this.restrictionChange('1');737 }738 restrictionChange(value : any) {739 var vm = this;740 if (value == '' || value == 'ALL')741 vm.removeFilter('restriction');742 if (!value || vm.restriction=="") {743 vm.resultData.restriction = null;744 return;745 }746 var restriction : Restriction = {747 restriction: vm.restriction,748 count: vm.restrictionCount,749 prefix: vm.fieldPrefix,750 field: vm.fields751 };752 vm.resultData.restriction = restriction;753 console.log(vm.resultData.restriction);754 }755 getCodeTermList(restriction) {756 return restriction.filter.codeSet.codeSetValue757 .map(val => val.term)758 .join(', ')759 }760 ok() {761 this.activeModal.close(this.resultData);762 }763 cancel() {764 this.activeModal.dismiss('cancel');765 }...

Full Screen

Full Screen

worker.js

Source:worker.js Github

copy

Full Screen

1const algoMetricsDir = '/var/metrics';2const workerTemplate = {3 apiVersion: 'batch/v1',4 kind: 'Job',5 metadata: {6 name: 'job-name',7 labels: {8 type: 'worker',9 group: 'hkube',10 core: 'true',11 'algorithm-name': 'algorithm-name',12 'metrics-group': 'workers'13 }14 },15 spec: {16 template: {17 metadata: {18 labels: {19 group: 'hkube',20 type: 'worker',21 'algorithm-name': 'algorithm-name',22 'metrics-group': 'workers'23 }24 },25 spec: {26 serviceAccountName: 'worker-serviceaccount',27 containers: [28 {29 name: 'worker',30 image: 'hkube/worker:latest',31 env: [32 {33 name: 'NODE_ENV',34 value: 'production'35 },36 {37 name: 'ALGORITHM_TYPE',38 value: 'algorithm-name'39 },40 {41 name: 'METRICS_PORT',42 value: '3001'43 },44 {45 name: 'INACTIVE_PAUSED_WORKER_TIMEOUT_MS',46 value: '10000'47 },48 {49 name: 'ALGO_METRICS_DIR',50 value: `${algoMetricsDir}`51 },52 {53 name: 'POD_ID',54 valueFrom: {55 fieldRef: {56 fieldPath: 'metadata.uid'57 }58 }59 },60 {61 name: 'POD_IP',62 valueFrom: {63 fieldRef: {64 fieldPath: 'status.podIP'65 }66 }67 },68 {69 name: 'POD_NAME',70 valueFrom: {71 fieldRef: {72 fieldPath: 'metadata.name'73 }74 }75 },76 {77 name: 'NAMESPACE',78 valueFrom: {79 fieldRef: {80 fieldPath: 'metadata.namespace'81 }82 }83 },84 {85 name: 'DEFAULT_STORAGE',86 valueFrom: {87 configMapKeyRef: {88 name: 'task-executor-configmap',89 key: 'DEFAULT_STORAGE'90 }91 }92 },93 {94 name: 'ALGORITHM_DISCONNECTED_TIMEOUT_MS',95 valueFrom: {96 configMapKeyRef: {97 name: 'task-executor-configmap',98 key: 'ALGORITHM_DISCONNECTED_TIMEOUT_MS'99 }100 }101 },102 {103 name: 'STORAGE_ENCODING',104 valueFrom: {105 configMapKeyRef: {106 name: 'task-executor-configmap',107 key: 'STORAGE_ENCODING'108 }109 }110 },111 {112 name: 'DISCOVERY_ENCODING',113 valueFrom: {114 configMapKeyRef: {115 name: 'task-executor-configmap',116 key: 'DISCOVERY_ENCODING'117 }118 }119 },120 {121 name: 'DISCOVERY_PORT',122 valueFrom: {123 configMapKeyRef: {124 name: 'task-executor-configmap',125 key: 'DISCOVERY_PORT'126 }127 }128 },129 {130 name: 'DISCOVERY_TIMEOUT',131 valueFrom: {132 configMapKeyRef: {133 name: 'task-executor-configmap',134 key: 'DISCOVERY_TIMEOUT'135 }136 }137 },138 {139 name: 'DISCOVERY_MAX_CACHE_SIZE',140 valueFrom: {141 configMapKeyRef: {142 name: 'task-executor-configmap',143 key: 'DISCOVERY_MAX_CACHE_SIZE'144 }145 }146 },147 {148 name: 'STORAGE_MAX_CACHE_SIZE',149 valueFrom: {150 configMapKeyRef: {151 name: 'task-executor-configmap',152 key: 'STORAGE_MAX_CACHE_SIZE'153 }154 }155 },156 {157 name: 'WORKER_ALGORITHM_ENCODING',158 valueFrom: {159 configMapKeyRef: {160 name: 'task-executor-configmap',161 key: 'WORKER_ALGORITHM_ENCODING'162 }163 }164 },165 {166 name: 'DISCOVERY_SERVING_REPORT_INTERVAL',167 valueFrom: {168 configMapKeyRef: {169 name: 'task-executor-configmap',170 key: 'DISCOVERY_SERVING_REPORT_INTERVAL'171 }172 }173 },174 {175 name: 'CLUSTER_NAME',176 valueFrom: {177 configMapKeyRef: {178 name: 'task-executor-configmap',179 key: 'CLUSTER_NAME'180 }181 }182 },183 {184 name: 'WORKER_SOCKET_MAX_PAYLOAD_BYTES',185 valueFrom: {186 configMapKeyRef: {187 name: 'task-executor-configmap',188 key: 'WORKER_SOCKET_MAX_PAYLOAD_BYTES'189 }190 }191 },192 {193 name: 'MONGODB_SERVICE_USER_NAME',194 valueFrom: {195 secretKeyRef: {196 name: 'mongodb-secret',197 key: 'mongodb-username'198 }199 }200 },201 {202 name: 'MONGODB_SERVICE_PASSWORD',203 valueFrom: {204 secretKeyRef: {205 name: 'mongodb-secret',206 key: 'mongodb-password'207 }208 }209 },210 {211 name: 'MONGODB_DB_NAME',212 valueFrom: {213 secretKeyRef: {214 name: 'mongodb-secret',215 key: 'mongodb-database'216 }217 }218 },219 {220 name: 'BASE_DATASOURCES_DIRECTORY',221 value: '/hkube/datasources-storage'222 },223 ],224 },225 {226 name: 'algorunner',227 image: 'hkube/algorunner:latest',228 env: [229 {230 name: 'ALGO_METRICS_DIR',231 value: `${algoMetricsDir}`232 },233 {234 name: 'POD_IP',235 valueFrom: {236 fieldRef: {237 fieldPath: 'status.podIP'238 }239 }240 },241 {242 name: 'DEFAULT_STORAGE',243 valueFrom: {244 configMapKeyRef: {245 name: 'task-executor-configmap',246 key: 'DEFAULT_STORAGE'247 }248 }249 },250 {251 name: 'STORAGE_ENCODING',252 valueFrom: {253 configMapKeyRef: {254 name: 'task-executor-configmap',255 key: 'STORAGE_ENCODING'256 }257 }258 },259 {260 name: 'DISCOVERY_ENCODING',261 valueFrom: {262 configMapKeyRef: {263 name: 'task-executor-configmap',264 key: 'DISCOVERY_ENCODING'265 }266 }267 },268 {269 name: 'DISCOVERY_PORT',270 valueFrom: {271 configMapKeyRef: {272 name: 'task-executor-configmap',273 key: 'DISCOVERY_PORT'274 }275 }276 },277 {278 name: 'DISCOVERY_TIMEOUT',279 valueFrom: {280 configMapKeyRef: {281 name: 'task-executor-configmap',282 key: 'DISCOVERY_TIMEOUT'283 }284 }285 },286 {287 name: 'DISCOVERY_MAX_CACHE_SIZE',288 valueFrom: {289 configMapKeyRef: {290 name: 'task-executor-configmap',291 key: 'DISCOVERY_MAX_CACHE_SIZE'292 }293 }294 },295 {296 name: 'STORAGE_MAX_CACHE_SIZE',297 valueFrom: {298 configMapKeyRef: {299 name: 'task-executor-configmap',300 key: 'STORAGE_MAX_CACHE_SIZE'301 }302 }303 },304 {305 name: 'WORKER_ALGORITHM_ENCODING',306 valueFrom: {307 configMapKeyRef: {308 name: 'task-executor-configmap',309 key: 'WORKER_ALGORITHM_ENCODING'310 }311 }312 },313 {314 name: 'DISCOVERY_SERVING_REPORT_INTERVAL',315 valueFrom: {316 configMapKeyRef: {317 name: 'task-executor-configmap',318 key: 'DISCOVERY_SERVING_REPORT_INTERVAL'319 }320 }321 },322 {323 name: 'CLUSTER_NAME',324 valueFrom: {325 configMapKeyRef: {326 name: 'task-executor-configmap',327 key: 'CLUSTER_NAME'328 }329 }330 }331 ]332 }333 ],334 restartPolicy: 'Never'335 }336 },337 backoffLimit: 0338 }339};340const logVolumes = [341 {342 name: 'varlog',343 hostPath: {344 path: '/var/log'345 }346 },347 {348 name: 'varlibdockercontainers',349 hostPath: {350 path: '/var/lib/docker/containers'351 }352 }353];354const algoMetricVolume = {355 name: 'algometrics',356 emptyDir: {}357};358const sharedVolumeMounts = [359 {360 name: 'algometrics',361 mountPath: `${algoMetricsDir}`362 }363];364const logVolumeMounts = [365 {366 name: 'varlog',367 mountPath: '/var/log'368 },369 {370 name: 'varlibdockercontainers',371 mountPath: '/var/lib/docker/containers',372 readOnly: true373 }374];375module.exports = {376 workerTemplate,377 logVolumes,378 logVolumeMounts,379 sharedVolumeMounts,380 algoMetricVolume...

Full Screen

Full Screen

CharacteristicsInterval.js

Source:CharacteristicsInterval.js Github

copy

Full Screen

1import valueFromControl from '../CharacteristicValueFromControl';2import libCommon from '../../../Common/Library/CommonLibrary';3import ODataDate from '../../../Common/Date/ODataDate';4import dateTime from '../Time/CharacteristicsFormatBackendTimeToLocal';5import validationFlag from './CharacteristicsValidationCheck';6export default function CharacteristicsInterval(context, controlFrom, controlTo) {7 let valueRelation = context.binding.CharValCode_Nav.ValueCode2;8 var valueFrom = valueFromControl(context, controlFrom);9 var valueTo = valueFromControl(context, controlTo);10 switch (context.binding.Characteristic.DataType) {11 case 'DATE':12 //Converting dates from String to Proper Date format13 valueFrom = valueFrom.toString();14 valueTo = valueTo.toString();15 valueFrom = [valueFrom.slice(0,4),'-',valueFrom.slice(4,6),'-',valueFrom.slice(6)].join('');16 valueFrom = new ODataDate(valueFrom);17 valueTo = [valueTo.slice(0,4),'-',valueTo.slice(4,6),'-',valueTo.slice(6)].join('');18 valueTo = new ODataDate(valueTo);19 break;20 case 'TIME':21 //Converting time from String to Proper time format22 valueFrom = valueFrom.toString();23 if (valueFrom.length < 6) {24 valueFrom = '0'+valueFrom;25 }26 valueFrom = dateTime(context, valueFrom);27 valueTo = valueTo.toString();28 if (valueTo.length < 6) {29 valueTo = '0'+valueTo;30 }31 valueTo = dateTime(context, valueTo);32 break;33 default:34 break;35 }36 //The validation flag checks for validation based on data type37 if (!validationFlag(context,valueFrom,valueTo,valueRelation)) {38 let message = context.localizeText('interval_not_valid');39 libCommon.executeInlineControlError(context, controlFrom, message);40 libCommon.executeInlineControlError(context, controlTo, message);41 return false;42 }43 return true;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var imposter = {2 {3 {4 equals: {5 }6 }7 {8 is: {9 headers: {10 },11 body: {12 }13 }14 }15 }16};17var mb = require('mountebank');18mb.create(imposter).then(function (imposter) {19 console.log('Imposter created at %s', imposter.url);20 console.log('To delete, run: mb delete %s', imposter.url);21});22var imposter = {23 {24 {25 equals: {26 }27 }28 {29 is: {30 headers: {31 },32 body: {33 }34 }35 }36 }37};38var mb = require('mountebank');39mb.create(imposter).then(function (imposter) {40 console.log('Imposter created at %s', imposter.url);41 console.log('To delete, run: mb delete %s', imposter.url);42});43var imposter = {44 {45 {46 equals: {47 }48 }49 {50 is: {51 headers: {52 },53 body: {54 }55 }56 }57 }58};59var mb = require('mountebank');60mb.create(imposter).then(function (imposter) {61 console.log('Imp

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var options = {3 'headers': {4 }5};6request(options, function (error, response) {7 if (error) throw new Error(error);8 console.log(response.body);9});10{11 {12 {13 "is": {14 "headers": {15 },16 "body": {17 }18 }19 }20 {21 {22 "equals": {23 }24 },25 {26 "equals": {27 }28 }29 }30 }31}32{33}34{35}36{37}38{39}40{41}42{43}44{45}46{47}48{49}50{51}

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank');2var imposter = {3 {4 { equals: { method: 'GET' } },5 { equals: { path: '/test' } }6 {7 is: {8 headers: { 'Content-Type': 'text/html' },9 }10 }11 }12};13mb.create(imposter).then(function (imposter) {14 console.log('Created imposter', imposter.port);15 return mb.get(imposter.port, '/test');16}).then(function (response) {17 console.log(response.body);18 return mb.del(imposter.port);19}).then(function () {20 console.log('Deleted imposter');21});22var mb = require('mountebank');23var imposter = {24 {25 { equals: { method: 'GET' } },26 { equals: { path: '/test' } }27 {28 is: {29 headers: { 'Content-Type': 'text/html' },30 }31 }32 }33};34mb.create(imposter).then(function (imposter) {35 console.log('Created imposter', imposter.port);36 return mb.get(imposter.port, '/test');37}).then(function (response) {38 console.log(response.body);39 return mb.del(imposter.port);40}).then(function () {41 console.log('Deleted imposter');42});43var mb = require('mountebank');44var imposter = {45 {46 { equals: { method: 'GET' } },47 { equals: { path: '/test' } }48 {49 is: {50 headers: { 'Content-Type': 'text/html' },51 }52 }53 }54};55mb.create(imposter).then(function (imposter) {56 console.log('Created imposter

Full Screen

Using AI Code Generation

copy

Full Screen

1var imposter = require('mountebank').createImposter(2525, 'http');2imposter.addStub({3 {4 is: {5 }6 }7 {8 equals: {9 }10 }11});12imposter.addStub({13 {14 is: {15 }16 }17 {18 equals: {19 }20 }21});22imposter.addStub({23 {24 is: {25 }26 }27 {28 equals: {29 }30 }31});32imposter.addStub({33 {34 is: {35 }36 }37 {38 equals: {39 }40 }41});42imposter.addStub({43 {44 is: {45 }46 }47 {48 equals: {49 }50 }51});52imposter.addStub({53 {54 is: {55 }56 }57 {58 equals: {59 }60 }61});62imposter.addStub({63 {64 is: {65 }66 }67 {68 equals: {69 }70 }71});72imposter.addStub({73 {74 is: {75 }76 }77 {78 equals: {79 }80 }81});82imposter.addStub({83 {84 is: {85 }86 }87 {88 equals: {89 }90 }91});92imposter.addStub({93 {94 is: {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { createImposter, valueFrom, getImposter } = require("mountebank");2const imposter = {3 {4 {5 equals: {6 }7 }8 {9 is: {10 body: valueFrom("response", "body")11 }12 }13 }14};15const main = async () => {16 await createImposter(imposter);17 const imposter = await getImposter(3000);18 console.log(imposter);19};20main();21const { createClient } = require("mountebank");22const client = createClient(2525);23const main = async () => {24 const response = await client.get("/imposters/3000");25 console.log(response.body);26};27main();28const { createClient } = require("mountebank");29const client = createClient(2525);30const main = async () => {31 const response = await client.get("/imposters/3000");32 console.log(response.body);33};34main();35const { createClient } = require("mountebank");36const client = createClient(2525);37const main = async () => {38 const response = await client.get("/imposters/3000");39 console.log(response.body);40};41main();42const { createClient } = require("mountebank");43const client = createClient(2525);44const main = async () => {45 const response = await client.get("/imposters/3000");46 console.log(response.body);47};48main();49const { createClient } = require("mountebank");50const client = createClient(2525);51const main = async () => {52 const response = await client.get("/imposters/3000");53 console.log(response.body);54};55main();

Full Screen

Using AI Code Generation

copy

Full Screen

1var mb = require('mountebank'),2 assert = require('assert'),3 stubs = 1;4mb.start({ port: port, pidfile: 'mb.pid', logfile: 'mb.log', ipWhitelist: ['*'] }, function () {5 var imposter = {6 {7 {8 equals: {9 headers: {10 }11 }12 }13 {14 is: {15 headers: {16 'x-foo': '${valueFrom(request.headers, "x-foo")}'17 },18 }19 }20 }21 };22 mb.post('/imposters', imposter, function (error, response) {23 assert.strictEqual(response.statusCode, 201);24 assert.strictEqual(response.body.port, imposter.port);25 assert.strictEqual(response.body.stubs.length, stubs);26 mb.get('/imposters/' + imposter.port, function (error, response) {27 assert.strictEqual(response.statusCode, 200);28 assert.strictEqual(response.body.port, imposter.port);29 assert.strictEqual(response.body.stubs.length, stubs);30 mb.get('/test', { headers: { 'x-foo': 'bar' } }, function (error, response) {31 assert.strictEqual(response.statusCode, 200);32 assert.strictEqual(response.body, 'Hello!');33 assert.strictEqual(response.headers['x-foo'], 'bar');34 mb.del('/imposters/' + imposter.port, function (error, response) {35 assert.strictEqual(response.statusCode, 200);36 assert.strictEqual(response.body.imposter.port, imposter.port);37 mb.get('/imposters/' + imposter.port, function (error, response) {38 assert.strictEqual(response.statusCode, 404);39 mb.stop();40 });41 });42 });43 });44 });45});46var mb = require('mountebank'),47 assert = require('assert'),

Full Screen

Using AI Code Generation

copy

Full Screen

1var imposter = require('mountebank').createImposter(4545, 'http');2 {3 {4 equals: {5 }6 }7 {8 is: {9 headers: {10 },11 body: {12 }13 }14 }15 }16];17imposter.addStubs(stubs);18imposter.start();19imposter.stop();20var imposter = require('mountebank').createImposter(4545, 'http');21 {22 {23 equals: {24 }25 }26 {27 is: {28 headers: {29 },30 body: {31 }32 }33 }34 }35];36imposter.addStubs(stubs);37imposter.start();38imposter.stop();39var imposter = require('mountebank').createImposter(4545, 'http');40 {41 {42 equals: {43 }44 }45 {46 is: {47 headers: {48 },49 body: {50 }51 }52 }53 }54];55imposter.addStubs(stubs);56imposter.start();

Full Screen

Using AI Code Generation

copy

Full Screen

1var faker = require('faker');2module.exports = {3 "valueFrom": {4 "function": "function() {return faker.name.findName();}"5 }6};7{8 {9 {10 "is": {11 "headers": {12 },13 "body": {14 "name": "<%= valueFrom('test.js') %>"15 }16 }17 }18 }19}20{21}22{23 {24 {25 "is": {26 "headers": {27 },28 "body": {29 "name": "<%= valueFrom('test.js', {faker: faker}) %>"30 }31 }32 }33 }34}35{36}37{38 {39 {40 "is": {41 "headers": {42 },43 "body": {44 "name": "<%= valueFrom('test.js', {faker: faker}, {name: 'Mr. Jevon Hahn'}) %>"45 }46 }47 }48 }49}50{51}52{53 {54 {55 "is": {

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert'),2 http = require('http'),3 mb = require('mountebank');4var getValueFromResponse = function (response) {5 return response.body.value;6};7var assertValueFromResponse = function (response) {8 assert.equal(response.body.value, 100);9};10var assertValueFromResponse1 = function (response) {11 assert.equal(response.body.value, 200);12};13var assertValueFromResponse2 = function (response) {14 assert.equal(response.body.value, 300);15};16var assertValueFromResponse3 = function (response) {17 assert.equal(response.body.value, 400);18};19var assertValueFromResponse4 = function (response) {20 assert.equal(response.body.value, 500);21};22var assertValueFromResponse5 = function (response) {23 assert.equal(response.body.value, 600);24};25var assertValueFromResponse6 = function (response) {26 assert.equal(response.body.value, 700);27};28var assertValueFromResponse7 = function (response) {29 assert.equal(response.body.value, 800);30};31var assertValueFromResponse8 = function (response) {32 assert.equal(response.body.value, 900);33};34var assertValueFromResponse9 = function (response) {35 assert.equal(response.body.value, 1000);36};37var assertValueFromResponse10 = function (response) {38 assert.equal(response.body.value, 1100);39};40var assertValueFromResponse11 = function (response) {41 assert.equal(response.body.value, 1200);42};43var assertValueFromResponse12 = function (response) {44 assert.equal(response.body.value, 1300);45};

Full Screen

Using AI Code Generation

copy

Full Screen

1const fetch = require('node-fetch');2const { stubFor, get } = require('mountebank-client');3const { valueFrom } = require('mountebank-client/lib/impl/util');4stubFor({5 request: {6 },7 response: {8 headers: {9 },10 body: {11 status: valueFrom('injected', 'status')12 }13 }14});15 .then(response => response.json())16 .then(json => console.log(json));17const fetch = require('node-fetch');18const { stubFor, get } = require('mountebank-client');19const { valueFrom } = require('mountebank-client/lib/impl/util');20stubFor({21 request: {22 },23 response: {24 headers: {25 },26 body: {27 status: valueFrom('injected', 'status')28 }29 }30});31 .then(response => response.json())32 .then(json => console.log(json));33{ status: 'success' }34{ status: 'success' }

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 mountebank 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