Skip to content
Snippets Groups Projects
test-data.service.ts 3 KiB
Newer Older
Janet Goldstein's avatar
Janet Goldstein committed
/*
 * Copyright (C) 2021 Associated Universities, Inc. Washington DC, USA.
 *
 * This file is part of NRAO Workspaces.
 *
 * Workspaces is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Workspaces is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Workspaces.  If not, see <https://www.gnu.org/licenses/>.
 */
import {Injectable} from '@angular/core';
import {Job} from '../workspaces/model/job';
import {User} from '../workspaces/model/user';
Janet Goldstein's avatar
Janet Goldstein committed
import {StorageService} from "./storage/storage.service";

@Injectable({
  providedIn: 'root'
})
export class TestDataService {

  constructor(private storage: StorageService) {
  }

  Init(): Promise<any> {
    return new Promise<void>((resolve) => {
Janet Goldstein's avatar
Janet Goldstein committed
      const users: Array<User> = [
        {name: 'Drew Medlin', email: 'dmedlin@nrao.edu', role: 'admin', id: 1},
        {name: 'Rachel Roberts', email: 'rroberts@nrao.edu', role: 'DA', id: 2},
        {name: 'Shelly Scientist', email: 'sscientist', role: 'AoD', id: 3},
        {name: 'Edward Starr', email: 'estarr@nrao.edu', role: 'DA', id: 4}
      ];
      this.storage.saveLocal("users", JSON.stringify(users));

      const jobs: Array<Job> = [
        {
          requestId: 1,
          currentVersion: 2,
          state: "Created",
Janet Goldstein's avatar
Janet Goldstein committed
          sdmId: "13B-014.sb12345.eb98765",
          obsDate: "2016-08-23",
          bands: ["C", "D", "B"],
          arrayConfiguration: "A",
          srdp: false,
        },
        {
          requestId: 2,
          currentVersion: 2,
          state: "Complete",
Janet Goldstein's avatar
Janet Goldstein committed
          sdmId: "14A-000.sb12345.eb98765",
          obsDate: "2016-11-01",
          bands: ["C"],
          arrayConfiguration: "A",
          srdp: false,
        },
        {
          requestId: 3,
          currentVersion: 1,
          state: "Submitted",
Janet Goldstein's avatar
Janet Goldstein committed
          sdmId: "13B-014.sb12345.eb98765",
          obsDate: "2016-08-23",
          bands: ["C", "D", "B"],
          arrayConfiguration: "A",
          srdp: false,
        },
        {
          requestId: 4,
          currentVersion: 3,
          state: "Cancelled",
Janet Goldstein's avatar
Janet Goldstein committed
          sdmId: "20A-465.sb34343.eb98765.23984239",
          obsDate: "2016-08-23",
          bands: ["C", "D", "B"],
          arrayConfiguration: "A",
          srdp: true,
        },
        {
          requestId: 5,
          currentVersion: 1,
          state: "Failed",
Janet Goldstein's avatar
Janet Goldstein committed
          sdmId: "19B-324.sb38254745.eb38257021.59004",
          obsDate: "2020-06-19",
          bands: ["D"],
          arrayConfiguration: "D",
          srdp: true,
        },

      ];

      this.storage.saveLocal("jobs", JSON.stringify(jobs));
      resolve();
    });
  }
}