Commit dcf45b0f authored by Matthieu Le Corre's avatar Matthieu Le Corre

Fix backend and add steps clean step

Signed-off-by: Matthieu Le Corre's avatarMatthieu Le Corre <matthieu.lecorre@univ-nantes.fr>
parent 98eafbb8
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -88,14 +88,14 @@ class CollaborationEngine {
$cnt = count($this->UserMapper->findAll($this->AppName,$fileId)) ;
if ( $cnt == 0 ) {
// delete all steps for this file
$this->StepMapper->removeAll($fileId) ;
}
return "user removed" ;
}
// ALMOST DONE
// DONE
public function addStep(int $fileId,string $user, string $type, string $datas) {
$Nstep = new Step() ;
......@@ -114,12 +114,14 @@ class CollaborationEngine {
// DONE
public function getSteps($fileId) {
return $this->StepMapper->findAll($this->AppName,$fileId) ;
$result =$this->StepMapper->findAll($this->AppName,$fileId) ;
return $result ;
}
// DONE
public function getUserList($fileId) {
return $this->UserMapper->findAll($this->AppName,$fileId) ;
$result = $this->UserMapper->findAll($this->AppName,$fileId) ;
return $result ;
}
// DONE
......
......@@ -35,7 +35,6 @@ class FileController extends Controller {
$this->userFolder = $userFolder;
}
/**
* @NoAdminRequired
*/
......
......@@ -63,7 +63,7 @@ Class StepMapper extends QBMApper {
$sub = $this->db->getQueryBuilder() ;
$sub->select('step_id')
$sub->select('*')
->from($this->getTableName())
->Where(
$sub->expr()->eq('step_type',$sub->createNamedParameter('save', IQueryBuilder::PARAM_STR))
......@@ -71,7 +71,7 @@ Class StepMapper extends QBMApper {
->orderBy('step_id','DESC')
->setMaxResults(1) ;
$lastSave = $this->findEntities($sub) ;
$lastSave = $this->findEntity($sub) ;
$qb->select('*')
->from($this->getTableName())
......@@ -83,14 +83,25 @@ Class StepMapper extends QBMApper {
if (count($lastSave) != 0) {
$qb->andWhere(
$qb->expr()->gt('step_id',$qb->createNamedParameter($lastSave->getSteptId, IQueryBuilder::PARAM_INT))
$qb->expr()->gt('step_id',$qb->createNamedParameter($lastSave->getStepId(), IQueryBuilder::PARAM_INT))
);
} ;
$qb->orderBy('step_id','DESC') ;
$qb->orderBy('step_id','ASC') ;
return $this->findEntities($qb) ;
}
public function removeAll(int $file_id) {
$qb = $this->db->getQueryBuilder();
$qb->delete('cengine_steps')
->where(
$qb->expr()->eq('file_id', $qb->createNamedParameter($file_id, IQueryBuilder::PARAM_INT))
) ;
$qb->execute() ;
}
}
\ No newline at end of file
......@@ -80,10 +80,8 @@ export default {
const url = generateUrl('apps/' + this.appname + '/file/save')
axios.post(url, {
param: {
content: JSON.stringify(this.whiteboard.getSnapshot()),
path: this.context.dir + '/' + this.filename,
},
content: JSON.stringify(this.whiteboard.getSnapshot()),
path: this.context.dir + '/' + this.filename,
}).then(function(content) {
OC.Notification.showTemporary('File saved')
const payload = {
......@@ -113,10 +111,20 @@ export default {
'step': self.LC.shapeToJSON(data.shape),
}
emit(self.appname + '::editorAddStep', payload)
// console.log('ED: Creating NewShape ')
return data
})
/*
this.whiteboard.on('backgroundColorChange', function(data) {
const payload = {
'type': 'backgroundColorChange',
'step': data,
}
emit(self.appname + '::editorAddStep', payload)
return data
})
*/
},
// destroy editor
......@@ -130,9 +138,17 @@ export default {
const shapeStep = this.LC.JSONToShape(JSON.parse(step.stepData)) // eslint-disable-line
this.whiteboard.saveShape(shapeStep, false)
break
default: console.warn('unknown step type')
case 'backgroundColorChange':
this.whiteboard.setColor('background', step.stepData)
break
case 'undo':
this.whiteboard.undo()
break
case 'redo':
this.whiteboard.undo()
break
default: console.warn('ED : Unknown step type')
}
},
}
......@@ -184,7 +184,6 @@ export default {
// local changes => send to Engine
subscribe(this.APP_NAME + '::editorAddStep', this.EDS = (data) => {
self.CE.sendStep(data).then(function() {
// console.log("CE: sendingStep Done",data) ;
})
})
......@@ -200,6 +199,9 @@ export default {
// stop editing
stopEdit: function() {
// save the content
this.ED.saveContent()
// unsubscribe from bus event
unsubscribe(this.APP_NAME + '::editorAddStep', this.EDS)
unsubscribe(this.APP_NAME + '::externalAddStep', this.EAS)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment