confirmDelete()

in ui/angular/src/app/job/job.component.ts [87:137]


  confirmDelete() {
    let self = this;
    if (this.isStop) {
      $("#save").attr("disabled", "true");
      let actionUrl = this.serviceService.config.uri.modifyJobs + "/" + this.deleteId + "?action=" + "stop";
      this.http.put(actionUrl, {}).subscribe(data => {
          let self = this;
          self.hide();
          var result = JSON.parse(JSON.stringify(data));
          self.results[self.deleteIndex].action = 'START';
          self.results[self.deleteIndex].jobState.state = result["job.state"].state;
          self.isStop = false;
        },
        err => {
          this.toasterService.pop("error", "Error!", "Failed to manage job state!");
          console.log("Error when manage job state");
        });
    }
    else if (this.isTrigger) {
      $("#save").attr("disabled", "true");
      let actionUrl = this.serviceService.config.uri.triggerJobById + "/" + this.deleteId;
      this.http.post(actionUrl, {}).subscribe(data => {
          let self = this;
          self.hide();
          this.isTrigger = false;
        },
        err => {
          this.toasterService.pop("error", "Error!", "Failed to trigger job!");
          console.log("Error when trigger job");
        });
    }
    else {
      let deleteJob = this.serviceService.config.uri.deleteJob;
      let deleteUrl = deleteJob + "/" + this.deleteId;
      $("#save").attr("disabled", "true");
      this.http.delete(deleteUrl).subscribe(
        data => {
          let self = this;
          self.hide();
          setTimeout(function () {
            self.results.splice(self.deleteIndex, 1);
          }, 0);
        },
        err => {
          this.toasterService.pop("error", "Error!", "Failed to delete job!");
          console.log("Error when deleting job");
        }
      );
    }

  }