global.ts 3.77 KB
import { CsvService } from "angular2-json2csv";
import { Injectable, Inject } from '@angular/core';
@Injectable()
export class GlobalService {
  userUrl: string = "";
  resourceBaseUrl: string = ""; 
  hostURL: string = "";
  LocalURL: string = "";
  LiveURL: string = "";
  LiveAPIURL: string = "";
  QAAPIURL: string = "";  
  UserId: number = 0;
  UserType: number =0;
  AccountType: number = 0;
  loggedInUser: any;
  NoRecords: string;
  ValidationMsg: string;
  constructor(private csvService:CsvService) {
    this.hostURL = "http://192.168.84.242:97/";
    this.LiveAPIURL = "http://beta.interactiveanatomy.com/API/Adminapi/";
    this.QAAPIURL = "http://qa.beta.interactiveanatomy.com/API/Adminapi/";    
    this.LocalURL = "http://localhost:4200";
   //this.resourceBaseUrl = this.hostURL;
    //this.resourceBaseUrl = this.LiveAPIURL;
     this.resourceBaseUrl = this.QAAPIURL;
    if (this.resourceBaseUrl == "http://192.168.84.242:97/") {
      localStorage.setItem('loggedInUserDetails', JSON.stringify(
        {
          "Id": 1, "FirstName": "Maribel", "LastName": "sfsfsfsfsfsfs", "EmailId": "ravi.vishwakarma@ebix.com", "LoginId": "superadmin", "Password": "ebix@2016", "SecurityQuestionId": 1, "SecurityAnswer": "boxer", "CreatorId": 1, "CreationDate": "2009-03-02T00:00:00", "DeactivationDate": null, "ModifierId": 1, "ModifiedDate": "2017-01-24T02:03:19", "UserType": "Super Admin", "UserTypeId": 1, "IsActive": true, "IsCorrectPassword": false, "IncorrectLoginAttemptCount": 0, "IsBlocked": false, "LicenseId": 0, "EditionId": 0, "LoginFailureCauseId": 0, "Modules": [{ "slug": "da-view-list", "name": "Dissectible Anatomy", "id": 1 }, { "slug": "tile-view-list", "name": "Atlas Anatomy", "id": 2 }, { "slug": "3d-anatomy-list", "name": "3D Anatomy", "id": 3 }, { "slug": "clinical-illustrations", "name": "Clinical Illustrations", "id": 4 }, { "slug": "clinical-animations", "name": "Clinical Animations", "id": 5 }, { "slug": "Link/encyclopedia", "name": "Encyclopedia", "id": 6 }, { "slug": "curriculum-builder", "name": "Curriculum Builder", "id": 7 }, { "slug": "anatomy-test", "name": "Anatomy Test", "id": 8 }, { "slug": "Link/IP-10", "name": "IP 10", "id": 9 }, { "slug": "lab-exercises", "name": "Lab Exercises", "id": 10 }, { "slug": "Link/indepth-reports", "name": "In-Depth Reports", "id": 11 }, { "slug": "Link/complementary-and-alternate-medicine", "name": "CAM", "id": 12 }, { "slug": "ADAM-images", "name": "A.D.A.M. Images", "id": 13 }, { "slug": "Link/bodyguide", "name": "Body Guide", "id": 14 }, { "slug": "Link/health-navigator", "name": "Symptom Navigator", "id": 15 }, { "slug": "Link/wellness-tools", "name": "The Wellness Tools", "id": 16 }, { "slug": "Link/aod", "name": "A.D.A.M. OnDemand", "id": 1017 }], "LicenseInfo": null, "LicenseSubscriptions": null, "IsSubscriptionExpired": false, "SubscriptionExpirationDate": null, "TermsAndConditionsTitle": null, "TermsAndConditionsText": null
        }));      
    }
    else if (this.resourceBaseUrl == "http://beta.interactiveanatomy.com/API/Adminapi/") {
      this.LiveURL = "http://beta.interactiveanatomy.com";
    }
    else if (this.resourceBaseUrl == "http://qa.beta.interactiveanatomy.com/API/Adminapi/") {
      this.LiveURL = "http://qa.beta.interactiveanatomy.com";
    }
    this.loggedInUser = JSON.parse(localStorage.getItem("loggedInUserDetails")); 
    this.UserId = this.loggedInUser.Id;
    this.UserType = this.loggedInUser.UserTypeId;
    this.NoRecords = 'No records founds.';
  }
  compareTwoDates(todate: string, fromdate: string) {
    debugger;
    if (new Date(todate) < new Date(fromdate)) {
      this.ValidationMsg = 'The end date should be greater than the start date.'
    }
    else {
      this.ValidationMsg = '';
    }
  }

  ExportToCSV(data: any, FileName: string) {
    this.csvService.download(data, FileName);
  }

}