Skip to content
Permalink
Browse files
upgrade helix-front from Angular 5.1 to 5.2 (#2108)
Incremental progress towards the goal of upgrading helix-front to the current version of Angular.
  • Loading branch information
micahstubbs committed May 26, 2022
1 parent c46a70f commit f76509a4f90d037eb29c751deb6f1135f2fea485
Show file tree
Hide file tree
Showing 19 changed files with 179 additions and 190 deletions.
@@ -1,7 +1,7 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';

import { Angulartics2Module, Angulartics2Piwik } from 'angulartics2';

@@ -26,7 +26,7 @@ import { DashboardModule } from './dashboard/dashboard.module';
imports: [
BrowserModule,
FormsModule,
HttpModule,
HttpClientModule,
AppRoutingModule,
Angulartics2Module.forRoot([ Angulartics2Piwik ]),
CoreModule,
@@ -1,6 +1,6 @@
import { TestBed, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';

import { ChooserService } from './chooser.service';

@@ -9,7 +9,7 @@ describe('ChooserService', () => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule,
HttpModule
HttpClientModule
],
providers: [ChooserService]
});
@@ -1,6 +1,6 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';

import { SharedModule } from '../shared/shared.module';
import { ClusterService } from './shared/cluster.service';
@@ -12,7 +12,7 @@ import { ClusterComponent } from './cluster.component';
@NgModule({
imports: [
CommonModule,
HttpModule,
HttpClientModule,
SharedModule
],
declarations: [
@@ -1,13 +1,13 @@
import { TestBed, inject } from '@angular/core/testing';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { ClusterService } from './cluster.service';

describe('ClusterService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, RouterTestingModule],
imports: [HttpClientModule, RouterTestingModule],
providers: [ClusterService]
});
});
@@ -1,13 +1,13 @@
import { TestBed, inject } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';

import { ConfigurationService } from './configuration.service';

describe('ConfigurationService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, RouterTestingModule],
imports: [HttpClientModule, RouterTestingModule],
providers: [ConfigurationService]
});
});
@@ -1,6 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { ControllerDetailComponent } from './controller-detail.component';
@@ -12,7 +12,7 @@ describe('ControllerDetailComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpModule,
HttpClientModule,
RouterTestingModule
],
declarations: [ ControllerDetailComponent ],
@@ -1,13 +1,13 @@
import { TestBed, inject } from '@angular/core/testing';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { ControllerService } from './controller.service';

describe('ControllerService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, RouterTestingModule],
imports: [HttpClientModule, RouterTestingModule],
providers: [ControllerService]
});
});
@@ -1,13 +1,13 @@
import { TestBed, inject } from '@angular/core/testing';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { HelixService } from './helix.service';

describe('HelixService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, RouterTestingModule],
imports: [HttpClientModule, RouterTestingModule],
providers: [HelixService]
});
});
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';
import { HttpHeaders, HttpClient, HttpResponse } from '@angular/common/http';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';

@@ -10,13 +10,12 @@ export class HelixService {

constructor(
protected router: Router,
private http: Http
private http: HttpClient
) { }

public can(): Observable<boolean> {
return this.http
.get(`${ Settings.userAPI }/can`, { headers: this.getHeaders() })
.map(response => response.json())
.catch(this.errorHandler);
}

@@ -31,7 +30,6 @@ export class HelixService {
`${Settings.helixAPI}${helix}${path}`,
{ headers: this.getHeaders() }
)
.map(response => response.json())
.catch(this.errorHandler);
}

@@ -42,7 +40,6 @@ export class HelixService {
data,
{ headers: this.getHeaders() }
)
.map(response => response.text().trim() ? response.json() : '{}')
.catch(this.errorHandler);
}

@@ -53,7 +50,6 @@ export class HelixService {
data,
{ headers: this.getHeaders() }
)
.map(response => response.text().trim() ? response.json() : '{}')
.catch(this.errorHandler);
}

@@ -63,7 +59,6 @@ export class HelixService {
`${Settings.helixAPI}${this.getHelixKey()}${path}`,
{ headers: this.getHeaders() }
)
.map(response => response.text().trim() ? response.json() : '{}')
.catch(this.errorHandler);
}

@@ -73,7 +68,7 @@ export class HelixService {
}

