How to use openExecution method in redwood

Best JavaScript code snippet using redwood

ExecutionMonitor.js

Source:ExecutionMonitor.js Github

copy

Full Screen

1import { useSpreadState } from "../common/hooks";2import React, { useEffect } from "react";3import { delay, switchMap, tap } from "rxjs/operators";4import Random from "../util/Random";5import Alert from "./Alert";6import { makeStyles, useTheme } from "@material-ui/core";7import { of } from "rxjs";8import AttachmentViewer from "../viewers/AttachmentViewer";9import Typography from "@material-ui/core/Typography";10import AuthorizationService from "../services/AuthorizationService";11import { DataType, isSimpleSchema } from "../services/DataTypeService";12import { TaskStatusConfig, TaskStatusViewer } from "../config/dataTypes/Setup/Task";13import Skeleton from "@material-ui/lab/Skeleton";14import clsx from "clsx";15import IconButton from "@material-ui/core/IconButton";16import OpenIcon from "@material-ui/icons/OpenInNew";17import { RecordSubject, TabsSubject } from "../services/subjects";18import zzip from "../util/zzip";19import RefreshIcon from "@material-ui/icons/Refresh";20import CircularProgress from "@material-ui/core/CircularProgress";21import LinearProgress from "@material-ui/core/LinearProgress";22const AliveStatuses = ['pending', 'running', 'retrying', 'paused'];23const useStyles = makeStyles(theme => ({24 result: {25 marginTop: theme.spacing(1),26 padding: theme.spacing(1),27 background: theme.palette.background.paper28 },29 error: {30 color: theme.palette.error.main31 },32 warning: {33 color: theme.palette.warning.main34 },35 resultSkeleton: {36 margin: theme.spacing(1, 0)37 },38 attachment: {39 marginTop: theme.spacing(1)40 },41 refreshing: {42 margin: theme.spacing(2, 0)43 },44 progress: {45 width: '100%',46 padding: theme.spacing(1, 0)47 }48}));49const Delays = [1, 3, 5, 8, 13];50const StatusNotifications = {51 failed: 'error',52 paused: 'warning'53};54export function ExecutionMonitor({ dataType, value, mainIcon }) {55 const [state, setState] = useSpreadState({56 task: value.task,57 execution: value,58 delayIndex: 0,59 taskProgress: 0,60 refreshKey: Random.string()61 });62 const theme = useTheme();63 const classes = useStyles();64 const {65 task, taskDataType, notificationDataType, delayIndex, taskProgress,66 execution, refreshKey, resultData, retrievingResult, refreshing67 } = state;68 const { status } = task;69 const { attachment } = execution;70 useEffect(() => {71 const subscription = zzip(72 dataType.findByName(value.task._type),73 DataType.find({74 namespace: 'Setup',75 name: 'SystemNotification'76 })77 ).subscribe(([taskDataType, notificationDataType]) => setState({78 taskDataType,79 notificationDataType80 }));81 return () => subscription.unsubscribe();82 }, [value, dataType]);83 useEffect(() => {84 if (taskDataType && refreshKey && taskProgress < 100) {85 const subscription = of(true).pipe(86 delay(1000 * (Delays[delayIndex] || 0)),87 tap(() => setState({ refreshing: true })),88 switchMap(() => taskDataType.get(task.id, {89 include_blanks: false,90 viewport: '{id status progress description current_execution {' +91 'attachment status notifications {id type message}' +92 '}'93 }))94 ).subscribe(remoteTask => {95 setState(({ task, taskProgress }) => {96 const currentProgress = remoteTask?.progress || taskProgress;97 if (currentProgress > taskProgress) {98 return {99 taskProgress: currentProgress,100 task: remoteTask,101 execution: remoteTask.current_execution || {},102 delayIndex: 2,103 refreshing: false104 };105 }106 const nextDelay = AliveStatuses.includes(remoteTask?.status) && delayIndex < Delays.length - 1107 ? delayIndex + 1108 : delayIndex;109 return {110 taskProgress: currentProgress,111 task: remoteTask || task,112 execution: remoteTask?.current_execution || {},113 delayIndex: nextDelay,114 refreshKey: nextDelay === delayIndex ? null : refreshKey,115 refreshing: false116 };117 });118 });119 return () => subscription.unsubscribe();120 }121 }, [taskDataType, refreshKey, delayIndex, taskProgress]);122 useEffect(() => {123 if (attachment) {124 const { url, size, metadata } = attachment;125 if (url && size && size < 30 && isSimpleSchema(metadata?.schema)) {126 setState({ retrievingResult: true });127 const subscription = AuthorizationService.request({128 url: attachment.url,129 method: 'GET'130 }).subscribe(131 resultData => setState({ resultData, retrievingResult: false })132 );133 return () => subscription.unsubscribe();134 }135 }136 }, [attachment]);137 if (!taskDataType) {138 return <LinearProgress/>;139 }140 const statusAlert = TaskStatusConfig[status] || TaskStatusConfig.default;141 Object.keys(statusAlert).forEach(key => {142 const value = statusAlert[key];143 if (typeof value === 'function') {144 statusAlert[key] = value(theme);145 }146 });147 Object.keys(TaskStatusConfig.default).forEach(key => {148 let value = statusAlert[key];149 if (!value) {150 value = TaskStatusConfig.default[key];151 if (typeof value === 'function') {152 value = value(theme);153 }154 statusAlert[key] = value;155 }156 });157 let result;158 if (attachment) {159 let data;160 if (retrievingResult) {161 data = <Skeleton variant="rect"162 width={theme.spacing(attachment.size)}163 height={theme.spacing(3)}164 className={classes.resultSkeleton}/>;165 } else if (resultData) {166 data = (167 <Typography component="pre"168 variant="h6"169 className={classes.result}>170 {resultData}171 </Typography>172 );173 }174 result = (175 <>176 {data}177 <AttachmentViewer value={attachment} className={classes.attachment}/>178 </>179 );180 }181 let notifications;182 Object.keys(StatusNotifications).forEach(key => {183 if (status === key) {184 const notificationType = StatusNotifications[key];185 const notification = (execution.notifications || []).find(({ type }) => type === notificationType);186 if (notification) {187 notifications = (188 <Typography component="div"189 variant="subtitle2"190 className={clsx(classes.result, classes[notificationType], 'flex column')}>191 {notification.message}192 <div>193 <IconButton size="small"194 onClick={() => TabsSubject.next({195 key: RecordSubject.for(notificationDataType.id, notification.id).key196 })}>197 <OpenIcon className={classes[notificationType]}/>198 </IconButton>199 </div>200 </Typography>201 );202 }203 }204 });205 const openExecution = () => TabsSubject.next({206 key: RecordSubject.for(taskDataType.id, task.id).key207 });208 let refresh;209 if (refreshing) {210 refresh = <CircularProgress size={theme.spacing(3)} className={classes.refreshing}/>;211 } else if (AliveStatuses.includes(status) && delayIndex > 3) {212 const handleRefresh = () => setState({213 refreshKey: Random.string(),214 delayIndex: Delays.length215 });216 refresh = (217 <IconButton onClick={handleRefresh} color="primary">218 <RefreshIcon/>219 </IconButton>220 );221 }222 const title = (223 <div className="text-align-center">224 {task.description}225 <IconButton onClick={openExecution}>226 <OpenIcon/>227 </IconButton>228 </div>229 );230 return (231 <Alert {...statusAlert}232 title={title}>233 <div className="flex column align-items-center full-width">234 <TaskStatusViewer value={status} item={task}/>235 <div className={classes.progress}>236 <Typography component="div" variant="caption">237 {task.progress}%238 </Typography>239 <LinearProgress variant="determinate" value={task.progress} className="grow-1"/>240 </div>241 {refresh}242 {result}243 {notifications}244 </div>245 </Alert>246 );...

Full Screen

Full Screen

Operativos.js

Source:Operativos.js Github

copy

Full Screen

1/* global Ext,Etc */2Ext.require('Ext.window.MessageBox');3Ext.define('ExtZF.controller.plano.Operativos', {4 extend: 'Ext.app.Controller',5 stores: ['Programacoes','Operativos','OperativosHistorico','Situacoes','Andamentos'], // Store utilizado no gerenciamento do usuário6 models: ['Programacoes','Operativos','OperativosHistorico','Situacoes','Andamentos'], // Modelo do usuário7 views: [8 'plano.operativos.List',9 'plano.operativos.Edit',10 'plano.operativos.Form'11 ],12 refs: [{13 ref:'grid',14 selector:'planoOperativosList'15 },{16 ref:'editPanel',17 selector:'planoOperativosEdit'18 },{19 ref:'formPanel',20 selector:'planoOperativosForm'21 }22 ],23 init: function() {24 var me = this;25 if(typeof(ExtZF.app.controllers.map['ExtZF.controller.plano.Operativos'])==='object'26 && me.initiated===true){27 return;28 }29 me.control(30 {31 'planoOperativosList': {32// itemdblclick: me.editObject33 },34 'planoOperativosList button[action=incluir]': {35 click: me.editObject36 },37 'planoOperativosList button[action=excluir]': {38 click: me.deleteObject39 },40 'planoOperativosForm button[action=salvar]': {41 click: me.saveObject42 },43 'planoOperativosForm [name=andamento_id]': {44 change: me.checkFinished45 },46 });47 me.application.on({48 filtrarHistoricoPorOperativo: me.filtrarHistoricoPorOperativo, 49 scope: me50 });51 me.application.on({52 openExecution: me.openExecution, 53 scope: me54 });55 me.initiated=true;56 },57 openExecution : function(record){58 var me = this;59 me.editObject(null,record);60 },61 checkFinished : function(combo,newValue,oldValue){62 var me=this;63 var percentual = Ext.getCmp('percentual_execucao');64 if(newValue===6){65 me.percentualOldValue = percentual.getValue();66 percentual.setValue(100);67 percentual.setDisabled(true); 68 var dataEncerramento = Ext.getCmp('data_encerramento');69 dataEncerramento.onTriggerClick();70 }else if(newValue===1){71 combo.setValue(oldValue);72 }else{73 if(typeof(me.percentualOldValue)!=='undefined'){74 percentual.setValue(me.percentualOldValue);75 delete me.percentualOldValue;76 }77 percentual.setDisabled(false);78 }79 },80 filtrarHistoricoPorOperativo: function(operativo_id){81 var me = this; 82 me.getOperativosHistoricoStore().remoteFilter = false;83 me.getOperativosHistoricoStore().suspendEvents();84 me.getOperativosHistoricoStore().clearFilter();85 me.getOperativosHistoricoStore().resumeEvents();86 me.getOperativosHistoricoStore().remoteFilter = true;87 me.getOperativosHistoricoStore().filter('operativo_id',operativo_id);88 89 },90 editObject: function(grid, record) {91 var me = this;92 var view = Ext.widget('planoOperativosEdit');93 view.setTitle('Edição ');94 if(!record.data){95 record = new ExtZF.model.Operativos();96 me.getOperativosStore().add(record);97 view.setTitle('Cadastro');98 }99 if(parseInt(record.get('andamento_id'),10)===1){100 record.set('andamento_id',2);101 me.getOperativosStore().sync();102 }103 104 view.down('form').loadRecord(record);105 },106 deleteObject: function() {107 var me = this;108 var grid = me.getGrid(); // recupera lista de usuários109 var ids = grid.getSelectionModel().getSelection(); // recupera linha selecionadas110 if(ids.length === 0){111 Ext.Msg.alert('Atenção', 'Nenhum registro selecionado');112 return ;113 }114 Ext.Msg.confirm('Confirmação', 'Tem certeza que deseja excluir o(s) registro(s) selecionado(s)?',115 function(opt){116 if(opt !== 'yes')117 return;118 grid.el.mask('Excluindo registro(s)');119 var store = me.getOperativosStore();120 store.remove(ids);121 store.sync();122 grid.el.unmask();123 }, this);124 },125 chengeHtmlFontSize : function(){126 var avaliacaoEditor =Ext.getCmp('avaliacao_andamentoHtmlEditor');127 avaliacaoEditor.focus(true);128 avaliacaoEditor.relayCmd('FontSize',2);129 },130 saveObject: function(button) {131 var me=this;132 me.chengeHtmlFontSize();133 var win = button.up('window'), // recupera um item acima(pai) do button do tipo window134 form = win.down('form').getForm(); // recupera item abaixo(filho) da window do tipo form135 if (form.isValid()) {136 var r = form.getRecord();137 form.updateRecord(r);138 me.getOperativosStore().sync();139 win.close();140 Ext.Msg.alert('Salvo', 'Registro salvo com sucesso',{duration:500});141 me.getOperativosStore().load();142 if(button.itemId==='sendmail'){143 var programacoesStore = me.getProgramacoesStore();144 programacoesStore.remoteFilter = false;145 programacoesStore.suspendEvents();146 programacoesStore.clearFilter();147 programacoesStore.resumeEvents();148 programacoesStore.filter('id',r.get('programacao_id'));149 programacoesStore.remoteFilter = true;150 programacoesStore.load({151 callback : function(records, operation, success) {152// var programacaoRecord = programacoesStore.findRecord('id',parseInt(r.get('id'),10));153 me.application.fireEvent('sendMailToSupervisor', records[0]);154 }155 });156 }157 }else{158 Etc.alert('formulário inválido');159 }160 }...

Full Screen

Full Screen

execution-edit.component.ts

Source:execution-edit.component.ts Github

copy

Full Screen

...54 this.executionService.update(this.form.value).subscribe(55 result => {56 this.form.reset();57 this.submitted = true;58 this.navigatorService.openExecution(this.projectId, this.model._id);59 }, error => {60 this.submitted = false;61 })62 }63 addNew() {64 this.executionService.push(this.form.value).subscribe(65 result => {66 this.form.reset();67 this.submitted = true;68 this.navigatorService.openExecution(this.projectId, result._id);69 }, error => {70 this.submitted = false;71 })72 }73 getFormGroup(data?: any): FormGroup {74 return new FormGroup({75 _id: new FormControl(data ? data._id : undefined),76 title: new FormControl(data ? data.title : '', Validators.required),77 description: new FormControl(data ? data.description : '', Validators.required),78 projectId: new FormControl(data ? data.projectId : ''),79 status: new FormControl(data ? data.status : 'active')80 });81 }82}

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2redwood.openExecution('test', function(err, exec) {3 if (err) {4 console.log('Error opening execution: ' + err);5 } else {6 console.log('Execution opened successfully');7 }8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var rw = new redwood.Redwood();3rw.openExecution('test', function (err, execution) {4 if (err) {5 console.log('Error opening execution: ' + err);6 return;7 }8 console.log('Execution opened successfully');9});10var redwood = require('redwood');11var rw = new redwood.Redwood();12rw.openExecution('test', function (err, execution) {13 if (err) {14 console.log('Error opening execution: ' + err);15 return;16 }17 console.log('Execution opened successfully');18});19var redwood = require('redwood');20var rw = new redwood.Redwood();21rw.openExecution('test', function (err, execution) {22 if (err) {23 console.log('Error opening execution: ' + err);24 return;25 }26 console.log('Execution opened successfully');27});28var redwood = require('redwood');29var rw = new redwood.Redwood();30rw.openExecution('test', function (err, execution) {31 if (err) {32 console.log('Error opening execution: ' + err);33 return;34 }35 console.log('Execution opened successfully');36});37var redwood = require('redwood');38var rw = new redwood.Redwood();39rw.openExecution('test', function (err, execution) {40 if (err) {41 console.log('Error opening execution: ' + err);42 return;43 }44 console.log('Execution opened successfully');45});46var redwood = require('redwood');47var rw = new redwood.Redwood();48rw.openExecution('test', function (err, execution) {49 if (err) {50 console.log('Error opening execution: ' + err);51 return;52 }53 console.log('Execution opened successfully');54});55var redwood = require('redwood');56var rw = new redwood.Redwood();

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2redwood.openExecution('test', {test: 'test'});3console.log('test');4var redwood = require('redwood');5redwood.openExecution('test', {test: 'test'});6console.log('test2');7var redwood = require('redwood');8var execution = redwood.openExecution('test', {test: 'test'});9console.log('test');10execution.start();11execution.pause();12execution.resume();13execution.stop();14var redwood = require('redwood');15var execution = redwood.openExecution('test', {test: 'test'});16console.log('test2');17execution.start();18execution.pause();19execution.resume();20execution.stop();

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2redwood.openExecution('test', 'Test', '0.0.1', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', function(err, result) {3 console.log('err: ' + err);4 console.log('result: ' + result);5});6var redwood = require('redwood');7redwood.closeExecution('test', 'Test', '0.0.1', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', function(err, result) {8 console.log('err: ' + err);9 console.log('result: ' + result);10});11var redwood = require('redwood');12redwood.getExecution('test', 'Test', '0.0.1', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', function(err, result) {13 console.log('err: ' + err);14 console.log('result: ' + result);15});16var redwood = require('redwood');17redwood.getExecutionList('test', 'Test', '0.0.1', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', function(err, result) {18 console.log('err: ' + err);19 console.log('result: ' + result);20});21var redwood = require('redwood');22redwood.getExecutionListByStatus('test', 'Test', '0.0.1', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', function(err, result) {23 console.log('err: ' + err);24 console.log('result: ' + result);25});

Full Screen

Using AI Code Generation

copy

Full Screen

1var redwood = require('redwood');2var redwoodInstance = new redwood.Redwood();3var redwoodInstance.openExecution('test', function(err, execution){4 execution.close(function(err, result){5 });6});

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