How to use d.updateSettings method in Appium

Best JavaScript code snippet using appium

Settings.js

Source:Settings.js Github

copy

Full Screen

1import { IconClose } from "./icons/close.js";2export function Settings({ settings, setSettings, setSentimentStatus, setDraftStatus, setCurrentPick }) {3 //closing the menu4 const handleSettingsMenu = () => {5 setSettings({6 ...settings,7 misc: {8 ...settings.misc,9 menu_open: false,10 menu_transition: true,11 },12 });13 };14 const handleSettingsMenuTransition = () => {15 setSettings({16 ...settings,17 misc: {18 ...settings.misc,19 menu_transition: false,20 },21 });22 };23 //set state for updating settings24 const updateSettings = (property, cat, value) => {25 let test;26 cat === "scoring" ? (test = new RegExp(/^(?:-?[\d]*(?:\.?[\d]{1,2})||-?[\d]*\.||-)$/, "i")) : (test = new RegExp(/^\d+$/, "i"));27 if (value === "" || test.test(value)) {28 const updatedSettings = { ...settings };29 updatedSettings[cat][property] = value;30 setSettings(updatedSettings);31 }32 };33 //toggling the color mode34 const handleColorMode = () => {35 const targetMode = settings.misc?.color_mode === "light" ? "dark" : "light";36 setSettings({37 ...settings,38 misc: {39 ...settings.misc,40 color_mode: targetMode,41 },42 });43 };44 //toggle slider setting45 const handleToggle = (property, cat) => {46 setSettings({47 ...settings,48 [cat]: {49 ...settings[cat],50 [property]: !settings[cat][property],51 },52 });53 };54 return (55 <div56 className={`settings${settings["misc"]?.["menu_open"] ? " settings--open" : ""}${57 settings["misc"]?.["menu_transition"] ? " settings--transitioning" : ""58 }`}59 >60 <div className="settings__container">61 <button className="close-settings" onClick={() => handleSettingsMenu()}>62 <IconClose />63 </button>64 <div className="league-settings">65 <h2 className="settings__title">League Settings</h2>66 <div className="settings__category-container settings__category-container--third">67 <h3 className="settings__category-title">General Settings</h3>68 {settings.general?.teams !== undefined && (69 <div className="input-containter">70 <label htmlFor="teams">Teams</label>71 <input72 className="text--number"73 id="teams"74 name="teams"75 type="text"76 value={settings.general.teams}77 onChange={(e) => updateSettings(e.target.name, "general", e.target.value)}78 />79 </div>80 )}81 {settings.general?.user_pick !== undefined && (82 <div className="input-containter">83 <label htmlFor="user-pick">Your Pick</label>84 <input85 className="text--number"86 id="user-pick"87 name="user_pick"88 type="text"89 value={settings.general.user_pick}90 onChange={(e) => updateSettings(e.target.name, "general", e.target.value)}91 />92 </div>93 )}94 </div>95 <div className="settings__category-container settings__category-container--full">96 {settings.general?.flex_te !== undefined && (97 <div className="switch__container">98 <label className="switch">99 <input type="checkbox" name="flex_te" checked={settings.general?.flex_te} onChange={(e) => handleToggle(e.target.name, "general")} />100 <span className="slider slider--round"></span>101 </label>102 <p className="switch__text">TE included in flex</p>103 </div>104 )}105 {settings.general?.flex_qb !== undefined && (106 <div className="switch__container">107 <label className="switch">108 <input type="checkbox" name="flex_qb" checked={settings.general?.flex_qb} onChange={(e) => handleToggle(e.target.name, "general")} />109 <span className="slider slider--round"></span>110 </label>111 <p className="switch__text">QB included in flex</p>112 </div>113 )}114 </div>115 <div className="settings__category-container settings__category-container--third">116 <h3 className="settings__category-title">Roster</h3>117 {settings.roster?.qb !== undefined && (118 <div className="input-containter">119 <label htmlFor="qb">QB</label>120 <input121 className="text--number"122 id="qb"123 name="qb"124 type="text"125 value={settings.roster.qb}126 onChange={(e) => updateSettings(e.target.name, "roster", e.target.value)}127 />128 </div>129 )}130 {settings.roster?.rb !== undefined && (131 <div className="input-containter">132 <label htmlFor="rb">RB</label>133 <input134 className="text--number"135 id="rb"136 name="rb"137 type="text"138 value={settings.roster.rb}139 onChange={(e) => updateSettings(e.target.name, "roster", e.target.value)}140 />141 </div>142 )}143 {settings.roster?.wr !== undefined && (144 <div className="input-containter">145 <label htmlFor="wr">WR</label>146 <input147 className="text--number"148 id="wr"149 name="wr"150 type="text"151 value={settings.roster.wr}152 onChange={(e) => updateSettings(e.target.name, "roster", e.target.value)}153 />154 </div>155 )}156 {settings.roster?.te !== undefined && (157 <div className="input-containter">158 <label htmlFor="te">TE</label>159 <input160 className="text--number"161 id="te"162 name="te"163 type="text"164 value={settings.roster.te}165 onChange={(e) => updateSettings(e.target.name, "roster", e.target.value)}166 />167 </div>168 )}169 {settings.roster?.flex !== undefined && (170 <div className="input-containter">171 <label htmlFor="flex">FLEX</label>172 <input173 className="text--number"174 id="flex"175 name="flex"176 type="text"177 value={settings.roster.flex}178 onChange={(e) => updateSettings(e.target.name, "roster", e.target.value)}179 />180 </div>181 )}182 {settings.roster?.k !== undefined && (183 <div className="input-containter">184 <label htmlFor="k">K</label>185 <input186 className="text--number"187 id="k"188 name="k"189 type="text"190 value={settings.roster.k}191 onChange={(e) => updateSettings(e.target.name, "roster", e.target.value)}192 />193 </div>194 )}195 {settings.roster?.dst !== undefined && (196 <div className="input-containter">197 <label htmlFor="dst">DST</label>198 <input199 className="text--number"200 id="dst"201 name="dst"202 type="text"203 value={settings.roster.dst}204 onChange={(e) => updateSettings(e.target.name, "roster", e.target.value)}205 />206 </div>207 )}208 {settings.roster?.bench !== undefined && (209 <div className="input-containter">210 <label htmlFor="bench">BENCH</label>211 <input212 className="text--number"213 id="bench"214 name="bench"215 type="text"216 value={settings.roster.bench}217 onChange={(e) => updateSettings(e.target.name, "roster", e.target.value)}218 />219 </div>220 )}221 </div>222 <div className="settings__category-container settings__category-container--third">223 <h3 className="settings__category-title">Scoring</h3>224 <h4 className="settings__scoring-title">Passing</h4>225 {settings.scoring?.pass_yrds !== undefined && (226 <div className="input-containter">227 <label htmlFor="pass_yrds">YRDS</label>228 <input229 className="text--number"230 id="pass_yrds"231 name="pass_yrds"232 type="text"233 value={settings.scoring.pass_yrds}234 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}235 />236 </div>237 )}238 {settings.scoring?.pass_td !== undefined && (239 <div className="input-containter">240 <label htmlFor="pass_td">TD</label>241 <input242 className="text--number"243 id="pass_td"244 name="pass_td"245 type="text"246 value={settings.scoring.pass_td}247 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}248 />249 </div>250 )}251 {settings.scoring?.pass_comp !== undefined && (252 <div className="input-containter">253 <label htmlFor="pass_comp">COMP</label>254 <input255 className="text--number"256 id="pass_comp"257 name="pass_comp"258 type="text"259 value={settings.scoring.pass_comp}260 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}261 />262 </div>263 )}264 {settings.scoring?.pass_int !== undefined && (265 <div className="input-containter">266 <label htmlFor="pass_int">INT</label>267 <input268 className="text--number"269 id="pass_int"270 name="pass_int"271 type="text"272 value={settings.scoring.pass_int}273 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}274 />275 </div>276 )}277 <h4 className="settings__scoring-title">Rushing</h4>278 {settings.scoring?.rush_yrds !== undefined && (279 <div className="input-containter">280 <label htmlFor="rush_yrds">YRDS</label>281 <input282 className="text--number"283 id="rush_yrds"284 name="rush_yrds"285 type="text"286 value={settings.scoring.rush_yrds}287 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}288 />289 </div>290 )}291 {settings.scoring?.rush_td !== undefined && (292 <div className="input-containter">293 <label htmlFor="rush_td">TD</label>294 <input295 className="text--number"296 id="rush_td"297 name="rush_td"298 type="text"299 value={settings.scoring.rush_td}300 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}301 />302 </div>303 )}304 <h4 className="settings__scoring-title">Receiving</h4>305 {settings.scoring?.rec_yrds !== undefined && (306 <div className="input-containter">307 <label htmlFor="rec_yrds">YRDS</label>308 <input309 className="text--number"310 id="rec_yrds"311 name="rec_yrds"312 type="text"313 value={settings.scoring.rec_yrds}314 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}315 />316 </div>317 )}318 {settings.scoring?.rec_td !== undefined && (319 <div className="input-containter">320 <label htmlFor="rec_td">TD</label>321 <input322 className="text--number"323 id="rec_td"324 name="rec_td"325 type="text"326 value={settings.scoring.rec_td}327 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}328 />329 </div>330 )}331 {settings.scoring?.rec_rec !== undefined && (332 <div className="input-containter">333 <label htmlFor="rec_rec">REC</label>334 <input335 className="text--number"336 id="rec_rec"337 name="rec_rec"338 type="text"339 value={settings.scoring.rec_rec}340 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}341 />342 </div>343 )}344 <h4 className="settings__scoring-title">Kicking</h4>345 {settings.scoring?.k_fg !== undefined && (346 <div className="input-containter">347 <label htmlFor="k_fg">FG</label>348 <input349 className="text--number"350 id="k_fg"351 name="k_fg"352 type="text"353 value={settings.scoring.k_fg}354 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}355 />356 </div>357 )}358 {settings.scoring?.k_mfg !== undefined && (359 <div className="input-containter">360 <label htmlFor="k_mfg">MFG</label>361 <input362 className="text--number"363 id="k_mfg"364 name="k_mfg"365 type="text"366 value={settings.scoring.k_mfg}367 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}368 />369 </div>370 )}371 {settings.scoring?.k_xpt !== undefined && (372 <div className="input-containter">373 <label htmlFor="k_xpt">XPT</label>374 <input375 className="text--number"376 id="k_xpt"377 name="k_xpt"378 type="text"379 value={settings.scoring.k_xpt}380 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}381 />382 </div>383 )}384 <h4 className="settings__scoring-title">Defense: Sacks, Turnovers, & Scoring</h4>385 {settings.scoring?.dst_sk !== undefined && (386 <div className="input-containter">387 <label htmlFor="dst_sk">SACK</label>388 <input389 className="text--number"390 id="dst_sk"391 name="dst_sk"392 type="text"393 value={settings.scoring.dst_sk}394 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}395 />396 </div>397 )}398 {settings.scoring?.dst_int !== undefined && (399 <div className="input-containter">400 <label htmlFor="dst_int">INT</label>401 <input402 className="text--number"403 id="dst_int"404 name="dst_int"405 type="text"406 value={settings.scoring.dst_int}407 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}408 />409 </div>410 )}411 {settings.scoring?.dst_fr !== undefined && (412 <div className="input-containter">413 <label htmlFor="dst_fr">FR</label>414 <input415 className="text--number"416 id="dst_fr"417 name="dst_fr"418 type="text"419 value={settings.scoring.dst_fr}420 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}421 />422 </div>423 )}424 {settings.scoring?.dst_ff !== undefined && (425 <div className="input-containter">426 <label htmlFor="dst_ff">FF</label>427 <input428 className="text--number"429 id="dst_ff"430 name="dst_ff"431 type="text"432 value={settings.scoring.dst_ff}433 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}434 />435 </div>436 )}437 {settings.scoring?.dst_td !== undefined && (438 <div className="input-containter">439 <label htmlFor="dst_td">TD</label>440 <input441 className="text--number"442 id="dst_td"443 name="dst_td"444 type="text"445 value={settings.scoring.dst_td}446 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}447 />448 </div>449 )}450 {settings.scoring?.dst_sf !== undefined && (451 <div className="input-containter">452 <label htmlFor="dst_sf">SAFE</label>453 <input454 className="text--number"455 id="dst_sf"456 name="dst_sf"457 type="text"458 value={settings.scoring.dst_sf}459 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}460 />461 </div>462 )}463 <h4 className="settings__scoring-title">Defense: Points Allowed</h4>464 {settings.scoring?.dst_pa_0 !== undefined && (465 <div className="input-containter">466 <label className="text--number" htmlFor="dst_pa_0">467 0468 </label>469 <input470 className="text--number"471 id="dst_pa_0"472 name="dst_pa_0"473 type="text"474 value={settings.scoring?.dst_pa_0}475 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}476 />477 </div>478 )}479 {settings.scoring?.dst_pa_1_5 !== undefined && (480 <div className="input-containter">481 <label className="text--number" htmlFor="dst_pa_1_5">482 1-5483 </label>484 <input485 className="text--number"486 id="dst_pa_1_5"487 name="dst_pa_1_5"488 type="text"489 value={settings.scoring?.dst_pa_1_5}490 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}491 />492 </div>493 )}494 {settings.scoring?.dst_pa_6_10 !== undefined && (495 <div className="input-containter">496 <label className="text--number" htmlFor="dst_pa_6_10">497 6-10498 </label>499 <input500 className="text--number"501 id="dst_pa_6_10"502 name="dst_pa_6_10"503 type="text"504 value={settings.scoring?.dst_pa_6_10}505 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}506 />507 </div>508 )}509 {settings.scoring?.dst_pa_11_15 !== undefined && (510 <div className="input-containter">511 <label className="text--number" htmlFor="dst_pa_11_15">512 11-15513 </label>514 <input515 className="text--number"516 id="dst_pa_11_15"517 name="dst_pa_11_15"518 type="text"519 value={settings.scoring?.dst_pa_11_15}520 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}521 />522 </div>523 )}524 {settings.scoring?.dst_pa_16_20 !== undefined && (525 <div className="input-containter">526 <label className="text--number" htmlFor="dst_pa_16_20">527 16-20528 </label>529 <input530 className="text--number"531 id="dst_pa_16_20"532 name="dst_pa_16_20"533 type="text"534 value={settings.scoring?.dst_pa_16_20}535 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}536 />537 </div>538 )}539 {settings.scoring?.dst_pa_21_25 !== undefined && (540 <div className="input-containter">541 <label className="text--number" htmlFor="dst_pa_21_25">542 21-25543 </label>544 <input545 className="text--number"546 id="dst_pa_21_25"547 name="dst_pa_21_25"548 type="text"549 value={settings.scoring?.dst_pa_21_25}550 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}551 />552 </div>553 )}554 {settings.scoring?.dst_pa_26_30 !== undefined && (555 <div className="input-containter">556 <label className="text--number" htmlFor="dst_pa_26_30">557 26-30558 </label>559 <input560 className="text--number"561 id="dst_pa_26_30"562 name="dst_pa_26_30"563 type="text"564 value={settings.scoring?.dst_pa_26_30}565 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}566 />567 </div>568 )}569 {settings.scoring?.dst_pa_31_35 !== undefined && (570 <div className="input-containter">571 <label className="text--number" htmlFor="dst_pa_31_35">572 31-35573 </label>574 <input575 className="text--number"576 id="dst_pa_31_35"577 name="dst_pa_31_35"578 type="text"579 value={settings.scoring?.dst_pa_31_35}580 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}581 />582 </div>583 )}584 {settings.scoring?.dst_pa_36_40 !== undefined && (585 <div className="input-containter">586 <label className="text--number" htmlFor="dst_pa_36_40">587 36-40588 </label>589 <input590 className="text--number"591 id="dst_pa_36_40"592 name="dst_pa_36_40"593 type="text"594 value={settings.scoring?.dst_pa_36_40}595 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}596 />597 </div>598 )}599 {settings.scoring?.dst_pa_41_plus !== undefined && (600 <div className="input-containter">601 <label className="text--number" htmlFor="dst_pa_41_plus">602 40+603 </label>604 <input605 className="text--number"606 id="dst_pa_41_plus"607 name="dst_pa_41_plus"608 type="text"609 value={settings.scoring?.dst_pa_41_plus}610 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}611 />612 </div>613 )}614 <h4 className="settings__scoring-title">Defense: Yards Allowed</h4>615 {settings.scoring?.dst_ya_49 !== undefined && (616 <div className="input-containter">617 <label className="text--number" htmlFor="dst_ya_49">618 &lt;49619 </label>620 <input621 className="text--number"622 id="dst_ya_49"623 name="dst_ya_49"624 type="text"625 value={settings.scoring?.dst_ya_49}626 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}627 />628 </div>629 )}630 {settings.scoring?.dst_ya_50_99 !== undefined && (631 <div className="input-containter">632 <label className="text--number" htmlFor="dst_ya_50_99">633 50-99634 </label>635 <input636 className="text--number"637 id="dst_ya_50_99"638 name="dst_ya_50_99"639 type="text"640 value={settings.scoring?.dst_ya_50_99}641 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}642 />643 </div>644 )}645 {settings.scoring?.dst_ya_100_149 !== undefined && (646 <div className="input-containter">647 <label className="text--number" htmlFor="dst_ya_100_149">648 100-149649 </label>650 <input651 className="text--number"652 id="dst_ya_100_149"653 name="dst_ya_100_149"654 type="text"655 value={settings.scoring?.dst_ya_100_149}656 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}657 />658 </div>659 )}660 {settings.scoring?.dst_ya_150_199 !== undefined && (661 <div className="input-containter">662 <label className="text--number" htmlFor="dst_ya_150_199">663 150-199664 </label>665 <input666 className="text--number"667 id="dst_ya_150_199"668 name="dst_ya_150_199"669 type="text"670 value={settings.scoring?.dst_ya_150_199}671 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}672 />673 </div>674 )}675 {settings.scoring?.dst_ya_200_249 !== undefined && (676 <div className="input-containter">677 <label className="text--number" htmlFor="dst_ya_200_249">678 200-249679 </label>680 <input681 className="text--number"682 id="dst_ya_200_249"683 name="dst_ya_200_249"684 type="text"685 value={settings.scoring?.dst_ya_200_249}686 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}687 />688 </div>689 )}690 {settings.scoring?.dst_ya_250_299 !== undefined && (691 <div className="input-containter">692 <label className="text--number" htmlFor="dst_ya_250_299">693 250-299694 </label>695 <input696 className="text--number"697 id="dst_ya_250_299"698 name="dst_ya_250_299"699 type="text"700 value={settings.scoring?.dst_ya_250_299}701 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}702 />703 </div>704 )}705 {settings.scoring?.dst_ya_300_349 !== undefined && (706 <div className="input-containter">707 <label className="text--number" htmlFor="dst_ya_300_349">708 300-349709 </label>710 <input711 className="text--number"712 id="dst_ya_300_349"713 name="dst_ya_300_349"714 type="text"715 value={settings.scoring?.dst_ya_300_349}716 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}717 />718 </div>719 )}720 {settings.scoring?.dst_ya_350_399 !== undefined && (721 <div className="input-containter">722 <label className="text--number" htmlFor="dst_ya_350_399">723 350-399724 </label>725 <input726 className="text--number"727 id="dst_ya_350_399"728 name="dst_ya_350_399"729 type="text"730 value={settings.scoring?.dst_ya_350_399}731 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}732 />733 </div>734 )}735 {settings.scoring?.dst_ya_400_449 !== undefined && (736 <div className="input-containter">737 <label className="text--number" htmlFor="dst_ya_400_449">738 400-449739 </label>740 <input741 className="text--number"742 id="dst_ya_400_449"743 name="dst_ya_400_449"744 type="text"745 value={settings.scoring?.dst_ya_400_449}746 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}747 />748 </div>749 )}750 {settings.scoring?.dst_ya_450_499 !== undefined && (751 <div className="input-containter">752 <label className="text--number" htmlFor="dst_ya_450_499">753 450-499754 </label>755 <input756 className="text--number"757 id="dst_ya_450_499"758 name="dst_ya_450_499"759 type="text"760 value={settings.scoring?.dst_ya_450_499}761 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}762 />763 </div>764 )}765 {settings.scoring?.dst_ya_500_plus !== undefined && (766 <div className="input-containter">767 <label className="text--number" htmlFor="dst_ya_500_plus">768 500+769 </label>770 <input771 className="text--number"772 id="dst_ya_500_plus"773 name="dst_ya_500_plus"774 type="text"775 value={settings.scoring?.dst_ya_500_plus}776 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}777 />778 </div>779 )}780 <h4 className="settings__scoring-title">Misc</h4>781 {settings.scoring?.misc_fum !== undefined && (782 <div className="input-containter">783 <label htmlFor="misc_fum">FUM</label>784 <input785 className="text--number"786 id="misc_fum"787 name="misc_fum"788 type="text"789 value={settings.scoring.misc_fum}790 onChange={(e) => updateSettings(e.target.name, "scoring", e.target.value)}791 />792 </div>793 )}794 </div>795 </div>796 <div className="app-settings">797 <h2 className="settings__title">App Settings</h2>798 <div className="settings__category-container settings__category-container--full">799 {settings.misc?.color_mode !== undefined && (800 <div className="switch__container switch__container--color-mode">801 <label className="switch">802 <input type="checkbox" checked={settings.misc?.color_mode === "dark" ? true : false} onChange={() => handleColorMode()} />803 <span className="slider slider--round"></span>804 </label>805 <p className="switch__text switch__text--color-mode">{settings.misc?.color_mode} mode</p>806 </div>807 )}808 </div>809 <div className="settings__category-container settings__category-container--full">810 <button811 className="button"812 onClick={() => {813 setDraftStatus({});814 setCurrentPick(1);815 }}816 >817 Reset Draft Progress818 </button>819 <button className="button button--negative" onClick={() => setSentimentStatus({})}>820 Reset Player Sentiment821 </button>822 </div>823 </div>824 </div>825 <div className="settings__overlay" onClick={() => handleSettingsMenu()} onTransitionEnd={() => handleSettingsMenuTransition()}></div>826 </div>827 );...

Full Screen

Full Screen

configuration.js

Source:configuration.js Github

copy

Full Screen

1/**2* Copyright (C) 2016-present The ISLE Authors3*4* The isle-dashboard program is free software: you can redistribute it and/or modify5* it under the terms of the GNU Affero General Public License as6* published by the Free Software Foundation, either version 3 of the7* License, or (at your option) any later version.8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU Affero General Public License for more details.13*14* You should have received a copy of the GNU Affero General Public License15* along with this program. If not, see <https://www.gnu.org/licenses/>.16*/17// MODULES //18import React, { Component } from 'react';19import PropTypes from 'prop-types';20import { withTranslation } from 'react-i18next';21import Container from 'react-bootstrap/Container';22import FormGroup from 'react-bootstrap/FormGroup';23import Form from 'react-bootstrap/Form';24import Nav from 'react-bootstrap/Nav';25import Row from 'react-bootstrap/Row';26import Col from 'react-bootstrap/Col';27import { LANGUAGES, languageLabel } from 'constants/languages';28import i18next from 'helpers/i18n';29import KeyValueMapInput from './key_value_map_input.js';30import Saml from 'ev/components/admin-settings/saml';31import SelectInputField from './select_input_field.js';32import MultiSelectInputField from './multi_select_input_field.js';33import TextSelectField from './text_select_field.js';34import InputField from './input_field.js';35import CheckboxInputField from './checkbox_input_field.js';36// MAIN //37class ConfigurationPage extends Component {38 constructor( props ) {39 super( props );40 this.state = {41 selected: 'main'42 };43 }44 componentDidMount() {45 this.props.getSettings();46 }47 handleSelect = ( key ) => {48 this.setState({49 selected: key50 });51 };52 renderMain() {53 const { admin, t, updateSettings } = this.props;54 let availableLanguages = admin.settings.availableLanguages;55 if ( !availableLanguages ) {56 availableLanguages = LANGUAGES;57 } else {58 availableLanguages = availableLanguages.map( x => ({ label: languageLabel( x ), value: x }) );59 }60 return (61 <Container style={{ float: 'left' }} className="d-grid gap-3" >62 <Form.Group as={Row} controlId="formPlaintextTitle" >63 <Form.Label column sm={2} >64 {t('title')}65 </Form.Label>66 <Col sm={5} >67 <InputField68 name="siteTitle"69 key={admin.settings.siteTitle}70 type="text"71 defaultValue={admin.settings.siteTitle}72 updateSettings={updateSettings}73 t={t}74 />75 </Col>76 <Col sm={5} >77 <Form.Text muted >78 {t('title-description')}79 </Form.Text>80 </Col>81 </Form.Group>82 <Form.Group as={Row} controlId="formPlaintextDescription">83 <Form.Label column sm={2} >84 {t('site-description')}85 </Form.Label>86 <Col sm={5} >87 <InputField88 name="siteDescription"89 key={admin.settings.siteDescription}90 type="text"91 defaultValue={admin.settings.siteDescription}92 updateSettings={updateSettings}93 t={t}94 />95 </Col>96 <Col sm={5} >97 <Form.Text muted >98 {t('site-description-description')}99 </Form.Text>100 </Col>101 </Form.Group>102 <FormGroup as={Row} >103 <Form.Label column sm={2} >104 {t('default-language')}105 </Form.Label>106 <Col sm={5} >107 <SelectInputField108 name="defaultLanguage"109 defaultValue={admin.settings.defaultLanguage}110 updateSettings={updateSettings}111 >112 <option value="en">English - EN</option>113 <option value="bg">Български - BG</option>114 <option value="cs">Česky - CS</option>115 <option value="da">Dansk - DA</option>116 <option value="el">Ελληνική - EL</option>117 <option value="es">Español - ES</option>118 <option value="et">Eesti - ET</option>119 <option value="de">Deutsch - DE</option>120 <option value="fi">Suomalainen - FI</option>121 <option value="fr">Français - FR</option>122 <option value="hu">English - HU</option>123 <option value="it">Italiano - IT</option>124 <option value="ja">にほんご - JA</option>125 <option value="lt">Lietuvių kalba - LT</option>126 <option value="lv">Latviešu - LV</option>127 <option value="nl">Nederlands - NL</option>128 <option value="pl">Polski - PL</option>129 <option value="pt">Porgtugês - PT</option>130 <option value="ro">Românesc - RO</option>131 <option value="ru">русский - RU</option>132 <option value="sk">Slovenská - SK</option>133 <option value="sl">Slovenski - SL</option>134 <option value="sv">Svenska - SV</option>135 <option value="zh">中文 - ZH</option>136 </SelectInputField>137 </Col>138 <Col sm={5} >139 <Form.Text muted >140 {t('default-language-description')}141 </Form.Text>142 </Col>143 </FormGroup>144 <Form.Group as={Row} controlId="availableLanguages" >145 <Form.Label column sm={2} >146 {t('available-languages')}147 </Form.Label>148 <Col sm={5} >149 <MultiSelectInputField150 name="availableLanguages"151 defaultValue={availableLanguages}152 options={LANGUAGES}153 updateSettings={updateSettings}154 placeholder={i18next.t('admin_settings:available-languages')}155 />156 </Col>157 <Col sm={5} >158 <Form.Text muted >159 {t('available-languages-description')}160 </Form.Text>161 </Col>162 </Form.Group>163 </Container>164 );165 }166 renderLogin() {167 const { admin, t, updateSettings } = this.props;168 return (169 <Container style={{ float: 'left' }} className="d-grid gap-3" >170 <Form.Group as={Row} controlId="formRegistrations" >171 <Form.Label column sm={4} >172 {t('allow-new-registrations')}173 </Form.Label>174 <Col sm={8} >175 <CheckboxInputField176 name="allowUserRegistrations"177 label={t('allow-new-registrations-description')}178 defaultValue={admin.settings.allowUserRegistrations}179 updateSettings={updateSettings}180 />181 </Col>182 </Form.Group>183 <Form.Group as={Row} controlId="permittedEmailDomains" >184 <Form.Label column sm={4} >185 {t('permitted-email-domains')}186 </Form.Label>187 <Col sm={4} >188 <TextSelectField189 name="permittedEmailDomains"190 key={admin.settings.permittedEmailDomains}191 placeholder={t('permitted-email-domains')}192 defaultValue={admin.settings.permittedEmailDomains}193 updateSettings={updateSettings}194 />195 </Col>196 <Col sm={4} >197 <Form.Text muted >198 {t('permitted-email-domains-description')}199 </Form.Text>200 </Col>201 </Form.Group>202 <Form.Group as={Row} controlId="disallowedEmailDomains" >203 <Form.Label column sm={4} >204 {t('disallowed-email-domains')}205 </Form.Label>206 <Col sm={4} >207 <TextSelectField208 name="disallowedEmailDomains"209 key={admin.settings.disallowedEmailDomains}210 placeholder={t('disallowed-email-domains')}211 defaultValue={admin.settings.disallowedEmailDomains}212 updateSettings={updateSettings}213 />214 </Col>215 <Col sm={4} >216 <Form.Text muted >217 {t('disallowed-email-domains-description')}218 </Form.Text>219 </Col>220 </Form.Group>221 <Form.Group as={Row} controlId="reservedUserNames" >222 <Form.Label column sm={4} >223 {t('reserved-user-names')}224 </Form.Label>225 <Col sm={4} >226 <TextSelectField227 name="reservedUserNames"228 key={admin.settings.reservedUserNames}229 placeholder={t('reserved-user-names')}230 defaultValue={admin.settings.reservedUserNames}231 updateSettings={updateSettings}232 />233 </Col>234 <Col sm={4} >235 <Form.Text muted >236 {t('reserved-user-names-description')}237 </Form.Text>238 </Col>239 </Form.Group>240 <Form.Group as={Row} controlId="emailInstitutionMap" >241 <Form.Label column sm={4} >242 {t('email-to-institution-map')}243 </Form.Label>244 <Col sm={6} >245 <KeyValueMapInput246 name="emailInstitutionMap"247 defaultValue={admin.settings.emailInstitutionMap}248 updateSettings={updateSettings}249 />250 </Col>251 <Col sm={2} >252 <Form.Text muted >253 {t('email-to-institution-map-description')}254 </Form.Text>255 </Col>256 </Form.Group>257 </Container>258 );259 }260 renderRateLimits() {261 const { admin, t, updateSettings } = this.props;262 return (263 <Container style={{ float: 'left' }} className="d-grid gap-3" >264 <Form.Group as={Row} controlId="rateLimitNamespaceCreation" >265 <Form.Label column sm={5} >266 {t('create-namespaces-per-hour')}267 </Form.Label>268 <Col sm={2} >269 <InputField270 name="rateLimitNamespaceCreation"271 type="number"272 defaultValue={admin.settings.rateLimitNamespaceCreation}273 updateSettings={updateSettings}274 t={t}275 />276 </Col>277 <Col sm={5} >278 <Form.Text muted >279 {t('create-namespaces-per-hour-description')}280 </Form.Text>281 </Col>282 </Form.Group>283 <Form.Group as={Row} controlId="rateLimitUserCreation" >284 <Form.Label column sm={5} >285 {t('create-users-per-hour')}286 </Form.Label>287 <Col sm={2} >288 <InputField289 name="rateLimitUserCreation"290 type="number"291 defaultValue={admin.settings.rateLimitUserCreation}292 updateSettings={updateSettings}293 t={t}294 />295 </Col>296 <Col sm={5} >297 <Form.Text muted >298 {t('create-users-per-hour-description')}299 </Form.Text>300 </Col>301 </Form.Group>302 <Form.Group as={Row} controlId="rateLimitBackupCreation" >303 <Form.Label column sm={5} >304 {t('create-backups-per-day')}305 </Form.Label>306 <Col sm={2} >307 <InputField308 name="rateLimitBackupCreation"309 type="number"310 defaultValue={admin.settings.rateLimitBackupCreation}311 updateSettings={updateSettings}312 t={t}313 />314 </Col>315 <Col sm={5} >316 <Form.Text muted >317 {t('create-backups-per-day-description')}318 </Form.Text>319 </Col>320 </Form.Group>321 </Container>322 );323 }324 render() {325 const { admin, updateSettings, user, t } = this.props;326 console.log( user.email );327 let content;328 if ( admin.settings ) {329 switch ( this.state.selected ) {330 case 'main':331 content = this.renderMain();332 break;333 case 'login':334 content = this.renderLogin();335 break;336 case 'rate-limits':337 content = this.renderRateLimits();338 break;339 case 'saml':340 content = <Saml admin={admin} updateSettings={updateSettings} />;341 }342 }343 return (344 <div className="admin-settings-outer-container" >345 <Row>346 <Col sm={2} >347 <Nav348 activeKey={this.state.selected}349 className="admin-settings-configuration-nav flex-column"350 onSelect={this.handleSelect}351 >352 <Nav.Link eventKey="main" >353 {t('main')}354 </Nav.Link>355 <Nav.Link eventKey="login" >356 {t('login')}357 </Nav.Link>358 <Nav.Link eventKey="rate-limits" >359 {t('rate-limits')}360 </Nav.Link>361 <Nav.Link eventKey="saml" >362 SSO / SAML363 </Nav.Link>364 </Nav>365 </Col>366 <Col sm={10} >367 {content}368 </Col>369 </Row>370 </div>371 );372 }373}374// PROPERTIES //375ConfigurationPage.propTypes = {376 admin: PropTypes.object,377 getSettings: PropTypes.func.isRequired,378 updateSettings: PropTypes.func.isRequired,379 user: PropTypes.object.isRequired380};381ConfigurationPage.defaultProps = {382 admin: {}383};384// EXPORTS //...

Full Screen

Full Screen

Editor.js

Source:Editor.js Github

copy

Full Screen

1import React from 'react';2import { connect } from 'react-redux';3import PropTypes from 'prop-types';4import styled from 'styled-components';5import themeList from 'monaco-themes/themes/themelist';6import * as uiActions from 'actions/ui';7import { getSetting, setBooleanSetting, setSetting } from 'utils/settings';8import Input from 'components/common/controls/Input';9import Checkbox from 'components/common/controls/Checkbox';10import Select from 'components/common/controls/Select';11import { toPairs } from 'lodash/fp';12const Wrapper = styled.div`13 display: flex;14 justify-content: space-between;15`;16const Label = styled.div`17 display: flex;18 justify-content: space-between;19 align-items: baseline;20 margin-top: 10px;21`;22const Section = styled.div`23 width: 45%;24`;25const Field = styled.div`26 height: 35px;27`;28const StyledInput = styled(Input)`29 padding: 0 5px;30 width: 148px;31`;32const StyledISelect = styled(Select)`33 width: 158px;34`;35const H4 = styled.h4`36 color: ${(props) => props.theme.baseAppColor};37 border-bottom: 1px dashed ${(props) => props.theme.baseAppColor};38 padding-bottom: 20px;39`;40export const EditorSettings = ({ changeSettings }) => {41 const updateSettings = (key, value, isBoolean = false) => {42 changeSettings(key, value, false, isBoolean);43 if (isBoolean) {44 setBooleanSetting(key);45 } else {46 setSetting(key, value);47 }48 };49 return (50 <div>51 <H4>Editor settings:</H4>52 <Wrapper>53 <Section>54 <Field>55 <Label>56 <span>Theme:</span>57 <StyledISelect58 value={ getSetting('editorTheme', 'vs') }59 onChange={ (event) => updateSettings('editorTheme', event.target.value) }>60 <option value="vs">vs light</option>61 <option value="vs-dark">vs dark</option>62 <option value="hc-black">hc dark</option>63 {toPairs(themeList).map((theme) => (64 <option key={ theme[0] } value={ theme[0] }>65 {theme[1]}66 </option>67 ))}68 </StyledISelect>69 </Label>70 </Field>71 <Field>72 <Label>73 <span>Minimap:</span>74 <Checkbox75 checked={ getSetting('minimap', false) }76 onChange={ () => updateSettings('minimap', null, true) }/>77 </Label>78 </Field>79 <Field>80 <Label>81 <span>Code lens:</span>82 <Checkbox83 checked={ getSetting('codeLens', false) }84 onChange={ () => updateSettings('codeLens', null, true) }/>85 </Label>86 </Field>87 <Field>88 <Label>89 <span>Line Numbers:</span>90 <Checkbox91 checked={ getSetting('lineNumbers', true) }92 onChange={ () => updateSettings('lineNumbers', null, true) }/>93 </Label>94 </Field>95 <Field>96 <Label>97 <span>Format On Paste:</span>98 <Checkbox99 checked={ getSetting('formatOnPaste', true) }100 onChange={ () => updateSettings('formatOnPaste', null, true) }/>101 </Label>102 </Field>103 <Field>104 <Label>105 <span>Format On Type:</span>106 <Checkbox107 checked={ getSetting('settings-editor-formatOnType', true) }108 onChange={ () => updateSettings('v', null, true) }/>109 </Label>110 </Field>111 <Field>112 <Label>113 <span>Select On Line Numbers:</span>114 <Checkbox115 checked={ getSetting('SelectOnLineNumbers', false) }116 onChange={ () => updateSettings('SelectOnLineNumbers', null, true) }/>117 </Label>118 </Field>119 <Field>120 <Label>121 <span>Fit editor height to content:</span>122 <Checkbox123 checked={ getSetting('editor-fit-to-content', false) }124 onChange={ () => updateSettings('editor-fit-to-content', null, true) }/>125 </Label>126 </Field>127 </Section>128 <Section>129 <Field>130 <Label>131 <span>Font Family:</span>132 <StyledInput133 type="text"134 value={ getSetting('fontFamily', 'monospace') }135 onChange={ (event) => updateSettings('fontFamily', event.target.value) }/>136 </Label>137 </Field>138 <Field>139 <Label>140 <span>Font Size:</span>141 <StyledInput142 type="number"143 value={ getSetting('fontSize', 12) }144 onChange={ (event) => updateSettings('fontSize', event.target.value) }/>145 </Label>146 </Field>147 <Field>148 <Label>149 <span>Line height:</span>150 <StyledInput151 type="number"152 value={ getSetting('lineHeight', 21) }153 onChange={ (event) => updateSettings('lineHeight', event.target.value) }/>154 </Label>155 </Field>156 <Field>157 <Label>158 <span>Font Ligatures:</span>159 <Checkbox160 checked={ getSetting('fontLigatures', false) }161 onChange={ () => updateSettings('fontLigatures', null, true) }/>162 </Label>163 </Field>164 <Field>165 <Label>166 <span>Cursor Blinking:</span>167 <StyledISelect168 value={ getSetting('cursorBlinking', 'blink') }169 onChange={ (event) => updateSettings('cursorBlinking', event.target.value) }>170 <option value="blink">blink</option>171 <option value="smooth">smooth</option>172 <option value="phase">phase</option>173 <option value="expand">expand</option>174 <option value="solid">solid</option>175 </StyledISelect>176 </Label>177 </Field>178 <Field>179 <Label>180 <span>Word wrap:</span>181 <StyledISelect182 value={ getSetting('settings-editor-wordWrap', 'bounded') }183 onChange={ (event) =>184 updateSettings('settings-editor-wordWrap', event.target.value)185 }>186 <option value="off">off</option>187 <option value="on">on</option>188 <option value="bounded">bounded</option>189 <option value="wordWrapColumn">wordWrapColumn</option>190 </StyledISelect>191 </Label>192 </Field>193 <Field>194 <Label>195 <span>Word wrap column size:</span>196 <StyledInput197 type="number"198 value={ getSetting('settings-editor-wordWrapColumn', 80) }199 onChange={ (event) =>200 updateSettings('settings-editor-wordWrapColumn', event.target.value)201 }/>202 </Label>203 </Field>204 </Section>205 </Wrapper>206 <H4>Preview settings:</H4>207 <Wrapper>208 <Section>209 <Field>210 <Label>211 <span>Preview HTML files:</span>212 <Checkbox213 checked={ getSetting('settings-editor-preview-html', false) }214 onChange={ () => updateSettings('settings-editor-preview-html', null, true) }/>215 </Label>216 </Field>217 <Field>218 <Label>219 <span>Preview Image files:</span>220 <Checkbox221 checked={ getSetting('settings-editor-preview-image', true) }222 onChange={ () => updateSettings('settings-editor-preview-image', null, true) }/>223 </Label>224 </Field>225 <Field>226 <Label>227 <span>Preview PDF files:</span>228 <Checkbox229 checked={ getSetting('settings-editor-preview-pdf', true) }230 onChange={ () => updateSettings('settings-editor-preview-pdf', null, true) }/>231 </Label>232 </Field>233 <Field>234 <Label>235 <span>Preview Open API/swagger files:</span>236 <Checkbox237 checked={ getSetting('settings-editor-preview-open-api', true) }238 onChange={ () => updateSettings('settings-editor-preview-open-api', null, true) }/>239 </Label>240 </Field>241 <Field>242 <Label>243 <span>Preview CSV/TSV files:</span>244 <Checkbox245 checked={ getSetting('settings-editor-preview-csv', true) }246 onChange={ () => updateSettings('settings-editor-preview-csv', null, true) }/>247 </Label>248 </Field>249 </Section>250 <Section>251 <Field>252 <Label>253 <span>Preview GeoJSON:</span>254 <Checkbox255 checked={ getSetting('settings-editor-preview-geojson', true) }256 onChange={ () => updateSettings('settings-editor-preview-geojson', null, true) }/>257 </Label>258 </Field>259 <Field>260 <Label>261 <span>Preview Markdown files:</span>262 <Checkbox263 checked={ getSetting('settings-editor-preview-markdown', true) }264 onChange={ () => updateSettings('settings-editor-preview-markdown', null, true) }/>265 </Label>266 </Field>267 <Field>268 <Label>269 <span>Preview AsciiDoc files:</span>270 <Checkbox271 checked={ getSetting('settings-editor-preview-asciidoc', true) }272 onChange={ () => updateSettings('settings-editor-preview-asciidoc', null, true) }/>273 </Label>274 </Field>275 <Field>276 <Label>277 <span>Preview LaTex files (using katex):</span>278 <Checkbox279 checked={ getSetting('settings-editor-preview-latex', true) }280 onChange={ () => updateSettings('settings-editor-preview-latex', null, true) }/>281 </Label>282 </Field>283 </Section>284 </Wrapper>285 </div>286 );287};288EditorSettings.propTypes = {289 changeSettings: PropTypes.func290};291export default connect(292 null,293 {294 changeSettings: uiActions.changeSettings295 }...

Full Screen

Full Screen

CheckboxSettings.jsx

Source:CheckboxSettings.jsx Github

copy

Full Screen

1// react:2import React, { PureComponent } from "react";34// material ui:5import { List, ListItem, Paper } from "@material-ui/core";67// components:8import MyCheckbox from "shared/components/general/MyCheckbox.jsx";9import ThemeSelector from "shared/components/general/ThemeSelector.jsx";1011// redux:12import { connect } from "react-redux";1314// actions:15import { updateSettings } from "src/actions/settings.js";1617// libs:18import { toggleFullscreen } from "shared/libs/utils.js";1920class CheckboxSettings extends PureComponent {21 constructor(props) {22 super(props);2324 this.state = {};25 }2627 render() {28 return (29 <Paper elevation={5}>30 <List>31 <ListItem>32 <MyCheckbox33 text={"Enable Keyboard Controls"}34 handleChange={(state) => {35 this.props.updateSettings({ keyboardControls: state });36 }}37 checked={this.props.settings.keyboardControls}38 />39 </ListItem>40 <ListItem>41 <MyCheckbox42 text={"Enable Controller Controls"}43 handleChange={(state) => {44 this.props.updateSettings({ controllerControls: state });45 }}46 checked={this.props.settings.controllerControls}47 />48 </ListItem>49 <ListItem>50 <MyCheckbox51 text={"Enable Touch Controls"}52 handleChange={(state) => {53 this.props.updateSettings({ touchControls: state });54 }}55 checked={this.props.settings.touchControls}56 />57 </ListItem>58 <ListItem>59 <MyCheckbox60 text={"Real keyboard / mouse"}61 handleChange={(state) => {62 this.props.updateSettings({ realKeyboardMouse: state });63 }}64 checked={this.props.settings.realKeyboardMouse}65 />66 </ListItem>67 <ListItem>68 <MyCheckbox69 text={"Show Controller View"}70 handleChange={(state) => {71 this.props.updateSettings({ controllerView: state });72 if (state && this.props.settings.largescreen) {73 this.props.updateSettings({ largescreen: false });74 } else if (!state && !this.props.settings.largescreen) {75 this.props.updateSettings({ largescreen: true });76 }77 setTimeout(() => {78 window.dispatchEvent(new Event("resize"));79 }, 200);80 }}81 checked={this.props.settings.controllerView}82 />83 </ListItem>84 <ListItem>85 <MyCheckbox86 text={"Mobile Mode"}87 handleChange={(state) => {88 this.props.updateSettings({ mobileMode: state, touchControls: state });89 // if (state && this.props.settings.controllerView) {90 // this.props.updateSettings({ controllerView: false });91 // } else if (!state && !this.props.settings.controllerView) {92 // this.props.updateSettings({ controllerView: true });93 // }94 // if (state && !this.props.settings.hideChat) {95 // this.props.updateSettings({ hideChat: false });96 // } else if (!state && this.props.settings.hideChat) {97 // this.props.updateSettings({ hideChat: true });98 // }99 // if (state && !this.props.settings.hideNav) {100 // this.props.updateSettings({ hideNav: false });101 // } else if (!state && this.props.settings.hideNav) {102 // this.props.updateSettings({ hideNav: true });103 // }104105 if (state) {106 this.props.updateSettings({107 hideChat: true,108 hideNav: true,109 controllerView: true,110 largescreen: true,111 });112 toggleFullscreen(document.getElementsByTagName("html")[0]);113 } else {114 this.props.updateSettings({115 hideChat: false,116 hideNav: false,117 controllerView: true,118 largescreen: false,119 });120 }121122 setTimeout(() => {123 window.dispatchEvent(new Event("resize"));124 }, 200);125 }}126 checked={this.props.settings.mobileMode}127 />128 </ListItem>129 <ListItem>130 <MyCheckbox131 text={"Audio 3.0"}132 handleChange={this.props.toggleAudioThree}133 checked={this.props.settings.audioThree}134 />135 </ListItem>136 <ListItem>137 <ThemeSelector />138 </ListItem>139 <ListItem>140 <MyCheckbox141 text={"Enable Fullscreen Mode"}142 handleChange={(state) => {143 if (state) {144 // $(document).scrollTop(0);145 document.body.scrollTop = document.documentElement.scrollTop = 0;146 // $("body").addClass("hideScrollbar");147 // $("#root").children()[0].style.padding = "0";148 this.props.updateSettings({149 fullscreen: state,150 controllerView: false,151 hideChat: true,152 hideNav: true,153 });154 toggleFullscreen(document.getElementsByTagName("html")[0]);155 } else {156 // console.log("exiting fullscreen");157 // $("body").removeClass("hideScrollbar");158 // $("#root").children()[0].style.padding = "";159 this.props.updateSettings({160 fullscreen: state,161 largescreen: false,162 controllerView: true,163 hideChat: false,164 hideNav: false,165 });166 }167 }}168 checked={this.props.settings.fullscreen}169 />170 </ListItem>171 {/* <ListItem>172 <MyCheckbox173 text={"Enable Mouse Controls"}174 handleChange={(state) => {this.props.updateSettings({ mouseControls: state })}}175 checked={this.props.settings.mouseControls}/>176 </ListItem>177 <ListItem>178 <MyCheckbox179 text={"Enable Touch Controls"}180 handleChange={(state) => {this.props.updateSettings({ touchControls: state })}}181 checked={this.props.settings.touchControls}/>182 </ListItem> */}183 <ListItem>184 <MyCheckbox185 text={"Analog Stick Mode"}186 handleChange={(state) => {187 this.props.updateSettings({ analogStickMode: state });188 }}189 checked={this.props.settings.analogStickMode}190 />191 </ListItem>192 {/* <ListItem>193 <MyCheckbox194 text={"DPad Swap"}195 handleChange={this.toggleDpadSwap}196 checked={this.props.settings.dpadSwap}/>197 </ListItem> */}198 {/* <ListItem>199 <MyCheckbox200 text={"3Ds config"}201 handleChange={this.toggleTDSConfig}202 checked={this.props.settings.TDSConfig}/>203 </ListItem> */}204 <ListItem>205 <MyCheckbox206 text={"Hide Chat"}207 handleChange={(state) => {208 this.props.updateSettings({ hideChat: state });209 }}210 checked={this.props.settings.hideChat}211 />212 </ListItem>213 <ListItem>214 <MyCheckbox215 text={"Hide Nav Bar"}216 handleChange={(state) => {217 this.props.updateSettings({ hideNav: state });218 }}219 checked={this.props.settings.hideNav}220 />221 </ListItem>222 {/* <ListItem>223 <MyCheckbox224 text={"Enable Controller View"}225 handleChange={(state) => {226 this.props.updateSettings({ controllerView: state });227 if (state && this.props.settings.largescreen) {228 this.props.updateSettings({ largescreen: false });229 }230 }}231 checked={this.props.settings.controllerView}/>232 </ListItem> */}233 </List>234 </Paper>235 );236 }237}238239// export default JoinLeaveQueueButton;240const mapStateToProps = (state) => {241 return {242 settings: state.settings,243 };244};245246const mapDispatchToProps = (dispatch) => {247 return {248 updateSettings: (settings) => {249 dispatch(updateSettings(settings));250 },251 };252};253 ...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1export default ({ post, rootUrl }) => {2 const getSettings = (guid, sharedKey) =>3 post({4 data: { format: 'json', guid, method: 'get-info', sharedKey },5 endPoint: '/wallet',6 url: rootUrl7 })8 const updateSettings = (guid, sharedKey, method, payload, querystring = '') =>9 post({10 data: { guid, length: `${payload}`.length, method, payload, sharedKey },11 endPoint: querystring ? `/wallet?${querystring}` : '/wallet',12 url: rootUrl13 })14 const updateEmail = (guid, sharedKey, email) =>15 updateSettings(guid, sharedKey, 'update-email', email)16 const sendConfirmationCodeEmail = (guid, sharedKey, email) =>17 updateSettings(guid, sharedKey, 'send-verify-email-mail', email)18 const sendEmailConfirmation = (guid, sharedKey, email) =>19 updateSettings(guid, sharedKey, 'update-email', email)20 const resendVerifyEmail = (guid, sharedKey, email) =>21 updateSettings(guid, sharedKey, 'resend-verify-email', email)22 const verifyEmail = (guid, sharedKey, code) =>23 updateSettings(guid, sharedKey, 'verify-email-code', code)24 const updateMobile = (guid, sharedKey, mobile) =>25 updateSettings(guid, sharedKey, 'update-sms', mobile)26 const verifyMobile = (guid, sharedKey, code) =>27 updateSettings(guid, sharedKey, 'verify-sms', code)28 const updateLanguage = (guid, sharedKey, language) =>29 updateSettings(guid, sharedKey, 'update-language', language)30 const updateCurrency = (guid, sharedKey, currency) =>31 updateSettings(guid, sharedKey, 'update-currency', currency)32 const updateLastTxTime = (guid, sharedKey, time) =>33 updateSettings(guid, sharedKey, 'update-last-tx-time', time)34 const updateLoggingLevel = (guid, sharedKey, loggingLevel) =>35 updateSettings(guid, sharedKey, 'update-logging-level', loggingLevel)36 const updateIpLock = (guid, sharedKey, ipLock) =>37 updateSettings(guid, sharedKey, 'update-ip-lock', ipLock)38 const updateIpLockOn = (guid, sharedKey, ipLockOn) =>39 updateSettings(guid, sharedKey, 'update-ip-lock-on', ipLockOn)40 const updateBlockTorIps = (guid, sharedKey, blockTorIps) =>41 updateSettings(guid, sharedKey, 'update-block-tor-ips', blockTorIps)42 const updateHint = (guid, sharedKey, hint) =>43 updateSettings(guid, sharedKey, 'update-password-hint1', hint)44 const updateAuthType = (guid, sharedKey, authType) =>45 updateSettings(guid, sharedKey, 'update-auth-type', authType)46 const updateAuthTypeNeverSave = (guid, sharedKey, authTypeNeverSave) =>47 updateSettings(guid, sharedKey, 'update-never-save-auth-type', authTypeNeverSave)48 const getGoogleAuthenticatorSecretUrl = (guid, sharedKey) =>49 updateSettings(guid, sharedKey, 'generate-google-secret', '')50 const enableGoogleAuthenticator = (guid, sharedKey, code) =>51 updateSettings(guid, sharedKey, 'update-auth-type', '4', `code=${code}`)52 const enableYubikey = (guid, sharedKey, code) =>53 updateSettings(guid, sharedKey, 'update-yubikey', code)54 const enableNotifications = (guid, sharedKey, value) =>55 updateSettings(guid, sharedKey, 'update-notifications-on', value)56 const updateNotificationsType = (guid, sharedKey, value) =>57 updateSettings(guid, sharedKey, 'update-notifications-type', value)58 return {59 enableGoogleAuthenticator,60 enableNotifications,61 enableYubikey,62 getGoogleAuthenticatorSecretUrl,63 getSettings,64 resendVerifyEmail,65 sendConfirmationCodeEmail,66 sendEmailConfirmation,67 updateAuthType,68 updateAuthTypeNeverSave,69 updateBlockTorIps,70 updateCurrency,71 updateEmail,72 updateHint,73 updateIpLock,74 updateIpLockOn,75 updateLanguage,76 updateLastTxTime,77 updateLoggingLevel,78 updateMobile,79 updateNotificationsType,80 verifyEmail,81 verifyMobile82 }...

Full Screen

Full Screen

update.js

Source:update.js Github

copy

Full Screen

1const isEmail = require('validator/lib/isEmail')2const isURL = require('validator/lib/isURL')3module.exports = {4 friendlyName: 'Update client settings',5 inputs: {6 client: {7 type: 'ref',8 required: true,9 },10 updateSettings: {11 type: 'json',12 required: true,13 },14 },15 exits: {16 invalidKeys: {},17 invalidValue: {},18 invalidEmail: {},19 invalidURL: {}20 },21 fn: async (inputs, exits) => {22 const clientId = sails.helpers.util.idOrObjectIdInteger(inputs.client)23 const settingsSchema = sails.helpers.clientSettings.getSchema()24 const secretSettingsSchema = sails.helpers.clientSettings.getSecretsSchema()25 const allSettingsSchema = _.assign({}, settingsSchema, secretSettingsSchema)26 const allSettingsKeys = _.keys(allSettingsSchema)27 const requestKeys = _.keys(inputs.updateSettings)28 const invalidKeys = _.difference(29 requestKeys,30 allSettingsKeys,31 )32 if (invalidKeys.length) {33 const e = new Error(34 'The following key(s) are not valid: ' + invalidKeys.join(', ') + '\n\n' +35 'The following client settings (plus some secret settings) are valid:\n' +36 JSON.stringify(settingsSchema)37 )38 e.code = 'invalidKeys'39 throw e40 }41 let validates = true42 _.each(requestKeys, requestKey => {43 if (allSettingsSchema[requestKey].isIn && !_.includes(allSettingsSchema[requestKey].isIn, inputs.updateSettings[requestKey])) {44 const e = new Error('The specified value "' + inputs.updateSettings[requestKey] + '" is not valid for the setting "' + requestKey + '". The following values are valid: ' + settingsSchema[requestKey].isIn.join(', ') + '.')45 e.code = 'invalidValue'46 throw e47 }48 if (allSettingsSchema[requestKey].isEmail && inputs.updateSettings[requestKey] && !isEmail(inputs.updateSettings[requestKey])) {49 const e = new Error('The specified value "' + inputs.updateSettings[requestKey] + '" does not look like a valid email.')50 e.code = 'invalidEmail'51 throw e52 }53 if (allSettingsSchema[requestKey].isURL && inputs.updateSettings[requestKey] && !isURL(inputs.updateSettings[requestKey])) {54 const e = new Error('The specified value "' + inputs.updateSettings[requestKey] + '" does not look like a valid URL.')55 e.code = 'invalidURL'56 throw e57 }58 })59 if (!validates) return60 await Promise.all(61 _.map(62 _.keys(inputs.updateSettings),63 async key => {64 let value65 switch (allSettingsSchema[key].type) {66 case 'string':67 value = inputs.updateSettings[key]68 break69 case 'integer':70 value = parseInt(inputs.updateSettings[key])71 break72 case 'boolean':73 value = inputs.updateSettings[key] ? 1 : 074 break75 }76 const updatedRecord = await ClientSettings.update({77 client: clientId,78 key: key,79 }, {80 value: value,81 }).fetch()82 if (!updatedRecord.length) {83 await ClientSettings.create({84 client: clientId,85 key: key,86 value: value,87 })88 }89 },90 ),91 )92 return exits.success()93 },...

Full Screen

Full Screen

test-Server.js

Source:test-Server.js Github

copy

Full Screen

1'use strict';2const tap = require('tap');3const mediasoup = require('../');4const roomOptions = require('./data/options').roomOptions;5tap.test('server.updateSettings() with no options must succeed', { timeout: 2000 }, (t) =>6{7 let server = mediasoup.Server();8 t.tearDown(() => server.close());9 server.updateSettings()10 .then(() =>11 {12 t.pass('server.updateSettings() succeeded');13 t.end();14 })15 .catch((error) => t.fail(`server.updateSettings() failed: ${error}`));16});17tap.test('server.updateSettings() with valid options must succeed', { timeout: 2000 }, (t) =>18{19 let server = mediasoup.Server();20 t.tearDown(() => server.close());21 server.updateSettings({ logLevel: 'warn' })22 .then(() =>23 {24 t.pass('server.updateSettings() succeeded');25 t.end();26 })27 .catch((error) => t.fail(`server.updateSettings() failed: ${error}`));28});29tap.test('server.updateSettings() with invalid options must fail', { timeout: 2000 }, (t) =>30{31 let server = mediasoup.Server();32 t.tearDown(() => server.close());33 server.updateSettings({ logLevel: 'chicken' })34 .then(() => t.fail('server.updateSettings() succeeded'))35 .catch((error) =>36 {37 t.pass(`server.updateSettings() failed: ${error}`);38 t.end();39 });40});41tap.test('server.updateSettings() in a closed server must fail', { timeout: 2000 }, (t) =>42{43 let server = mediasoup.Server();44 t.tearDown(() => server.close());45 server.on('close', () =>46 {47 server.updateSettings({ logLevel: 'error' })48 .then(() => t.fail('server.updateSettings() succeeded'))49 .catch((error) =>50 {51 t.pass(`server.updateSettings() failed: ${error}`);52 t.type(error, mediasoup.errors.InvalidStateError, 'server.updateSettings() must reject with InvalidStateError');53 t.end();54 });55 });56 server.close();57});58tap.test('server.createRoom() must succeed', { _timeout: 2000 }, (t) =>59{60 let server = mediasoup.Server();61 t.tearDown(() => server.close());62 server.createRoom(roomOptions)63 .then((room) =>64 {65 t.pass('server.createRoom() succeeded');66 room.on('close', (error) =>67 {68 t.error(error, 'room must close cleanly');69 t.end();70 });71 // Wait a bit so Channel requests receive response72 setTimeout(() => room.close(), 50);73 })74 .catch((error) => t.fail(`server.createRoom() failed: ${error}`));75});76tap.test('server.createRoom() in a closed server must fail', { timeout: 2000 }, (t) =>77{78 let server = mediasoup.Server();79 server.close();80 server.createRoom(roomOptions)81 .then((room) => t.fail('server.createRoom() succeeded')) // eslint-disable-line no-unused-vars82 .catch((error) =>83 {84 t.pass(`server.createRoom() failed: ${error}`);85 t.type(error, mediasoup.errors.InvalidStateError, 'server.createRoom() must reject with InvalidStateError');86 t.end();87 });88});89tap.test('server.dump() must succeed', { timeout: 2000 }, (t) =>90{91 let server = mediasoup.Server({ numWorkers: 2 });92 t.tearDown(() => server.close());93 server.dump()94 .then((data) =>95 {96 t.pass('server.dump() succeeded');97 t.equal(Object.keys(data.workers).length, 2, 'server.dump() must retrieve two workers');98 t.end();99 })100 .catch((error) => t.fail(`server.dump() failed: ${error}`));...

Full Screen

Full Screen

test_Server.js

Source:test_Server.js Github

copy

Full Screen

1'use strict';2const tap = require('tap');3const mediasoup = require('../');4const roomOptions = require('./data/options').roomOptions;5tap.test('server.updateSettings() with no options must succeed', { timeout: 2000 }, (t) =>6{7 let server = mediasoup.Server();8 t.tearDown(() => server.close());9 server.updateSettings()10 .then(() =>11 {12 t.pass('server.updateSettings() succeeded');13 t.end();14 })15 .catch((error) => t.fail(`server.updateSettings() failed: ${error}`));16});17tap.test('server.updateSettings() with valid options must succeed', { timeout: 2000 }, (t) =>18{19 let server = mediasoup.Server();20 t.tearDown(() => server.close());21 server.updateSettings({ logLevel: 'warn' })22 .then(() =>23 {24 t.pass('server.updateSettings() succeeded');25 t.end();26 })27 .catch((error) => t.fail(`server.updateSettings() failed: ${error}`));28});29tap.test('server.updateSettings() with invalid options must fail', { timeout: 2000 }, (t) =>30{31 let server = mediasoup.Server();32 t.tearDown(() => server.close());33 server.updateSettings({ logLevel: 'chicken' })34 .then(() => t.fail('server.updateSettings() succeeded'))35 .catch((error) =>36 {37 t.pass(`server.updateSettings() failed: ${error}`);38 t.end();39 });40});41tap.test('server.updateSettings() in a closed server must fail', { timeout: 2000 }, (t) =>42{43 let server = mediasoup.Server();44 t.tearDown(() => server.close());45 server.on('close', () =>46 {47 server.updateSettings({ logLevel: 'error' })48 .then(() => t.fail('server.updateSettings() succeeded'))49 .catch((error) =>50 {51 t.pass(`server.updateSettings() failed: ${error}`);52 t.type(error, mediasoup.errors.InvalidStateError, 'server.updateSettings() must reject with InvalidStateError');53 t.end();54 });55 });56 server.close();57});58tap.test('server.createRoom() must succeed', { _timeout: 2000 }, (t) =>59{60 let server = mediasoup.Server();61 t.tearDown(() => server.close());62 server.createRoom(roomOptions)63 .then((room) =>64 {65 t.pass('server.createRoom() succeeded');66 room.on('close', (error) =>67 {68 t.error(error, 'room must close cleanly');69 t.end();70 });71 // Wait a bit so Channel requests receive response72 setTimeout(() => room.close(), 50);73 })74 .catch((error) => t.fail(`server.createRoom() failed: ${error}`));75});76tap.test('server.createRoom() in a closed server must fail', { timeout: 2000 }, (t) =>77{78 let server = mediasoup.Server();79 server.close();80 server.createRoom(roomOptions)81 .then((room) => t.fail('server.createRoom() succeeded')) // eslint-disable-line no-unused-vars82 .catch((error) =>83 {84 t.pass(`server.createRoom() failed: ${error}`);85 t.type(error, mediasoup.errors.InvalidStateError, 'server.createRoom() must reject with InvalidStateError');86 t.end();87 });88});89tap.test('server.dump() must succeed', { timeout: 2000 }, (t) =>90{91 let server = mediasoup.Server({ numWorkers: 2 });92 t.tearDown(() => server.close());93 server.dump()94 .then((data) =>95 {96 t.pass('server.dump() succeeded');97 t.equal(Object.keys(data.workers).length, 2, 'server.dump() must retrieve two workers');98 t.end();99 })100 .catch((error) => t.fail(`server.dump() failed: ${error}`));...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .setValue('*[name="q"]','webdriverio')9 .keys('Enter')10 .getTitle().then(function(title) {11 console.log('Title was: ' + title);12 })13 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('chai').assert;3var serverConfig = {4};5var desiredCaps = {6};7var driver = wd.promiseChainRemote(serverConfig);8 .init(desiredCaps)9 .then(function() {10 return driver.setImplicitWaitTimeout(3000);11 })12 .then(function() {13 return driver.updateSettings({14 'ignoreUnimportantViews': true15 });16 })17 .then(function() {18 return driver.elementByName('Text');19 })20 .then(function(el) {21 return el.click();22 })23 .then(function() {24 return driver.elementByName('Text');25 })26 .then(function(el) {27 return el.text();28 })29 .then(function(text) {30 assert.equal(text, 'Text');31 })32 .fin(function() {33 return driver.quit();34 })35 .done();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require("wd");2var driver = wd.remote("localhost", 4723);3driver.init({4}, function() {5 driver.updateSettings({6 ignoreUnimportantViews: true7 }, function() {8 driver.quit();9 });10});11Error: Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Original error: Error executing adbExec. Original error: 'Command '/Users/xyz/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings put secure ignore_unimportant_views 1' exited with code 1'; Stderr: 'Exception occurred while executing:12java.lang.IllegalArgumentException: Unknown system setting: secure.ignore_unimportant_views13at com.android.server.am.ActivityManagerService.enforceCallingPermission(ActivityManagerService.java:10217)14at com.android.server.am.ActivityManagerService.enforceCallingOrSelfPermission(ActivityManagerService.java:10281)15at com.android.server.am.ActivityManagerService.enforceReadPermission(ActivityManagerService.java:10291)16at com.android.server.am.ActivityManagerService.enforceReadPermission(ActivityManagerService.java:10296)17at com.android.server.am.ActivityManagerService.enforceCallingPermission(ActivityManagerService.java:10217)18at com.android.server.am.ActivityManagerService.enforceCallingOrSelfPermission(ActivityManagerService.java:10281)19at com.android.server.am.ActivityManagerService.enforceCallingOrSelfUriPermission(ActivityManagerService.java:10460)20at com.android.server.am.ActivityManagerService.setSystemSetting(ActivityManagerService.java:27738)21at com.android.server.am.ActivityManagerShellCommand.runSet(ActivityManagerShellCommand.java:1833)22at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:170)23at android.os.ShellCommand.exec(ShellCommand.java:103)24at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:19369)25at android.os.Binder.shellCommand(Binder.java:634)26at android.os.Binder.onTransact(Binder.java:532)27at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3935)28at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3734)

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