[DEV] update the elements

This commit is contained in:
Edouard DUPIN 2023-08-13 23:51:26 +02:00
parent 82cba33e99
commit 0ee08ac7e5
10 changed files with 155 additions and 69 deletions

View File

@ -77,7 +77,11 @@ public class UserMediaAdvancementResource {
UserMediaAdvancement elem = this.getWithId(sc, id); UserMediaAdvancement elem = this.getWithId(sc, id);
if (elem == null) { if (elem == null) {
// insert element // insert element
return this.post(sc, id, new MediaInformations(data.time(), data.percent(), 0)); if (data.addCount) {
return this.post(sc, id, new MediaInformations(data.time(), data.percent(), 1));
} else {
return this.post(sc, id, new MediaInformations(data.time(), data.percent(), 0));
}
} }
elem.time = data.time; elem.time = data.time;
elem.percent = data.percent; elem.percent = data.percent;

View File

@ -16,7 +16,7 @@ public class Migration20230810 extends MigrationSqlStep {
addClass(UserMediaAdvancement.class); addClass(UserMediaAdvancement.class);
addAction(""" addAction("""
ALTER TABLE `userMediaAdvencement` AUTO_INCREMENT = 1000; ALTER TABLE `userMediaAdvancement` AUTO_INCREMENT = 1000;
"""); """);
} }

View File

@ -1,18 +1,24 @@
<div> <div>
<div class="count-base">
<span class="views" *ngIf="advancement">
{{advancement.count}}
</span>
</div>
<div class="videoImgContainer"> <div class="videoImgContainer">
<div *ngIf="covers"> <div *ngIf="covers">
<!--<data-image id="{{cover}}"></data-image>--> <!--<data-image id="{{cover}}"></data-image>-->
<img src="{{covers[0]}}"/> <img src="{{covers[0]}}" />
</div> </div>
<div *ngIf="!covers" class="noImage"> <div *ngIf="!covers" class="noImage">
</div> </div>
</div> </div>
<div class="view-progess" [ngStyle]="updateAdvancement()"></div>
<div class="title-small" *ngIf="data"> <div class="title-small" *ngIf="data">
{{episodeDisplay}} {{name}} {{episodeDisplay}} {{name}}
</div> </div>
<div class="title-small" *ngIf="!data"> <div class="title-small" *ngIf="!data">
Error meda: {{element?.id}} Error media: {{element?.id}}
</div> </div>
<!-- <!--
<div class="description-small" *ngIf="description"> <div class="description-small" *ngIf="description">

View File

