Best JavaScript code snippet using wpt
TreeJSONStructure.js
Source:TreeJSONStructure.js
1sap.ui.define(function () {2 "use strict";3 return {45 /*-------------------------------------------------------6 * @author Deloitte7 * @category UI58 * @date 9 *10 * @describe Creates a JSON Structure using the data that is passed11 *12 * @param 13 -------------------------------------------------------*/14 _createD3Data: function (data) {15 var dictionary = this._readDictionary(data);16 var treeDetails = this._readTree(data);17 return this._generateTree(treeDetails, dictionary);18 },19 _createD3Data_ContractDisplay: function (data) {20 var dictionary = this._readDictionary_ContractDisplay(data);21 var treeDetails = this._readTree(data);22 return this._generateTree(treeDetails, dictionary);23 },24 /*-------------------------------------------------------25 * @author Deloitte26 * @category UI527 * @date 28 *29 * @describe Creates a dictionary using the data that is passed30 *31 * @param 32 -------------------------------------------------------*/33 _readDictionary_ContractDisplay: function (dictionaryResponseData) {34 var dictionary = {};35 for (var counter = 0; counter < dictionaryResponseData.length; counter++) {36 var detail = dictionaryResponseData[counter];37 dictionary[parseInt(detail['NodeID']).toString()] = {3839 NodeID: detail['NodeID'],40 ParentNodeID: detail['ParentNodeID'],41 DrillState: detail['DrillState'],42 HierarchyLevel: detail['HierarchyLevel'],43 Document: detail['Document'],44 Document_Date: detail['Document_Date'],45 User_Status: detail['User_Status'],46 Sales_Document_Type: detail['Sales_Document_Type'],47 Net_Value: detail['Net_Value'],48 Currency: detail['Currency']4950 };51 }52 return dictionary;53 },54 _readDictionary: function (dictionaryResponseData) {55 var dictionary = {};56 for (var counter = 0; counter < dictionaryResponseData.length; counter++) {57 var detail = dictionaryResponseData[counter];58 switch (detail.Object_Type) {59 case "New Business Quote":60 detail.Icon = "sap-icon://document-text";61 detail.OAC_Log = "View Text";62 break;63 case "Renewal Quote":64 detail.Icon = "sap-icon://create";65 detail.OAC_Log = "View Text";66 break;67 case "Quote":68 detail.Icon = "sap-icon://create";69 detail.OAC_Log = "View Text";70 break;71 case "Sold To":72 //detail.Object = "Sold To - " + detail.Object;73 detail.Icon = "sap-icon://customer";74 break;75 case "Reseller":76 //detail.Object = "Sold To - " + detail.Object;77 detail.Icon = "sap-icon://customer";78 break;79 case "Functional Location":80 //detail.Object = "LLFL - " + detail.Object;81 detail.Icon = "sap-icon://functional-location";82 break;83 case "Functional Location (AMP)":84 //detail.Object = "LLFL - " + detail.Object;85 detail.Icon = "sap-icon://functional-location";86 break;87 case "MLFL":88 detail.Icon = "sap-icon://functional-location";89 //detail.Object = "MLFL - " + detail.Object;90 break;91 case "Contract":92 detail.Icon = "sap-icon://sales-order";93 //detail.Object = "C - " + detail.Object;94 break;95 case "Master Contract":96 detail.Icon = "sap-icon://expense-report";97 //detail.Object = "MC - " + detail.Object;98 break;99 case "Equipment":100 //detail.Object = "E - " + detail.Object;101 detail.Icon = "sap-icon://add-equipment";102 break;103 default:104 detail.Icon = "";105 }106 dictionary[parseInt(detail['NodeID']).toString()] = {107 Icon: detail['Icon'],108 Object_Type: detail['Object_Type'],109 Object: detail['Object'],110 NodeID: detail['NodeID'],111 ParentNodeID: detail['ParentNodeID'],112 HierarchyLevel: detail['HierarchyLevel'],113 DrillState: detail['DrillState'],114 Account_Ops_Lead: detail['Account_Ops_Lead'],115 Action_Code: detail['Action_Code'],116 Action_Date: detail['Action_Date'],117 Asset_Location: detail['Asset_Location'],118 Attachment_Indicator: detail['Attachment_Indicator'],119 Bill_To_Party: detail['Bill_To_Party'],120 Billing_Block: detail['Billing_Block'],121 Billing_Cycle: detail['Billing_Cycle'],122 BRT: detail['BRT'],123 Business_Area: detail['Business_Area'],124 Contract: detail['Contract'],125 Contract_Admin_Contact: detail['Contract_Admin_Contact'],126 Contract_End_Date: detail['Contract_End_Date'],127 Contract_Item: detail['Contract_Item'],128 Contract_Start_Date: detail['Contract_Start_Date'],129 Country: detail['Country'],130 Created_By: detail['Created_By'],131 Credit_Status: detail['Credit_Status'],132 CSSA_Number: detail['CSSA_Number'],133 Currency: detail['Currency'],134 Customer_PO_Number: detail['Customer_PO_Number'],135 Deal_Discount_Percentage: detail['Deal_Discount_Percentage'],136 Deal_Discount_Value: detail['Deal_Discount_Value'],137 Deal_ID: detail['Deal_ID'],138 Document_Type: detail['Document_Type'],139 End_Customer: detail['End_Customer'],140 Entitled_Party: detail['Entitled_Party'],141 Equipment_Number: detail['Equipment_Number'],142 Federal_Indicator: detail['Federal_Indicator'],143 GBS_Admin: detail['GBS_Admin'],144 Hpe_Net_Value: detail['Hpe_Net_Value'],145 Legacy_Doc: detail['Legacy_Doc'],146 LLFL: detail['LLFL'],147 LLFL_Desc: detail['LLFL_Desc'],148 Group_Contract: detail['Group_Contract'],149 Material: detail['Material'],150 Material_Description: detail['Material_Description'],151 MLFL: detail['MLFL'],152 MLFL_Description: detail['MLFL_Description'],153 Offer: detail['Offer'],154 Offer_Description: detail['Offer_Description'],155 Opportunity_ID: detail['Opportunity_ID'],156 Overall_Blocked_Status: detail['Overall_Blocked_Status'],157 Package: detail['Package'],158 Package_Description: detail['Package_Description'],159 Payment_Term: detail['Payment_Term'],160 PO_Value: detail['PO_Value'],161 Prefered_Service_Provider: detail['Prefered_Service_Provider'],162 Product_Number: detail['Product_Number'],163 Purchase_Agreement_ID: detail['Purchase_Agreement_ID'],164 Quote: detail['Quote'],165 Quote_Amount: detail['Quote_Amount'],166 Reason_For_Cancellation: detail['Reason_For_Cancellation'],167 Rejection_Status: detail['Rejection_Status'],168 Reseller_PO_Number: detail['Reseller_PO_Number'],169 Route_To_Market: detail['Route_To_Market'],170 Sales_Document_Status: detail['Sales_Document_Status'],171 Sales_Metric_Code: detail['Sales_Metric_Code'],172 Sales_Order_Number: detail['Sales_Order_Number'],173 Sales_Org: detail['Sales_Org'],174 Sales_Rep: detail['Sales_Rep'],175 // BOC SDAS52 ER-1036 11/10/2020176 SignatureFlag: detail['SignatureFlag'],177 // EOC SDAS52 ER-1036 11/10/2020178 Serial_Number: detail['Serial_Number'],179 TechIdentNo: detail['TechIdentNo'], //INC0154688 ++VS180 Service_Level: detail['Service_Level'],181 SLED_Indicator: detail['SLED_Indicator'],182 Sold_To_Company_Name: detail['Sold_To_Company_Name'],183 T2_Reseller: detail['T2_Reseller'],184 Usage_Indicator: detail['Usage_Indicator'],185 Valid_To: detail['Valid_To'],186 Version_Description: detail['Version_Description'],187 Warranty_End_Date: detail['Warranty_End_Date'],188 Warranty_Id: detail['Warranty_Id'],189 Warranty_Start_Date: detail['Warranty_Start_Date'],190 Web_Status: detail['Web_Status'],191 Nav_To_Cust_Docs: detail['Nav_To_Cust_Docs'],192 Sold_To_Party: detail['Sold_To_Party'],193 Sold_To_Name: detail['Sold_To_Name'],194 Sold_to_LLFL: detail['Sold_to_LLFL'],195 Sold_to_LLFL_Name: detail['Sold_to_LLFL_Name'],196 HLFL: detail['HLFL'],197 HLFL_Desc: detail['HLFL_Desc'],198 RTM_FL: detail['RTM_FL'],199 RTM_FL_Category: detail['RTM_FL_Category'],200 RTM_FL_Desc: detail['RTM_FL_Desc'],201 AMP: detail['AMP'],202 AMP_Desc: detail['AMP_Desc'],203 MLFL1: detail['MLFL1'],204 MLFL1_Desc: detail['MLFL1_Desc'],205 MLFL2: detail['MLFL2'],206 MLFL2_Desc: detail['MLFL2_Desc'],207 VTWEG: detail['VTWEG'],208 SPART: detail['SPART'],209 Region: detail['Region'],210 Created_By_Group: detail['Created_By_Group'],211 PO_End_Date: detail['PO_End_Date'],212 Master_Contract_ID: detail['Master_Contract_ID'],213 Commerciality_Code: detail['Commerciality_Code'],214 Price_List_Type: detail['Price_List_Type'],215 Invoice_Spreadsheet_Flag: detail['Invoice_Spreadsheet_Flag'],216 Third_Party_Info: detail['Third_Party_Info'],217 Equipment_not_linked_to_Contract: detail['Equipment_not_linked_to_Contract'],218 Equipment_not_linked_to_Quote: detail['Equipment_not_linked_to_Quote'],219 PSP_SubContractor: detail['PSP_SubContractor'],220 PSP_SubContractor_name1: detail['PSP_SubContractor_name1'],221 GDI: detail['GDI'],222 Local_Invoicing: detail['Local_Invoicing'],223 Central_Invoicing: detail['Central_Invoicing'],224 LLFL_Status: detail['LLFL_Status'],225 Equipment_Qty: detail['Equipment_Qty'],226 Missing_Billing_Amt: detail['Missing_Billing_Amt'],227 End_Customer_Name: detail['End_Customer_Name'],228 Channel_Reseller_Name: detail['Channel_Reseller_Name'],229 Sales_Rep_Name: detail['Sales_Rep_Name'],230 Sales_Rep_Email: detail['Sales_Rep_Email'], //++ VS SR 1.7 DVNK9A24K2231 Entitled_Party_Name: detail['Entitled_Party_Name'],232 Bill_To_Party_Name: detail['Bill_To_Party_Name'],233 Contract_Admin_Contact_Name: detail['Contract_Admin_Contact_Name'],234 Contract_Admin_Contact_Email: detail['Contract_Admin_Contact_Email'], //++ VS SR 1.7 DVNK9A24K2235 Global_Operations_Name: detail['Global_Operations_Name'],236 Account_Ops_Lead_Name: detail['Account_Ops_Lead_Name'],237 Account_Ops_Lead_Email: detail['Account_Ops_Lead_Email'], //++ VS SR 1.7 DVNK9A24K2238 LID_Code: detail['LID_Code'],239 PAC_Code: detail['PAC_Code'],240 Exclusion_Date: detail['Exclusion_Date'],241 Equipment_Status: detail['Equipment_Status'],242 HW_SW_JW: detail['HW_SW_JW'],243 E_Not_Linked_To_Contract: detail['E_Not_Linked_To_Contract'],244 E_Not_Linked_To_Quote: detail['E_Not_Linked_To_Quote'],245 Asset_Location_Address: detail['Asset_Location_Address'],246 Asset_Location_Name: detail['Asset_Location_Name'],247 PSP_Name: detail['PSP_Name'],248 Payer: detail['Payer'],249 Payer_Name: detail['Payer_Name'],250 System_Manager_Contact: detail['System_Manager_Contact'],251 System_Manager_Contact_Name: detail['System_Manager_Contact_Name'],252 SM_Backup_Contact: detail['SM_Backup_Contact'],253 SM_Backup_Contact_Name: detail['SM_Backup_Contact_Name'],254 Software_delivery_contact: detail['Software_delivery_contact'],255 Software_delivery_contact_Name: detail['Software_delivery_contact_Name'],256 Invoicing_Contact: detail['Invoicing_Contact'],257 Invoicing_Contact_Name: detail['Invoicing_Contact_Name'],258 Sold_To_Contact: detail['Sold_To_Contact'],259 Sold_To_Contact_Name: detail['Sold_To_Contact_Name'],260 Reseller_Contact: detail['Reseller_Contact'],261 Reseller_Contact_Name: detail['Reseller_Contact_Name'],262 Entitled_Party_Contact: detail['Entitled_Party_Contact'],263 Entitled_Party_Contact_Name: detail['Entitled_Party_Contact_Name'],264 Delivery_Contact: detail['Delivery_Contact'],265 Delivery_Contact_Name: detail['Delivery_Contact_Name'],266 Backup_Delivery_Contact: detail['Backup_Delivery_Contact'],267 Backup_Delivery_Contact_Name: detail['Backup_Delivery_Contact_Name'],268 Bill_to_Contact: detail['Bill_to_Contact'],269 Bill_to_Contact_Name: detail['Bill_to_Contact_Name'],270 Install_Base_Sales_Rep: detail['Install_Base_Sales_Rep'],271 Install_Base_Sales_Rep_Name: detail['Install_Base_Sales_Rep_Name'],272 Install_Base_Sales_Rep_Email: detail['Install_Base_Sales_Rep_Email'], //++ VS SR 1.7 DVNK9A24K2273 PSDM: detail['PSDM'],274 PSDM_Name: detail['PSDM_Name'],275 Admin_Signer: detail['Admin_Signer'],276 Admin_Signer_Name: detail['Admin_Signer_Name'],277 Admin_Supervisor_Email: detail['Admin_Supervisor_Email'], //++ VS SR 1.7 DVNK9A24K2278 Admin_Supervisor: detail['Admin_Supervisor'],279 Admin_Supervisor_Name: detail['Admin_Supervisor_Name'],280 Global_Deal_Specialist: detail['Global_Deal_Specialist'],281 Global_Deal_Specialist_Name: detail['Global_Deal_Specialist_Name'],282 Global_Deal_Specialist_Email: detail['Global_Deal_Specialist_Email'], //++ VS SR 1.7 DVNK9A24K2283 Distribution_Channel: detail['Distribution_Channel'],284 Division: detail['Division'],285 InAdvance_Flag: detail['InAdvance_Flag'],286 Rule_for_Det_Of_a_Deviating_Invoice_Dat: detail['Rule_for_Det_Of_a_Deviating_Invoice_Dat'],287 Rule_for_Origin_Of_Next_Invoice_Date: detail['Rule_for_Origin_Of_Next_Invoice_Date'],288 Alt_Tax_Classification: detail['Alt_Tax_Classification'],289 Sales_Document_Description: detail['Sales_Document_Description'],290 Equipment_Type: detail['Equipment_Type'],291 Profit_Center: detail['Profit_Center'],292 QuoteStartDate: detail['QuoteStartDate'],293 QuoteEndDate: detail['QuoteEndDate'],294 CreationDate: detail['CreationDate'],295 QuoteStartDateItem: detail['QuoteStartDateItem'], //ER2955 VSINGH39 28 Apr 2021 DEVK9A0SNM296 QuoteEndDateItem: detail['QuoteEndDateItem'], //ER2955 VSINGH39 28 Apr 2021 DEVK9A0SNM297 IsFederal: detail['IsFederal'],298 Superior_Equipment: detail['Superior_Equipment'],299 //SRE2523 VSINGH BOC300 Delivery_Block: detail['Delivery_Block'],301 Status_without_statusno: detail['Status_without_statusno'],302 Invoicing_Contact_Email: detail['Invoicing_Contact_Email'],303 Bill_To_contact_Email: detail['Bill_To_contact_Email'],304 //SRE2523 VSINGH EOC305 //SOC szanzaney SRE2524306 Agent_Number: detail['Agent_Number'],307 Agent_Number_Name: detail['Agent_Number_Name'],308 General_Manager: detail['General_Manager'],309 General_Manager_Name: detail['General_Manager_Name'],310 Chief_Accountant: detail['Chief_Accountant'],311 Chief_Accountant_Name: detail['Chief_Accountant_Name'],312 Service_Rendered_Date: detail['Service_Rendered_Date'],313 SupplyTypeCode: detail['SupplyTypeCode'],314 ListPrice: detail['ListPrice'],315 ExternalID: detail['ExternalID'],316 Bill_From: detail['Bill_From'],317 Bill_From_Name: detail['Bill_From_Name'],318 //EOC szanzaney SRE2524319 //SOC szanzaney SRE2487_2320 Business_Place: detail['Business_Place'],321 Business_Place_Name: detail['Business_Place_Name'],322 //EOC szanzaney SRE2487_2323 //SOC szanzaney CCB488324 Linked_SO: detail['Linked_SO'],325 //EOC szanzaney CCB488326 //soc szanzaney 4/12 CR143712 and CR143970327 PIBillRule: detail['PIBillRule'],328 PaymentDue: detail['PaymentDue'],329 PaymentCurrency: detail['PaymentCurrency'],330 //eoc szanzaney 4/12 CR143712 and CR143970331 Virtual_AMP: detail['Virtual_AMP'], //Competitive Quote Requirement332 Agreement_Id: detail['Agreement_Id'], //SRI3197 Defect 124973333 Sales_Office: detail['Sales_Office'], //ER 1294 ++VSINGH39 DEVK9A0O6C 13 Apr 2021334 SalesOffice_Eq: detail['SalesOffice_Eq'] //ER 1294 ++VSINGH39 DEVK9A0O6C 13 Apr 2021335 };336337 }338 return dictionary;339 },340341 /*-------------------------------------------------------342 * @author Deloitte343 * @category UI5344 * @date 345 *346 * @describe Creates a common structure for parent and children data and creates a create a hierarchy by comparing nodes.347 *348 * @param 349 -------------------------------------------------------*/350 _readTree: function (responseData) {351 var data = [];352 var len = responseData.length;353 var reverseLength = len - 1;354 for (var counter = 0; counter < len; counter++) {355 var detail = responseData[counter];356357 data.push({358 parentNode: parseInt(detail['ParentNodeID']),359 node: parseInt(detail['NodeID']),360 root: 0,361 level: parseInt(detail['HierarchyLevel'])362 });363364 }365366 data.sort(this._compareNodeByLevel);367 return data;368 },369370 /*-------------------------------------------------------371 * @author Deloitte372 * @category UI5373 * @date 374 *375 * @describe Compares nodes based on level to create a hierarchy 376 *377 * @param 378 -------------------------------------------------------*/379 _compareNodeByLevel: function (a, b) {380 if (a.level > b.level)381 return -1;382 if (a.level < b.level)383 return 1;384 return 0;385 },386387 /*-------------------------------------------------------388 * @author Deloitte389 * @category UI5390 * @date 391 *392 * @describe Gets the children by comparing the parent node ID of each of the nodes with the node IDs at the previous level 393 *394 * @param 395 -------------------------------------------------------*/396 _getChildren: function (parentNode, probableChildren) {397 var children = [];398 //console.log("Seraching for children for :",parentNode);399 //console.log("Seraching for children in :",probableChildren);400 for (var counter = 0; counter < probableChildren.length; counter++) {401 var treeNode = probableChildren[counter];402 if (treeNode.parentNode === parentNode) {403 children.push(treeNode);404 }405 }406 return children;407 },408409 /*-------------------------------------------------------410 * @author Deloitte411 * @category UI5412 * @date 413 *414 * @describe Gets the nodes at each level415 *416 * @param 417 -------------------------------------------------------*/418 _getNodesAtLevel: function (nodes, level) {419 var nodesAtLevel = [];420 for (var counter = 0; counter < nodes.length; counter++) {421 var detail = nodes[counter];422 if (detail.level === level) {423 nodesAtLevel.push(detail);424 }425 }426 return nodesAtLevel;427 },428429 /*-------------------------------------------------------430 * @author Deloitte431 * @category UI5432 * @date 433 *434 * @describe Generate the nested JSON structure by creating parent child relationships based on the hierarchy435 *436 * @param 437 -------------------------------------------------------*/438 _generateTree: function (data, dictionary) {439 var maxLevel = data[0].level;440 var currentLevel = maxLevel;441 var treeNodesAtPreviousLevel = [];442 var treeNodesAtCurrentLevel = [];443444 while (currentLevel >= 0) {445 //console.log("--------------------------Level:",currentLevel);446 treeNodesAtCurrentLevel = [];447 var nodesAtCurrentLevel = this._getNodesAtLevel(data, currentLevel);448 //console.log("nodesAtCurrentLevel:",nodesAtCurrentLevel);449 //console.log("treeNodesAtPreviousLevel",treeNodesAtPreviousLevel);450 if (treeNodesAtPreviousLevel.length === 0) {451 for (var counter = 0; counter < nodesAtCurrentLevel.length; counter++) {452 var node = nodesAtCurrentLevel[counter];453 var treeNode = {454 name: node.node.toString(),455 size: Math.floor(Math.random() * 1000000000),456 parentNode: node.parentNode.toString()457 };458 treeNode.data = dictionary[treeNode.name];459 treeNodesAtCurrentLevel.push(treeNode);460 //console.log("Pushing without children",treeNode);461 }462 } else {463 for (var counter = 0; counter < nodesAtCurrentLevel.length; counter++) {464 //console.log("Getting details for:",node.node);465 var node = nodesAtCurrentLevel[counter];466 var treeNode = {467 name: node.node.toString(),468 parentNode: node.parentNode.toString()469 };470 var children = this._getChildren(treeNode.name, treeNodesAtPreviousLevel);471 //console.log("Found Children:",children);472 if (children.length > 0) {473 treeNode.children = children;474 } else {475 treeNode.size = Math.floor(Math.random() * 1000000000);476 }477 treeNode.data = dictionary[treeNode.name];478 treeNodesAtCurrentLevel.push(treeNode);479 //console.log("Pushing node with children",treeNode);480 }481 }482 treeNodesAtPreviousLevel = treeNodesAtCurrentLevel;483 currentLevel--;484 }485 // //console.log(JSON.stringify(treeNodesAtCurrentLevel, null, 4));486 var a = treeNodesAtCurrentLevel;487488 return a;489 //this.getView().getModel("viewData").setProperty("/TreeDataSet", a);490 //return treeNodesAtCurrentLevel[0];491492 }493 };
...
useDetailState.ts
Source:useDetailState.ts
1import { useCallback, useState } from 'react';2import { DetailState } from '@jaegertracing/jaeger-ui-components';3import { TraceLog } from '@jaegertracing/jaeger-ui-components/src/types/trace';4/**5 * Keeps state of the span detail. This means whether span details are open but also state of each detail subitem6 * like logs or tags.7 */8export function useDetailState() {9 const [detailStates, setDetailStates] = useState(new Map<string, DetailState>());10 const toggleDetail = useCallback(11 function toggleDetail(spanID: string) {12 const newDetailStates = new Map(detailStates);13 if (newDetailStates.has(spanID)) {14 newDetailStates.delete(spanID);15 } else {16 newDetailStates.set(spanID, new DetailState());17 }18 setDetailStates(newDetailStates);19 },20 [detailStates]21 );22 const detailLogItemToggle = useCallback(23 function detailLogItemToggle(spanID: string, log: TraceLog) {24 const old = detailStates.get(spanID);25 if (!old) {26 return;27 }28 const detailState = old.toggleLogItem(log);29 const newDetailStates = new Map(detailStates);30 newDetailStates.set(spanID, detailState);31 return setDetailStates(newDetailStates);32 },33 [detailStates]34 );35 return {36 detailStates,37 toggleDetail,38 detailLogItemToggle,39 detailLogsToggle: useCallback(40 (spanID: string) => makeDetailSubsectionToggle('logs', detailStates, setDetailStates)(spanID),41 [detailStates]42 ),43 detailWarningsToggle: useCallback(44 (spanID: string) => makeDetailSubsectionToggle('warnings', detailStates, setDetailStates)(spanID),45 [detailStates]46 ),47 detailStackTracesToggle: useCallback(48 (spanID: string) => makeDetailSubsectionToggle('stackTraces', detailStates, setDetailStates)(spanID),49 [detailStates]50 ),51 detailReferencesToggle: useCallback(52 (spanID: string) => makeDetailSubsectionToggle('references', detailStates, setDetailStates)(spanID),53 [detailStates]54 ),55 detailProcessToggle: useCallback(56 (spanID: string) => makeDetailSubsectionToggle('process', detailStates, setDetailStates)(spanID),57 [detailStates]58 ),59 detailTagsToggle: useCallback(60 (spanID: string) => makeDetailSubsectionToggle('tags', detailStates, setDetailStates)(spanID),61 [detailStates]62 ),63 };64}65function makeDetailSubsectionToggle(66 subSection: 'tags' | 'process' | 'logs' | 'warnings' | 'references' | 'stackTraces',67 detailStates: Map<string, DetailState>,68 setDetailStates: (detailStates: Map<string, DetailState>) => void69) {70 return (spanID: string) => {71 const old = detailStates.get(spanID);72 if (!old) {73 return;74 }75 let detailState;76 if (subSection === 'tags') {77 detailState = old.toggleTags();78 } else if (subSection === 'process') {79 detailState = old.toggleProcess();80 } else if (subSection === 'warnings') {81 detailState = old.toggleWarnings();82 } else if (subSection === 'references') {83 detailState = old.toggleReferences();84 } else if (subSection === 'stackTraces') {85 detailState = old.toggleStackTraces();86 } else {87 detailState = old.toggleLogs();88 }89 const newDetailStates = new Map(detailStates);90 newDetailStates.set(spanID, detailState);91 setDetailStates(newDetailStates);92 };...
SliderValues.ts
Source:SliderValues.ts
1import { Option } from '@ephox/katamari';2import { SliderDetail } from '../../ui/types/SliderTypes';3const t = 'top',4 r = 'right',5 b = 'bottom',6 l = 'left';7// Values8const minX = (detail: SliderDetail): number => detail.model.minX;9const minY = (detail: SliderDetail): number => detail.model.minY;10const min1X = (detail: SliderDetail): number => detail.model.minX - 1;11const min1Y = (detail: SliderDetail): number => detail.model.minY - 1;12const maxX = (detail: SliderDetail): number => detail.model.maxX;13const maxY = (detail: SliderDetail): number => detail.model.maxY;14const max1X = (detail: SliderDetail): number => detail.model.maxX + 1;15const max1Y = (detail: SliderDetail): number => detail.model.maxY + 1;16const range = (detail: SliderDetail, max: (detail: SliderDetail) => number, min: (detail: SliderDetail) => number): number => max(detail) - min(detail);17const xRange = (detail: SliderDetail): number => range(detail, maxX, minX);18const yRange = (detail: SliderDetail): number => range(detail, maxY, minY);19const halfX = (detail: SliderDetail): number => xRange(detail) / 2;20const halfY = (detail: SliderDetail): number => yRange(detail) / 2;21const step = (detail: SliderDetail): number => detail.stepSize;22const snap = (detail: SliderDetail): boolean => detail.snapToGrid;23const snapStart = (detail: SliderDetail): Option<number> => detail.snapStart;24const rounded = (detail: SliderDetail): boolean => detail.rounded;25// Not great but... /shrug26const hasEdge = (detail: SliderDetail, edgeName: string): boolean => detail[edgeName + '-edge'] !== undefined;27const hasLEdge = (detail: SliderDetail): boolean => hasEdge(detail, l);28const hasREdge = (detail: SliderDetail): boolean => hasEdge(detail, r);29const hasTEdge = (detail: SliderDetail): boolean => hasEdge(detail, t);30const hasBEdge = (detail: SliderDetail): boolean => hasEdge(detail, b);31// Ew, any32const currentValue = (detail: SliderDetail): any => detail.model.value.get();33export {34 minX,35 min1X,36 maxX,37 max1X,38 minY,39 min1Y,40 maxY,41 max1Y,42 step,43 snap,44 snapStart,45 rounded,46 hasLEdge,47 hasREdge,48 hasTEdge,49 hasBEdge,50 currentValue,51 xRange,52 yRange,53 halfX,54 halfY...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');3wpt.getTestStatus('150709_4A_6a4e6c4a6e4d6b4e6c4f6e4d6f4e6d4', function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});7{ statusCode: 200,8 { statusCode: 200,9 { testId: '150709_4A_6a4e6c4a6e4d6b4e6c4f6e4d6f4e6d4',
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getTestStatus('160613_3C_3b9c9e3a3a8d3f2a2a2b2f2c2d2e2f2a', function(err, data) {4 if (err) return console.error(err);5 console.log(data);6});
Using AI Code Generation
1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org', 'A.6b4d6b1d1b2f36d2f0c2c6a9d9f9b0c0');3var testId = '140423_3H_1E8';4wpt.getTestResults(testId, function(err, data) {5 console.log(data);6});7{ statusCode: 400,8 data: '{"statusCode":400,"statusText":"Bad Request","data":{"error":"Invalid test ID"}}' }9{ statusCode: 400,10 data: '{"statusCode":400,"statusText":"Bad Request","data":{"error":"Invalid test ID"}}' }
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!!