Skip to content

Commit 26ecb26

Browse files
committed
Merge branch 'master' of ssh://pctkn8.eur.ad.sag:10122/Adabas/adabas-rest-webapp-mirror
2 parents ab6b7ce + 9019c15 commit 26ecb26

34 files changed

+186
-216
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 & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -20,96 +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;
3056
}
31-
start() {
32-
console.log("Starting ...");
57+
// Schedule the job
58+
async start(): Promise<AxiosResponse<any>> {
3359
const getConfig = {
3460
headers: authHeader("application/json"),
3561
useCredentails: true,
3662
};
37-
return axios
38-
.put(config.Url() + "/scheduler/job/" + this.status.Job.Name, {}, getConfig)
39-
.catch((error: any) => {
40-
if (error.response) {
41-
if (error.response.status == 401 || error.response.status == 403) {
42-
userService.logout();
43-
location.reload(true);
44-
}
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);
4572
}
46-
throw error;
47-
});
73+
}
74+
throw error;
75+
}
4876
}
4977
name(): string {
5078
return this.status.Job.Name;
5179
}
52-
delete() {
80+
async delete(): Promise<AxiosResponse<any>> {
5381
const getConfig = {
5482
headers: authHeader("application/json"),
5583
useCredentails: true,
5684
};
57-
return axios
58-
.delete(config.Url() + "/scheduler/job/" + this.status.Job.Name, getConfig)
59-
.catch((error: any) => {
60-
if (error.response) {
61-
if (error.response.status == 401 || error.response.status == 403) {
62-
userService.logout();
63-
location.reload(true);
64-
}
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);
6594
}
66-
throw error;
67-
});
95+
}
96+
throw error;
97+
}
6898
}
69-
delete_execution(id: string) {
99+
async delete_execution(id: string): Promise<AxiosResponse<any>> {
70100
console.log("Starting ...");
71101
const getConfig = {
72102
headers: authHeader("application/json"),
73103
useCredentails: true,
74104
};
75-
return axios
76-
.delete(config.Url() + "/scheduler/job/" + this.status.Job.Name + "/result/" + id, getConfig)
77-
.catch((error: any) => {
78-
if (error.response) {
79-
if (error.response.status == 401 || error.response.status == 403) {
80-
userService.logout();
81-
location.reload(true);
82-
}
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);
83114
}
84-
throw error;
85-
});
115+
}
116+
throw error;
117+
}
86118

87119
}
88120
}
89121

90-
export function insertJob(job: any): Promise<any> {
122+
// Insert job in REST server configuration.
123+
export async function insertJob(job: any): Promise<any> {
91124
const getConfig = {
92125
headers: authHeader("application/json"),
93126
useCredentails: true,
94127
};
95-
return axios
96-
.post(config.Url() + "/scheduler/job/", job, getConfig)
97-
.catch((error: any) => {
98-
if (error.response) {
99-
if (error.response.status == 401 || error.response.status == 403) {
100-
userService.logout();
101-
location.reload(true);
102-
}
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);
103137
}
104-
throw error;
105-
});
138+
}
139+
throw error;
140+
}
106141
}
107-
export function loadJobs(): Promise<any> {
108-
return triggerCall("/scheduler/job").then((response: any) => {
109-
const jobs = [] as any[];
110-
response.JobDefinition.forEach((element: any) => {
111-
jobs.push(new JobAdmin(element));
112-
});
113-
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));
114150
});
151+
return jobs;
115152
}

src/components/ActivityDisplay.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,7 @@
129129

