Standard Format Code Changes
This commit is contained in:
1 parent
4ce8cde5b0
commit
37028e34ad
33 files changed
+175
-232
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import gql from 'graphql-tag';
|
||||
import { clone } from '../Fragments';
|
||||
import gql from 'graphql-tag'
|
||||
import { clone } from '../Fragments'
|
||||
|
||||
const OPERATIONS_ADD_CLONE = gql`
|
||||
mutation Operations_AddClone($clone: operations_CloneInput!) {
|
||||
@@ -8,7 +8,7 @@ const OPERATIONS_ADD_CLONE = gql`
|
||||
}
|
||||
}
|
||||
${clone}
|
||||
`;
|
||||
`
|
||||
|
||||
const OPERATIONS_LIST_CLONES = gql`
|
||||
query Operations_Clones{
|
||||
@@ -17,7 +17,7 @@ const OPERATIONS_LIST_CLONES = gql`
|
||||
}
|
||||
}
|
||||
${clone}
|
||||
`;
|
||||
`
|
||||
|
||||
const OPERATIONS_HISTORY_CLONES = gql`
|
||||
query Operations_HistoryClones{
|
||||
@@ -26,17 +26,17 @@ const OPERATIONS_HISTORY_CLONES = gql`
|
||||
}
|
||||
}
|
||||
${clone}
|
||||
`;
|
||||
`
|
||||
|
||||
const OPERATIONS_REMOVE_CLONE = gql`
|
||||
mutation Operations_RemoveClone($id: ID!){
|
||||
operations_RemoveClone( id: $id)
|
||||
}
|
||||
`;
|
||||
`
|
||||
|
||||
export default {
|
||||
OPERATIONS_LIST_CLONES,
|
||||
OPERATIONS_HISTORY_CLONES,
|
||||
OPERATIONS_ADD_CLONE,
|
||||
OPERATIONS_REMOVE_CLONE
|
||||
};
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import clones from './clones';
|
||||
import teams from './teams';
|
||||
import keys from './keys';
|
||||
import clones from './clones'
|
||||
import teams from './teams'
|
||||
import keys from './keys'
|
||||
|
||||
export {
|
||||
clones,
|
||||
teams,
|
||||
keys
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import gql from 'graphql-tag';
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const GET_ALL_KEYS = gql`
|
||||
query {
|
||||
@@ -12,4 +12,4 @@ export const GET_ALL_KEYS = gql`
|
||||
|
||||
export default {
|
||||
GET_ALL_KEYS
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import gql from 'graphql-tag';
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const GET_ALL_TEAMS_QUERY = gql`
|
||||
query {
|
||||
@@ -18,4 +18,4 @@ export const GET_ALL_TEAMS_QUERY = gql`
|
||||
|
||||
export default {
|
||||
GET_ALL_TEAMS_QUERY
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import gql from 'graphql-tag';
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const clone = gql`
|
||||
fragment clone on operations_Clone {
|
||||
@@ -32,4 +32,4 @@ export const clone = gql`
|
||||
processName
|
||||
keyId
|
||||
}
|
||||
`;
|
||||
`
|
||||
@@ -1,6 +1,5 @@
|
||||
import { clone } from './clone'
|
||||
|
||||
|
||||
export {
|
||||
clone
|
||||
};
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
const availableMonths = ["January", "February", "March", "April", "May", "June",
|
||||
"July", "August", "September", "October", "November", "December"]
|
||||
const availableMonths = ['January', 'February', 'March', 'April', 'May', 'June',
|
||||
'July', 'August', 'September', 'October', 'November', 'December']
|
||||
|
||||
const tradingStartModes ={
|
||||
live: "Live",
|
||||
backtest: "Backtest"
|
||||
const tradingStartModes = {
|
||||
live: 'Live',
|
||||
backtest: 'Backtest'
|
||||
}
|
||||
|
||||
const indicatorStartModes = {
|
||||
allMonths: "All Months",
|
||||
oneMonth: "One Month",
|
||||
noTime: "No Time"
|
||||
allMonths: 'All Months',
|
||||
oneMonth: 'One Month',
|
||||
noTime: 'No Time'
|
||||
}
|
||||
|
||||
const exchanges = [
|
||||
@@ -19,6 +19,4 @@ const exchanges = [
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
|
||||
export { tradingStartModes, exchanges, indicatorStartModes, availableMonths }
|
||||
@@ -10,13 +10,13 @@ export function toLocalTime (epoch) {
|
||||
}
|
||||
|
||||
export function toUTCTimestamp (localDate) {
|
||||
if(isDefined(localDate)){
|
||||
if (isDefined(localDate)) {
|
||||
const date = new Date(localDate.valueOf())
|
||||
const utcDate = Date.UTC(date.getUTCFullYear(), date.getUTCMonth(),
|
||||
date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(),
|
||||
date.getUTCSeconds())
|
||||
|
||||
return utcDate.valueOf() / 1000|0
|
||||
return utcDate.valueOf() / 1000 | 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ export function getIndicatorYears () {
|
||||
const localDate = new Date()
|
||||
let availableYears = []
|
||||
for (var i = 2015; i <= localDate.getUTCFullYear(); i++) {
|
||||
availableYears[i-2015] = i
|
||||
availableYears[i - 2015] = i
|
||||
}
|
||||
return availableYears
|
||||
}
|
||||
@@ -14,10 +14,7 @@ import {
|
||||
Select, FormControlLabel, Checkbox, FormHelperText
|
||||
} from '@material-ui/core'
|
||||
import { DateTimePicker } from 'material-ui-pickers'
|
||||
import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
} from '@material-ui/icons'
|
||||
import { ChevronLeft, ChevronRight } from '@material-ui/icons'
|
||||
|
||||
class AddClone extends Component {
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ const styles = theme => ({
|
||||
},
|
||||
textField: {
|
||||
width: '80%',
|
||||
marginLeft:'10%',
|
||||
marginLeft: '10%',
|
||||
marginBottom: 10
|
||||
},
|
||||
actionButton: {
|
||||
@@ -30,8 +30,8 @@ const styles = theme => ({
|
||||
marginTop: 20
|
||||
},
|
||||
selectEmpty: {
|
||||
marginTop: theme.spacing.unit * 2,
|
||||
},
|
||||
});
|
||||
marginTop: theme.spacing.unit * 2
|
||||
}
|
||||
})
|
||||
|
||||
export default styles;
|
||||
export default styles
|
||||
@@ -40,7 +40,7 @@ class HistoryClones extends Component {
|
||||
{
|
||||
data.operations_HistoryClones.map((clone, i) => {
|
||||
return (
|
||||
<ListClones key={clone.id} currentClone={clone} isHistory={true}/>
|
||||
<ListClones key={clone.id} currentClone={clone} isHistory />
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -17,26 +17,26 @@ const styles = theme => ({
|
||||
},
|
||||
buttonList: {
|
||||
margin: theme.spacing.unit,
|
||||
float: 'right',
|
||||
float: 'right'
|
||||
},
|
||||
buttonGrid: {
|
||||
marginTop: -20,
|
||||
marginTop: -20
|
||||
},
|
||||
button: {
|
||||
display: 'block',
|
||||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
marginRight: 'auto'
|
||||
},
|
||||
textField: {
|
||||
marginLeft: theme.spacing.unit,
|
||||
marginRight: theme.spacing.unit,
|
||||
marginRight: theme.spacing.unit
|
||||
},
|
||||
textArea: {
|
||||
margin: theme.spacing.unit,
|
||||
whiteSpace: 'pre',
|
||||
width:'98%',
|
||||
overflowY:'hidden',
|
||||
overflowX:'hidden'
|
||||
width: '98%',
|
||||
overflowY: 'hidden',
|
||||
overflowX: 'hidden'
|
||||
},
|
||||
heading: {
|
||||
fontSize: theme.typography.pxToRem(18),
|
||||
@@ -49,15 +49,15 @@ const styles = theme => ({
|
||||
},
|
||||
helper: {
|
||||
borderLeft: `2px solid ${theme.palette.divider}`,
|
||||
padding: `0px ${theme.spacing.unit * 2}px`,
|
||||
padding: `0px ${theme.spacing.unit * 2}px`
|
||||
},
|
||||
logsWrapper:{
|
||||
width:'1750px',
|
||||
overflowY:'auto',
|
||||
overflowX:'hidden'
|
||||
logsWrapper: {
|
||||
width: '1750px',
|
||||
overflowY: 'auto',
|
||||
overflowX: 'hidden'
|
||||
},
|
||||
details:{
|
||||
display:'flex'
|
||||
details: {
|
||||
display: 'flex'
|
||||
},
|
||||
column2: {
|
||||
flexBasis: '50%',
|
||||
@@ -67,23 +67,23 @@ const styles = theme => ({
|
||||
flexBasis: '33.33%',
|
||||
maxWidth: '33.33%'
|
||||
},
|
||||
cloneInfoTitle:{
|
||||
cloneInfoTitle: {
|
||||
fontWeight: '600',
|
||||
flexBasis: '100%',
|
||||
maxWidth: '100%'
|
||||
},
|
||||
cloneInfoBold:{
|
||||
cloneInfoBold: {
|
||||
fontWeight: '600',
|
||||
paddingLeft: '10px',
|
||||
paddingTop: '10px'
|
||||
},
|
||||
cloneInfoNormal:{
|
||||
cloneInfoNormal: {
|
||||
paddingLeft: '10px',
|
||||
paddingTop: '10px'
|
||||
},
|
||||
avatar: {
|
||||
margin: 10,
|
||||
},
|
||||
margin: 10
|
||||
}
|
||||
})
|
||||
|
||||
export default styles
|
||||
@@ -6,7 +6,6 @@ export const ONE_MONTH = 'oneMonth'
|
||||
export const NO_TIME = 'noTime'
|
||||
export const FIXED_INTERVAL = 'fixedInterval'
|
||||
|
||||
|
||||
export const CloneModeEnum = [
|
||||
LIVE,
|
||||
BACKTEST,
|
||||
|
||||
@@ -34,13 +34,13 @@ const teamQuery = (authorization, teamId) => {
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
teamId: teamId
|
||||
}
|
||||
teamId: teamId
|
||||
}
|
||||
},
|
||||
headers: {
|
||||
authorization: authorization
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
export default teamQuery
|
||||
+4
-4
@@ -5,17 +5,17 @@ import schema from './schema'
|
||||
import mongoose from 'mongoose'
|
||||
import cors from 'cors'
|
||||
import logger from './config/logger'
|
||||
import wrongPreshared from './errors/notAllowed.json';
|
||||
import wrongPreshared from './errors/notAllowed.json'
|
||||
|
||||
const app = express()
|
||||
|
||||
app.post('/graphql', (req, res, next) => {
|
||||
if (req.headers.preshared === process.env.OPERATIONS_API_PRESHARED) {
|
||||
next();
|
||||
next()
|
||||
} else {
|
||||
res.send(wrongPreshared);
|
||||
res.send(wrongPreshared)
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
// Allow cross origing request
|
||||
app.use(cors())
|
||||
|
||||
@@ -10,8 +10,6 @@ const createClone = async (clone) => {
|
||||
try {
|
||||
logger.debug('createClone %s', clone.id)
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
|
||||
// Make changes to base deployment config
|
||||
deploymentManifest.metadata.name = clone.id
|
||||
|
||||
logger.debug('createClone Environment and Auth Configuration.')
|
||||
|
||||
@@ -4,31 +4,31 @@ import { Client, config } from 'kubernetes-client'
|
||||
|
||||
const getClonePodLogs = async (cloneName) => {
|
||||
try {
|
||||
logger.debug("getClonePodLogs on kubernates started.")
|
||||
logger.debug('getClonePodLogs on kubernates started.')
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
|
||||
let query = {
|
||||
"qs":{
|
||||
"labelSelector": "job-name="+cloneName
|
||||
'qs': {
|
||||
'labelSelector': 'job-name=' + cloneName
|
||||
}
|
||||
}
|
||||
|
||||
const pod = await client.api.v1.namespaces('default').pods.get(query)
|
||||
|
||||
let queryLogs = {
|
||||
"qs":{
|
||||
"tailLines": "20"
|
||||
'qs': {
|
||||
'tailLines': '20'
|
||||
}
|
||||
}
|
||||
const logs = await client.api.v1.namespaces('default')
|
||||
.pods(pod.body.items[0].metadata.name).log.get(queryLogs)
|
||||
let logsArray = logs.body.split('\n')
|
||||
|
||||
logger.debug("getClonePodLogs on kubernates successful.")
|
||||
logger.debug('getClonePodLogs on kubernates successful.')
|
||||
|
||||
return JSON.stringify(logsArray, null, 2)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
}
|
||||
export default getClonePodLogs
|
||||
@@ -4,12 +4,12 @@ import { Client, config } from 'kubernetes-client'
|
||||
|
||||
const getClonePodStatus = async (cloneName) => {
|
||||
try {
|
||||
logger.debug("getClonePodStatus on kubernates started. ")
|
||||
logger.debug('getClonePodStatus on kubernates started. ')
|
||||
const client = new Client({config: config.fromKubeconfig(), version: '1.9'})
|
||||
|
||||
let query = {
|
||||
"qs":{
|
||||
"labelSelector": "job-name="+cloneName
|
||||
'qs': {
|
||||
'labelSelector': 'job-name=' + cloneName
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@ const getClonePodStatus = async (cloneName) => {
|
||||
&& clonePodStatus.terminated.hasOwnProperty('containerID')) {
|
||||
delete clonePodStatus.terminated.containerID
|
||||
}
|
||||
logger.debug("getClonePodStatus %s on kubernates successful", cloneName)
|
||||
logger.debug('getClonePodStatus %s on kubernates successful', cloneName)
|
||||
return JSON.stringify(clonePodStatus, null, 2)
|
||||
} catch (err) {
|
||||
throw new KubernateError(err)
|
||||
throw new KubernateError(err)
|
||||
}
|
||||
}
|
||||
export default getClonePodStatus
|
||||
+12
-12
@@ -2,32 +2,32 @@ import mongoose, { Schema } from 'mongoose'
|
||||
|
||||
import {
|
||||
UNPUBLISHED,
|
||||
CloneStateEnum,
|
||||
} from '../enums/CloneState';
|
||||
CloneStateEnum
|
||||
} from '../enums/CloneState'
|
||||
|
||||
import {
|
||||
BACKTEST,
|
||||
CloneModeEnum,
|
||||
} from '../enums/CloneMode';
|
||||
CloneModeEnum
|
||||
} from '../enums/CloneMode'
|
||||
|
||||
const cloneSchema = new Schema({
|
||||
authId: {
|
||||
type: String,
|
||||
required: true,
|
||||
required: true
|
||||
},
|
||||
teamId: {
|
||||
type: String,
|
||||
required: true,
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
botId: {
|
||||
type: String,
|
||||
required: true,
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
keyId: String,
|
||||
mode: {
|
||||
type: String,
|
||||
enum: CloneModeEnum,
|
||||
default: BACKTEST,
|
||||
default: BACKTEST
|
||||
},
|
||||
resumeExecution: Boolean,
|
||||
beginDatetime: Number,
|
||||
@@ -36,7 +36,7 @@ const cloneSchema = new Schema({
|
||||
state: {
|
||||
type: String,
|
||||
enum: CloneStateEnum,
|
||||
default: UNPUBLISHED,
|
||||
default: UNPUBLISHED
|
||||
},
|
||||
stateDatetime: Number,
|
||||
createDatetime: Number,
|
||||
@@ -52,7 +52,7 @@ const cloneSchema = new Schema({
|
||||
assetB: String,
|
||||
processName: {
|
||||
type: String,
|
||||
required: true,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ import { AutorizationError } from '../errors'
|
||||
const cloneDetails = (authId, team, clone) => {
|
||||
logger.debug('cloneDetails -> Entering function.')
|
||||
|
||||
if(!(authId === (process.env.AUTH_CLIENT_ID + '@clients') || isAuthorized(team, authId))){
|
||||
logger.debug('User %s is not authorized to manage team %s.', authId, team.slug )
|
||||
if (!(authId === (process.env.AUTH_CLIENT_ID + '@clients') || isAuthorized(team, authId))) {
|
||||
logger.debug('User %s is not authorized to manage team %s.', authId, team.slug)
|
||||
throw new AutorizationError()
|
||||
}
|
||||
|
||||
@@ -20,29 +20,29 @@ const cloneDetails = (authId, team, clone) => {
|
||||
clone.botName = selectedBot.name
|
||||
clone.botAvatar = selectedBot.avatar
|
||||
clone.teamAvatar = team.profile.avatar
|
||||
clone.userLoggedIn = team.members[0].member.alias //TODO change by context info if possible
|
||||
clone.userLoggedIn = team.members[0].member.alias // TODO change by context info if possible
|
||||
|
||||
logger.debug('cloneDetails -> Retrieving clone details complete.')
|
||||
return clone
|
||||
};
|
||||
}
|
||||
|
||||
function getSelectedBot(team, selectedBotId){
|
||||
function getSelectedBot (team, selectedBotId) {
|
||||
logger.debug('cloneDetails -> Getting selected bot.')
|
||||
if(isDefined(team)){
|
||||
if (isDefined(team)) {
|
||||
for (var i = 0; i < team.fb.length; i++) {
|
||||
if(team.fb[i].id === selectedBotId){
|
||||
if (team.fb[i].id === selectedBotId) {
|
||||
return team.fb[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isAuthorized(team, authId){
|
||||
function isAuthorized (team, authId) {
|
||||
logger.debug('cloneDetails -> Checking if the user is authorized by the teams module.')
|
||||
let authorized = false
|
||||
if(isDefined(team)){
|
||||
if (isDefined(team)) {
|
||||
for (var i = 0; i < team.members.length; i++) {
|
||||
if(team.members[i].member.authId === authId){
|
||||
if (team.members[i].member.authId === authId) {
|
||||
authorized = true
|
||||
break
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
GraphQLSchema
|
||||
} from 'graphql'
|
||||
|
||||
import { GraphQLSchema } from 'graphql'
|
||||
import Mutation from './mutations'
|
||||
import RootQuery from './queries'
|
||||
|
||||
|
||||
@@ -6,14 +6,12 @@ import { BotTypesEnum } from '../../enums/BotTypes'
|
||||
import teamQuery from '../../graphQLCalls/teamQuery'
|
||||
import authorizeClone from '../../graphQLCalls/authorizeClone'
|
||||
import cloneDetails from '../cloneDetails'
|
||||
|
||||
import {
|
||||
AuthentificationError,
|
||||
WrongArgumentsError,
|
||||
OperationsError,
|
||||
AutorizationError
|
||||
} from '../../errors'
|
||||
|
||||
import logger from '../../config/logger'
|
||||
import createKubernetesClone from '../../kubernetes/createClone'
|
||||
import { isDefined } from '../../config/utils'
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
import {
|
||||
GraphQLNonNull,
|
||||
GraphQLID,
|
||||
GraphQLString
|
||||
} from 'graphql'
|
||||
|
||||
import {
|
||||
AuthentificationError,
|
||||
OperationsError
|
||||
} from '../../errors'
|
||||
|
||||
import { GraphQLNonNull, GraphQLID, GraphQLString } from 'graphql'
|
||||
import { AuthentificationError, OperationsError } from '../../errors'
|
||||
import { Clone } from '../../models'
|
||||
import logger from '../../config/logger'
|
||||
import removeKuberneteClone from '../../kubernetes/removeClone'
|
||||
@@ -33,7 +24,7 @@ const resolve = async (parent, { id }, context) => {
|
||||
active: true
|
||||
})
|
||||
|
||||
if(!isDefined(clone)){
|
||||
if (!isDefined(clone)) {
|
||||
throw new OperationsError('You are not authorized to remove this clone.')
|
||||
}
|
||||
|
||||
@@ -54,12 +45,12 @@ const resolve = async (parent, { id }, context) => {
|
||||
const update = { active: false }
|
||||
|
||||
Clone.findOneAndUpdate(query, update, options, (err, doc) => {
|
||||
if (err){
|
||||
if (err) {
|
||||
logger.error('removeClone -> Error removing clone from the DB. %s', err.stack)
|
||||
throw new OperationsError(err)
|
||||
}else{
|
||||
} else {
|
||||
logger.debug('removeClone -> Clone Removed from the DB.')
|
||||
return('Clone Removed.')
|
||||
return ('Clone Removed.')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import {
|
||||
GraphQLInt,
|
||||
GraphQLFloat
|
||||
} from 'graphql'
|
||||
import {
|
||||
OperationsError
|
||||
} from '../../errors'
|
||||
import { OperationsError } from '../../errors'
|
||||
import { Clone } from '../../models'
|
||||
import logger from '../../config/logger'
|
||||
import teamQuery from '../../graphQLCalls/teamQuery'
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
GraphQLObjectType
|
||||
} from 'graphql'
|
||||
|
||||
import { GraphQLObjectType } from 'graphql'
|
||||
import AddCloneMutation from './AddCloneMutation'
|
||||
import RemoveCloneMutation from './RemoveCloneMutation'
|
||||
import UpdateExecutionSummary from './UpdateExecutionSummary'
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import {
|
||||
GraphQLList,
|
||||
GraphQLID
|
||||
} from 'graphql'
|
||||
|
||||
import {
|
||||
OperationsError
|
||||
} from '../../errors'
|
||||
|
||||
import { GraphQLList, GraphQLID } from 'graphql'
|
||||
import { OperationsError } from '../../errors'
|
||||
import { GetClonesType } from '../types'
|
||||
import { Clone } from '../../models'
|
||||
import logger from '../../config/logger'
|
||||
@@ -19,38 +12,37 @@ const args = {
|
||||
|
||||
const resolve = async(parent, { cloneIdList }, context) => {
|
||||
logger.debug('Get Clones -> Entering Fuction.')
|
||||
try{
|
||||
let clones = []
|
||||
for (var i = 0; i < cloneIdList.length; i++) {
|
||||
try {
|
||||
let clones = []
|
||||
for (var i = 0; i < cloneIdList.length; i++) {
|
||||
if (mongoose.Types.ObjectId.isValid(cloneIdList[i])) {
|
||||
let existingClone = await Clone.findOne({
|
||||
_id: cloneIdList[i]
|
||||
})
|
||||
|
||||
if(mongoose.Types.ObjectId.isValid(cloneIdList[i])){
|
||||
let existingClone = await Clone.findOne({
|
||||
_id: cloneIdList[i]
|
||||
})
|
||||
if (isDefined(existingClone)) {
|
||||
clones.push({
|
||||
id: cloneIdList[i],
|
||||
teamId: existingClone.teamId,
|
||||
botId: existingClone.botId
|
||||
})
|
||||
} else {
|
||||
clones.push({
|
||||
id: cloneIdList[i]
|
||||
})
|
||||
}
|
||||
} else {
|
||||
clones.push({
|
||||
id: cloneIdList[i]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if(isDefined(existingClone)){
|
||||
clones.push({
|
||||
id: cloneIdList[i],
|
||||
teamId: existingClone.teamId,
|
||||
botId: existingClone.botId
|
||||
})
|
||||
}else{
|
||||
clones.push({
|
||||
id: cloneIdList[i]
|
||||
})
|
||||
}
|
||||
} else {
|
||||
clones.push({
|
||||
id: cloneIdList[i]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return clones
|
||||
} catch (err){
|
||||
return clones
|
||||
} catch (err) {
|
||||
logger.error('Get Clones error: %s', err.stack)
|
||||
throw new OperationsError('There has been an error getting the clones.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const GetClones = {
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import {
|
||||
GraphQLList
|
||||
} from 'graphql'
|
||||
|
||||
import {
|
||||
AuthentificationError,
|
||||
OperationsError
|
||||
} from '../../errors'
|
||||
|
||||
import { GraphQLList } from 'graphql'
|
||||
import { AuthentificationError, OperationsError } from '../../errors'
|
||||
import { CloneType } from '../types'
|
||||
import { Clone } from '../../models'
|
||||
import logger from '../../config/logger'
|
||||
@@ -17,27 +10,27 @@ const args = {}
|
||||
|
||||
const resolve = async(parent, args, context) => {
|
||||
logger.debug('Retrieving History Clones.')
|
||||
try{
|
||||
if (!context.userId) {
|
||||
throw new AuthentificationError()
|
||||
}
|
||||
try {
|
||||
if (!context.userId) {
|
||||
throw new AuthentificationError()
|
||||
}
|
||||
|
||||
let clones = await Clone.find({
|
||||
authId: context.userId,
|
||||
active: false
|
||||
}).sort({createDatetime: -1})
|
||||
let clones = await Clone.find({
|
||||
authId: context.userId,
|
||||
active: false
|
||||
}).sort({createDatetime: -1})
|
||||
|
||||
for (var i = 0; i < clones.length; i++) {
|
||||
for (var i = 0; i < clones.length; i++) {
|
||||
let team = await teamQuery(context.authorization, clones[i].teamId)
|
||||
clones[i] = await cloneDetails(context.userId, team.data.data.teams_TeamById, clones[i])
|
||||
clones[i].botType = clones[i].kind // Only for listing we show the teams value
|
||||
}
|
||||
}
|
||||
|
||||
return clones
|
||||
} catch (err){
|
||||
logger.error('Retrieving History Clones error: %s', err.stack)
|
||||
throw new OperationsError('There has been an error retrieving history clones.')
|
||||
}
|
||||
return clones
|
||||
} catch (err) {
|
||||
logger.error('Retrieving History Clones error: %s', err.stack)
|
||||
throw new OperationsError('There has been an error retrieving history clones.')
|
||||
}
|
||||
}
|
||||
|
||||
const HistoryClones = {
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
import {
|
||||
GraphQLList
|
||||
} from 'graphql'
|
||||
|
||||
import {
|
||||
AuthentificationError,
|
||||
OperationsError
|
||||
} from '../../errors'
|
||||
|
||||
import { GraphQLList } from 'graphql'
|
||||
import { AuthentificationError, OperationsError } from '../../errors'
|
||||
import { CloneType } from '../types'
|
||||
import { Clone } from '../../models'
|
||||
import logger from '../../config/logger'
|
||||
@@ -19,30 +12,30 @@ const args = {}
|
||||
|
||||
const resolve = async(parent, args, context) => {
|
||||
logger.debug('List Clones -> Entering Fuction.')
|
||||
try{
|
||||
if (!context.userId) {
|
||||
throw new AuthentificationError()
|
||||
}
|
||||
try {
|
||||
if (!context.userId) {
|
||||
throw new AuthentificationError()
|
||||
}
|
||||
|
||||
let clones = await Clone.find({
|
||||
authId: context.userId,
|
||||
active: true
|
||||
}).sort({createDatetime: -1})
|
||||
let clones = await Clone.find({
|
||||
authId: context.userId,
|
||||
active: true
|
||||
}).sort({createDatetime: -1})
|
||||
|
||||
for (var i = 0; i < clones.length; i++) {
|
||||
for (var i = 0; i < clones.length; i++) {
|
||||
let team = await teamQuery(context.authorization, clones[i].teamId)
|
||||
clones[i] = await cloneDetails(context.userId, team.data.data.teams_TeamById, clones[i])
|
||||
let state = await getCloneStatus(clones[i].id)
|
||||
clones[i].state = state.substring(1, state.length-1)
|
||||
clones[i].state = state.substring(1, state.length - 1)
|
||||
let lastLogs = await getCloneLogs(clones[i].id)
|
||||
clones[i].lastLogs = lastLogs.substring(1, lastLogs.length-1)
|
||||
clones[i].lastLogs = lastLogs.substring(1, lastLogs.length - 1)
|
||||
clones[i].botType = clones[i].kind // Only for listing we show the teams value
|
||||
}
|
||||
return clones
|
||||
} catch (err){
|
||||
}
|
||||
return clones
|
||||
} catch (err) {
|
||||
logger.error('List Clones error: %s', err.stack)
|
||||
throw new OperationsError('There has been an error listing the clones.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ListClones = {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
GraphQLObjectType
|
||||
} from 'graphql'
|
||||
|
||||
import { GraphQLObjectType } from 'graphql'
|
||||
import ListClones from './ListClones'
|
||||
import HistoryClones from './HistoryClones'
|
||||
import GetClones from './GetClones'
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
GraphQLObjectType,
|
||||
GraphQLID
|
||||
} from 'graphql'
|
||||
import { GraphQLObjectType, GraphQLID } from 'graphql'
|
||||
|
||||
const GetClonesType = new GraphQLObjectType({
|
||||
name: 'GetClones',
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
GraphQLInputObjectType,
|
||||
GraphQLBoolean,
|
||||
GraphQLNonNull
|
||||
} from 'graphql';
|
||||
} from 'graphql'
|
||||
|
||||
const Type = new GraphQLInputObjectType({
|
||||
name: 'CloneInput',
|
||||
@@ -25,7 +25,7 @@ const Type = new GraphQLInputObjectType({
|
||||
processName: { type: new GraphQLNonNull(GraphQLString) },
|
||||
botType: { type: new GraphQLNonNull(GraphQLString) },
|
||||
keyId: { type: GraphQLString }
|
||||
})
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
export default Type;
|
||||
export default Type
|
||||
@@ -2,4 +2,4 @@ import CloneInputType from './Clone'
|
||||
|
||||
export {
|
||||
CloneInputType
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user