30
30
<Url url =" /scheduler/jobs" />
31
31
<b-row >
32
32
<b-col sm =" 5" >
33
- <b-pagination
34
- v-model =" currentPage"
35
- :total-rows =" jobs.length"
36
- :per-page =" perPage"
37
- aria-controls =" my-table"
38
- ></b-pagination ></b-col >
33
+ <b-pagination
34
+ v-model =" currentPage"
35
+ :total-rows =" jobs.length"
36
+ :per-page =" perPage"
37
+ aria-controls =" my-table"
38
+ ></b-pagination
39
+ ></b-col >
39
40
<b-col sm =" 1" >
40
- <b-form-select v-model =" perPage" :options =" perPageOptions" size =" sm" class =" mt-3" ></b-form-select >
41
- </b-col ></b-row >
41
+ <b-form-select
42
+ v-model =" perPage"
43
+ :options =" perPageOptions"
44
+ size =" sm"
45
+ class =" mt-3"
46
+ ></b-form-select > </b-col
47
+ ></b-row >
42
48
<b-row >
43
49
<b-col sm =" 6" >
44
50
<b-table
72
78
<b-button
73
79
variant =" outline-primary"
74
80
class =" mr-2"
75
- v-b-modal = " 'modal-definition-' + row.item.status.Job.Name "
81
+ v-on:click = " viewJob( row.item.status) "
76
82
>Show</b-button
77
83
>
78
- <b-modal
79
- size =" xl"
80
- :id =" 'modal-definition-' + row.item.status.Job.Name"
81
- title =" Job definition"
82
- ok-only
83
- >
84
- <pre class =" my-4" >{{ row.item.status.Job }}</pre >
85
- </b-modal >
86
84
<b-button
87
85
variant =" outline-primary"
88
86
id =" expJob"
156
154
</b-row >
157
155
</b-card-body >
158
156
</b-card >
157
+ <b-modal
158
+ size =" xl"
159
+ id =" modal-definition-job"
160
+ :title =" 'Job definition ' + currentJob.Name"
161
+ ok-only
162
+ >
163
+ <pre class =" my-4" >{{ currentJob }}</pre >
164
+ </b-modal >
159
165
<StatusBar />
160
166
</div >
161
167
</template >
162
168
163
169
<script lang="ts">
164
- import { Component , Prop , Vue } from " vue-property-decorator" ;
165
- import { JobAdmin , loadExecutions } from " ../adabas/jobs" ;
166
- import { userService } from " ../user/service" ;
167
- import store from " ../store/index" ;
168
- import CreateJob from " ./CreateJob.vue" ;
169
- import StatusBar from " ./StatusBar.vue" ;
170
- import Url from " ./Url.vue" ;
170
+ import { Component , Prop , Vue } from ' vue-property-decorator' ;
171
+ import { JobAdmin , loadExecutions , loadJobDefinition } from ' ../adabas/jobs' ;
172
+ import { userService } from ' ../user/service' ;
173
+ import store from ' ../store/index' ;
174
+ import CreateJob from ' ./CreateJob.vue' ;
175
+ import StatusBar from ' ./StatusBar.vue' ;
176
+ import Url from ' ./Url.vue' ;
171
177
172
178
@Component ({
173
179
components: {
@@ -183,26 +189,27 @@ export default class JobList extends Vue {
183
189
return {
184
190
perPage: 10 ,
185
191
currentPage: 1 ,
186
- perPageOptions: [10 ,20 ,50 ,100 ],
192
+ perPageOptions: [10 , 20 , 50 , 100 ],
187
193
selectedJob: null ,
188
194
selectedExecution: null ,
189
195
fields: [
190
- { key: " status.Job.Name" , label: " Name" },
191
- { key: " status.Job.User" , label: " User" },
192
- { key: " status.Job.Utility" , label: " Utility" },
193
- { key: " status.Status" , label: " Status" },
194
- { key: " status.Job.Description" , label: " Description" },
195
- " info" ,
196
+ { key: ' status.Job.Name' , label: ' Name' },
197
+ { key: ' status.Job.User' , label: ' User' },
198
+ { key: ' status.Job.Utility' , label: ' Utility' },
199
+ { key: ' status.Status' , label: ' Status' },
200
+ { key: ' status.Job.Description' , label: ' Description' },
201
+ ' info' ,
196
202
],
197
- execFields: [" Id " , " Scheduled" , " Ended" , " ExitCode" , " log" ],
203
+ execFields: [' Id ' , ' Scheduled' , ' Ended' , ' ExitCode' , ' log' ],
198
204
jobs: [] as JobAdmin [],
199
- currentId: " " ,
205
+ currentId: ' ' ,
200
206
executions: [],
201
- timer: " " ,
207
+ timer: ' ' ,
202
208
max: maxDate ,
203
- log: " " ,
209
+ log: ' ' ,
204
210
from: null ,
205
211
to: null ,
212
+ currentJob: {} as any ,
206
213
};
207
214
}
208
215
created(): void {
@@ -214,35 +221,43 @@ export default class JobList extends Vue {
214
221
}
215
222
convertDate(currentdate : Date ): string {
216
223
return (
217
- new String (currentdate .getFullYear ()).padStart (4 , " 0 " ) +
218
- " - " +
219
- new String (currentdate .getMonth () + 1 ).padStart (2 , " 0 " ) +
220
- " - " +
221
- new String (currentdate .getDate ()).padStart (2 , " 0 " )
224
+ new String (currentdate .getFullYear ()).padStart (4 , ' 0 ' ) +
225
+ ' - ' +
226
+ new String (currentdate .getMonth () + 1 ).padStart (2 , ' 0 ' ) +
227
+ ' - ' +
228
+ new String (currentdate .getDate ()).padStart (2 , ' 0 ' )
222
229
);
223
230
}
224
231
convertTime(currentdate : Date ): string {
225
232
return (
226
- new String (currentdate .getHours ()).padStart (2 , " 0 " ) +
227
- " : " +
228
- new String (currentdate .getMinutes ()).padStart (2 , " 0 " ) +
229
- " : " +
230
- new String (currentdate .getSeconds ()).padStart (2 , " 0 " )
233
+ new String (currentdate .getHours ()).padStart (2 , ' 0 ' ) +
234
+ ' : ' +
235
+ new String (currentdate .getMinutes ()).padStart (2 , ' 0 ' ) +
236
+ ' : ' +
237
+ new String (currentdate .getSeconds ()).padStart (2 , ' 0 ' )
231
238
);
232
239
}
233
240
convertDateTime(d : string ): string {
234
241
var de = new Date (d );
235
242
return de .toUTCString ();
236
243
}
244
+ viewJob(item : any ): void {
245
+ console .log (' View job ' + JSON .stringify (item ));
246
+ loadJobDefinition (item .Job .Name ).then ((result : any ) => {
247
+ console .log (' Return ' + JSON .stringify (result ));
248
+ this .$data .currentJob = result ;
249
+ this .$bvModal .show (' modal-definition-job' );
250
+ });
251
+ }
237
252
retrieveJobs(): void {
238
253
store
239
- .dispatch (" SYNC_ADMIN_JOBS" )
254
+ .dispatch (' SYNC_ADMIN_JOBS' )
240
255
.then ((response : any ) => {
241
256
if (this .$data .selectedJob != null ) {
242
257
const name = this .$data .selectedJob .status .Job .Name ;
243
258
let x = response .find ((j : JobAdmin ) => j .name () === name );
244
259
if (! x ) {
245
- console .log (" No name found" );
260
+ console .log (' No name found' );
246
261
return ;
247
262
}
248
263
this .$data .selectedJob = x ;
@@ -251,22 +266,22 @@ export default class JobList extends Vue {
251
266
this .$data .jobs = response ;
252
267
})
253
268
.catch ((error : any ) => {
254
- console .log (" ERROR JOBLIST: " + JSON .stringify (error ));
269
+ console .log (' ERROR JOBLIST: ' + JSON .stringify (error ));
255
270
if (error .response ) {
256
- store .commit (" SET_STATUS" , JSON .stringify (error .response ));
271
+ store .commit (' SET_STATUS' , JSON .stringify (error .response ));
257
272
if (error .response .status == 401 || error .response .status == 403 ) {
258
273
userService .logout ();
259
274
location .reload ();
260
275
}
261
276
} else {
262
- store .commit (" SET_STATUS" , JSON .stringify (error ));
277
+ store .commit (' SET_STATUS' , JSON .stringify (error ));
263
278
userService .logout ();
264
279
location .reload ();
265
280
}
266
281
throw error ;
267
282
});
268
283
if (this .$data .selectedJob != null ) {
269
- console .log (this .$data .from )
284
+ console .log (this .$data .from );
270
285
loadExecutions (
271
286
this .$data .selectedJob .status .Job .Name ,
272
287
this .$data .from ,
@@ -289,7 +304,7 @@ export default class JobList extends Vue {
289
304
if (items .length == 0 ) {
290
305
return ;
291
306
}
292
- this .$data .log = " " ;
307
+ this .$data .log = ' ' ;
293
308
this .$data .selectedJob = items [0 ];
294
309
loadExecutions (
295
310
items [0 ].status .Job .Name ,
@@ -317,23 +332,29 @@ export default class JobList extends Vue {
317
332
const jobToDelete = this .$data .jobs .find (
318
333
(j : JobAdmin ) => j .name () === name
319
334
);
320
- console .log (" Job to delete: " + name );
335
+ console .log (' Job to delete: ' + name );
321
336
jobToDelete .delete ();
322
337
}
323
338
exportJob(name : string ): void {
324
- const jobToExport = this .$data .jobs .find (
325
- (j : JobAdmin ) => j .name () === name
326
- );
327
- console .log (
328
- " Job to export: " + name + " " + JSON .stringify (jobToExport .status .Job )
329
- );
339
+ loadJobDefinition (name ).then ((result : any ) => {
340
+ var filename = ' job.json' ;
341
+ const a = document .createElement (' a' );
342
+ const type = filename .split (' .' ).pop ();
343
+ a .href = URL .createObjectURL (
344
+ new Blob ([JSON .stringify (result )], {
345
+ type: ` text/${type === ' txt' ? ' plain' : type } ` ,
346
+ })
347
+ );
348
+ a .download = filename ;
349
+ a .click ();
350
+ });
330
351
}
331
352
delExecution(id : string ): void {
332
- console .log (" Delete id " + id );
353
+ console .log (' Delete id ' + id );
333
354
this .$data .selectedJob .delete_execution (id );
334
355
}
335
356
showLog(item : any ): void {
336
- console .log (" Show log id " + JSON .stringify (item ));
357
+ console .log (' Show log id ' + JSON .stringify (item ));
337
358
this .$data .currentId = item .ID ;
338
359
this .$data .log = item .Log ;
339
360
}
0 commit comments