@ -1,14 +1,53 @@
.count-base {
height: 0px;
width: 100%;
left: 0px;
z-index: 12;
//position:flex;
text-align: left;
.views {
height: 30px;
//width: 30px;
font-size: 17px;
line-height: 30px;
overflow: hidden;
position: relative;
z-index: 12;
left: 6px;
top: 6px;
text-align: left;
padding: 5px 10px;
color: rgba(0, 0, 0, 1.0);
background: rgba(256, 256, 256, 0.3);
border: 1px solid;
border-color: rgba(56, 206, 26, 0.8);
border-radius: 15px;
}
}
.view-progess {
//position: relative;
//display: flex;
height: 2px;
background-color: #079207;
//width: 70%;
left: 0px;
z-index: 15;
}
.videoImgContainer { .videoImgContainer {
text-align: center; text-align: center;
width: 200px; width: 200px;
margin: 0 auto; margin: 0 auto;
height: 250px; height: 250px;
img { img {
//width: 100%; //width: 100%;
max-height: 250px; max-height: 250px;
max-width: 200px; max-width: 200px;
} }
.noImage { .noImage {
height: 243px; height: 243px;
width: 193px; width: 193px;
@ -22,10 +61,10 @@
height: 40px; height: 40px;
width: 200px; width: 200px;
font-size: 17px; font-size: 17px;
overflow:hidden; overflow: hidden;
display:inline-block; display: inline-block;
text-align: center; text-align: center;
padding:auto; padding: auto;
background: rgba(256, 256, 256, 0.3); background: rgba(256, 256, 256, 0.3);
border-radius: 7px; border-radius: 7px;
} }
@ -33,6 +72,6 @@
.description-small { .description-small {
height: 30px; height: 30px;
font-size: 12px; font-size: 12px;
overflow:hidden; overflow: hidden;
vertical-align: middle; vertical-align: middle;
} }

View File

@ -5,32 +5,36 @@
*/ */
import { Injectable, Component, OnInit, Input } from '@angular/core'; import { Injectable, Component, OnInit, Input } from '@angular/core';
import { isMedia, Media } from 'app/model'; import { isMedia, Media } from 'app/model';
import { UserMediaAdvancement } from 'app/model/user-media-advancement';
import { DataService } from 'app/service'; import { AdvancementService, DataService } from 'app/service';
import { NodeData } from 'common/model'; import { NodeData } from 'common/model';
import { isNullOrUndefined } from 'common/utils'; import { isNullOrUndefined } from 'common/utils';
@Component({ @Component({
selector: 'app-element-video', selector: 'app-element-video',
templateUrl: './element-video.html', templateUrl: './element-video.html',
styleUrls: [ './element-video.less' ] styleUrls: ['./element-video.less']
}) })
@Injectable() @Injectable()
export class ElementVideoComponent implements OnInit { export class ElementVideoComponent implements OnInit {
// input parameters // input parameters
@Input() element:NodeData; @Input() element: NodeData;
data:Media; data: Media;
name:string = ''; name: string = '';
description:string = ''; description: string = '';
episodeDisplay:string = ''; episodeDisplay: string = '';
cover:string = ''; cover: string = '';
covers:string[]; covers: string[];
advancement: UserMediaAdvancement = undefined;
constructor( constructor(
private dataService: DataService) { private dataService: DataService,
private advancementService: AdvancementService) {
// nothing to do. // nothing to do.
} }
ngOnInit() { ngOnInit() {
@ -43,11 +47,25 @@ export class ElementVideoComponent implements OnInit {
this.data = this.element; this.data = this.element;
this.name = this.element.name; this.name = this.element.name;
this.description = this.element.description; this.description = this.element.description;
if(isNullOrUndefined(this.element.episode)) { if (isNullOrUndefined(this.element.episode)) {
this.episodeDisplay = ''; this.episodeDisplay = '';
} else { } else {
this.episodeDisplay = `${this.element.episode } - `; this.episodeDisplay = `${this.element.episode} - `;
} }
this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers); this.covers = this.dataService.getCoverListThumbnailUrl(this.element.covers);
this.advancementService.get(this.element.id)
.then((response: UserMediaAdvancement) => {
console.log(` ==> get answer sub-series: ${JSON.stringify(response)}`);
this.advancement = response;
}).catch((response) => {
this.advancement = undefined;
});
}
updateAdvancement() {
if (isNullOrUndefined(this.advancement)) {
return { width: "0%" };
}
return { width: `${this.advancement.percent * 100}%` };
} }
} }

View File

@ -6,12 +6,12 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { SeasonService, DataService, SeriesService, ArianeService } from 'app/service'; import { SeasonService, DataService, SeriesService, ArianeService, AdvancementService } from 'app/service';
@Component({ @Component({
selector: 'app-season', selector: 'app-season',
templateUrl: './season.html', templateUrl: './season.html',
styleUrls: [ './season.less' ] styleUrls: ['./season.less']
}) })
export class SeasonScene implements OnInit { export class SeasonScene implements OnInit {
name: string = ''; name: string = '';
@ -24,10 +24,11 @@ export class SeasonScene implements OnInit {
videosError = ''; videosError = '';
videos = []; videos = [];
constructor( constructor(
private seasonService: SeasonService, private seasonService: SeasonService,
private seriesService: SeriesService, private seriesService: SeriesService,
private arianeService: ArianeService, private arianeService: ArianeService,
private dataService: DataService) { private dataService: DataService,
private advancementService: AdvancementService) {
} }
@ -36,27 +37,27 @@ export class SeasonScene implements OnInit {
let self = this; let self = this;
this.seasonService.get(this.idSeason) this.seasonService.get(this.idSeason)
.then((response:any) => { .then((response: any) => {
console.log("Get element ! " + JSON.stringify(response)); console.log("Get element ! " + JSON.stringify(response));
self.name = response.name; self.name = response.name;
self.seriesId = response.parentId; self.seriesId = response.parentId;
self.description = response.description; self.description = response.description;
if(response.covers === undefined || response.covers === null || response.covers.length === 0) { if (response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
} else { } else {
self.cover = self.dataService.getCoverUrl(response.covers[0]); self.cover = self.dataService.getCoverUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) { for (let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.dataService.getCoverUrl(response.covers[iii])); self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
} }
} }
self.seriesService.get(self.seriesId) self.seriesService.get(self.seriesId)
.then((response2:any) => { .then((response2: any) => {
self.seriesName = response2.name; self.seriesName = response2.name;
}).catch((response2:any) => { }).catch((response2: any) => {
self.seriesName = ''; self.seriesName = '';
}); });
}).catch((response3:any) => { }).catch((response3: any) => {
self.description = ''; self.description = '';
self.name = '???'; self.name = '???';
self.seriesName = ''; self.seriesName = '';
@ -64,18 +65,23 @@ export class SeasonScene implements OnInit {
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
}); });
console.log(`get parameter id: ${ this.idSeason}`); console.log(`get parameter id: ${this.idSeason}`);
this.seasonService.getVideo(this.idSeason) this.seasonService.getVideo(this.idSeason)
.then((response4:any) => { .then((response4: any) => {
self.videosError = ''; self.videosError = '';
self.videos = response4; self.videos = response4;
}).catch((response5:any) => { }).catch((response5: any) => {
self.videosError = 'Can not get the List of video without season'; self.videosError = 'Can not get the List of video without season';
self.videos = []; self.videos = [];
}); });
} }
onSelectVideo(event: any, idSelected: number):void { onSelectVideo(event: any, idSelected: number): void {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey); if (event.ctrlKey && event.altKey && event.which === 2) {
// special feature ==> add count id...
this.advancementService.updateTime(idSelected, 0, 1, true);
} else {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
}
} }
} }

