How to use executing method in Best

Best JavaScript code snippet using best

rbd-list.component.ts

Source:rbd-list.component.ts Github

copy

Full Screen

1import { Component, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';2import * as _ from 'lodash';3import { BsModalRef, BsModalService } from 'ngx-bootstrap';4import { RbdService } from '../../../shared/api/rbd.service';5import {6 DeletionModalComponent7} from '../../../shared/components/deletion-modal/deletion-modal.component';8import { CellTemplate } from '../../../shared/enum/cell-template.enum';9import { NotificationType } from '../../../shared/enum/notification-type.enum';10import { ViewCacheStatus } from '../../../shared/enum/view-cache-status.enum';11import { CdTableColumn } from '../../../shared/models/cd-table-column';12import { CdTableSelection } from '../../../shared/models/cd-table-selection';13import { ExecutingTask } from '../../../shared/models/executing-task';14import { FinishedTask } from '../../../shared/models/finished-task';15import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe';16import { DimlessPipe } from '../../../shared/pipes/dimless.pipe';17import {18 NotificationService19} from '../../../shared/services/notification.service';20import { SummaryService } from '../../../shared/services/summary.service';21import { TaskManagerMessageService } from '../../../shared/services/task-manager-message.service';22import { TaskManagerService } from '../../../shared/services/task-manager.service';23import {24 FlattenConfirmationModalComponent25} from '../flatten-confirmation-modal/flatten-confimation-modal.component';26import { RbdParentModel } from '../rbd-form/rbd-parent.model';27import { RbdModel } from './rbd-model';28@Component({29 selector: 'cd-rbd-list',30 templateUrl: './rbd-list.component.html',31 styleUrls: ['./rbd-list.component.scss']32})33export class RbdListComponent implements OnInit, OnDestroy {34 @ViewChild('usageTpl') usageTpl: TemplateRef<any>;35 @ViewChild('parentTpl') parentTpl: TemplateRef<any>;36 @ViewChild('nameTpl') nameTpl: TemplateRef<any>;37 images: any;38 executingTasks: ExecutingTask[] = [];39 columns: CdTableColumn[];40 retries: number;41 viewCacheStatusList: any[];42 selection = new CdTableSelection();43 summaryDataSubscription = null;44 modalRef: BsModalRef;45 constructor(private rbdService: RbdService,46 private dimlessBinaryPipe: DimlessBinaryPipe,47 private dimlessPipe: DimlessPipe,48 private summaryService: SummaryService,49 private modalService: BsModalService,50 private notificationService: NotificationService,51 private taskManagerMessageService: TaskManagerMessageService,52 private taskManagerService: TaskManagerService) {53 }54 ngOnInit() {55 this.columns = [56 {57 name: 'Name',58 prop: 'name',59 flexGrow: 2,60 cellTransformation: CellTemplate.executing61 },62 {63 name: 'Pool',64 prop: 'pool_name',65 flexGrow: 266 },67 {68 name: 'Size',69 prop: 'size',70 flexGrow: 1,71 cellClass: 'text-right',72 pipe: this.dimlessBinaryPipe73 },74 {75 name: 'Objects',76 prop: 'num_objs',77 flexGrow: 1,78 cellClass: 'text-right',79 pipe: this.dimlessPipe80 },81 {82 name: 'Object size',83 prop: 'obj_size',84 flexGrow: 1,85 cellClass: 'text-right',86 pipe: this.dimlessBinaryPipe87 },88 {89 name: 'Provisioned',90 prop: 'disk_usage',91 cellClass: 'text-center',92 flexGrow: 1,93 pipe: this.dimlessBinaryPipe94 },95 {96 name: 'Total provisioned',97 prop: 'total_disk_usage',98 cellClass: 'text-center',99 flexGrow: 1,100 pipe: this.dimlessBinaryPipe101 },102 {103 name: 'Parent',104 prop: 'parent',105 flexGrow: 2,106 cellTemplate: this.parentTpl107 }108 ];109 this.summaryService.get().then(resp => {110 this.loadImages(resp.executing_tasks);111 this.summaryDataSubscription = this.summaryService.summaryData$.subscribe((data: any) => {112 this.loadImages(data.executing_tasks);113 });114 });115 }116 ngOnDestroy() {117 if (this.summaryDataSubscription) {118 this.summaryDataSubscription.unsubscribe();119 }120 }121 loadImages(executingTasks) {122 if (executingTasks === null) {123 executingTasks = this.executingTasks;124 }125 this.rbdService.list()126 .subscribe(127 (resp: any[]) => {128 let images = [];129 const viewCacheStatusMap = {};130 resp.forEach(pool => {131 if (_.isUndefined(viewCacheStatusMap[pool.status])) {132 viewCacheStatusMap[pool.status] = [];133 }134 viewCacheStatusMap[pool.status].push(pool.pool_name);135 images = images.concat(pool.value);136 });137 const viewCacheStatusList = [];138 _.forEach(viewCacheStatusMap, (value: [], key) => {139 viewCacheStatusList.push({140 status: parseInt(key, 10),141 statusFor: (value.length > 1 ? 'pools ' : 'pool ') +142 '<strong>' + value.join('</strong>, <strong>') + '</strong>'143 });144 });145 this.viewCacheStatusList = viewCacheStatusList;146 images.forEach(image => {147 image.executingTasks = this._getExecutingTasks(executingTasks,148 image.pool_name, image.name);149 });150 this.images = this.merge(images, executingTasks);151 this.executingTasks = executingTasks;152 },153 () => {154 this.viewCacheStatusList = [{status: ViewCacheStatus.ValueException}];155 }156 );157 }158 _getExecutingTasks(executingTasks: ExecutingTask[], poolName, imageName): ExecutingTask[] {159 const result: ExecutingTask[] = [];160 executingTasks.forEach(executingTask => {161 if (executingTask.name === 'rbd/snap/create' ||162 executingTask.name === 'rbd/snap/delete' ||163 executingTask.name === 'rbd/snap/edit' ||164 executingTask.name === 'rbd/snap/rollback') {165 if (poolName === executingTask.metadata['pool_name'] &&166 imageName === executingTask.metadata['image_name']) {167 result.push(executingTask);168 }169 }170 });171 return result;172 }173 private merge(rbds: RbdModel[], executingTasks: ExecutingTask[] = []) {174 const resultRBDs = _.clone(rbds);175 executingTasks.forEach((executingTask) => {176 const rbdExecuting = resultRBDs.find((rbd) => {177 return rbd.pool_name === executingTask.metadata['pool_name'] &&178 rbd.name === executingTask.metadata['image_name'];179 });180 if (rbdExecuting) {181 if (executingTask.name === 'rbd/delete') {182 rbdExecuting.cdExecuting = 'deleting';183 } else if (executingTask.name === 'rbd/edit') {184 rbdExecuting.cdExecuting = 'updating';185 } else if (executingTask.name === 'rbd/flatten') {186 rbdExecuting.cdExecuting = 'flattening';187 }188 } else if (executingTask.name === 'rbd/create') {189 const rbdModel = new RbdModel();190 rbdModel.name = executingTask.metadata['image_name'];191 rbdModel.pool_name = executingTask.metadata['pool_name'];192 rbdModel.cdExecuting = 'creating';193 resultRBDs.push(rbdModel);194 } else if (executingTask.name === 'rbd/clone') {195 const rbdModel = new RbdModel();196 rbdModel.name = executingTask.metadata['child_image_name'];197 rbdModel.pool_name = executingTask.metadata['child_pool_name'];198 rbdModel.cdExecuting = 'cloning';199 resultRBDs.push(rbdModel);200 } else if (executingTask.name === 'rbd/copy') {201 const rbdModel = new RbdModel();202 rbdModel.name = executingTask.metadata['dest_image_name'];203 rbdModel.pool_name = executingTask.metadata['dest_pool_name'];204 rbdModel.cdExecuting = 'copying';205 resultRBDs.push(rbdModel);206 }207 });208 return resultRBDs;209 }210 updateSelection(selection: CdTableSelection) {211 this.selection = selection;212 }213 deleteRbd(poolName: string, imageName: string) {214 const finishedTask = new FinishedTask();215 finishedTask.name = 'rbd/delete';216 finishedTask.metadata = {'pool_name': poolName, 'image_name': imageName};217 this.rbdService.delete(poolName, imageName)218 .toPromise().then((resp) => {219 if (resp.status === 202) {220 this.notificationService.show(NotificationType.info,221 `RBD deletion in progress...`,222 this.taskManagerMessageService.getDescription(finishedTask));223 const executingTask = new ExecutingTask();224 executingTask.name = finishedTask.name;225 executingTask.metadata = finishedTask.metadata;226 this.executingTasks.push(executingTask);227 this.taskManagerService.subscribe(executingTask.name, executingTask.metadata,228 (asyncFinishedTask: FinishedTask) => {229 this.notificationService.notifyTask(asyncFinishedTask);230 });231 } else {232 finishedTask.success = true;233 this.notificationService.notifyTask(finishedTask);234 }235 this.modalRef.hide();236 this.loadImages(null);237 }).catch((resp) => {238 this.modalRef.content.stopLoadingSpinner();239 finishedTask.success = false;240 finishedTask.exception = resp.error;241 this.notificationService.notifyTask(finishedTask);242 });243 }244 deleteRbdModal() {245 const poolName = this.selection.first().pool_name;246 const imageName = this.selection.first().name;247 this.modalRef = this.modalService.show(DeletionModalComponent);248 this.modalRef.content.setUp({249 metaType: 'RBD',250 pattern: `${poolName}/${imageName}`,251 deletionMethod: () => this.deleteRbd(poolName, imageName),252 modalRef: this.modalRef253 });254 }255 flattenRbd(poolName, imageName) {256 const finishedTask = new FinishedTask();257 finishedTask.name = 'rbd/flatten';258 finishedTask.metadata = {'pool_name': poolName, 'image_name': imageName};259 this.rbdService.flatten(poolName, imageName)260 .toPromise().then((resp) => {261 if (resp.status === 202) {262 this.notificationService.show(NotificationType.info,263 `RBD flatten in progress...`,264 this.taskManagerMessageService.getDescription(finishedTask));265 const executingTask = new ExecutingTask();266 executingTask.name = finishedTask.name;267 executingTask.metadata = finishedTask.metadata;268 this.executingTasks.push(executingTask);269 this.taskManagerService.subscribe(executingTask.name, executingTask.metadata,270 (asyncFinishedTask: FinishedTask) => {271 this.notificationService.notifyTask(asyncFinishedTask);272 });273 } else {274 finishedTask.success = true;275 this.notificationService.notifyTask(finishedTask);276 }277 this.modalRef.hide();278 this.loadImages(null);279 }).catch((resp) => {280 finishedTask.success = false;281 finishedTask.exception = resp.error;282 this.notificationService.notifyTask(finishedTask);283 });284 }285 flattenRbdModal() {286 const poolName = this.selection.first().pool_name;287 const imageName = this.selection.first().name;288 this.modalRef = this.modalService.show(FlattenConfirmationModalComponent);289 const parent: RbdParentModel = this.selection.first().parent;290 this.modalRef.content.parent = `${parent.pool_name}/${parent.image_name}@${parent.snap_name}`;291 this.modalRef.content.child = `${poolName}/${imageName}`;292 this.modalRef.content.onSubmit.subscribe(() => {293 this.flattenRbd(poolName, imageName);294 });295 }...

Full Screen

Full Screen

ua_machinery_item_state_state_machine.ts

Source:ua_machinery_item_state_state_machine.ts Github

copy

Full Screen

1// ----- this file has been automatically generated - do not edit2import { UAProperty } from "node-opcua-address-space-base"3import { DataType, VariantOptions } from "node-opcua-variant"4import { LocalizedText, QualifiedName } from "node-opcua-data-model"5import { NodeId } from "node-opcua-nodeid"6import { UInt32 } from "node-opcua-basic-types"7import { UAFiniteStateMachine, UAFiniteStateMachine_Base } from "node-opcua-nodeset-ua/source/ua_finite_state_machine"8import { UAState } from "node-opcua-nodeset-ua/source/ua_state"9import { UATransition } from "node-opcua-nodeset-ua/source/ua_transition"10/**11 * State machine representing the state of a12 * machinery item13 *14 * | | |15 * |----------------|--------------------------------------------------|16 * |namespace |http://opcfoundation.org/UA/Machinery/ |17 * |nodeClass |ObjectType |18 * |typedDefinition |8:MachineryItemState_StateMachineType ns=8;i=1002 |19 * |isAbstract |false |20 */21export interface UAMachineryItemState_StateMachine_Base extends UAFiniteStateMachine_Base {22 /**23 * defaultInstanceBrowseName24 * The default BrowseName for instances of the type25 */26 defaultInstanceBrowseName: UAProperty<QualifiedName, DataType.QualifiedName>;27 /**28 * executing29 * The machine is available & functional and is30 * actively performing an activity (pursues a31 * purpose)32 */33 executing: UAState;34 /**35 * fromExecutingToExecuting36 * Transition from state Executing to state Executing37 */38 fromExecutingToExecuting: UATransition;39 /**40 * fromExecutingToNotAvailable41 * Transition from state Executing to state42 * NotAvailable43 */44 fromExecutingToNotAvailable: UATransition;45 /**46 * fromExecutingToNotExecuting47 * Transition from state Executing to state48 * NotExecuting49 */50 fromExecutingToNotExecuting: UATransition;51 /**52 * fromExecutingToOutOfService53 * Transition from state Executing to state54 * OutOfService55 */56 fromExecutingToOutOfService: UATransition;57 /**58 * fromNotAvailableToExecuting59 * Transition from state NotAvailable to state60 * Executing61 */62 fromNotAvailableToExecuting: UATransition;63 /**64 * fromNotAvailableToNotAvailable65 * Transition from state NotAvailable to state66 * NotAvailable67 */68 fromNotAvailableToNotAvailable: UATransition;69 /**70 * fromNotAvailableToNotExecuting71 * Transition from state NotAvailable to state72 * NotExecuting73 */74 fromNotAvailableToNotExecuting: UATransition;75 /**76 * fromNotAvailableToOutOfService77 * Transition from state NotAvailable to state78 * OutOfService79 */80 fromNotAvailableToOutOfService: UATransition;81 /**82 * fromNotExecutingToExecuting83 * Transition from state NotExecuting to state84 * Executing85 */86 fromNotExecutingToExecuting: UATransition;87 /**88 * fromNotExecutingToNotAvailable89 * Transition from state NotExecuting to state90 * NotAvailable91 */92 fromNotExecutingToNotAvailable: UATransition;93 /**94 * fromNotExecutingToNotExecuting95 * Transition from state NotExecuting to state96 * NotExecuting97 */98 fromNotExecutingToNotExecuting: UATransition;99 /**100 * fromNotExecutingToOutOfService101 * Transition from state NotExecuting to state102 * OutOfService103 */104 fromNotExecutingToOutOfService: UATransition;105 /**106 * fromOutOfServiceToExecuting107 * Transition from state OutOfService to state108 * Executing109 */110 fromOutOfServiceToExecuting: UATransition;111 /**112 * fromOutOfServiceToNotAvailable113 * Transition from state OutOfService to state114 * NotAvailable115 */116 fromOutOfServiceToNotAvailable: UATransition;117 /**118 * fromOutOfServiceToNotExecuting119 * Transition from state OutOfService to state120 * NotExecuting121 */122 fromOutOfServiceToNotExecuting: UATransition;123 /**124 * fromOutOfServiceToOutOfService125 * Transition from state OutOfService to state126 * OutOfService127 */128 fromOutOfServiceToOutOfService: UATransition;129 /**130 * notAvailable131 * The machine is not available and does not perform132 * any activity (e.g., switched off, in energy133 * saving mode)134 */135 notAvailable: UAState;136 /**137 * notExecuting138 * The machine is available & functional and does139 * not perform any activity. It waits for an action140 * from outside to start or restart an activity141 */142 notExecuting: UAState;143 /**144 * outOfService145 * The machine is not functional and does not146 * perform any activity (e.g., error, blocked)147 */148 outOfService: UAState;149}150export interface UAMachineryItemState_StateMachine extends UAFiniteStateMachine, UAMachineryItemState_StateMachine_Base {...

Full Screen

Full Screen

dc.progressbar.js

Source:dc.progressbar.js Github

copy

Full Screen

1function showProgressBar() {2 $("#dc-common-progress-bar").show();3}4function hideProgressBar() {5 $("#dc-common-progress-bar").hide();6}7/*8 Use this function for dialog with progress bar9 @dialogElement - (object) dialog object10 @executingFunc - (function) main executing function with progress bar11 @executingSuccessFunc - (function) function delegated in [executingFunc]12 @executingFailFunc - (function) function delegated in [executingFunc]13 @errorMessage - [string] this text used in the error message if [executingFunc] is fail14*/15function dialogStartWaiting(dialogElement, executingFunc, executingSuccessFunc, executingFailFunc, errorMessage) {16 dialogElement.dialog("destroy");17 showProgressBar();18 var executingSuccessFuncProxi = GetExecutingSuccessProxi(executingSuccessFunc);19 var executingFailFuncProxi = GetExecutingFailProxi(executingFailFunc, errorMessage);20 executingFunc(executingSuccessFuncProxi, executingFailFuncProxi);21}22/*23 Use this function for dialog with progress bar24 @dialogElement - (object) dialog object25 @executingFunc - (function) main executing function with progress bar26 @executingSuccessFunc - (function) function delegated in [executingFunc]27 @executingFailFunc - (function) function delegated in [executingFunc]28 @errorMessage - [string] this text used in the error message if [executingFunc] is fail29 @parameter - [object] parameter inexecutingFunc30*/31function dialogStartWaitingWithParameter(dialogElement, executingFunc, executingSuccessFunc, executingFailFunc, errorMessage, parameter) {32 dialogElement.dialog("destroy");33 showProgressBar();34 var executingSuccessFuncProxi = GetExecutingSuccessProxi(executingSuccessFunc);35 var executingFailFuncProxi = GetExecutingFailProxi(executingFailFunc, errorMessage);36 executingFunc(executingSuccessFuncProxi, executingFailFuncProxi, parameter);37}38function GetExecutingSuccessProxi(executingSuccessFunc) {39 if(!executingSuccessFunc) {40 return function(data) { hideProgressBar(); };41 }42 return function(data) {43 hideProgressBar();44 executingSuccessFunc(data);45 };46}47function GetExecutingFailProxi(executingFailFunc, errorMessage) {48 if(!executingFailFunc) {49 return function(data) {50 hideProgressBar();51 showErrorMessage(errorMessage);52 };53 }54 return function(data) {55 hideProgressBar();56 executingFailFunc(data);57 };58}59function showErrorMessage(errorMessage) {60 var content = $("<div> </div>");61 if (!errorMessage) {62 errorMessage = 'Извините, операция завершилась неудачей.';63 }64 content.text(errorMessage);65 displayInformationDialog(content, 'ошибка');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBuy = require('./BestBuy.js');2var bestBuy = new BestBuy();3bestBuy.execute('test4', function (data) {4 console.log(data);5});6var BestBuy = require('./BestBuy.js');7var bestBuy = new BestBuy();8bestBuy.execute('test5', function (data) {9 console.log(data);10});11var BestBuy = require('./BestBuy.js');12var bestBuy = new BestBuy();13bestBuy.execute('test6', function (data) {14 console.log(data);15});16var BestBuy = require('./BestBuy.js');17var bestBuy = new BestBuy();18bestBuy.execute('test7', function (data) {19 console.log(data);20});21var BestBuy = require('./BestBuy.js');22var bestBuy = new BestBuy();23bestBuy.execute('test8', function (data) {24 console.log(data);25});26var BestBuy = require('./BestBuy.js');27var bestBuy = new BestBuy();28bestBuy.execute('test9', function (data) {29 console.log(data);30});31var BestBuy = require('./BestBuy.js');32var bestBuy = new BestBuy();33bestBuy.execute('test10', function (data) {34 console.log(data);35});36var BestBuy = require('./BestBuy.js');37var bestBuy = new BestBuy();38bestBuy.execute('test11', function (data) {39 console.log(data);40});41var BestBuy = require('./BestBuy.js');42var bestBuy = new BestBuy();43bestBuy.execute('test12', function (data) {44 console.log(data);45});46var BestBuy = require('./BestBuy.js');47var bestBuy = new BestBuy();

Full Screen

Using AI Code Generation

copy

Full Screen

1var bestbuy = require('bestbuy')('your api key here');2bestbuy.products('(search=ipad&salePrice<500)', {show: 'sku,name,salePrice'}).exec(function(err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var bestbuy = require('bestbuy')('your api key here');10bestbuy.products('(search=ipad&salePrice<500)', {show: 'sku,name,salePrice', pageSize: 2, page: 1}).exec(function(err, data) {11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var bestbuy = require('bestbuy')('your api key here');18bestbuy.products('(search=ipad&salePrice<500)', {show: 'sku,name,salePrice', pageSize: 2, page: 2}).exec(function(err, data) {19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var bestbuy = require('bestbuy')('your api key here');26bestbuy.products('(search=ipad&salePrice<500)', {show: 'sku,name,salePrice', pageSize: 2, page: 3}).exec(function(err, data) {27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var bestbuy = require('bestbuy')('your api key here');34bestbuy.products('(search=ipad&salePrice<500)', {show: 'sku,name,salePrice', pageSize: 2, page: 4}).exec(function(err, data) {35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var bestbuy = require('bestbuy')('your api key here');42bestbuy.products('(search=

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestMatch = require('./BestMatch.js');2var bm = new BestMatch();3var result = bm.executing("test", ["test", "test1", "test2", "test3"]);4console.log(result);5var BestMatch = function() {6 this.executing = function(str, arr) {7 var result = [];8 var strLength = str.length;9 var strArr = str.split("");10 var arrLength = arr.length;11 var arrArr = [];12 for (var i = 0; i < arrLength; i++) {13 arrArr.push(arr[i].split(""));14 }15 var count = 0;16 var max = 0;17 var index = 0;18 for (var i = 0; i < arrLength; i++) {19 for (var j = 0; j < strLength; j++) {20 if (strArr[j] == arrArr[i][j]) {21 count++;22 }23 }24 if (count > max) {25 max = count;26 index = i;27 }28 count = 0;29 }30 if (max == 0) {31 return result;32 } else {33 result.push(arr[index]);34 for (var i = 0; i < arrLength; i++) {35 if (i != index) {36 for (var j = 0; j < strLength; j++) {37 if (strArr[j] == arrArr[i][j]) {38 count++;39 }40 }41 if (count == max) {42 result.push(arr[i]);43 }44 count = 0;45 }46 }47 return result;48 }49 }50};51module.exports = BestMatch;

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