submit.component.ts 3.66 KB
Newer Older
Rasko Leinonen's avatar
Rasko Leinonen committed
1 2 3 4 5 6 7 8 9 10 11
/*
 * Copyright 2018 EMBL - European Bioinformatics Institute
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software distributed under the
 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */

rajkumar's avatar
rajkumar committed
12 13 14 15 16 17 18
import { Component, ViewEncapsulation } from "@angular/core";
import { Observable } from "rxjs";
import { ChecklistType } from "../checklist-type.enum";
import { WebinAuthenticationService } from "../webin-authentication.service";
import { WebinRestService } from "../webin-rest.service";
import { MatDialog } from "@angular/material";
import { SubmissionResultDialogComponent } from "../submission-result-dialog/submission-result-dialog.component";
19 20

@Component({
rajkumar's avatar
rajkumar committed
21 22 23 24
  selector: "app-submit",
  templateUrl: "./submit.component.html",
  styleUrls: ["./submit.component.css"],
  encapsulation: ViewEncapsulation.None,
25
})
26
export class SubmitComponent {
rajkumar's avatar
rajkumar committed
27
  ChecklistType = ChecklistType; // Allows use in template
28

29 30 31 32 33 34 35 36 37 38
  submissionFile: File;
  studyFile: File;
  projectFile: File;
  sampleFile: File;
  experimentFile: File;
  runFile: File;
  analysisFile: File;
  dacFile: File;
  policyFile: File;
  datasetFile: File;
Rajkumar-D's avatar
Rajkumar-D committed
39
  centerName: String;
40

41
  constructor(
42
    private _webinAuthenticationService: WebinAuthenticationService,
43
    private _webinRestService: WebinRestService,
rajkumar's avatar
rajkumar committed
44 45
    public dialog: MatDialog
  ) { }
46

47
  isEga(): boolean {
48
    return this._webinAuthenticationService.ega;
49 50
  }

51 52
  onChangeSubmissionFile(files) {
    this.submissionFile = files[0];
53
    // console.log("Submission file: " + this.submissionFile);
54 55 56 57
  }

  onChangeStudyFile(files) {
    this.studyFile = files[0];
58
    // console.log("Study file: " + this.studyFile);
59 60 61 62
  }

  onChangeProjectFile(files) {
    this.projectFile = files[0];
63
    // console.log("Project file: " + this.projectFile);
64 65 66 67
  }

  onChangeSampleFile(files) {
    this.sampleFile = files[0];
68
    // console.log("Sample file: " + this.sampleFile);
69 70 71 72
  }

  onChangeExperimentFile(files) {
    this.experimentFile = files[0];
73
    // console.log("Experiment file: " + this.experimentFile);
74 75 76 77
  }

  onChangeRunFile(files) {
    this.runFile = files[0];
78
    // console.log("Run file: " + this.runFile);
79 80
  }

Rasko Leinonen's avatar
Rasko Leinonen committed
81 82
  onChangeAnalysisFile(files) {
    this.analysisFile = files[0];
83
    // console.log("Analysis file: " + this.analysisFile);
Rasko Leinonen's avatar
Rasko Leinonen committed
84 85
  }

86 87
  onChangeDacFile(files) {
    this.dacFile = files[0];
88
    // console.log("Dac file: " + this.dacFile);
89 90 91 92
  }

  onChangePolicyFile(files) {
    this.policyFile = files[0];
93
    // console.log("Policy file: " + this.policyFile);
94 95 96 97
  }

  onChangeDatasetFile(files) {
    this.datasetFile = files[0];
98
    // console.log("Dataset file: " + this.datasetFile);
99 100 101
  }

  canSubmit() {
102
    return this.submissionFile ? true : false;
103 104 105
  }

  submit() {
rajkumar's avatar
rajkumar committed
106 107 108 109 110 111 112 113 114 115 116 117
    console.log("** Webin XML submission **");

    const observable: Observable<string> = this._webinRestService.submitXml(
      this.submissionFile,
      this.studyFile,
      this.projectFile,
      this.sampleFile,
      this.experimentFile,
      this.runFile,
      this.analysisFile,
      this.dacFile,
      this.policyFile,
Rajkumar-D's avatar
Rajkumar-D committed
118 119
      this.datasetFile,
      this.centerName
rajkumar's avatar
rajkumar committed
120
    );
121

122
    this.dialog.open(SubmissionResultDialogComponent, {
rajkumar's avatar
rajkumar committed
123 124
      width: "600px",
      data: { "observable": observable, "redirectPath": "/app-submit" },
125
    });
126
  }
Rajkumar-D's avatar
Rajkumar-D committed
127 128 129 130

  isBroker(): boolean {
    return this._webinAuthenticationService.isBroker();
  }
131
}