github.com/hernad/nomad@v1.6.112/ui/app/controllers/jobs/run/templates/manage.js (about) 1 /** 2 * Copyright (c) HashiCorp, Inc. 3 * SPDX-License-Identifier: MPL-2.0 4 */ 5 6 import Controller from '@ember/controller'; 7 import { inject as service } from '@ember/service'; 8 import { tracked } from '@glimmer/tracking'; 9 import { task } from 'ember-concurrency'; 10 11 export default class JobsRunTemplatesManageController extends Controller { 12 @service notifications; 13 @service router; 14 15 get templates() { 16 return [...this.model.variables.toArray(), ...this.model.default]; 17 } 18 19 @tracked selectedTemplate = null; 20 21 columns = ['name', 'namespace', 'description', 'delete'].map((column) => { 22 return { 23 key: column, 24 label: `${column.charAt(0).toUpperCase()}${column.substring(1)}`, 25 }; 26 }); 27 28 formatTemplateLabel(path) { 29 return path.split('nomad/job-templates/')[1]; 30 } 31 32 @task(function* (model) { 33 try { 34 yield model.destroyRecord(); 35 this.notifications.add({ 36 title: 'Job template deleted', 37 message: `${model.path} successfully deleted`, 38 color: 'success', 39 }); 40 } catch (err) { 41 this.notifications.add({ 42 title: `Job template could not be deleted.`, 43 message: err, 44 color: 'critical', 45 sticky: true, 46 }); 47 } 48 }) 49 deleteTemplate; 50 }