Skip to content

Commit

Permalink
Merge pull request #29 from SRGSSR/develop
Browse files Browse the repository at this point in the history
Release deeplink aggregation
  • Loading branch information
pyby authored Jul 24, 2019
2 parents c0f94bb + 781b9a1 commit 6d644af
Show file tree
Hide file tree
Showing 40 changed files with 1,931 additions and 117 deletions.
21 changes: 19 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Playfff

## About

Playfff is a SRG micro service to serve extra datas to Play applications. Playfff means "Play Features and Functionalities with Flair".
Playfff is a SRG micro service to serve extra datas to Play applications. Playfff means "Play Features and Functionalities with Flair".

## Compatibility

Expand All @@ -18,7 +18,9 @@ A Java development environment with Maven is needed.
A wide list of parameters are available.

* `PFFF_USER` (optional, string): A user login to admin service.
* `PFFF_PASSWORD` (optional, string): A user password to admin service.
* `PFFF_PASSWORD` (optional, string): A user password to admin service.
* `DEEP_LINK_REFRESH_DELAY_MS` (optional, integer): Scheduled fixed delay before refreshing the deep link script cache. If not set, defaults is `300000`.
* `MAX_DEEP_LINK_REPORTS` (optional, integer): Maximum number of deep link reports in the database. If not set, defaults is `2500`.

## API
* `urn` (string): an unique identifier.
Expand All @@ -44,6 +46,15 @@ A wide list of parameters are available.
* `/api/v1/whatisnew/text?package={package}&version={version}` : get WhatIsNewResult object.
* `/api/v1/whatisnew/html?package={package}&version={version}` : get What's new html format.

#### Deep link

* `/api/v1/deeplink/parsePlayUrl.js` (GET): Get the Play web URL to mobile application scheme URL script (deep link script). The HTTP ETag caching is supported.
* `/api/v1/deeplink/report` (POST) : create or update a new deep link report object from the JSON body object. Send a report only if the script returns `[scheme]://redirect`. The JSON object must contains:
* `clientTime` (string): date of the parsing execution in `yyyy-MM-dd'T'HH:mm:ssXXX` format.
* `clientId` (string): Bundle id or package name.
* `jsVersion` (integer): the `parsePlayUrl.js` value of `parsePlayUrlVersion` variable.
* `url` (string): the unparsing url.

#### Recommendation for a media

* `/api/v2/playlist/recommendation/continuousPlayback/{urn}` : get media list object.
Expand Down Expand Up @@ -71,6 +82,12 @@ Private APIs need a user authentification.
* `/api/v1/update` (PUT) : update an update object from the body object.
* `/api/v1/update/{id}` (GET) : get update object with `id` identifier.
* `/api/v1/update/{id}` (DELETE) : remove update object with `id` identifier.

#### Deep link

* `/api/v1/deeplink/report` (GET) : get All deep link reports.
* `/api/v1/deeplink/report/{id}` (GET) : get deep link report object with `id` identifier.
* `/api/v1/deeplink/report/{id}` (DELETE) : remove deep link report object with `id` identifier.

## License

Expand Down
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>ch.srgssr</groupId>
<artifactId>playfff</artifactId>
<version>12</version>
<version>13</version>
<packaging>jar</packaging>

<name>pfff</name>
Expand Down Expand Up @@ -103,6 +103,13 @@
<artifactId>integrationlayer-domain-objects</artifactId>
<version>1.20.272</version>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
10 changes: 8 additions & 2 deletions portal-app/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
<h1 class="text-center">Pfff - Admin</h1>
</div>

<p class="text-right">
<button type="button" class="btn btn-default btn-sm" onclick="window.location.href='/logout'">
<span class="glyphicon glyphicon-log-out"></span> Logout
</button>
</p>

<div class="btn-group-justified">
<a routerLink="/updates" class="btn btn-primary">List Updates</a>
<a routerLink="/add_update" class="btn btn-success">Add Update</a>
<a routerLink="/updates" class="btn btn-primary">Update alerts</a>
<a routerLink="/deeplink" class="btn btn-primary">Deep links</a>
</div>
<br/>
<router-outlet></router-outlet>
Expand Down
11 changes: 7 additions & 4 deletions portal-app/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@ import { FormsModule } from '@angular/forms';

import { AppComponent } from './app.component';
import { UpdateComponent } from './update/update.component';
import { DeeplinkComponent } from './deeplink/deeplink.component';
import { AppRoutingModule } from './app.routing.module';
import {UpdateService} from './update/update.service';
import {HttpClientModule} from "@angular/common/http";
import { UpdateService } from './update/update.service';
import { DeeplinkService } from './deeplink/deeplink.service';
import { HttpClientModule } from "@angular/common/http";

import {AddUpdateComponent} from './update/add-update.component';

@NgModule({
declarations: [
AppComponent,
UpdateComponent,
AddUpdateComponent
AddUpdateComponent,
DeeplinkComponent
],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
FormsModule
],
providers: [UpdateService],
providers: [UpdateService, DeeplinkService],
bootstrap: [AppComponent]
})
export class AppModule { }
6 changes: 4 additions & 2 deletions portal-app/src/app/app.routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';

import { UpdateComponent } from './update/update.component';
import {AddUpdateComponent} from './update/add-update.component';
import { AddUpdateComponent } from './update/add-update.component';
import { DeeplinkComponent } from './deeplink/deeplink.component';

const routes: Routes = [
{ path: 'updates', component: UpdateComponent },
{ path: 'add_update', component: AddUpdateComponent }
{ path: 'add_update', component: AddUpdateComponent },
{ path: 'deeplink', component: DeeplinkComponent }
];