View File

@ -6,13 +6,13 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { SeriesService, DataService, ArianeService } from 'app/service'; import { SeriesService, DataService, ArianeService, AdvancementService } from 'app/service';
import { NodeData } from 'common/model'; import { NodeData } from 'common/model';
@Component({ @Component({
selector: 'app-series', selector: 'app-series',
templateUrl: './series.html', templateUrl: './series.html',
styleUrls: [ './series.less' ] styleUrls: ['./series.less']
}) })
export class SeriesScene implements OnInit { export class SeriesScene implements OnInit {
@ -26,9 +26,10 @@ export class SeriesScene implements OnInit {
videosError: string = ''; videosError: string = '';
videos: Array<any> = []; videos: Array<any> = [];
constructor( constructor(
private seriesService: SeriesService, private seriesService: SeriesService,
private arianeService: ArianeService, private arianeService: ArianeService,
private dataService: DataService) { private dataService: DataService,
private advancementService: AdvancementService) {
} }
@ -46,12 +47,12 @@ export class SeriesScene implements OnInit {
.then((response) => { .then((response) => {
self.name = response.name; self.name = response.name;
self.description = response.description; self.description = response.description;
if(response.covers === undefined || response.covers === null || response.covers.length === 0) { if (response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
} else { } else {
self.cover = self.dataService.getCoverUrl(response.covers[0]); self.cover = self.dataService.getCoverUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) { for (let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.dataService.getCoverUrl(response.covers[iii])); self.covers.push(self.dataService.getCoverUrl(response.covers[iii]));
} }
} }
@ -92,24 +93,29 @@ export class SeriesScene implements OnInit {
self.checkIfJumpIsNeeded(updateEnded); self.checkIfJumpIsNeeded(updateEnded);
}); });
} }
onSelectSeason(event: any, idSelected: number):void { onSelectSeason(event: any, idSelected: number): void {
this.arianeService.navigateSeason(idSelected, event.which === 2, event.ctrlKey); this.arianeService.navigateSeason(idSelected, event.which === 2, event.ctrlKey);
} }
onSelectVideo(event: any, idSelected: number):void { onSelectVideo(event: any, idSelected: number): void {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey); if (event.ctrlKey && event.altKey && event.which === 2) {
// special feature ==> add count id...
this.advancementService.updateTime(idSelected, 0, 1, true);
} else {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
}
} }
checkIfJumpIsNeeded(updateEnded: { seriesMetadata: boolean; subSaison: boolean; subVideo: boolean; }): void { checkIfJumpIsNeeded(updateEnded: { seriesMetadata: boolean; subSaison: boolean; subVideo: boolean; }): void {
// all update is ended // all update is ended
if(updateEnded.seriesMetadata === false || updateEnded.subSaison === false || updateEnded.subVideo === false) { if (updateEnded.seriesMetadata === false || updateEnded.subSaison === false || updateEnded.subVideo === false) {
return; return;
} }
// no local video // no local video
if(this.videos.length > 0) { if (this.videos.length > 0) {
return; return;
} }
// only one season: // only one season:
if(this.seasons.length !== 1) { if (this.seasons.length !== 1) {
return; return;
} }
this.arianeService.navigateSeason(this.seasons[0].id, false, false, true); this.arianeService.navigateSeason(this.seasons[0].id, false, false, true);

View File

@ -7,28 +7,29 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute } from '@angular/router';
import { TypeService, DataService, ArianeService } from 'app/service'; import { TypeService, DataService, ArianeService, AdvancementService } from 'app/service';
@Component({ @Component({
selector: 'app-type', selector: 'app-type',
templateUrl: './type.html', templateUrl: './type.html',
styleUrls: [ './type.less' ] styleUrls: ['./type.less']
}) })
export class TypeScene implements OnInit { export class TypeScene implements OnInit {
typeId = -1; typeId = -1;
name: string = ''; name: string = '';
description: string = ''; description: string = '';
cover:string = null; cover: string = null;
covers:string[] = []; covers: string[] = [];
seriessError = ''; seriessError = '';
series = []; series = [];
videosError = ''; videosError = '';
videos = []; videos = [];
constructor( constructor(
private typeService: TypeService, private typeService: TypeService,
private arianeService: ArianeService, private arianeService: ArianeService,
private dateService: DataService) { private dateService: DataService,
private advancementService: AdvancementService) {
/* /*
this.route.params.subscribe(params => { this.route.params.subscribe(params => {
@ -43,18 +44,18 @@ export class TypeScene implements OnInit {
ngOnInit() { ngOnInit() {
this.typeId = this.arianeService.getTypeId(); this.typeId = this.arianeService.getTypeId();
let self = this; let self = this;
console.log(`get type global id: ${ this.typeId}`); console.log(`get type global id: ${this.typeId}`);
this.typeService.get(this.typeId) this.typeService.get(this.typeId)
.then((response) => { .then((response) => {
self.name = response.name; self.name = response.name;
self.description = response.description; self.description = response.description;
console.log(` ==> get answer type detail: ${JSON.stringify(response)}`); console.log(` ==> get answer type detail: ${JSON.stringify(response)}`);
if(response.covers === undefined || response.covers === null || response.covers.length === 0) { if (response.covers === undefined || response.covers === null || response.covers.length === 0) {
self.cover = null; self.cover = null;
self.covers = []; self.covers = [];
} else { } else {
self.cover = self.dateService.getCoverUrl(response.covers[0]); self.cover = self.dateService.getCoverUrl(response.covers[0]);
for(let iii = 0; iii < response.covers.length; iii++) { for (let iii = 0; iii < response.covers.length; iii++) {
self.covers.push(self.dateService.getCoverUrl(response.covers[iii])); self.covers.push(self.dateService.getCoverUrl(response.covers[iii]));
} }
} }
@ -85,11 +86,17 @@ export class TypeScene implements OnInit {
self.videos = []; self.videos = [];
}); });
} }
onSelectSeries(event: any, idSelected: number):void { onSelectSeries(event: any, idSelected: number): void {
this.arianeService.navigateSeries(idSelected, event.which === 2, event.ctrlKey); this.arianeService.navigateSeries(idSelected, event.which === 2, event.ctrlKey);
} }
onSelectVideo(event: any, idSelected: number):void { onSelectVideo(event: any, idSelected: number): void {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey); console.log(` type of event: ${typeof event}`);
if (event.ctrlKey && event.altKey && event.which === 2) {
// special feature ==> add count id...
this.advancementService.updateTime(idSelected, 0, 1, true);
} else {
this.arianeService.navigateVideo(idSelected, event.which === 2, event.ctrlKey);
}
} }
} }

View File

@ -53,9 +53,9 @@
<div class="episode"> <div class="episode">
<b>generatedName:</b> {{generatedName}} <b>generatedName:</b> {{generatedName}}
</div> </div>
<div class="description"> <div class="episode" *ngIf="userMetaData">
count= {{userMetaData?.count}} view percent={{userMetaData?.percent}} <b>Number of view:</b> {{userMetaData.count}}<br />
percent={{convertIndisplayTime(userMetaData?.time)}} <b>Position:</b> {{userMetaData.percentDisplay}} % ==> {{convertIndisplayTime(userMetaData.time)}}
</div> </div>
<div class="description"> <div class="description">
{{description}} {{description}}

View File

@ -74,7 +74,7 @@ export class VideoScene implements OnInit {
timeLeft: number = 10; timeLeft: number = 10;
interval = null; interval = null;
userMetaData: UserMediaAdvancement = undefined userMetaData: UserMediaAdvancement & { percentDisplay: number } = undefined
previousTime: number = 0; previousTime: number = 0;
startPlayingTime: number = undefined; startPlayingTime: number = undefined;
@ -299,7 +299,7 @@ export class VideoScene implements OnInit {
}); });
this.advancementService.get(this.idVideo) this.advancementService.get(this.idVideo)
.then((response: UserMediaAdvancement) => { .then((response: UserMediaAdvancement) => {
this.userMetaData = response this.userMetaData = { ...response, percentDisplay: Math.floor(response.percent * 100) }
this.startPlayingTime = response.time this.startPlayingTime = response.time
}) })
} }