130130
<script lang="ts">
131131
import { Component, Prop, Vue } from "vue-property-decorator";
132-
import { authHeader } from "../user/auth-header";
133-
import { config } from "../store/config";
134-
import { userService } from "../user/service";
135132
import Sidebar from "./Sidebar.vue";
136-
import { AdabasAdmin } from "../adabas/admin";
137133
import store from "../store/index";
138134
import StatusBar from "./StatusBar.vue";
139135
import Url from "./Url.vue";
@@ -162,12 +158,12 @@ export default class ActivityDisplay extends Vue {
162158
this.$data.activity = response;
163159
});
164160
}
165-
searchArray(s: any[]) {
161+
searchArray(s: any[]): any {
166162
return this.$data.activity.filter((row: any) => {
167163
return s.indexOf(row.Name) > -1;
168164
});
169165
}
170-
search(s: string) {
166+
search(s: string): any {
171167
return this.$data.activity.filter((row: any) => {
172168
return row.Name.startsWith(s);
173169
});

src/components/BarChart.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Component } from 'vue-property-decorator';
2626
mixins: [mixins.reactiveProp]
2727
})
2828
export default class CommitChart extends Bar {
29-
mounted () {
29+
mounted (): void {
3030
// Overwriting base render method with actual data.
3131
this.renderChart({
3232
labels: ['CL','BT','ET'],

src/components/BufferPoolData.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@
181181

182182
<script lang="ts">
183183
import { Component, Prop, Vue } from "vue-property-decorator";
184-
import { authHeader } from "../user/auth-header";
185-
import { config } from "../store/config";
186-
import { userService } from "../user/service";
187184
import Sidebar from "./Sidebar.vue";
188185
import store from "../store/index";
189186
import StatusBar from "./StatusBar.vue";
@@ -213,7 +210,7 @@ export default class BufferPoolData extends Vue {
213210
this.$data.bufferPoolSize = this.searchValue("Size");
214211
});
215212
}
216-
searchValue(s: string) {
213+
searchValue(s: string): number {
217214
let v = this.$data.bufferpool.filter((row: any) => {
218215
return row.Name === s;
219216
});
@@ -222,7 +219,7 @@ export default class BufferPoolData extends Vue {
222219
}
223220
return 0;
224221
}
225-
search(s: string) {
222+
search(s: string): any {
226223
return this.$data.bufferpool.filter((row: any) => {
227224
return row.Name.startsWith(s);
228225
});

src/components/CheckpointList.vue

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@
118118

119119
<script lang="ts">
120120
import { Component, Prop, Vue } from "vue-property-decorator";
121-
import { authHeader } from "../user/auth-header";
122-
import { config } from "../store/config";
123-
import { userService } from "../user/service";
124121
import Sidebar from "./Sidebar.vue";
125122
import store from "../store/index";
126123
import StatusBar from "./StatusBar.vue";
@@ -168,15 +165,15 @@ export default class CheckpointList extends Vue {
168165
this.$data.fromTime = this.convertTime(currentdate);
169166
this.updateCheckpoints();
170167
}
171-
updateCheckpoints() {
168+
updateCheckpoints(): void {
172169
let to = this.$data.to + "+" + this.$data.toTime;
173170
let from = this.$data.from + "+" + this.$data.fromTime;
174171
const db = store.getters.search(this.url);
175172
db.checkpoints(from, to).then((response: any) => {
176173
this.$data.checkpoints = response;
177174
});
178175
}
179-
convertDate(currentdate: Date) {
176+
convertDate(currentdate: Date): string {
180177
return (
181178
new String(currentdate.getFullYear()).padStart(4, "0") +
182179
"-" +
@@ -185,7 +182,7 @@ export default class CheckpointList extends Vue {
185182
new String(currentdate.getDate()).padStart(2, "0")
186183
);
187184
}
188-
convertTime(currentdate: Date) {
185+
convertTime(currentdate: Date): string {
189186
return (
190187
new String(currentdate.getHours()).padStart(2, "0") +
191188
":" +
@@ -194,7 +191,7 @@ export default class CheckpointList extends Vue {
194191
new String(currentdate.getSeconds()).padStart(2, "0")
195192
);
196193
}
197-
onContext(ctx: any) {
194+
onContext(ctx: any): void {
198195
this.updateCheckpoints();
199196
}
200197
}

src/components/CommandqueueList.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959

6060
<script lang="ts">
6161
import { Component, Prop, Vue } from "vue-property-decorator";
62-
import { authHeader } from "../user/auth-header";
63-
import { config } from "../store/config";
64-
import { userService } from "../user/service";
6562
import Sidebar from "./Sidebar.vue";
6663
import StatusBar from "./StatusBar.vue";
6764
import store from "../store/index";

src/components/CommandstatsData.vue

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@
8484

8585
<script lang="ts">
8686
import { Component, Prop, Vue } from "vue-property-decorator";
87-
import { authHeader } from "../user/auth-header";
88-
import { config } from "../store/config";
89-
import { userService } from "../user/service";
9087
import Sidebar from "./Sidebar.vue";
9188
import store from "../store/index";
9289
import BarChart from "./BarChart";

src/components/ContainerList.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@
6262

6363
<script lang="ts">
6464
import { Component, Prop, Vue } from "vue-property-decorator";
65-
import { authHeader } from "../user/auth-header";
66-
import { config } from "../store/config";
67-
import { userService } from "../user/service";
6865
import Sidebar from "./Sidebar.vue";
6966
import store from "../store/index";
7067
import StatusBar from "./StatusBar.vue";
@@ -96,7 +93,6 @@ export default class DatabaseList extends Vue {
9693
};
9794
}
9895
created() {
99-
console.log("Container list ..." + this.url);
10096
const db = store.getters.search(this.url);
10197
db.containerList().then((response: any) => {
10298
this.$data.containers = response;

src/components/CreateDatabase.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,13 @@ export default class CreateDatabase extends Vue {
336336
this.$data.createJob.Job.Name = "CreateJob-" + new Date().getTime();
337337
}
338338
handleOk(bvModalEvt: any) {
339-
console.log("Handle OK");
340339
if (this.$data.useJob) {
341340
this.createDatabaseJob();
342341
} else {
343342
this.createDatabaseAPI();
344343
}
345344
}
346-
createDatabaseAPI() {
345+
createDatabaseAPI(): void {
347346
const getConfig = {
348347
headers: authHeader("application/json"),
349348
};
@@ -362,10 +361,10 @@ export default class CreateDatabase extends Vue {
362361
);
363362
});
364363
}
365-
changeUseJob() {
364+
changeUseJob(): void {
366365
console.log("Change use job "+this.$data.useJob);
367366
}
368-
createDatabaseJob() {
367+
createDatabaseJob(): void {
369368
this.$data.createJob.Job.Parameters = [];
370369
this.$data.createJob.Job.Parameters.push({
371370
Parameter: "dbid=" + this.$data.createDatabase.Dbid,
@@ -430,7 +429,7 @@ export default class CreateDatabase extends Vue {
430429
// });
431430
insertJob(this.$data.createJob);
432431
}
433-
replaceValue(str: string) {
432+
replaceValue(str: string): string {
434433
const regex = /\$\{([^$]*)\}/gm;
435434
let m;
436435
let newstr = str;

0 commit comments

Comments
 (0)