@NgModule({
Expand Down
26 changes: 26 additions & 0 deletions portal-app/src/app/deeplink/deeplink.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div class="col-md-12">
<h2 class="text-center">
Deep link reports
</h2>
<p class="text-center">Only failed parsing urls are reported and ordered by JS version and count.</p>

<table class="table table-striped">
<thead>
<tr>
<th *ngFor="let col of columns">
{{col}}
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let deeplinkReport of deeplinkReports">
<td *ngFor="let col of columns">
{{deeplinkReport[col]}}
</td>
<td>
<button class="btn btn-danger" (click)="deleteDeeplinkReport(deeplinkReport)">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
25 changes: 25 additions & 0 deletions portal-app/src/app/deeplink/deeplink.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { DeeplinkComponent } from './deeplink.component';

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

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ DeeplinkComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DeeplinkComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
37 changes: 37 additions & 0 deletions portal-app/src/app/deeplink/deeplink.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

import {DeeplinkReport} from '../models/deeplink-report.model';
import { DeeplinkService } from './deeplink.service';

@Component({
selector: 'app-user',
templateUrl: './deeplink.component.html',
styles: []
})
export class DeeplinkComponent implements OnInit {
deeplinkReports: DeeplinkReport[];
columns: string[];

constructor(private router: Router, private deeplinkService: DeeplinkService) {

}

ngOnInit() {
this.columns = this.deeplinkService.getColumns();

this.deeplinkService.getDeeplinkReports()
.subscribe( data => {
console.log(data);
this.deeplinkReports = data;
});
};

deleteDeeplinkReport(deeplinkReport: DeeplinkReport): void {
this.deeplinkService.deleteDeeplinkReport(deeplinkReport)
.subscribe( data => {
this.deeplinkReports = this.deeplinkReports.filter(dr => dr !== deeplinkReport);
})
};

}
37 changes: 37 additions & 0 deletions portal-app/src/app/deeplink/deeplink.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders} from '@angular/common/http';

import {DeeplinkReport} from '../models/deeplink-report.model';


const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};

@Injectable()
export class DeeplinkService {

constructor(private http: HttpClient) {
}

private deeplinkReportUrl = '/api/v1/deeplink/report';

public getDeeplinkReports() {
return this.http.get<DeeplinkReport[]>(this.deeplinkReportUrl);
}

public deleteDeeplinkReport(deeplinkReport) {
return this.http.delete(this.deeplinkReportUrl + "/" + deeplinkReport.id);
}

public getColumns() {
return [
"id",
"clientId",
"clientTime",
"count",
"jsVersion",
"url",
]
}
}
8 changes: 8 additions & 0 deletions portal-app/src/app/models/deeplink-report.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class DeeplinkReport {
id: string;
clientId: string;
clientTime: string;
count: number;
jsVersion: number;
url: string;
}
4 changes: 2 additions & 2 deletions portal-app/src/app/update/add-update.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="col-md-12">
<h2 class="text-center">Add Update</h2>
<h2 class="text-center">Add an update alert</h2>
<form>
<div class="form-group">
<label for="packageName">Package name:</label>
Expand All @@ -20,6 +20,6 @@ <h2 class="text-center">Add Update</h2>
<label><input type="checkbox" [(ngModel)]="update.mandatory" name="mandatory" id="mandatory"> Mandatory</label>
</div>

<button class="btn btn-success" (click)="createUpdate()">Create</button>
<button class="btn btn-success" (click)="createUpdate()">Add / Update</button>
</form>
</div>
6 changes: 5 additions & 1 deletion portal-app/src/app/update/add-update.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export class AddUpdateComponent {
createUpdate(): void {
this.updateService.createUpdate(this.update)
.subscribe( data => {
alert("Update created successfully.");
alert("Update message created or updated.");
this.router.navigate(['/updates']);
},
err => {
alert("Please complete all fields.");
});

};
Expand Down
Empty file.
8 changes: 6 additions & 2 deletions portal-app/src/app/update/update.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div class="col-md-12">
<h2 class="text-center">Update Details</h2>
<h2 class="text-center">
Update alerts
</h2>
<p class="text-center">Recommended update or mandatory update alert displayed at application launch.</p>
<p class="text-center"><a routerLink="/add_update" class="btn btn-success col-2">Add an update alert</a></p>

<table class="table table-striped">
<thead>
Expand All @@ -15,7 +19,7 @@ <h2 class="text-center">Update Details</h2>
{{update[col]}}
</td>
<td>
<button class="btn btn-danger" (click)="deleteUpdate(update)"> Delete Update</button>
<button class="btn btn-danger" (click)="deleteUpdate(update)">Delete</button>
</td>
</tr>
</tbody>
Expand Down
22 changes: 21 additions & 1 deletion src/main/java/ch/srgssr/playfff/config/AuthenticationConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;

import java.util.Collections;

Expand All @@ -30,7 +33,7 @@ public AuthenticationConfig(
@Value("${PFFF_USER:}") String user,
@Value("${PFFF_PASSWORD:}") String password) {

this.user = user;;
this.user = user;
this.password = password;
}

Expand All @@ -43,12 +46,29 @@ protected void configure(HttpSecurity http) throws Exception {
.and()
.formLogin()
.loginPage("/login")
.defaultSuccessUrl("/", true)
.permitAll()
.and()
.logout()
.deleteCookies("JSESSIONID")
.invalidateHttpSession(true)
.logoutUrl("/logout")
.logoutSuccessUrl("/login")
.permitAll();
http
.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());

http
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"));
}

@Override
public void configure(WebSecurity web) throws Exception {
web
.ignoring()
.antMatchers("/api/v1/deeplink/parsePlayUrl.js")
.antMatchers(HttpMethod.POST, "/api/v1/deeplink/report");
}

@Bean
Expand Down
Loading

0 comments on commit 6d644af

Please sign in to comment.