Best Python code snippet using yandex-tank
multimedia.js
Source:multimedia.js
1/*2Bigtree Studio3Class Multimedia.4*/5(function($){6 var MultimediaBigTree = function(element, options)7 {8 var obj = this;9 var fileupd = "mul_multimedia_general_upd.php";10 var defaults = {11 IdPrefijo: "#prefijo",12 IdCodigo: "#codigoTablaRelacionMultimedia",13 IdPopup: "#PopupMultimedia",14 Imagen: true,15 Video: true,16 Audio: true,17 Archivos:true,18 BtImagen: ".multimediaImagen",19 BtVideo: ".multimediaVideo",20 BtAudio: ".multimediaAudio",21 BtArchivo: ".multimediaArchivos",22 IdMsgAccion: ".msgaccionmultimedia",23 IdLstImagen: "#fotos",24 IdLstOrdenImagen: "#multimedia_fotos",25 ClassConnectOrdenImagen: ".sortable_multimedia_fotos",26 IdLstVideo: "#videos",27 IdLstOrdenVideo: "#multimedia_videos",28 ClassConnectOrdenVideo: ".sortable_multimedia_videos",29 IdLstAudio: "#audios",30 IdLstOrdenAudio: "#multimedia_audios",31 IdMultimedia: "",32 ClassConnectOrdenAudio: ".sortable_multimedia_audios",33 IdLstArchivos: "#files",34 IdLstOrdenArchivos: "#multimedia_archivos",35 ClassConnectOrdenArchivos: ".sortable_multimedia_archivos",36 HandleSortable: ".orden",37 TipoMultimedia:138 };39 40 var config = $.extend(defaults, options || {});41 this.getConfig = function(){return config;};42 this.setConfig = function(variable,data){obj.getConfig().variable=data};43 44 this.Inicializate = function()45 {46 if (obj.getConfig().Imagen==true)47 {48 $( obj.getConfig().BtImagen ).click(function() {49 obj.AbrirPopupMultimedia("Cargando im\u00e1genes...","mul_multimedia_foto.php");50 });51 obj.CargarImagenes();52 }53 if (obj.getConfig().Video==true)54 {55 $( obj.getConfig().BtVideo ).click(function() {56 obj.AbrirPopupMultimedia("Cargando videos...","mul_multimedia_video.php");57 });58 obj.CargarVideos();59 }60 if (obj.getConfig().Audio==true)61 {62 $( obj.getConfig().BtAudio ).click(function() {63 obj.AbrirPopupMultimedia("Cargando audios...","mul_multimedia_audio.php");64 });65 obj.CargarAudios();66 } 67 if (obj.getConfig().Archivos==true)68 {69 $( obj.getConfig().BtArchivo ).click(function() {70 obj.AbrirPopupMultimedia("Cargando archivos...","mul_multimedia_archivo.php");71 });72 obj.CargarArchivos();73 } 74 75 return true;76 };77 78 this.CargarImagenes = function(){obj.CargarMultimedia("Cargando im\u00e1genes",obj.getConfig().IdLstImagen,1);}79 this.CargarVideos = function(){obj.CargarMultimedia("Cargando videos",obj.getConfig().IdLstVideo,2);}80 this.CargarAudios = function(){obj.CargarMultimedia("Cargando audios",obj.getConfig().IdLstAudio,3);}81 this.CargarArchivos = function(){obj.CargarMultimedia("Cargando archivos",obj.getConfig().IdLstArchivos,4);}82 83 this.CargarListadoTipo = function(tipo)84 {85 switch(tipo)86 {87 case 1:88 obj.CargarImagenes();89 break; 90 case 2:91 obj.CargarVideos();92 break; 93 case 3:94 obj.CargarAudios();95 break; 96 case 4:97 obj.CargarArchivos();98 break; 99 100 } 101 102 }103 this.CargarMultimedia = function(txt,idListado,tipo)104 {105 $("#MsgGuardando").html(txt);106 $("#MsgGuardando").show();107 var param = "prefijo="+$(obj.getConfig().IdPrefijo).val();108 param += "&codigo="+$(obj.getConfig().IdCodigo).val();109 param += "&tipo="+tipo;110 111 $.ajax({112 type: "POST",113 url: "mul_multimedia_general_lst.php",114 data: param,115 dataType:"html",116 success: function(msg){ 117 jQuery(idListado).html(msg);118 obj.AplicarOrdenMultimedia(tipo);119 jQuery("#MsgGuardando").hide();120 jQuery("#MsgGuardando").html("Guardando...");121 }122 });123 124 }125 this.AbrirPopupMultimedia = function(txt,archivo)126 {127 if ($(obj.getConfig().IdCodigo).val()=="")128 {129 alert("Debe guardar antes de subir un archivo multimedia");130 return false; 131 }132 133 var param;134 $("#MsgGuardando").html(txt)135 $("#MsgGuardando").show();136 $.ajax({137 type: "POST",138 url: archivo,139 data: param,140 success: function(msg){141 $($(obj.getConfig().IdPopup)).dialog({ 142 height: 500, 143 width: 800, 144 zIndex: 999999999,145 position: 'center', 146 resizable: false,147 title: "Multimedia", 148 open: function(type, data) {$($(obj.getConfig().IdPopup)).html(msg);},149 beforeclose: function(event, ui) {$($(obj.getConfig().IdPopup)).html("");}150 151 });152 $("#MsgGuardando").hide();153 $("#MsgGuardando").html("Guardando...");154 }155 });156 }// Fin Multimedia157 this.AplicarOrdenMultimedia = function(tipoSortable)158 {159 160 var id, connect, tipo;161 switch(tipoSortable)162 {163 case 1:164 tipo = obj.getConfig().IdLstOrdenImagen;165 connect = obj.getConfig().ClassConnectOrdenImagen;166 break; 167 case 2:168 tipo = obj.getConfig().IdLstOrdenVideo;169 connect = obj.getConfig().ClassConnectOrdenVideo;170 break; 171 case 3:172 tipo = obj.getConfig().IdLstOrdenAudio;173 connect = obj.getConfig().ClassConnectOrdenAudio;174 break; 175 case 4:176 tipo = obj.getConfig().IdLstOrdenArchivos;177 connect = obj.getConfig().ClassConnectOrdenArchivos;178 break; 179 180 }181 182 $(function() {183 $(tipo).sortable(184 { 185 tolerance: 'pointer',186 scroll: true , 187 handle: $(obj.getConfig().HandleSortable),188 connectWith: connect,189 axis: 'y',190 cursor: 'pointer',191 opacity: 0.6, 192 update: function() {193 194 var order = $(this).sortable("serialize");195 order += "&prefijo="+$(obj.getConfig().IdPrefijo).val();196 order += "&codigo="+$(obj.getConfig().IdCodigo).val();197 order += "&accion=2";198 $("#MsgGuardando").show();199 $.post(fileupd, order, function(msg){200 if (msg.IsSucceed)201 $($(obj.getConfig().IdMsgAccion)).html(" ");202 else203 alert(msg.Msg) 204 $("#MsgGuardando").hide();205 }, "json");206 } 207 });208 209 });// fin functio()210 211 212 }// Fin sortable Multimedia213 214 215 this.EliminarMultimedia = function(multimedia,tipo)216 {217 if (!confirm("Esta seguro que desea eliminar el archivo multimedia?"))218 return false;219 220 $("#MsgGuardando").html("Eliminando...");221 $("#MsgGuardando").show();222 var param = "prefijo="+$(obj.getConfig().IdPrefijo).val();223 param += "&codigo="+$(obj.getConfig().IdCodigo).val();224 param += "&tipo="+tipo; 225 param += "&multimediacod="+multimedia;226 param += "&accion=3";227 228 $($(obj.getConfig().IdMsgAccion)).html(" ");229 var param, url;230 $.ajax({231 type: "POST",232 url: fileupd,233 data: param,234 dataType:"json",235 success: function(msg){ 236 if (msg.IsSucceed)237 {238 obj.CargarListadoTipo(tipo);239 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);240 }else241 {242 alert(msg.Msg); 243 }244 $("#MsgGuardando").hide();245 $("#MsgGuardando").html("Guardando...");246 }247 });248 249 250 }// Fin eliminar Multimedia251 252 this.RelacionarMultimedia = function(txt,multimediacod,tipo)253 {254 $("#MsgGuardando").html(txt);255 $("#MsgGuardando").show();256 $.blockUI({ message: '<h1 class="h1block"><img src="images/cargando.gif" /> '+txt+'...</h1>',baseZ: 9999999999 }) 257 var param = "prefijo="+$(obj.getConfig().IdPrefijo).val();258 param += "&codigo="+$(obj.getConfig().IdCodigo).val();259 param += "&tipo="+tipo; 260 param += "&multimediacod="+multimediacod; 261 param += "&accion=4";262 263 $($(obj.getConfig().IdMsgAccion)).html(" ");264 $.ajax({265 type: "POST",266 url: fileupd,267 data: param,268 dataType:"json",269 success: function(msg){ 270 if (msg.IsSucceed)271 {272 obj.CargarListadoTipo(tipo);273 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);274 }else275 {276 alert(msg.Msg); 277 }278 $("#MsgGuardando").hide();279 $("#MsgGuardando").html("Guardando...");280 $.unblockUI();281 }282 });283 }284 this.SubirRelacionarMultimedia = function(txt,tipo,form)285 {286 $("#MsgGuardando").show();287 var param, url;288 $.blockUI({ message: '<h1 class="h1block"><img src="images/cargando.gif" /> '+txt+'...</h1>',baseZ: 9999999999 }) 289 param = $("#"+form).serialize(); 290 param += "&prefijo="+$(obj.getConfig().IdPrefijo).val();291 param += "&codigo="+$(obj.getConfig().IdCodigo).val();292 param += "&tipo="+tipo; 293 param += "&accion=1";294 295 $($(obj.getConfig().IdMsgAccion)).html(" ");296 $.ajax({297 type: "POST",298 url: fileupd,299 data: param,300 dataType:"json",301 success: function(msg){ 302 if (msg.IsSucceed)303 {304 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);305 $(ObjMultimedia.getConfig().IdPopup).dialog("close");306 obj.CargarListadoTipo(tipo);307 }else308 {309 alert(msg.Msg); 310 }311 $.unblockUI();312 $("#MsgGuardando").hide();313 $("#MsgGuardando").html("Guardando...");314 }315 });316 }317 this.ModificarHome = function(multimediahome,txt,multimediacod)318 {319 $("#MsgGuardando").show();320 var param, url;321 $.blockUI({ message: '<h1 class="h1block"><img src="images/cargando.gif" /> '+txt+'...</h1>',baseZ: 9999999999 }) 322 param = "prefijo="+$(obj.getConfig().IdPrefijo).val();323 param += "&codigo="+$(obj.getConfig().IdCodigo).val();324 param += "&multimediahome="+multimediahome; 325 param += "&multimediacod="+multimediacod; 326 param += "&accion=5";327 328 $($(obj.getConfig().IdMsgAccion)).html(" ");329 $.ajax({330 type: "POST",331 url: fileupd,332 data: param,333 dataType:"json",334 success: function(msg){ 335 if (msg.IsSucceed)336 {337 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);338 }else339 {340 alert(msg.Msg); 341 }342 $.unblockUI();343 $("#MsgGuardando").hide();344 $("#MsgGuardando").html("Guardando...");345 }346 });347 }348 this.SeleccionarSubirMultimediaPreview = function(multimediacod)349 {350 $("#MsgGuardando").show();351 var param, url;352 param = "prefijo="+$(obj.getConfig().IdPrefijo).val();353 param += "&codigo="+$(obj.getConfig().IdCodigo).val();354 param += "&multimediacod="+multimediacod; 355 param += "&accion=5";356 357 obj.AbrirPopupMultimedia("Cargando formulario...","mul_multimedia_general_preview_fotos_am.php");358 }359 this.AbrirPopupDominio = function(multimediacod)360 {361 var param, url;362 param = "multimediacod="+multimediacod; 363 364 $("#MsgGuardando").html("Cargando...")365 $("#MsgGuardando").show();366 $.ajax({367 type: "POST",368 url: "mul_multimedia_general_dominio.php",369 data: param,370 success: function(msg){371 $($(obj.getConfig().IdPopup)).dialog({ 372 height: 100, 373 width: 800, 374 zIndex: 999999999,375 position: 'center', 376 resizable: false,377 title: "Multimedia", 378 open: function(type, data) {$($(obj.getConfig().IdPopup)).html(msg);}379 });380 $("#MsgGuardando").hide();381 $("#MsgGuardando").html("Guardando...");382 }383 });384 }// Fin Multimedia385 this.ModificarTitulo = function(txt,multimediacod)386 {387 $("#MsgGuardando").show();388 var param, url;389 param = "prefijo="+$(obj.getConfig().IdPrefijo).val();390 param += "&codigo="+$(obj.getConfig().IdCodigo).val();391 param += "&multimediatitulo="+$("#multimediatitulo_"+multimediacod).val(); 392 param += "&multimediacod="+multimediacod; 393 param += "&accion=6";394 395 $($(obj.getConfig().IdMsgAccion)).html(" ");396 $.ajax({397 type: "POST",398 url: fileupd,399 data: param,400 dataType:"json",401 success: function(msg){ 402 if (msg.IsSucceed)403 {404 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);405 }else406 {407 alert(msg.Msg); 408 }409 $("#MsgGuardando").hide();410 }411 });412 }413 this.ModificarDescripcion = function(txt,multimediacod)414 {415 $("#MsgGuardando").show();416 var param, url;417 param = "prefijo="+$(obj.getConfig().IdPrefijo).val();418 param += "&codigo="+$(obj.getConfig().IdCodigo).val();419 param += "&multimediadesc="+$("#multimediadesc_"+multimediacod).val(); 420 param += "&multimediacod="+multimediacod; 421 param += "&accion=7";422 423 $($(obj.getConfig().IdMsgAccion)).html(" ");424 $.ajax({425 type: "POST",426 url: fileupd,427 data: param,428 dataType:"json",429 success: function(msg){ 430 if (msg.IsSucceed)431 {432 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);433 }else434 {435 alert(msg.Msg); 436 }437 $("#MsgGuardando").hide();438 }439 });440 }441 this.RelacionarPreview = function(multimediacod,multimediacodrelacion)442 {443 $("#MsgGuardando").show();444 var param, url;445 $.blockUI({ message: '<h1 class="h1block"><img src="images/cargando.gif" /> Seleccionando preview...</h1>',baseZ: 9999999999 }) 446 param = "prefijo="+$(obj.getConfig().IdPrefijo).val();447 param += "&codigo="+$(obj.getConfig().IdCodigo).val();448 param += "&multimediacod="+ObjMultimedia.IdMultimedia; 449 param += "&multimediacodRelacion="+multimediacod; 450 param += "&accion=8";451 452 $($(obj.getConfig().IdMsgAccion)).html(" ");453 $.ajax({454 type: "POST",455 url: fileupd,456 data: param,457 dataType:"json",458 success: function(msg){ 459 if (msg.IsSucceed)460 {461 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);462 if (obj.getConfig().Video==true)463 obj.CargarVideos();464 if (obj.getConfig().Audio==true)465 obj.CargarAudios();466 if (obj.getConfig().Archivos==true)467 obj.CargarArchivos();468 }else469 {470 alert(msg.Msg); 471 }472 $.unblockUI();473 $("#MsgGuardando").hide();474 $("#MsgGuardando").html("Guardando...");475 }476 });477 }478 this.EliminarPreview = function(multimediacod)479 {480 if (!confirm("Esta seguro que desea eliminar el preview?"))481 return false;482 483 $("#MsgGuardando").show();484 var param, url;485 $.blockUI({ message: '<h1 class="h1block"><img src="images/cargando.gif" /> Eliminando preview...</h1>',baseZ: 9999999999 }) 486 param = "prefijo="+$(obj.getConfig().IdPrefijo).val();487 param += "&codigo="+$(obj.getConfig().IdCodigo).val();488 param += "&multimediacod="+multimediacod; 489 param += "&accion=9";490 491 $($(obj.getConfig().IdMsgAccion)).html(" ");492 $.ajax({493 type: "POST",494 url: fileupd,495 data: param,496 dataType:"json",497 success: function(msg){ 498 if (msg.IsSucceed)499 {500 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);501 if (obj.getConfig().Video==true)502 obj.CargarVideos();503 if (obj.getConfig().Audio==true)504 obj.CargarAudios();505 if (obj.getConfig().Archivos==true)506 obj.CargarArchivos();507 508 }else509 {510 alert(msg.Msg); 511 }512 $.unblockUI();513 $("#MsgGuardando").hide();514 $("#MsgGuardando").html("Guardando...");515 }516 });517 }518 519 520 this.SubirRelacionarMultimediaPreview = function(multimediacod)521 {522 $("#MsgGuardando").show();523 var param, url;524 $.blockUI({ message: '<h1 class="h1block"><img src="images/cargando.gif" /> Subiendo preview...</h1>',baseZ: 9999999999 }) 525 param = $("#form_mul_multimedia_img").serialize(); 526 param += "&prefijo="+$(obj.getConfig().IdPrefijo).val();527 param += "&codigo="+$(obj.getConfig().IdCodigo).val();528 param += "&multimediacod="+ObjMultimedia.IdMultimedia; 529 param += "&accion=10";530 531 $($(obj.getConfig().IdMsgAccion)).html(" ");532 $.ajax({533 type: "POST",534 url: fileupd,535 data: param,536 dataType:"json",537 success: function(msg){ 538 if (msg.IsSucceed)539 {540 $($(obj.getConfig().IdMsgAccion)).html(msg.Msg);541 $(ObjMultimedia.getConfig().IdPopup).dialog("close");542 if (obj.getConfig().Video==true)543 obj.CargarVideos();544 if (obj.getConfig().Audio==true)545 obj.CargarAudios();546 if (obj.getConfig().Archivos==true)547 obj.CargarArchivos();548 }else549 {550 alert(msg.Msg); 551 }552 $.unblockUI();553 $("#MsgGuardando").hide();554 $("#MsgGuardando").html("Guardando...");555 }556 });557 }558 559 };560 561 $.fn.extend({562 multimediaBigTree: function(options)563 {564 return multimediaBigTree = new MultimediaBigTree(this, options);565 }566 });...
shapes.js
Source:shapes.js
1import { line, curveBasis } from 'd3';2import idCache from './id-cache.js';3import stateDb from './stateDb';4import utils from '../../utils';5import common from '../common/common';6import { getConfig } from '../../config';7import { log } from '../../logger';8/**9 * Draws a start state as a black circle10 *11 * @param {any} g12 */13export const drawStartState = (g) =>14 g15 .append('circle')16 // .style('stroke', 'black')17 // .style('fill', 'black')18 .attr('class', 'start-state')19 .attr('r', getConfig().state.sizeUnit)20 .attr('cx', getConfig().state.padding + getConfig().state.sizeUnit)21 .attr('cy', getConfig().state.padding + getConfig().state.sizeUnit);22/**23 * Draws a start state as a black circle24 *25 * @param {any} g26 */27export const drawDivider = (g) =>28 g29 .append('line')30 .style('stroke', 'grey')31 .style('stroke-dasharray', '3')32 .attr('x1', getConfig().state.textHeight)33 .attr('class', 'divider')34 .attr('x2', getConfig().state.textHeight * 2)35 .attr('y1', 0)36 .attr('y2', 0);37/**38 * Draws a an end state as a black circle39 *40 * @param {any} g41 * @param {any} stateDef42 */43export const drawSimpleState = (g, stateDef) => {44 const state = g45 .append('text')46 .attr('x', 2 * getConfig().state.padding)47 .attr('y', getConfig().state.textHeight + 2 * getConfig().state.padding)48 .attr('font-size', getConfig().state.fontSize)49 .attr('class', 'state-title')50 .text(stateDef.id);51 const classBox = state.node().getBBox();52 g.insert('rect', ':first-child')53 .attr('x', getConfig().state.padding)54 .attr('y', getConfig().state.padding)55 .attr('width', classBox.width + 2 * getConfig().state.padding)56 .attr('height', classBox.height + 2 * getConfig().state.padding)57 .attr('rx', getConfig().state.radius);58 return state;59};60/**61 * Draws a state with descriptions62 *63 * @param {any} g64 * @param {any} stateDef65 * @returns66 */67export const drawDescrState = (g, stateDef) => {68 const addTspan = function (textEl, txt, isFirst) {69 const tSpan = textEl70 .append('tspan')71 .attr('x', 2 * getConfig().state.padding)72 .text(txt);73 if (!isFirst) {74 tSpan.attr('dy', getConfig().state.textHeight);75 }76 };77 const title = g78 .append('text')79 .attr('x', 2 * getConfig().state.padding)80 .attr('y', getConfig().state.textHeight + 1.3 * getConfig().state.padding)81 .attr('font-size', getConfig().state.fontSize)82 .attr('class', 'state-title')83 .text(stateDef.descriptions[0]);84 const titleBox = title.node().getBBox();85 const titleHeight = titleBox.height;86 const description = g87 .append('text') // text label for the x axis88 .attr('x', getConfig().state.padding)89 .attr(90 'y',91 titleHeight +92 getConfig().state.padding * 0.4 +93 getConfig().state.dividerMargin +94 getConfig().state.textHeight95 )96 .attr('class', 'state-description');97 let isFirst = true;98 let isSecond = true;99 stateDef.descriptions.forEach(function (descr) {100 if (!isFirst) {101 addTspan(description, descr, isSecond);102 isSecond = false;103 }104 isFirst = false;105 });106 const descrLine = g107 .append('line') // text label for the x axis108 .attr('x1', getConfig().state.padding)109 .attr('y1', getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2)110 .attr('y2', getConfig().state.padding + titleHeight + getConfig().state.dividerMargin / 2)111 .attr('class', 'descr-divider');112 const descrBox = description.node().getBBox();113 const width = Math.max(descrBox.width, titleBox.width);114 descrLine.attr('x2', width + 3 * getConfig().state.padding);115 // const classBox = title.node().getBBox();116 g.insert('rect', ':first-child')117 .attr('x', getConfig().state.padding)118 .attr('y', getConfig().state.padding)119 .attr('width', width + 2 * getConfig().state.padding)120 .attr('height', descrBox.height + titleHeight + 2 * getConfig().state.padding)121 .attr('rx', getConfig().state.radius);122 return g;123};124/** Adds the creates a box around the existing content and adds a panel for the id on top of the content. */125/**126 * Function that creates an title row and a frame around a substate for a composit state diagram.127 * The function returns a new d3 svg object with updated width and height properties;128 *129 * @param {any} g The d3 svg object for the substate to framed130 * @param {any} stateDef The info about the131 * @param {any} altBkg132 */133export const addTitleAndBox = (g, stateDef, altBkg) => {134 const pad = getConfig().state.padding;135 const dblPad = 2 * getConfig().state.padding;136 const orgBox = g.node().getBBox();137 const orgWidth = orgBox.width;138 const orgX = orgBox.x;139 const title = g140 .append('text')141 .attr('x', 0)142 .attr('y', getConfig().state.titleShift)143 .attr('font-size', getConfig().state.fontSize)144 .attr('class', 'state-title')145 .text(stateDef.id);146 const titleBox = title.node().getBBox();147 const titleWidth = titleBox.width + dblPad;148 let width = Math.max(titleWidth, orgWidth); // + dblPad;149 if (width === orgWidth) {150 width = width + dblPad;151 }152 let startX;153 // const lineY = 1 - getConfig().state.textHeight;154 // const descrLine = g155 // .append('line') // text label for the x axis156 // .attr('x1', 0)157 // .attr('y1', lineY)158 // .attr('y2', lineY)159 // .attr('class', 'descr-divider');160 const graphBox = g.node().getBBox();161 // descrLine.attr('x2', graphBox.width + getConfig().state.padding);162 if (stateDef.doc) {163 // cnsole.warn(164 // stateDef.id,165 // 'orgX: ',166 // orgX,167 // 'width: ',168 // width,169 // 'titleWidth: ',170 // titleWidth,171 // 'orgWidth: ',172 // orgWidth,173 // 'width',174 // width175 // );176 }177 startX = orgX - pad;178 if (titleWidth > orgWidth) {179 startX = (orgWidth - width) / 2 + pad;180 }181 if (Math.abs(orgX - graphBox.x) < pad) {182 if (titleWidth > orgWidth) {183 startX = orgX - (titleWidth - orgWidth) / 2;184 }185 }186 const lineY = 1 - getConfig().state.textHeight;187 // White color188 g.insert('rect', ':first-child')189 .attr('x', startX)190 .attr('y', lineY)191 .attr('class', altBkg ? 'alt-composit' : 'composit')192 .attr('width', width)193 .attr(194 'height',195 graphBox.height + getConfig().state.textHeight + getConfig().state.titleShift + 1196 )197 .attr('rx', '0');198 title.attr('x', startX + pad);199 if (titleWidth <= orgWidth) title.attr('x', orgX + (width - dblPad) / 2 - titleWidth / 2 + pad);200 // Title background201 g.insert('rect', ':first-child')202 .attr('x', startX)203 .attr(204 'y',205 getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding206 )207 .attr('width', width)208 // Just needs to be higher then the descr line, will be clipped by the white color box209 .attr('height', getConfig().state.textHeight * 3)210 .attr('rx', getConfig().state.radius);211 // Full background212 g.insert('rect', ':first-child')213 .attr('x', startX)214 .attr(215 'y',216 getConfig().state.titleShift - getConfig().state.textHeight - getConfig().state.padding217 )218 .attr('width', width)219 .attr('height', graphBox.height + 3 + 2 * getConfig().state.textHeight)220 .attr('rx', getConfig().state.radius);221 return g;222};223const drawEndState = (g) => {224 g.append('circle')225 // .style('stroke', 'black')226 // .style('fill', 'white')227 .attr('class', 'end-state-outer')228 .attr('r', getConfig().state.sizeUnit + getConfig().state.miniPadding)229 .attr(230 'cx',231 getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding232 )233 .attr(234 'cy',235 getConfig().state.padding + getConfig().state.sizeUnit + getConfig().state.miniPadding236 );237 return (238 g239 .append('circle')240 // .style('stroke', 'black')241 // .style('fill', 'black')242 .attr('class', 'end-state-inner')243 .attr('r', getConfig().state.sizeUnit)244 .attr('cx', getConfig().state.padding + getConfig().state.sizeUnit + 2)245 .attr('cy', getConfig().state.padding + getConfig().state.sizeUnit + 2)246 );247};248const drawForkJoinState = (g, stateDef) => {249 let width = getConfig().state.forkWidth;250 let height = getConfig().state.forkHeight;251 if (stateDef.parentId) {252 let tmp = width;253 width = height;254 height = tmp;255 }256 return g257 .append('rect')258 .style('stroke', 'black')259 .style('fill', 'black')260 .attr('width', width)261 .attr('height', height)262 .attr('x', getConfig().state.padding)263 .attr('y', getConfig().state.padding);264};265export const drawText = function (elem, textData) {266 // Remove and ignore br:s267 const nText = textData.text.replace(common.lineBreakRegex, ' ');268 const textElem = elem.append('text');269 textElem.attr('x', textData.x);270 textElem.attr('y', textData.y);271 textElem.style('text-anchor', textData.anchor);272 textElem.attr('fill', textData.fill);273 if (typeof textData.class !== 'undefined') {274 textElem.attr('class', textData.class);275 }276 const span = textElem.append('tspan');277 span.attr('x', textData.x + textData.textMargin * 2);278 span.attr('fill', textData.fill);279 span.text(nText);280 return textElem;281};282const _drawLongText = (_text, x, y, g) => {283 let textHeight = 0;284 const textElem = g.append('text');285 textElem.style('text-anchor', 'start');286 textElem.attr('class', 'noteText');287 let text = _text.replace(/\r\n/g, '<br/>');288 text = text.replace(/\n/g, '<br/>');289 const lines = text.split(common.lineBreakRegex);290 let tHeight = 1.25 * getConfig().state.noteMargin;291 for (const line of lines) {292 const txt = line.trim();293 if (txt.length > 0) {294 const span = textElem.append('tspan');295 span.text(txt);296 if (tHeight === 0) {297 const textBounds = span.node().getBBox();298 tHeight += textBounds.height;299 }300 textHeight += tHeight;301 span.attr('x', x + getConfig().state.noteMargin);302 span.attr('y', y + textHeight + 1.25 * getConfig().state.noteMargin);303 }304 }305 return { textWidth: textElem.node().getBBox().width, textHeight };306};307/**308 * Draws a note to the diagram309 *310 * @param text - The text of the given note.311 * @param g - The element the note is attached to.312 */313export const drawNote = (text, g) => {314 g.attr('class', 'state-note');315 const note = g.append('rect').attr('x', 0).attr('y', getConfig().state.padding);316 const rectElem = g.append('g');317 const { textWidth, textHeight } = _drawLongText(text, 0, 0, rectElem);318 note.attr('height', textHeight + 2 * getConfig().state.noteMargin);319 note.attr('width', textWidth + getConfig().state.noteMargin * 2);320 return note;321};322/**323 * Starting point for drawing a state. The function finds out the specifics about the state and324 * renders with approprtiate function.325 *326 * @param {any} elem327 * @param {any} stateDef328 */329export const drawState = function (elem, stateDef) {330 const id = stateDef.id;331 const stateInfo = {332 id: id,333 label: stateDef.id,334 width: 0,335 height: 0,336 };337 const g = elem.append('g').attr('id', id).attr('class', 'stateGroup');338 if (stateDef.type === 'start') drawStartState(g);339 if (stateDef.type === 'end') drawEndState(g);340 if (stateDef.type === 'fork' || stateDef.type === 'join') drawForkJoinState(g, stateDef);341 if (stateDef.type === 'note') drawNote(stateDef.note.text, g);342 if (stateDef.type === 'divider') drawDivider(g);343 if (stateDef.type === 'default' && stateDef.descriptions.length === 0)344 drawSimpleState(g, stateDef);345 if (stateDef.type === 'default' && stateDef.descriptions.length > 0) drawDescrState(g, stateDef);346 const stateBox = g.node().getBBox();347 stateInfo.width = stateBox.width + 2 * getConfig().state.padding;348 stateInfo.height = stateBox.height + 2 * getConfig().state.padding;349 idCache.set(id, stateInfo);350 // stateCnt++;351 return stateInfo;352};353let edgeCount = 0;354export const drawEdge = function (elem, path, relation) {355 const getRelationType = function (type) {356 switch (type) {357 case stateDb.relationType.AGGREGATION:358 return 'aggregation';359 case stateDb.relationType.EXTENSION:360 return 'extension';361 case stateDb.relationType.COMPOSITION:362 return 'composition';363 case stateDb.relationType.DEPENDENCY:364 return 'dependency';365 }366 };367 path.points = path.points.filter((p) => !Number.isNaN(p.y));368 // The data for our line369 const lineData = path.points;370 // This is the accessor function we talked about above371 const lineFunction = line()372 .x(function (d) {373 return d.x;374 })375 .y(function (d) {376 return d.y;377 })378 .curve(curveBasis);379 const svgPath = elem380 .append('path')381 .attr('d', lineFunction(lineData))382 .attr('id', 'edge' + edgeCount)383 .attr('class', 'transition');384 let url = '';385 if (getConfig().state.arrowMarkerAbsolute) {386 url =387 window.location.protocol +388 '//' +389 window.location.host +390 window.location.pathname +391 window.location.search;392 url = url.replace(/\(/g, '\\(');393 url = url.replace(/\)/g, '\\)');394 }395 svgPath.attr(396 'marker-end',397 'url(' + url + '#' + getRelationType(stateDb.relationType.DEPENDENCY) + 'End' + ')'398 );399 if (typeof relation.title !== 'undefined') {400 const label = elem.append('g').attr('class', 'stateLabel');401 const { x, y } = utils.calcLabelPosition(path.points);402 const rows = common.getRows(relation.title);403 let titleHeight = 0;404 const titleRows = [];405 let maxWidth = 0;406 let minX = 0;407 for (let i = 0; i <= rows.length; i++) {408 const title = label409 .append('text')410 .attr('text-anchor', 'middle')411 .text(rows[i])412 .attr('x', x)413 .attr('y', y + titleHeight);414 const boundstmp = title.node().getBBox();415 maxWidth = Math.max(maxWidth, boundstmp.width);416 minX = Math.min(minX, boundstmp.x);417 log.info(boundstmp.x, x, y + titleHeight);418 if (titleHeight === 0) {419 const titleBox = title.node().getBBox();420 titleHeight = titleBox.height;421 log.info('Title height', titleHeight, y);422 }423 titleRows.push(title);424 }425 let boxHeight = titleHeight * rows.length;426 if (rows.length > 1) {427 const heightAdj = (rows.length - 1) * titleHeight * 0.5;428 titleRows.forEach((title, i) => title.attr('y', y + i * titleHeight - heightAdj));429 boxHeight = titleHeight * rows.length;430 }431 const bounds = label.node().getBBox();432 label433 .insert('rect', ':first-child')434 .attr('class', 'box')435 .attr('x', x - maxWidth / 2 - getConfig().state.padding / 2)436 .attr('y', y - boxHeight / 2 - getConfig().state.padding / 2 - 3.5)437 .attr('width', maxWidth + getConfig().state.padding)438 .attr('height', boxHeight + getConfig().state.padding);439 log.info(bounds);440 //label.attr('transform', '0 -' + (bounds.y / 2));441 // Debug points442 // path.points.forEach(point => {443 // g.append('circle')444 // .style('stroke', 'red')445 // .style('fill', 'red')446 // .attr('r', 1)447 // .attr('cx', point.x)448 // .attr('cy', point.y);449 // });450 // g.append('circle')451 // .style('stroke', 'blue')452 // .style('fill', 'blue')453 // .attr('r', 1)454 // .attr('cx', x)455 // .attr('cy', y);456 }457 edgeCount++;...
api.js
Source:api.js
1import axios from 'axios';2import util from '../common/js/util'3let openapi_server = axios.create({4 baseURL: OPENAPI_SERVER,5 headers: {6 'Content-Type':'application/json'7 }8 });9const getConfig = params => { return { headers: { 'token':sms_store('sms-token') } }; };10const getMultipartConfig = params => { return { headers: { 'Content-Type':'multipart/form-data;charset=UTF-8', 'token':sms_store('sms-token') } }; };11export const requestLogin = params => { return openapi_server.post(`login`, params); };12export const ssoLogin = params => { return openapi_server.post(`login/sso`, params); };13export const requestCaptcha = force => { return openapi_server.get(`captcha/` + force); };14export const getStudentList = params => { return util.checkToken(openapi_server.post(`base/getStudentList`, params, getConfig())); };15export const syncBase = params => { return util.checkToken(openapi_server.post(`base/sync`, params, getConfig())); };16export const getExamYearTermList = params => { return util.checkToken(openapi_server.post(`exam/getTermList`, params, getConfig())); };17export const getExamExamTypeList = params => { return util.checkToken(openapi_server.post(`exam/getTypeList`, params, getConfig())); };18export const getExamGradeList = params => { return util.checkToken(openapi_server.post(`exam/getGradeList`, params, getConfig())); };19export const getExamSubjectList = params => { return util.checkToken(openapi_server.post(`exam/getSubjectList`, params, getConfig())); };20export const getExamClassList = params => { return util.checkToken(openapi_server.post(`exam/getClassList`, params, getConfig())); }21export const searchExam = params => { return util.checkToken(openapi_server.post(`exam/search`, params, getConfig())); };22export const getSimpleExamList = params => { return util.checkToken(openapi_server.post(`exam/getSimpleList`, params, getConfig())); };23export const getRecentExams = (pages, params) => { return util.checkToken(openapi_server.post(`exam/recent/` + pages, params, getConfig())); };24export const addExam = params => { return util.checkToken(openapi_server.post(`exam/add`, params, getConfig())); };25export const updateExam = params => { return util.checkToken(openapi_server.post(`exam/update`, params, getConfig())); };26export const syncExam = params => { return util.checkToken(openapi_server.post(`exam/sync`, params, getConfig())); };27export const closeExam = examid => { return util.checkToken(openapi_server.get(`exam/close/` + examid, getConfig())); };28export const getExamInfo = examid => { return util.checkToken(openapi_server.get(`exam/` + examid, getConfig())); };29export const deleteExam = examid => { return util.checkToken(openapi_server.get(`exam/delete/` + examid, getConfig())); };30export const getAnalysisConfig = params => { return util.checkToken(openapi_server.post(`sys/analysis-config/search`, params, getConfig())); };31export const getAnalysisScoreLevelConfig = params => { return util.checkToken(openapi_server.post(`sys/analysis-score-level/search`, params, getConfig())); };32export const setAnalysisConfig = params => { return util.checkToken(openapi_server.post(`sys/analysis-config/addUpdate`, params, getConfig())); };33export const setAnalysisScoreLevelConfig = (examid, gradeid, subjecttype, subjectid, volumeid, params) => { return util.checkToken(openapi_server.post(`sys/analysis-score-level/batchAdd/` + examid + `/` + gradeid + `/` + subjecttype + `/` + subjectid + `/` + volumeid, params, getConfig())); };34export const getExamSubjectScoreList = params => { return util.checkToken(openapi_server.post(`exam-subject-score/search`, params, getConfig())); };35export const setExamSubjectScore = params => { return util.checkToken(openapi_server.post(`exam-subject-score/save`, params, getConfig())); };36export const getPubStatusList = params => { return util.checkToken(openapi_server.post(`exam-subject-score/getPubStatusList`, params, getConfig())); };37export const publishExamSubjectScore = params => { return util.checkToken(openapi_server.post(`exam-subject-score/publish`, params, getConfig())); };38export const unPublishExamSubjectScore = params => { return util.checkToken(openapi_server.post(`exam-subject-score/unpublish`, params, getConfig())); };39export const getExamQuestionScoreList = params => { return util.checkToken(openapi_server.post(`exam-part-score/search`, params, getConfig())); };40export const setExamQuestionScore = (examsubjectscoreid, params) => { return util.checkToken(openapi_server.post(`exam-part-score/batchAdd/` + examsubjectscoreid, params, getConfig())); };41export const importExamQuestionScore = (examid, params) => { return util.checkToken(openapi_server.post(`exam-part-score/import/` + examid, params, getMultipartConfig())); };42export const exportExamQuestionScore = params => { return util.checkToken(openapi_server.post(`exam-part-score/export`, params, getConfig())); };43export const importStudentTotalScore = (fullscoreid, params) => { return util.checkToken(openapi_server.post(`student-subject-score/import/` + fullscoreid, params, getMultipartConfig())); };44export const getSubjectIndividualList = params => { return util.checkToken(openapi_server.post(`student-subject-score/getIndividualList`, params, getConfig())); };45export const getStudentTotalScoreList = params => { return util.checkToken(openapi_server.post(`student-subject-score/search`, params, getConfig())) };46export const setStudentTotalScore = params => { return util.checkToken(openapi_server.post(`student-subject-score/save`, params, getConfig())) };47export const getEnteredStudentList = params => { return util.checkToken(openapi_server.post(`student-subject-score/getScoreEnteredList`, params, getConfig())) };48export const getUnenteredStudentList = params => { return util.checkToken(openapi_server.post(`student-subject-score/getScoreUnenteredList`, params, getConfig())) };49export const getExamMissedStudentList = params => { return util.checkToken(openapi_server.post(`student-subject-score/getExamMissedList`, params, getConfig())) };50export const exportPersonalExamTotalScore = params => { return util.checkToken(openapi_server.post(`student-subject-score/export/book/word`, params, getConfig())) };51export const getUpdateScoreProposalList = params => { return util.checkToken(openapi_server.post(`student-subject-score/review/search`, params, getConfig())) };52export const requestUpdateScoreProposal = params => { return util.checkToken(openapi_server.post(`student-subject-score/review/request`, params, getConfig())) };53export const deleteUpdateScoreProposal = params => { return util.checkToken(openapi_server.post(`student-subject-score/review/batchDelete`, params, getConfig())) };54export const acceptUpdateScoreProposal = params => { return util.checkToken(openapi_server.post(`student-subject-score/review/batchAccept`, params, getConfig())) };55export const rejectUpdateScoreProposal = params => { return util.checkToken(openapi_server.post(`student-subject-score/review/batchReject`, params, getConfig())) };56export const getReviewStudentList = params => { return util.checkToken(openapi_server.post(`student-subject-score/review/getStudentList`, params, getConfig())) };57export const getStudentPartScoreList = params => { return util.checkToken(openapi_server.post(`student-part-score/search`, params, getConfig())) };58export const importQuestionScore = (examid, params) => { return util.checkToken(openapi_server.post(`student-part-score/import/` + examid, params, getMultipartConfig())); };59export const getScoreRankStat = (params) => { return util.checkToken(openapi_server.post(`rank-stats/getList`, params, getConfig())); };60export const exportScoreRankStat = (params) => { return util.checkToken(openapi_server.post(`rank-stats/export`, params, getConfig())); };61export const exportScoreRankStatForCompare = (params) => { return util.checkToken(openapi_server.post(`rank-stats/export/compare`, params, getConfig())); };62export const getSubjectAvgScoreList = params => { return util.checkToken(openapi_server.post(`subject-average-score/getList`, params, getConfig())); };63export const exportSubjectAvgScore = params => { return util.checkToken(openapi_server.post(`subject-average-score/export`, params, getConfig())); };64export const exportSubjectAvgScoreByClass = params => { return util.checkToken(openapi_server.post(`subject-average-score/export/class`, params, getConfig())); };65export const getStudentTopCountStatList = params => { return util.checkToken(openapi_server.post(`class-top-count-stats/getList`, params, getConfig())); };66export const exportStudentTopCountStat = params => { return util.checkToken(openapi_server.post(`class-top-count-stats/export`, params, getConfig())); };67export const exportStudentTopCountStatForCompare = params => { return util.checkToken(openapi_server.post(`class-top-count-stats/export/compare`, params, getConfig())); };68export const getRankZoneStatList = params => { return util.checkToken(openapi_server.post(`rank-zone-stats/getList`, params, getConfig())); };69export const exportRankZoneStat = params => { return util.checkToken(openapi_server.post(`rank-zone-stats/export`, params, getConfig())); };70export const getLevelZoneStatList = params => { return util.checkToken(openapi_server.post(`level-zone-stats/getList`, params, getConfig())); };71export const exportLevelZoneStat = params => { return util.checkToken(openapi_server.post(`level-zone-stats/export`, params, getConfig())) };72export const getEqualityStatList = params => { return util.checkToken(openapi_server.post(`equality-stats/getList`, params, getConfig())) };73export const exportExqualityStat = params => { return util.checkToken(openapi_server.post(`equality-stats/export`, params, getConfig())) };74export const exportExqualityStatForCompare = params => { return util.checkToken(openapi_server.post(`equality-stats/export/compare`, params, getConfig())) };75export const exportExqualityStatByClass = params => { return util.checkToken(openapi_server.post(`equality-stats/export/class`, params, getConfig())) };76export const getScoreZoneStatList = params => { return util.checkToken(openapi_server.post(`score-zone-stats/getList`, params, getConfig())); };77export const exportScoreZoneStat = params => { return util.checkToken(openapi_server.post(`score-zone-stats/export`, params, getConfig())); };78export const getPartRateStatList = params => { return util.checkToken(openapi_server.post(`part-gain-rate-stats/getList`, params, getConfig())); };79export const exportPartRateStat = params => { return util.checkToken(openapi_server.post(`part-gain-rate-stats/export`, params, getConfig())); };80export const getSubjectDifficultyStatList = params => { return util.checkToken(openapi_server.post(`difficulty-stats/getList`, params, getConfig())); };81export const exportSubjectDifficultyStat = params => { return util.checkToken(openapi_server.post(`difficulty-stats/export`, params, getConfig())); };82export const getQuestionDifficultyStatList = params => { return util.checkToken(openapi_server.post(`part-difficulty-stats/getList`, params, getConfig())); };83export const exportQuestionDifficultyStat = params => { return util.checkToken(openapi_server.post(`part-difficulty-stats/export`, params, getConfig())); };84export const getStudentStatList = params => { return util.checkToken(openapi_server.post(`student-stats/getList`, params, getConfig())); };85// ECO API86const getEcoBaseAPIConfig = params => {87 return {88 baseURL: ECOAPI_SERVER + 'openapi-base',89 headers: {90 'access-token':sms_store('sms-token'),91 'Content-Type':'application/json',92 'Tenant-Id':TENANT_ID93 }94 };95};96const getEcoScoreAPIConfig = params => {97 return {98 baseURL: ECOAPI_SERVER + 'openapi-score',99 headers: {100 'access-token':sms_store('sms-token'),101 'Content-Type':'application/json',102 'Tenant-Id':TENANT_ID103 }104 };105};106const getEcoUCAPIConfig = params => {107 return {108 baseURL: ECOAPI_SERVER + 'openapi-uc',109 headers: {110 'access-token':sms_store('sms-token'),111 'Content-Type':'application/json'112 }113 };114};115export const updatePwdECO = (params, message) => { return util.checkECOToken(openapi_server.post(`/uc/updatePwd`, params, getEcoUCAPIConfig()), message); };116export const joinSearchClasses = (params, message) => { return util.checkECOToken(openapi_server.post(`/base/joinSearchClasses`, params, getEcoBaseAPIConfig()), message); };117export const joinSearchSchools = (params, message) => { return util.checkECOToken(openapi_server.post(`/base/joinSearchSchools`, params, getEcoBaseAPIConfig()), message); };118export const queryTeachs = (params, message) => { return util.checkECOToken(openapi_server.post(`/base/queryTeachs`, params, getEcoBaseAPIConfig()), message); };119export const queryDictItemList = (params, message) => { return util.checkECOToken(openapi_server.post(`/base/queryDictItemList`, params, getEcoBaseAPIConfig()), message); };120export const queryTermList = (params, message) => { return util.checkECOToken(openapi_server.post(`/base/queryTermList`, params, getEcoBaseAPIConfig()), message); };121export const queryExamInfoList = (params, message) => { return util.checkECOToken(openapi_server.post(`/exam/queryExamInfoList`, params, getEcoScoreAPIConfig()), message); };...
facade.js
Source:facade.js
1//@flow2// import { Just, Nothing, fromNullable, Maybe } from 'folktale/maybe'3import { Maybe } from 'apropos'4const { fromNullable } = Maybe5import { type PublicKey } from '../service/main/index.h'6import { type DCNumber } from 'Newtype'7import getCrypto from '../co-worker'8import { getConfig } from './provider'9import random from '../service/secure-random'10import KeyManager from '../service/authorizer/rsa-keys-manger'11import NetworkerThread from '../service/networker'12import L1Cache from '../l1-cache'13const Config = {14 halt: {15 get(uid: string, dc: number): boolean {16 const val = getConfig(uid).halt[dc]17 if (typeof val !== 'boolean') {18 Config.halt.set(uid, dc, false)19 return false20 }21 return val22 },23 set(uid: string, dc: number, val: boolean) {24 getConfig(uid).halt[dc] = val25 }26 },27 // invoke(method: string, params: Object = {}, opts: Object = {}) {28 //29 // },30 seq: {31 get(uid: string, dc: number) {32 const seq = getConfig(uid).seq[dc]33 if (typeof seq !== 'number') {34 Config.seq.set(uid, dc, 1)35 return 136 }37 return seq38 },39 set(uid: string, dc: number, newSeq: number) {40 getConfig(uid).seq[dc] = newSeq41 }42 },43 apiConfig: {44 get(uid: string) {45 return getConfig(uid).apiConfig46 }47 },48 thread: {49 set(uid: string, dc: DCNumber, thread: NetworkerThread) {50 getConfig(uid).thread[dc] = thread51 },52 get(uid: string, dc: DCNumber) {53 return fromNullable(getConfig(uid).thread[dc])54 },55 },56 storage: {57 get(uid: string, key: string): Promise<mixed> {58 return getConfig(uid).storage.get(key)59 },60 set(uid: string, key: string, value: any): Promise<void> {61 return getConfig(uid).storage.set(key, value)62 },63 has(uid: string, key: string): Promise<boolean> {64 return getConfig(uid).storage.has(key)65 },66 remove(uid: string, ...keys: string[]): Promise<void> {67 return getConfig(uid).storage.remove(...keys)68 },69 },70 storageAdapter: {71 get: {72 authKey(uid: string, dc: number) {73 return getConfig(uid).storageAdapter.getAuthKey(dc)74 },75 authID(uid: string, dc: number) {76 return getConfig(uid).storageAdapter.getAuthID(dc)77 },78 salt(uid: string, dc: number) {79 return getConfig(uid).storageAdapter.getSalt(dc)80 },81 dc(uid: string) {82 return getConfig(uid).storageAdapter.getDC()83 },84 nearestDC(uid: string) {85 return getConfig(uid).storageAdapter.getNearestDC()86 },87 },88 set: {89 authKey(uid: string, dc: number, data: number[]) {90 return getConfig(uid).storageAdapter.setAuthKey(dc, data)91 },92 authID(uid: string, dc: number, data: number[]) {93 return getConfig(uid).storageAdapter.setAuthID(dc, data)94 },95 salt(uid: string, dc: number, data: number[]) {96 return getConfig(uid).storageAdapter.setSalt(dc, data)97 },98 dc(uid: string, dc: number) {99 return getConfig(uid).storageAdapter.setDC(dc)100 },101 nearestDC(uid: string, dc: number) {102 return getConfig(uid).storageAdapter.setNearestDC(dc)103 },104 },105 remove: {106 authKey(uid: string, dc: number) {107 return getConfig(uid).storageAdapter.removeAuthKey(dc)108 },109 authID(uid: string, dc: number) {110 return getConfig(uid).storageAdapter.removeAuthID(dc)111 },112 salt(uid: string, dc: number) {113 return getConfig(uid).storageAdapter.removeSalt(dc)114 },115 dc(uid: string) {116 return getConfig(uid).storageAdapter.removeDC()117 },118 nearestDC(uid: string) {119 return getConfig(uid).storageAdapter.removeNearestDC()120 },121 },122 },123 fastCache: {124 get(uid: string, dc: DCNumber) {125 return getConfig(uid).fastCache[dc | 0]126 },127 init(uid: string, dc: DCNumber) {128 getConfig(uid).fastCache[dc | 0] = L1Cache.of()129 }130 },131 publicKeys: {132 get(uid: string, keyHex: string): PublicKey | false {133 return getConfig(uid).publicKeys[keyHex] || false134 },135 set(uid: string, keyHex: string, key: PublicKey) {136 getConfig(uid).publicKeys[keyHex] = key137 },138 init(uid: string, keys: PublicKey[]) {139 getConfig(uid).keyManager = KeyManager(uid, keys, Config.publicKeys)140 },141 select(uid: string, fingerprints: string[]) {142 return getConfig(uid).keyManager(fingerprints)143 },144 },145 authRequest: {146 get(uid: string, dc: number) {147 return getConfig(uid).authRequest[dc]148 },149 set(uid: string, dc: number, req: *) {150 getConfig(uid).authRequest[dc] = req151 },152 remove(uid: string, dc: number) {153 delete getConfig(uid).authRequest[dc]154 },155 },156 session: {157 get(uid: string, dc: number) {158 let session = getConfig(uid).session[dc]159 if (!Array.isArray(session)) {160 session = new Array(8)161 random(session)162 Config.session.set(uid, dc, session)163 }164 return session165 },166 set(uid: string, dc: number, session: number[]) {167 getConfig(uid).session[dc] = session168 }169 },170 rootEmitter: (uid: string) => getConfig(uid).rootEmitter,171 emit : (uid: string) => getConfig(uid).emit,172 layer : {173 apiLayer: (uid: string) => getConfig(uid).layer.apiLayer,174 mtLayer : (uid: string) => getConfig(uid).layer.mtLayer,175 },176 schema: {177 get : (uid: string) => getConfig(uid).schema,178 apiSchema: (uid: string) => getConfig(uid).schema.apiSchema,179 mtSchema : (uid: string) => getConfig(uid).schema.mtSchema,180 },181 timerOffset: {182 get: (uid: string) => getConfig(uid).timerOffset,183 set(uid: string, value: number) {184 getConfig(uid).timerOffset = value185 }186 },187 lastMessageID: {188 get: (uid: string) => getConfig(uid).lastMessageID,189 set(uid: string, value: [number, number]) {190 getConfig(uid).lastMessageID = value191 }192 },193 dcMap(uid: string, id: DCNumber) {194 const dc = getConfig(uid).dcMap.get(id)195 if (typeof dc !== 'string')196 throw new Error(`Wrong dc id! ${id}`)197 return dc198 },199 dcList(uid: string) {200 return [...getConfig(uid).dcMap.keys()]201 },202 common: getCrypto()203}...
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!!