protected getHeaders() {
let headers = new Headers();
let headers = new HttpHeaders();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json');
return headers;
@@ -84,12 +79,12 @@ export class HelixService {

let message = error.message || 'Cannot reach Helix restful service.';

if (error instanceof Response) {
if (error instanceof HttpResponse) {
if (error.status == 404) {
// rest api throws 404 directly to app without any wrapper
message = 'Not Found';
} else {
message = error.text();
message = error;
try {
message = JSON.parse(message).error;
} catch (e) {}
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { Headers, Http, Response } from '@angular/http';
import { HttpHeaders, HttpClient, HttpResponse } from '@angular/common/http';
import { Router } from '@angular/router';
import { Observable } from 'rxjs/Rx';

@@ -10,28 +10,26 @@ export class UserService {

constructor(
protected router: Router,
private http: Http
private http: HttpClient
) { }

public getCurrentUser(): Observable<string> {
public getCurrentUser(): Observable<string | object> {
return this.http
.get(`${ Settings.userAPI }/current`, { headers: this.getHeaders() })
.map(response => response.json())
.catch(_ => _);
}

public login(username: string, password: string): Observable<boolean> {
public login(username: string, password: string): Observable<object> {
return this.http
.post(
`${ Settings.userAPI }/login`,
{ username: username, password: password },
{ headers: this.getHeaders() }
)
.map(response => response.json());
);
}

protected getHeaders() {
let headers = new Headers();
let headers = new HttpHeaders();
headers.append('Accept', 'application/json');
headers.append('Content-Type', 'application/json');
return headers;
@@ -1,6 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { HistoryListComponent } from './history-list.component';
@@ -12,7 +12,7 @@ describe('HistoryListComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpModule,
HttpClientModule,
RouterTestingModule
],
declarations: [ HistoryListComponent ],
@@ -1,13 +1,13 @@
import { TestBed, inject } from '@angular/core/testing';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { HistoryService } from './history.service';

describe('HistoryService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, RouterTestingModule],
imports: [HttpClientModule, RouterTestingModule],
providers: [HistoryService]
});
});
@@ -1,13 +1,13 @@
import { TestBed, inject } from '@angular/core/testing';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { InstanceService } from './instance.service';

describe('InstanceService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, RouterTestingModule],
imports: [HttpClientModule, RouterTestingModule],
providers: [InstanceService]
});
});
@@ -1,6 +1,6 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { ResourceService } from '../shared/resource.service';
@@ -12,7 +12,7 @@ describe('ResourceDetailForInstanceComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ HttpModule, RouterTestingModule ],
imports: [ HttpClientModule, RouterTestingModule ],
declarations: [ ResourceDetailForInstanceComponent ],
schemas: [
/* avoid importing modules */
@@ -1,13 +1,13 @@
import { TestBed, inject } from '@angular/core/testing';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';

import { ResourceService } from './resource.service';

describe('ResourceService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpModule, RouterTestingModule],
imports: [HttpClientModule, RouterTestingModule],
providers: [ResourceService]
});
});
@@ -4,15 +4,15 @@ import { RouterTestingModule } from '@angular/router/testing';

import { WorkflowListComponent } from './workflow-list.component';
import { WorkflowService } from '../shared/workflow.service';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';

describe('WorkflowListComponent', () => {
let component: WorkflowListComponent;
let fixture: ComponentFixture<WorkflowListComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ HttpModule, RouterTestingModule ],
imports: [ HttpClientModule, RouterTestingModule ],
declarations: [ WorkflowListComponent ],
providers: [ WorkflowService ],
schemas: [
@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { HttpClientModule } from '@angular/common/http';
import { MaterialModule } from '../app/shared/material.module';
import { RouterTestingModule } from '@angular/router/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
@@ -9,7 +9,7 @@ import { HelperServiceStub } from './stubs';

@NgModule({
imports: [
HttpModule,
HttpClientModule,
MaterialModule,
RouterTestingModule,
NoopAnimationsModule
@@ -21,7 +21,7 @@ import { HelperServiceStub } from './stubs';
}
],
exports: [
HttpModule,
HttpClientModule,
MaterialModule,
RouterTestingModule,
NoopAnimationsModule

0 comments on commit f76509a

Please sign in to comment.