Merge branch 'DEVELOP_FE' of ssh://git.eclipse.org/gitroot/elogbook/elogbookFE into DEVELOP_FE_MESSAGE_BANNER_REFAC
# Conflicts:
# src/app/app.component.ts
# src/app/app.module.ts
# src/app/services/base-http.service.ts
# src/app/services/import.service.ts
diff --git a/package.json b/package.json
index 769b425..9a3a914 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"angular-cli": {},
"scripts": {
"ng": "ng",
- "start": "ng serve --sourcemap --proxy-config proxy.conf.json",
+ "start": "ng serve --sourcemap --proxy-config proxy.conf.json --port 4200",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
@@ -13,7 +13,7 @@
"e2e": "protractor",
"posttest": "node_modules/.bin/remap-istanbul -i coverage/coverage-final.json -o coverage -t html",
"coverage": "ng test --code-coverage --single-run",
- "cc": "ng test --code-coverage --single-run"
+ "cc": "ng test --port 4200 --code-coverage --single-run"
},
"private": true,
"dependencies": {
@@ -28,6 +28,8 @@
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@types/jquery": "^2.0.41",
+ "angular-oauth2-oidc": "^1.0.20",
+ "angular2-jwt": "^0.2.3",
"angular2-uuid": "^1.1.1",
"bootstrap": "^3.3.7",
"classlist.js": "^1.1.20150312",
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index 534888a..d4c2335 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -1,8 +1,15 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
+import { Http } from '@angular/http';
+import { Observable } from 'rxjs/Observable';
+import 'rxjs/add/operator/catch';
+import 'rxjs/add/operator/map';
+import 'rxjs/add/observable/throw';
+import { SessionContext } from './common/session-context';
+import { OAuthService } from 'angular-oauth2-oidc';
+import { Globals } from './common/globals';
import { BaseDataLoaderService } from './services/jobs/base-data-loader.service';
import { ReminderCallerJobService } from './services/jobs/reminder-caller-job.service';
-import { SessionContext } from './common/session-context';
import { ImportFileCallerService } from './services/jobs/import-file-caller.service';
import { HttpResponseInterceptorService } from './services/http-response-interceptor.service';
@@ -18,15 +25,24 @@
title = 'app works!';
private bannerMessageStatus = BannerMessageStatusEn;
- constructor(public router: Router,
+ constructor(private http: Http, public router: Router,
public baseDataLoader: BaseDataLoaderService,
public httpInterceptor: HttpResponseInterceptorService,
private sessionContext: SessionContext,
public reminderCallerJobService: ReminderCallerJobService,
public importFileCallerService: ImportFileCallerService) {
+
+ this.http.get('assets/settings.json')
+ .subscribe(res => this.sessionContext.settings = res.json());
+
+ this.sessionContext.centralHttpResultCode$.subscribe(rc => {
+ this.onRcFromHttpService(rc);
+ });
+
}
ngOnInit() {
+ /*
const self = this;
window.onload = function () {
if (!self.sessionContext.getCurrUser()) {
@@ -35,6 +51,12 @@
return '';
};
+*/ }
+
+ private onRcFromHttpService(rc: number): void {
+ if (rc === 401) {
+ this.router.navigate(['/login']);
+ }
}
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 2105835..1cc3e9f 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -40,6 +40,7 @@
import { Injectable } from '@angular/core';
import { BaseRequestOptions, Headers } from '@angular/http';
import { RequestOptions, Request, RequestMethod } from '@angular/http';
+import { AlertComponent } from './dialogs/alert/alert.component';
import { FilterComponent } from './filter/filter.component';
import { AutocompleteComponent } from './common-components/autocomplete/autocomplete.component';
import { MainNavigationComponent } from './common-components/main-navigation/main-navigation.component';
@@ -73,6 +74,7 @@
SearchComponent,
ShiftChangeProtocolComponent,
LogoutComponent,
+ AlertComponent,
VersionInfoComponent,
StringToDatePipe,
FormattedDatePipe,
@@ -110,7 +112,8 @@
ShiftChangeComponent,
ShiftChangeProtocolComponent,
LogoutComponent,
- LoadingSpinnerComponent
+ LoadingSpinnerComponent,
+ AlertComponent
],
providers: [
NotificationService,
@@ -128,8 +131,7 @@
MessageService,
BaseDataLoaderService,
ImportService,
- HttpResponseInterceptorService
- ],
+ HttpResponseInterceptorService ],
bootstrap: [AppComponent]
})
export class AppModule { }
diff --git a/src/app/common-components/main-navigation/main-navigation.component.html b/src/app/common-components/main-navigation/main-navigation.component.html
index f85fc2d..22d84a0 100644
--- a/src/app/common-components/main-navigation/main-navigation.component.html
+++ b/src/app/common-components/main-navigation/main-navigation.component.html
@@ -32,6 +32,11 @@
<span class="glyphicon glyphicon glyphicon-time" [ngClass]="{'active-navitem': router.url === '/shiftChangeOverview'}"></span>
</button>
</div>
+ <div class="btn btn-link navbar-btn">
+ <a href="{{sessionContext.settings?.HELPURL}}" title="Hilfe" target="_blank">
+ <span class="glyphicon glyphicon-question-sign"></span>
+ </a>
+ </div>
<div class="nav-overview-user">
<a class="dropdown-open dropdown-toggle " data-toggle="dropdown" href="#" aria-expanded="true">
{{sessionContext.getCurrUser()?.name}}<span class="caret"></span>
diff --git a/src/app/common-components/main-navigation/main-navigation.component.spec.ts b/src/app/common-components/main-navigation/main-navigation.component.spec.ts
index 29c4aa7..678a533 100644
--- a/src/app/common-components/main-navigation/main-navigation.component.spec.ts
+++ b/src/app/common-components/main-navigation/main-navigation.component.spec.ts
@@ -66,8 +66,9 @@
expect(routerStub.navigate).toHaveBeenCalledWith(['/overview']);
});
- xit('should open the filter on click on the filter button', () => {
+ it('should open the filter on click on the filter button', () => {
//WIP
+ /*
component.goToOverview();
fixture.detectChanges(); // update view with array
@@ -76,6 +77,7 @@
const des = fixture.debugElement.queryAll(By.css('button'));
click(des[0]);
});
+ */
});
it('should navigate to search on search-button click', () => {
diff --git a/src/app/common/globals.ts b/src/app/common/globals.ts
index 902caf5..edd963a 100644
--- a/src/app/common/globals.ts
+++ b/src/app/common/globals.ts
@@ -25,7 +25,15 @@
static COLLAPSE_STATE_PAST = 'COLLAPSE_STATE_PAST';
static COLLAPSE_STATE_FUTURE = 'COLLAPSE_STATE_FUTURE';
static LOCALSTORAGE_SESSION_ID = '/elogbook/session-id';
- static REMINDER_JOB_POLLING_INTERVALL = 60000;
+
+ static OAUTH2CONF_LOGOUT_URL = 'http://entjava002:8080/auth/realms/elogbook/' +
+ 'protocol/openid-connect/logout?post_logout_redirect_uri=';
+ static OAUTH2CONF_CLIENTID = 'elogbook-backend-fd';
+ static OAUTH2CONF_SUPERUSER_ROLE = 'elogbook-superuser';
+
+ static REMINDER_JOB_POLLING_INTERVALL = 8000;
static REMINDER_JOB_POLLING_START_DELAY = 2000;
+ static IMPORT_JOB_POLLING_INTERVALL = 8000;
+ static IMPORT_JOB_POLLING_START_DELAY = 2000;
static SORTING_STATE = 'SORTING_STATE';
}
diff --git a/src/app/common/session-context.ts b/src/app/common/session-context.ts
index 74e8097..3aac155 100644
--- a/src/app/common/session-context.ts
+++ b/src/app/common/session-context.ts
@@ -1,4 +1,5 @@
-import { Injectable } from '@angular/core';
+import { Injectable, EventEmitter } from '@angular/core';
+import { OAuthService } from 'angular-oauth2-oidc';
import { User } from '../model/user';
import { Branch } from '../model/branch';
import { GridTerritory } from '../model/gridterritory';
@@ -15,6 +16,9 @@
@Injectable()
export class SessionContext {
+ public oauthService: OAuthService;
+ public centralHttpResultCode$: EventEmitter<number> = new EventEmitter<number>();
+ public settings;
private currUser: User = null;
private statuses: Status[];
private branches: Branch[];
diff --git a/src/app/dialogs/alert/alert.component.css b/src/app/dialogs/alert/alert.component.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/app/dialogs/alert/alert.component.css
diff --git a/src/app/dialogs/alert/alert.component.html b/src/app/dialogs/alert/alert.component.html
new file mode 100644
index 0000000..9c89d3e
--- /dev/null
+++ b/src/app/dialogs/alert/alert.component.html
@@ -0,0 +1,15 @@
+<header>
+ <h2>
+ Benachrichtigung
+ </h2>
+</header>
+
+<div class="panel panel-default alert-dialog">
+ <div class="panel-body">
+ <span>{{ alertMessage }}</span>
+ </div>
+</div>
+
+<div class="margin-top">
+ <button class="btn btn-primary btn-sm" (click)="dialogRef.close()">OK</button>
+</div>
\ No newline at end of file
diff --git a/src/app/dialogs/alert/alert.component.spec.ts b/src/app/dialogs/alert/alert.component.spec.ts
new file mode 100644
index 0000000..f2698c9
--- /dev/null
+++ b/src/app/dialogs/alert/alert.component.spec.ts
@@ -0,0 +1,28 @@
+/* tslint:disable:no-unused-variable */
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+import { DebugElement } from '@angular/core';
+
+import { AlertComponent } from './alert.component';
+
+describe('AlertComponent', () => {
+ let component: AlertComponent;
+ let fixture: ComponentFixture<AlertComponent>;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ AlertComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(AlertComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/dialogs/alert/alert.component.ts b/src/app/dialogs/alert/alert.component.ts
new file mode 100644
index 0000000..d2c4e19
--- /dev/null
+++ b/src/app/dialogs/alert/alert.component.ts
@@ -0,0 +1,14 @@
+import { Component, Optional } from '@angular/core';
+import { MdDialogRef } from '@angular/material';
+
+@Component({
+ selector: 'app-alert',
+ templateUrl: './alert.component.html',
+ styleUrls: ['./alert.component.css']
+})
+export class AlertComponent {
+ alertMessage = '';
+
+ constructor(@Optional() public dialogRef: MdDialogRef<AlertComponent>) { }
+
+}
diff --git a/src/app/dialogs/entry/entry.component.spec.ts b/src/app/dialogs/entry/entry.component.spec.ts
index 677bb27..45e4b56 100644
--- a/src/app/dialogs/entry/entry.component.spec.ts
+++ b/src/app/dialogs/entry/entry.component.spec.ts
@@ -273,7 +273,6 @@
fixture.whenStable().then(() => {
expect(component.add).toHaveBeenCalled();
expect(hasBeenCalled).toBeTruthy();
- //expect(component.sessionContext.bannerMessage.text).toEqual('Fehler bei der Erstellung eines Eintrags.');
});
}));
diff --git a/src/app/dialogs/file-import/file-import.component.ts b/src/app/dialogs/file-import/file-import.component.ts
index 6cc2591..4269225 100644
--- a/src/app/dialogs/file-import/file-import.component.ts
+++ b/src/app/dialogs/file-import/file-import.component.ts
@@ -74,7 +74,6 @@
deleteFile(fileName: string) {
this.importService.deleteImportFile(fileName).subscribe(result => {
- this.sessionContext.setImportFileAvailable(false);
this.dialogRef.close();
},
error => {
@@ -82,7 +81,6 @@
BannerMessageStatusEn.error,
'Fehler beim Löschen der Datei.',
true);
- this.sessionContext.setImportFileAvailable(false);
this.dialogRef.close();
}
);
diff --git a/src/app/filter/filter.component.spec.ts b/src/app/filter/filter.component.spec.ts
index c6622e9..2aab8f7 100644
--- a/src/app/filter/filter.component.spec.ts
+++ b/src/app/filter/filter.component.spec.ts
@@ -91,8 +91,10 @@
});
}));
- xit('should show an error message on the banner when an error occurs while running "initFilterMatrixWithDefaults"', async(() => {
+ it('should show an error message on the banner when an error occurs while running "initFilterMatrixWithDefaults"', async(() => {
+ let hasBeenCalled = false;
mockService.error = 'initFilterMatrixWithDefaults_ERROR';
+ messageService.errorOccured$.subscribe( msg => hasBeenCalled = true);
fixture.detectChanges();
component.ngOnChanges({
@@ -100,7 +102,7 @@
});
fixture.whenStable().then(() => {
- expect(component.bannerMessage.text).toEqual('Es ist ein Fehler aufgetreten. Bitte kontaktieren Sie den Administrator');
+ expect(hasBeenCalled).toBeTruthy();
});
}));
diff --git a/src/app/lists/abstract-list/abstract-list.component.spec.ts b/src/app/lists/abstract-list/abstract-list.component.spec.ts
index 62c9c43..7c349c7 100644
--- a/src/app/lists/abstract-list/abstract-list.component.spec.ts
+++ b/src/app/lists/abstract-list/abstract-list.component.spec.ts
@@ -56,11 +56,14 @@
let sessionContext;
let mockReminderService;
let mockService;
+ let messageService;
beforeEach(async(() => {
sessionContext = new SessionContext();
mockService = new MockNotificationService();
mockReminderService = new MockReminderService();
+ messageService = new MessageService();
+
TestBed.configureTestingModule({
imports: [FormsModule],
declarations: [
@@ -71,7 +74,7 @@
MockComponent({ selector: 'input', inputs: ['options'] })
],
providers: [
- { provide: MessageService, useClass: MessageService },
+ { provide: MessageService, useValue: messageService },
{ provide: NotificationService, useValue: mockService },
{ provide: ReminderService, useValue: mockReminderService },
{ provide: SessionContext, useClass: SessionContext },
@@ -125,16 +128,17 @@
});
}));
- xit('should set error on retrieveNotificationVersions failure', async(() => {
- const anyComp: any = component;
- spyOn(anyComp, 'setError');
+ it('should set error on retrieveNotificationVersions failure', async(() => {
+ let hasBeenCalled = false;
+ messageService.errorOccured$.subscribe( msg => hasBeenCalled = true);
+
mockService.error = 'VERSION_ERROR';
component.retrieveNotificationVersions(DUMMY_NOTIFICATION);
fixture.detectChanges();
fixture.whenStable().then(() => {
fixture.detectChanges();
+ expect(hasBeenCalled).toBeTruthy();
- expect(anyComp.setError).toHaveBeenCalled();
});
}));
diff --git a/src/app/lists/sorting/sorting.component.ts b/src/app/lists/sorting/sorting.component.ts
index b8a1fb2..a7749ce 100644
--- a/src/app/lists/sorting/sorting.component.ts
+++ b/src/app/lists/sorting/sorting.component.ts
@@ -1,4 +1,4 @@
-import { AfterViewInit, Component, Input, Output, EventEmitter, OnInit, OnChanges,SimpleChanges } from '@angular/core';
+import { AfterViewInit, Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { SessionContext } from '../../common/session-context';
import { SortingState } from '../../model/sorting-state';
diff --git a/src/app/model/sorting-state.ts b/src/app/model/sorting-state.ts
index ed49827..5630155 100644
--- a/src/app/model/sorting-state.ts
+++ b/src/app/model/sorting-state.ts
@@ -1,5 +1,5 @@
export class SortingState {
- column: string = '';
+ column = '';
counter: number;
defaultState: boolean;
isDesc: boolean;
diff --git a/src/app/pages/overview/overview.component.spec.ts b/src/app/pages/overview/overview.component.spec.ts
index 7c14885..1c1aa32 100644
--- a/src/app/pages/overview/overview.component.spec.ts
+++ b/src/app/pages/overview/overview.component.spec.ts
@@ -34,6 +34,7 @@
import { CurrentRemindersComponent } from '../../lists/current-reminders/current-reminders.component';
import { OPEN_NOTIFICATIONS } from '../../test-data/notifications';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { MessageService } from '../../services/message.service';
class FakeRouter {
navigate(commands: any[]) {
@@ -55,6 +56,7 @@
let router: Router;
let mockNotificationService: MockNotificationService;
let mockRespService: MockResponsibilityService;
+ let messageService: MessageService;
const correctUser: User = {
id: 44, username: 'carlo', password: 'serverPwd'
@@ -102,6 +104,7 @@
mockNotificationService = new MockNotificationService();
mockAuthService = new MockAuthService();
router = new FakeRouter() as any as Router;
+ messageService = new MessageService();
TestBed.overrideModule(BrowserDynamicTestingModule, {
set: {
@@ -161,7 +164,9 @@
selector: 'app-autocomplete',
inputs: ['responsibilityForwarding'],
outputs: ['responsibilityForwarding']
- })
+ }),
+ MockComponent({
+ selector: 'app-message-banner'})
],
providers: [
{ provide: NotificationService, useValue: mockNotificationService },
@@ -171,7 +176,8 @@
{ provide: SessionContext, useValue: sessionContext },
{ provide: DaterangepickerConfig, useClass: DaterangepickerConfig },
{ provide: ResponsibilityService, useValue: mockRespService },
- { provide: ReminderService, useClass: ReminderService }
+ { provide: ReminderService, useClass: ReminderService },
+ { provide: MessageService, useValue: messageService }
],
}).compileComponents();
@@ -182,7 +188,7 @@
component = fixture.componentInstance;
});
- xit('should init correctly with plannedResponsibility if available', async(() => {
+ it('should init correctly with plannedResponsibility if available', async(() => {
sessionContext.setCurrUser(correctUser);
mockRespService.plannedResponsibilities = RESPONSIBILITIES;
fixture.detectChanges();
@@ -193,7 +199,7 @@
});
}));
- xit('should init correctly with plannedResponsibility and open a shiftChangeProtocoll dialog', async(() => {
+ it('should init correctly with plannedResponsibility and open a shiftChangeProtocoll dialog', async(() => {
let shiftChangeProtocollOpened = false;
let dialog;
@@ -215,21 +221,21 @@
});
}));
- xit('should init correctly with empty plannedResponsibility', async(() => {
+ it('should init correctly with empty plannedResponsibility', async(() => {
sessionContext.setCurrUser(correctUser);
mockRespService.plannedResponsibilities = [];
fixture.detectChanges();
expect(component.responsibilitiesContainer).toBeUndefined();
}));
- xit('should init correctly with plannedResponsibility not available', async(() => {
+ it('should init correctly with plannedResponsibility not available', async(() => {
sessionContext.setCurrUser(correctUser);
mockRespService.error = 'error';
fixture.detectChanges();
expect(component.responsibilitiesContainer).toBeUndefined();
}));
- xit('should open dialog to create new notification on button click', async(() => {
+ it('should open dialog to create new notification on button click', async(() => {
let entryOpend = false;
sessionContext.setCurrUser(correctUser);
@@ -246,7 +252,7 @@
});
}));
- xit('should open special dialog to create new notification on button click', async(() => {
+ it('should open special dialog to create new notification on button click', async(() => {
let entryOpend = false;
let dialog;
let de: DebugElement;
@@ -268,7 +274,7 @@
});
}));
- xit('should open a dialog to edit a notification on button click', async(() => {
+ it('should open a dialog to edit a notification on button click', async(() => {
let entryOpend = false;
let dialog;
@@ -293,7 +299,7 @@
});
}));
- xit('should open a dialog to view a notification on button click', async(() => {
+ it('should open a dialog to view a notification on button click', async(() => {
let entryOpend = false;
let dialog;
diff --git a/src/app/pages/reminder/reminder.component.spec.ts b/src/app/pages/reminder/reminder.component.spec.ts
index f88f2f7..66730c0 100644
--- a/src/app/pages/reminder/reminder.component.spec.ts
+++ b/src/app/pages/reminder/reminder.component.spec.ts
@@ -185,6 +185,9 @@
MockComponent({
selector: 'app-future-notifications', inputs: [ 'responsiblitySelection',
'withCheckboxes', 'withEditButtons', 'isCollapsible', 'stayHidden']
+ }),
+ MockComponent({
+ selector: 'app-message-banner'
})
],
providers: [
@@ -208,7 +211,7 @@
//fixture.detectChanges();
});
- xit('should init correctly with correct user', async(() => {
+ it('should init correctly with correct user', async(() => {
sessionContext.setCurrUser(correctUser);
mockReminderService.currentReminders = [];
@@ -216,7 +219,7 @@
expect(component.user.id).toBe(correctUser.id);
}));
- xit('should open a dialog to edit a notification on button click', async(() => {
+ it('should open a dialog to edit a notification on button click', async(() => {
let entryOpend = false;
let dialog;
@@ -241,7 +244,7 @@
});
}));
- xit('should open a dialog to view a notification on button click', async(() => {
+ it('should open a dialog to view a notification on button click', async(() => {
let entryOpend = false;
let dialog;
diff --git a/src/app/pages/search/search.component.spec.ts b/src/app/pages/search/search.component.spec.ts
index c582e19..92d7a3c 100644
--- a/src/app/pages/search/search.component.spec.ts
+++ b/src/app/pages/search/search.component.spec.ts
@@ -64,7 +64,6 @@
let mockNotificationService: MockNotificationService;
let mockNotificationSearchSortService: MockNotificationSearchSortService;
let mockSearchResultService: MockSearchResultService;
- let mockRespService: MockResponsibilityService;
let messageService;
let routerStub: FakeRouter;
@@ -194,6 +193,9 @@
MockComponent({
selector: 'app-future-notifications', inputs: ['responsiblitySelection',
'withCheckboxes', 'withEditButtons', 'isCollapsible', 'stayHidden']
+ }),
+ MockComponent({
+ selector: 'app-message-banner'
})
],
providers: [
@@ -207,7 +209,7 @@
{ provide: SearchResultService, useValue: mockSearchResultService },
{ provide: SessionContext, useClass: SessionContext },
{ provide: ReminderService, useClass: ReminderService },
- { provide: ResponsibilityService, useValue: mockRespService },
+ { provide: ResponsibilityService, useClass: MockResponsibilityService },
{ provide: MessageService, useValue: messageService }
]
})
@@ -222,7 +224,7 @@
component.sessionContext = sessionContext;
});
- xit('should init correctly with correct user', async(() => {
+ it('should init correctly with correct user', async(() => {
sessionContext.setCurrUser(correctUser);
mockNotificationSearchSortService.searchResultNotifications = [];
@@ -230,8 +232,7 @@
expect(component.user.id).toBe(correctUser.id);
}));
- xit('should should navigate to Overview after click at homebbutton', (() => {
- //TODO
+ it('should should navigate to Overview after click at homebbutton', (() => {
spyOn(component, 'goToOverview').and.callThrough();
fixture.detectChanges();
@@ -245,12 +246,12 @@
});
}));
- xit('should navigate to overview on home-button click', () => {
+ it('should navigate to overview on home-button click', () => {
component.goToOverview();
expect(routerStub.navigate).toHaveBeenCalledWith(['/overview']);
});
- xit('should open a dialog to view a notification on button click', async(() => {
+ it('should open a dialog to view a notification on button click', async(() => {
let entryOpend = false;
let dialog;
@@ -275,7 +276,7 @@
});
}));
- xit('should delete search parameters after Suche löschen button pressed', (() => {
+ it('should delete search parameters after Suche löschen button pressed', (() => {
let dialog;
const globalSearchFilter: GlobalSearchFilter = new GlobalSearchFilter();
globalSearchFilter.searchString = 'Ab1224ag';
@@ -313,7 +314,7 @@
}));
- xit('should execute fast search and store it in the session context', (() => {
+ it('should execute fast search and store it in the session context', (() => {
let dialog;
const globalSearchFilter: GlobalSearchFilter = new GlobalSearchFilter();
globalSearchFilter.searchString = 'a';
@@ -335,10 +336,9 @@
});
}));
- xit('should call search function after search button pressed', async(() => {
+ it('should call search function after search button pressed', async(() => {
spyOn(component, 'search').and.callThrough();
fixture.detectChanges();
- //buttons.forEach((button: HTMLButtonElement) => {
fixture.whenStable().then(() => {
const currentSearchFilter: GlobalSearchFilter = new GlobalSearchFilter();
currentSearchFilter.searchString = 'Test';
@@ -354,21 +354,8 @@
let de: DebugElement;
de = fixture.debugElement.queryAll(By.css('form button:not(#deletesearch)'))[1];
- //de.nativeElement.click();
click(de);
fixture.detectChanges();
- /*
- const buttons: DebugElement[] = fixture.debugElement.nativeElement.querySelectorAll('form button:not(#deletesearch');
- //const button[] = fixture.debugElement.nativeElement.querySelectorAll('form button:not(#deletesearch)');
-
- buttons[0].nativeElement.click();
- fixture.detectChanges();
- expect(component.search).toHaveBeenCalled();
-
- //console.log(buttons[1].nativeElement);
- //buttons[1].nativeElement.click();
- */
-
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(component.search).toHaveBeenCalled();
@@ -377,8 +364,5 @@
});
});
-
- //});
-
}));
});
diff --git a/src/app/services/authentication.service.spec.ts b/src/app/services/authentication.service.spec.ts
index 565252d..c64ddc3 100644
--- a/src/app/services/authentication.service.spec.ts
+++ b/src/app/services/authentication.service.spec.ts
@@ -53,7 +53,7 @@
expect(backend).not.toBeNull('backend should be provided');
}));
- xdescribe('when login()', () => {
+ describe('when login()', () => {
let backend: MockBackend;
let service: AuthenticationService;
let response: Response;
@@ -70,7 +70,7 @@
const options = new ResponseOptions({status: 200, body: fakeUser, headers: successHeaders} );
response = new Response(options);
}));
- xit('should have expected fake user (then)', async(inject([], () => {
+ it('should have expected fake user (then)', async(inject([], () => {
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
service.login( fakeCreds ).toPromise()
@@ -84,8 +84,9 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
- const resp = new Response(new ResponseOptions({status: 404}));
+ it('should treat 404 as an Observable error', async(inject([], () => {
+ const resp = new Response(new ResponseOptions({status: 404, body: {} }));
+
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
service.login(fakeCreds)
diff --git a/src/app/services/base-data.service.spec.ts b/src/app/services/base-data.service.spec.ts
index ec08227..3e98bf9 100644
--- a/src/app/services/base-data.service.spec.ts
+++ b/src/app/services/base-data.service.spec.ts
@@ -79,7 +79,7 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({status: 404}));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
@@ -96,7 +96,7 @@
})));
});
- xdescribe('when getGridTerritories()', () => {
+ describe('when getGridTerritories()', () => {
let backend: MockBackend;
let service: BaseDataService;
let fakeGridTerritories: GridTerritory[];
@@ -152,7 +152,7 @@
const options = new ResponseOptions({status: 200, body: fakeStatuses});
response = new Response(options);
}));
- xit('should have expected fake notification statuses (then)', async(inject([], () => {
+ it('should have expected fake notification statuses (then)', async(inject([], () => {
backend.connections.subscribe((c: MockConnection) => c.mockRespond(response));
service.getStatuses().toPromise()
@@ -161,7 +161,7 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({status: 404}));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
diff --git a/src/app/services/base-http.service.ts b/src/app/services/base-http.service.ts
index fb9392c..a166310 100644
--- a/src/app/services/base-http.service.ts
+++ b/src/app/services/base-http.service.ts
@@ -24,6 +24,10 @@
protected createCommonHeaders(headers: Headers, sessionContext: SessionContext) {
headers.append('Accept', 'application/json');
headers.append('content-Type', 'application/json');
+ headers.append('Access-Control-Allow-Origin', '*');
+ if ( sessionContext.oauthService != null) {
+ headers.set('Authorization', 'Bearer ' + sessionContext.oauthService.getAccessToken());
+ }
headers.append('unique-TAN', UUID.UUID());
if (sessionContext.getCurrSessionId() !== null) {
headers.append(Globals.SESSION_TOKEN_TAG, sessionContext.getCurrSessionId());
@@ -31,10 +35,13 @@
}
protected extractData(res: Response, _sessContext: SessionContext) {
- if (res.status < 200 || res.status >= 300) {
+ // let the interested 'people' know about our result
+ _sessContext.centralHttpResultCode$.emit( res.status );
+
+ if (res.status !== 302 && (res.status < 200 || res.status >= 300) ) {
throw new Error('Bad response status: ' + res.status);
}
-
+
const data = res.json();
return data || {};
}
@@ -50,16 +57,17 @@
protected handleErrorPromise(error: any) {
// In a real world app, we might use a remote logging infrastructure
let errMsg: string;
- const body = error.json() || '';
- if (error instanceof Response) {
+ let body = null;
+ if (error instanceof Response) {
+ body = error.json() || '';
const err = body.error || JSON.stringify(body);
errMsg = `${error.status} - ${error.statusText || ''} ${err}`;
} else {
errMsg = error.message ? error.message : error.toString();
}
- if (body.errorCode === 401 && this.messageService) {
+ if (body !== null && body.errorCode === 401 && this.messageService) {
const bannerMessage = new BannerMessage();
bannerMessage.errorType = ErrorType.authentication;
this.messageService.errorOccured$.emit(bannerMessage);
diff --git a/src/app/services/http-response-interceptor.service.spec.ts b/src/app/services/http-response-interceptor.service.spec.ts
index 83f7fda..51715f8 100644
--- a/src/app/services/http-response-interceptor.service.spec.ts
+++ b/src/app/services/http-response-interceptor.service.spec.ts
@@ -9,7 +9,5 @@
});
});
- xit('should be created', inject([HttpResponseInterceptorService], (service: HttpResponseInterceptorService) => {
- expect(service).toBeTruthy();
- }));
+
});
diff --git a/src/app/services/import.service.ts b/src/app/services/import.service.ts
index d0cce31..92d08d8 100644
--- a/src/app/services/import.service.ts
+++ b/src/app/services/import.service.ts
@@ -26,45 +26,17 @@
public getImportFiles(): Observable<NotificationFileModel[]> {
const headers = new Headers();
- const url = super.getBaseUrl() + '/importFiles/';
+ const url = super.getBaseUrl() + '/getImportFiles/';
this.createCommonHeaders(headers, this._sessionContext);
- return Observable.of(IMPORT_NOTIFICATION_FILES);
- // return this._http.get(super.getBaseUrl() + '/importFiles', { headers: headers })
- // .map(res => super.extractData(res, this._sessionContext))
- // .catch(super.handleErrorPromise);
-
-
-
- /*
- // TODO: use this, when service is implemented
- return this._http.get(url, { headers: headers })
+ return this._http.get(url, { headers: headers })
.map(res => super.extractData(res, this._sessionContext))
.catch(super.handleErrorPromise);
- */
- // TODO: remove this, when service is implemented
- //return Observable.of(IMPORT_NOTIFICATION_FILES);
- //return Observable.of(ONE_IMPORT_NOTIFICATION_FILE);
}
- /*
- // can be deleted, if current solution is accepted
- public getImportFile(fileModel: NotificationFileModel): Observable<NotificationFileModel> {
- const headers = new Headers();
- const url = super.getBaseUrl() + '/importFiles/';
- const filter = fileModel || {};
- this.createCommonHeaders(headers, this._sessionContext);
-
- return this._http.post(url, JSON.stringify(filter), { headers: headers })
- .map(res => super.extractData(res, this._sessionContext))
- .catch(super.handleErrorPromise);
-
- }
- */
-
public deleteImportFile(fileName: string): Observable<boolean> {
const headers = new Headers();
- const url = super.getBaseUrl() + '/importFiles/' + fileName;
+ const url = super.getBaseUrl() + '/deleteImportedFiles/' + fileName;
this.createCommonHeaders(headers, this._sessionContext);
return this._http.delete(url, { headers: headers })
diff --git a/src/app/services/jobs/import-file-caller.service.spec.ts b/src/app/services/jobs/import-file-caller.service.spec.ts
index aa5b56b..6ca6b10 100644
--- a/src/app/services/jobs/import-file-caller.service.spec.ts
+++ b/src/app/services/jobs/import-file-caller.service.spec.ts
@@ -64,7 +64,7 @@
it('should set importFileAvailable to true when importfiles exist', fakeAsync(() => {
spyOn(injectedService, 'init').and.callThrough();
mockImportService.content = IMPORT_NOTIFICATION_FILES;
- Globals.REMINDER_JOB_POLLING_START_DELAY = 10;
+ Globals.IMPORT_JOB_POLLING_START_DELAY = 10;
expect(sessionContext.importFileAvailable).toBe(false);
messageService.loginLogoff$.emit(MessageDefines.MSG_LOG_IN_SUCCEEDED);
@@ -80,7 +80,7 @@
it('should set importFileAvailable to false when the are no importfiles', fakeAsync(() => {
mockImportService.content = [];
- Globals.REMINDER_JOB_POLLING_START_DELAY = 10;
+ Globals.IMPORT_JOB_POLLING_START_DELAY = 10;
expect(sessionContext.importFileAvailable).toBe(false);
diff --git a/src/app/services/jobs/import-file-caller.service.ts b/src/app/services/jobs/import-file-caller.service.ts
index acadd2b..73af2f9 100644
--- a/src/app/services/jobs/import-file-caller.service.ts
+++ b/src/app/services/jobs/import-file-caller.service.ts
@@ -37,7 +37,7 @@
}
init() {
- this.timer = TimerObservable.create(Globals.REMINDER_JOB_POLLING_START_DELAY, Globals.REMINDER_JOB_POLLING_INTERVALL);
+ this.timer = TimerObservable.create(Globals.IMPORT_JOB_POLLING_START_DELAY, Globals.IMPORT_JOB_POLLING_INTERVALL);
this.subscription = this.timer.subscribe(t => this.doJob(t));
}
diff --git a/src/app/services/notification.service.spec.ts b/src/app/services/notification.service.spec.ts
index 283bbbb..1f3d96d 100644
--- a/src/app/services/notification.service.spec.ts
+++ b/src/app/services/notification.service.spec.ts
@@ -41,11 +41,6 @@
}));
- // xit('can instantiate service when inject service',
- // inject([NotificationService], (service: NotificationService) => {
- // expect(service instanceof NotificationService).toBe(true);
- // }));
-
it('can instantiate service with "new"', inject([Http], (http: Http) => {
expect(http).not.toBeNull('http should be provided');
const service = new NotificationService(http, sessionContext, messageService);
@@ -81,7 +76,7 @@
sessionContext.setCurrSessionId(''); // current SessionID in LocalStorage is empty
}));
- xit('create call should response a fake notification with new id', async(inject([], () => {
+ it('create call should response a fake notification with new id', async(inject([], () => {
backend.connections.subscribe((c: MockConnection) => c.mockRespond(createNotificationResponse));
service.itemAdded$.subscribe(item => expect(item.id).toBe(DUMMY_CREATED_NOTIFICATION.id));
@@ -116,7 +111,7 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({ status: 404 }));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
@@ -184,7 +179,7 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({ status: 404 }));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
@@ -200,7 +195,7 @@
.toPromise();
})));
- xit('should call the correct getNotificationFunction', () => {
+ it('should call the correct getNotificationFunction', () => {
class MockNotificationService extends NotificationService {
lastCall: String = '';
@@ -253,7 +248,7 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({ status: 404 }));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
diff --git a/src/app/services/responsibility.service.spec.ts b/src/app/services/responsibility.service.spec.ts
index f43edb2..f519b8e 100644
--- a/src/app/services/responsibility.service.spec.ts
+++ b/src/app/services/responsibility.service.spec.ts
@@ -85,7 +85,7 @@
expect(sessionContext.getCurrSessionId()).not.toBe('SuperVALID!'); // only done with authentification
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({ status: 404 }));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
@@ -191,7 +191,7 @@
expect(sessionContext.getCurrSessionId()).not.toBe('SuperVALID!'); // only done with authentification
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({ status: 404 }));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
@@ -234,7 +234,7 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({ status: 404 }));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
diff --git a/src/app/services/user.service.spec.ts b/src/app/services/user.service.spec.ts
index 0602e1e..20784b9 100644
--- a/src/app/services/user.service.spec.ts
+++ b/src/app/services/user.service.spec.ts
@@ -85,7 +85,7 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({status: 404}));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
diff --git a/src/app/services/version-info.service.spec.ts b/src/app/services/version-info.service.spec.ts
index b6297e3..3ad4872 100644
--- a/src/app/services/version-info.service.spec.ts
+++ b/src/app/services/version-info.service.spec.ts
@@ -80,7 +80,7 @@
});
})));
- xit('should treat 404 as an Observable error', async(inject([], () => {
+ it('should treat 404 as an Observable error', async(inject([], () => {
const resp = new Response(new ResponseOptions({ status: 404 }));
backend.connections.subscribe((c: MockConnection) => c.mockRespond(resp));
diff --git a/src/assets/settings.json b/src/assets/settings.json
new file mode 100644
index 0000000..acff65f
--- /dev/null
+++ b/src/assets/settings.json
@@ -0,0 +1,3 @@
+{
+ "HELPURL": "https://www.google.de"
+}
\ No newline at end of file