From c046cc89af93385d3dc5d12a754d88716cffa368 Mon Sep 17 00:00:00 2001 From: TINCU Sebastian-Ion <Sebastian-Ion.TINCU@ext.ec.europa.eu> Date: Thu, 27 Sep 2018 13:26:47 +0200 Subject: [PATCH] EDELIVERY-3762 Clean the smp-angular project from domibus object Remove ngOnInit where not required; add OnInit implementation where required. Use correct components in tests. --- smp-angular/src/app/alert/alert.component.ts | 4 ++-- smp-angular/src/app/alerts/alerts.component.ts | 4 ++-- .../common/cancel-dialog/cancel-dialog.component.ts | 7 ++----- .../common/column-picker/column-picker.component.ts | 7 ++----- .../save-dialog/save-dialog.component.spec.ts | 2 +- .../app/common/save-dialog/save-dialog.component.ts | 6 ++---- .../common/search-table/search-table.component.ts | 13 ++----------- .../src/app/custom-date/date-format.service.ts | 12 ++++++------ .../domain-details-dialog.component.ts | 8 ++------ smp-angular/src/app/domain/domain.component.ts | 4 ++-- .../default-password-dialog.component.ts | 7 ++----- .../src/app/security/is-authorized.directive.ts | 4 ++-- .../app/service-group/service-group.component.ts | 4 ++-- .../user-details-dialog.component.spec.ts | 12 ++++++------ smp-angular/src/app/user/user.component.ts | 4 ++-- 15 files changed, 37 insertions(+), 61 deletions(-) diff --git a/smp-angular/src/app/alert/alert.component.ts b/smp-angular/src/app/alert/alert.component.ts index 8819f7053..857369e2f 100644 --- a/smp-angular/src/app/alert/alert.component.ts +++ b/smp-angular/src/app/alert/alert.component.ts @@ -1,4 +1,4 @@ -import {Component} from "@angular/core"; +import {Component, OnInit} from "@angular/core"; import {AlertService} from "./alert.service"; @Component({ @@ -8,7 +8,7 @@ import {AlertService} from "./alert.service"; styleUrls: ['./alert.component.css'] }) -export class AlertComponent { +export class AlertComponent implements OnInit { message: any; public static readonly MAX_COUNT_CSV: number = 10000; diff --git a/smp-angular/src/app/alerts/alerts.component.ts b/smp-angular/src/app/alerts/alerts.component.ts index 9f256634b..bb6516a89 100644 --- a/smp-angular/src/app/alerts/alerts.component.ts +++ b/smp-angular/src/app/alerts/alerts.component.ts @@ -1,4 +1,4 @@ -import {Component, TemplateRef, ViewChild} from "@angular/core"; +import {Component, OnInit, TemplateRef, ViewChild} from "@angular/core"; import {ColumnPicker} from "../common/column-picker/column-picker.model"; import {RowLimiter} from "../common/row-limiter/row-limiter.model"; import {isNullOrUndefined} from "util"; @@ -18,7 +18,7 @@ import {SaveDialogComponent} from "../common/save-dialog/save-dialog.component"; templateUrl: './alerts.component.html' }) -export class AlertsComponent { +export class AlertsComponent implements OnInit { @ViewChild('rowProcessed') rowProcessed: TemplateRef<any>; diff --git a/smp-angular/src/app/common/cancel-dialog/cancel-dialog.component.ts b/smp-angular/src/app/common/cancel-dialog/cancel-dialog.component.ts index a3dbf4d5e..eab362124 100644 --- a/smp-angular/src/app/common/cancel-dialog/cancel-dialog.component.ts +++ b/smp-angular/src/app/common/cancel-dialog/cancel-dialog.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit} from '@angular/core'; +import {Component} from '@angular/core'; import {MdDialogRef} from "@angular/material"; @Component({ @@ -6,12 +6,9 @@ import {MdDialogRef} from "@angular/material"; templateUrl: './cancel-dialog.component.html', styleUrls: ['./cancel-dialog.component.css'] }) -export class CancelDialogComponent implements OnInit { +export class CancelDialogComponent { constructor(public dialogRef: MdDialogRef<CancelDialogComponent>) { } - ngOnInit() { - } - } diff --git a/smp-angular/src/app/common/column-picker/column-picker.component.ts b/smp-angular/src/app/common/column-picker/column-picker.component.ts index b2cc6e1a4..3b5c37bc8 100644 --- a/smp-angular/src/app/common/column-picker/column-picker.component.ts +++ b/smp-angular/src/app/common/column-picker/column-picker.component.ts @@ -1,11 +1,11 @@ -import {Component, EventEmitter, Input, OnInit, Output} from "@angular/core"; +import {Component, EventEmitter, Input, Output} from "@angular/core"; import {isNullOrUndefined} from "util"; @Component({ selector: 'app-column-picker', templateUrl: './column-picker.component.html' }) -export class ColumnPickerComponent implements OnInit { +export class ColumnPickerComponent { columnSelection: boolean; @@ -21,9 +21,6 @@ export class ColumnPickerComponent implements OnInit { constructor() { } - ngOnInit() { - } - toggleColumnSelection() { this.columnSelection = !this.columnSelection } diff --git a/smp-angular/src/app/common/save-dialog/save-dialog.component.spec.ts b/smp-angular/src/app/common/save-dialog/save-dialog.component.spec.ts index 2edb76189..0d3215f7c 100644 --- a/smp-angular/src/app/common/save-dialog/save-dialog.component.spec.ts +++ b/smp-angular/src/app/common/save-dialog/save-dialog.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { SaveDialogComponent } from './save-dialog.component'; -describe('ServicegroupExtensionDialogComponent', () => { +describe('SaveDialogComponent', () => { let component: SaveDialogComponent; let fixture: ComponentFixture<SaveDialogComponent>; diff --git a/smp-angular/src/app/common/save-dialog/save-dialog.component.ts b/smp-angular/src/app/common/save-dialog/save-dialog.component.ts index c9b2c888c..1c098b491 100644 --- a/smp-angular/src/app/common/save-dialog/save-dialog.component.ts +++ b/smp-angular/src/app/common/save-dialog/save-dialog.component.ts @@ -1,16 +1,14 @@ -import {Component, OnInit} from '@angular/core'; +import {Component} from '@angular/core'; import {MdDialogRef} from "@angular/material"; @Component({ selector: 'app-messagefilter-dialog', templateUrl: './save-dialog.component.html' }) -export class SaveDialogComponent implements OnInit { +export class SaveDialogComponent { constructor(public dialogRef: MdDialogRef<SaveDialogComponent>) { } - ngOnInit() { - } } diff --git a/smp-angular/src/app/common/search-table/search-table.component.ts b/smp-angular/src/app/common/search-table/search-table.component.ts index 6cba1fa59..294f8b26b 100644 --- a/smp-angular/src/app/common/search-table/search-table.component.ts +++ b/smp-angular/src/app/common/search-table/search-table.component.ts @@ -1,4 +1,4 @@ -import {Component, EventEmitter, Input, TemplateRef, ViewChild} from "@angular/core"; +import {Component, EventEmitter, Input, OnInit, TemplateRef, ViewChild} from "@angular/core"; import {Http, URLSearchParams, Response} from "@angular/http"; import {SearchTableResult} from "./search-table-result.model"; import {Observable} from "rxjs"; @@ -15,15 +15,12 @@ import {SearchTableController} from "./search-table-controller"; styleUrls: ['./search-table.component.css'] }) -export class SearchTableComponent { +export class SearchTableComponent implements OnInit { @ViewChild('rowActions') rowActions: TemplateRef<any>; @Input() @ViewChild('additionalToolButtons') additionalToolButtons: TemplateRef<any>; @Input() @ViewChild('searchPanel') searchPanel: TemplateRef<any>; - - - @Input() id: String = ""; @Input() title: String = ""; @Input() columnPicker: ColumnPicker; @@ -31,16 +28,12 @@ export class SearchTableComponent { @Input() searchTableController: SearchTableController; @Input() filter: any = {}; - - columnActions:any; rowLimiter: RowLimiter = new RowLimiter(); selected = []; - - loading: boolean = false; rows = []; count: number = 0; @@ -52,14 +45,12 @@ export class SearchTableComponent { msgStatus: Array<String>; - messageResent = new EventEmitter(false); constructor(protected http: Http, protected alertService: AlertService, public dialog: MdDialog) { } ngOnInit() { - this.columnActions = { cellTemplate: this.rowActions, name: 'Actions', diff --git a/smp-angular/src/app/custom-date/date-format.service.ts b/smp-angular/src/app/custom-date/date-format.service.ts index e6791c5bd..9f61abcd5 100644 --- a/smp-angular/src/app/custom-date/date-format.service.ts +++ b/smp-angular/src/app/custom-date/date-format.service.ts @@ -3,19 +3,19 @@ import {Injectable} from "@angular/core"; @Injectable() export class DateFormatService { - private static getFormattedDate(date: Date): string { + format(date: Date): string { + return this.getFormattedDate(date) + "_" + this.getFormattedTime(date); + } + + private getFormattedDate(date: Date): string { return ("0" + date.getDate()).slice(-2).toString()+"-"+ ("0" + (date.getMonth() + 1)).slice(-2).toString()+"-"+ date.getFullYear().toString(); } - private static getFormattedTime(date: Date): string { + private getFormattedTime(date: Date): string { return ("0" + date.getHours()).slice(-2).toString()+"h"+ ("0" + date.getMinutes()).slice(-2).toString()+"m"+ ("0" + date.getSeconds()).slice(-2).toString(); } - - static format(date: Date): string { - return this.getFormattedDate(date) + "_" + this.getFormattedTime(date); - } } diff --git a/smp-angular/src/app/domain/domain-details-dialog/domain-details-dialog.component.ts b/smp-angular/src/app/domain/domain-details-dialog/domain-details-dialog.component.ts index 44ad2ac8e..7058eab9c 100644 --- a/smp-angular/src/app/domain/domain-details-dialog/domain-details-dialog.component.ts +++ b/smp-angular/src/app/domain/domain-details-dialog/domain-details-dialog.component.ts @@ -1,19 +1,15 @@ -import {Component, OnInit} from '@angular/core'; +import {Component} from '@angular/core'; import {MdDialogRef} from "@angular/material"; @Component({ selector: 'domain-details-dialog', templateUrl: './domain-details-dialog.component.html' }) -export class DomainDetailsDialogComponent implements OnInit { +export class DomainDetailsDialogComponent { domain; dateFormat: String = 'yyyy-MM-dd HH:mm:ssZ'; constructor(public dialogRef: MdDialogRef<DomainDetailsDialogComponent>) { } - - ngOnInit() { - } - } diff --git a/smp-angular/src/app/domain/domain.component.ts b/smp-angular/src/app/domain/domain.component.ts index 008116839..9127f08ba 100644 --- a/smp-angular/src/app/domain/domain.component.ts +++ b/smp-angular/src/app/domain/domain.component.ts @@ -1,4 +1,4 @@ -import {Component, TemplateRef, ViewChild} from "@angular/core"; +import {Component, OnInit, TemplateRef, ViewChild} from "@angular/core"; import {ColumnPicker} from "../common/column-picker/column-picker.model"; import {MdDialog, MdDialogRef} from "@angular/material"; @@ -11,7 +11,7 @@ import {DomainController} from "./domain-controller"; templateUrl:'./domain.component.html', styleUrls: ['./domain.component.css'] }) -export class DomainComponent { +export class DomainComponent implements OnInit { @ViewChild('rowMetadataAction') rowMetadataAction: TemplateRef<any>; @ViewChild('rowExtensionAction') rowExtensionAction: TemplateRef<any>; diff --git a/smp-angular/src/app/security/default-password-dialog/default-password-dialog.component.ts b/smp-angular/src/app/security/default-password-dialog/default-password-dialog.component.ts index a2519a804..24e50370b 100644 --- a/smp-angular/src/app/security/default-password-dialog/default-password-dialog.component.ts +++ b/smp-angular/src/app/security/default-password-dialog/default-password-dialog.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit} from "@angular/core"; +import {Component} from "@angular/core"; import {MdDialogRef} from "@angular/material"; @Component({ @@ -6,11 +6,8 @@ import {MdDialogRef} from "@angular/material"; templateUrl: './default-password-dialog.component.html', styleUrls: ['./default-password-dialog.component.css'] }) -export class DefaultPasswordDialogComponent implements OnInit { +export class DefaultPasswordDialogComponent { constructor(public dialogRef: MdDialogRef<DefaultPasswordDialogComponent>) { } - ngOnInit() { - } - } diff --git a/smp-angular/src/app/security/is-authorized.directive.ts b/smp-angular/src/app/security/is-authorized.directive.ts index b53cccf91..1fbe813d9 100644 --- a/smp-angular/src/app/security/is-authorized.directive.ts +++ b/smp-angular/src/app/security/is-authorized.directive.ts @@ -1,10 +1,10 @@ -import {Directive,ElementRef,Input} from '@angular/core'; +import {Directive, ElementRef, Input, OnInit} from '@angular/core'; import {SecurityService} from './security.service'; @Directive({ selector:'[isAuthorized]' }) -export class IsAuthorized { +export class IsAuthorized implements OnInit { @Input('isAuthorized') role:string; constructor(private _elementRef:ElementRef, private securityService:SecurityService) { } diff --git a/smp-angular/src/app/service-group/service-group.component.ts b/smp-angular/src/app/service-group/service-group.component.ts index 6e13170d3..051c7ca7f 100644 --- a/smp-angular/src/app/service-group/service-group.component.ts +++ b/smp-angular/src/app/service-group/service-group.component.ts @@ -1,4 +1,4 @@ -import {Component, TemplateRef, ViewChild} from "@angular/core"; +import {Component, OnInit, TemplateRef, ViewChild} from "@angular/core"; import {ColumnPicker} from "../common/column-picker/column-picker.model"; import {MdDialog, MdDialogRef} from "@angular/material"; import {ServiceGroupDetailsDialogComponent} from "./service-group-details-dialog/service-group-details-dialog.component"; @@ -11,7 +11,7 @@ import {ServiceGroupController} from "./service-group-controller"; templateUrl:'./service-group.component.html', styleUrls: ['./service-group.component.css'] }) -export class ServiceGroupComponent { +export class ServiceGroupComponent implements OnInit { @ViewChild('rowMetadataAction') rowMetadataAction: TemplateRef<any> @ViewChild('rowExtensionAction') rowExtensionAction: TemplateRef<any> diff --git a/smp-angular/src/app/user/user-details-dialog/user-details-dialog.component.spec.ts b/smp-angular/src/app/user/user-details-dialog/user-details-dialog.component.spec.ts index 634a222ca..001878158 100644 --- a/smp-angular/src/app/user/user-details-dialog/user-details-dialog.component.spec.ts +++ b/smp-angular/src/app/user/user-details-dialog/user-details-dialog.component.spec.ts @@ -1,20 +1,20 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { ServicegroupDetailsDialogComponent } from './servicegroup-details-dialog.component'; +import {UserDetailsDialogComponent} from './user-details-dialog.component'; -describe('ServiceGroupDetailsDialogComponent', () => { - let component: ServicegroupDetailsDialogComponent; - let fixture: ComponentFixture<ServicegroupDetailsDialogComponent>; +describe('UserDetailsDialogComponent', () => { + let component: UserDetailsDialogComponent; + let fixture: ComponentFixture<UserDetailsDialogComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ ServicegroupDetailsDialogComponent ] + declarations: [ UserDetailsDialogComponent ] }) .compileComponents(); })); beforeEach(() => { - fixture = TestBed.createComponent(ServicegroupDetailsDialogComponent); + fixture = TestBed.createComponent(UserDetailsDialogComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/smp-angular/src/app/user/user.component.ts b/smp-angular/src/app/user/user.component.ts index 7df94f310..bcac77b2b 100644 --- a/smp-angular/src/app/user/user.component.ts +++ b/smp-angular/src/app/user/user.component.ts @@ -1,4 +1,4 @@ -import {Component, TemplateRef, ViewChild} from "@angular/core"; +import {Component, OnInit, TemplateRef, ViewChild} from "@angular/core"; import {ColumnPicker} from "../common/column-picker/column-picker.model"; import {MdDialog, MdDialogRef} from "@angular/material"; @@ -11,7 +11,7 @@ import {UserController} from "./user-controller"; templateUrl:'./user.component.html', styleUrls: ['./user.component.css'] }) -export class UserComponent { +export class UserComponent implements OnInit { @ViewChild('rowMetadataAction') rowMetadataAction: TemplateRef<any> @ViewChild('rowExtensionAction') rowExtensionAction: TemplateRef<any> -- GitLab