Jtimer-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
July 2014
- 1 participants
- 14 discussions
Author: obruce
Date: 2014-07-03 16:41:29 +0200 (Thu, 03 Jul 2014)
New Revision: 3012
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3012
Log:
controller, alarmpartial : changement correction
Modified:
branches/ng-jtimer/src/main/webapp/js/controllers.js
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 14:39:22 UTC (rev 3011)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 14:41:29 UTC (rev 3012)
@@ -379,6 +379,33 @@
}
+ /**
+ * 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 getObjectInArrayWithId= function(array, id){
var res;
@@ -404,33 +431,7 @@
return res;
}
- /**
- * Methode qui recupere les alarmes pour une tache
- */
- var getAlarmsFromServerWithTask = function(task){
- serverAlarmAccess.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();
- });
- }
-
-
/**
* Methode qui retourne l'existence d'un element dans un array
*/
1
0
03 Jul '14
Author: obruce
Date: 2014-07-03 16:39:22 +0200 (Thu, 03 Jul 2014)
New Revision: 3011
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3011
Log:
controller, alarmpartial : changement
Modified:
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/partials/alertModal.html
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 13:12:30 UTC (rev 3010)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 14:39:22 UTC (rev 3011)
@@ -379,33 +379,6 @@
}
- /**
- * 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 getObjectInArrayWithId= function(array, id){
var res;
@@ -431,7 +404,33 @@
return res;
}
+ /**
+ * Methode qui recupere les alarmes pour une tache
+ */
+ var getAlarmsFromServerWithTask = function(task){
+ serverAlarmAccess.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();
+ });
+ }
+
+
/**
* Methode qui retourne l'existence d'un element dans un array
*/
@@ -780,7 +779,7 @@
task : function(){
return node.task;
},
- time : function(){
+ totaltime : function(){
var res=0;
@@ -800,6 +799,28 @@
console.log(res);
return res;
+ },
+ todaytime : function(){
+ var res=0;
+
+ var recChildren = function(noeud){
+ angular.forEach($scope.data.times[noeud.task.taskId], function(t){
+ if(t.isToday()){
+ res+=t.time;
+ }
+ });
+
+ if(noeud.children){
+ angular.forEach(noeud.children, function(child){
+ recChildren(child);
+ });
+ }
+
+ }
+ recChildren(node);
+
+ console.log(res);
+ return res;
}
}
});
@@ -1045,8 +1066,12 @@
};
}
-function AlertModalInstanceCtrl($scope, $modalInstance, serverAlarmAccess, task, time){
+function AlertModalInstanceCtrl($scope, $modalInstance, serverAlarmAccess, task, totaltime, todaytime){
+ console.log(totaltime +" " +todaytime)
+
+ $scope.alarm={name : "" , type : "Type"};
+
var msToHour=function(ms){
return ((ms / (1000*60*60)) % 24);
}
@@ -1056,20 +1081,33 @@
}
$scope.valMinHour=function(){
- return parseInt(msToHour(time));
+ var res;
+ if($scope.alarm.type=="Total_Time"){
+ res = parseInt(msToHour(totaltime));
+ }else{
+ res = parseInt(msToHour(todaytime));
+ }
+ return res;
}
$scope.valMinMin=function(){
- return parseInt(msToMin(time));
+ var res;
+ if($scope.alarm.type=="Total_Time"){
+ res = parseInt(msToMin(totaltime));
+ }else{
+ res = parseInt(msToMin(todaytime));
+ }
+ return res;
}
- $scope.alarm={name : "" , type : "Type", hour : $scope.valMinHour(), min : $scope.valMinMin()};
+ $scope.alarm.hour = $scope.valMinHour();
+ $scope.alarm.min = $scope.valMinMin();
$scope.name = task.name;
$scope.alarms = task.alarms;
- $scope.dynamic = function(alarm){
+ $scope.dynamicProgressBar = function(alarm){
var res = 0;
var limit = alarm.limitHour*60 + alarm.limitMin;
@@ -1082,10 +1120,14 @@
$scope.dropdownType1= function(){
$scope.alarm.type = "Total_Day_Time";
+ $scope.alarm.hour = $scope.valMinHour();
+ $scope.alarm.min = $scope.valMinMin();
}
$scope.dropdownType2 = function(){
$scope.alarm.type = "Total_Time";
+ $scope.alarm.hour = $scope.valMinHour();
+ $scope.alarm.min = $scope.valMinMin();
}
/**
@@ -1102,16 +1144,15 @@
if($scope.alarm.name== "" || $scope.alarm.type=="Type" ){
}else{
- console.log("save " +time);
- minusPreviousTime(time, $scope.alarm.hour, $scope.alarm.min);
+ if($scope.alarm.type=="Total_Time"){
+ minusPreviousTime(totaltime, $scope.alarm.hour, $scope.alarm.min);
+ }else{
+ minusPreviousTime(todaytime, $scope.alarm.hour, $scope.alarm.min);
+ }
- console.log("apres minus " +$scope.alarm.hour + " "+$scope.alarm.min);
-
if($scope.alarm.hour > 0 || $scope.alarm.min> 0 ){
- console.log($scope.alarm.hour + " "+$scope.alarm.min);
-
var al = new TaskAlarm(task,undefined ,
$scope.alarm.name,
$scope.alarm.type,
@@ -1131,7 +1172,6 @@
//On remet les elements affiches a la valeur par defaut
$scope.alarm.name= "";
$scope.alarm.type="Type";
- //$scope.alarm.date= new Date();
$scope.alarm.hour = 0;
$scope.alarm.min = 0;
}
Modified: branches/ng-jtimer/src/main/webapp/partials/alertModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-03 13:12:30 UTC (rev 3010)
+++ branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-03 14:39:22 UTC (rev 3011)
@@ -22,47 +22,46 @@
<!--Portion d'ajout -->
<tr ng-repeat="(index,alarm) in alarms">
- <th><i class="glyphicon glyphicon-minus-sign" ng-click="removeAlert(index,alarm)"></i></th>
+ <td><i class="glyphicon glyphicon-minus-sign" ng-click="removeAlert(index,alarm)"></i></td>
- <th>{{alarm.name}}</th>
- <th>{{alarm.type}}</th>
- <th>{{alarm.limitHour}}h: {{alarm.limitMin}}min</th>
- <th>
- <progressbar value="dynamic(alarm)"></progressbar>
- </th>
- <th></th>
+ <td >{{alarm.name}}</td>
+ <td>{{alarm.type}}</td>
+ <td>{{alarm.limitHour}}h: {{alarm.limitMin}}min</td>
+ <td>
+ <progressbar value="dynamicProgressBar(alarm)"></progressbar>
+ </td>
</tr>
<tr>
-
- <th>Nouveau:</th>
+ <th>New:</th>
</tr>
-
<tr>
-
- <th></th>
- <th><input class='input-sm small_input' ng-model="alarm.name" placeholder="New Alert">
+ <td><i class="glyphicon glyphicon-floppy-disk" ng-click="saveAlarm()"></i></td>
+ <td><input class='input-sm small_input' ng-model="alarm.name" placeholder="New Alert">
<i class="glyphicon glyphicon-edit color_red" ng-show="alarm.name==''"> </i>
- <i class="glyphicon glyphicon-check color_green" ng-show="alarm.name!=''"> </i></th>
- <th>
+ <i class="glyphicon glyphicon-check color_green" ng-show="alarm.name!=''"> </i></td>
+ <td>
<div class="btn-group" dropdown is-open="status.isopen">
<button type="button" class="btn btn-primary dropdown-toggle">
{{alarm.type}} <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
- <li ng-click="dropdownType1()">Total_Time_In_a_Day</li>
+ <li ng-click="dropdownType1()">Total_Day_Time</li>
<li ng-click="dropdownType2()">Total_Time</li>
</ul>
</div>
<i class="glyphicon glyphicon-edit color_red" ng-show="alarm.type=='Type'"> </i>
<i class="glyphicon glyphicon-check color_green"ng-show="alarm.type!='Type'"> </i>
- </th>
- <th>
+ </td>
+ <td>
<!--<timepicker ng-model="alarm.date" ng-change="changed()"
hour-step="1" minute-step="1" show-meridian="ismeridian">
</timepicker>-->
- <div ng-if="alarm.type!='Total_Time'">
+ <div ng-if="alarm.type=='Type'">
+ </div>
+
+ <div ng-if="alarm.type=='Total_Day_Time'">
<input type="number" step="1" min="{{valMinHour()}}" max="23" ng-model="alarm.hour">h:
<input type="number" step="1" min="{{valMinMin()}}" max="59" ng-model="alarm.min">m
</div>
@@ -72,9 +71,8 @@
<input class="xsmall_input" type="number" step="1" min="{{valMinMin()}}" max="59" ng-model="alarm.min">m
</div>
- </th>
- <th></th>
- <th><i class="glyphicon glyphicon-ok green" ng-click="saveAlarm()"></i></th>
+ </td>
+ <td></td>
</tr>
</div>
1
0
r3010 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/config java/org/chorem/jtimer/entities java/org/chorem/jtimer/storage java/org/chorem/jtimer/web resources webapp/css webapp/js webapp/partials
by obruce@users.chorem.org 03 Jul '14
by obruce@users.chorem.org 03 Jul '14
03 Jul '14
Author: obruce
Date: 2014-07-03 15:12:30 +0200 (Thu, 03 Jul 2014)
New Revision: 3010
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3010
Log:
ui-serveur: persist alarm, correction modal
Added:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmsResource.java
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AbstractResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.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/js/service.js
branches/ng-jtimer/src/main/webapp/partials/alertModal.html
branches/ng-jtimer/src/main/webapp/partials/tasks.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfig.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -91,6 +91,10 @@
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_CREATE_TABLE_TIME.getKey());
}
+ public String getStorageQueryCreateTableAlarm(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_CREATE_TABLE_ALARM.getKey());
+ }
+
public String getStorageQueryInsertVersionNumber(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_VERSION_NUMBER.getKey());
}
@@ -103,6 +107,10 @@
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_TIME.getKey());
}
+ public String getStorageQueryInsertAlarm(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_INSERT_ALARM.getKey());
+ }
+
public String getStorageQuerySelectTableName(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_TABLE_NAME.getKey());
}
@@ -132,15 +140,33 @@
public String getStorageQuerySelectReportRootTask(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_REPORT_ROOTTASK.getKey());
}
+
+ public String getStorageQuerySelectAlarmOnDate(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_ALARM_ONDATE.getKey());
+ }
+
+ public String getStorageQuerySelectAlarmWithTaskID(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_SELECT_ALARM_WITHTASKID.getKey());
+ }
public String getStorageQueryDeleteTime(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_DELETE_TIME_WITHID.getKey());
}
+
+ public String getStorageQueryDeleteAlarm(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_DELETE_ALARM_WITHID.getKey());
+ }
+
public String getStorageQueryDeleteTask(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_DELETE_TASK_WITHID.getKey());
}
public String getStorageQueryUpdateTask(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TASK_WITHID.getKey());
}
+
+ public String getStorageQueryUpdateAlarm(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_ALARM_WITHID.getKey());
+ }
+
public String getStorageQueryUpdateTime(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TIME_WITHID.getKey());
}
@@ -150,4 +176,7 @@
public String getStorageQueryUpdateTimeToRemove(){
return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_TIME_FORREMOVE.getKey());
}
+ public String getStorageQueryUpdateAlarmToRemove(){
+ return appConfig.getOption(JtimerConfigOption.JTIMER_STORAGE_UPDATE_ALARM_FORREMOVE.getKey());
+ }
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/config/JtimerConfigOption.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -40,6 +40,12 @@
"tasktime",
String.class
),
+ JTIMER_STORAGE_TABLE_ALARM(
+ "jtimer.storage.table.alarm",
+ "le nom de la table des version",
+ "tasktime",
+ String.class
+ ),
JTIMER_STORAGE_CREATE_TABLE_VERSION(
"jtimer.storage.create.table.version",
"requête de création la table des version",
@@ -58,6 +64,12 @@
"",
String.class
),
+ JTIMER_STORAGE_CREATE_TABLE_ALARM(
+ "jtimer.storage.create.alarm",
+ "requête de création la table des alarmes",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_INSERT_VERSION_NUMBER(
"jtimer.storage.insert.version.number",
"requête d'insertion dans la table des versions",
@@ -76,6 +88,12 @@
"",
String.class
),
+ JTIMER_STORAGE_INSERT_ALARM(
+ "jtimer.storage.insert.alarm",
+ "requête d'insertion dans la table des alarmes",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_SELECT_TABLE_NAME(
"jtimer.storage.select.table.name",
"requête de selection des noms dans le table name",
@@ -130,6 +148,18 @@
"",
String.class
),
+ JTIMER_STORAGE_SELECT_ALARM_ONDATE(
+ "jtimer.storage.select.alarm.ondate",
+ "requête de selection des alarmes ",
+ "",
+ String.class
+ ),
+ JTIMER_STORAGE_SELECT_ALARM_WITHTASKID(
+ "jtimer.storage.select.alarm.fortask",
+ "requête de selection des alarmes d'une tâches",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_DELETE_TIME_WITHID(
"jtimer.storage.delete.time.withid",
"requête de suppression d'un temps avec un identifiant",
@@ -142,6 +172,12 @@
"",
String.class
),
+ JTIMER_STORAGE_DELETE_ALARM_WITHID(
+ "jtimer.storage.delete.alarm.withid",
+ "requête de suppression d'une tâches avec un identifiant",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_UPDATE_TASK_WITHID(
"jtimer.storage.update.task.withid",
"requête de mise à jour d'une taches avec un identifiant",
@@ -154,6 +190,12 @@
"",
String.class
),
+ JTIMER_STORAGE_UPDATE_ALARM_WITHID(
+ "jtimer.storage.update.alarm.withid",
+ "requête de mise à jour d'une alarme avec un identifiant",
+ "",
+ String.class
+ ),
JTIMER_STORAGE_UPDATE_TASK_FORREMOVE(
"jtimer.storage.update.task.forremove",
"requête de de changement de statut (remove) d'une tâches avec un identifiant",
@@ -165,7 +207,13 @@
"requête de de changement de statut (remove) d'un temps avec un identifiant",
"",
String.class
- );
+ ),JTIMER_STORAGE_UPDATE_ALARM_FORREMOVE(
+ "jtimer.storage.update.alarm.forremove",
+ "requête de de changement de statut (remove) d'une alarme avec un identifiant",
+ "",
+ String.class
+ )
+ ;
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerAlarm.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -0,0 +1,159 @@
+package org.chorem.jtimer.entities;
+
+import java.util.Date;
+
+/**
+ * Created by olivia on 02/07/14.
+ *
+ * Classe qui represente les alarmes sur les taches
+ *
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.entities
+ */
+public class TimerAlarm {
+
+ /** Task uuid */
+ protected String taskId;
+
+ /** Alarm uuid */
+ protected String alarmId;
+
+ /** Alarm name. */
+ protected String name;
+
+ /** Alarm type. */
+ protected String type;
+
+ /**ModificationDate*/
+ protected Date modificationDate;
+
+ /** limit time in hour to spend on the task */
+ protected int limitHour;
+
+ /** limit time in min to spend on the task */
+ protected int limitMin;
+
+ /** passed time in hour to spend on the task */
+ protected int remainingMin;
+
+ /** passed time in min to spend on the task */
+ protected int remainingHour;
+
+ /** date if alarm is removed */
+ protected long removed;
+
+ public TimerAlarm(String taskId, String alarmId, String name, String type, Date modificationDate, int limitHour, int limitMin) {
+ this.taskId = taskId;
+ this.alarmId = alarmId;
+ this.name = name;
+ this.type = type;
+ this.modificationDate = modificationDate;
+ this.limitHour = limitHour;
+ this.limitMin = limitMin;
+ this.remainingHour = limitHour;
+ this.remainingMin =limitMin;
+ }
+
+ public TimerAlarm() {
+
+ }
+
+ public long getRemoved() {
+ return removed;
+ }
+
+ public void setRemoved(long removed) {
+ this.removed = removed;
+ }
+
+ public String getTaskId() {
+ return taskId;
+ }
+
+ public void setTaskId(String taskId) {
+ this.taskId = taskId;
+ }
+
+ public String getAlarmId() {
+ return alarmId;
+ }
+
+ public void setAlarmId(String alarmId) {
+ this.alarmId = alarmId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Date getModificationDate() {
+ return modificationDate;
+ }
+
+ public void setModificationDate(Date modificationDate) {
+ this.modificationDate = modificationDate;
+ }
+
+ public int getLimitHour() {
+ return limitHour;
+ }
+
+ public void setLimitHour(int limitHour) {
+ this.limitHour = limitHour;
+ }
+
+ public int getLimitMin() {
+ return limitMin;
+ }
+
+ public void setLimitMin(int limitMin) {
+ this.limitMin = limitMin;
+ }
+
+ public int getRemainingMin() {
+ return remainingMin;
+ }
+
+ public void setRemainingMin(int remainingMin) {
+ this.remainingMin = remainingMin;
+ }
+
+ public int getRemainingHour() {
+ return remainingHour;
+ }
+
+ public void setRemainingHour(int remainingHour) {
+ this.remainingHour = remainingHour;
+ }
+
+
+ @Override
+ public String toString() {
+ return "TimerAlarm{" +
+ "taskId='" + taskId + '\'' +
+ ", alarmId='" + alarmId + '\'' +
+ ", name='" + name + '\'' +
+ ", type='" + type + '\'' +
+ ", modificationDate=" + modificationDate +
+ ", limitHour=" + limitHour +
+ ", limitMin=" + limitMin +
+ ", remainingMin=" + remainingMin +
+ ", remainingHour=" + remainingHour +
+ ", removed=" + removed +
+ '}';
+ }
+}
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-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -3,6 +3,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.config.JtimerConfig;
+import org.chorem.jtimer.entities.TimerAlarm;
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TimerTime;
import org.chorem.jtimer.utils.ReportTask;
@@ -36,6 +37,7 @@
protected static final String TABLE_TASK = "task";
protected static final String TABLE_TIME = "tasktime";
+ protected static final String TABLE_ALARM = "taskalarm";
protected String TABLE_VERSION;
protected String STORAGE_PATH;
@@ -155,6 +157,7 @@
statement.executeUpdate(config.getStorageQueryCreateTableVersion());
statement.executeUpdate(config.getStorageQueryCreateTableTask());
statement.executeUpdate(config.getStorageQueryCreateTableTime());
+ statement.executeUpdate(config.getStorageQueryCreateTableAlarm());
} catch (SQLException ex) {
throw new StorageException("Can't create schema", ex);
@@ -189,62 +192,10 @@
return result;
}
- /**
- * Query that returns not removed tasks
- * @return tasks arraylist of tasks
- */
- public ArrayList<TimerTask> getTasks(Long date) {
- ArrayList<TimerTask> tasks = new ArrayList<>();
- PreparedStatement statement = null;
- PreparedStatement statement2 = null;
- try {
- statement = connection.prepareStatement(config.getStorageQuerySelectTimedTask());
- statement.setLong(1, date);
- log.debug(statement.toString());
- ResultSet rs = statement.executeQuery();
- while (rs.next()) {
- TimerTask task = new TimerTask();
- task.setTaskId(rs.getString("taskId"));
- task.setName(rs.getString("name"));
- task.setParent(rs.getString("parent"));
- task.setRemoved(rs.getLong("removed"));
- task.setTodayTime(0);
- task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
- task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
- task.setTotalTime(rs.getLong("totalduration"));
- tasks.add(task);
- }
+ /* Insert */
- // not timed tasks
- statement2 = connection.prepareStatement(config.getStorageQuerySelectNotTimedTask());
- statement2.setLong(1, date);
-
- rs = statement2.executeQuery();
- while (rs.next()) {
- TimerTask task = new TimerTask();
- task.setName(rs.getString("name"));
- task.setTaskId(rs.getString("taskId"));
- task.setParent(rs.getString("parent"));
- task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
- task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
- task.setRemoved(rs.getLong("removed"));
- task.setTodayTime(0);
- task.setTotalTime(0);
- tasks.add(task);
- }
- } catch (SQLException ex) {
- throw new StorageException("Can't get task", ex);
- } finally {
- closeStatement(statement);
- closeStatement(statement2);
- }
- return tasks;
- }
-
- /* Insert, Update, Delete */
-
public void addTask(TimerTask task) {
PreparedStatement statement = null;
try {
@@ -267,46 +218,7 @@
log.info("insert done");
}
- public void modifyTask(TimerTask task) {
- PreparedStatement statement = null;
- try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateTask());
- statement.setString(1, task.getName()); //name
- statement.setString(2, task.getParent()); //parent
- statement.setBoolean(3, task.isClosed()); //hidden
- statement.setString(4, null /*project.getNote()*/);//note
- statement.setLong(5, task.getModificationDate().getTime()); //modificationDate
-
- statement.setLong(6,task.getRemoved());
- statement.setString(7, task.getTaskId()); //taskId
-
- statement.executeUpdate();
- } catch (SQLException ex) {
- throw new StorageException("Can't modify task", ex);
- } finally {
- closeStatement(statement);
- }
- }
-
- public void modifyTime(TimerTime t) {
- PreparedStatement statement = null;
- try {
- statement = connection.prepareStatement(config.getStorageQueryUpdateTime());
-
- statement.setLong(1, t.getCreationDate().getTime());
- statement.setLong(2, t.getTime());
- statement.setLong(3, t.getModificationDate().getTime()); //modificationDate
- statement.setLong(4, t.getRemoved());
- statement.setString(5, t.getTimeId() );
- statement.executeUpdate();
- } catch (SQLException ex) {
- throw new StorageException("Can't modify time", ex);
- } finally {
- closeStatement(statement);
- }
- }
-
/**
* Ajoute une periode pour une tache
* @param task la tache qui va recevoir un temps
@@ -357,13 +269,36 @@
}
+ /** Select */
+ /**
+ * Ajoute une alarme pour une tache
+ * @param alarm le timeralarm a ajouter
+ */
+ public void addTaskAlarm(TimerAlarm alarm) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryInsertAlarm());
- public void setAnnotation(TimerTask task, Date date, String annotation) {
+ statement.setString(1, alarm.getTaskId());
+ statement.setString(2, alarm.getAlarmId());
+ statement.setString(3, alarm.getName());
+ statement.setString(4, alarm.getType());
+ statement.setInt(5, alarm.getLimitHour());
+ statement.setInt(6, alarm.getLimitMin());
+ statement.setInt(7, alarm.getRemainingHour());
+ statement.setInt(8, alarm.getRemainingMin());
+ statement.setLong(9, alarm.getModificationDate().getTime());
+ statement.setLong(10, alarm.getRemoved());
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't add task alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
}
-
/**
* Query that returns every task's times
* @return times hashMap(key: taskId, value: times)
@@ -401,7 +336,60 @@
return times;
}
+ /**
+ * Query that returns not removed tasks
+ * @return tasks arraylist of tasks
+ */
+ public ArrayList<TimerTask> getTasks(Long date) {
+ ArrayList<TimerTask> tasks = new ArrayList<>();
+ PreparedStatement statement = null;
+ PreparedStatement statement2 = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQuerySelectTimedTask());
+ statement.setLong(1, date);
+ log.debug(statement.toString());
+
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ TimerTask task = new TimerTask();
+ task.setTaskId(rs.getString("taskId"));
+ task.setName(rs.getString("name"));
+ task.setParent(rs.getString("parent"));
+ task.setRemoved(rs.getLong("removed"));
+ task.setTodayTime(0);
+ task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
+ task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
+ task.setTotalTime(rs.getLong("totalduration"));
+ tasks.add(task);
+ }
+
+ // not timed tasks
+ statement2 = connection.prepareStatement(config.getStorageQuerySelectNotTimedTask());
+ statement2.setLong(1, date);
+
+ rs = statement2.executeQuery();
+ while (rs.next()) {
+ TimerTask task = new TimerTask();
+ task.setName(rs.getString("name"));
+ task.setTaskId(rs.getString("taskId"));
+ task.setParent(rs.getString("parent"));
+ task.setCreationDate(new java.util.Date(rs.getLong("creationDate")));
+ task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
+ task.setRemoved(rs.getLong("removed"));
+ task.setTodayTime(0);
+ task.setTotalTime(0);
+ tasks.add(task);
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get task", ex);
+ } finally {
+ closeStatement(statement);
+ closeStatement(statement2);
+ }
+ return tasks;
+ }
+
/**
* Query that returns every tasks for a specified task
* @return tasks arraylist of tasks
@@ -435,6 +423,80 @@
return times;
}
+
+ /**
+ * Methode qui retourne toutes les alarmes dans la base
+ * @param date
+ * @return
+ */
+ public ArrayList<TimerAlarm> getAlarms(Long date) {
+ ArrayList<TimerAlarm> alarms = new ArrayList<>();
+ PreparedStatement statement = null;
+
+ try {
+ statement = connection.prepareStatement(config.getStorageQuerySelectAlarmOnDate());
+ statement.setLong(1, date);
+
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ TimerAlarm alarm = new TimerAlarm();
+ alarm.setTaskId(rs.getString("taskid"));
+ alarm.setAlarmId(rs.getString("alarmId"));
+ alarm.setName(rs.getString("name"));
+ alarm.setType(rs.getString("type"));
+ alarm.setLimitHour(rs.getInt("limitHour"));
+ alarm.setLimitMin(rs.getInt("limitMin"));
+ alarm.setRemainingHour(rs.getInt("remainingHour"));
+ alarm.setRemainingMin(rs.getInt("remainingMin"));
+ alarm.setModificationDate(new Date(rs.getLong("modificationDate")));
+ alarm.setRemoved(rs.getLong("removed"));
+
+ alarms.add(alarm);
+
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return alarms;
+ }
+
+
+ public ArrayList<TimerAlarm> getAlarms(String taskId, Long date) {
+ ArrayList<TimerAlarm> alarms = new ArrayList<>();
+ PreparedStatement statement = null;
+
+ try {
+ statement = connection.prepareStatement(config.getStorageQuerySelectAlarmWithTaskID());
+ statement.setLong(1, date);
+ statement.setString(2, taskId);
+
+ ResultSet rs = statement.executeQuery();
+ while (rs.next()) {
+ TimerAlarm alarm = new TimerAlarm();
+ alarm.setTaskId(rs.getString("taskid"));
+ alarm.setAlarmId(rs.getString("alarmId"));
+ alarm.setName(rs.getString("name"));
+ alarm.setType(rs.getString("type"));
+ alarm.setLimitHour(rs.getInt("limitHour"));
+ alarm.setLimitMin(rs.getInt("limitMin"));
+ alarm.setRemainingHour(rs.getInt("remainingHour"));
+ alarm.setRemainingMin(rs.getInt("remainingMin"));
+ alarm.setModificationDate(new Date(rs.getLong("modificationDate")));
+ alarm.setRemoved(rs.getLong("removed"));
+
+ alarms.add(alarm);
+
+ }
+ } catch (SQLException ex) {
+ throw new StorageException("Can't get time", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ return alarms;
+ }
+
public HashMap<String, ArrayList<ReportTask>> getReportByProject(Long startDate, Long endDate){
HashMap map = new HashMap();
@@ -490,6 +552,81 @@
}
+ /** Update */
+
+ /**
+ * Update the specified task
+ * @param task the task to be updated
+ */
+ public void modifyTask(TimerTask task) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryUpdateTask());
+
+ statement.setString(1, task.getName()); //name
+ statement.setString(2, task.getParent()); //parent
+ statement.setBoolean(3, task.isClosed()); //hidden
+ statement.setString(4, null /*project.getNote()*/);//note
+ statement.setLong(5, task.getModificationDate().getTime()); //modificationDate
+
+ statement.setLong(6,task.getRemoved());
+ statement.setString(7, task.getTaskId()); //taskId
+
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't modify task", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+ /**
+ * Update the specified time
+ * @param t the time to be updated
+ */
+ public void modifyTime(TimerTime t) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryUpdateTime());
+
+ statement.setLong(1, t.getCreationDate().getTime());
+ statement.setLong(2, t.getTime());
+ statement.setLong(3, t.getModificationDate().getTime()); //modificationDate
+ statement.setLong(4, t.getRemoved());
+ statement.setString(5, t.getTimeId() );
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't modify time", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+
+ /**
+ * Update the specified alarm
+ * @param t the alarm to be updated
+ */
+ public void modifyAlarm(TimerAlarm t) {
+
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryUpdateAlarm());
+
+ statement.setLong(1, t.getRemainingHour());
+ statement.setLong(2, t.getRemainingMin());
+ statement.setLong(3, t.getRemoved());
+
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't modify alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
+
+ }
+
+
/** Suppression de tuple **/
/**
@@ -577,4 +714,21 @@
}
+ public void removeAlarmWithId(String alarmId, long time) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement(config.getStorageQueryUpdateAlarmToRemove());
+
+ statement.setLong(1, time);
+ statement.setLong(2, time);
+ statement.setString(3, alarmId);
+
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't delete alarm", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
}
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AbstractResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AbstractResource.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AbstractResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,10 +1,23 @@
package org.chorem.jtimer.web;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.jtimer.storage.Storage;
import org.restlet.resource.Options;
+import org.restlet.resource.ResourceException;
import org.restlet.resource.ServerResource;
+import java.lang.reflect.Type;
+import java.util.Date;
+
/**
* Created by olivia on 11/06/14.
* <p/>
@@ -16,7 +29,40 @@
private static final Log log = LogFactory.getLog(AbstractResource.class);
+ protected Storage storage;
+ protected GsonBuilder builder;
+
/**
+ * Methode qui initialis la resource
+ * @throws org.restlet.resource.ResourceException
+ */
+ @Override
+ protected void doInit() throws ResourceException {
+ storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
+
+ builder = new GsonBuilder();
+
+ // Register an adapter to manage the date types as long values
+ //GSON builder to format dates
+ builder = new GsonBuilder();
+ builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
+
+ public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
+ return new Date(json.getAsJsonPrimitive().getAsLong());
+ }
+
+ });
+
+ builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
+ @Override
+ public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
+ return new JsonPrimitive(date.getTime());
+ }
+ });
+
+ }
+
+ /**
* Called when option requests are catched
* Needed to avoid cross origin
*/
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmResource.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -0,0 +1,130 @@
+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.entities.TimerAlarm;
+import org.restlet.data.MediaType;
+import org.restlet.representation.Representation;
+import org.restlet.representation.StringRepresentation;
+import org.restlet.resource.Delete;
+import org.restlet.resource.Get;
+import org.restlet.resource.Post;
+import org.restlet.resource.Put;
+import org.restlet.resource.ResourceException;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by olivia on 01/07/14.
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.web
+ */
+public class AlarmResource extends AbstractResource {
+
+ private static final Log log = LogFactory.getLog(AlarmResource.class);
+
+ /**
+ * Methode qui initialis la resource
+ * @throws org.restlet.resource.ResourceException
+ */
+ @Override
+ protected void doInit() throws ResourceException {
+ super.doInit();
+ }
+
+ /**
+ * Methode qui retourne la representation de la liste des alarmes
+ * Suite a une requete de type GET
+ *
+ * @return la representation
+ */
+ @Get("json")
+ public Representation getAlarmForATask() {
+
+ Long date = (long) 0;
+ try{
+ date = Long.valueOf(getQuery().getValues("date"));
+ }
+ catch(Exception e){
+ date = (long) 0;
+ }
+
+ String taskId = (String)getRequest().getAttributes().get("taskId");
+ List<TimerAlarm> timerAlarms = storage.getAlarms(taskId, date);
+
+ Gson gson = builder.create();
+ String json = gson.toJson(timerAlarms);
+
+ return new StringRepresentation(json, MediaType.APPLICATION_JSON);
+ }
+
+ /**
+ * Methode qui supprime un element de la base
+ * suite d'une requête de type DELETE
+ *
+ */
+ @Delete
+ public void deleteAlarm() {
+
+
+ String alarmId = (String)getRequest().getAttributes().get("alarmId");
+ storage.removeAlarmWithId(alarmId, new Date().getTime());
+
+ }
+
+ /**
+ * Methode qui cree une periode
+ * suite d'une requête de type POST
+ */
+ @Post("json")
+ public void createAlarm(Representation representation) throws IOException {
+
+ if(representation.isAvailable()) {
+ Gson gson = builder.create();
+
+ //On reconstruit l'element avec la representation
+ String jsonRepr = representation.getText();
+ TimerAlarm newAlarm = gson.fromJson(jsonRepr, TimerAlarm.class);
+
+ log.info(newAlarm.toString());
+
+ if (log.isInfoEnabled()) {
+ log.info("L'alarme suivante est cree : " + newAlarm.toString());
+ }
+
+ storage.addTaskAlarm(newAlarm);
+
+ }
+ }
+
+ /**
+ * Methode qui met à jour une tache
+ * suite d'une requête de type PUT
+ */
+ @Put("json")
+ public void updateAlarm(Representation representation) throws IOException{
+
+ if(representation.isAvailable()) {
+
+
+
+ Gson gson = builder.create();
+ String jsonRepr = representation.getText();
+ TimerAlarm t = gson.fromJson(jsonRepr, TimerAlarm.class);
+
+ if (log.isInfoEnabled()) {
+ log.info("La periode suivante est en maj : " + t.toString());
+ }
+
+ storage.modifyAlarm(t);
+ }
+
+ }
+
+
+}
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmsResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmsResource.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/AlarmsResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -0,0 +1,62 @@
+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.entities.TimerAlarm;
+import org.restlet.data.MediaType;
+import org.restlet.representation.Representation;
+import org.restlet.representation.StringRepresentation;
+import org.restlet.resource.Get;
+import org.restlet.resource.ResourceException;
+
+import java.util.ArrayList;
+
+/**
+ * Created by olivia on 01/07/14.
+ * <p/>
+ * Project name : jtimer
+ * <p/>
+ * Package name : org.chorem.jtimer.web
+ */
+public class AlarmsResource extends AbstractResource{
+
+ private static final Log log = LogFactory.getLog(AlarmsResource.class);
+
+ /**
+ * Methode qui initialis la resource
+ * @throws org.restlet.resource.ResourceException
+ */
+ @Override
+ protected void doInit() throws ResourceException {
+ super.doInit();
+ }
+
+ /**
+ * Methode qui retourne la representation de la liste des alarmes
+ * Suite a une requete de type GET
+ *
+ * @return la representation
+ */
+ @Get("json")
+ public Representation getAlarmForATask() {
+
+ Long date = (long) 0;
+
+ try {
+ date = Long.valueOf(getQuery().getValues("date"));
+ } catch (Exception e) {
+ date = (long) 0;
+ }
+
+ Gson gson = builder.create();
+ ArrayList<TimerAlarm> timerAlarms = storage.getAlarms(date);
+
+
+
+ String json = gson.toJson(timerAlarms);
+
+ return new StringRepresentation(json, MediaType.APPLICATION_JSON);
+ }
+
+}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -57,7 +57,8 @@
router.attach("/tasks/time/{taskId}", TimeResource.class);
router.attach("/tasks/time", TimesResource.class);
router.attach("/report", ReportResource.class);
- //router.attach("/tiers", TiersServerResource.class);
+ router.attach("/tasks/alarm", AlarmsResource.class);
+ router.attach("/tasks/alarm/{taskId}", AlarmResource.class);
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,20 +1,11 @@
package org.chorem.jtimer.web;
import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerTime;
import org.chorem.jtimer.entities.TodoList;
-import org.chorem.jtimer.storage.Storage;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
@@ -25,7 +16,6 @@
import org.restlet.resource.ResourceException;
import java.io.IOException;
-import java.lang.reflect.Type;
import java.util.Date;
import java.util.List;
@@ -33,10 +23,6 @@
private static final Log log = LogFactory.getLog(TimeResource.class);
- /** Builder for serialisation deserialisation */
- private GsonBuilder builder;
- /** H2 storage instance */
- protected Storage storage;
/** Todolist instance */
protected TodoList todoList;
@@ -50,28 +36,8 @@
@Override
protected void doInit() throws ResourceException {
- //GSON builder to format dates
+ super.doInit();
- builder = new GsonBuilder();
- builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
-
- public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
-
- return new Date(json.getAsJsonPrimitive().getAsLong());
-
- }
-
- });
-
- builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
- @Override
- public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
- return new JsonPrimitive(date.getTime());
- }
- });
-
-
- storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
todoList = TodoList.getInstance();
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimesResource.java 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,27 +1,16 @@
package org.chorem.jtimer.web;
import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerTime;
-import org.chorem.jtimer.storage.Storage;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.Get;
import org.restlet.resource.ResourceException;
-import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Date;
/**
* Created by olivia on 21/05/14.
@@ -29,8 +18,6 @@
public class TimesResource extends AbstractResource {
private static final Log log = LogFactory.getLog(TaskResource.class);
- protected Storage storage;
- protected GsonBuilder builder;
/**
* Methode qui initialis la resource
@@ -38,30 +25,7 @@
*/
@Override
protected void doInit() throws ResourceException {
- storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
-
- builder = new GsonBuilder();
- // Register an adapter to manage the date types as long values
- //GSON builder to format dates
-
- builder = new GsonBuilder();
- builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() {
-
- public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
-
- return new Date(json.getAsJsonPrimitive().getAsLong());
-
- }
-
- });
-
- builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
- @Override
- public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
- return new JsonPrimitive(date.getTime());
- }
- });
-
+ super.doInit();
}
/**
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-07-03 13:12:30 UTC (rev 3010)
@@ -2,7 +2,7 @@
# jTimer default properties
###
# jTimer storage path
-jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimerNew
+jtimer.storage.path=/home/olivia/Bureau/jtimer/jtimer/newWithAlarm
###
# SQL properties
###
@@ -10,7 +10,7 @@
jtimer.storage.table.task=task
jtimer.storage.table.time=tasktime
jtimer.storage.table.version=version
-jtimer.storage.table.alert=taskalert
+jtimer.storage.table.alarm=taskalarm
###
#CREATE SCHEMA
jtimer.storage.create.table.version=CREATE TABLE version (version VARCHAR(10))
@@ -35,19 +35,30 @@
FOREIGN KEY (taskid) \
REFERENCES task (taskId) \
ON DELETE CASCADE)
-jtimer.storage.create.alert=CREATE TABLE taskalert \
- (taskid VARCHAR(255) NOT NULL, \
+jtimer.storage.create.alarm=CREATE TABLE taskalarm \
+ (taskId VARCHAR(255) NOT NULL, \
+ alarmId VARCHAR(255) NOT NULL, \
name VARCHAR(255) NOT NULL, \
type VARCHAR(255) NOT NULL, \
- limitDate LONG, \
+ limitHour INTEGER, \
+ limitMin INTEGER, \
+ remainingMin INTEGER, \
+ remainingHour INTEGER, \
modificationDate LONG, \
- repeatFrequence VARCHAR(255), \
- PRIMARY KEY (taskId, name))
+ removed LONG, \
+ PRIMARY KEY (taskId, alarmId), \
+ FOREIGN KEY (taskid) \
+ REFERENCES task (taskId) \
+ ON DELETE CASCADE)
####
#INSERT
jtimer.storage.insert.version.number=INSERT INTO VERSION VALUES('2.0')
-jtimer.storage.insert.task=INSERT INTO task (name, parent, taskId, hidden, note,creationDate, modificationDate, removed) VALUES (?, ?, ?, ?, ?,?, ?, ?)
-jtimer.storage.insert.time=INSERT INTO tasktime (taskid, date, uuid, duration, modificationDate, removed) VALUES (?, ?, ?, ?, ?, ?)
+jtimer.storage.insert.task=INSERT INTO task (name, parent, taskId, hidden, note,creationDate, modificationDate, removed) \
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)
+jtimer.storage.insert.time=INSERT INTO tasktime (taskid, date, uuid, duration, modificationDate, removed) \
+ VALUES (?, ?, ?, ?, ?, ?)
+jtimer.storage.insert.alarm=INSERT INTO taskalarm (taskid, alarmId, name, type, limitHour, \
+ limitMin, remainingHour, remainingMin, modificationDate, removed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
###
#SELECT
jtimer.storage.select.table.name=SELECT table_name FROM information_schema.tables;
@@ -85,17 +96,28 @@
jtimer.storage.select.report.roottasks=SELECT * \
FROM task \
WHERE (taskId not in (SELECT taskid FROM tasktime) AND removed = 0 )
+jtimer.storage.select.alarm.ondate= SELECT * \
+ FROM taskalarm \
+ WHERE modificationDate > ?
+jtimer.storage.select.alarm.fortask= SELECT * \
+ FROM taskalarm \
+ WHERE removed = 0 AND modificationDate > ? AND taskId = ?
###
#DELETE
jtimer.storage.delete.time.withid=DELETE FROM tasktime WHERE uuid = ?
jtimer.storage.delete.task.withid=DELETE FROM task WHERE taskId = ?
+jtimer.storage.delete.alarm.withid=DELETE FROM taskalarm WHERE alarmId = ?
###
#UPDATE
jtimer.storage.update.task.withid=UPDATE task SET name=?, parent=?, hidden=?, note=?, modificationDate=?, removed=? \
WHERE taskId = ?
jtimer.storage.update.time.withid=UPDATE tasktime SET date=?, duration=?, modificationDate=?, removed = ? \
WHERE uuid = ?
+jtimer.storage.update.alarm.withid=UPDATE tasktime SET remainingHour=?, remainingMin=?, modificationDate=?, removed = ? \
+ WHERE alarmid = ?
jtimer.storage.update.task.forremove=UPDATE task SET removed = ?, modificationDate = ? \
WHERE taskId = ?
jtimer.storage.update.time.forremove=UPDATE tasktime SET removed = ?, modificationDate = ? \
WHERE uuid = ?
+jtimer.storage.update.alarm.forremove=UPDATE tasktime SET removed = ?, modificationDate = ? \
+ WHERE alarmid = ?
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/src/main/webapp/css/app.css 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-07-03 13:12:30 UTC (rev 3010)
@@ -272,4 +272,12 @@
.medium_input{
width : 200px;
+}
+
+.color_red{
+ color : red;
+}
+
+.color_green{
+ color : green;
}
\ 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-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/js/app.js 2014-07-03 13:12:30 UTC (rev 3010)
@@ -306,7 +306,7 @@
/**
* Module de webtimer
**/
-angular.module('webtimer', ['webtimerFilters', 'ngRoute', 'ngAnimate', 'ui.bootstrap','serverAccessService', 'serverTimeService','serverReportService' ])
+angular.module('webtimer', ['webtimerFilters', 'ngRoute', 'ngAnimate', 'ui.bootstrap','serverAccessService', 'serverTimeService','serverReportService', 'serverAlarmService' ])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/tasks', {templateUrl: 'partials/tasks.html', controller: TasksCtrl}).
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,4 +1,4 @@
-function TasksCtrl($scope, $interval, $timeout, $q, serverTaskAccess, serverTimeAccess, serverReportAccess, $localStorage, $window, $document, $modal, wtWebsocket, jTimerWebsocket) {
+function TasksCtrl($scope, $interval, $timeout, $q, serverTaskAccess, serverTimeAccess, serverAlarmAccess, serverReportAccess, $localStorage, $window, $document, $modal, wtWebsocket, jTimerWebsocket) {
// {Boolean} vrai si on est online
$scope.online = $window.navigator.onLine;
@@ -172,23 +172,23 @@
if(!alarm.type=="Total_Time" && !alarm.isToday()){
alarm.setToday();
- alarm.passedHour = alarm.limitHour;
- alarm.passedMin = alarm.limitMin;
+ alarm.remainingHour = alarm.limitHour;
+ alarm.remainingMin = alarm.limitMin;
}
- if(alarm.passedMin > 0){
- alarm.passedMin -=1;
- }else if(alarm.passedMin == 0){
- alarm.passedMin = 59;
- alarm.passedHour -=1;
+ if(alarm.remainingMin > 0){
+ alarm.remainingMin -=1;
+ }else if(alarm.remainingMin == 0){
+ alarm.remainingMin = 59;
+ alarm.remainingHour -=1;
}
- if(alarm.passedHour == 0 && alarm.passedMin == 0){
+ if(alarm.remainingHour == 0 && alarm.remainingMin == 0){
//console.log("Alarme lancée " +alarm.name +" de type "+ alarm.type + " par " + task.name );
if(alarm.type=="Total_Time"){
alarms.splice(index,1);
}
- alert('Alarme déclenchée, '+alarm.name + ' ce message va s\'auto détruire!\n');
+ alert('Alarme déclenchée: '+alarm.name + '\nVotre alarme va être désactivée.');
}
index+=1;
});
@@ -771,14 +771,35 @@
};
/** Methode qui va tenter d'envoyer la tâche vers le serveur */
- $scope.alarmPopup = function(task){
+ $scope.alarmPopup = function(node){
var modalInstance = $modal.open({
templateUrl: 'partials/alertModal.html',
controller: AlertModalInstanceCtrl,
resolve: {
task : function(){
- return task;
+ return node.task;
+ },
+ time : function(){
+ var res=0;
+
+
+ var recChildren = function(noeud){
+ angular.forEach($scope.data.times[noeud.task.taskId], function(t){
+ res+=t.time;
+ });
+
+ if(noeud.children){
+ angular.forEach(noeud.children, function(child){
+ recChildren(child);
+ });
+ }
+
+ }
+ recChildren(node);
+
+ console.log(res);
+ return res;
}
}
});
@@ -1024,21 +1045,37 @@
};
}
-function AlertModalInstanceCtrl($scope, $modalInstance, task){
+function AlertModalInstanceCtrl($scope, $modalInstance, serverAlarmAccess, task, time){
- $scope.alarm={name : "" , type : "Type", hour : 0, min : 0};
+ var msToHour=function(ms){
+ return ((ms / (1000*60*60)) % 24);
+ }
+ var msToMin=function(ms){
+ return ((ms / (1000*60)) % 60);
+ }
+
+ $scope.valMinHour=function(){
+ return parseInt(msToHour(time));
+ }
+ $scope.valMinMin=function(){
+ return parseInt(msToMin(time));
+ }
+
+ $scope.alarm={name : "" , type : "Type", hour : $scope.valMinHour(), min : $scope.valMinMin()};
+
$scope.name = task.name;
$scope.alarms = task.alarms;
+
$scope.dynamic = function(alarm){
var res = 0;
var limit = alarm.limitHour*60 + alarm.limitMin;
- var passed = alarm.passedHour*60 + alarm.passedMin;
+ var remaining = alarm.remainingHour*60 + alarm.remainingMin;
- res = ((limit-passed)/limit)*100;
+ res = ((limit-remaining)/limit)*100;
return res;
};
@@ -1062,21 +1099,60 @@
* Methode qui sauve l'alarme
*/
$scope.saveAlarm = function(){
- if($scope.alarm.name== "" || $scope.alarm.type=="Type"){
+ if($scope.alarm.name== "" || $scope.alarm.type=="Type" ){
+ }else{
+ console.log("save " +time);
+ minusPreviousTime(time, $scope.alarm.hour, $scope.alarm.min);
- }else{
- $scope.alarms.push(new TaskAlarm(task, $scope.alarm.name, $scope.alarm.type, $scope.alarm.hour, $scope.alarm.min));
+ console.log("apres minus " +$scope.alarm.hour + " "+$scope.alarm.min);
- $scope.alarm.name= "";
- $scope.alarm.type="Type";
- //$scope.alarm.date= new Date();
- $scope.alarm.hour = 0;
- $scope.alarm.min = 0;
+ if($scope.alarm.hour > 0 || $scope.alarm.min> 0 ){
+
+ console.log($scope.alarm.hour + " "+$scope.alarm.min);
+
+ var al = new TaskAlarm(task,undefined ,
+ $scope.alarm.name,
+ $scope.alarm.type,
+ $scope.alarm.hour,
+ $scope.alarm.min);
+
+ $scope.alarms.push(al);
+
+ serverAlarmAccess.create({alarmId : al.alarmId }, angular.toJson(al),
+ function(){
+ console.log("persist alarm success");
+ },
+ function(){
+ console.log("fail");
+ });
+
+ //On remet les elements affiches a la valeur par defaut
+ $scope.alarm.name= "";
+ $scope.alarm.type="Type";
+ //$scope.alarm.date= new Date();
+ $scope.alarm.hour = 0;
+ $scope.alarm.min = 0;
+ }
}
}
+ var minusPreviousTime= function(previousTime, hour, min){
+ var prevHour = msToHour(previousTime);
+ var prevMin = msToMin(previousTime);
+
+ hour-=prevHour;
+
+ if(min - prevMin<0){
+ min = 59 +(min-prevMin);
+ hour -=1;
+ }
+ }
+
+
+
+
$scope.close = function() {
$modalInstance.close();
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-07-03 13:12:30 UTC (rev 3010)
@@ -73,6 +73,7 @@
this.stockedEditedTimes = {};
// {Array of TaskID} la file de temps attendant la synchronisation avec le serveur
this.stockedDeletedTimes = {};
+
};
@@ -527,8 +528,15 @@
* @param {Task} task la tache liee
* @returns {TaskAlarm}
*/
-var TaskAlarm = function (task, name, type, limitHour,limitMin, repeatF) {
+var TaskAlarm = function (task,id, name, type, limitHour,limitMin, repeatF) {
this.taskId = task && task.taskId;
+
+ if(id == undefined){
+ this.alarmId = generateUUID();
+ }else{
+ this.alarmId = id;
+ }
+
this.name = name;
this.type = type;
@@ -536,9 +544,11 @@
this.limitHour = limitHour;
this.limitMin = limitMin;
- this.passedHour = limitHour;
- this.passedMin = limitMin;
+ this.remainingHour = limitHour;
+ this.remainingMin = limitMin;
+ this.modificationDate = Date.now();
+
this.Frequence = repeatF;
};
Modified: branches/ng-jtimer/src/main/webapp/js/service.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/service.js 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/js/service.js 2014-07-03 13:12:30 UTC (rev 3010)
@@ -1,3 +1,6 @@
+/**
+ * Service qui permet un échange restfull des taches
+ */
angular.module("serverAccessService", ["ngResource"])
.factory("serverTaskAccess", function ( $resource) {
// Encapsule l'acces au server
@@ -15,6 +18,9 @@
}
);
+/**
+ * Service qui permet un échange restfull des temps
+ */
angular.module("serverTimeService", ["ngResource"])
.factory("serverTimeAccess", function ( $resource) {
// Encapsule l'acces au server
@@ -32,6 +38,9 @@
}
);
+/**
+ * Service qui permet un échange restfull des rapports
+ */
angular.module("serverReportService", ["ngResource"])
.factory("serverReportAccess", function ( $resource) {
// Encapsule l'acces au server
@@ -41,4 +50,22 @@
}
);
}
+);
+
+/**
+ * Service qui permet un échange restfull des alarmes
+ */
+angular.module("serverAlarmService", ["ngResource"])
+.factory("serverAlarmAccess", function ( $resource) {
+ // Encapsule l'acces au server
+ return $resource("/rest/tasks/alarm/:alarmId",{},
+ {
+ query : {method:'GET', isArray:true},
+ get : {method: 'GET', isArray: false},
+ update: {method: "PUT"},
+ create: { method: 'POST' },
+ deleteAlarm: { method: 'DELETE' }
+ }
+ );
+ }
);
\ No newline at end of file
Modified: branches/ng-jtimer/src/main/webapp/partials/alertModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-03 13:12:30 UTC (rev 3010)
@@ -33,12 +33,17 @@
<th></th>
</tr>
+ <tr>
+ <th>Nouveau:</th>
+ </tr>
+
<tr>
+
<th></th>
<th><input class='input-sm small_input' ng-model="alarm.name" placeholder="New Alert">
- <i class="glyphicon glyphicon-edit" ng-show="alarm.name==''"> </i>
- <i class="glyphicon glyphicon-check" ng-show="alarm.name!=''"> </i></th>
+ <i class="glyphicon glyphicon-edit color_red" ng-show="alarm.name==''"> </i>
+ <i class="glyphicon glyphicon-check color_green" ng-show="alarm.name!=''"> </i></th>
<th>
<div class="btn-group" dropdown is-open="status.isopen">
<button type="button" class="btn btn-primary dropdown-toggle">
@@ -49,8 +54,8 @@
<li ng-click="dropdownType2()">Total_Time</li>
</ul>
</div>
- <i class="glyphicon glyphicon-edit" ng-show="alarm.type=='Type'"> </i>
- <i class="glyphicon glyphicon-check" ng-show="alarm.type!='Type'"> </i>
+ <i class="glyphicon glyphicon-edit color_red" ng-show="alarm.type=='Type'"> </i>
+ <i class="glyphicon glyphicon-check color_green"ng-show="alarm.type!='Type'"> </i>
</th>
<th>
<!--<timepicker ng-model="alarm.date" ng-change="changed()"
@@ -58,18 +63,18 @@
</timepicker>-->
<div ng-if="alarm.type!='Total_Time'">
- <input type="number" step="1" min="0" max="23" ng-model="alarm.hour">h:
- <input type="number" step="1" min="0" max="59" ng-model="alarm.min">m
+ <input type="number" step="1" min="{{valMinHour()}}" max="23" ng-model="alarm.hour">h:
+ <input type="number" step="1" min="{{valMinMin()}}" max="59" ng-model="alarm.min">m
</div>
<div ng-if="alarm.type=='Total_Time'">
- <input class="xsmall_input" type="number" step="1" min="0" max="" ng-model="alarm.hour">h:
- <input class="xsmall_input" type="number" step="1" min="0" max="" ng-model="alarm.min">m
+ <input class="xsmall_input" type="number" step="1" min="{{valMinHour()}}" max="" ng-model="alarm.hour">h:
+ <input class="xsmall_input" type="number" step="1" min="{{valMinMin()}}" max="59" ng-model="alarm.min">m
</div>
</th>
<th></th>
- <th><i class="glyphicon glyphicon-ok" ng-click="saveAlarm()"></i></th>
+ <th><i class="glyphicon glyphicon-ok green" ng-click="saveAlarm()"></i></th>
</tr>
</div>
@@ -77,6 +82,6 @@
<div class="modal-footer">
- <button class="btn btn-primary" ng-click="cancel()">Cancel</button>
+ <!--<button class="btn btn-primary" ng-click="cancel()">Cancel</button>-->
<button class="btn btn-primary" ng-click="close()">Close</button>
</div>
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-07-01 15:47:05 UTC (rev 3009)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-07-03 13:12:30 UTC (rev 3010)
@@ -91,7 +91,7 @@
ng-show="!$node.task.isRoot() ">
<i class="glyphicon glyphicon-pencil" ></i>
</a>
- <a class="btn btn-default btn-xs" ng-click="alarmPopup($node.task)">
+ <a class="btn btn-default btn-xs" ng-click="alarmPopup($node)">
<i class="glyphicon glyphicon-bell" ></i>
</a>
</span>
1
0
r3009 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage resources webapp/css webapp/js webapp/partials
by obruce@users.chorem.org 01 Jul '14
by obruce@users.chorem.org 01 Jul '14
01 Jul '14
Author: obruce
Date: 2014-07-01 17:47:05 +0200 (Tue, 01 Jul 2014)
New Revision: 3009
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/3009
Log:
interface alarm
Added:
branches/ng-jtimer/src/main/webapp/partials/alertModal.html
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.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/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/partials/tasks.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-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-07-01 15:47:05 UTC (rev 3009)
@@ -36,7 +36,7 @@
protected static final String TABLE_TASK = "task";
protected static final String TABLE_TIME = "tasktime";
- protected static final String TABLE_VERSION = "version";
+ protected String TABLE_VERSION;
protected String STORAGE_PATH;
protected JtimerConfig config;
@@ -47,6 +47,7 @@
this.config = conf;
this.STORAGE_PATH = config.getStoragePath();
+ this.TABLE_VERSION = config.getStorageTableVersion();
try {
if (log.isDebugEnabled()) {
Modified: branches/ng-jtimer/src/main/resources/jtimer-default.properties
===================================================================
--- branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/resources/jtimer-default.properties 2014-07-01 15:47:05 UTC (rev 3009)
@@ -10,6 +10,7 @@
jtimer.storage.table.task=task
jtimer.storage.table.time=tasktime
jtimer.storage.table.version=version
+jtimer.storage.table.alert=taskalert
###
#CREATE SCHEMA
jtimer.storage.create.table.version=CREATE TABLE version (version VARCHAR(10))
@@ -34,6 +35,14 @@
FOREIGN KEY (taskid) \
REFERENCES task (taskId) \
ON DELETE CASCADE)
+jtimer.storage.create.alert=CREATE TABLE taskalert \
+ (taskid VARCHAR(255) NOT NULL, \
+ name VARCHAR(255) NOT NULL, \
+ type VARCHAR(255) NOT NULL, \
+ limitDate LONG, \
+ modificationDate LONG, \
+ repeatFrequence VARCHAR(255), \
+ PRIMARY KEY (taskId, name))
####
#INSERT
jtimer.storage.insert.version.number=INSERT INTO VERSION VALUES('2.0')
Modified: branches/ng-jtimer/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/src/main/webapp/css/app.css 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-07-01 15:47:05 UTC (rev 3009)
@@ -262,6 +262,10 @@
margin : auto;
}
+.xsmall_input{
+ width : 50px;
+}
+
.small_input{
width : 100px;
}
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-07-01 15:47:05 UTC (rev 3009)
@@ -142,6 +142,64 @@
refresh();
/**
+ * Methode qui se lance toutes les minutes pour verifier les alamres des taches
+ */
+ var checkAlarms = function() {
+ $timeout(function() {
+
+ if ($scope.currentTask) {
+
+ checkRecurseParent($scope.currentTask);
+ }
+
+ checkAlarms();
+ }, 60000);
+ };
+ checkAlarms();
+
+ /**
+ *
+ * @param :task la tache
+ */
+ var checkRecurseParent = function(task){
+
+ var alarms= task.alarms;
+ var index=0;
+ var parent = $scope.data.tasks[task.parent];
+
+ angular.forEach(alarms, function(alarm){
+
+
+ if(!alarm.type=="Total_Time" && !alarm.isToday()){
+ alarm.setToday();
+ alarm.passedHour = alarm.limitHour;
+ alarm.passedMin = alarm.limitMin;
+ }
+
+ if(alarm.passedMin > 0){
+ alarm.passedMin -=1;
+ }else if(alarm.passedMin == 0){
+ alarm.passedMin = 59;
+ alarm.passedHour -=1;
+ }
+
+ if(alarm.passedHour == 0 && alarm.passedMin == 0){
+ //console.log("Alarme lancée " +alarm.name +" de type "+ alarm.type + " par " + task.name );
+ if(alarm.type=="Total_Time"){
+ alarms.splice(index,1);
+ }
+ alert('Alarme déclenchée, '+alarm.name + ' ce message va s\'auto détruire!\n');
+ }
+ index+=1;
+ });
+
+
+ if(task.parent != ""){
+ checkRecurseParent(parent);
+ }
+ };
+
+ /**
* Timer qui joue des actions sur un interval donné
* @returns {promise}
*/
@@ -246,7 +304,6 @@
}
}else{
- //Un noeud avec un parent est ajoute à l'arbre de son parent
//On ajoute le node à l'arbre
if ($scope.tree.getNode(item.parent)) {
@@ -714,10 +771,22 @@
};
/** Methode qui va tenter d'envoyer la tâche vers le serveur */
- $scope.persistToServ = function(task){
+ $scope.alarmPopup = function(task){
- };
+ var modalInstance = $modal.open({
+ templateUrl: 'partials/alertModal.html',
+ controller: AlertModalInstanceCtrl,
+ resolve: {
+ task : function(){
+ return task;
+ }
+ }
+ });
+ modalInstance.result.then(function (item) {
+ });
+ }
+
/**
* Active/desactive le comptage de temps pour une tache
* @param {type} task
@@ -913,9 +982,6 @@
}
}
});
-
- modalInstance.result.then(function (item) {
- });
}
/**
@@ -958,6 +1024,66 @@
};
}
+function AlertModalInstanceCtrl($scope, $modalInstance, task){
+
+ $scope.alarm={name : "" , type : "Type", hour : 0, min : 0};
+
+ $scope.name = task.name;
+ $scope.alarms = task.alarms;
+
+
+ $scope.dynamic = function(alarm){
+ var res = 0;
+
+ var limit = alarm.limitHour*60 + alarm.limitMin;
+ var passed = alarm.passedHour*60 + alarm.passedMin;
+
+ res = ((limit-passed)/limit)*100;
+
+ return res;
+ };
+
+ $scope.dropdownType1= function(){
+ $scope.alarm.type = "Total_Day_Time";
+ }
+
+ $scope.dropdownType2 = function(){
+ $scope.alarm.type = "Total_Time";
+ }
+
+ /**
+ * Methode qui supprime un element du tableau d'alerte
+ */
+ $scope.removeAlert = function(index,a){
+ $scope.alarms.splice(index, 1);
+ }
+
+ /**
+ * Methode qui sauve l'alarme
+ */
+ $scope.saveAlarm = function(){
+ if($scope.alarm.name== "" || $scope.alarm.type=="Type"){
+
+
+
+ }else{
+ $scope.alarms.push(new TaskAlarm(task, $scope.alarm.name, $scope.alarm.type, $scope.alarm.hour, $scope.alarm.min));
+
+ $scope.alarm.name= "";
+ $scope.alarm.type="Type";
+ //$scope.alarm.date= new Date();
+ $scope.alarm.hour = 0;
+ $scope.alarm.min = 0;
+ }
+ }
+
+ $scope.close = function() {
+
+ $modalInstance.close();
+ };
+}
+
+
function ReportModalInstanceCtrl($scope, $modalInstance,$http, $sce, serverReportAccess, tree){
$scope.tree = tree;
@@ -976,6 +1102,10 @@
return $sce.trustAsHtml(data);
}
+ /**
+ * Methode de generation du rapport
+ *
+ */
$scope.generateReport= function(){
$scope.obj.startDate.setHours(0,0,0,0);
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-07-01 15:47:05 UTC (rev 3009)
@@ -403,6 +403,7 @@
this.name = name;
this.description = "";
this.isReported = true;
+ this.alarms=[];
this.tags = [];
this.syncOptions = {};
};
@@ -521,7 +522,37 @@
return this;
};
+/**
+ * Permet de conserver une alarme
+ * @param {Task} task la tache liee
+ * @returns {TaskAlarm}
+ */
+var TaskAlarm = function (task, name, type, limitHour,limitMin, repeatF) {
+ this.taskId = task && task.taskId;
+ this.name = name;
+ this.type = type;
+ this.date = today();
+
+ this.limitHour = limitHour;
+ this.limitMin = limitMin;
+ this.passedHour = limitHour;
+ this.passedMin = limitMin;
+
+ this.Frequence = repeatF;
+
+};
+
+TaskAlarm.prototype.isToday = function() {
+ var result = this.date === today();
+ return result;
+};
+
+TaskAlarm.prototype.setToday = function() {
+ this.date=today();
+};
+
+
/**
* Represente une note pour une tache
* @param {Task} task
Added: branches/ng-jtimer/src/main/webapp/partials/alertModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/alertModal.html (rev 0)
+++ branches/ng-jtimer/src/main/webapp/partials/alertModal.html 2014-07-01 15:47:05 UTC (rev 3009)
@@ -0,0 +1,82 @@
+<h3>Les alarmes pour {{name}} :</h3>
+
+<hr/>
+
+<table class='table'>
+ <thead>
+ <tr>
+ <th></th>
+ <th>Name</th>
+ <th>Type</th>
+ <th>Limit time</th>
+ <th>Progress</th>
+ <th></th>
+ </tr>
+ </thead>
+ <div class="tbody">
+
+ <!-- <div ng-bind-html="toHTML(htmlReport)"></div>
+ $scope.toHTML = function (data) {
+ return $sce.trustAsHtml(data);
+ -->
+
+ <!--Portion d'ajout -->
+ <tr ng-repeat="(index,alarm) in alarms">
+ <th><i class="glyphicon glyphicon-minus-sign" ng-click="removeAlert(index,alarm)"></i></th>
+
+ <th>{{alarm.name}}</th>
+ <th>{{alarm.type}}</th>
+ <th>{{alarm.limitHour}}h: {{alarm.limitMin}}min</th>
+ <th>
+ <progressbar value="dynamic(alarm)"></progressbar>
+ </th>
+ <th></th>
+ </tr>
+
+
+ <tr>
+ <th></th>
+ <th><input class='input-sm small_input' ng-model="alarm.name" placeholder="New Alert">
+ <i class="glyphicon glyphicon-edit" ng-show="alarm.name==''"> </i>
+ <i class="glyphicon glyphicon-check" ng-show="alarm.name!=''"> </i></th>
+ <th>
+ <div class="btn-group" dropdown is-open="status.isopen">
+ <button type="button" class="btn btn-primary dropdown-toggle">
+ {{alarm.type}} <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu" role="menu">
+ <li ng-click="dropdownType1()">Total_Time_In_a_Day</li>
+ <li ng-click="dropdownType2()">Total_Time</li>
+ </ul>
+ </div>
+ <i class="glyphicon glyphicon-edit" ng-show="alarm.type=='Type'"> </i>
+ <i class="glyphicon glyphicon-check" ng-show="alarm.type!='Type'"> </i>
+ </th>
+ <th>
+ <!--<timepicker ng-model="alarm.date" ng-change="changed()"
+ hour-step="1" minute-step="1" show-meridian="ismeridian">
+
+ </timepicker>-->
+ <div ng-if="alarm.type!='Total_Time'">
+ <input type="number" step="1" min="0" max="23" ng-model="alarm.hour">h:
+ <input type="number" step="1" min="0" max="59" ng-model="alarm.min">m
+ </div>
+
+ <div ng-if="alarm.type=='Total_Time'">
+ <input class="xsmall_input" type="number" step="1" min="0" max="" ng-model="alarm.hour">h:
+ <input class="xsmall_input" type="number" step="1" min="0" max="" ng-model="alarm.min">m
+ </div>
+
+ </th>
+ <th></th>
+ <th><i class="glyphicon glyphicon-ok" ng-click="saveAlarm()"></i></th>
+ </tr>
+ </div>
+
+</table>
+
+
+<div class="modal-footer">
+ <button class="btn btn-primary" ng-click="cancel()">Cancel</button>
+ <button class="btn btn-primary" ng-click="close()">Close</button>
+</div>
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-06-27 09:46:09 UTC (rev 3008)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-07-01 15:47:05 UTC (rev 3009)
@@ -37,7 +37,7 @@
<span class="left">{{currentDate()}}</span>
<span class="center"><i class="fa fa-html5"></i> <a>WebTimer</a></span>
<!--<span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</span>-->
- <span class="right">Dernière mise à jour: {{getLastMajDate()}}</span>
+ <span class="right">Last update : {{getLastMajDate()}}</span>
</div>
@@ -69,11 +69,12 @@
<i class="glyphicon glyphicon-minus-sign" ng-click="$toggleState()" ng-show="$state=='open'"></i>
<!--Project name visible and editable -->
- <form ng-submit="saveTask($node)" ng-show="$node.edit == 'name'">
+ <form ng-submit="saveTask($node)" ng-show="$node.edit == 'name'" ng-blur="$node.edit == ''">
<input ng-model="$node.task.name" ng-blur="$node.edit == ''" >
</form>
<span ng-click="editTask($node, 'name')" ng-show="$node.edit != 'name'">{{$node.task.name}} </span>
+
<!-- Action button, add,remove activate task -->
<span class="btn-group action">
<a class="btn btn-default btn-xs" ng-click="timeTask($node.task)" ng-show="$level > 1">
@@ -90,8 +91,8 @@
ng-show="!$node.task.isRoot() ">
<i class="glyphicon glyphicon-pencil" ></i>
</a>
- <a class="btn btn-default btn-xs" ng-click="persistToServ($node.task)">
- <i class="glyphicon glyphicon-floppy-disk" ></i>
+ <a class="btn btn-default btn-xs" ng-click="alarmPopup($node.task)">
+ <i class="glyphicon glyphicon-bell" ></i>
</a>
</span>
</div>
1
0