diff --git a/.vscode/launch.json b/.vscode/launch.json index d296a5b..204beb2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -100,45 +100,45 @@ // ------------------------------------ // Import tasks from CSV file // ------------------------------------ - "args": [ - "task-import", - "--auth-type", - "cert", - "--host", - // "192.168.100.109", - "10.211.55.15", + // "args": [ + // "task-import", + // "--auth-type", + // "cert", + // "--host", + // // "192.168.100.109", + // "10.211.55.15", - "--auth-cert-file", - "../../code/secret/winsrv.local/client.pem", - "--auth-cert-key-file", - "../../code/secret/winsrv.local/client_key.pem", - // "--auth-cert-file", - // "./cert/client.pem", - // "--auth-cert-key-file", - // "./cert/client_key.pem", - "--auth-user-dir", - "winsrv1", - // "LAB", - "--auth-user-id", - "goran", + // "--auth-cert-file", + // "../../code/secret/winsrv.local/client.pem", + // "--auth-cert-key-file", + // "../../code/secret/winsrv.local/client_key.pem", + // // "--auth-cert-file", + // // "./cert/client.pem", + // // "--auth-cert-key-file", + // // "./cert/client_key.pem", + // "--auth-user-dir", + // "winsrv1", + // // "LAB", + // "--auth-user-id", + // "goran", - "--file-type", - "csv", + // "--file-type", + // "csv", - "--file-name", - // "tasks2source.csv", - // "task-chain.csv", - // "testdata/reload-tasks.csv", - "./tasks_all.csv", + // "--file-name", + // // "tasks2source.csv", + // // "task-chain.csv", + // // "testdata/reload-tasks.csv", + // "./tasks_all.csv", - // "--qvf-overwrite", - // "no", + // // "--qvf-overwrite", + // // "no", - "--limit-import-count", - "2", + // "--limit-import-count", + // "2", - // "--dry-run" - ] + // // "--dry-run" + // ] // ------------------------------------ // Export apps to QVF files @@ -228,9 +228,9 @@ // // "--dry-run" // ] - // // ------------------------------------ - // // Get task tree - // // ------------------------------------ + // ------------------------------------ + // Get task tree + // ------------------------------------ // "args": [ // "task-get", // // "--auth-type", @@ -275,56 +275,55 @@ // ------------------------------------ // Get reload tasks as table // ------------------------------------ - // "args": [ - // "task-get", - // "--auth-type", - // "cert", - // "--host", - // "192.168.100.109", - // "--auth-cert-file", - // "./cert/client.pem", - // "--auth-cert-key-file", - // "./cert/client_key.pem", - // "--auth-user-dir", - // "LAB", - // "--auth-user-id", - // "goran", + "args": [ + "task-get", + "--auth-type", + "cert", + "--host", + "192.168.100.109", + "--auth-cert-file", + "../../code/secret/pro2win1-nopwd/client.pem", + // "./cert/client.pem", + "--auth-cert-key-file", + "../../code/secret/pro2win1-nopwd/client_key.pem", + // "./cert/client_key.pem", + "--auth-user-dir", + "LAB", + "--auth-user-id", + "goran", - // "--task-type", + "--task-type", // "reload", - // "ext-program", - - // // "--task-id", - // // "82bc3e66-c899-4e44-b52f-552145da5ee0", - // // "5748afa9-3abe-43ab-bb1f-127c48ced075", - // // "5520e710-91ad-41d2-aeb6-434cafbf366b", - // "--output-format", - // "table", - - // "--output-dest", - // "screen", - // // "--output-file-name", - // // "tasks.csv", - // // "tasks.json", - // // "--output-file-format", - // // "csv", - // // "json", - // // "excel", - - // // "--text-color", - // // "no", + "ext-program", + + "--task-id", + "afc250bc-28c3-49a2-8d63-80966749abe3", + // "5748afa9-3abe-43ab-bb1f-127c48ced075", + // "5520e710-91ad-41d2-aeb6-434cafbf366b", + "--output-format", + "table", + + "--output-dest", + "screen", + // "--output-file-name", + // "tasks.csv", + // "tasks.json", + // "--output-file-format", + // "csv", + // "json", + // "excel", + + // "--text-color", + // "no", - // "--table-details", - // "common", - // // "extprogram", - // // "lastexecution", - // // "tag", - // // "customproperty", - // // "schematrigger", - // "compositetrigger", - // // "comptimeconstraint", - // "comprule" - // ] + // "--table-details", + // "common", + // "lastexecution", + // "tag", + // "customproperty", + // "schematrigger", + // "compositetrigger", + ] // ------------------------------------ // Get reload tasks as CSV/Excel/JSON file diff --git a/src/ctrl-q.js b/src/ctrl-q.js index 53c5954..68f95a7 100644 --- a/src/ctrl-q.js +++ b/src/ctrl-q.js @@ -515,17 +515,7 @@ const program = new Command(); // This is allowed, but should be interpreted as "all" table details. // Make options.tableDetails an array with all possible table details. if (options.tableDetails === true) { - newOptions.tableDetails = [ - 'common', - 'extprogram', - 'lastexecution', - 'tag', - 'customproperty', - 'schematrigger', - 'compositetrigger', - 'comptimeconstraint', - 'comprule', - ]; + newOptions.tableDetails = ['common', 'lastexecution', 'tag', 'customproperty', 'schematrigger', 'compositetrigger']; } await sharedParamAssertOptions(newOptions); @@ -577,17 +567,7 @@ const program = new Command(); '--table-details [detail...]', 'which aspects of tasks should be included in table view. Not choosing any details will show all' ) - .choices([ - 'common', - 'extprogram', - 'lastexecution', - 'tag', - 'customproperty', - 'schematrigger', - 'compositetrigger', - 'comptimeconstraint', - 'comprule', - ]) + .choices(['common', 'lastexecution', 'tag', 'customproperty', 'schematrigger', 'compositetrigger']) .default('') ); diff --git a/src/lib/cmd/gettask.js b/src/lib/cmd/gettask.js index 04f6c22..d87e274 100644 --- a/src/lib/cmd/gettask.js +++ b/src/lib/cmd/gettask.js @@ -295,11 +295,6 @@ const getTask = async (options) => { options.tableDetails === '' || (typeof options.tableDetails === 'object' && options.tableDetails.find((item) => item === 'common')) ), - extprogram: !!( - options.tableDetails === true || - options.tableDetails === '' || - (typeof options.tableDetails === 'object' && options.tableDetails.find((item) => item === 'extprogram')) - ), lastexecution: !!( options.tableDetails === true || options.tableDetails === '' || @@ -325,16 +320,6 @@ const getTask = async (options) => { options.tableDetails === '' || (typeof options.tableDetails === 'object' && options.tableDetails?.find((item) => item === 'compositetrigger')) ), - comptimeconstraint: !!( - options.tableDetails === true || - options.tableDetails === '' || - (typeof options.tableDetails === 'object' && options.tableDetails?.find((item) => item === 'comptimeconstraint')) - ), - comprule: !!( - options.tableDetails === true || - options.tableDetails === '' || - (typeof options.tableDetails === 'object' && options.tableDetails?.find((item) => item === 'comprule')) - ), }; // eslint-disable-next-line no-restricted-syntax @@ -382,15 +367,12 @@ const getTask = async (options) => { task.appId ? task.appId : '', task.isPartialReload ? task.isPartialReload : '', task.isManuallyTriggered ? task.isManuallyTriggered : '', + task.path ? task.path : '', + task.parameters ? task.parameters : '', ]; row = row.concat(tmpRow); } - if (columnBlockShow.extprogram) { - tmpRow = [task.path ? task.path : '', task.parameters ? task.parameters : '']; - row = row.concat(tmpRow); - } - if (columnBlockShow.lastexecution) { tmpRow = [ taskStatus, @@ -412,31 +394,33 @@ const getTask = async (options) => { row = row.concat(tmpRow[0]); } - if (options.tableDetails === true || options.tableDetails === '') { - tmpRow = Array(14).fill(''); - row = row.concat(tmpRow); - } else if (columnBlockShow.schematrigger) { - tmpRow = Array(14).fill(''); - row = row.concat(tmpRow); - } else if (columnBlockShow.compositetrigger) { + // If complete details are requested, or if schema or composite columns are requested, add empty columns for general event info + if ( + options.tableDetails === true || + options.tableDetails === '' || + columnBlockShow.schematrigger || + columnBlockShow.compositetrigger + ) { tmpRow = Array(7).fill(''); row = row.concat(tmpRow); } - if (columnBlockShow.comptimeconstraint) { - tmpRow = Array(4).fill(''); + // If complete details are requested, or if schema columns are requested, add empty columns for schema event info + if (columnBlockShow.schematrigger) { + tmpRow = Array(7).fill(''); row = row.concat(tmpRow); } - if (columnBlockShow.comprule) { - tmpRow = Array(4).fill(''); + // If complete details are requested, or if composite columns are requested, add empty columns for composite event info + if (columnBlockShow.compositetrigger) { + tmpRow = Array(8).fill(''); row = row.concat(tmpRow); } // Add main task info to table taskTable = taskTable.concat([row]); - // Find all triggers for this task + // Find all schema events for this task const schemaEventsForThisTask = schemaEventList.filter((item) => { if (item.schemaEvent?.reloadTask?.id === task.taskId) { return true; @@ -447,6 +431,7 @@ const getTask = async (options) => { return false; }); + // Find all composite events for this task const compositeEventsForThisTask = compositeEventList.filter((item) => { if (item.compositeEvent?.reloadTask?.id === task.taskId) { return true; @@ -464,12 +449,7 @@ const getTask = async (options) => { row = [taskCount, '']; if (columnBlockShow.common) { - tmpRow = [...Array(8).fill('')]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.extprogram) { - tmpRow = [...Array(2).fill('')]; + tmpRow = [...Array(10).fill('')]; row = row.concat(tmpRow); } @@ -488,38 +468,29 @@ const getTask = async (options) => { row = row.concat(tmpRow); } - if (columnBlockShow.schematrigger || columnBlockShow.compositetrigger) { - // Include general event columns if schema or composite columns should be shown - tmpRow = [eventCount, mapEventType.get(event.schemaEvent.eventType)]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.schematrigger) { - tmpRow = [ - event.schemaEvent.name, - event.schemaEvent.enabled, - event.schemaEvent.createdDate, - event.schemaEvent.modifiedDate, - event.schemaEvent.modifiedByUserName, - - mapIncrementOption.get(event.schemaEvent.incrementOption), - event.schemaEvent.incrementDescription, - mapDaylightSavingTime.get(event.schemaEvent.daylightSavingTime), - event.schemaEvent.startDate, - event.schemaEvent.expirationDate, - event.schemaEvent.schemaFilterDescription[0], - event.schemaEvent.timeZone, - ]; - row = row.concat(tmpRow); - } + // Include general event columns if schema or composite columns should be shown + tmpRow = [eventCount, mapEventType.get(event.schemaEvent.eventType)]; + row = row.concat(tmpRow); - if (columnBlockShow.comptimeconstraint) { - tmpRow = Array(4).fill(''); - row = row.concat(tmpRow); - } + tmpRow = [ + event.schemaEvent.name, + event.schemaEvent.enabled, + event.schemaEvent.createdDate, + event.schemaEvent.modifiedDate, + event.schemaEvent.modifiedByUserName, + + mapIncrementOption.get(event.schemaEvent.incrementOption), + event.schemaEvent.incrementDescription, + mapDaylightSavingTime.get(event.schemaEvent.daylightSavingTime), + event.schemaEvent.startDate, + event.schemaEvent.expirationDate, + event.schemaEvent.schemaFilterDescription[0], + event.schemaEvent.timeZone, + ]; + row = row.concat(tmpRow); - if (columnBlockShow.comprule) { - tmpRow = Array(4).fill(''); + if (columnBlockShow.compositetrigger) { + tmpRow = Array(8).fill(''); row = row.concat(tmpRow); } @@ -529,18 +500,14 @@ const getTask = async (options) => { } } - if (columnBlockShow.compositetrigger || columnBlockShow.comptimeconstraint || columnBlockShow.comprule) { + // Write composite events to table + if (columnBlockShow.compositetrigger) { // eslint-disable-next-line no-restricted-syntax for (const event of compositeEventsForThisTask) { row = [taskCount, '']; if (columnBlockShow.common) { - tmpRow = [...Array(8).fill('')]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.extprogram) { - tmpRow = [...Array(2).fill('')]; + tmpRow = [...Array(10).fill('')]; row = row.concat(tmpRow); } @@ -559,7 +526,7 @@ const getTask = async (options) => { row = row.concat(tmpRow); } - // Include general event columns if schema or composite columns should be shown + // Include general event columns tmpRow = [eventCount, mapEventType.get(event.compositeEvent.eventType)]; row = row.concat(tmpRow); @@ -579,103 +546,90 @@ const getTask = async (options) => { row = row.concat(tmpRow); } - if (columnBlockShow.comptimeconstraint) { + if (columnBlockShow.compositetrigger) { // Composite task time constraints tmpRow = [ event.compositeEvent.timeConstraint.seconds, event.compositeEvent.timeConstraint.minutes, event.compositeEvent.timeConstraint.hours, event.compositeEvent.timeConstraint.days, + '', + '', + '', + '', ]; row = row.concat(tmpRow); } - if (columnBlockShow.comprule) { - tmpRow = Array(4).fill(''); - row = row.concat(tmpRow); - } - taskTable = taskTable.concat([row]); // Add all composite rules to table let ruleCount = 1; - if (columnBlockShow.comprule) { - // eslint-disable-next-line no-restricted-syntax - for (const rule of event.compositeEvent.compositeRules) { - row = [taskCount, '']; - - if (columnBlockShow.common) { - tmpRow = [...Array(8).fill('')]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.extprogram) { - tmpRow = [...Array(2).fill('')]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.lastexecution) { - tmpRow = [...Array(5).fill('')]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.tag) { - tmpRow = [...Array(1).fill('')]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.customproperty) { - tmpRow = [...Array(1).fill('')]; - row = row.concat(tmpRow); - } - - // Include general event columns if schema or composite columns should be shown - // tmpRow = [eventCount, mapEventType.get(event.compositeEvent.eventType)]; - tmpRow = [eventCount, '']; + // eslint-disable-next-line no-restricted-syntax + for (const rule of event.compositeEvent.compositeRules) { + row = [taskCount, '']; + + if (columnBlockShow.common) { + tmpRow = [...Array(10).fill('')]; + row = row.concat(tmpRow); + } + + if (columnBlockShow.lastexecution) { + tmpRow = [...Array(5).fill('')]; + row = row.concat(tmpRow); + } + + if (columnBlockShow.tag) { + tmpRow = [...Array(1).fill('')]; + row = row.concat(tmpRow); + } + + if (columnBlockShow.customproperty) { + tmpRow = [...Array(1).fill('')]; + row = row.concat(tmpRow); + } + + // Include general event columns + tmpRow = [eventCount, '', '', '', '', '', '']; + row = row.concat(tmpRow); + + if (columnBlockShow.schematrigger) { + // Add empty columns for schema event info + tmpRow = [...Array(7).fill('')]; row = row.concat(tmpRow); + } - if (columnBlockShow.schematrigger) { - tmpRow = [...Array(12).fill('')]; - row = row.concat(tmpRow); - } else if (columnBlockShow.compositetrigger) { - tmpRow = [...Array(5).fill('')]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.comptimeconstraint) { - // Composite task time constraints - tmpRow = [...Array(4).fill('')]; - row = row.concat(tmpRow); - } - - if (columnBlockShow.comprule) { - // Composite rules - - // Is it a reload task or external program task? - if (rule.reloadTask) { - tmpRow = [ - ruleCount, - mapRuleState.get(rule.ruleState), - rule.reloadTask.name, - rule.reloadTask.id, - ]; - } else if (rule.externalProgramTask) { - tmpRow = [ - ruleCount, - mapRuleState.get(rule.ruleState), - rule.externalProgramTask.name, - rule.externalProgramTask.id, - ]; - } - - row = row.concat(tmpRow); - } - - taskTable = taskTable.concat([row]); - - ruleCount += 1; + // Is it a reload task or external program task? + if (rule.reloadTask) { + tmpRow = [ + '', + '', + '', + '', + ruleCount, + mapRuleState.get(rule.ruleState), + rule.reloadTask.name, + rule.reloadTask.id, + ]; + } else if (rule.externalProgramTask) { + tmpRow = [ + '', + '', + '', + '', + ruleCount, + mapRuleState.get(rule.ruleState), + rule.externalProgramTask.name, + rule.externalProgramTask.id, + ]; } + + row = row.concat(tmpRow); + + taskTable = taskTable.concat([row]); + + ruleCount += 1; } eventCount += 1; @@ -701,13 +655,11 @@ const getTask = async (options) => { 'App id', 'Partial reload', 'Manually triggered', + 'Ext program path', + 'Ext program parameters', ]); } - if (columnBlockShow.extprogram) { - headerRow = headerRow.concat(['Ext program path', 'Ext program parameters']); - } - if (columnBlockShow.lastexecution) { headerRow = headerRow.concat(['Task status', 'Task started', 'Task ended', 'Task duration', 'Task executedon node']); } @@ -744,19 +696,19 @@ const getTask = async (options) => { ]); } - if (columnBlockShow.comptimeconstraint) { + if (columnBlockShow.compositetrigger) { headerRow = headerRow.concat([ 'Time contstraint seconds', 'Time contstraint minutes', 'Time contstraint hours', 'Time contstraint days', + 'Rule counter', + 'Rule state', + 'Rule task name', + 'Rule task id', ]); } - if (columnBlockShow.comprule) { - headerRow = headerRow.concat(['Rule counter', 'Rule state', 'Rule task name', 'Rule task id']); - } - consoleTableConfig.header = { alignment: 'left', content: `# reload tasks: ${taskTable.filter((task) => task[1] === 'Reload').length}, # external program tasks: ${