Commit 974540c7 authored by Nezael's avatar Nezael
Browse files

Merge branch '189-ajouter-le-dessin-a-main-leve' into paperboard

parents 7a7ec865 cec74ba8
......@@ -17,7 +17,7 @@ ui-sref="project.workshops.overview">{{::_labels.disconnectWorkshopBtn}}
<button>Blue</button>
<button>Red</button>
<button>Cursor</button>
<button>Pen</button>
<button ng-click="paperBoardCtrl.penMode()">Pen</button>
<button>Circle</button>
<button>Square</button>
<button>Add Post-It</button>
......
......@@ -7,10 +7,22 @@
/* Controllers */
root.controller('DetailsPaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state', '$paperboardFactory', '$languageFactory', '$utilsFactory', function ($scope, $stateParams, $http, $state, $paperboardFactory, $languageFactory, $utilsFactory) {
var detailsPaperBoardCtrl = this;
root.controller('PaperBoardCtrl', ['$scope', '$stateParams', '$http', '$state', '$paperboardFactory', '$languageFactory', '$utilsFactory', function ($scope, $stateParams, $http, $state, $paperboardFactory, $languageFactory, $utilsFactory) {
let paperBoardCtrl = this;
detailsPaperBoardCtrl.getPaperBoardDetails = function (paperBoardDetails) {
let canvas = document.querySelector('#drawZone');
let ctx = canvas.getContext("2d");
let rect;
let mouseX = 0;
let mouseY = 0;
let lineWidth = 3;
let isDrawing = false;
let style = "#000";
let pen = false;
paperBoardCtrl.getPaperBoardDetails = function (paperBoardDetails) {
if (!paperBoardDetails) var paperBoardDetails = {"id": $stateParams.elementId};
$scope._showAlert({status: 2, message: $languageFactory._labels.alerts_loadingpaperBoardDetails});
......@@ -18,10 +30,10 @@ root.controller('DetailsPaperBoardCtrl', ['$scope', '$stateParams', '$http', '$s
{
if (data.status == "success")
{
var paperboard = data.details[0];
detailsPaperBoardCtrl.paperboard = JSON.parse(paperboard.params);
detailsPaperBoardCtrl.paperboard.id = paperboard.id;
detailsPaperBoardCtrl.paperboard.type = 1;
let paperboard = data.details[0];
paperBoardCtrl.paperboard = JSON.parse(paperboard.params);
paperBoardCtrl.paperboard.id = paperboard.id;
paperBoardCtrl.paperboard.type = 1;
$scope._showAlert({status: 1, message: $languageFactory._labels.alerts_loadingpaperBoardDetailsSuccess});
}
else
......@@ -31,11 +43,64 @@ root.controller('DetailsPaperBoardCtrl', ['$scope', '$stateParams', '$http', '$s
});
}
paperBoardCtrl.lineDraw = function (ctx, x1, y1, x2, y2, styleColor, lineWidth)
{
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.lineCap = ctx.lineJoin = 'round';
ctx.strokeStyle = styleColor;
ctx.shadowColor = styleColor;
ctx.lineWidth = lineWidth;
ctx.stroke();
ctx.closePath();
}
paperBoardCtrl.penMode = function ()
{
pen = true;
}
$scope.leaveBoard = function(){
alert("Vous venez de quitter l'atelier");
alert("Vous venez de quitter l'atelier");
}
detailsPaperBoardCtrl.getPaperBoardDetails();
paperBoardCtrl.getPaperBoardDetails();
document.querySelector('#lineWidth').addEventListener('change', e =>
{
lineWidth = document.querySelector('#lineWidth').value;
});
canvas.addEventListener('mousedown', e=>
{
rect = canvas.getBoundingClientRect();
mouseX = e.clientX - rect.left;
mouseY = e.clientY - rect.top;
console.log("position souris X: " + e.clientX + "position canvas X: " + rect.left);
console.log("position souris Y: " + e.clientY + "position canvas Y: " + rect.top)
console.log("X: " + mouseX + " : Y: " + mouseY);
isDrawing = true;
});
canvas.addEventListener('mousemove', e=>
{
if(isDrawing)
{
if(pen)
{
console.log("après dessin X: " + mouseX + " : Y: " + mouseY);
paperBoardCtrl.lineDraw(ctx,mouseX,mouseY,e.clientX - rect.left, e.clientY - rect.top, style, lineWidth);
mouseX = e.clientX - rect.left;
mouseY = e.clientY - rect.top;
}
}
});
canvas.addEventListener('mouseup', e =>
{
isDrawing = false;
});
}]);
......@@ -16,7 +16,7 @@ $frontEndServer = "";
$serverType = "";
$listUrls = url_config_front::$listUrls;
$chatServerUrl = url_config_front::$chatServerUrl;
$root = $_SERVER["REQUEST_URI"];
if ($_SERVER && isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
......
......@@ -24,6 +24,7 @@
var __version = "<?php echo $version;?>";
var __backEndServer = "<?php echo $backEndServer;?>";
var __frontEndServer = "<?php echo isset($frontEndServer) ? $frontEndServer : '';?>";
var __chatServer = "<?php echo isset($chatServerUrl) ? $chatServerUrl : '';?>";
var __root = "<?php echo $root;?>";
var __serverType = "<?php echo $serverType;?>";
var __casUser = "<?php echo $_SERVER["REDIRECT_REMOTE_USER"];?>";
......
......@@ -434,8 +434,8 @@ angular.module('myApp', [
$stateProvider.state('project.workshops.paperboard', {
url: '/:elementId',
templateUrl: __root + 'components/projects/workshops/paperboard.html',
controller: 'DetailsPaperBoardCtrl',
controllerAs: "detailsPaperBoardCtrl",
controller: 'PaperBoardCtrl',
controllerAs: "paperBoardCtrl",
params: {
section: {
elementId: true,
......
function $socketIOFactory($rootScope, $rightFactory, $chatFactory, $chatEventsFactory, $chatModelFactory) {
function $socketIOFactory($rootScope, $rightFactory, $chatFactory, $chatEventsFactory, $chatModelFactory,) {
let returns = {};
const URL = "http://localhost:8080";
const URL = __chatServer;
let socket = null;
// initialise socketIO.
......
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