Skip to content

Commit 2c456c0

Browse files
committed
Update job editing
1 parent 0731500 commit 2c456c0

File tree

2 files changed

+64
-17
lines changed

2 files changed

+64
-17
lines changed

src/components/CreateJob.vue

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
<template>
1717
<div class="createjob">
18-
<b-button variant="success" v-b-modal.modal-createjob>Create RESTful server job</b-button>
18+
<b-button variant="success" v-b-modal.modal-createjob
19+
>Create RESTful server job</b-button
20+
>
1921

2022
<b-modal
2123
@ok="insertJobInServer"
@@ -101,13 +103,17 @@
101103
<b-button v-on:click="removeParameter(row.index)"
102104
>Remove</b-button
103105
>
104-
<b-button v-on:click="editParameter">Edit</b-button>
106+
<b-button
107+
v-on:click="editParameter(row.index)"
108+
v-b-modal.modal-parameter
109+
>Edit</b-button
110+
>
105111
</template>
106112
</b-table>
107113
<b-modal
108114
id="modal-parameter"
109115
ref="modal"
110-
:title="'Add ' + editable"
116+
:title="operation + ' ' + editable"
111117
@show="resetModal"
112118
@hidden="resetModal"
113119
@ok="handleOk"
@@ -178,12 +184,15 @@ export default class CreateJob extends Vue {
178184
CronScheduler: "(null)",
179185
},
180186
},
187+
newSavedJob: null,
181188
editable: "Parameter",
189+
operation: "Add",
182190
description: "xxx",
183191
parameterDescription: "The parameter for the Adabas utility",
184192
environmentDescription:
185193
"The environment defined with {VAR}={VALUE} for the Adabas utility",
186194
parameter: "",
195+
parameterEditIndex: -1,
187196
nameState: null,
188197
submittedNames: [],
189198
paraFields: ["Parameter", "action"],
@@ -206,31 +215,57 @@ export default class CreateJob extends Vue {
206215
}
207216
created() {
208217
this.$data.newJob.Job.User = userService.getUsername();
218+
this.$data.newSavedJob = this.$data.newJob;
219+
this.$root.$on("editJob", (data: any) => {
220+
this.$data.newJob = data;
221+
});
222+
209223
}
210224
removeParameter(parameter: number): void {
211225
this.$data.newJob.Job.Parameters.splice(parameter, 1);
212226
}
213-
editParameter(parameter: any): void {
214-
console.log("Remove " + parameter);
227+
editParameter(parameter: number): void {
228+
console.log("Edit " + parameter);
229+
this.$data.parameterEditIndex = parameter;
230+
this.$data.parameter = this.$data.newJob.Job.Parameters[
231+
parameter
232+
].Parameter;
233+
this.$data.editable = "Parameter";
234+
this.$data.operation = "Edit";
235+
this.$data.description = this.$data.parameterDescription;
215236
}
216237
prepareParameter(): void {
217238
this.$data.editable = "Parameter";
239+
this.$data.operation = "Add";
218240
this.$data.description = this.$data.parameterDescription;
219241
}
220242
prepareEnvironment(): void {
221243
this.$data.editable = "Environment";
244+
this.$data.operation = "Add";
222245
this.$data.description = this.$data.environmentDescription;
223246
}
224247
handleOk(bvModalEvt: any): void {
225-
if (this.$data.editable === "Environment") {
226-
console.log("Add environment " + this.$data.parameter);
227-
this.$data.newJob.Job.Environments.push({
228-
Parameter: this.$data.parameter,
229-
});
248+
if (this.$data.operation === "Edit") {
249+
if (this.$data.editable === "Environment") {
250+
this.$data.newJob.Job.Environments[
251+
this.$data.parameterEditIndex
252+
].Parameter = this.$data.parameter;
253+
} else {
254+
this.$data.newJob.Job.Parameters[
255+
this.$data.parameterEditIndex
256+
].Parameter = this.$data.parameter;
257+
}
230258
} else {
231-
this.$data.newJob.Job.Parameters.push({
232-
Parameter: this.$data.parameter,
233-
});
259+
if (this.$data.editable === "Environment") {
260+
console.log("Add environment " + this.$data.parameter);
261+
this.$data.newJob.Job.Environments.push({
262+
Parameter: this.$data.parameter,
263+
});
264+
} else {
265+
this.$data.newJob.Job.Parameters.push({
266+
Parameter: this.$data.parameter,
267+
});
268+
}
234269
}
235270
}
236271
checkFormValidity(): boolean {

src/components/JobList.vue

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<b-col sm="6">
3030
<b-table
3131
class="w-100 p-3"
32-
3332
striped
3433
bordered
3534
hover
@@ -57,9 +56,8 @@
5756
variant="info"
5857
class="mr-2"
5958
v-b-modal="'modal-definition-' + row.item.status.Job.Name"
60-
>Job definition</b-button
59+
>Show</b-button
6160
>
62-
6361
<b-modal
6462
size="xl"
6563
:id="'modal-definition-' + row.item.status.Job.Name"
@@ -68,13 +66,19 @@
6866
>
6967
<pre class="my-4">{{ row.item.status.Job }}</pre>
7068
</b-modal>
69+
<b-button
70+
variant="info"
71+
id="expJob"
72+
class="mr-2"
73+
v-on:click="exportJob(row.item.status.Job.Name)"
74+
>Export</b-button
75+
>
7176
</template>
7277
</b-table>
7378
</b-col>
7479
<b-col sm="6">
7580
<b-table
7681
class="w-100 p-3"
77-
7882
striped
7983
bordered
8084
hover
@@ -211,6 +215,14 @@ export default class JobList extends Vue {
211215
console.log("Job to delete: " + name);
212216
jobToDelete.delete();
213217
}
218+
exportJob(name: string): void {
219+
const jobToExport = this.$data.jobs.find(
220+
(j: JobAdmin) => j.name() === name
221+
);
222+
console.log(
223+
"Job to export: " + name + " " + JSON.stringify(jobToExport.status.Job)
224+
);
225+
}
214226
delExecution(id: string): void {
215227
console.log("Delete id " + id + " of " + this.$data.selected.name());
216228
this.$data.selected.delete_execution(id);

0 commit comments

Comments
 (0)