r2978 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage webapp/js webapp/partials
Author: obruce Date: 2014-05-16 18:18:00 +0200 (Fri, 16 May 2014) New Revision: 2978 Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2978 Log: UI: ajout de la ajout et de suppression des periodes serveur : suppression des periodes Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java branches/ng-jtimer/src/main/webapp/js/controllers.js branches/ng-jtimer/src/main/webapp/js/entities.js branches/ng-jtimer/src/main/webapp/partials/tasks.html branches/ng-jtimer/src/main/webapp/partials/timeModal.html Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java =================================================================== --- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-15 12:50:25 UTC (rev 2977) +++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-16 16:18:00 UTC (rev 2978) @@ -60,8 +60,9 @@ } protected Connection getConnection() throws SQLException { - //TODO path a definir - String url = "/tmp/jtimer/jtimer"; + //TODO obruce 15-05-14 path a definir + //String url = "/tmp/jtimer/jtimer"; + String url = "/home/olivia/Bureau/jtimer/jtimer"; if (log.isInfoEnabled()) { log.info("Opening connection to database : " + url); } Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js =================================================================== --- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-15 12:50:25 UTC (rev 2977) +++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-16 16:18:00 UTC (rev 2978) @@ -9,7 +9,7 @@ $scope.todo = $localStorage.getTodo("todo"); // {Date} last update to server - $scope.acces = moment().format("DD-MM-YYYY H:mm:ss"); + $scope.access = $scope.todo.lastAccess; // {TreeNode} l'arbre regenere automatiquement lorsque les donnees changent $scope.tree; @@ -60,6 +60,14 @@ }; /** + * Methode qui retourne la date de derniere mise a jour(serveur) + * @returns moment + */ + $scope.getLastMajDate = function(){ + return moment($scope.access).format("YYYY-MM-DD H:mm:ss"); + }; + + /** * Permet de faire des actions sur la tache selectionne en fonction * des touches pressees * @param {type} e @@ -114,7 +122,7 @@ angular.forEach(response, function (item) { //On verife si l'element n'est pas deja present - if(!(item.taskId in $scope.data.tasks)){ + if(!(item.taskId in $scope.data.tasks) && !(item.timeId in $scope.todo.stockedDeletedTask)){ var newTask = new Task( item.name, item.taskId, item.parent); @@ -150,7 +158,7 @@ serverTimeAccess.query({taskId : task.taskId}, function (response) { angular.forEach(response, function (item) { - if(!(item.timeId in $scope.data.times[task.taskId])){ + if(!(item.timeId in $scope.data.times[task.taskId]) && !(item.timeId in $scope.todo.stockedDeletedTimes[task.taskId])){ //On cree le tasktime taskTime = new TaskTime(task, item.timeId, item.creationDate, item.time); $scope.data.times[task.taskId].push(taskTime); @@ -204,6 +212,7 @@ function(){ console.log("persist time success" + task); $scope.todo.stockedNewTimes[task].shift(); + console.log($scope.todo.stockedNewTimes[task]); }, function(){ console.log("fail"); @@ -225,6 +234,21 @@ }); }); + //On supprime de la base les taches sotckees pour suppression + angular.forEach($scope.todo.stockedDeletedTimes, function(times,task){ + angular.forEach(times, function(time){ + serverTimeAccess.delete({taskId: task}, angular.toJson(time), + function(){ + console.log("update time success" + task); + $scope.todo.stockedDeletedTimes[task].shift(); + }, + function(){ + console.log("fail"); + }); + }); + }); + + save(); } @@ -256,7 +280,7 @@ var timer = function() { $interval(function() { actionToServ(); - }, 30000); //TODO: for now 30s but for real put at least 2h: 200000000 + }, 30000); //TODO: obruce 05-05-14 for now 30s but for real put at least 2h: 200000000 }; timer(); @@ -271,7 +295,7 @@ getTasksFromServ(); //On change la date de dernier acces - $scope.acces = moment().format("DD-MM-YYYY H:mm:ss a"); + $scope.access = new Date().getTime(); } } @@ -595,17 +619,45 @@ modalInstance.result.then(function (item) { if(item.index != -1){ - //On met la valeur à jour - $scope.data.times[id][item.index].changeCreationDate(item.creationDate); - $scope.data.times[id][item.index].changeDuration(item.time); + if(item.action=='Modification'){ + //On met la valeur à jour + $scope.data.times[id][item.index].changeCreationDate(item.creationDate); + $scope.data.times[id][item.index].changeDuration(item.time); - //init - if(!$scope.todo.stockedEditedTimes[id]){$scope.todo.stockedEditedTimes[id]=[]; } + //init + if(!$scope.todo.stockedEditedTimes[id]){$scope.todo.stockedEditedTimes[id]=[]; } - //On ajoute dans la tdList - $scope.todo.stockedEditedTimes[id].push($scope.data.times[id][item.index]); + //On ajoute dans la tdList + $scope.todo.stockedEditedTimes[id].push($scope.data.times[id][item.index]); - save(); + save(); + } + + if(item.action=='Ajout'){ + //init + + if(!$scope.data.times[id]){$scope.data.times[id]= [];}; + if(!$scope.todo.stockedNewTimes[id]){$scope.todo.stockedNewTimes[id] = []}; + + //on cree le temps + var res = new TaskTime(node.task,undefined,item.creationDate,item.time); + $scope.data.times[id].push(res); + $scope.todo.stockedNewTimes[id].push(res); + save(); + } + + if(item.action == 'Suppression'){ + + if(!$scope.todo.stockedDeletedTimes[id]){$scope.todo.stockedDeletedTimes[id] = []}; + $scope.todo.stockedDeletedTimes[id].push($scope.data.times[id][item.index].timeId); + + $scope.data.times[id].splice(item.index,1); + //Todo obruce 15-5-2014 ajout de suppression du temps du serveur + + + save(); + } + } }); } @@ -641,17 +693,22 @@ // Les temps de la tache $scope.times = taskTimes; + $scope.dateobj={aTime : new Date(), date : new Date(),}; - //Le time selectionne - $scope.activTime = null; - - //L'objet retourner $scope.obj={}; - $scope.obj.creationDate=-1; - $scope.obj.time=-1; + $scope.obj.creationDate=new Date().getTime(); + $scope.obj.time=0; $scope.obj.index = -1; + $scope.obj.action = ''; + $scope.activTime = null; + + //Choix d'action + $scope.periodAction1 =function(){$scope.obj.action = "Ajout"; $scope.act}; + $scope.periodAction2 = function(){$scope.obj.action = "Modification";}; + $scope.periodAction3 = function(){$scope.obj.action = "Suppression";}; + //Pour l'affichage $scope.getStartTime = function(item){return moment(item.creationDate).format("DD-MM-YYYY H:mm:ss");} $scope.getStopTime = function(item){return item.time;} @@ -662,14 +719,15 @@ //selectionne un element dans le dropdown $scope.select = function(item, ind){ - $scope.activTime = item; //On intialise l'objet a envoyer $scope.obj.index = ind; $scope.obj.creationDate=item.creationDate; $scope.obj.time=item.time; - $scope.aTime = item.creationDate; + $scope.activTime = item; + + $scope.dateobj.aTime = new Date(item.creationDate); } // Methode a la fermeture avec ok @@ -683,6 +741,28 @@ }; }; +var datePickerCtrl = function($scope){ + + $scope.dateMaxPicker= new Date(); + + $scope.alert = function(){ + + var year = $scope.dateobj.date.getFullYear(); + var month = $scope.dateobj.date.getMonth(); + var date = $scope.dateobj.date.getDate(); + + var uneDate = new Date($scope.obj.creationDate); + uneDate.setFullYear(year,month,date); + + $scope.obj.creationDate = uneDate.getTime(); + + $scope.dateobj.aTime = uneDate; + }; +} + + + + var radioTimeCtrl = function ($scope){ //Activated button radio @@ -692,38 +772,40 @@ $scope.hstep = 1; $scope.mstep = 1; - //La date max - var maxDate = new Date($scope.activTime.creationDate); - maxDate.setHours(23,59,59,999); + $scope.obj.index= null; - /* * Méthode déclancher quand l'heure change dans le timepicker * Change l'objet du controller principal */ $scope.changeModel = function(){ + //La date max + var maxDate = new Date($scope.dateobj.aTime); + maxDate.setHours(23,59,59,999); + //Si On modifie sur la date de debut if(($scope.radioModel || 'null') == 'Left'){ + $scope.obj.creationDate = $scope.dateobj.aTime.getTime(); - $scope.obj.creationDate = $scope.aTime.getTime(); - //si crea+temps superieur à 23:59 if(($scope.obj.creationDate+$scope.obj.time) > maxDate.getTime()){ - $scope.aTime=maxDate.getTime()-$scope.obj.time; + $scope.dateobj.aTime=new Date(maxDate.getTime()-$scope.obj.time); $scope.obj.creationDate = maxDate.getTime()-$scope.obj.time; } }else{//On modifie la date de fin - - if($scope.aTime.getTime() > $scope.activTime.creationDate){ - //Si l'heure de fin est superieur a l'heure de depart - var duree = $scope.aTime.getTime() - $scope.obj.creationDate ; + //Si l'heure de fin est superieur a l'heure de depart + if($scope.dateobj.aTime.getTime() > $scope.obj.creationDate){ + var duree = $scope.dateobj.aTime.getTime() - $scope.obj.creationDate ; $scope.obj.time = duree; }else{ //Empeche de depasser 23:59 - $scope.aTime = maxDate; + $scope.dateobj.aTime = maxDate; $scope.obj.time = maxDate.getTime() - $scope.obj.creationDate; + console.log($scope.obj.time); + console.log(maxDate); + } } } @@ -731,9 +813,9 @@ //Change l'heure dans le timePicker selon debut/fin $scope.changeFonc=function(){ if(($scope.radioModel || 'null') == 'Left'){ - $scope.aTime = $scope.obj.creationDate; + $scope.dateobj.aTime = new Date($scope.obj.creationDate); }else{ - $scope.aTime = $scope.obj.creationDate + $scope.obj.time; + $scope.dateobj.aTime = new Date($scope.obj.creationDate + $scope.obj.time); } } }; Modified: branches/ng-jtimer/src/main/webapp/js/entities.js =================================================================== --- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-15 12:50:25 UTC (rev 2977) +++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-16 16:18:00 UTC (rev 2978) @@ -60,6 +60,7 @@ * @returns {tdListData} */ var tdListData = function(){ + this.lastAccess = new Date().getTime(); // {Array of TaskID} la file de tache attendant la synchronisation avec le serveur this.stockedDeletedTasks = []; // {Array of Task} file de tache attendant la synchronisation avec le serveur @@ -68,7 +69,8 @@ // {key: taskId, value: Array of TaskTime} la file de temps attendant la synchronisation avec le serveur this.stockedNewTimes = {}; this.stockedEditedTimes = {}; - + // {Array of TaskID} la file de temps attendant la synchronisation avec le serveur + this.stockedDeletedTimes = {}; }; @@ -93,6 +95,8 @@ } if (json) { + this.lastAccess = json.lastAccess; + angular.forEach(json.stockedDeletedTasks, function (t) { this.stockedDeletedTasks.push(t); }, this); @@ -122,6 +126,14 @@ this.stockedEditedTimes[k].push(t); }, this); }, this); + + angular.forEach(json.stockedDeletedTimes, function (times, k) { + this.stockedDeletedTimes[k] = []; + angular.forEach(times, function (t) { + t = jQuery.extend(new TaskTime(), t); + this.stockedDeletedTimes[k].push(t); + }, this); + }, this); } return this; @@ -328,13 +340,6 @@ return this; }; -/** - * Determine si le global time est vide - * @returns {GlobalTime} this - */ -GlobalTime.prototype.estVide = function() { - return (this.global) == 0; -}; /** * Ajoute les temps d'un tableau de TaskTime au temps global et a today si Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html =================================================================== --- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-15 12:50:25 UTC (rev 2977) +++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-16 16:18:00 UTC (rev 2978) @@ -31,7 +31,7 @@ <span class="left">{{currentDate()}}</span> <span class="center"><i class="fa fa-html5"></i> <a href="#">WebTimer</a></span> <!--<span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</span>--> - <span class="right">Dernier accès serveur: {{acces}}</span> + <span class="right">Dernière mise à jour: {{getLastMajDate()}}</span> </div> <div> @@ -78,7 +78,10 @@ <i class="glyphicon glyphicon-minus"></i> </a> - <a class="btn btn-default btn-xs" href="" ng-click="popup($node)" ng-show="!$node.getTime().estVide()"><i class="glyphicon glyphicon-pencil" ></i></a> + <a class="btn btn-default btn-xs" href="" ng-click="popup($node)" + ng-show="!$node.task.isRoot() "> + <i class="glyphicon glyphicon-pencil" ></i> + </a> Modified: branches/ng-jtimer/src/main/webapp/partials/timeModal.html =================================================================== --- branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-15 12:50:25 UTC (rev 2977) +++ branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-16 16:18:00 UTC (rev 2978) @@ -1,26 +1,71 @@ <div> - <h3> Modifier la tâche.</h3> + <h3> Edition de la tâche.</h3> - <div class="btn-group" dropdown is-open="status.isopen" ng-show="activTime == null"> + <div class="btn-group" dropdown is-open="status.isopen" ng-show="obj.action==''"> <button type="button" class="btn btn-primary dropdown-toggle"> + Action à faire sur la tâche: <span class="caret"></span> + </button> + <ul class="dropdown-menu" role="menu"> + <li><a href="#" ng-click="periodAction1()">Ajouter une periode</a></li> + <li><a href="#" ng-click="periodAction2()">Modifier une periode</a></li> + <li><a href="#" ng-click="periodAction3()">Supprimer une periode</a></li> + </ul> + + </div> + + <h4 ng-show="obj.action != ''"> {{obj.action}} d'une période</h4> + + <!-- Div dropdown choix de periode --> + <div class="btn-group" dropdown is-open="status.isopen" ng-if="!activTime && obj.action !='' && obj.action !='Ajout'"> + <button type="button" class="btn btn-primary dropdown-toggle"> Les périodes pour la tâche sélectionnée : <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li ng-repeat="(index,item) in times" > - <span ng-click="select(item, index)"> + <a href="#" ng-click="select(item, index)"> Début : {{getStartTime(item)}} - Durée : {{getStopTime(item)| time}} - </span> + </a> </li> </ul> </div> - <div ng-if = "activTime != null"> + <!-- div ajout d'une periode --> + <div ng-if = " obj.action=='Ajout'"> + <hr/> - <h4>Période : Début : {{getStartTime(activTime)}} - Durée : {{getStopTime(activTime)| time}}</h4> + <div class ="timepick"> + <div ng-controller="datePickerCtrl" style="display:inline-block; min-height:290px;"> + <datepicker ng-model="dateobj.date" ng-change="alert()" min-date="minDate" max-date="dateMaxPicker" show-weeks="true" class="well well-sm"></datepicker> + </div> + + <div ng-controller="radioTimeCtrl"> + <div> + <div class="btn-group"> + <label class="btn btn-primary" ng-model="radioModel" ng-change="changeFonc()" btn-radio="'Left'">Début de période </label> + <label class="btn btn-primary" ng-model="radioModel" ng-change="changeFonc()" btn-radio="'Right'">Fin de période </label> + </div> + </div> + <div class="timepick"> + <timepicker + ng-model="dateobj.aTime" ng-change="changeModel()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian"> + </timepicker> + </div> + + </div> + </div> + <alert type="info" >Début : {{getStartObjTime()}} - Fin : {{getStopObjTime()}} - Duree : {{getObjDuration() | time}} </alert> + </div> + + + + <!-- div modification d'une periode --> + <div ng-if = "activTime && obj.action=='Modification'"> + <hr/> + <alert type="danger" >Choisir une période :</alert> <div class = "timepick" ng-controller="radioTimeCtrl"> @@ -38,7 +83,7 @@ <div class = "timepick"> <timepicker - ng-model="aTime" ng-change="changeModel()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian"> + ng-model="dateobj.aTime" ng-change="changeModel()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian"> </timepicker> </div> <br/> @@ -50,6 +95,11 @@ </div> + <!-- div suppression d'une periode --> + <div ng-if = "activTime && obj.action=='Suppression'"> + <alert type="danger" > La période suivante va être supprimée :<br/> + Début : {{getStartObjTime()}} - Fin : {{getStopObjTime()}} - Duree : {{getObjDuration() | time}} </alert> + </div> <div class="modal-footer">
participants (1)
-
obruce@users.chorem.org