Author: obruce Date: 2014-08-21 17:57:32 +0200 (Thu, 21 Aug 2014) New Revision: 3030 Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3030 Log: changement au niveau des taches cachees et de l'import Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java branches/ng-jtimer/src/main/resources/jtimer-default.properties branches/ng-jtimer/src/main/webapp/css/app.css branches/ng-jtimer/src/main/webapp/js/app.js 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/reportModal.html branches/ng-jtimer/src/main/webapp/partials/settings.html branches/ng-jtimer/src/main/webapp/partials/tasks.html Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java =================================================================== --- branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/io/GTimerDataLoader.java 2014-08-21 15:57:32 UTC (rev 3030) @@ -583,6 +583,8 @@ folder.mkdir(); } + log.warn("le fichier" + zipFile); + // We get zip's content ZipInputStream zip = new ZipInputStream(new FileInputStream(zipFile)); 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-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-08-21 15:57:32 UTC (rev 3030) @@ -218,7 +218,7 @@ statement.executeUpdate(); - String[] path; + String[] path= new String[]{task.getTaskId()};; //On recupere le path du parent if(!task.getParent().equals("")) { @@ -232,22 +232,23 @@ try { rs.first(); Object[] parentArray = (Object[]) rs.getObject("path"); - path = new String[parentArray.length + 1]; - int cpt = 0; - for(Object s : parentArray){ - parentArray[cpt] = s; - cpt++; + if(parentArray != null) { + path = new String[parentArray.length + 1]; + + int cpt = 0; + for (Object s : parentArray) { + parentArray[cpt] = s; + cpt++; + } + + path[parentArray.length] = task.getTaskId(); } - path[parentArray.length] = task.getTaskId(); - }catch(JdbcSQLException eee){ log.error(eee); path = new String[]{task.getTaskId()}; } - } else { - path = new String[]{task.getTaskId()}; } updateTaskPath(task.getTaskId(), path); @@ -373,18 +374,19 @@ task.setDescription(rs.getString("description")); Object[] obj = (Object[]) rs.getObject("tags"); - String[] tag = new String[obj.length]; - log.warn(ArrayUtils.toString(obj)); - int cpt = 0; + if(obj != null) { + String[] tag = new String[obj.length]; - for(Object s :obj){ - tag[cpt] = (String)s; - cpt++; + int cpt = 0; + for (Object s : obj) { + tag[cpt] = (String) s; + cpt++; + } + + task.setTags(tag); } - task.setTags(tag); - task.setTodayTime(0); task.setCreationDate(new java.util.Date((rs.getTimestamp("creationDate").getTime()))); task.setModificationDate(new java.util.Date(rs.getTimestamp("modificationDate").getTime())); Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java =================================================================== --- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ImportResource.java 2014-08-21 15:57:32 UTC (rev 3030) @@ -1,11 +1,15 @@ package org.chorem.jtimer.web; +import com.google.gson.Gson; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.jtimer.io.DataHandler; +import org.restlet.data.MediaType; import org.restlet.representation.Representation; +import org.restlet.representation.StringRepresentation; import org.restlet.resource.Post; +import java.io.File; import java.io.IOException; /** @@ -24,13 +28,32 @@ * suite d'une requête de type POST */ @Post("json") - public void importTasks(Representation representation) throws IOException { + public Representation importTasks(Representation representation) throws IOException { + //Le message a retourner + String json = "No available path."; + if(representation.isAvailable()) { - DataHandler g = new DataHandler(storage); - g.migrateData(); - //g.migrateData(representation.getText()); + + //Le path du fichier + Gson gson = new Gson(); + String path = gson.fromJson(representation.getText(), String.class); + + File file = new File(path); + + if(file.exists()){ + DataHandler g = new DataHandler(storage); + + g.migrateData(path); + + json = "{\"message\" : \"Ok\"}"; + + }else{ + json = "{\"message\" : \"The file doesn't exist\"}"; + } } + + return new StringRepresentation(json, MediaType.APPLICATION_JSON); } } Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties =================================================================== --- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-08-21 15:57:32 UTC (rev 3030) @@ -2,7 +2,7 @@ # jTimer default properties ### # jTimer storage path -jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDtag +jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/BDDtag3 ### # SQL properties ### Modified: branches/ng-jtimer/src/main/webapp/css/app.css =================================================================== --- branches/ng-jtimer/src/main/webapp/css/app.css 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-08-21 15:57:32 UTC (rev 3030) @@ -417,4 +417,8 @@ .borderedbottom{ border-bottom : 1px solid #E8E8E8; +} + +.glyphSizeSmall{ + font-size:10px; } \ No newline at end of file Modified: branches/ng-jtimer/src/main/webapp/js/app.js =================================================================== --- branches/ng-jtimer/src/main/webapp/js/app.js 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/webapp/js/app.js 2014-08-21 15:57:32 UTC (rev 3030) @@ -22,7 +22,7 @@ * @param {ngFilter} $filter permet de filtrer les elements de l'arbre a afficher (filtre, tri, ...) * @param {ngParse} $parse permet de parser des expressions qui doivent etre evaluer regulierement sur une scope */ -var wtTreeRepeatDirective = ['$animate', '$filter', '$parse', function($animate, $filter, $parse) { +var wtTreeRepeatDirective = ['$animate', '$filter', '$parse','settings', function($animate, $filter, $parse, settings) { return { transclude: 'element', priority: 1000, @@ -108,8 +108,8 @@ // new item which we don't know about var childScope = cacheEntry.scope; - - if (node.children.length === 0) { + + if (node.children.length === 0 || (node.hasAllChildHidden(true) && !settings.showHidden)) { state = 'empty'; } else { if (node.$$open || forceOpen($scope)) { Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js =================================================================== --- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-08-21 15:57:32 UTC (rev 3030) @@ -12,9 +12,9 @@ $scope.taskAccess = $scope.todo.lastTaskAccess; $scope.timeAccess = $scope.todo.lastTimeAccess; - //interval de conec - var interval = 60000; //TODO: obruce 05-05-14 decider d'un intervalle interessant - // periode de delais = 3 periode +1msec + //{int} interval de conec + var interval = 5 * 60000; + // {int} delais pour avoir acces au modifications sur plusieurs inter var delayAccess = interval + 1; @@ -28,6 +28,7 @@ $scope.selectedTask = null; // {Task} la tache en cours de timing $scope.currentTask = null; + $scope.currentTime = null; // {Date in millis} le temps pour la tache en cours de timing $scope.currentTaskDate = null; @@ -126,16 +127,30 @@ } else if (e.keyCode === 73 && e.ctrlKey && e.shiftKey) { // increment by 30min taskTime.addTime(30*60*1000); + update(); } else if (e.keyCode === 68 && e.ctrlKey && e.shiftKey) { // decrement by 30min taskTime.addTime(-30*60*1000); + update(); } else if (e.keyCode === 73 && e.ctrlKey) { // increment by 5min taskTime.addTime(5*60*1000); + update(); } else if (e.keyCode === 68 && e.ctrlKey) { // decrement by 5min taskTime.addTime(-5*60*1000); + update(); } + var update = function(){ + serverTimeAccess.update({taskId: $scope.selectedTask.taskId,dispatch:true}, angular.toJson(taskTime), + function(){ + console.log("update time success" ); + }, + function(){ + console.log("fail"); + $scope.todo.stockedEditedTimes[$scope.selectedTask.taskId].push(taskTime); + }); + }; } }; @@ -182,6 +197,22 @@ var now = Date.now(); var taskTime = $scope.getRecentTaskTime($scope.currentTask); taskTime.addTime(now - $scope.currentTaskDate); + + // toutes les 5 minutes on update la periode en cours + if((parseInt(taskTime.time/ 1000) % (5 *60)) == 0){ + + var prom = serverTimeAccess.update({taskId: taskTime.taskId,dispatch:true}, angular.toJson(taskTime)).$promise; + + prom.then(function(){ + console.log("update time success" +$scope.currentTask.name); + }, + function(){ + console.log("fail"); + $scope.todo.stockedEditedTimes[$scope.currentTask.taskId].push(taskTime); + } + ); + } + $scope.currentTaskDate = now; save(); } @@ -359,22 +390,28 @@ var editedTime = getTimeInArrayWithId($scope.data.times[item.taskId],item.timeId); + //Si la periode existe if(editedTime){ - if(item.removed == 0){ - console.log("Temps existe donc remplacé"); - //Le temps existe - editedTime.time = item.time; - editedTime.creationDate = item.creationDate; - //TODO obruce 2/6/14 verfication chevauchement temps + if(!($scope.currentTime && item.timeId == $scope.currentTime.timeId)){ - save(); - }else{ - //TODO supprimer si existant mais removed - suppressObjectInArrayWithId($scope.data.times[item.taskId],item.timeId); + //si la tache n'a pas ete supprime + if(item.removed == 0){ + console.log("Temps existe donc remplacé"); + //Le temps existe + editedTime.time = item.time; + editedTime.creationDate = item.creationDate; + + //TODO obruce 2/6/14 verfication chevauchement temps + + save(); + }else{ + suppressObjectInArrayWithId($scope.data.times[item.taskId],item.timeId); + } } - }else if(item.removed == 0){ + //Elle n'existe pas et n'est pas supprimee + }else if(item.removed == 0 ){ console.log("le temps n'existe pas"); //init de l'array des temps de la tache if(!$scope.data.times[item.taskId]){$scope.data.times[item.taskId] = []} @@ -396,33 +433,7 @@ } - /** - * Methode qui recupere les temps pour une tache - */ - var getTimesFromServerWithTask = function(task){ - serverTimeAccess.query({taskId : task.taskId, date : $scope.timeAccess}, function (response) { - - angular.forEach(response, function (item) { - - if(!$scope.data.times[task.taskId]){$scope.data.times[task.taskId] = []} - - if(!(existInObject($scope.data.times,item.timeId,task.taskId)) && !(existInObject($scope.todo.stockedDeletedTimes, item.timeId, task.taskId)) && !item.isremoved){ - //On cree le tasktime - taskTime = new TaskTime(task, item.timeId, item.creationDate, item.time); - $scope.data.times[task.taskId].push(taskTime); - save(); - //TODO obruce 2/6/14 verfication chevauchement temps - } - }); - //On change la date de dernier acces - $scope.timeAccess = new Date().getTime(); - $scope.todo.lastTimeAccess= $scope.timeAccess; - save(); - }); - } - - //Recuperer un element dans un array avec son id var getTimeInArrayWithId= function(array, id){ var res; @@ -492,7 +503,7 @@ if(getAlarmInArrayWithId(task.alarms, item.alarmId) == undefined && !item.removed){ //On cree le taskalarm - taskAlarm = new TaskAlarm(task, item.alarmId, item.name, item.type, item.modificationDate); //TODO + taskAlarm = new TaskAlarm(task, item.alarmId, item.name, item.type, item.modificationDate); task.alarms.push(taskAlarm); save(); } @@ -637,7 +648,7 @@ */ $scope.addSubTask = function(node) { var task = node.task; - var newTask = new Task("New task", undefined,task.taskId, task.tags); + var newTask = new Task("New task", undefined,task.taskId); $scope.data.tasks[newTask.taskId] = newTask; //On synchronise la tache creer @@ -861,6 +872,7 @@ * @returns {nodes} */ $scope.getRecentTaskTime = function(task) { + //On recupere les temps var times = $scope.data.times[task.taskId]; if (!times) { @@ -868,9 +880,11 @@ $scope.data.times[task.taskId]= times; } + // Le temps max pour la journee var maxDate = new Date(0,0,0,0,0).getTime(); var result; + //Pour chaque on recupere celui qui a la date la plus haute pour la journee angular.forEach(times, function (t) { if (t.isToday() ) { if(maxDate < t.creationDate){ @@ -885,6 +899,7 @@ times.push(result); } + return result; }; @@ -930,19 +945,18 @@ var taskTime = $scope.getRecentTaskTime($scope.currentTask); taskTime.addTime(now - $scope.currentTaskDate); - //On pousse la tache - serverTimeAccess.create({taskId: task.taskId,dispatch:true} , angular.toJson(taskTime), + serverTimeAccess.update({taskId: task.taskId,dispatch:true}, angular.toJson(taskTime), function(){ - console.log("persist time success" + task); + console.log("update time success" ); }, function(){ console.log("fail"); - if(!$scope.todo.stockedNewTimes[task.taskId]){$scope.todo.stockedNewTimes[task.taskId]=[];} - $scope.todo.stockedNewTimes[task.taskId].push(taskTime); + $scope.todo.stockedEditedTimes[task.taskId].push(taskTime); } ); } - //si ce n'est la la tache courante actuel + + //si ce n'est pas la la tache courante actuel if ($scope.currentTask !== task) { //On ajoute un nouveau timeTask dans la liste des times @@ -953,8 +967,21 @@ //On change la task courante $scope.currentTask = task; + $scope.currentTime = temp; $scope.currentTaskDate = now; + + serverTimeAccess.create({taskId: task.taskId,dispatch:true} , angular.toJson(temp), + function(){ + console.log("persist time success" + task); + }, + function(){ + console.log("fail"); + if(!$scope.todo.stockedNewTimes[task.taskId]){$scope.todo.stockedNewTimes[task.taskId]=[];} + $scope.todo.stockedNewTimes[task.taskId].push(temp); + } + ); + //A voir pour mettre enlever quelques secondes en trop checkAlarms(0); @@ -976,6 +1003,7 @@ $scope.currentTask = null; + $scope.currentTime = null; $scope.currentTaskDate = null; } @@ -1598,7 +1626,7 @@ // On parcours les data pour maj angular.forEach(child.children, function(childnode){recurseGenerateChildReport(childnode, parentHasTag)}); - if( parentHasTag && child.task.isReported){ + if( parentHasTag && child.task.isReported ){ toReportTask.push(child.task.taskId); } } @@ -1932,13 +1960,12 @@ serverTimeAccess.update({taskId: task.taskId,dispatch:true} , angular.toJson($scope.selectedItem), function(){ - console.log("update time success" + task); - + console.log("update time success" + task.taskId); }, function(){ console.log("fail"); + $scope.todo.stockedEditedTimes[$scope.selectedTask.taskId].push(taskTime); }); - } /** @@ -2041,9 +2068,13 @@ $scope.import = function(path){ if(path){ - importService.import({}, angular.toJson($scope.path)); + var prom = importService.import({}, angular.toJson($scope.path)).$promise; - $scope.done = true; + prom.then(function(data){ + $scope.response = data; + }); + + // $scope.done = true; } }; Modified: branches/ng-jtimer/src/main/webapp/js/entities.js =================================================================== --- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-08-21 15:57:32 UTC (rev 3030) @@ -258,6 +258,20 @@ this.children = children || []; }; +TreeNode.prototype.hasAllChildHidden = function(f){ + var bool = true; + + if(!f){ + bool = this.task.hidden; + }; + + angular.forEach(this.children , function(child){ + bool = bool && child.hasAllChildHidden(false); + }); + + return bool; +}; + /** * Methode qui fait un parcours reccursif de l'arbre et recupere l'element voulu */ Modified: branches/ng-jtimer/src/main/webapp/partials/reportModal.html =================================================================== --- branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/webapp/partials/reportModal.html 2014-08-21 15:57:32 UTC (rev 3030) @@ -101,9 +101,9 @@ <span class="spacer level{{$level}}"></span> <!--Task state icon--> - <i class="glyphicon glyphicon-ban-circle" ng-show="$state=='empty'"></i> - <i class="glyphicon glyphicon-plus-sign" ng-click="$toggleState()" ng-show="$state=='close'"></i> - <i class="glyphicon glyphicon-minus-sign" ng-click="$toggleState()" ng-show="$state=='open'"></i> + <i style="font-size:10px" class="glyphicon glyphicon-ban-circle glyphSizeSmall" ng-show="$state=='empty'"></i> + <i style="font-size:10px" class="glyphicon glyphicon-chevron-right glyphSizeSmall" ng-click="$toggleState()" ng-show="$state=='close'"></i> + <i style="font-size:10px" class="glyphicon glyphicon-chevron-down glyphSizeSmall" ng-click="$toggleState()" ng-show="$state=='open'"></i> <!--Project name--> <input type="checkbox" ng-model="$node.task.isReported" ng-change="setChildrenCheckbox($node)"> @@ -123,6 +123,8 @@ </div> + <!-- Affichage du résultat --> + <div style="display : inline-block; vertical-align: top; width : 350px"> <alert type="info" > @@ -143,15 +145,18 @@ <br/> </div> - <div class="tr" ng-show="taskData[$node.task.taskId].selftime || hasSelfOrChildTime(taskData,$node,false) || ($node.task.isRoot() && getTotalProjectTime($node,0) != 0 )"> + <div class="tr" ng-show="taskData[$node.task.taskId].selftime + || hasSelfOrChildTime(taskData,$node,false) + || ($node.task.isRoot() && getTotalProjectTime($node,0) != 0 )"> <div class="td" > <span class="spacer level{{$level}}"></span> <b ng-if="$node.task.isRoot()">Projet : {{$node.task.name}}</b> - <span ng-if="!$node.task.isRoot()">{{$node.task.name}} </span> + <span ng-if="!$node.task.isRoot() && !$node.task.hidden">{{$node.task.name}} </span> + <span ng-if="!$node.task.isRoot() && ($node.task.hidden && modal.showHidden)">**{{$node.task.name}}** </span> </div > - <div class="td" ng-show="!$node.task.isRoot() && taskData[$node.task.taskId].selftime && modal.showTime" > + <div class="td" ng-show="!$node.task.isRoot() && taskData[$node.task.taskId].selftime && modal.showTime && ($node.task.hidden && modal.showHidden)" > <span class="spacer level{{$level}}"></span> <span>{{taskData[$node.task.taskId].selftime |time }} </span> @@ -193,6 +198,7 @@ <b>Total : {{getTotalPeriodTime($node,0,period) |time }} </b> </div> + <!-- not root task --> <div class="td" ng-if="!$node.task.isRoot()" > <span class="spacer level{{$level}}"></span> <span>{{$node.task.name}} </span> Modified: branches/ng-jtimer/src/main/webapp/partials/settings.html =================================================================== --- branches/ng-jtimer/src/main/webapp/partials/settings.html 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/webapp/partials/settings.html 2014-08-21 15:57:32 UTC (rev 3030) @@ -28,8 +28,8 @@ <input ng-if="path" type="submit" id="submit" value="Submit" /> </p> </form> -<div ng-click="edit()" ng-show="done"> - {{path}} +<div ng-click="edit()" ng-show="!done"> + {{path}} - {{response.message}} </div> <!-- Footer --> Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html =================================================================== --- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-20 08:19:42 UTC (rev 3029) +++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-08-21 15:57:32 UTC (rev 3030) @@ -12,9 +12,9 @@ <span class="right"> <i class="glyphicon glyphicon-stop color_red" ng-show="currentTask" ng-click="timeTask(currentTask)">Stop </i> <i popover-placement="left" popover="Report " popover-trigger="mouseenter" - class="glyphicon glyphicon-cog" ng-click="reportPopup()"></i> + class="glyphicon glyphicon-list-alt" ng-click="reportPopup()"></i> <a popover-placement="left" popover="Settings" popover-trigger="mouseenter" href="#/settings" - class="glyphicon glyphicon-list-alt" ></a> + class="glyphicon glyphicon-cog" ></a> <i class="glyphicon glyphicon-cloud" ng-class="{online: online, offline: !online}"></i> </span> </div> @@ -66,9 +66,9 @@ <!--Task state icon--> <span > - <i style="font-size:10px" class="glyphicon glyphicon-ban-circle" ng-show="$state=='empty'"></i> - <i style="font-size:10px" class="glyphicon glyphicon-chevron-right" ng-click="$toggleState()" ng-show="$state=='close'"></i> - <i style="font-size:10px" class="glyphicon glyphicon-chevron-down" ng-click="$toggleState()" ng-show="$state=='open'"></i> + <i class="glyphicon glyphicon-ban-circle glyphSizeSmall" ng-show="$state=='empty'"></i> + <i class="glyphicon glyphicon-chevron-right glyphSizeSmall" ng-click="$toggleState()" ng-show="$state=='close'"></i> + <i class="glyphicon glyphicon-chevron-down glyphSizeSmall" ng-click="$toggleState()" ng-show="$state=='open'"></i> <img src="partials/loading_timer.gif" height="20" width="20" ng-show=" (hasActivSon($node) && $state=='close') || currentTask == $node.task"> </span>