Skip to content

Commit

Permalink
feat(backend): New Backend and authentication for Phonebook data. (#7)
Browse files Browse the repository at this point in the history
The following are the changes, most of them are breaking changes:

- replace the json file with a real backend
   - the backend connects directly to a database
   - currently, it try to return the same stuff as the old JSON file
- Open Source the backend
- add authentification to the people data
   - currently, supported is WsFederation over Azure or ADFS (and tested)

There are some issues that currently are known:

- the search for numbers is broken
   - this is not related to this change but good to know (#591 )
- the last hierarchy in the org structure isn't visible in any view
   - organigram
   - users supervisor
   - Users organigram information
- after login the user is redirected to `/` and not to the path the redirection starts. (#586 )
- the picture backend asked for login
   - this will change soon because we plan to use the same auth like this backend.

But we must ship this because the old source is broken. (after more than 15 years!)
So let's

![ship it gif](https://media1.tenor.com/images/6727709a62756a117203bbbf42c23ad9/tenor.gif?itemid=14131994)

BREAKING CHANGE
closes #18
closes #271
  • Loading branch information
paule96 authored Apr 7, 2020
1 parent 6c4a130 commit bdbc898
Show file tree
Hide file tree
Showing 64 changed files with 2,365 additions and 517 deletions.
18 changes: 18 additions & 0 deletions .azure/pipelines/pr/Phonebook.Source.PeopleSoft.pr.yml
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# TODO: #18
trigger: none
pr:
branches:
include:
- master
paths:
include:
- Phonebook.Source.PeopleSoft/**

jobs:
- job: build
displayName: build docker image
pool:
vmImage: 'ubuntu-16.04'
steps:
- bash: |
docker build .
workingDirectory: 'Phonebook.Source.PeopleSoft/'
27 changes: 26 additions & 1 deletion .azure/pipelines/production/Phonebook.Source.PeopleSoft.yml
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
# TODO: #18
trigger:
batch: true
branches:
include:
- master
paths:
include:
- Phonebook.Source.PeopleSoft/
pr: none

jobs:
- job: build
displayName: build docker image
pool:
vmImage: 'ubuntu-16.04'
steps:
- bash: |
docker build -t $dockerRepo:$tag .
docker login -u $DOCKER_REGISTRY_USER -p $DOCKER_REGISTRY_PASSWORD
docker push $dockerRepo:$tag
workingDirectory: 'Phonebook.Source.PeopleSoft/'
env:
DOCKER_REGISTRY_PASSWORD: $(DOCKER_REGISTRY_PASSWORD)
DOCKER_REGISTRY_USER: $(DOCKER_REGISTRY_USER)
dockerRepo: tsystemsmms/phonebook-build
tag: source-peoplesoft
36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/Phonebook.Source.PeopleSoft/src/Phonebook.Source.PeopleSoft/bin/Debug/netcoreapp2.2/Phonebook.Source.PeopleSoft.dll",
"args": [],
"cwd": "${workspaceFolder}/Phonebook.Source.PeopleSoft/src/Phonebook.Source.PeopleSoft",
"stopAtEntry": false,
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
36 changes: 36 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Phonebook.Source.PeopleSoft/src/Phonebook.Source.PeopleSoft/Phonebook.Source.PeopleSoft.csproj"
],
"problemMatcher": "$tsc"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/Phonebook.Source.PeopleSoft/src/Phonebook.Source.PeopleSoft/Phonebook.Source.PeopleSoft.csproj"
],
"problemMatcher": "$tsc"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/Phonebook.Source.PeopleSoft/src/Phonebook.Source.PeopleSoft/Phonebook.Source.PeopleSoft.csproj"
],
"problemMatcher": "$tsc"
}
]
}
4 changes: 2 additions & 2 deletions Phonebook.Frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"ng": "ng",
"start": "npm run start:en",
"start:en": "concurrently -n mock-backend,assets,angular \"docker run --rm -p 8080:80 --name phonebook-backend-mock tsystemsmms/phonebook-build:mock-backend\" \"docker run --rm -p 8081:80 --name phonebook-assets tsystemsmms/phonebook-build:assets\" \"ng serve --ssl --proxy-config proxy.conf.json --configuration en\"",
"start:de": "concurrently -n mock-backend,assets,angular \"docker run --rm -p 8080:80 --name phonebook-backend-mock tsystemsmms/phonebook-build:mock-backend\" \"docker run --rm -p 8081:80 --name phonebook-assets tsystemsmms/phonebook-build:assets\" \"ng serve --ssl --proxy-config proxy.conf.json --configuration de\"",
"start:en": "concurrently -n mock-backend,assets,angular \"docker run --rm -p 8080:80 --name phonebook-source-mock -e ASPNETCORE_ENVIRONMENT=Development tsystemsmms/phonebook-build:source-peoplesoft\" \"docker run --rm -p 8081:80 --name phonebook-assets tsystemsmms/phonebook-build:assets\" \"ng serve --ssl --proxy-config proxy.conf.json --configuration en\"",
"start:de": "concurrently -n mock-backend,assets,angular \"docker run --rm -p 8080:80 --name phonebook-source-mock -e ASPNETCORE_ENVIRONMENT=Development tsystemsmms/phonebook-build:source-peoplesoft\" \"docker run --rm -p 8081:80 --name phonebook-assets tsystemsmms/phonebook-build:assets\" \"ng serve --ssl --proxy-config proxy.conf.json --configuration de\"",
"start:debug": "ng serve --ssl --proxy-config=proxy.conf.json --configuration debug",
"start-compose": "npm run compose-build && docker-compose run --rm --service-ports angular npm run start:en",
"start-compose:debug": "npm run compose-build && docker-compose run --rm --service-ports angular npm run start:debug",
Expand Down
9 changes: 6 additions & 3 deletions Phonebook.Frontend/proxy.conf.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"/signin-wsfed": {
"target": "http://localhost:8080",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
},
"/api/*": {
"target": "http://localhost:8080",
"secure": false,
"changeOrigin": true,
"pathRewrite": {
"^/api": ""
},
"logLevel": "debug"
},
"/external_assets/*": {
Expand Down
6 changes: 4 additions & 2 deletions Phonebook.Frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//Angular Imports
import { DragDropModule } from '@angular/cdk/drag-drop';
import { PlatformModule } from '@angular/cdk/platform';
import { HttpClientModule } from '@angular/common/http';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { MatBadgeModule } from '@angular/material/badge';
import { MAT_DIALOG_DEFAULT_OPTIONS } from '@angular/material/dialog';
Expand Down Expand Up @@ -52,6 +52,7 @@ import { environment } from 'src/environments/environment';
// Services
import { FloorplanService } from './services/floorplan.service';
import { SearchComponent } from './shared/components/search/search.component';
import { HttpRedirectToLogin } from 'src/app/shared/interceptors/HttpRedirectToLogin';

declare const require;

Expand Down Expand Up @@ -95,6 +96,7 @@ declare const require;
UserPagesModule
],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: HttpRedirectToLogin, multi: true },
// {
// provide: TRANSLATIONS,
// useFactory: (locale: string) => {
Expand All @@ -115,4 +117,4 @@ declare const require;
],
bootstrap: [AppComponent]
})
export class AppModule {}
export class AppModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</mat-card-header>
<img
mat-card-image
[src]="runtimeEnvironment.assetsEndpoint + location.LinkPicture"
[src]="runtimeEnvironment.assetsEndpoint + '/locations/' + location.LinkPicture"
[alt]="location.LinkRoutingInfo"
/>
<mat-card-content>
Expand All @@ -43,16 +43,11 @@ <h3 mat-subheader>
[href]="location.LinkRoutingWebsite"
target="_blank"
rel="noopener"
*ngIf="
location.LinkRoutingWebsite != '' &&
location.LinkRoutingWebsite != null
"
*ngIf="location.LinkRoutingWebsite != '' && location.LinkRoutingWebsite != null"
class="mat-small"
>
<mat-icon>open_in_new</mat-icon>
<span i18n="@@GeneralShowOnMapButton"
>Show on Google-Maps</span
>
<span i18n="@@GeneralShowOnMapButton">Show on Google-Maps</span>
</a>
</h3>
<mat-list-item>
Expand All @@ -61,12 +56,7 @@ <h3 mat-subheader>
</div>
</mat-list-item>
<h3 mat-subheader i18n="@@DataLocationContact">Contact</h3>
<mat-list-item
*ngIf="
location.ReceptionPhone != '' &&
location.ReceptionPhone != null
"
>
<mat-list-item *ngIf="location.ReceptionPhone != '' && location.ReceptionPhone != null">
<mat-icon mat-list-icon>call</mat-icon>
<h4 mat-line i18n="@@ColumnTitlePhone">Phone</h4>
<p mat-line>
Expand All @@ -81,43 +71,27 @@ <h4 mat-line i18n="@@ColumnTitlePhone">Phone</h4>
</button>
</p>
</mat-list-item>
<mat-list-item
*ngIf="
location.ReceptionFax != '' && location.ReceptionFax != null
"
>
<mat-list-item *ngIf="location.ReceptionFax != '' && location.ReceptionFax != null">
<mat-icon mat-list-icon>print</mat-icon>
<h4 mat-line i18n="@@DataPersonFax">Fax</h4>
<p mat-line>
<button
mat-button
actionDrawer
[copy]="location.ReceptionFax"
>
<button mat-button actionDrawer [copy]="location.ReceptionFax">
{{ location.ReceptionFax }}
</button>
</p></mat-list-item
>
</p>
</mat-list-item>

<mat-list-item
*ngIf="
location.ContactPerson != '' && location.ContactPerson != null
"
>
<mat-list-item *ngIf="location.ContactPerson != '' && location.ContactPerson != null">
<mat-icon mat-list-icon>person</mat-icon>
<h4 mat-line i18n="@@DataLocationContactPerson">
Contact Person
</h4>
<p mat-line>
<button
mat-button
stopPropagation
[routerLink]="['/search/' + location.ContactPerson]"
>
<button mat-button stopPropagation [routerLink]="['/search/' + location.ContactPerson]">
{{ location.ContactPerson }}
</button>
</p></mat-list-item
>
</p>
</mat-list-item>
</mat-list>
</mat-card-content>
</mat-card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class RoomDetailComponent implements OnInit {
this.room = this.node.data as Room;
}
this.personService
.getPersonsByRoom(RoomHelpers.getParamsAsArray(params, ['cityId', 'buildingId', 'floorId', 'roomId']))
.getPersonsByRoom(RoomHelpers.getParamsAsArray(params, ['roomId'])[0])
.subscribe(person => {
this.persons = person;
});
Expand Down
5 changes: 4 additions & 1 deletion Phonebook.Frontend/src/app/modules/table/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export class Helpers {
* Removes Accents from the string.
* @param str Any String
*/
public static removeAccents(str: string): string {
public static removeAccents(str: string | null): string {
if(str === null){
return '';
}
return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
}
}
28 changes: 13 additions & 15 deletions Phonebook.Frontend/src/app/services/api/person.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class PersonService {
item.Contacts.Fax,
item.Contacts.Email,
item.Contacts.Phone,
new Messenger(item.Contacts.Messenger.Text, item.Contacts.Messenger.State)
new Messenger("", null)
),
new Location(
item.Location.City,
Expand Down Expand Up @@ -74,15 +74,16 @@ export class PersonService {
return this.allPersonObservable;
}

const observable = this.http.get<Person[]>('/api/persons').pipe(
map(personArray => {
return TableLogic.sort(this.generateRealPersonArray(personArray), {
column: ColumnDefinitions.fullname,
direction: PhonebookSortDirection.asc
});
}),
publishReplay()
);
const observable = this.http.get<Person[]>('/api/people')
.pipe(
map(personArray => {
return TableLogic.sort(this.generateRealPersonArray(personArray), {
column: ColumnDefinitions.fullname,
direction: PhonebookSortDirection.asc
});
}),
publishReplay()
);
(observable as ConnectableObservable<Person[]>).connect();
this.allPersonObservable = observable;
return this.allPersonObservable;
Expand All @@ -102,15 +103,12 @@ export class PersonService {
);
}

public getPersonsByRoom(positionArray: string[]): Observable<Person[]> {
public getPersonsByRoom(roomId: string): Observable<Person[]> {
return this.getAll().pipe(
map(personArray => {
return personArray.filter(x => {
return (
x.Location.RoomCollection[0].Place === positionArray[0] &&
x.Location.RoomCollection[0].Building === positionArray[1] &&
x.Location.RoomCollection[0].Floor.toString() === positionArray[2] &&
x.Location.RoomCollection[0].Number === positionArray[3]
x.Location.RoomCollection.some( x=> x.Number == roomId)
);
});
})
Expand Down
Loading

0 comments on commit bdbc898

Please sign in to comment.