Best JavaScript code snippet using redwood
job_detail.js
Source:job_detail.js
1$(function() {2 renderSettings();3 bindSubmitJobSettingsForm();4 $('[href="#settings"]').click(function() {5 renderSettings();6 });7 $('[href="#servers"]').click(function() {8 renderServers();9 });10 $('[href="#execution_info"]').click(function() {11 renderExecution();12 });13 bindTriggerButtons();14 bindTriggerAllButtons();15 bindPauseButtons();16 bindPauseAllButtons();17 bindResumeButtons();18 bindResumeAllButton();19 bindShutdownButtons();20 bindRemoveButtons();21 bindDisableButtons();22 bindEnableButtons();23});24function renderSettings() {25 $.get("job/settings", {jobName : $("#job-name").text()}, function (data) {26 $("#jobType").attr("value", data.jobType);27 $("#jobClass").attr("value", data.jobClass);28 $("#shardingTotalCount").attr("value", data.shardingTotalCount);29 $("#cron").attr("value", data.cron);30 $("#shardingItemParameters").text(data.shardingItemParameters);31 $("#jobParameter").attr("value", data.jobParameter);32 $("#monitorExecution").attr("checked", data.monitorExecution);33 $("#failover").attr("checked", data.failover);34 $("#misfire").attr("checked", data.misfire);35 $("#jobEventLogConfig").attr("checked", data.jobEventConfigs["log"]);36 $("#jobEventRdbConfig").attr("checked", data.jobEventConfigs["rdb"]);37 if (data.jobEventConfigs["rdb"]) {38 $("#driver").attr("value", data.jobEventConfigs["rdb"]["driverClassName"]);39 $("#url").attr("value", data.jobEventConfigs["rdb"]["url"]);40 $("#username").attr("value", data.jobEventConfigs["rdb"]["username"]);41 $("#password").attr("value", data.jobEventConfigs["rdb"]["password"]);42 if (data.jobEventConfigs["rdb"]["logLevel"]) {43 $("#logLevel").val(data.jobEventConfigs["rdb"]["logLevel"]);44 } 45 }46 $("#streamingProcess").attr("checked", data.streamingProcess);47 $("#maxTimeDiffSeconds").attr("value", data.maxTimeDiffSeconds);48 $("#monitorPort").attr("value", data.monitorPort);49 $("#jobShardingStrategyClass").attr("value", data.jobShardingStrategyClass);50 $("#executorServiceHandler").attr("value", data.jobProperties["executor_service_handler"]);51 $("#jobExceptionHandler").attr("value", data.jobProperties["job_exception_handler"]);52 $("#description").text(data.description);53 if (!data.monitorExecution) {54 $("#execution_info_tab").addClass("disabled");55 }56 changeJobEventRdbConfigDiv(data.jobEventConfigs["rdb"]);57 $("#scriptCommandLine").attr("value", data.scriptCommandLine);58 });59}60function bindSubmitJobSettingsForm() {61 $("#job-settings-form").submit(function(event) {62 event.preventDefault();63 var jobName = $("#job-name").text();64 var jobType = $("#jobType").val();65 var jobClass = $("#jobClass").val();66 var shardingTotalCount = $("#shardingTotalCount").val();67 var jobParameter = $("#jobParameter").val();68 var cron = $("#cron").val();69 var streamingProcess = $("#streamingProcess").prop("checked");70 var maxTimeDiffSeconds = $("#maxTimeDiffSeconds").val();71 var monitorPort = $("#monitorPort").val();72 var monitorExecution = $("#monitorExecution").prop("checked");73 var failover = $("#failover").prop("checked");74 var misfire = $("#misfire").prop("checked");75 var hasJobEventLogConfig = $("#jobEventLogConfig").prop("checked");76 var hasJobEventRdbConfig = $("#jobEventRdbConfig").prop("checked");77 var driver = $("#driver").val();78 var url = $("#url").val();79 var username = $("#username").val();80 var password = $("#password").val();81 var logLevel = $("#logLevel").val();82 var shardingItemParameters = $("#shardingItemParameters").val();83 var jobShardingStrategyClass = $("#jobShardingStrategyClass").val();84 var scriptCommandLine = $("#scriptCommandLine").val();85 var executorServiceHandler = $("#executorServiceHandler").val();86 var jobExceptionHandler = $("#jobExceptionHandler").val();87 var description = $("#description").val();88 var jobEventConfigs = {"log": hasJobEventLogConfig, "rdb": hasJobEventRdbConfig};89 if (hasJobEventRdbConfig) {90 if (driver.length == 0) {91 alert("æ°æ®åºé©±å¨ä¸è½ä¸ºç©º!");92 return;93 }94 if (url.length == 0) {95 alert("æ°æ®åºURLä¸è½ä¸ºç©º!");96 return;97 }98 if (username.length == 0) {99 alert("æ°æ®åºç¨æ·åä¸è½ä¸ºç©º!");100 return;101 }102 jobEventConfigs["rdb.driverClassName"] = driver;103 jobEventConfigs["rdb.url"] = url;104 jobEventConfigs["rdb.username"] = username;105 jobEventConfigs["rdb.password"] = password;106 jobEventConfigs["rdb.logLevel"] = logLevel;107 }108 var postJson = {jobName: jobName, jobType : jobType, jobClass : jobClass, shardingTotalCount: shardingTotalCount, jobParameter: jobParameter, cron: cron, streamingProcess: streamingProcess, maxTimeDiffSeconds: maxTimeDiffSeconds, monitorPort: monitorPort, monitorExecution: monitorExecution, failover: failover, misfire: misfire, shardingItemParameters: shardingItemParameters, jobShardingStrategyClass: jobShardingStrategyClass, jobProperties: {"executor_service_handler": executorServiceHandler, "job_exception_handler": jobExceptionHandler}, jobEventConfigs: jobEventConfigs, description: description, scriptCommandLine: scriptCommandLine};109 $.post("job/settings", postJson, function() {110 showSuccessDialog();111 if (monitorExecution) {112 $("#execution_info_tab").removeClass("disabled");113 } else {114 $("#execution_info_tab").addClass("disabled");115 }116 });117 });118}119function renderServers() {120 $.get("job/servers", {jobName : $("#job-name").text()}, function (data) {121 $("#servers tbody").empty();122 for (var i = 0;i < data.length;i++) {123 var status = data[i].status;124 var baseTd = "<td>" + data[i].ip + "</td><td>" + data[i].hostName + "</td><td>" + status + "</td><td>" + data[i].sharding + "</td>";125 var operationTd = "";126 var triggerButton = "<button operation='trigger' class='btn btn-success' ip='" + data[i].ip + "'>触å</button>";127 var resumeButton = "<button operation='resume' class='btn btn-success' ip='" + data[i].ip + "'>æ¢å¤</button>";128 var pauseButton = "<button operation='pause' class='btn btn-warning' ip='" + data[i].ip + "'" + ">æå</button>";129 var shutdownButton = "<button operation='shutdown' class='btn btn-danger' ip='" + data[i].ip + "'>å
³é</button>";130 var removeButton = "<button operation='remove' class='btn btn-danger' ip='" + data[i].ip + "'>å é¤</button>";131 var disableButton = "<button operation='disable' class='btn btn-danger' ip='" + data[i].ip + "'>失æ</button>";132 var enableButton = "<button operation='enable' class='btn btn-success' ip='" + data[i].ip + "'>çæ</button>";133 operationTd = triggerButton + " ";134 if ("PAUSED" === status) {135 operationTd = operationTd + resumeButton + " ";136 } else if ("DISABLED" !== status && "CRASHED" !== status && "SHUTDOWN" !== status) {137 operationTd = operationTd + pauseButton + " ";138 }139 if ("SHUTDOWN" !== status) {140 operationTd = operationTd + shutdownButton + " ";141 }142 if ("SHUTDOWN" === status || "CRASHED" === status) {143 operationTd = operationTd + removeButton + " ";144 }145 if("DISABLED" == status) {146 operationTd = operationTd + enableButton;147 } else if ("CRASHED" !== status && "SHUTDOWN" !== status){148 operationTd = operationTd + disableButton;149 }150 operationTd = "<td>" + operationTd + "</td>";151 var trClass = "";152 if ("READY" === status) {153 trClass = "info";154 } else if ("RUNNING" === status) {155 trClass = "success";156 } else if ("DISABLED" === status || "PAUSED" === status) {157 trClass = "warning";158 } else if ("CRASHED" === status || "SHUTDOWN" === status) {159 trClass = "danger";160 }161 $("#servers tbody").append("<tr class='" + trClass + "'>" + baseTd + operationTd + "</tr>");162 }163 });164}165function bindTriggerButtons() {166 $(document).on("click", "button[operation='trigger'][data-toggle!='modal']", function(event) {167 var jobName = $("#job-name").text();168 $.post("job/trigger", {jobName : jobName, ip : $(event.currentTarget).attr("ip")}, function () {169 renderServers();170 showSuccessDialog();171 });172 });173}174function bindTriggerAllButtons() {175 $(document).on("click", "#trigger-all-jobs-btn", function() {176 var jobName = $("#job-name").text();177 $.post("job/triggerAll/name", {jobName : jobName}, function () {178 renderServers();179 showSuccessDialog();180 });181 });182}183function bindPauseButtons() {184 $(document).on("click", "button[operation='pause'][data-toggle!='modal']", function(event) {185 var jobName = $("#job-name").text();186 $.post("job/pause", {jobName : jobName, ip : $(event.currentTarget).attr("ip")}, function () {187 renderServers();188 showSuccessDialog();189 });190 });191}192function bindPauseAllButtons() {193 $(document).on("click", "#pause-all-jobs-btn", function() {194 var jobName = $("#job-name").text();195 $.post("job/pauseAll/name", {jobName : jobName}, function () {196 renderServers();197 showSuccessDialog();198 });199 });200}201function bindResumeButtons() {202 $(document).on("click", "button[operation='resume']", function(event) {203 var jobName = $("#job-name").text();204 $.post("job/resume", {jobName : jobName, ip : $(event.currentTarget).attr("ip")}, function () {205 renderServers();206 showSuccessDialog();207 });208 });209}210function bindResumeAllButton() {211 $(document).on("click", "#resume-all-jobs-btn", function() {212 var jobName = $("#job-name").text();213 $.post("job/resumeAll/name", {jobName : jobName}, function () {214 renderServers();215 showSuccessDialog();216 });217 });218}219function renderExecution() {220 $.get("job/execution", {jobName : $("#job-name").text()}, function (data) {221 $("#execution tbody").empty();222 for (var i = 0;i < data.length;i++) {223 var status = data[i].status;224 var failoverIp = null == data[i].failoverIp ? "-" : data[i].failoverIp;225 var lastBeginTime = null == data[i].lastBeginTime ? null : new Date(data[i].lastBeginTime).toLocaleString();226 var lastCompleteTime = null == data[i].lastCompleteTime ? null : new Date(data[i].lastCompleteTime).toLocaleString();227 var nextFireTime = null == data[i].nextFireTime ? null : new Date(data[i].nextFireTime).toLocaleString();228 var baseTd = "<td>" + data[i].item + "</td><td>" + status + "</td><td>" + failoverIp + "</td><td>" + lastBeginTime + "</td><td>" + lastCompleteTime + "</td><td>" + nextFireTime + "</td>";229 var trClass = "";230 if ("RUNNING" === status) {231 trClass = "success";232 } else if ("COMPLETED" === status) {233 trClass = "info";234 } else if ("PENDING" === status) {235 trClass = "warning";236 }237 $("#execution tbody").append("<tr class='" + trClass + "'>" + baseTd + "</tr>");238 }239 });240}241function bindShutdownButtons() {242 $(document).on("click", "button[operation='shutdown']", function(event) {243 var jobName = $("#job-name").text();244 $.post("job/shutdown", {jobName : jobName, ip : $(event.currentTarget).attr("ip")}, function () {245 renderServers();246 showSuccessDialog();247 });248 });249}250function bindRemoveButtons() {251 $(document).on("click", "button[operation='remove']", function(event) {252 var jobName = $("#job-name").text();253 $.post("job/remove", {jobName : jobName, ip : $(event.currentTarget).attr("ip")}, function () {254 renderServers();255 showSuccessDialog();256 });257 });258}259function bindDisableButtons() {260 $(document).on("click", "button[operation='disable']", function(event) {261 var jobName = $("#job-name").text();262 $.post("job/disable", {jobName : jobName, ip : $(event.currentTarget).attr("ip")}, function () {263 renderServers();264 showSuccessDialog();265 });266 });267}268function bindEnableButtons() {269 $(document).on("click", "button[operation='enable']", function(event) {270 var jobName = $("#job-name").text();271 $.post("job/enable", {jobName : jobName, ip : $(event.currentTarget).attr("ip")}, function () {272 renderServers();273 showSuccessDialog();274 });275 });276}277function changeJobEventRdbConfigDiv(isChecked) {278 if (isChecked) {279 $("#jobEventRdbConfigDiv").show();280 } else {281 $("#jobEventRdbConfigDiv").hide();282 }...
job_config.js
Source:job_config.js
1$(function() {2 tooltipLocale();3 validate();4 bindSubmitJobSettingsForm();5 bindResetForm();6});7function tooltipLocale(){8 for (var i = 0; i < $("[data-toggle='tooltip']").length; i++) {9 var object = $("[data-toggle='tooltip']")[i];10 $(object).attr('title',$.i18n.prop("placeholder-" + object.getAttribute("id"))).tooltip('fixTitle');11 }12}13function getJobParams() {14 var jobName = $("#job-overviews-name").text();15 var jobParams;16 $.ajax({17 url: "/api/jobs/config/" + jobName,18 async: false,19 success: function(data) {20 jobParams = data;21 }22 });23 return jobParams;24}25function bindSubmitJobSettingsForm() {26 $("#update-job-info-btn").on("click", function(){27 var bootstrapValidator = $("#job-config-form").data("bootstrapValidator");28 bootstrapValidator.validate();29 if (bootstrapValidator.isValid()) {30 var jobName = $("#job-name").val();31 var jobType = $("#job-type").val();32 var jobClass = $("#job-class").val();33 var shardingTotalCount = $("#sharding-total-count").val();34 var jobParameter = $("#job-parameter").val();35 var cron = $("#cron").val();36 var streamingProcess = $("#streaming-process").prop("checked");37 var maxTimeDiffSeconds = $("#max-time-diff-seconds").val();38 var monitorPort = $("#monitor-port").val();39 var monitorExecution = $("#monitor-execution").prop("checked");40 var failover = $("#failover").prop("checked");41 var misfire = $("#misfire").prop("checked");42 var driver = $("#driver").val();43 var url = $("#url").val();44 var username = $("#username").val();45 var password = $("#password").val();46 var logLevel = $("#logLevel").val();47 var shardingItemParameters = $("#sharding-item-parameters").val();48 var jobShardingStrategyClass = $("#job-sharding-strategy-class").val();49 var scriptCommandLine = $("#script-command-line").val();50 var executorServiceHandler = $("#executor-service-handler").val();51 var jobExceptionHandler = $("#job-exception-handler").val();52 var description = $("#description").val();53 var reconcileIntervalMinutes = $("#reconcile-interval-minutes").val();54 var jobExecutionLog = $("#job-execution-log").prop("checked");55 var jobStatusTraceLog = $("#job-status-trace-log").prop("checked");56 var postJson = {jobExecutionLog:jobExecutionLog,jobStatusTraceLog:jobStatusTraceLog,jobName: jobName, jobType : jobType, jobClass : jobClass, shardingTotalCount: shardingTotalCount, jobParameter: jobParameter, cron: cron, streamingProcess: streamingProcess, maxTimeDiffSeconds: maxTimeDiffSeconds, monitorPort: monitorPort, monitorExecution: monitorExecution, failover: failover, misfire: misfire, shardingItemParameters: shardingItemParameters, jobShardingStrategyClass: jobShardingStrategyClass, jobProperties: {"executor_service_handler": executorServiceHandler, "job_exception_handler": jobExceptionHandler}, description: description, scriptCommandLine: scriptCommandLine, reconcileIntervalMinutes:reconcileIntervalMinutes};57 var jobParams = getJobParams();58 if (jobParams.monitorExecution !== monitorExecution || jobParams.failover !== failover || jobParams.misfire !== misfire) {59 showUpdateConfirmModal();60 $(document).off("click", "#confirm-btn");61 $(document).on("click", "#confirm-btn", function() {62 $("#confirm-dialog").modal("hide");63 submitAjax(postJson);64 });65 } else {66 submitAjax(postJson);67 }68 }69 });70}71function submitAjax(postJson) {72 $.ajax({73 url: "/api/jobs/config",74 type: "PUT",75 data: JSON.stringify(postJson),76 contentType: "application/json",77 dataType: "json",78 success: function() {79 $("#data-update-job").modal("hide");80 $("#jobs-status-overview-tbl").bootstrapTable("refresh");81 showSuccessDialog();82 }83 });84}85function validate() {86 $("#job-config-form").bootstrapValidator({87 message: "This value is not valid",88 feedbackIcons: {89 valid: "glyphicon glyphicon-ok",90 invalid: "glyphicon glyphicon-remove",91 validating: "glyphicon glyphicon-refresh"92 },93 fields: {94 shardingTotalCount: {95 validators: {96 notEmpty: {97 message: $.i18n.prop("job-sharding-count-not-null")98 },99 regexp: {100 regexp: /^(-?\d+)?$/,101 message: $.i18n.prop("job-sharding-count-should-be-integer")102 }103 }104 },105 cron: {106 validators: {107 stringLength: {108 max: 40,109 message: $.i18n.prop("job-cron-length-limit")110 },111 notEmpty: {112 message: $.i18n.prop("job-cron-not-null")113 }114 }115 },116 monitorPort: {117 validators: {118 regexp: {119 regexp: /^(-?\d+)?$/,120 message: $.i18n.prop("job-monitor-port-should-be-integer")121 },122 notEmpty: {123 message: $.i18n.prop("job-monitor-port-not-null")124 },125 callback: {126 message: $.i18n.prop("job-monitor-port-range-limit"),127 callback: function(value, validator) {128 var monitorPort = parseInt(validator.getFieldElements("monitorPort").val(), 10);129 if (monitorPort <= 65535) {130 validator.updateStatus("monitorPort", "VALID");131 return true;132 }133 return false;134 }135 }136 }137 }138 }139 });140 $("#job-config-form").submit(function(event) {141 event.preventDefault();142 });143}144function bindResetForm() {145 $("#reset").click(function() {146 $("#job-config-form").data("bootstrapValidator").resetForm();147 });...
Using AI Code Generation
1var redwood = require('redwood');2var monitor = redwood.monitorExecution('test.js');3monitor.end();4var redwood = require('redwood');5var monitor = redwood.monitorExecution('test2.js');6monitor.end();7var redwood = require('redwood');8var monitor = redwood.monitorExecution('test3.js');9monitor.end();10var redwood = require('redwood');11var monitor = redwood.monitorExecution('test4.js');12monitor.end();13var redwood = require('redwood');14var monitor = redwood.monitorExecution('test5.js');15monitor.end();16var redwood = require('redwood');17var monitor = redwood.monitorExecution('test6.js');18monitor.end();19var redwood = require('redwood');20var monitor = redwood.monitorExecution('test7.js');21monitor.end();22var redwood = require('redwood');23var monitor = redwood.monitorExecution('test8.js');24monitor.end();25var redwood = require('redwood');26var monitor = redwood.monitorExecution('test9.js');27monitor.end();28var redwood = require('redwood');29var monitor = redwood.monitorExecution('test10.js');30monitor.end();31var redwood = require('redwood');32var monitor = redwood.monitorExecution('test11
Using AI Code Generation
1var redwood = require('redwoodJS');2var monitor = new redwood.MonitorExecution();3monitor.start();4monitor.stop();5var redwood = require('redwoodJS');6var monitor = new redwood.MonitorExecution();7monitor.start();8monitor.stop();9var redwood = require('redwoodJS');10var monitor = new redwood.MonitorExecution();11monitor.start();12monitor.stop();13var redwood = require('redwoodJS');14var monitor = new redwood.MonitorExecution();15monitor.start();16monitor.stop();17var redwood = require('redwoodJS');18var monitor = new redwood.MonitorExecution();19monitor.start();20monitor.stop();21var redwood = require('redwoodJS');22var monitor = new redwood.MonitorExecution();23monitor.start();24monitor.stop();25var redwood = require('redwoodJS');26var monitor = new redwood.MonitorExecution();27monitor.start();28monitor.stop();29var redwood = require('redwoodJS');30var monitor = new redwood.MonitorExecution();31monitor.start();32monitor.stop();33var redwood = require('redwoodJS');34var monitor = new redwood.MonitorExecution();35monitor.start();36monitor.stop();37var redwood = require('redwoodJS');38var monitor = new redwood.MonitorExecution();39monitor.start();40monitor.stop();
Using AI Code Generation
1var redwood = require('redwoodjs');2redwood.MonitorExecution("test.js");3var a = 1;4var b = 2;5var c = a + b;6console.log(c);7var redwood = require('redwoodjs');8redwood.MonitorExecution("test.js");9var a = 1;10var b = 2;11var c = a + b;12console.log(c);13redwood.StopMonitoringExecution();
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!!