mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2026-01-23 14:33:26 +01:00
Check input schema (#33)
This commit is contained in:
1533
ui/src/client/api.ts
1533
ui/src/client/api.ts
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@
|
||||
import { Configuration } from "./configuration";
|
||||
// Some imports not used depending on template conditions
|
||||
// @ts-ignore
|
||||
import globalAxios, { AxiosPromise, AxiosInstance } from 'axios';
|
||||
import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
||||
|
||||
export const BASE_PATH = "http://./api".replace(/\/+$/, "");
|
||||
|
||||
@@ -38,7 +38,7 @@ export const COLLECTION_FORMATS = {
|
||||
*/
|
||||
export interface RequestArgs {
|
||||
url: string;
|
||||
options: any;
|
||||
options: AxiosRequestConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
|
||||
import { Configuration } from "./configuration";
|
||||
import { RequiredError, RequestArgs } from "./base";
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { RequiredError, RequestArgs } from "./base";
|
||||
import { AxiosInstance, AxiosResponse } from 'axios';
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -131,8 +131,8 @@ export const toPathString = function (url: URL) {
|
||||
* @export
|
||||
*/
|
||||
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
||||
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||
const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
|
||||
return axios.request(axiosRequestArgs);
|
||||
return axios.request<T, R>(axiosRequestArgs);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ export default Vue.extend({
|
||||
return icon;
|
||||
},
|
||||
statusColor: function () {
|
||||
let color = TypeColorEnum.Info;
|
||||
let color = TypeColorEnum.Info as TypeColorEnum;
|
||||
this.lodash.forEach(this.$store.state.settings.artifactStates, (state: Type) => {
|
||||
if (this.artifact.status === state.id && state.color) {
|
||||
color = state.color
|
||||
color = state.color;
|
||||
}
|
||||
})
|
||||
return color;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated from CAQLLexer.g4 by ANTLR 4.9.2
|
||||
// Generated from CAQLLexer.g4 by ANTLR 4.9.3
|
||||
// jshint ignore: start
|
||||
import antlr4 from 'antlr4';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated from CAQLParser.g4 by ANTLR 4.9.2
|
||||
// Generated from CAQLParser.g4 by ANTLR 4.9.3
|
||||
// jshint ignore: start
|
||||
import antlr4 from 'antlr4';
|
||||
import CAQLParserListener from './CAQLParserListener.js';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Generated from CAQLParser.g4 by ANTLR 4.9.2
|
||||
// Generated from CAQLParser.g4 by ANTLR 4.9.3
|
||||
// jshint ignore: start
|
||||
import antlr4 from 'antlr4';
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ export default Vue.extend({
|
||||
return icon;
|
||||
},
|
||||
statusColor: function (status: string) {
|
||||
let color = TypeColorEnum.Info;
|
||||
let color = TypeColorEnum.Info as TypeColorEnum;
|
||||
this.lodash.forEach(this.$store.state.settings.artifactStates, (state: Type) => {
|
||||
if (status === state.id && state.color) {
|
||||
color = state.color
|
||||
|
||||
@@ -152,7 +152,7 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
loadAutomations() {
|
||||
API.listAutomations(this.$route.params.id).then((response) => {
|
||||
API.listAutomations().then((response) => {
|
||||
this.automations = response.data;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1145,30 +1145,13 @@ export default Vue.extend({
|
||||
this.selectedTask = undefined;
|
||||
this.selectedTaskPlaybook = undefined;
|
||||
},
|
||||
toTaskForm(task: TaskResponse): Task {
|
||||
return {
|
||||
automation: task.automation,
|
||||
closed: task.closed,
|
||||
created: task.created,
|
||||
data: task.data,
|
||||
done: task.done,
|
||||
join: task.join,
|
||||
payload: task.payload,
|
||||
name: task.name,
|
||||
next: task.next,
|
||||
owner: task.owner,
|
||||
schema: task.schema,
|
||||
type: task.type.toString() as TaskTypeEnum,
|
||||
} as Task
|
||||
},
|
||||
save(playbookID: string, taskID: string) {
|
||||
if (!this.ticket || !this.ticket.id || !this.ticket.playbooks) {
|
||||
return;
|
||||
}
|
||||
|
||||
let task = this.ticket.playbooks[playbookID].tasks[taskID]
|
||||
task.data = this.tdata[playbookID.toString() + "-" + taskID];
|
||||
API.setTask(this.ticket.id, playbookID, taskID, this.toTaskForm(task)).then((response) => {
|
||||
let data = this.tdata[playbookID.toString() + "-" + taskID];
|
||||
API.setTaskData(this.ticket.id, playbookID, taskID, data).then((response) => {
|
||||
this.$store.dispatch("alertSuccess", { name: "Task saved" });
|
||||
this.setTicket(response.data);
|
||||
});
|
||||
@@ -1181,9 +1164,7 @@ export default Vue.extend({
|
||||
return;
|
||||
}
|
||||
|
||||
let task = this.ticket.playbooks[playbookID].tasks[taskID]
|
||||
task.owner = owner
|
||||
API.setTask(this.ticket.id, playbookID, taskID, this.toTaskForm(task)).then((response) => {
|
||||
API.setTaskOwner(this.ticket.id, playbookID, taskID, owner).then((response) => {
|
||||
this.$store.dispatch("alertSuccess", { name: "Owner saved" });
|
||||
this.setTicket(response.data);
|
||||
if (response.data.playbooks) {
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<script lang="ts">
|
||||
import Vue from "vue";
|
||||
|
||||
import { NewUserResponse, UserResponse } from "../client";
|
||||
import { NewUserResponse, UserResponse } from "@/client";
|
||||
import {API} from "@/services/api";
|
||||
|
||||
interface State {
|
||||
|
||||
Reference in New Issue
Block a user