Best JavaScript code snippet using argos
job.entity.ts
Source:job.entity.ts
1import { Entity } from '../../shared/entities/entity';2import { DocumentRef } from '../../shared/entities/document-ref.entity';3import DateTimeFormat = Intl.DateTimeFormat;4import { UserRef } from '../../auth/user.models';5import { DateTimeUtils } from '../../shared/utils/datetime-utils';6import * as moment from 'moment';7export class Job extends Entity {8 server: DocumentRef;9 game: DocumentRef;10 jobArgs: string;11 status: JobStatus;12 created: DateTimeFormat;13 minStartDate: DateTimeFormat;14 jobHandler: DocumentRef;15 handlerType: JobHandlerType;16 comments: string[];17 assignee: UserRef;18 jobType: JobType;19 statusUpdates: { newStatus: string, updated: Date }[];20 public static createJobFromScratch(type, serverId, gameId, gameIid) {21 return {22 server: <DocumentRef>{ id: serverId, iid: 0 },23 game: <DocumentRef>{ id: gameId, iid: gameIid },24 jobArgs: '',25 status: JobStatus.New,26 created: moment.utc().format(),27 minStartDate: moment.utc().format(),28 jobHandler: null,29 handlerType: JobHandlerType.Unknown,30 comments: [''],31 assignee: <UserRef>{},32 jobType: type33 };34 }35 public static getJobNameByType(jobType: any) {36 if (JobType.Unknown === jobType) {37 return JobType[JobType.Unknown];38 }39 if (JobType.RosterUpdate === jobType) {40 return JobType[JobType.RosterUpdate];41 }42 if (JobType.MoveHyperAsset === jobType) {43 return JobType[JobType.MoveHyperAsset];44 }45 if (JobType.CreateMission === jobType) {46 return JobType[JobType.CreateMission];47 }48 if (JobType.ActivateMission === jobType) {49 return JobType[JobType.ActivateMission];50 }51 if (JobType.Phase1Logging === jobType) {52 return JobType[JobType.Phase1Logging];53 }54 if (JobType.Phase2Logging === jobType) {55 return JobType[JobType.Phase2Logging];56 }57 if (JobType.Phase3Logging === jobType) {58 return JobType[JobType.Phase3Logging];59 }60 if (JobType.ExportEvents === jobType) {61 return JobType[JobType.ExportEvents];62 }63 if (JobType.IngestEvents === jobType) {64 return JobType[JobType.IngestEvents];65 }66 if (JobType.SendToQA === jobType) {67 return JobType[JobType.SendToQA];68 }69 if (JobType.Encoding === jobType) {70 return JobType[JobType.Encoding];71 }72 return JobType[JobType.Unknown];73 }74 public static getJobStatusNameByStatus(status, jobType = undefined) {75 if (JobStatus.Unknown === status) {76 return JobStatus[JobStatus.Unknown];77 }78 if (JobStatus.New === status) {79 return JobStatus[JobStatus.New];80 }81 if (JobStatus.Claimed === status) {82 return JobStatus[JobStatus.Claimed];83 }84 if (JobStatus.Running === status && Job.isLoggingPhase(jobType)) {85 return 'In Progress';86 } else if (JobStatus.Running === status) {87 return JobStatus[JobStatus.Running];88 }89 if (JobStatus.RetryPending === status) {90 return JobStatus[JobStatus.RetryPending];91 }92 if (JobStatus.Cancelled === status) {93 return JobStatus[JobStatus.Cancelled];94 }95 if (JobStatus.Failed === status) {96 return JobStatus[JobStatus.Failed];97 }98 if (JobStatus.Completed === status) {99 return JobStatus[JobStatus.Completed];100 }101 if (JobStatus.Ready === status) {102 return JobStatus[JobStatus.Ready];103 }104 return JobStatus[JobStatus.Unknown];105 }106 public static getCorrectAssigneeName(assignee) {107 if (!assignee) {108 return 'Unassigned';109 }110 let name = '';111 if (assignee.first) {112 name += assignee.first + ' ';113 }114 if (assignee.last) {115 name += assignee.last;116 }117 if (name === '' && assignee.username && assignee.username !== '') {118 name = assignee.username;119 }120 return name !== '' ? name : 'Unassigned';121 }122 static isLoggingPhase(jobType) {123 return jobType === 5 || jobType === 6 || jobType === 7;124 }125}126export enum JobStatus {127 Unknown = 0,128 New,129 Claimed,130 Running,131 RetryPending,132 Cancelled,133 Failed,134 Completed,135 Ready136}137export enum JobHandlerType {138 Unknown = 0,139 DvdEncoding,140 TvEncoding141}142export enum JobType {143 Unknown = 0,144 RosterUpdate,145 MoveHyperAsset,146 CreateMission,147 ActivateMission,148 Phase1Logging,149 Phase2Logging,150 Phase3Logging,151 ExportEvents,152 IngestEvents,153 SendToQA,154 Encoding...
job-status.js
Source:job-status.js
1/*2 * Licensed under the Apache License, Version 2.0 (the "License");3 * you may not use this file except in compliance with the License.4 * You may obtain a copy of the License at5 *6 * http://www.apache.org/licenses/LICENSE-2.07 *8 * Unless required by applicable law or agreed to in writing, software9 * distributed under the License is distributed on an "AS IS" BASIS,10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11 * See the License for the specific language governing permissions and12 * limitations under the License.13 */14export const JobStatus = {15 READY: 'READY',16 FINISHED: 'FINISHED',17 ABORT: 'ABORT',18 ERROR: 'ERROR',19 PENDING: 'PENDING',20 RUNNING: 'RUNNING',21}22export function getJobIconByStatus(jobStatus) {23 if (jobStatus === JobStatus.READY) {24 return 'fa fa-circle-o'25 } else if (jobStatus === JobStatus.FINISHED) {26 return 'fa fa-circle'27 } else if (jobStatus === JobStatus.ABORT) {28 return 'fa fa-circle'29 } else if (jobStatus === JobStatus.ERROR) {30 return 'fa fa-circle'31 } else if (jobStatus === JobStatus.PENDING) {32 return 'fa fa-circle'33 } else if (jobStatus === JobStatus.RUNNING) {34 return 'fa fa-spinner'35 }36}37export function getJobColorByStatus(jobStatus) {38 if (jobStatus === JobStatus.READY) {39 return 'green'40 } else if (jobStatus === JobStatus.FINISHED) {41 return 'green'42 } else if (jobStatus === JobStatus.ABORT) {43 return 'orange'44 } else if (jobStatus === JobStatus.ERROR) {45 return 'red'46 } else if (jobStatus === JobStatus.PENDING) {47 return 'gray'48 } else if (jobStatus === JobStatus.RUNNING) {49 return 'blue'50 }...
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!!