[DEV] set back edition adn add many small GUI adaptations

This commit is contained in:
Edouard DUPIN 2020-02-28 00:16:34 +01:00
parent 4794fd4cf0
commit 47cbf4d5f2
11 changed files with 203 additions and 55 deletions

View File

@ -191,8 +191,8 @@ def add(_app, _name_api):
@doc.summary("get a specific resource") @doc.summary("get a specific resource")
@doc.description("Get a resource with all the needed datas ... It permeit seek for video stream.") @doc.description("Get a resource with all the needed datas ... It permeit seek for video stream.")
@doc.produces(content_type='application/json') @doc.produces(content_type='application/json')
async def retrive2(request, id, custom_user_video_name): def retrive2(request, id, custom_user_video_name):
return retrive2(request, id) return retrive(request, id)
@elem_blueprint.get('/' + _name_api + '/<id:int>', strict_slashes=True) @elem_blueprint.get('/' + _name_api + '/<id:int>', strict_slashes=True)
@doc.summary("get a specific resource") @doc.summary("get a specific resource")

View File

@ -233,7 +233,7 @@ class DataInterface():
raise ServerError("INTERNAL_ERROR fail request SQL ...", status_code=500) raise ServerError("INTERNAL_ERROR fail request SQL ...", status_code=500)
self.mark_to_store(); self.mark_to_store();
return self.get(iddd); return self.get(_id);
def post(self, _value): def post(self, _value):
debug.info("post " + self.name) debug.info("post " + self.name)

View File

@ -10,6 +10,9 @@
<div class="saison-small"> <div class="saison-small">
Saison {{numberSaison}} Saison {{numberSaison}}
</div> </div>
<div class="description-small" *ngIf="count"> <div class="description-small" *ngIf="count > 1">
{{count}} Episodes {{count}} Episodes
</div>
<div class="description-small" *ngIf="count <= 1">
{{count}} Episode
</div> </div>

View File

@ -39,7 +39,7 @@ export class ElementSaisonComponent implements OnInit {
this.saisonService.get(this.id_saison) this.saisonService.get(this.id_saison)
.then(function(response) { .then(function(response) {
self.error = ""; self.error = "";
self.numberSaison = response.number; self.numberSaison = 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;

View File

@ -47,7 +47,7 @@ export class SaisonComponent implements OnInit {
let self = this; let self = this;
this.saisonService.get(this.id_saison) this.saisonService.get(this.id_saison)
.then(function(response) { .then(function(response) {
self.name = response.number; self.name = response.name;
self.group_id = response.parent_id; self.group_id = response.parent_id;
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) {

View File

@ -1,5 +1,8 @@
<div class="main-reduce"> <div class="main-reduce">
<div class="fill-all"> <div class="fill-all">
<div class="title">
Edit media
</div>
<div class="request_raw"> <div class="request_raw">
<div class="label"> <div class="label">
Title: Title:
@ -14,7 +17,7 @@
</div> </div>
<div class="request_raw2"> <div class="request_raw2">
<div class="label"> <div class="label">
Description: <i class="material-icons">description</i> Description:
</div> </div>
<div class="input"> <div class="input">
<textarea (input)="onDescription($event.target.value)" placeholder="Description of the Media" rows=6>{{data.description}}</textarea> <textarea (input)="onDescription($event.target.value)" placeholder="Description of the Media" rows=6>{{data.description}}</textarea>
@ -26,7 +29,7 @@
</div> </div>
<div class="request_raw"> <div class="request_raw">
<div class="label"> <div class="label">
Date: <i class="material-icons">date_range</i> Date:
</div> </div>
<div class="input"> <div class="input">
<input type="number" <input type="number"
@ -46,6 +49,11 @@
<option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listType" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
</div> </div>
<div class="input_add">
<button class="button color-button-normal color-shadow-black" (click)="newType()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
</div>
</div> </div>
<div class="request_raw"> <div class="request_raw">
<div class="label"> <div class="label">
@ -57,17 +65,27 @@
<option *ngFor="let element of listUnivers" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listUnivers" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
</div> </div>
<div class="input_add">
<button class="button color-button-normal color-shadow-black" (click)="newUnivers()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
</div>
</div> </div>
<div class="request_raw"> <div class="request_raw">
<div class="label"> <div class="label">
Group: Serie:
</div> </div>
<div class="input"> <div class="input">
<select [ngModel]="data.group_id" <select [ngModel]="data.serie_id"
(ngModelChange)="onChangeGroup($event)"> (ngModelChange)="onChangeGroup($event)">
<option *ngFor="let element of listGroup" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listGroup" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
</div> </div>
<div class="input_add">
<button class="button color-button-normal color-shadow-black" (click)="newSerie()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
</div>
</div> </div>
<div class="request_raw"> <div class="request_raw">
<div class="label"> <div class="label">
@ -79,6 +97,11 @@
<option *ngFor="let element of listSaison" [ngValue]="element.value">{{element.label}}</option> <option *ngFor="let element of listSaison" [ngValue]="element.value">{{element.label}}</option>
</select> </select>
</div> </div>
<div class="input_add">
<button class="button color-button-normal color-shadow-black" (click)="newSaison()" type="submit">
<i class="material-icons">add_circle_outline</i>
</button>
</div>
</div> </div>
<div class="request_raw"> <div class="request_raw">
<div class="label"> <div class="label">
@ -94,33 +117,53 @@
</div> </div>
<div class="request_raw"> <div class="request_raw">
<div class="label"> <div class="label">
Data ID: <i class="material-icons">data_usage</i> Data ID:
</div> </div>
<div class="input"> <div class="input">
{{data.data_id}} {{data.data_id}}
</div> </div>
</div> </div>
<div class="request_raw">
<div class="label">
Covers:
</div>
<div class="input">
<div *ngFor="let element of covers_display" class="cover_div"><img src="{{element}}" class="cover"/></div>
</div>
</div>
<div class="send_value"> <div class="send_value">
<button class="button fill-x color-button-validate color-shadow-black" [disabled]="!need_send" (click)="sendValues()" type="submit"><i class="material-icons">save_alt</i> Save</button> <button class="button fill-x color-button-validate color-shadow-black" [disabled]="!need_send" (click)="sendValues()" type="submit"><i class="material-icons">save_alt</i> Save</button>
</div> </div>
<div class="clear"><hr/></div>
<div class="request_raw"> <div class="request_raw">
<div class="label"> <div class="label">
Covers: Add covers:
</div> </div>
<div class="input"> <div class="input">
<input type="file" <input type="file"
(change)="onChangeCover($event.target)" (change)="onChangeCover($event.target)"
placeholder="Select a cover file" placeholder="Select a cover file"
accept=".png,.jpg,.jpeg,.webp"/>{{upload_file_value}} accept=".png,.jpg,.jpeg,.webp"/>{{upload_file_value}}
</div> </div>
</div> </div>
<div class="request_raw">
<div class="label">
Actual Covers:
</div>
<div class="input">
<div *ngFor="let element of covers_display" class="cover_div">
<img src="{{element.url}}" class="cover"/>
<div class="cover_remove_div">
<button class="button color-button-cancel color-shadow-black" (click)="removeCover(element.id)" type="submit">
<i class="material-icons">delete</i> Remove Cover
</button>
</div>
</div>
</div>
</div>
<div class="clear"><hr/></div>
<div class="request_raw">
<div class="label">
<i class="material-icons">warning</i> Administration:
</div>
<div class="input">
<button class="button color-button-cancel color-shadow-black" (click)="removeMedia()" type="submit">
<i class="material-icons">delete</i> Remove Media
</button>
</div>
</div>
<div class="clear"></div>
</div> </div>
</div> </div>

View File

@ -9,12 +9,19 @@
box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6); box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6);
} }
.title {
width: 90%;
margin: 0 auto;
font-size: 50px;
text-align: center;
}
.request_raw2 { .request_raw2 {
width: 90%; width: 90%;
margin: 0 auto; margin: 0 auto;
height: 160px; height: 160px;
.label { .label {
width: 20%; width: 15%;
margin-right: 10px; margin-right: 10px;
text-align: right; text-align: right;
float: left; float: left;
@ -36,7 +43,7 @@
margin: 0 auto; margin: 0 auto;
height: 45px; height: 45px;
.label { .label {
width: 20%; width: 15%;
margin-right: 10px; margin-right: 10px;
text-align: right; text-align: right;
float: left; float: left;
@ -59,8 +66,17 @@
font-size: 20px; font-size: 20px;
} }
} }
.input_add {
width: 5%;
float: right;
display: block;
}
.cover_div { .cover_div {
//float: left; float: left;
display: block;
}
.cover_remove_div {
float: left;
display: block; display: block;
} }
.cover { .cover {

View File

@ -36,7 +36,7 @@ class DataToSend {
description:string = "" description:string = ""
episode:number = undefined episode:number = undefined
univers_id:number = undefined univers_id:number = undefined
group_id:number = undefined serie_id:number = undefined
saison_id:number = undefined saison_id:number = undefined
data_id:number = -1 data_id:number = -1
time:number = undefined time:number = undefined
@ -49,7 +49,7 @@ class DataToSend {
tmp.description = this.description tmp.description = this.description
tmp.episode = this.episode tmp.episode = this.episode
tmp.univers_id = this.univers_id tmp.univers_id = this.univers_id
tmp.group_id = this.group_id tmp.serie_id = this.serie_id
tmp.saison_id = this.saison_id tmp.saison_id = this.saison_id
tmp.data_id = this.data_id tmp.data_id = this.data_id
tmp.time = this.time tmp.time = this.time
@ -128,7 +128,7 @@ export class VideoEditComponent implements OnInit {
if (this.data.univers_id != this.data_ori.univers_id) { if (this.data.univers_id != this.data_ori.univers_id) {
this.need_send = true; this.need_send = true;
} }
if (this.data.group_id != this.data_ori.group_id) { if (this.data.serie_id != this.data_ori.serie_id) {
this.need_send = true; this.need_send = true;
} }
if (this.data.saison_id != this.data_ori.saison_id) { if (this.data.saison_id != this.data_ori.saison_id) {
@ -161,10 +161,12 @@ export class VideoEditComponent implements OnInit {
}).catch(function(response2) { }).catch(function(response2) {
console.log("get response22 : " + JSON.stringify(response2, null, 2)); console.log("get response22 : " + JSON.stringify(response2, null, 2));
}); });
this.groupService.getOrder() //this.groupService.getOrder()
this.groupService.getData()
.then(function(response3) { .then(function(response3) {
for(let iii= 0; iii < response3.length; iii++) { for(let iii= 0; iii < response3.length; iii++) {
self.listGroup.push({value: response3[iii].id, label: response3[iii].name}); self.listGroup.push({value: response3[iii].id, label: response3[iii].name});
console.log("[" + self.data.data_id + "] Get serie: " + response3[iii].id + ", label:" + response3[iii].name)
} }
}).catch(function(response3) { }).catch(function(response3) {
console.log("get response3 : " + JSON.stringify(response3, null, 2)); console.log("get response3 : " + JSON.stringify(response3, null, 2));
@ -180,13 +182,13 @@ export class VideoEditComponent implements OnInit {
self.data.time = response.time; self.data.time = response.time;
self.data.generated_name = response.generated_name; self.data.generated_name = response.generated_name;
self.onChangeType(response.type_id); self.onChangeType(response.type_id);
self.onChangeGroup(response.group_id); self.onChangeGroup(response.serie_id);
self.data.saison_id = response.saison_id; self.data.saison_id = response.saison_id;
self.data_ori = self.data.clone(); self.data_ori = self.data.clone();
if (response.covers !== undefined && response.covers !== null) { if (response.covers !== undefined && response.covers !== null) {
for (let iii=0; iii<response.covers.length; iii++) { for (let iii=0; iii<response.covers.length; iii++) {
self.data.covers.push(response.covers[iii]); self.data.covers.push(response.covers[iii]);
self.covers_display.push(self.videoService.getCoverUrl(response.covers[iii])); self.covers_display.push({id:response.covers[iii],url:self.videoService.getCoverUrl(response.covers[iii])});
} }
} else { } else {
self.covers_display = [] self.covers_display = []
@ -205,10 +207,10 @@ export class VideoEditComponent implements OnInit {
onChangeType(_value:any):void { onChangeType(_value:any):void {
console.log("Change requested of type ... " + _value); console.log("Change requested of type ... " + _value);
this.data.type_id = _value; this.data.type_id = _value;
this.data.group_id = null; //this.data.serie_id = null;
this.data.saison_id = null; //this.data.saison_id = null;
//this.listGroup = [{value: undefined, label: '---'}]; //this.listGroup = [{value: undefined, label: '---'}];
this.listSaison = [{value: undefined, label: '---'}]; //this.listSaison = [{value: undefined, label: '---'}];
let self = this; let self = this;
this.updateNeedSend(); this.updateNeedSend();
/* /*
@ -231,15 +233,15 @@ export class VideoEditComponent implements OnInit {
} }
onChangeGroup(_value:any):void { onChangeGroup(_value:any):void {
this.data.group_id = _value; this.data.serie_id = _value;
this.data.saison_id = null; this.data.saison_id = null;
this.listSaison = [{value: undefined, label: '---'}]; this.listSaison = [{value: undefined, label: '---'}];
let self = this; let self = this;
if (this.data.group_id != undefined) { if (this.data.serie_id != undefined) {
self.groupService.getSaison(this.data.group_id, ["id", "number"]) self.groupService.getSaison(this.data.serie_id, ["id", "name"])
.then(function(response3) { .then(function(response3) {
for(let iii= 0; iii < response3.length; iii++) { for(let iii= 0; iii < response3.length; iii++) {
self.listSaison.push({value: response3[iii].id, label: "saison " + response3[iii].number}); self.listSaison.push({value: response3[iii].id, label: "saison " + response3[iii].name});
} }
}).catch(function(response3) { }).catch(function(response3) {
console.log("get response22 : " + JSON.stringify(response3, null, 2)); console.log("get response22 : " + JSON.stringify(response3, null, 2));
@ -304,8 +306,8 @@ export class VideoEditComponent implements OnInit {
if (this.data.univers_id != this.data_ori.univers_id) { if (this.data.univers_id != this.data_ori.univers_id) {
data["univers_id"] = this.data.univers_id; data["univers_id"] = this.data.univers_id;
} }
if (this.data.group_id != this.data_ori.group_id) { if (this.data.serie_id != this.data_ori.serie_id) {
data["group_id"] = this.data.group_id; data["serie_id"] = this.data.serie_id;
} }
if (this.data.saison_id != this.data_ori.saison_id) { if (this.data.saison_id != this.data_ori.saison_id) {
data["saison_id"] = this.data.saison_id; data["saison_id"] = this.data.saison_id;
@ -368,5 +370,24 @@ export class VideoEditComponent implements OnInit {
console.log("Can not add the data in the system..."); console.log("Can not add the data in the system...");
}); });
} }
removeCover(_id) {
console.log("Request remove cover: " + _id);
}
removeMedia() {
console.log("Request remove Media...");
}
newSaison() {
console.log("Request new Saison...");
}
newSerie() {
console.log("Request new Serie...");
}
newType() {
console.log("Request new Type...");
}
newUnivers() {
console.log("Request new Univers...");
}
} }

View File

@ -6,17 +6,23 @@
<div class="cover" *ngIf="cover != null" > <div class="cover" *ngIf="cover != null" >
<img src="{{cover}}"/> <img src="{{cover}}"/>
</div> </div>
<div class="episode" *ngIf="group_name!=null">
<b>Serie:</b> {{group_name}}
</div>
<div class="episode" *ngIf="saison_name!=null">
<b>Saison:</b> {{saison_name}}
</div>
<div class="episode" *ngIf="episode!=null">
<b>Episode:</b> {{episode}}
</div>
<div class="episode">
<b>generated_name:</b> {{generated_name}}
</div>
<div class="description"> <div class="description">
{{description}} {{description}}
</div> </div>
<div class="episode" *ngIf="episode!=null">
Episode <b>{{episode}}</b>
</div>
<div class="generated_name">
generated_name <b>{{generated_name}}</b>
</div>
<div class="video_div"> <div class="video_div">
<video class="video_object" src="{{video_source}}" controls preload="none"> <video class="video_object" src="{{video_source}}/{{generated_name}}" controls preload="none">
<!--<p>Your browser des not suport HTML5 video player. download video: <a href="{{video_source}}>link here</a>.</p>--> <!--<p>Your browser des not suport HTML5 video player. download video: <a href="{{video_source}}>link here</a>.</p>-->
</video> </video>
</div> </div>

View File

@ -10,6 +10,8 @@ import { Location } from '@angular/common';
import { fadeInAnimation } from '../../_animations/index'; import { fadeInAnimation } from '../../_animations/index';
import { HttpWrapperService } from '../../service/http-wrapper.service'; import { HttpWrapperService } from '../../service/http-wrapper.service';
import { VideoService } from '../../service/video.service'; import { VideoService } from '../../service/video.service';
import { GroupService } from '../../service/group.service';
import { SaisonService } from '../../service/saison.service';
import { ArianeService } from '../../service/ariane.service'; import { ArianeService } from '../../service/ariane.service';
@Component({ @Component({
@ -29,7 +31,9 @@ export class VideoComponent implements OnInit {
description:string = "" description:string = ""
episode:number = undefined episode:number = undefined
group_id:number = undefined group_id:number = undefined
group_name:string = undefined
saison_id:number = undefined saison_id:number = undefined
saison_name:string = undefined
data_id:number = -1 data_id:number = -1
time:number = undefined time:number = undefined
type_id:number = undefined type_id:number = undefined
@ -42,11 +46,35 @@ export class VideoComponent implements OnInit {
private router: Router, private router: Router,
private locate: Location, private locate: Location,
private videoService: VideoService, private videoService: VideoService,
private groupService: GroupService,
private saisonService: SaisonService,
private httpService: HttpWrapperService, private httpService: HttpWrapperService,
private arianeService: ArianeService) { private arianeService: ArianeService) {
} }
generateName() {
this.generated_name = "";
if (this.group_name != undefined) {
this.generated_name += this.group_name + "-";
}
if (this.saison != undefined) {
if (this.saison_name.length < 2) {
this.generated_name += "s0" + this.saison_name + "-";
} else {
this.generated_name += "s" + this.saison_name + "-";
}
}
if (this.episode != undefined) {
if (this.episode < 10) {
this.generated_name += "e0" + this.episode + "-";
} else {
this.generated_name += "e" + this.episode + "-";
}
}
this.generated_name += this.name;
}
ngOnInit() { ngOnInit() {
this.id_video = parseInt(this.route.snapshot.paramMap.get('video_id')); this.id_video = parseInt(this.route.snapshot.paramMap.get('video_id'));
this.arianeService.setVideo(this.id_video); this.arianeService.setVideo(this.id_video);
@ -76,6 +104,25 @@ export class VideoComponent implements OnInit {
self.covers.push(self.videoService.getCoverUrl(response.covers[iii])); self.covers.push(self.videoService.getCoverUrl(response.covers[iii]));
} }
} }
self.generateName();
if (self.group_id !== undefined && self.group_id !== null) {
self.groupService.get(self.group_id)
.then(function(response) {
self.group_name = response.name;
self.generateName();
}).catch(function(response) {
// nothing to do ...
});
}
if (self.saison_id !== undefined && self.saison_id !== null) {
self.saisonService.get(self.saison_id)
.then(function(response) {
self.saison_name = response.name;
self.generateName();
}).catch(function(response) {
// nothing to do ...
});
}
//console.log("display source " + self.video_source); //console.log("display source " + self.video_source);
//console.log("set transformed : " + JSON.stringify(self, null, 2)); //console.log("set transformed : " + JSON.stringify(self, null, 2));
}).catch(function(response) { }).catch(function(response) {
@ -90,6 +137,8 @@ export class VideoComponent implements OnInit {
self.generated_name = ""; self.generated_name = "";
self.video_source = ""; self.video_source = "";
self.cover = null; self.cover = null;
self.group_name = undefined;
self.saison_name = undefined;
}); });
} }

View File

@ -17,9 +17,6 @@ export class GroupService {
} }
get(_id:number):any { get(_id:number):any {
if (environment.localBdd != true) {
return this.http.get_specific(this.serviceName, _id);
}
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getGroup() self.bdd.getGroup()
@ -35,17 +32,30 @@ export class GroupService {
}); });
}); });
}; };
getOrder():any {
if (environment.localBdd != true) { getData():any {
return this.http.get_specific(this.serviceName, null, "", ["name","id"]);
}
let self = this; let self = this;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
self.bdd.getGroup() self.bdd.getGroup()
.then(function(response) { .then(function(response) {
let data = response.gets_where([["!=", "id", null]], ["id"], ["name","id"]) let data = response.gets();
resolve(data); resolve(data);
}).catch(function(response) { }).catch(function(response) {
console.log("[E] " + self.constructor.name + ": can not retrive BDD values");
reject(response);
});
});
};
getOrder():any {
let self = this;
return new Promise((resolve, reject) => {
self.bdd.getGroup()
.then(function(response) {
let data = response.gets_where([["!=", "id", null]], ["id", "name"], ["name","id"])
resolve(data);
}).catch(function(response) {
console.log("[E] " + self.constructor.name + ": can not retrive BDD values");
reject(response); reject(response);
}); });
}); });