metron-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nickal...@apache.org
Subject [1/9] metron git commit: METRON-1749 Update Angular to latest release in Management UI (sardell via nickwallen) closes apache/metron#1217
Date Wed, 14 Nov 2018 20:03:18 GMT
Repository: metron
Updated Branches:
  refs/heads/master 0e2a43484 -> 0c4c622b9


http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/app/shared/sample-data/sample-data.component.spec.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/app/shared/sample-data/sample-data.component.spec.ts
b/metron-interface/metron-config/src/app/shared/sample-data/sample-data.component.spec.ts
index 5488209..b8cdf1f 100644
--- a/metron-interface/metron-config/src/app/shared/sample-data/sample-data.component.spec.ts
+++ b/metron-interface/metron-config/src/app/shared/sample-data/sample-data.component.spec.ts
@@ -15,17 +15,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {async, TestBed, ComponentFixture} from '@angular/core/testing';
-import {KafkaService} from '../../service/kafka.service';
-import {Observable} from  'rxjs/Observable';
-import {SampleDataComponent} from './sample-data.component';
-import {SharedModule} from '../shared.module';
-import '../../rxjs-operators';
+import { async, TestBed, ComponentFixture } from '@angular/core/testing';
+import { KafkaService } from '../../service/kafka.service';
+import { Observable, throwError } from 'rxjs';
+import { SampleDataComponent } from './sample-data.component';
+import { SharedModule } from '../shared.module';
 
 class MockKafkaService {
   _sample: string[];
-  _sampleCounter: number = 0;
-
+  _sampleCounter = 0;
 
   public setSample(sampleMessages: string[]): void {
     this._sample = sampleMessages;
@@ -33,7 +31,6 @@ class MockKafkaService {
   }
 
   public sample(name: string): Observable<string> {
-
     if (this._sampleCounter < this._sample.length) {
       return Observable.create(observer => {
         observer.next(this._sample[this._sampleCounter++]);
@@ -41,7 +38,7 @@ class MockKafkaService {
       });
     }
 
-    return Observable.throw('Error');
+    return throwError('Error');
   }
 }
 
@@ -58,24 +55,21 @@ describe('SampleDataComponent', () => {
   beforeEach(async(() => {
     TestBed.configureTestingModule({
       imports: [SharedModule],
-      declarations: [ SampleDataComponent],
+      declarations: [SampleDataComponent],
       providers: [
         SampleDataComponent,
-        {provide: KafkaService, useClass: MockKafkaService}
+        { provide: KafkaService, useClass: MockKafkaService }
       ]
     });
-
     fixture = TestBed.createComponent(SampleDataComponent);
     sampleDataComponent = fixture.componentInstance;
-    kafkaService = fixture.debugElement.injector.get(KafkaService);
-
+    kafkaService = TestBed.get(KafkaService);
   }));
 
   it('can instantiate SampleDataComponent', async(() => {
     expect(sampleDataComponent instanceof SampleDataComponent).toBe(true);
   }));
 
-
   it('should emmit messages', async(() => {
     let expectedMessage;
     let successCount = 0;
@@ -140,11 +134,9 @@ describe('SampleDataComponent', () => {
     sampleDataComponent.getPreviousSample();
     expect(successCount).toEqual(7);
     expect(failureCount).toEqual(1);
-
   }));
 
   it('should emmit messages on blur', async(() => {
-
     let expectedMessage;
     let successCount = 0;
 
@@ -155,9 +147,10 @@ describe('SampleDataComponent', () => {
       expect(message).toEqual(expectedMessage);
     });
 
-
     expectedMessage = 'This is a simple message';
-    fixture.debugElement.nativeElement.querySelector('textarea').value = expectedMessage;
+    fixture.debugElement.nativeElement.querySelector(
+      'textarea'
+    ).value = expectedMessage;
     sampleDataComponent.onBlur();
 
     expect(successCount).toEqual(1);
@@ -165,16 +158,16 @@ describe('SampleDataComponent', () => {
     expect(sampleDataComponent.sampleData.length).toEqual(1);
     expect(sampleDataComponent.sampleData[0]).toEqual(expectedMessage);
 
-
     expectedMessage = '';
-    fixture.debugElement.nativeElement.querySelector('textarea').value = expectedMessage;
+    fixture.debugElement.nativeElement.querySelector(
+      'textarea'
+    ).value = expectedMessage;
     sampleDataComponent.onBlur();
 
     expect(successCount).toEqual(2);
     expect(sampleDataComponent.sampleDataIndex).toEqual(0);
     expect(sampleDataComponent.sampleData.length).toEqual(1);
 
-
     expectedMessage = sampleMessages[0];
     sampleDataComponent.getNextSample();
 
@@ -182,7 +175,5 @@ describe('SampleDataComponent', () => {
     expect(sampleDataComponent.sampleDataIndex).toEqual(1);
     expect(sampleDataComponent.sampleData.length).toEqual(2);
     expect(sampleDataComponent.sampleData[1]).toEqual(sampleMessages[0]);
-
   }));
-
 });

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/app/util/httpUtil.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/app/util/httpUtil.ts b/metron-interface/metron-config/src/app/util/httpUtil.ts
index dfcb61f..d8a21a5 100644
--- a/metron-interface/metron-config/src/app/util/httpUtil.ts
+++ b/metron-interface/metron-config/src/app/util/httpUtil.ts
@@ -15,34 +15,34 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {Response} from '@angular/http';
-import {Observable}     from 'rxjs/Observable';
-import {RestError} from '../model/rest-error';
+import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
+import { throwError, Observable } from 'rxjs';
 
-export class HttpUtil {
+import { RestError } from '../model/rest-error';
 
-  public static extractString(res: Response): string {
-    let text: string = res.text();
+export class HttpUtil {
+  public static extractString(res: HttpResponse<any>): string {
+    let text: string = res.toString();
     return text || '';
   }
 
-  public static extractData(res: Response): any {
-    let body = res.json();
+  public static extractData(res: HttpResponse<any>): any {
+    let body = res;
     return body || {};
   }
 
-  public static handleError(res: Response): Observable<RestError> {
+  public static handleError(res: HttpErrorResponse): Observable<RestError> {
     // In a real world app, we might use a remote logging infrastructure
     // We'd also dig deeper into the error to get a better message
     let restError: RestError;
     if (res.status === 401) {
       window.location.assign('/login?sessionExpired=true');
     } else if (res.status !== 404) {
-      restError = res.json();
+      restError = res;
     } else {
       restError = new RestError();
-      restError.responseCode = 404;
+      restError.status = 404;
     }
-    return Observable.throw(restError);
+    return throwError(restError);
   }
 }

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/app/util/httpUtils.spec.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/app/util/httpUtils.spec.ts b/metron-interface/metron-config/src/app/util/httpUtils.spec.ts
index ff1e39d..c2b0e6b 100644
--- a/metron-interface/metron-config/src/app/util/httpUtils.spec.ts
+++ b/metron-interface/metron-config/src/app/util/httpUtils.spec.ts
@@ -15,33 +15,52 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {HttpUtil} from './httpUtil';
-import {Response, ResponseOptions, ResponseType} from '@angular/http';
-import {Observable} from 'rxjs/Observable';
-import {RestError} from '../model/rest-error';
+import { HttpUtil } from './httpUtil';
+import { RestError } from '../model/rest-error';
+import { HttpErrorResponse } from '@angular/common/http';
+import { noop } from 'rxjs';
 
 describe('HttpUtil', () => {
-
   it('should create an instance', () => {
     expect(HttpUtil.handleError).toBeTruthy();
     expect(HttpUtil.extractString).toBeTruthy();
     expect(HttpUtil.extractData).toBeTruthy();
   });
 
-  it('should handleError', () => {
-    let error500: RestError = {message: 'This is error', responseCode: 500, fullMessage:
'This is error'};
-    let responseOptions = new ResponseOptions();
-    responseOptions.body = error500;
-    let response = new Response(responseOptions);
-    response.type = ResponseType.Basic;
-    expect(HttpUtil.handleError(response)).toEqual(Observable.throw(error500));
-
-    let error404 = new RestError();
-    error404.responseCode = 404;
-    response = new Response(new ResponseOptions());
-    response.type = ResponseType.Basic;
-    response.status = 404;
-    expect(HttpUtil.handleError(response)).toEqual(Observable.throw(error404));
+  it('should handleError 500', () => {
+    let error500: RestError = {
+      message: 'This is error',
+      status: 500,
+      error: 'This is error'
+    };
+    let response = new HttpErrorResponse(error500);
+    let httpUtilSub = HttpUtil.handleError(response).subscribe(
+      noop,
+      e => {
+        expect(e.status).toBe(500);
+        expect(e.message).toBe(
+          'Http failure response for (unknown url): 500 undefined'
+        );
+        expect(e.error).toBe('This is error');
+      },
+      noop
+    );
+    httpUtilSub.unsubscribe();
   });
 
+  it('should handleError 404', () => {
+    const error404 = new RestError();
+    error404.status = 404;
+    const response = new HttpErrorResponse(error404);
+    const httpUtilSub = HttpUtil.handleError(response).subscribe(
+      noop,
+      e => {
+        expect(e.status).toBe(404);
+        expect(e.message).toBe(undefined);
+        expect(e.error).toBe(undefined);
+      },
+      noop
+    );
+    httpUtilSub.unsubscribe();
+  });
 });

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.spec.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.spec.ts
b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.spec.ts
index 7be3ccd..432ec2b 100644
--- a/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.spec.ts
+++ b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.spec.ts
@@ -15,39 +15,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import {async, inject, TestBed} from '@angular/core/testing';
+import {TestBed} from '@angular/core/testing';
 import {Router} from '@angular/router';
 import {VerticalNavbarComponent} from './verticalnavbar.component';
 
 class MockRouter {
-  url: string = '';
+  url = '';
 }
 
 describe('VerticalNavbarComponent', () => {
-
-  beforeEach(async(() => {
+  let router: Router;
+  let verticalNavbarComponent: VerticalNavbarComponent;
+  beforeEach(() => {
     TestBed.configureTestingModule({
       providers: [
         VerticalNavbarComponent,
         {provide: Router, useClass: MockRouter}
       ]
-    }).compileComponents();
-
-  }));
+    });
+    verticalNavbarComponent = TestBed.get(VerticalNavbarComponent);
+  });
 
-  it('can instantiate VerticalNavbarComponent',
-    inject([VerticalNavbarComponent], (verticalNavbarComponent: VerticalNavbarComponent)
=> {
+  it('can instantiate VerticalNavbarComponent', () => {
       expect(verticalNavbarComponent instanceof VerticalNavbarComponent).toBe(true);
-  }));
-
-  it('check isActive for a URL VerticalNavbarComponent',
-    inject([VerticalNavbarComponent, Router], (component: VerticalNavbarComponent, router:
Router) => {
-
-      router.url = '/abc';
-      expect(component.isActive(['/def'])).toEqual(false);
-      expect(component.isActive(['/abc'])).toEqual(true);
-      expect(component.isActive(['/def', '/abc'])).toEqual(true);
-
-  }));
+  });
 
 });

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.ts
b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.ts
index 4067f6c..3425612 100644
--- a/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.ts
+++ b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.component.ts
@@ -29,7 +29,4 @@ export class VerticalNavbarComponent {
 
   constructor(private router: Router) {}
 
-  isActive(validRoutes: string[]) {
-    return validRoutes.indexOf(this.router.url) !== -1;
-  }
 }

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.html
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.html b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.html
index a4052b3..994711a 100644
--- a/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.html
+++ b/metron-interface/metron-config/src/app/verticalnavbar/verticalnavbar.html
@@ -19,10 +19,10 @@
 
   <ul class="nav">
     <li class="nav-item">
-      <a [routerLink]="['/sensors']"  class="nav-link" [ngClass]="{'active': isActive(['/',
'/sensors'])}" href="#">Sensors</a>
+      <a [routerLink]="['/sensors']"  class="nav-link" routerLinkActive="active" href="#">Sensors</a>
     </li>
     <li class="nav-item">
-      <a [routerLink]="['/general-settings']"  class="nav-link" [ngClass]="{'active':
isActive(['/general-settings'])}" href="#">General Settings</a>
+      <a [routerLink]="['/general-settings']"  class="nav-link" routerLinkActive="active"
href="#">General Settings</a>
     </li>
   </ul>
 

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/styles.scss
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/styles.scss b/metron-interface/metron-config/src/styles.scss
index db57e91..26bb57c 100644
--- a/metron-interface/metron-config/src/styles.scss
+++ b/metron-interface/metron-config/src/styles.scss
@@ -17,7 +17,7 @@
  */
 /* You can add global styles to this file, and also import other style files */
 @import "app/_variables.scss";
-@import "app/_main.scss";
+@import "app/_fonts.scss";
 
 $height: 60px;
 

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/test.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/test.ts b/metron-interface/metron-config/src/test.ts
index 347d245..606c810 100644
--- a/metron-interface/metron-config/src/test.ts
+++ b/metron-interface/metron-config/src/test.ts
@@ -15,50 +15,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-import './polyfills.ts';
 
-import 'zone.js/dist/long-stack-trace-zone';
-import 'zone.js/dist/proxy.js';
-import 'zone.js/dist/sync-test';
-import 'zone.js/dist/jasmine-patch';
-import 'zone.js/dist/async-test';
-import 'zone.js/dist/fake-async-test';
-
-import 'jquery/dist/jquery';
-import 'tether/dist/js/tether';
-
-import * as $ from 'jquery';
-window['$'] = window['jQuery'] = $;
-
-import  * as Tether from 'tether';
-window['Tether'] = Tether;
-
-import 'ace-builds/src-noconflict/ace.js';
-import 'bootstrap/dist/js/bootstrap';
-import 'bootstrap';
-
-// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
-declare var __karma__: any;
-declare var require: any;
-
-// Prevent Karma from running prematurely.
-__karma__.loaded = function () {};
-
-
-Promise.all([
-  System.import('@angular/core/testing'),
-  System.import('@angular/platform-browser-dynamic/testing')
-])
-  // First, initialize the Angular testing environment.
-  .then(([testing, testingBrowser]) => {
-    testing.getTestBed().initTestEnvironment(
-      testingBrowser.BrowserDynamicTestingModule,
-      testingBrowser.platformBrowserDynamicTesting()
-    );
-  })
-  // Then we find all the tests.
-  .then(() => require.context('./', true, /\.spec\.ts/))
-  // And load the modules.
-  .then(context => context.keys().map(context))
-  // Finally, start Karma to run the tests.
-  .then(__karma__.start, __karma__.error);
+// This file is required by karma.conf.js and loads recursively all the .spec and framework
files
+
+import 'zone.js/dist/zone-testing';
+import { getTestBed } from '@angular/core/testing';
+import {
+  BrowserDynamicTestingModule,
+  platformBrowserDynamicTesting
+} from '@angular/platform-browser-dynamic/testing';
+
+declare const require: any;
+
+// First, initialize the Angular testing environment.
+getTestBed().initTestEnvironment(
+  BrowserDynamicTestingModule,
+  platformBrowserDynamicTesting()
+);
+// Then we find all the tests.
+const context = require.context('./', true, /\.spec\.ts$/);
+// And load the modules.
+context.keys().map(context);

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/tsconfig.app.json
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/tsconfig.app.json b/metron-interface/metron-config/src/tsconfig.app.json
new file mode 100644
index 0000000..107b74d
--- /dev/null
+++ b/metron-interface/metron-config/src/tsconfig.app.json
@@ -0,0 +1,23 @@
+{
+  "extends": "../tsconfig.json",
+  "compilerOptions": {
+    "outDir": "../out-tsc/app",
+    "module": "es2015",
+    "baseUrl": "",
+    "types": [
+      "jquery",
+      "bootstrap",
+      "ace",
+      "node"
+    ],
+    "typeRoots": [ "../node_modules/@types" ]
+  },
+  "exclude": [
+    "test.ts",
+    "**/*.spec.ts"
+  ],
+  "angularCompilerOptions": {
+    "preserveWhitespaces": true
+  },
+}
+

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/tsconfig.json
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/tsconfig.json b/metron-interface/metron-config/src/tsconfig.json
deleted file mode 100644
index 65756e3..0000000
--- a/metron-interface/metron-config/src/tsconfig.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
-  "compilerOptions": {
-    "declaration": false,
-    "emitDecoratorMetadata": true,
-    "experimentalDecorators": true,
-    "lib": ["es6", "dom"],
-    "mapRoot": "./",
-    "module": "es6",
-    "moduleResolution": "node",
-    "outDir": "../dist/out-tsc",
-    "sourceMap": true,
-    "target": "es5",
-    "typeRoots": [
-      "../node_modules/@types"
-    ],
-    "types": [
-      "jasmine",
-      "jquery",
-      "bootstrap",
-      "ace"
-    ]
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/tsconfig.spec.json
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/tsconfig.spec.json b/metron-interface/metron-config/src/tsconfig.spec.json
new file mode 100644
index 0000000..eb43ad2
--- /dev/null
+++ b/metron-interface/metron-config/src/tsconfig.spec.json
@@ -0,0 +1,24 @@
+{
+    "extends": "../tsconfig.json",
+    "compilerOptions": {
+      "outDir": "../out-tsc/spec",
+      "module": "commonjs",
+      "target": "es5",
+      "baseUrl": "",
+      "types": [
+        "jquery",
+        "bootstrap",
+        "jasmine",
+        "node"
+      ],
+      "typeRoots": [ "../node_modules/@types" ]
+    },
+    "files": [
+      "test.ts",
+      "polyfills.ts"
+    ],
+    "include": [
+      "**/*.spec.ts",
+      "**/*.d.ts"
+    ]
+  }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/src/typings.d.ts
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/src/typings.d.ts b/metron-interface/metron-config/src/typings.d.ts
index c0aaf0c..75b5619e 100644
--- a/metron-interface/metron-config/src/typings.d.ts
+++ b/metron-interface/metron-config/src/typings.d.ts
@@ -20,4 +20,4 @@
 // https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html
 
 declare var System: any;
-declare var require: any;
+declare var require: NodeRequire;

http://git-wip-us.apache.org/repos/asf/metron/blob/0c4c622b/metron-interface/metron-config/tsconfig.json
----------------------------------------------------------------------
diff --git a/metron-interface/metron-config/tsconfig.json b/metron-interface/metron-config/tsconfig.json
new file mode 100644
index 0000000..1ca28d2
--- /dev/null
+++ b/metron-interface/metron-config/tsconfig.json
@@ -0,0 +1,20 @@
+{
+    "compileOnSave": false,
+    "compilerOptions": {
+      "outDir": "./dist/out-tsc",
+      "baseUrl": "src",
+      "sourceMap": true,
+      "declaration": false,
+      "moduleResolution": "node",
+      "emitDecoratorMetadata": true,
+      "experimentalDecorators": true,
+      "target": "es5",
+      "typeRoots": [
+        "node_modules/@types"
+      ],
+      "lib": [
+        "es2016",
+        "dom"
+      ]
+    }
+  }
\ No newline at end of file


Mime
View raw message