diff --git a/back/src/data_interface.py b/back/src/data_interface.py
index 5139fe8..cc2cfb3 100644
--- a/back/src/data_interface.py
+++ b/back/src/data_interface.py
@@ -21,7 +21,9 @@ def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
if col[0] == "covers":
- if row[idx] != None:
+ if row[idx] == "":
+ d[col[0]] = None
+ elif row[idx] != None:
d[col[0]] = row[idx].split("/")
else:
d[col[0]] = None
@@ -142,7 +144,7 @@ class DataInterface():
if self.need_save == False:
return
debug.warning("Save bdd: " + self.file)
- conn.commit()
+ self.conn.commit()
def gets(self, filter=None):
debug.info("gets " + self.name)
@@ -189,23 +191,37 @@ class DataInterface():
return elem
debug.warning("not found element: " + str(len(self.bdd)))
"""
+ self.mark_to_store();
return None
def delete(self, _id):
debug.info("delete " + self.name + ": " + str(_id))
+ cursor = self.conn.cursor()
req = (_id,)
cursor.execute('UPDATE data SET deleted=1 WHERE id=?', req)
+ self.mark_to_store();
return True
def put(self, _id, _value):
- request = 'UPDATE data WHERE id=? SET'
- list_data = [_id]
+ debug.info("put in " + self.name + ": " + str(_id))
+ cursor = self.conn.cursor()
+ request = 'UPDATE data SET'
+ list_data = []
+ first = True;
for elem in _value.keys():
if elem == "id":
continue
+ if first == True:
+ first = False
+ else:
+ request += " , "
list_data.append(_value[elem])
request += " '" + elem + "' = ?"
+ request += " WHERE id = ? "
+ list_data.append(_id)
+ debug.info("Request executed : '" + request + "'")
cursor.execute(request, list_data)
+ self.mark_to_store();
"""
debug.info("put " + self.name + ": " + str(_id))
@@ -236,6 +252,7 @@ class DataInterface():
self.bdd.append(_value)
self.mark_to_store()
"""
+ self.mark_to_store();
return _value
# TODO : rework this
diff --git a/front/src/app/scene/video-edit/video-edit.html b/front/src/app/scene/video-edit/video-edit.html
index 2e7ce20..445d3fc 100644
--- a/front/src/app/scene/video-edit/video-edit.html
+++ b/front/src/app/scene/video-edit/video-edit.html
@@ -7,20 +7,21 @@
-
@@ -38,7 +41,7 @@
Type:
-
@@ -49,7 +52,7 @@
Univers:
-
@@ -60,7 +63,7 @@
Group:
-
@@ -71,7 +74,7 @@
Saison:
-
@@ -82,9 +85,11 @@
Episode:
-
+
@@ -92,7 +97,7 @@
Data ID:
- {{data_id}}
+ {{data.data_id}}
@@ -104,7 +109,7 @@
-
+
diff --git a/front/src/app/scene/video-edit/video-edit.less b/front/src/app/scene/video-edit/video-edit.less
index d6c2f02..9a213af 100644
--- a/front/src/app/scene/video-edit/video-edit.less
+++ b/front/src/app/scene/video-edit/video-edit.less
@@ -9,6 +9,28 @@
box-shadow: 0px 2px 4px 0 rgba(0, 0, 0, 0.6);
}
+.request_raw2 {
+ width: 90%;
+ margin: 0 auto;
+ height: 160px;
+ .label {
+ width: 20%;
+ margin-right: 10px;
+ text-align: right;
+ float: left;
+ display: block;
+ }
+ .input {
+ width: 75%;
+ float: left;
+ display: block;
+ textarea {
+ width: 100%;
+ font-size: 20px;
+ resize: none;
+ }
+ }
+}
.request_raw {
width: 90%;
margin: 0 auto;
@@ -32,6 +54,10 @@
width: 100%;
font-size: 20px;
}
+ textarea {
+ width: 100%;
+ font-size: 20px;
+ }
}
.cover_div {
//float: left;
diff --git a/front/src/app/scene/video-edit/video-edit.ts b/front/src/app/scene/video-edit/video-edit.ts
index 95f57cf..0cc2216 100644
--- a/front/src/app/scene/video-edit/video-edit.ts
+++ b/front/src/app/scene/video-edit/video-edit.ts
@@ -30,6 +30,36 @@ export class ElementList {
}
}
+
+class DataToSend {
+ name:string = ""
+ description:string = ""
+ episode:number = undefined
+ univers_id:number = undefined
+ group_id:number = undefined
+ saison_id:number = undefined
+ data_id:number = -1
+ time:number = undefined
+ type_id:number = undefined
+ covers:Array = [];
+ generated_name:string = ""
+ clone() {
+ let tmp = new DataToSend();
+ tmp.name = this.name
+ tmp.description = this.description
+ tmp.episode = this.episode
+ tmp.univers_id = this.univers_id
+ tmp.group_id = this.group_id
+ tmp.saison_id = this.saison_id
+ tmp.data_id = this.data_id
+ tmp.time = this.time
+ tmp.type_id = this.type_id
+ tmp.covers = this.covers
+ tmp.generated_name = this.generated_name
+ return tmp;
+ }
+};
+
@Component({
selector: 'app-video-edit',
templateUrl: './video-edit.html',
@@ -43,19 +73,12 @@ export class VideoEditComponent implements OnInit {
error:string = ""
- name:string = ""
- description:string = ""
- episode:number = undefined
- univers_id:number = undefined
- group_id:number = undefined
- saison_id:number = undefined
- data_id:number = -1
- time:number = undefined
- type_id:number = undefined
- generated_name:string = ""
+ data:DataToSend = new DataToSend();
+ data_ori:DataToSend = new DataToSend();
coverFile:File;
upload_file_value:string = ""
selectedFiles:FileList;
+ need_send:boolean = false;
covers_display:Array = [];
@@ -85,6 +108,35 @@ export class VideoEditComponent implements OnInit {
}
+ updateNeedSend(): boolean {
+ this.need_send = false;
+ if (this.data.name != this.data_ori.name) {
+ this.need_send = true;
+ }
+ if (this.data.description != this.data_ori.description) {
+ this.need_send = true;
+ }
+ if (this.data.episode != this.data_ori.episode) {
+ this.need_send = true;
+ }
+ if (this.data.time != this.data_ori.time) {
+ this.need_send = true;
+ }
+ if (this.data.type_id != this.data_ori.type_id) {
+ this.need_send = true;
+ }
+ if (this.data.univers_id != this.data_ori.univers_id) {
+ this.need_send = true;
+ }
+ if (this.data.group_id != this.data_ori.group_id) {
+ this.need_send = true;
+ }
+ if (this.data.saison_id != this.data_ori.saison_id) {
+ this.need_send = true;
+ }
+ return this.need_send;
+ }
+
ngOnInit() {
this.id_video = parseInt(this.route.snapshot.paramMap.get('video_id'));
this.arianeService.setVideo(this.id_video);
@@ -120,47 +172,45 @@ export class VideoEditComponent implements OnInit {
this.videoService.get(this.id_video)
.then(function(response) {
console.log("get response of video : " + JSON.stringify(response, null, 2));
- self.name = response.name;
- self.description = response.description;
- self.episode = response.episode;
- self.univers_id = response.univers_id;
- self.data_id = response.data_id;
- self.time = response.time;
- self.generated_name = response.generated_name;
+ self.data.name = response.name;
+ self.data.description = response.description;
+ self.data.episode = response.episode;
+ self.data.univers_id = response.univers_id;
+ self.data.data_id = response.data_id;
+ self.data.time = response.time;
+ self.data.generated_name = response.generated_name;
self.onChangeType(response.type_id);
self.onChangeGroup(response.group_id);
- self.saison_id = response.saison_id;
+ self.data.saison_id = response.saison_id;
+ self.data_ori = self.data.clone();
if (response.covers !== undefined && response.covers !== null) {
for (let iii=0; iii 4) {
+ _value.value = this.data.time;
+ } else {
+ this.data.time = _value.value;
+ }
+ this.updateNeedSend();
}
onEpisode(_value:any):void {
- this.episode = parseInt(_value, 10);
- //this.episode = _value;
+ if (_value.value.length > 4) {
+ _value.value = this.data.episode;
+ } else {
+ this.data.episode = parseInt(_value.value, 10);
+ }
+ this.updateNeedSend();
}
sendValues():void {
console.log("send new values....");
- let data = {
- "name": this.name,
- "description": this.description,
- "episode": this.episode,
- "time": this.time,
- "type_id": this.type_id,
- "univers_id": this.univers_id,
- "group_id": this.group_id,
- "saison_id": this.saison_id
- };
- this.videoService.put(this.id_video, data);
+ let data = {}
+ if (this.data.name != this.data_ori.name) {
+ data["name"] = this.data.name;
+ }
+ if (this.data.description != this.data_ori.description) {
+ data["description"] = this.data.description;
+ }
+ if (this.data.episode != this.data_ori.episode) {
+ data["episode"] = this.data.episode;
+ }
+ if (this.data.time != this.data_ori.time) {
+ data["time"] = this.data.time;
+ }
+ if (this.data.type_id != this.data_ori.type_id) {
+ data["type_id"] = this.data.type_id;
+ }
+ if (this.data.univers_id != this.data_ori.univers_id) {
+ data["univers_id"] = this.data.univers_id;
+ }
+ if (this.data.group_id != this.data_ori.group_id) {
+ data["group_id"] = this.data.group_id;
+ }
+ if (this.data.saison_id != this.data_ori.saison_id) {
+ data["saison_id"] = this.data.saison_id;
+ }
+ let tmpp = this.data.clone();
+ let self = this;
+ this.videoService.put(this.id_video, data)
+ .then(function(response3) {
+ self.data_ori = tmpp;
+ self.updateNeedSend();
+ }).catch(function(response3) {
+ console.log("get response22 : " + JSON.stringify(response3, null, 2));
+ self.updateNeedSend();
+ });
}
-
-
-
// At the drag drop area
// (drop)="onDropFile($event)"
onDropFile(_event: DragEvent) {
@@ -255,6 +343,7 @@ export class VideoEditComponent implements OnInit {
this.coverFile = this.selectedFiles[0];
console.log("select file " + this.coverFile.name);
this.uploadFile(this.coverFile);
+ this.updateNeedSend();
}
uploadFile(_file:File) {