Commit 8a047882 authored by Matthieu Le Corre's avatar Matthieu Le Corre

setup code styling tools

parent 7c678678
module.exports = {
extends: [
'@nextcloud',
"plugin:nextcloud/recommended"
],
}
\ No newline at end of file
node_modules
.vscode/
\ No newline at end of file
.vscode/
vendor
\ No newline at end of file
{"php":"7.3.14-1~deb10u1","version":"2.16.3:v2.16.3#83baf823a33a1cbd5416c8626935cf3f843c10b0","indent":"\t","lineEnding":"\n","rules":{"encoding":true,"full_opening_tag":true,"blank_line_after_namespace":true,"braces":{"position_after_anonymous_constructs":"same","position_after_control_structures":"same","position_after_functions_and_oop_constructs":"same"},"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":{"closure_function_spacing":"one"},"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["property","method","const"]},"align_multiline_comment":true,"array_indentation":true,"array_syntax":{"syntax":"short"},"blank_line_after_opening_tag":true,"no_unused_imports":true},"hashes":{"lib\/Migration\/Version000001Date20200416.php":1953890070,"lib\/AppInfo\/Application.php":174795872,"lib\/Collaboration\/CollaborationEngine.php":2351675227,"lib\/Collaboration\/SimpleFileCollaborationEngine.php":2415317954,"lib\/Collaboration\/ICollaborationEngine.php":2942581184,"lib\/Controller\/FileController.php":2479672228,"lib\/Controller\/CollaborationController.php":2467698673,"lib\/Db\/UserMapper.php":3118327894,"lib\/Db\/StepMapper.php":2228899967,"lib\/Db\/Step.php":730276846,"lib\/Db\/User.php":924648166,"appinfo\/app.php":2708770990,"appinfo\/routes.php":3100920729}}
\ No newline at end of file
<?php
declare(strict_types=1);
require_once './vendor/autoload.php';
use Nextcloud\CodingStandard\Config;
$config = new Config();
$config
->getFinder()
->ignoreVCSIgnored(true)
->notPath('build')
->notPath('l10n')
->notPath('src')
->notPath('vendor')
->in(__DIR__);
return $config;
\ No newline at end of file
{
"require-dev": {
"nextcloud/coding-standard": "^0.3.0"
},
"scripts": {
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix"
}
}
This diff is collapsed.
This diff is collapsed.
......@@ -8,10 +8,26 @@
"license": "AGPL-3.0",
"scripts": {
"build": "NODE_ENV=production webpack --progress --hide-modules --config webpack.prod.js ",
"dev": "NODE_ENV=none webpack --progress --config webpack.dev.js ",
"watch": "NODE_ENV=none webpack --progress --watch --config webpack.dev.js "
"dev": "NODE_ENV=development webpack --progress --config webpack.dev.js ",
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.dev.js ",
"lint": "eslint --ext .js,.vue src",
"lint:fix": "eslint --ext .js,.vue src --fix",
"stylelint": "stylelint src",
"stylelint:fix": "stylelint src --fix"
},
"devDependencies": {
"@nextcloud/eslint-config": "^2.0.0",
"@nextcloud/eslint-plugin": "^1.4.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-config-standard": "^12.0.0",
"eslint-loader": "^3.0.4",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-nextcloud": "^0.3.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-vue": "^6.2.2",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11"
},
......
......@@ -18,156 +18,156 @@
*
*/
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' ;
import { emit } from '@nextcloud/event-bus'
/**
* @namespace collaborationEngine
*/
export default {
name: 'collaborationEngine',
start: function(app_name,filename,context) {
var self = this ;
this.app_name = app_name ;
this.filename = filename ;
this.context = context ;
this.SSE_URL = OC.generateUrl('apps/'+this.app_name+'/collaboration/event');
this.SSE_OPT = {withCredentials:true} ;
this.init().then(function(data) {
console.log("CE : Collaboration started for "+ self.app_name) ;
self.addUser() ;
// because we may arrive in an allready running session
// get all steps from last last save
self.getSteps().then(function(steps){
steps.forEach(step => emit(self.app_name+"::externalAddStep",step)) ;
})
// start pulling for change
self.communicationStarted = true ;
console.log("CE : starting communication ") ;
self.startCommunication() ;
});
},
stop: function() {
this.removeUser() ;
this.stopCommunication() ;
console.log("CE : Collaboration stopped for "+ this.app_name) ;
},
init: function() {
var url = OC.generateUrl('apps/'+this.app_name+'/collaboration/startsession');
this.id = window.FileList.findFile(this.filename).id
var ajx = $.ajax({
type: 'POST',
url: url,
data: {id: this.id }
}) ;
return ajx.promise() ;
},
addUser: function() {
var url = OC.generateUrl('apps/'+this.app_name+'/collaboration/adduser');
console.log("CE : Adding user " + OC.currentUser ) ;
var ajx = $.ajax({
type: 'POST',
url: url,
data: {id: this.id,
user: OC.currentUser
}
}) ;
return ajx.promise() ;
},
removeUser: function() {
var url = OC.generateUrl('apps/'+this.app_name+'/collaboration/removeuser');
console.log("CE : Removing user " + OC.currentUser ) ;
var ajx = $.ajax({
type: 'POST',
url: url,
data: {id: this.id,
user: OC.currentUser
}
}) ;
return ajx.promise() ;
},
sendStep: function(payload) {
var url = OC.generateUrl('apps/'+this.app_name+'/collaboration/addstep');
console.log("CE : Sending ",payload.type," step" ) ;
var ajx = $.ajax({
type: 'POST',
url: url,
data: {id: this.id,
user: OC.currentUser,
type: payload.type,
step: JSON.stringify(payload.step)
}
}) ;
return ajx.promise() ;
},
getSteps: function() {
var url = OC.generateUrl('apps/'+this.app_name+'/collaboration/getsteps');
console.log("CE : Getting initial steps") ;
var ajx = $.ajax({
type: 'GET',
url: url,
data: {
id: this.id
}
}) ;
return ajx.promise() ;
},
startCommunication: function() {
var self = this ;
this.longPull().done(function(steps) {
steps.forEach(function (step) {
if (step.userId != OC.currentUser) {
emit(self.app_name+"::externalAddStep",step) ;
console.log("CE : A step for me !") ;
} ;
}) ;
if (self.communicationStarted == true) {
self.startCommunication() ;
}
})
},
longPull: function() {
var url = OC.generateUrl('apps/'+this.app_name+'/collaboration/pushstep');
console.log("CE : Poll again ...") ;
var ajx = $.ajax({
type: 'GET',
url: url,
data: {
id: this.id,
user: OC.currentUser
}
}) ;
return ajx.promise() ;
},
stopCommunication: function(){
this.communicationStarted = false ;
// this.source.close() ;
}
name: 'collaborationEngine',
start: function(appName, filename, context) {
const self = this
this.appName = appName
this.filename = filename
this.context = context
this.SSE_URL = OC.generateUrl('apps/' + this.appName + '/collaboration/event')
this.SSE_OPT = { withCredentials: true }
this.init().then(function(data) {
console.log('CE : Collaboration started for ' + self.appName)
self.addUser()
// because we may arrive in an allready running session
// get all steps from last last save
self.getSteps().then(function(steps) {
steps.forEach(step => emit(self.appName + '::externalAddStep', step))
})
// start pulling for change
self.communicationStarted = true
console.log('CE : starting communication ')
self.startCommunication()
})
},
stop: function() {
this.removeUser()
this.stopCommunication()
console.log('CE : Collaboration stopped for ' + this.appName)
},
init: function() {
const url = OC.generateUrl('apps/' + this.appName + '/collaboration/startsession')
this.id = window.FileList.findFile(this.filename).id
const ajx = $.ajax({
type: 'POST',
url: url,
data: { id: this.id },
})
return ajx.promise()
},
addUser: function() {
const url = OC.generateUrl('apps/' + this.appName + '/collaboration/adduser')
console.log('CE : Adding user ' + OC.currentUser)
const ajx = $.ajax({
type: 'POST',
url: url,
data: { id: this.id,
user: OC.currentUser,
},
})
return ajx.promise()
},
removeUser: function() {
const url = OC.generateUrl('apps/' + this.appName + '/collaboration/removeuser')
console.log('CE : Removing user ' + OC.currentUser)
const ajx = $.ajax({
type: 'POST',
url: url,
data: { id: this.id,
user: OC.currentUser,
},
})
return ajx.promise()
},
sendStep: function(payload) {
const url = OC.generateUrl('apps/' + this.appName + '/collaboration/addstep')
console.log('CE : Sending ', payload.type, ' step')
const ajx = $.ajax({
type: 'POST',
url: url,
data: { id: this.id,
user: OC.currentUser,
type: payload.type,
step: JSON.stringify(payload.step),
},
})
return ajx.promise()
},
getSteps: function() {
const url = OC.generateUrl('apps/' + this.appName + '/collaboration/getsteps')
console.log('CE : Getting initial steps')
const ajx = $.ajax({
type: 'GET',
url: url,
data: {
id: this.id,
},
})
return ajx.promise()
},
startCommunication: function() {
const self = this
this.longPull().done(function(steps) {
steps.forEach(function(step) {
if (step.userId != OC.currentUser) {
emit(self.appName + '::externalAddStep', step)
console.log('CE : A step for me !')
}
})
if (self.communicationStarted == true) {
self.startCommunication()
}
})
},
longPull: function() {
const url = OC.generateUrl('apps/' + this.appName + '/collaboration/pushstep')
console.log('CE : Poll again ...')
const ajx = $.ajax({
type: 'GET',
url: url,
data: {
id: this.id,
user: OC.currentUser,
},
})
return ajx.promise()
},
stopCommunication: function() {
this.communicationStarted = false
// this.source.close() ;
},
}
......@@ -19,120 +19,120 @@
*/
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
export default {
name: "editor",
start: function (app_name,filename,context) {
var self = this ;
this.app_name = app_name ;
this.filename = filename ;
this.context = context ;
this.init().then(function(){
self.loadContent() ;
self.setupCallbacks() ;
}) ;
},
init: function () {
return import(/* webpackChunkName: "literallycanvas" */ "literallycanvas").then(LC => {
this.LC = LC ;
this.whiteboard = LC.init(
document.getElementById(this.app_name+'-editor'),
{
imageURLPrefix: OC.linkTo(this.app_name,'img/lc_assets') ,
toolbarPosition: 'top'
}
)
}) ;
},
//load whiteboard
loadContent: function() {
var self = this ;
var url = OC.generateUrl('apps/'+this.app_name+'/file/load');
$.ajax({
type: 'GET',
url: url,
data: {path: this.context.dir + "/" + this.filename }
}).done(function(content){
//console.log("WB : loaded") ;
if (content.trim() != "" ) {
self.whiteboard.loadSnapshot(JSON.parse(content)) ;
} ;
}) ;
},
//save whiteboard
saveContent: function() {
var self = this ;
var url = OC.generateUrl('apps/'+this.app_name+'/file/save');
var postObject = {
content: JSON.stringify(this.whiteboard.getSnapshot()),
path: this.context.dir + "/" + this.filename
};
$.ajax({
type: 'POST',
url: url,
data: postObject
}).done(function(content){
OC.Notification.showTemporary("File saved") ;
var payload = {
'type' : 'save',
'step' : 'NA'
} ;
emit(self.app_name+"::editorAddStep",payload) ;
})
},
//setup callback
setupCallbacks: function (){
var self = this ;
// set save callback
//this.whiteboard.on('drawingChange', function(data) {
//emit(self.app_name+"::editorContentChange",data) ,
//self.saveContent() ;
//});
this.whiteboard.on('shapeSave', function(data) {
var payload = {
'type' : 'shapeSave',
'step' : self.LC.shapeToJSON(data.shape)
} ;
emit(self.app_name+"::editorAddStep",payload) ;
console.log("ED: Creating NewShape ") ;
return data ;
});
},
//destroy editor
stop: function() {
this.whiteboard.teardown() ;
},
applyChange: function(step) {
switch (step.stepType) {
case 'shapeSave':
var shapeStep = this.LC.JSONToShape(JSON.parse(step.stepData)) ;
this.whiteboard.saveShape(shapeStep,false) ;
break ;
default: console.warn("unknown step type")
}
},
}
\ No newline at end of file
export default {
name: 'editor',
start: function(app_name, filename, context) {
const self = this
this.app_name = app_name
this.filename = filename
this.context = context
this.init().then(function() {
self.loadContent()
self.setupCallbacks()
})
},
init: function() {
return import(/* webpackChunkName: "literallycanvas" */ 'literallycanvas').then(LC => {
this.LC = LC
this.whiteboard = LC.init(
document.getElementById(this.app_name + '-editor'),
{
imageURLPrefix: OC.linkTo(this.app_name, 'img/lc_assets'),
toolbarPosition: 'top',
}
)
})
},
// load whiteboard
loadContent: function() {
const self = this
const url = OC.generateUrl('apps/' + this.app_name + '/file/load')
$.ajax({
type: 'GET',
url: url,
data: { path: this.context.dir + '/' + this.filename },
}).done(function(content) {
// console.log("WB : loaded") ;
if (content.trim() != '') {
self.whiteboard.loadSnapshot(JSON.parse(content))
}
})
},
// save whiteboard
saveContent: function() {
const self = this
const url = OC.generateUrl('apps/' + this.app_name + '/file/save')
const postObject = {
content: JSON.stringify(this.whiteboard.getSnapshot()),
path: this.context.dir + '/' + this.filename,
}
$.ajax({
type: 'POST',
url: url,
data: postObject,
}).done(function(content) {
OC.Notification.showTemporary('File saved')
const payload = {
'type': 'save',
'step': 'NA',
}
emit(self.app_name + '::editorAddStep', payload)
})
},
// setup callback
setupCallbacks: function() {
const self = this
// set save callback
// this.whiteboard.on('drawingChange', function(data) {
// emit(self.app_name+"::editorContentChange",data) ,
// self.saveContent() ;
// });
this.whiteboard.on('shapeSave', function(data) {
const payload = {
'type': 'shapeSave',
'step': self.LC.shapeToJSON(data.shape),
}
emit(self.app_name + '::editorAddStep', payload)
console.log('ED: Creating NewShape ')
return data
})
},
// destroy editor
stop: function() {
this.whiteboard.teardown()
},
applyChange: function(step) {
switch (step.stepType) {
case 'shapeSave':
var shapeStep = this.LC.JSONToShape(JSON.parse(step.stepData))
this.whiteboard.saveShape(shapeStep, false)
break
default: console.warn('unknown step type')