Skip to content

Commit 9019c15

Browse files
committed
Remove typescript warnings
1 parent 6e80653 commit 9019c15

File tree

2 files changed

+98
-61
lines changed

2 files changed

+98
-61
lines changed

src/adabas/admin.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ import axios, { AxiosResponse } from "axios";
2424
import store from "../store/index";
2525

2626
interface AdabasAdminType {
27-
Active: boolean;
28-
Dbid: number;
29-
Name: string;
30-
StructureLevel: number;
31-
Version:string;
27+
Active: boolean;
28+
Dbid: number;
29+
Name: string;
30+
StructureLevel: number;
31+
Version: string;
3232
}
33+
3334
/*
3435
* This typescript class AdabasAdmin handles all database administration
3536
* and monitor tasks provided by Adabas REST server.

src/adabas/jobs.ts

Lines changed: 92 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -20,97 +20,133 @@
2020
import { authHeader } from "../user/auth-header";
2121
import { config } from "../store/config";
2222
import { userService } from "../user/service";
23-
import axios from "axios";
23+
import axios, { AxiosResponse } from "axios";
2424
import { triggerCall } from "./admin";
2525

26+
interface JobJobType {
27+
Name: string;
28+
User: string;
29+
Utility: string;
30+
Environments: {
31+
Parameter: string
32+
}
33+
Parameters: {
34+
Parameter: string
35+
}
36+
}
37+
38+
interface JobExecutionType {
39+
Ended: string;
40+
ExitCode: number;
41+
Log: string;
42+
Id: string;
43+
Scheduled: string;
44+
}
45+
46+
interface JobAdminType {
47+
Executions: JobExecutionType[];
48+
Job: JobJobType;
49+
Status: string;
50+
}
51+
2652
export class JobAdmin {
27-
private status: any;
28-
constructor(dbInput: any) {
53+
private status: JobAdminType;
54+
constructor(dbInput: JobAdminType) {
2955
this.status = dbInput;
30-
console.log("JOBS struct: "+JSON.stringify(dbInput));
3156
}
32-
start() {
33-
console.log("Starting ...");
57+
// Schedule the job
58+
async start(): Promise<AxiosResponse<any>> {
3459
const getConfig = {
3560
headers: authHeader("application/json"),
3661
useCredentails: true,
3762
};
38-
return axios
39-
.put(config.Url() + "/scheduler/job/" + this.status.Job.Name, {}, getConfig)
40-
.catch((error: any) => {
41-
if (error.response) {
42-
if (error.response.status == 401 || error.response.status == 403) {
43-
userService.logout();
44-
location.reload(true);
45-
}
63+
try {
64+
return axios
65+
.put(config.Url() + "/scheduler/job/" + this.status.Job.Name, {}, getConfig);
66+
}
67+
catch (error) {
68+
if (error.response) {
69+
if (error.response.status == 401 || error.response.status == 403) {
70+
userService.logout();
71+
location.reload(true);
4672
}
47-
throw error;
48-
});
73+
}
74+
throw error;
75+
}
4976
}
5077
name(): string {
5178
return this.status.Job.Name;
5279
}
53-
delete() {
80+
async delete(): Promise<AxiosResponse<any>> {
5481
const getConfig = {
5582
headers: authHeader("application/json"),
5683
useCredentails: true,
5784
};
58-
return axios
59-
.delete(config.Url() + "/scheduler/job/" + this.status.Job.Name, getConfig)
60-
.catch((error: any) => {
61-
if (error.response) {
62-
if (error.response.status == 401 || error.response.status == 403) {
63-
userService.logout();
64-
location.reload(true);
65-
}
85+
try {
86+
return axios
87+
.delete(config.Url() + "/scheduler/job/" + this.status.Job.Name, getConfig);
88+
}
89+
catch (error) {
90+
if (error.response) {
91+
if (error.response.status == 401 || error.response.status == 403) {
92+
userService.logout();
93+
location.reload(true);
6694
}
67-
throw error;
68-
});
95+
}
96+
throw error;
97+
}
6998
}
70-
delete_execution(id: string) {
99+
async delete_execution(id: string): Promise<AxiosResponse<any>> {
71100
console.log("Starting ...");
72101
const getConfig = {
73102
headers: authHeader("application/json"),
74103
useCredentails: true,
75104
};
76-
return axios
77-
.delete(config.Url() + "/scheduler/job/" + this.status.Job.Name + "/result/" + id, getConfig)
78-
.catch((error: any) => {
79-
if (error.response) {
80-
if (error.response.status == 401 || error.response.status == 403) {
81-
userService.logout();
82-
location.reload(true);
83-
}
105+
try {
106+
return axios
107+
.delete(config.Url() + "/scheduler/job/" + this.status.Job.Name + "/result/" + id, getConfig);
108+
}
109+
catch (error) {
110+
if (error.response) {
111+
if (error.response.status == 401 || error.response.status == 403) {
112+
userService.logout();
113+
location.reload(true);
84114
}
85-
throw error;
86-
});
115+
}
116+
throw error;
117+
}
87118

88119
}
89120
}
90121

91-
export function insertJob(job: any): Promise<any> {
122+
// Insert job in REST server configuration.
123+
export async function insertJob(job: any): Promise<any> {
92124
const getConfig = {
93125
headers: authHeader("application/json"),
94126
useCredentails: true,
95127
};
96-
return axios
97-
.post(config.Url() + "/scheduler/job/", job, getConfig)
98-
.catch((error: any) => {
99-
if (error.response) {
100-
if (error.response.status == 401 || error.response.status == 403) {
101-
userService.logout();
102-
location.reload(true);
103-
}
128+
try {
129+
return axios
130+
.post(config.Url() + "/scheduler/job/", job, getConfig);
131+
}
132+
catch (error) {
133+
if (error.response) {
134+
if (error.response.status == 401 || error.response.status == 403) {
135+
userService.logout();
136+
location.reload(true);
104137
}
105-
throw error;
106-
});
138+
}
139+
throw error;
140+
}
107141
}
108-
export function loadJobs(): Promise<any> {
109-
return triggerCall("/scheduler/job").then((response: any) => {
110-
const jobs = [] as any[];
111-
response.JobDefinition.forEach((element: any) => {
112-
jobs.push(new JobAdmin(element));
113-
});
114-
return jobs;
142+
143+
// Load all jobs available in REST server. Return array
144+
// of all jobs.
145+
export async function loadJobs(): Promise<any> {
146+
const response = await triggerCall("/scheduler/job");
147+
const jobs = ([] as JobAdmin[]);
148+
response.JobDefinition.forEach((element: any) => {
149+
jobs.push(new JobAdmin(element));
115150
});
151+
return jobs;
116152
}

0 commit comments

Comments
 (0)