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
May 2014
- 3 participants
- 31 discussions
r2982 - in branches/ng-jtimer: . src/main/java/org/chorem/jtimer/web
by athimel@users.chorem.org 21 May '14
by athimel@users.chorem.org 21 May '14
21 May '14
Author: athimel
Date: 2014-05-21 11:57:31 +0200 (Wed, 21 May 2014)
New Revision: 2982
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2982
Log:
Correction de l'integration du HTTP OPTIONS
Modified:
branches/ng-jtimer/pom.xml
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
Modified: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml 2014-05-21 09:12:42 UTC (rev 2981)
+++ branches/ng-jtimer/pom.xml 2014-05-21 09:57:31 UTC (rev 2982)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>5.0.5</version>
+ <version>5.0.6-SNAPSHOT</version>
</parent>
<groupId>org.chorem</groupId>
@@ -151,9 +151,12 @@
<dependencies>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
- <version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
@@ -184,7 +187,6 @@
</dependencies>
<repositories>
-
<repository>
<id>maven-restlet</id>
<name>Public online Restlet repository</name>
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java 2014-05-21 09:12:42 UTC (rev 2981)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java 2014-05-21 09:57:31 UTC (rev 2982)
@@ -9,18 +9,23 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* Created by olivia on 20/05/14.
*/
public class ApplicationServletFilter implements Filter {
- private final static Logger LOGGER = Logger.getLogger(TasksResource.class.getName());
+ // private final static Logger LOGGER = Logger.getLogger(TasksResource.class.getName());
+ private static final Log log = LogFactory.getLog(TasksResource.class);
private static final String HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
private static final String HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";
private static final String HEADER_ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers";
private static final String HEADER_ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers";
+ private static final String HEADER_ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods";
@Override
public void init(FilterConfig filterConfig) throws ServletException {
@@ -30,7 +35,9 @@
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//Avant l'execution de la requete
- LOGGER.log(Level.WARNING, "Passqage dans le filter");
+ if (log.isDebugEnabled()) {
+ log.debug("Passage dans le filter");
+ }
if(servletRequest instanceof HttpServletRequest ) {
@@ -43,11 +50,12 @@
while (lesElem.hasMoreElements()) {
names += ", " + lesElem.nextElement();
}
- LOGGER.log(Level.WARNING, names);
+ log.warn(names);
httpServletResponse.addHeader(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*");
httpServletResponse.addHeader(HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
+ httpServletResponse.addHeader(HEADER_ACCESS_CONTROL_ALLOW_METHODS, "GET, POST, PUT, OPTIONS, DELETE");
String requestHeaders = httpServletRequest.getHeader(HEADER_ACCESS_CONTROL_REQUEST_HEADERS);
@@ -60,7 +68,9 @@
}
- LOGGER.log(Level.WARNING, "Fin filter");
+ if (log.isWarnEnabled()) {
+ log.warn("Fin filter");
+ }
}
@Override
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-05-21 09:12:42 UTC (rev 2981)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-05-21 09:57:31 UTC (rev 2982)
@@ -1,6 +1,9 @@
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.storage.Storage;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
@@ -10,6 +13,8 @@
public class TaskResource extends ServerResource {
+ private static final Log log = LogFactory.getLog(TaskResource.class);
+
protected Storage storage;
/**
@@ -48,6 +53,12 @@
}
+ @Options
+ public void taskOptions() {
+ if (log.isInfoEnabled()) {
+ log.info("org.chorem.jtimer.web.TaskResource.taskOptions");
+ }
+ }
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-05-21 09:12:42 UTC (rev 2981)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-05-21 09:57:31 UTC (rev 2982)
@@ -1,36 +1,53 @@
package org.chorem.jtimer.web;
-import com.google.gson.*;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.storage.Storage;
-import org.eclipse.jetty.util.log.Log;
import org.restlet.data.MediaType;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;
-import org.restlet.resource.*;
+import org.restlet.resource.Get;
+import org.restlet.resource.Options;
+import org.restlet.resource.Post;
+import org.restlet.resource.Put;
+import org.restlet.resource.ResourceException;
+import org.restlet.resource.ServerResource;
+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 java.io.IOException;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
public class TasksResource extends ServerResource {
+ private static final Log log = LogFactory.getLog(TasksResource.class);
+
protected Storage storage;
private final static Logger LOGGER = Logger.getLogger(TasksResource.class.getName());
private GsonBuilder builder;
/**
* Methode qui initialis la resource
+ *
* @throws ResourceException
*/
@Override
protected void doInit() throws ResourceException {
- storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
+ storage = (Storage) getContext().getAttributes().get(Storage.class.getName());
builder = new GsonBuilder();
// Register an adapter to manage the date types as long values
@@ -57,18 +74,16 @@
/**
* Methode qui retourne la representation de la liste de toutes les taches
* Suite a une requete de type GET
+ *
* @return
*/
@Get("json")
public Representation getTasks() {
Long date = Long.valueOf(0);
- try
- {
+ try {
date = Long.valueOf(getQuery().getValues("date"));
- }
- catch(Exception e)
- {
+ } catch (Exception e) {
date = Long.valueOf(0);
}
@@ -80,7 +95,7 @@
for (int i = 0; i < tabSize; i++) {
TimerTask task = timerTasks.get(i);
- if (task.getParent() == "") {
+ if (StringUtils.isBlank(task.getParent())) {
timerTasks.add(task);
timerTasks.remove(i);
i--;
@@ -104,7 +119,7 @@
Gson gson = builder.create();
String repr1 = representation.getText();
TimerTask t = gson.fromJson(repr1, TimerTask.class);
- LOGGER.log(Level.INFO,"repr1");
+ LOGGER.log(Level.INFO, "repr1");
storage.addTask(t);
}
@@ -114,7 +129,7 @@
* suite d'une requête de type PUT
*/
@Put("json")
- public void updateTask(Representation representation) throws IOException{
+ public void updateTask(Representation representation) throws IOException {
Gson gson = builder.create();
String repr1 = representation.getText();
@@ -123,4 +138,12 @@
storage.modifyTask(t);
}
+
+ @Options
+ public void tasksOptions() {
+ if (log.isInfoEnabled()) {
+ log.info("org.chorem.jtimer.web.TasksResource.tasksOptions");
+ }
+ }
+
}
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-05-21 09:12:42 UTC (rev 2981)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-05-21 09:57:31 UTC (rev 2982)
@@ -1,6 +1,9 @@
package org.chorem.jtimer.web;
import com.google.gson.*;
+
+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;
@@ -15,6 +18,8 @@
public class TimeResource extends ServerResource {
+ private static final Log log = LogFactory.getLog(TimeResource.class);
+
private GsonBuilder builder;
protected Storage storage;
@@ -107,4 +112,11 @@
storage.modifyTime(t);
}
+ @Options
+ public void timeOptions() {
+ if (log.isInfoEnabled()) {
+ log.info("org.chorem.jtimer.web.TimeResource.timeOptions");
+ }
+ }
+
}
1
0
r2981 - branches/ng-jtimer/src/main/java/org/chorem/jtimer/web
by obruce@users.chorem.org 21 May '14
by obruce@users.chorem.org 21 May '14
21 May '14
Author: obruce
Date: 2014-05-21 11:12:42 +0200 (Wed, 21 May 2014)
New Revision: 2981
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2981
Log:
Filter ajout du header
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java 2014-05-21 07:32:07 UTC (rev 2980)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java 2014-05-21 09:12:42 UTC (rev 2981)
@@ -1,7 +1,6 @@
package org.chorem.jtimer.web;
-
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -10,6 +9,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+
/**
* Created by olivia on 20/05/14.
*/
@@ -19,6 +19,8 @@
private static final String HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
private static final String HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";
+ private static final String HEADER_ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers";
+ private static final String HEADER_ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers";
@Override
public void init(FilterConfig filterConfig) throws ServletException {
@@ -30,26 +32,32 @@
//Avant l'execution de la requete
LOGGER.log(Level.WARNING, "Passqage dans le filter");
+ if(servletRequest instanceof HttpServletRequest ) {
- HttpServletRequest request = (HttpServletRequest) servletRequest;
+ HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
+ HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
- Enumeration<String> lesElem = request.getHeaderNames();
+ Enumeration<String> lesElem = httpServletRequest.getHeaderNames();
- String names = "";
- while(lesElem.hasMoreElements()){
- names += ", " +lesElem.nextElement();
+ String names = "";
+ while (lesElem.hasMoreElements()) {
+ names += ", " + lesElem.nextElement();
+ }
+ LOGGER.log(Level.WARNING, names);
- }
- LOGGER.log(Level.WARNING, names);
+ httpServletResponse.addHeader(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*");
+ httpServletResponse.addHeader(HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS, "true");
- //Apres l'execution de la requete
- ((HttpServletResponse) servletResponse).addHeader(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,"*");
- ((HttpServletResponse) servletResponse).addHeader(HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS,"true");
+ String requestHeaders = httpServletRequest.getHeader(HEADER_ACCESS_CONTROL_REQUEST_HEADERS);
- filterChain.doFilter(request,servletResponse);
+ if (requestHeaders!= null && !requestHeaders.isEmpty()) {
+ httpServletResponse.addHeader(HEADER_ACCESS_CONTROL_ALLOW_HEADERS, requestHeaders);
+ }
+ filterChain.doFilter(httpServletRequest, httpServletResponse);
+ }
LOGGER.log(Level.WARNING, "Fin filter");
1
0
r2980 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/web webapp/WEB-INF
by obruce@users.chorem.org 21 May '14
by obruce@users.chorem.org 21 May '14
21 May '14
Author: obruce
Date: 2014-05-21 09:32:07 +0200 (Wed, 21 May 2014)
New Revision: 2980
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2980
Log:
Ajout d'un servlet filter
Added:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
branches/ng-jtimer/src/main/webapp/WEB-INF/web.xml
Added: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java (rev 0)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/ApplicationServletFilter.java 2014-05-21 07:32:07 UTC (rev 2980)
@@ -0,0 +1,62 @@
+package org.chorem.jtimer.web;
+
+
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Created by olivia on 20/05/14.
+ */
+public class ApplicationServletFilter implements Filter {
+
+ private final static Logger LOGGER = Logger.getLogger(TasksResource.class.getName());
+
+ private static final String HEADER_ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
+ private static final String HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+
+ }
+
+ @Override
+ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
+ //Avant l'execution de la requete
+ LOGGER.log(Level.WARNING, "Passqage dans le filter");
+
+
+ HttpServletRequest request = (HttpServletRequest) servletRequest;
+
+ Enumeration<String> lesElem = request.getHeaderNames();
+
+ String names = "";
+ while(lesElem.hasMoreElements()){
+ names += ", " +lesElem.nextElement();
+
+ }
+ LOGGER.log(Level.WARNING, names);
+
+ //Apres l'execution de la requete
+ ((HttpServletResponse) servletResponse).addHeader(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,"*");
+ ((HttpServletResponse) servletResponse).addHeader(HEADER_ACCESS_CONTROL_ALLOW_CREDENTIALS,"true");
+
+
+ filterChain.doFilter(request,servletResponse);
+
+
+
+
+ LOGGER.log(Level.WARNING, "Fin filter");
+ }
+
+ @Override
+ public void destroy() {
+
+ }
+}
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-05-20 09:31:49 UTC (rev 2979)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/RestApplication.java 2014-05-21 07:32:07 UTC (rev 2980)
@@ -5,7 +5,9 @@
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.storage.Storage;
-import org.restlet.*;
+import org.restlet.Application;
+import org.restlet.Context;
+import org.restlet.Restlet;
import org.restlet.routing.Router;
public class RestApplication extends Application {
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-05-20 09:31:49 UTC (rev 2979)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TaskResource.java 2014-05-21 07:32:07 UTC (rev 2980)
@@ -7,8 +7,6 @@
import org.restlet.representation.StringRepresentation;
import org.restlet.resource.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class TaskResource extends ServerResource {
Modified: branches/ng-jtimer/src/main/webapp/WEB-INF/web.xml
===================================================================
--- branches/ng-jtimer/src/main/webapp/WEB-INF/web.xml 2014-05-20 09:31:49 UTC (rev 2979)
+++ branches/ng-jtimer/src/main/webapp/WEB-INF/web.xml 2014-05-21 07:32:07 UTC (rev 2980)
@@ -1,19 +1,29 @@
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
- <context-param>
- <param-name>org.restlet.application</param-name>
- <param-value>org.chorem.jtimer.web.RestApplication</param-value>
- </context-param>
+ <context-param>
+ <param-name>org.restlet.application</param-name>
+ <param-value>org.chorem.jtimer.web.RestApplication</param-value>
+ </context-param>
- <servlet>
- <servlet-name>RestletServlet</servlet-name>
- <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
- </servlet>
+ <servlet>
+ <servlet-name>RestletServlet</servlet-name>
+ <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
+ </servlet>
- <servlet-mapping>
- <servlet-name>RestletServlet</servlet-name>
- <url-pattern>/rest/*</url-pattern>
- </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>RestletServlet</servlet-name>
+ <url-pattern>/rest/*</url-pattern>
+ </servlet-mapping>
+
+ <filter>
+ <filter-name>appFilter</filter-name>
+ <filter-class>org.chorem.jtimer.web.ApplicationServletFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>appFilter</filter-name>
+ <url-pattern>/rest/*</url-pattern>
+ </filter-mapping>
</web-app>
1
0
r2979 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/entities java/org/chorem/jtimer/storage java/org/chorem/jtimer/web webapp/js webapp/partials
by obruce@users.chorem.org 20 May '14
by obruce@users.chorem.org 20 May '14
20 May '14
Author: obruce
Date: 2014-05-20 11:31:49 +0200 (Tue, 20 May 2014)
New Revision: 2979
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2979
Log:
Base/UI ajout date de modification pour les taches
Changement algo de synchro
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/js/service.js
branches/ng-jtimer/src/main/webapp/partials/timeModal.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-05-16 16:18:00 UTC (rev 2978)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTask.java 2014-05-20 09:31:49 UTC (rev 2979)
@@ -56,7 +56,7 @@
protected String name;
/** Creation date. */
- protected Date creationDate;
+ protected Date modificationDate;
/** Closed task. */
protected boolean closed;
@@ -86,7 +86,7 @@
this.name = name;
this.taskId = UUID.randomUUID().toString();
this.parent = "";
- this.creationDate= new Date();
+ this.modificationDate = new Date();
}
/**
@@ -100,7 +100,7 @@
this.name = name;
this.taskId = UUID.randomUUID().toString();
this.parent = "";
- this.creationDate= new Date(datetime);
+ this.modificationDate = new Date(datetime);
}
@@ -178,17 +178,17 @@
*
* @return task creation date
*/
- public Date getCreationDate() {
- return creationDate;
+ public Date getModificationDate() {
+ return modificationDate;
}
/**
* Set task creation date.
*
- * @param creationDate creation date
+ * @param modificationDate creation date
*/
- public void setCreationDate(Date creationDate) {
- this.creationDate = creationDate;
+ public void setModificationDate(Date modificationDate) {
+ this.modificationDate = modificationDate;
}
/**
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java 2014-05-16 16:18:00 UTC (rev 2978)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/entities/TimerTime.java 2014-05-20 09:31:49 UTC (rev 2979)
@@ -23,6 +23,9 @@
/** Creation Date*/
protected Date creationDate;
+ /** Modification Date */
+ protected Date modificationDate;
+
/** Time Elapsed in the period */
protected long time;
@@ -41,10 +44,17 @@
this.taskId = taskId;
this.time = time;
this.creationDate = creationDate;
+ this.modificationDate = creationDate;
}
+ public Date getModificationDate() {
+ return modificationDate;
+ }
+ public void setModificationDate(Date modificationDate) {
+ this.modificationDate = modificationDate;
+ }
public String getTaskId() {
return taskId;
@@ -83,7 +93,7 @@
return "TimerTime{" +
", taskId='" + taskId + '\'' +
", timeId='" + timeId + '\'' +
- ", creationDate=" + creationDate +
+ ", modificationDate=" + creationDate +
", time=" + time +
'}';
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-16 16:18:00 UTC (rev 2978)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-20 09:31:49 UTC (rev 2979)
@@ -61,8 +61,8 @@
protected Connection getConnection() throws SQLException {
//TODO obruce 15-05-14 path a definir
- //String url = "/tmp/jtimer/jtimer";
- String url = "/home/olivia/Bureau/jtimer/jtimer";
+ String url = "/tmp/jtimer/jtimer";
+ //String url = "/home/olivia/Bureau/jtimer/jtimer";
if (log.isInfoEnabled()) {
log.info("Opening connection to database : " + url);
}
@@ -144,6 +144,7 @@
" taskId VARCHAR(255) NOT NULL UNIQUE," +
" name VARCHAR(255) NOT NULL," +
" parent VARCHAR(255)," +
+ " modificationDate LONG, " +
" hidden BOOLEAN," +
" note TEXT," +
" PRIMARY KEY (id, taskId))");
@@ -152,6 +153,7 @@
" date LONG," +
" uuid varchar(255) unique," +
" duration LONG," +
+ " modificationDate LONG," +
" PRIMARY KEY (taskid, date, uuid)," +
" FOREIGN KEY (taskid)" +
" REFERENCES " + TABLE_TASK +"(id)" +
@@ -193,14 +195,14 @@
* Query that returns every tasks
* @return tasks arraylist of tasks
*/
- public List<TimerTask> getTasks() {
- List<TimerTask> tasks = new ArrayList<>();
+ public ArrayList<TimerTask> getTasks(Long date) {
+ ArrayList<TimerTask> tasks = new ArrayList<TimerTask>();
PreparedStatement statement = null;
PreparedStatement statement2 = null;
try {
- statement = connection.prepareStatement("SELECT TA.*, MIN(TI.date) as modifdate, sum(TI.duration) AS totalduration FROM " +
+ statement = connection.prepareStatement("SELECT TA.*, sum(TI.duration) AS totalduration FROM " +
TABLE_TASK + " TA, " + TABLE_TIME + " TI" +
- " WHERE TA.id = TI.taskid" +
+ " WHERE TA.id = TI.taskid AND TA.modificationDate >" +date +
" GROUP BY TA.id");
ResultSet rs = statement.executeQuery();
while (rs.next()) {
@@ -210,14 +212,14 @@
task.setName(rs.getString("name"));
task.setParent(rs.getString("parent"));
task.setTodayTime(0);
- task.setCreationDate(new java.util.Date(rs.getLong("modifdate")));
+ task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
task.setTotalTime(rs.getLong("totalduration"));
tasks.add(task);
}
// not timed tasks
statement2 = connection.prepareStatement("SELECT * FROM " + TABLE_TASK +
- " WHERE id not in (SELECT taskid FROM " + TABLE_TIME + ")");
+ " WHERE (id not in (SELECT taskid FROM " + TABLE_TIME + ")) AND "+ TABLE_TASK +".modificationDate >" +date );
rs = statement2.executeQuery();
while (rs.next()) {
TimerTask task = new TimerTask();
@@ -225,7 +227,7 @@
task.setName(rs.getString("name"));
task.setTaskId(rs.getString("taskId"));
task.setParent(rs.getString("parent"));
- task.setCreationDate(new Date());
+ task.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
task.setTodayTime(0);
task.setTotalTime(0);
tasks.add(task);
@@ -247,17 +249,14 @@
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT INTO " +
- TABLE_TASK + "(name, parent, taskId, hidden, note)" +
- " VALUES (?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
+ TABLE_TASK + "(name, parent, taskId, hidden, note, modificationDate)" +
+ " VALUES (?, ?, ?, ?, ?,?)", Statement.RETURN_GENERATED_KEYS);
statement.setString(1, task.getName());
- if (task.getParent() == "" || task.getParent() == "0" ) {
- statement.setString(2, "");
- } else {
- statement.setString(2, task.getParent());
- }
+ statement.setString(2, task.getParent());
statement.setString(3, task.getTaskId());
statement.setBoolean(4, task.isClosed());
statement.setString(5, null /*project.getNote()*/);
+ statement.setLong(6, task.getModificationDate().getTime());
statement.executeUpdate();
// get generated id
@@ -276,18 +275,15 @@
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " +
- TABLE_TASK + " SET name=?, parent=?, hidden=?, note=?" +
+ TABLE_TASK + " SET name=?, parent=?, hidden=?, note=?, modificationDate=?" +
" WHERE taskId = ?");
statement.setString(1, task.getName()); //name
- if (task.getParent() == "") {
- statement.setString(2, ""); //parent
- } else {
- statement.setString(2, task.getParent()); //parent
- }
-
+ statement.setString(2, task.getParent()); //parent
statement.setBoolean(3, task.isClosed()); //hidden
statement.setString(4, null /*project.getNote()*/);//note
- statement.setString(5, task.getTaskId()); //taskId
+ statement.setLong(5, task.getModificationDate().getTime()); //modificationDate
+ statement.setString(6, task.getTaskId()); //taskId
+
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't modify task", ex);
@@ -300,11 +296,12 @@
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("UPDATE " +
- TABLE_TIME + " SET date=?, duration=?" +
+ TABLE_TIME + " SET date=?, duration=?, modificationDate=?" +
" WHERE uuid = ?");
statement.setLong(1, t.getCreationDate().getTime());
statement.setLong(2, t.getTime());
- statement.setString(3, t.getTimeId() );
+ statement.setLong(3, t.getModificationDate().getTime()); //modificationDate
+ statement.setString(4, t.getTimeId() );
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't modify time", ex);
@@ -337,17 +334,25 @@
return result;
}
+ /**
+ * Ajoute une periode pour une tache
+ * @param task
+ * @param date
+ * @param uuid
+ * @param duration
+ */
public void addTaskTime(TimerTask task, Date date, String uuid, long duration) {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT INTO " + TABLE_TIME +
- "(taskid, date, uuid, duration)" +
- " VALUES(?, ?, ?, ?)");
+ "(taskid, date, uuid, duration, modificationDate)" +
+ " VALUES(?, ?, ?, ?,?)");
statement.setLong(1, task.getNumber());
statement.setLong(2, date.getTime());
statement.setString(3, uuid);
statement.setLong(4, duration);
+ statement.setLong(5, new Date().getTime());
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't add task time", ex);
@@ -356,17 +361,23 @@
}
}
+ /**
+ * Ajoute une periode pour une tache
+ * @param time
+ * @param number
+ */
public void addTaskTime(TimerTime time, long number) {
PreparedStatement statement = null;
try {
statement = connection.prepareStatement("INSERT INTO " + TABLE_TIME +
- "(taskid, date, uuid, duration)" +
+ "(taskid, date, uuid, duration, modificationDate)" +
" VALUES(?, ?, ?, ?)");
statement.setLong(1, number);
statement.setLong(2, time.getCreationDate().getTime());
statement.setString(3, time.getTimeId());
statement.setLong(4, time.getTime());
+ statement.setLong(4, time.getModificationDate().getTime());
statement.executeUpdate();
} catch (SQLException ex) {
throw new StorageException("Can't add task time", ex);
@@ -404,7 +415,7 @@
time.setTimeId(rs.getString("uuid"));
time.setTime(rs.getLong("duration"));
time.setCreationDate(new java.util.Date(rs.getLong("date")));
-
+ time.setModificationDate(new java.util.Date(rs.getLong("modificationDate")));
times.add(time);
}
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-05-16 16:18:00 UTC (rev 2978)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TasksResource.java 2014-05-20 09:31:49 UTC (rev 2979)
@@ -12,6 +12,7 @@
import java.io.IOException;
import java.lang.reflect.Type;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
@@ -33,11 +34,24 @@
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());
+ }
+ });
}
/**
@@ -47,14 +61,26 @@
*/
@Get("json")
public Representation getTasks() {
- Gson gson = new Gson();
- List<TimerTask> timerTasks = storage.getTasks();
+ Long date = Long.valueOf(0);
+ try
+ {
+ date = Long.valueOf(getQuery().getValues("date"));
+ }
+ catch(Exception e)
+ {
+ date = Long.valueOf(0);
+ }
+
+ Gson gson = builder.create();
+ ArrayList<TimerTask> timerTasks = storage.getTasks(date);
+
//On ordonne les donnees, tache fille placee en début
int tabSize = timerTasks.size();
- for(int i =0; i <= tabSize;i++){
+
+ for (int i = 0; i < tabSize; i++) {
TimerTask task = timerTasks.get(i);
- if(task.getParent() == ""){
+ if (task.getParent() == "") {
timerTasks.add(task);
timerTasks.remove(i);
i--;
@@ -63,6 +89,7 @@
}
+
String json = gson.toJson(timerTasks);
return new StringRepresentation(json, MediaType.APPLICATION_JSON);
}
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-16 16:18:00 UTC (rev 2978)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-20 09:31:49 UTC (rev 2979)
@@ -118,12 +118,18 @@
*/
var getTasksFromServ = function(){
- serverTaskAccess.query(function (response) {
+ serverTaskAccess.query({date : $scope.access},function (response) {
+ //On change la date de dernier acces
+ $scope.access = new Date().getTime();
+ $scope.todo.lastAccess= $scope.access;
+ save();
+
angular.forEach(response, function (item) {
- //On verife si l'element n'est pas deja present
- if(!(item.taskId in $scope.data.tasks) && !(item.timeId in $scope.todo.stockedDeletedTask)){
+ //On verife si l'element n'est pas en cours de suppression
+ if(!(item.taskId in $scope.data.tasks)){
+ console.log( "Un element non present " + item.name + item.modificationDate);
var newTask = new Task( item.name, item.taskId, item.parent);
if(item.parent == "" ){
@@ -136,19 +142,28 @@
}
}else{
+ //TODO obruce ajout avec parent deja present
//Un noeud avec un parent est ajoute à l'arbre de son parent
$scope.data.tasks[newTask.taskId] = newTask;
-
+ save();
//Les temps sont recuperes du serveur
getTimesFromServer(newTask);
save();
}
+ }else{
+ console.log( "Un element deja present " + item.name + item.modificationDate);
+ var newTask = new Task( item.name, item.taskId, item.parent);
+ $scope.data.tasks[newTask.taskId] = newTask;
+ save();
+
}
});
+
+ console.log("Je suis dans le get tasks");
+
});
-
};
var getTimesFromServer = function(task){
@@ -158,7 +173,7 @@
serverTimeAccess.query({taskId : task.taskId}, function (response) {
angular.forEach(response, function (item) {
- if(!(item.timeId in $scope.data.times[task.taskId]) && !(item.timeId in $scope.todo.stockedDeletedTimes[task.taskId])){
+ if(!(existInObject($scope.data.times,item.timeId,task.taskId)) && !(existInObject($scope.todo.stockedDeletedTimes, item.timeId, task.taskId))){
//On cree le tasktime
taskTime = new TaskTime(task, item.timeId, item.creationDate, item.time);
$scope.data.times[task.taskId].push(taskTime);
@@ -169,6 +184,10 @@
}
+ var existInObject = function(object, item, pos){
+ return (object[pos]) && (item in object[pos]);
+ };
+
var pushChangesToServ= function(){
//On supprime de la base les taches sotckees pour suppression
@@ -293,9 +312,6 @@
pushChangesToServ();
getTasksFromServ();
-
- //On change la date de dernier acces
- $scope.access = new Date().getTime();
}
}
@@ -307,8 +323,17 @@
var newTask = new Task($scope.name);
$scope.data.tasks[newTask.taskId] = newTask;
- //On ajoute à la file de synchro
- $scope.todo.stockedNewTasks.push(newTask);
+ //On synchronise la tache creer
+ serverTaskAccess.create(angular.toJson(newTask),
+ function(){
+ console.log("persist task success" + newTask);
+ $scope.todo.stockedNewTasks.shift();
+ },
+ function(){
+ console.log("fail");
+ //On ajoute à la file de synchro
+ $scope.todo.stockedNewTasks.push(newTask);
+ });
$scope.name = "";
save();
@@ -327,8 +352,17 @@
var newTask = new Task("New task", undefined,task.taskId);
$scope.data.tasks[newTask.taskId] = newTask;
- //On ajoute à la file de synchro
- $scope.todo.stockedNewTasks.push(newTask);
+ //On synchronise la tache creer
+ serverTaskAccess.create(angular.toJson(newTask),
+ function(){
+ console.log("persist task success" + newTask);
+ $scope.todo.stockedNewTasks.shift();
+ },
+ function(){
+ console.log("fail");
+ //On ajoute à la file de synchro
+ $scope.todo.stockedNewTasks.push(newTask);
+ });
node.$$open = true;
save();
@@ -349,9 +383,18 @@
delete $scope.data.tasks[task.taskId];
delete $scope.data.times[task.taskId];
- $scope.todo.stockedDeletedTasks.push(task.taskId);
delete $scope.todo.stockedNewTimes[task.taskId];
+ serverTaskAccess.delete({taskId: task.taskId}, function(){
+ console.log("delete success" + task.taskId);
+ },
+ function(){
+ console.log("fail");
+ $scope.todo.stockedDeletedTasks.push(task.taskId);
+
+ });
+
+
var children = $scope.getChildren(task);
removeRecurse(children);
save();
@@ -488,6 +531,7 @@
*/
$scope.editTask = function(node, type) {
node.edit = type;
+
save();
};
@@ -497,6 +541,8 @@
*/
$scope.saveTask = function(node) {
node.edit = null;
+
+ node.task.setModificationDate();
$scope.todo.stockedEditedTasks.push(node.task);
save();
};
@@ -652,9 +698,7 @@
$scope.todo.stockedDeletedTimes[id].push($scope.data.times[id][item.index].timeId);
$scope.data.times[id].splice(item.index,1);
- //Todo obruce 15-5-2014 ajout de suppression du temps du serveur
-
save();
}
@@ -745,7 +789,7 @@
$scope.dateMaxPicker= new Date();
- $scope.alert = function(){
+ $scope.changeDayDate = function(){
var year = $scope.dateobj.date.getFullYear();
var month = $scope.dateobj.date.getMonth();
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-16 16:18:00 UTC (rev 2978)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-20 09:31:49 UTC (rev 2979)
@@ -60,7 +60,7 @@
* @returns {tdListData}
*/
var tdListData = function(){
- this.lastAccess = new Date().getTime();
+ this.lastAccess = 0;
// {Array of TaskID} la file de tache attendant la synchronisation avec le serveur
this.stockedDeletedTasks = [];
// {Array of Task} file de tache attendant la synchronisation avec le serveur
@@ -140,7 +140,6 @@
};
-
/**
* Toutes les donnees de la fenetre qui sont a stocker entre 2 sessions
* @returns {WebTimerData}
@@ -371,8 +370,7 @@
this.taskId = taskId;
}
- this.creationDate = Date.now();
- this.modificationDate = this.creationDate;
+ this.modificationDate = Date.now();
this.removed = 0;
if(parentTaskId == undefined){
Modified: branches/ng-jtimer/src/main/webapp/js/service.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/service.js 2014-05-16 16:18:00 UTC (rev 2978)
+++ branches/ng-jtimer/src/main/webapp/js/service.js 2014-05-20 09:31:49 UTC (rev 2979)
@@ -1,7 +1,7 @@
angular.module("serverAccessService", ["ngResource"])
.factory("serverTaskAccess", function ( $resource) {
// Encapsule l'acces au server
- return $resource("rest/tasks/:taskId",{},
+ return $resource("http://localhost:8080/rest/tasks/:taskId",{},
{
query : {method:'GET', isArray:true},
get : {method: 'GET',isArray: false},
@@ -18,7 +18,7 @@
angular.module("serverTimeService", ["ngResource"])
.factory("serverTimeAccess", function ( $resource) {
// Encapsule l'acces au server
- return $resource("rest/tasks/:taskId/time",{},
+ return $resource("http://localhost:8080/rest/tasks/:taskId/time",{},
{
query : {method:'GET', isArray:true},
get : {method: 'GET', isArray: false},
Modified: branches/ng-jtimer/src/main/webapp/partials/timeModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-16 16:18:00 UTC (rev 2978)
+++ branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-20 09:31:49 UTC (rev 2979)
@@ -39,7 +39,7 @@
<hr/>
<div class ="timepick">
<div ng-controller="datePickerCtrl" style="display:inline-block; min-height:290px;">
- <datepicker ng-model="dateobj.date" ng-change="alert()" min-date="minDate" max-date="dateMaxPicker" show-weeks="true" class="well well-sm"></datepicker>
+ <datepicker ng-model="dateobj.date" ng-change="changeDayDate()" min-date="minDate" max-date="dateMaxPicker" show-weeks="true" class="well well-sm"></datepicker>
</div>
<div ng-controller="radioTimeCtrl">
1
0
r2978 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage webapp/js webapp/partials
by obruce@users.chorem.org 16 May '14
by obruce@users.chorem.org 16 May '14
16 May '14
Author: obruce
Date: 2014-05-16 18:18:00 +0200 (Fri, 16 May 2014)
New Revision: 2978
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2978
Log:
UI: ajout de la ajout et de suppression des periodes
serveur : suppression des periodes
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/js/entities.js
branches/ng-jtimer/src/main/webapp/partials/tasks.html
branches/ng-jtimer/src/main/webapp/partials/timeModal.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-15 12:50:25 UTC (rev 2977)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-16 16:18:00 UTC (rev 2978)
@@ -60,8 +60,9 @@
}
protected Connection getConnection() throws SQLException {
- //TODO path a definir
- String url = "/tmp/jtimer/jtimer";
+ //TODO obruce 15-05-14 path a definir
+ //String url = "/tmp/jtimer/jtimer";
+ String url = "/home/olivia/Bureau/jtimer/jtimer";
if (log.isInfoEnabled()) {
log.info("Opening connection to database : " + url);
}
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-15 12:50:25 UTC (rev 2977)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-16 16:18:00 UTC (rev 2978)
@@ -9,7 +9,7 @@
$scope.todo = $localStorage.getTodo("todo");
// {Date} last update to server
- $scope.acces = moment().format("DD-MM-YYYY H:mm:ss");
+ $scope.access = $scope.todo.lastAccess;
// {TreeNode} l'arbre regenere automatiquement lorsque les donnees changent
$scope.tree;
@@ -60,6 +60,14 @@
};
/**
+ * Methode qui retourne la date de derniere mise a jour(serveur)
+ * @returns moment
+ */
+ $scope.getLastMajDate = function(){
+ return moment($scope.access).format("YYYY-MM-DD H:mm:ss");
+ };
+
+ /**
* Permet de faire des actions sur la tache selectionne en fonction
* des touches pressees
* @param {type} e
@@ -114,7 +122,7 @@
angular.forEach(response, function (item) {
//On verife si l'element n'est pas deja present
- if(!(item.taskId in $scope.data.tasks)){
+ if(!(item.taskId in $scope.data.tasks) && !(item.timeId in $scope.todo.stockedDeletedTask)){
var newTask = new Task( item.name, item.taskId, item.parent);
@@ -150,7 +158,7 @@
serverTimeAccess.query({taskId : task.taskId}, function (response) {
angular.forEach(response, function (item) {
- if(!(item.timeId in $scope.data.times[task.taskId])){
+ if(!(item.timeId in $scope.data.times[task.taskId]) && !(item.timeId in $scope.todo.stockedDeletedTimes[task.taskId])){
//On cree le tasktime
taskTime = new TaskTime(task, item.timeId, item.creationDate, item.time);
$scope.data.times[task.taskId].push(taskTime);
@@ -204,6 +212,7 @@
function(){
console.log("persist time success" + task);
$scope.todo.stockedNewTimes[task].shift();
+ console.log($scope.todo.stockedNewTimes[task]);
},
function(){
console.log("fail");
@@ -225,6 +234,21 @@
});
});
+ //On supprime de la base les taches sotckees pour suppression
+ angular.forEach($scope.todo.stockedDeletedTimes, function(times,task){
+ angular.forEach(times, function(time){
+ serverTimeAccess.delete({taskId: task}, angular.toJson(time),
+ function(){
+ console.log("update time success" + task);
+ $scope.todo.stockedDeletedTimes[task].shift();
+ },
+ function(){
+ console.log("fail");
+ });
+ });
+ });
+
+
save();
}
@@ -256,7 +280,7 @@
var timer = function() {
$interval(function() {
actionToServ();
- }, 30000); //TODO: for now 30s but for real put at least 2h: 200000000
+ }, 30000); //TODO: obruce 05-05-14 for now 30s but for real put at least 2h: 200000000
};
timer();
@@ -271,7 +295,7 @@
getTasksFromServ();
//On change la date de dernier acces
- $scope.acces = moment().format("DD-MM-YYYY H:mm:ss a");
+ $scope.access = new Date().getTime();
}
}
@@ -595,17 +619,45 @@
modalInstance.result.then(function (item) {
if(item.index != -1){
- //On met la valeur à jour
- $scope.data.times[id][item.index].changeCreationDate(item.creationDate);
- $scope.data.times[id][item.index].changeDuration(item.time);
+ if(item.action=='Modification'){
+ //On met la valeur à jour
+ $scope.data.times[id][item.index].changeCreationDate(item.creationDate);
+ $scope.data.times[id][item.index].changeDuration(item.time);
- //init
- if(!$scope.todo.stockedEditedTimes[id]){$scope.todo.stockedEditedTimes[id]=[]; }
+ //init
+ if(!$scope.todo.stockedEditedTimes[id]){$scope.todo.stockedEditedTimes[id]=[]; }
- //On ajoute dans la tdList
- $scope.todo.stockedEditedTimes[id].push($scope.data.times[id][item.index]);
+ //On ajoute dans la tdList
+ $scope.todo.stockedEditedTimes[id].push($scope.data.times[id][item.index]);
- save();
+ save();
+ }
+
+ if(item.action=='Ajout'){
+ //init
+
+ if(!$scope.data.times[id]){$scope.data.times[id]= [];};
+ if(!$scope.todo.stockedNewTimes[id]){$scope.todo.stockedNewTimes[id] = []};
+
+ //on cree le temps
+ var res = new TaskTime(node.task,undefined,item.creationDate,item.time);
+ $scope.data.times[id].push(res);
+ $scope.todo.stockedNewTimes[id].push(res);
+ save();
+ }
+
+ if(item.action == 'Suppression'){
+
+ if(!$scope.todo.stockedDeletedTimes[id]){$scope.todo.stockedDeletedTimes[id] = []};
+ $scope.todo.stockedDeletedTimes[id].push($scope.data.times[id][item.index].timeId);
+
+ $scope.data.times[id].splice(item.index,1);
+ //Todo obruce 15-5-2014 ajout de suppression du temps du serveur
+
+
+ save();
+ }
+
}
});
}
@@ -641,17 +693,22 @@
// Les temps de la tache
$scope.times = taskTimes;
+ $scope.dateobj={aTime : new Date(), date : new Date(),};
- //Le time selectionne
- $scope.activTime = null;
-
-
//L'objet retourner
$scope.obj={};
- $scope.obj.creationDate=-1;
- $scope.obj.time=-1;
+ $scope.obj.creationDate=new Date().getTime();
+ $scope.obj.time=0;
$scope.obj.index = -1;
+ $scope.obj.action = '';
+ $scope.activTime = null;
+
+ //Choix d'action
+ $scope.periodAction1 =function(){$scope.obj.action = "Ajout"; $scope.act};
+ $scope.periodAction2 = function(){$scope.obj.action = "Modification";};
+ $scope.periodAction3 = function(){$scope.obj.action = "Suppression";};
+
//Pour l'affichage
$scope.getStartTime = function(item){return moment(item.creationDate).format("DD-MM-YYYY H:mm:ss");}
$scope.getStopTime = function(item){return item.time;}
@@ -662,14 +719,15 @@
//selectionne un element dans le dropdown
$scope.select = function(item, ind){
- $scope.activTime = item;
//On intialise l'objet a envoyer
$scope.obj.index = ind;
$scope.obj.creationDate=item.creationDate;
$scope.obj.time=item.time;
- $scope.aTime = item.creationDate;
+ $scope.activTime = item;
+
+ $scope.dateobj.aTime = new Date(item.creationDate);
}
// Methode a la fermeture avec ok
@@ -683,6 +741,28 @@
};
};
+var datePickerCtrl = function($scope){
+
+ $scope.dateMaxPicker= new Date();
+
+ $scope.alert = function(){
+
+ var year = $scope.dateobj.date.getFullYear();
+ var month = $scope.dateobj.date.getMonth();
+ var date = $scope.dateobj.date.getDate();
+
+ var uneDate = new Date($scope.obj.creationDate);
+ uneDate.setFullYear(year,month,date);
+
+ $scope.obj.creationDate = uneDate.getTime();
+
+ $scope.dateobj.aTime = uneDate;
+ };
+}
+
+
+
+
var radioTimeCtrl = function ($scope){
//Activated button radio
@@ -692,38 +772,40 @@
$scope.hstep = 1;
$scope.mstep = 1;
- //La date max
- var maxDate = new Date($scope.activTime.creationDate);
- maxDate.setHours(23,59,59,999);
+ $scope.obj.index= null;
-
/*
* Méthode déclancher quand l'heure change dans le timepicker
* Change l'objet du controller principal
*/
$scope.changeModel = function(){
+ //La date max
+ var maxDate = new Date($scope.dateobj.aTime);
+ maxDate.setHours(23,59,59,999);
+
//Si On modifie sur la date de debut
if(($scope.radioModel || 'null') == 'Left'){
+ $scope.obj.creationDate = $scope.dateobj.aTime.getTime();
- $scope.obj.creationDate = $scope.aTime.getTime();
-
//si crea+temps superieur à 23:59
if(($scope.obj.creationDate+$scope.obj.time) > maxDate.getTime()){
- $scope.aTime=maxDate.getTime()-$scope.obj.time;
+ $scope.dateobj.aTime=new Date(maxDate.getTime()-$scope.obj.time);
$scope.obj.creationDate = maxDate.getTime()-$scope.obj.time;
}
}else{//On modifie la date de fin
-
- if($scope.aTime.getTime() > $scope.activTime.creationDate){
- //Si l'heure de fin est superieur a l'heure de depart
- var duree = $scope.aTime.getTime() - $scope.obj.creationDate ;
+ //Si l'heure de fin est superieur a l'heure de depart
+ if($scope.dateobj.aTime.getTime() > $scope.obj.creationDate){
+ var duree = $scope.dateobj.aTime.getTime() - $scope.obj.creationDate ;
$scope.obj.time = duree;
}else{
//Empeche de depasser 23:59
- $scope.aTime = maxDate;
+ $scope.dateobj.aTime = maxDate;
$scope.obj.time = maxDate.getTime() - $scope.obj.creationDate;
+ console.log($scope.obj.time);
+ console.log(maxDate);
+
}
}
}
@@ -731,9 +813,9 @@
//Change l'heure dans le timePicker selon debut/fin
$scope.changeFonc=function(){
if(($scope.radioModel || 'null') == 'Left'){
- $scope.aTime = $scope.obj.creationDate;
+ $scope.dateobj.aTime = new Date($scope.obj.creationDate);
}else{
- $scope.aTime = $scope.obj.creationDate + $scope.obj.time;
+ $scope.dateobj.aTime = new Date($scope.obj.creationDate + $scope.obj.time);
}
}
};
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-15 12:50:25 UTC (rev 2977)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-16 16:18:00 UTC (rev 2978)
@@ -60,6 +60,7 @@
* @returns {tdListData}
*/
var tdListData = function(){
+ this.lastAccess = new Date().getTime();
// {Array of TaskID} la file de tache attendant la synchronisation avec le serveur
this.stockedDeletedTasks = [];
// {Array of Task} file de tache attendant la synchronisation avec le serveur
@@ -68,7 +69,8 @@
// {key: taskId, value: Array of TaskTime} la file de temps attendant la synchronisation avec le serveur
this.stockedNewTimes = {};
this.stockedEditedTimes = {};
-
+ // {Array of TaskID} la file de temps attendant la synchronisation avec le serveur
+ this.stockedDeletedTimes = {};
};
@@ -93,6 +95,8 @@
}
if (json) {
+ this.lastAccess = json.lastAccess;
+
angular.forEach(json.stockedDeletedTasks, function (t) {
this.stockedDeletedTasks.push(t);
}, this);
@@ -122,6 +126,14 @@
this.stockedEditedTimes[k].push(t);
}, this);
}, this);
+
+ angular.forEach(json.stockedDeletedTimes, function (times, k) {
+ this.stockedDeletedTimes[k] = [];
+ angular.forEach(times, function (t) {
+ t = jQuery.extend(new TaskTime(), t);
+ this.stockedDeletedTimes[k].push(t);
+ }, this);
+ }, this);
}
return this;
@@ -328,13 +340,6 @@
return this;
};
-/**
- * Determine si le global time est vide
- * @returns {GlobalTime} this
- */
-GlobalTime.prototype.estVide = function() {
- return (this.global) == 0;
-};
/**
* Ajoute les temps d'un tableau de TaskTime au temps global et a today si
Modified: branches/ng-jtimer/src/main/webapp/partials/tasks.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-15 12:50:25 UTC (rev 2977)
+++ branches/ng-jtimer/src/main/webapp/partials/tasks.html 2014-05-16 16:18:00 UTC (rev 2978)
@@ -31,7 +31,7 @@
<span class="left">{{currentDate()}}</span>
<span class="center"><i class="fa fa-html5"></i> <a href="#">WebTimer</a></span>
<!--<span class="right">{{tree.getTime().today |time}} | {{tree.getTime().global | time}}</span>-->
- <span class="right">Dernier accès serveur: {{acces}}</span>
+ <span class="right">Dernière mise à jour: {{getLastMajDate()}}</span>
</div>
<div>
@@ -78,7 +78,10 @@
<i class="glyphicon glyphicon-minus"></i>
</a>
- <a class="btn btn-default btn-xs" href="" ng-click="popup($node)" ng-show="!$node.getTime().estVide()"><i class="glyphicon glyphicon-pencil" ></i></a>
+ <a class="btn btn-default btn-xs" href="" ng-click="popup($node)"
+ ng-show="!$node.task.isRoot() ">
+ <i class="glyphicon glyphicon-pencil" ></i>
+ </a>
Modified: branches/ng-jtimer/src/main/webapp/partials/timeModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-15 12:50:25 UTC (rev 2977)
+++ branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-16 16:18:00 UTC (rev 2978)
@@ -1,26 +1,71 @@
<div>
- <h3> Modifier la tâche.</h3>
+ <h3> Edition de la tâche.</h3>
- <div class="btn-group" dropdown is-open="status.isopen" ng-show="activTime == null">
+ <div class="btn-group" dropdown is-open="status.isopen" ng-show="obj.action==''">
<button type="button" class="btn btn-primary dropdown-toggle">
+ Action à faire sur la tâche: <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu" role="menu">
+ <li><a href="#" ng-click="periodAction1()">Ajouter une periode</a></li>
+ <li><a href="#" ng-click="periodAction2()">Modifier une periode</a></li>
+ <li><a href="#" ng-click="periodAction3()">Supprimer une periode</a></li>
+ </ul>
+
+ </div>
+
+ <h4 ng-show="obj.action != ''"> {{obj.action}} d'une période</h4>
+
+ <!-- Div dropdown choix de periode -->
+ <div class="btn-group" dropdown is-open="status.isopen" ng-if="!activTime && obj.action !='' && obj.action !='Ajout'">
+ <button type="button" class="btn btn-primary dropdown-toggle">
Les périodes pour la tâche sélectionnée : <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li ng-repeat="(index,item) in times" >
- <span ng-click="select(item, index)">
+ <a href="#" ng-click="select(item, index)">
Début : {{getStartTime(item)}} - Durée : {{getStopTime(item)| time}}
- </span>
+ </a>
</li>
</ul>
</div>
- <div ng-if = "activTime != null">
+ <!-- div ajout d'une periode -->
+ <div ng-if = " obj.action=='Ajout'">
+
<hr/>
- <h4>Période : Début : {{getStartTime(activTime)}} - Durée : {{getStopTime(activTime)| time}}</h4>
+ <div class ="timepick">
+ <div ng-controller="datePickerCtrl" style="display:inline-block; min-height:290px;">
+ <datepicker ng-model="dateobj.date" ng-change="alert()" min-date="minDate" max-date="dateMaxPicker" show-weeks="true" class="well well-sm"></datepicker>
+ </div>
+
+ <div ng-controller="radioTimeCtrl">
+ <div>
+ <div class="btn-group">
+ <label class="btn btn-primary" ng-model="radioModel" ng-change="changeFonc()" btn-radio="'Left'">Début de période </label>
+ <label class="btn btn-primary" ng-model="radioModel" ng-change="changeFonc()" btn-radio="'Right'">Fin de période </label>
+ </div>
+ </div>
+ <div class="timepick">
+ <timepicker
+ ng-model="dateobj.aTime" ng-change="changeModel()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian">
+ </timepicker>
+ </div>
+
+ </div>
+ </div>
+ <alert type="info" >Début : {{getStartObjTime()}} - Fin : {{getStopObjTime()}} - Duree : {{getObjDuration() | time}} </alert>
+ </div>
+
+
+
+ <!-- div modification d'une periode -->
+ <div ng-if = "activTime && obj.action=='Modification'">
+ <hr/>
+
<alert type="danger" >Choisir une période :</alert>
<div class = "timepick" ng-controller="radioTimeCtrl">
@@ -38,7 +83,7 @@
<div class = "timepick">
<timepicker
- ng-model="aTime" ng-change="changeModel()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian">
+ ng-model="dateobj.aTime" ng-change="changeModel()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian">
</timepicker>
</div>
<br/>
@@ -50,6 +95,11 @@
</div>
+ <!-- div suppression d'une periode -->
+ <div ng-if = "activTime && obj.action=='Suppression'">
+ <alert type="danger" > La période suivante va être supprimée :<br/>
+ Début : {{getStartObjTime()}} - Fin : {{getStopObjTime()}} - Duree : {{getObjDuration() | time}} </alert>
+ </div>
<div class="modal-footer">
1
0
r2977 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/web webapp/js webapp/partials
by obruce@users.chorem.org 15 May '14
by obruce@users.chorem.org 15 May '14
15 May '14
Author: obruce
Date: 2014-05-15 14:50:25 +0200 (Thu, 15 May 2014)
New Revision: 2977
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2977
Log:
UI: ajout de la modification des periodes, changement todolist en entities
enregistrement todolist dans le localstorage
serveur : ajout modification des periodes
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
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/timeModal.html
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-14 16:22:39 UTC (rev 2976)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-15 12:50:25 UTC (rev 2977)
@@ -1,23 +1,15 @@
package org.chorem.jtimer.storage;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TimerTime;
-import org.chorem.jtimer.web.TasksResource;
+import java.sql.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* Implementation du stockage des taches en base de données basée sur h2.
*
@@ -32,8 +24,6 @@
*/
public class Storage {
- private final static Logger LOGGER = Logger.getLogger(TasksResource.class.getName());
-
private static final Log log = LogFactory.getLog(Storage.class);
protected static final String TABLE_TASK = "task";
@@ -70,8 +60,8 @@
}
protected Connection getConnection() throws SQLException {
-
- String url = "/home/olivia/Bureau/jtimer/jtimer";
+ //TODO path a definir
+ String url = "/tmp/jtimer/jtimer";
if (log.isInfoEnabled()) {
log.info("Opening connection to database : " + url);
}
@@ -305,6 +295,28 @@
}
}
+ public void modifyTime(TimerTime t) {
+ PreparedStatement statement = null;
+ try {
+ statement = connection.prepareStatement("UPDATE " +
+ TABLE_TIME + " SET date=?, duration=?" +
+ " WHERE uuid = ?");
+ statement.setLong(1, t.getCreationDate().getTime());
+ statement.setLong(2, t.getTime());
+ statement.setString(3, t.getTimeId() );
+ statement.executeUpdate();
+ } catch (SQLException ex) {
+ throw new StorageException("Can't modify time", ex);
+ } finally {
+ closeStatement(statement);
+ }
+ }
+
+ /**
+ * Returns task number with ID
+ * @param id
+ * @return
+ */
public long getTaskNumber(String id) {
PreparedStatement statement = null;
long result= 0;
@@ -352,8 +364,6 @@
statement.setLong(1, number);
statement.setLong(2, time.getCreationDate().getTime());
-
- LOGGER.log(Level.WARNING, "Storage add times datetime " +time.getCreationDate().getTime());
statement.setString(3, time.getTimeId());
statement.setLong(4, time.getTime());
statement.executeUpdate();
@@ -460,4 +470,5 @@
}
}
+
}
\ No newline at end of file
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-05-14 16:22:39 UTC (rev 2976)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-05-15 12:50:25 UTC (rev 2977)
@@ -1,7 +1,6 @@
package org.chorem.jtimer.web;
import com.google.gson.*;
-import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TimerTime;
import org.chorem.jtimer.storage.Storage;
import org.restlet.data.MediaType;
@@ -13,8 +12,6 @@
import java.lang.reflect.Type;
import java.util.Date;
import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
public class TimeResource extends ServerResource {
@@ -96,5 +93,18 @@
storage.addTaskTime(t,number);
}
+ /**
+ * Methode qui met à jour une tache
+ * suite d'une requête de type PUT
+ */
+ @Put("json")
+ public void updateTime(Representation representation) throws IOException{
+ Gson gson = builder.create();
+ String repr1 = representation.getText();
+ TimerTime t = gson.fromJson(repr1, TimerTime.class);
+
+ storage.modifyTime(t);
+ }
+
}
Modified: branches/ng-jtimer/src/main/webapp/js/app.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/app.js 2014-05-14 16:22:39 UTC (rev 2976)
+++ branches/ng-jtimer/src/main/webapp/js/app.js 2014-05-15 12:50:25 UTC (rev 2977)
@@ -272,8 +272,22 @@
var item = window.localStorage.getItem(key);
var result = new WebTimerData();
result.fromJson(item);
-
+
return result;
+ },
+ setTodo: function(key, value) {
+ key = webtimerPrefix + key;
+ // add version, to check version during read (get)
+ var item = value.toJson();
+ window.localStorage.setItem(key, item);
+ },
+ getTodo: function(key) {
+ key = webtimerPrefix + key;
+ var item = window.localStorage.getItem(key);
+ var result = new tdListData();
+ result.fromJson(item);
+
+ return result;
}
};
})
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-14 16:22:39 UTC (rev 2976)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-15 12:50:25 UTC (rev 2977)
@@ -5,6 +5,9 @@
// {WebTimerData} toutes les donnees
$scope.data = $localStorage.get("data");
+ //{tdListData} toutes les donnees non envoyees
+ $scope.todo = $localStorage.getTodo("todo");
+
// {Date} last update to server
$scope.acces = moment().format("DD-MM-YYYY H:mm:ss");
@@ -43,16 +46,6 @@
// {boolean} boolean qui indique si une inactivite a ete detectee
$scope.webSocketClientIdle = false;
-
- // {Array of TaskID} la file de tache attendant la synchronisation avec le serveur
- var stockedDeletedTasks = [];
- // {Array of Task}
- var stockedNewTasks = [];
- var stockedEditedTasks = [];
- // {key: taskId, value: Array of TaskTime} la file de temps des taches attendant la synchronisation avec le serveur
- var stockedNewTimes = {};
- var stockedEditedTimes = {};
-
/**
* Met a jour la tache selectionne, si la tache selectionnee est la courante
* alors on met la selection a null
@@ -109,6 +102,7 @@
*/
var save = function() {
$localStorage.set("data", $scope.data);
+ $localStorage.setTodo("todo", $scope.todo);
};
/**
@@ -168,34 +162,35 @@
}
var pushChangesToServ= function(){
+
//On supprime de la base les taches sotckees pour suppression
- angular.forEach(stockedDeletedTasks, function(task){
+ angular.forEach($scope.todo.stockedDeletedTasks, function(task){
serverTaskAccess.delete({taskId: task},
function(){
console.log("delete success" + task);
- stockedDeletedTasks.shift();
+ $scope.todo.stockedDeletedTasks.shift();
},
function(){
console.log("fail");
});
});
//On ajoute au serveur les taches stockees pour l'ajout
- angular.forEach(stockedNewTasks, function(task){
+ angular.forEach($scope.todo.stockedNewTasks, function(task){
serverTaskAccess.create(angular.toJson(task),
function(){
console.log("persist task success" + task);
- stockedNewTasks.shift();
+ $scope.todo.stockedNewTasks.shift();
},
function(){
console.log("fail");
});
});
//On ajoute au serveur les taches stockees pour l'ajout
- angular.forEach(stockedEditedTasks, function(task){
+ angular.forEach($scope.todo.stockedEditedTasks, function(task){
serverTaskAccess.update(angular.toJson(task),
function(){
console.log("update task success" + task);
- stockedEditedTasks.shift();
+ $scope.todo.stockedEditedTasks.shift();
},
function(){
console.log("fail");
@@ -203,18 +198,34 @@
});
//On ajoute les nouveaux temps au serveur
- angular.forEach(stockedNewTimes, function(times,task){
+ angular.forEach($scope.todo.stockedNewTimes, function(times,task){
angular.forEach(times, function(time){
serverTimeAccess.create({taskId: task} , angular.toJson(time),
function(){
console.log("persist time success" + task);
- stockedNewTimes[task].shift();
+ $scope.todo.stockedNewTimes[task].shift();
},
function(){
console.log("fail");
});
});
});
+
+ //On update les temps sur le serveur
+ angular.forEach($scope.todo.stockedEditedTimes, function(times,task){
+ angular.forEach(times, function(time){
+ serverTimeAccess.update({taskId: task}, angular.toJson(time),
+ function(){
+ console.log("update time success" + task);
+ $scope.todo.stockedEditedTimes[task].shift();
+ },
+ function(){
+ console.log("fail");
+ });
+ });
+ });
+
+ save();
}
@@ -273,7 +284,7 @@
$scope.data.tasks[newTask.taskId] = newTask;
//On ajoute à la file de synchro
- stockedNewTasks.push(newTask);
+ $scope.todo.stockedNewTasks.push(newTask);
$scope.name = "";
save();
@@ -293,7 +304,7 @@
$scope.data.tasks[newTask.taskId] = newTask;
//On ajoute à la file de synchro
- stockedNewTasks.push(newTask);
+ $scope.todo.stockedNewTasks.push(newTask);
node.$$open = true;
save();
@@ -314,13 +325,14 @@
delete $scope.data.tasks[task.taskId];
delete $scope.data.times[task.taskId];
- stockedDeletedTasks.push(task.taskId);
- delete stockedNewTimes[task.taskId];
+ $scope.todo.stockedDeletedTasks.push(task.taskId);
+ delete $scope.todo.stockedNewTimes[task.taskId];
var children = $scope.getChildren(task);
removeRecurse(children);
+ save();
});
- save();
+
};
// mark all task as removed
removeRecurse([node.task]);
@@ -461,7 +473,7 @@
*/
$scope.saveTask = function(node) {
node.edit = null;
- stockedEditedTasks.push(node.task);
+ $scope.todo.stockedEditedTasks.push(node.task);
save();
};
@@ -478,8 +490,8 @@
var taskTime = $scope.getRecentTaskTime($scope.currentTask);
taskTime.addTime(now - $scope.currentTaskDate);
- if(!stockedNewTimes[task.taskId]){stockedNewTimes[task.taskId]=[];}
- stockedNewTimes[task.taskId].push(taskTime);
+ if(!$scope.todo.stockedNewTimes[task.taskId]){$scope.todo.stockedNewTimes[task.taskId]=[];}
+ $scope.todo.stockedNewTimes[task.taskId].push(taskTime);
}
//si ce n'est la la tache courante actuel
if ($scope.currentTask !== task) {
@@ -583,15 +595,17 @@
modalInstance.result.then(function (item) {
if(item.index != -1){
- //changement
+ //On met la valeur à jour
$scope.data.times[id][item.index].changeCreationDate(item.creationDate);
$scope.data.times[id][item.index].changeDuration(item.time);
//init
- if(!stockedEditedTimes[id]){stockedEditedTimes[id]=[]; }
+ if(!$scope.todo.stockedEditedTimes[id]){$scope.todo.stockedEditedTimes[id]=[]; }
- stockedEditedTimes[id].push($scope.data.times[id][item.index]);
- console.log(stockedEditedTimes);
+ //On ajoute dans la tdList
+ $scope.todo.stockedEditedTimes[id].push($scope.data.times[id][item.index]);
+
+ save();
}
});
}
@@ -644,6 +658,7 @@
$scope.getStartObjTime = function(){return moment($scope.obj.creationDate).format("DD-MM-YYYY H:mm:ss");}
$scope.getStopObjTime = function(){return moment($scope.obj.creationDate + $scope.obj.time).format("DD-MM-YYYY H:mm:ss");}
+ $scope.getObjDuration = function(){return $scope.obj.time;}
//selectionne un element dans le dropdown
$scope.select = function(item, ind){
@@ -654,14 +669,15 @@
$scope.obj.creationDate=item.creationDate;
$scope.obj.time=item.time;
- $scope.aTime = new Date(item.creationDate);
+ $scope.aTime = item.creationDate;
}
- // Methode a la fermeture
+ // Methode a la fermeture avec ok
$scope.ok = function () {
$modalInstance.close($scope.obj);
};
+ //Methode a la fermeture avec cancel
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
@@ -671,38 +687,53 @@
//Activated button radio
$scope.radioModel = 'Left';
- $scope.aTime = new Date($scope.activTime.creationDate);
//Le pas des heures et minutes
$scope.hstep = 1;
$scope.mstep = 1;
+ //La date max
+ var maxDate = new Date($scope.activTime.creationDate);
+ maxDate.setHours(23,59,59,999);
+
+
+ /*
+ * Méthode déclancher quand l'heure change dans le timepicker
+ * Change l'objet du controller principal
+ */
$scope.changeModel = function(){
- //TODO obruce : ici il faut mettre des contraintes pour pas depasser 24h
- //TODO pas depasser dans l'autre sens
+
+ //Si On modifie sur la date de debut
if(($scope.radioModel || 'null') == 'Left'){
$scope.obj.creationDate = $scope.aTime.getTime();
- console.log($scope.obj.creationDate);
- }else{
+ //si crea+temps superieur à 23:59
+ if(($scope.obj.creationDate+$scope.obj.time) > maxDate.getTime()){
+ $scope.aTime=maxDate.getTime()-$scope.obj.time;
+ $scope.obj.creationDate = maxDate.getTime()-$scope.obj.time;
+ }
+
+ }else{//On modifie la date de fin
+
if($scope.aTime.getTime() > $scope.activTime.creationDate){
- var duree = $scope.aTime.getTime() - $scope.activTime.creationDate ;
+ //Si l'heure de fin est superieur a l'heure de depart
+ var duree = $scope.aTime.getTime() - $scope.obj.creationDate ;
$scope.obj.time = duree;
}else{
- $scope.aTime = new Date($scope.obj.creationDate );
- duree = 0;
+ //Empeche de depasser 23:59
+ $scope.aTime = maxDate;
+ $scope.obj.time = maxDate.getTime() - $scope.obj.creationDate;
}
- console.log($scope.obj.time);
}
}
//Change l'heure dans le timePicker selon debut/fin
$scope.changeFonc=function(){
if(($scope.radioModel || 'null') == 'Left'){
- $scope.aTime = new Date($scope.obj.creationDate);
+ $scope.aTime = $scope.obj.creationDate;
}else{
- $scope.aTime = new Date($scope.obj.creationDate + $scope.activTime.time);
+ $scope.aTime = $scope.obj.creationDate + $scope.obj.time;
}
}
};
Modified: branches/ng-jtimer/src/main/webapp/js/entities.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-14 16:22:39 UTC (rev 2976)
+++ branches/ng-jtimer/src/main/webapp/js/entities.js 2014-05-15 12:50:25 UTC (rev 2977)
@@ -55,9 +55,82 @@
}
};
+/**
+ * Toutes les donnees qui demandent d'etre traitees par le serveur
+ * @returns {tdListData}
+ */
+var tdListData = function(){
+ // {Array of TaskID} la file de tache attendant la synchronisation avec le serveur
+ this.stockedDeletedTasks = [];
+ // {Array of Task} file de tache attendant la synchronisation avec le serveur
+ this.stockedNewTasks = [];
+ this.stockedEditedTasks = [];
+ // {key: taskId, value: Array of TaskTime} la file de temps attendant la synchronisation avec le serveur
+ this.stockedNewTimes = {};
+ this.stockedEditedTimes = {};
+};
+
+
/**
- * Toutes les donnees qui sont a stocker entre 2 sessions
+ * Converti l'objet tdListData en Json
+ * @returns {JSON}
+ */
+tdListData.prototype.toJson = function() {
+ var result = angular.toJson(this);
+ return result;
+};
+
+/**
+ * Charge des donnees au format JSON les convertit dans le bon type d'objet,
+ * fait la migration des data si necessaire
+ * @param {JSON or JsonString} json
+ * @returns {tdListData} retourne lui meme
+ */
+tdListData.prototype.fromJson = function(json) {
+ if (angular.isString(json)) {
+ json = angular.fromJson(json);
+ }
+ if (json) {
+
+ angular.forEach(json.stockedDeletedTasks, function (t) {
+ this.stockedDeletedTasks.push(t);
+ }, this);
+
+ angular.forEach(json.stockedNewTasks, function (t) {
+ t = jQuery.extend(new Task(), t);
+ this.stockedNewTasks.push(t);
+ }, this);
+
+ angular.forEach(json.stockedEditedTasks, function (t) {
+ t = jQuery.extend(new Task(), t);
+ this.stockedEditedTasks.push(t);
+ }, this);
+
+ angular.forEach(json.stockedNewTimes, function (times, k) {
+ this.stockedNewTimes[k] = [];
+ angular.forEach(times, function (t) {
+ t = jQuery.extend(new TaskTime(), t);
+ this.stockedNewTimes[k].push(t);
+ }, this);
+ }, this);
+
+ angular.forEach(json.stockedEditedTimes, function (times, k) {
+ this.stockedEditedTimes[k] = [];
+ angular.forEach(times, function (t) {
+ t = jQuery.extend(new TaskTime(), t);
+ this.stockedEditedTimes[k].push(t);
+ }, this);
+ }, this);
+ }
+
+ return this;
+};
+
+
+
+/**
+ * Toutes les donnees de la fenetre qui sont a stocker entre 2 sessions
* @returns {WebTimerData}
*/
var WebTimerData = function() {
Modified: branches/ng-jtimer/src/main/webapp/partials/timeModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-14 16:22:39 UTC (rev 2976)
+++ branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-15 12:50:25 UTC (rev 2977)
@@ -46,7 +46,7 @@
</div>
- <alert type="info" >Début : {{getStartObjTime()}} - Fin : {{getStopObjTime(activTime)}}</alert>
+ <alert type="info" >Début : {{getStartObjTime()}} - Fin : {{getStopObjTime()}} - Duree : {{getObjDuration() | time}} </alert>
</div>
1
0
r2976 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/web webapp webapp/css webapp/js webapp/partials
by obruce@users.chorem.org 14 May '14
by obruce@users.chorem.org 14 May '14
14 May '14
Author: obruce
Date: 2014-05-14 18:22:39 +0200 (Wed, 14 May 2014)
New Revision: 2976
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2976
Log:
controller: modification timeModalCtrl.
serveur : correction date
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
branches/ng-jtimer/src/main/webapp/css/app.css
branches/ng-jtimer/src/main/webapp/js/controllers.js
branches/ng-jtimer/src/main/webapp/partials/timeModal.html
branches/ng-jtimer/src/main/webapp/webtimer.appcache
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-14 08:27:44 UTC (rev 2975)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-14 16:22:39 UTC (rev 2976)
@@ -71,7 +71,7 @@
protected Connection getConnection() throws SQLException {
- String url = "/tmp/jtimer/jtimer";
+ String url = "/home/olivia/Bureau/jtimer/jtimer";
if (log.isInfoEnabled()) {
log.info("Opening connection to database : " + url);
}
@@ -332,7 +332,7 @@
" VALUES(?, ?, ?, ?)");
statement.setLong(1, task.getNumber());
- statement.setLong(2, date.getTime()); //TODO
+ statement.setLong(2, date.getTime());
statement.setString(3, uuid);
statement.setLong(4, duration);
statement.executeUpdate();
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-05-14 08:27:44 UTC (rev 2975)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-05-14 16:22:39 UTC (rev 2976)
@@ -18,6 +18,7 @@
public class TimeResource extends ServerResource {
+ private GsonBuilder builder;
protected Storage storage;
/**
@@ -26,6 +27,27 @@
*/
@Override
protected void doInit() throws ResourceException {
+
+ //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());
+ }
+ });
+
+
storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
}
@@ -40,7 +62,7 @@
String taskId = (String)getRequest().getAttributes().get("taskId");
List<TimerTime> timerTimes = storage.getTimes(taskId);
- Gson gson = new Gson();
+ Gson gson = builder.create();
String json = gson.toJson(timerTimes);
return new StringRepresentation(json, MediaType.APPLICATION_JSON);
@@ -66,7 +88,7 @@
String timeId = (String)getRequest().getAttributes().get("taskId");
long number = storage.getTaskNumber(timeId);
- Gson gson = new Gson();
+ Gson gson = builder.create();
String repr1 = representation.getText();
TimerTime t = gson.fromJson(repr1, TimerTime.class);
Modified: branches/ng-jtimer/src/main/webapp/css/app.css
===================================================================
--- branches/ng-jtimer/src/main/webapp/css/app.css 2014-05-14 08:27:44 UTC (rev 2975)
+++ branches/ng-jtimer/src/main/webapp/css/app.css 2014-05-14 16:22:39 UTC (rev 2976)
@@ -255,4 +255,9 @@
.idleModal {
width: 400px;
-}
\ No newline at end of file
+}
+
+.timepick{
+ width : 50%;
+ margin : auto;
+}
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-14 08:27:44 UTC (rev 2975)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-14 16:22:39 UTC (rev 2976)
@@ -51,6 +51,7 @@
var stockedEditedTasks = [];
// {key: taskId, value: Array of TaskTime} la file de temps des taches attendant la synchronisation avec le serveur
var stockedNewTimes = {};
+ var stockedEditedTimes = {};
/**
* Met a jour la tache selectionne, si la tache selectionnee est la courante
@@ -462,7 +463,6 @@
node.edit = null;
stockedEditedTasks.push(node.task);
save();
- console.log(stockedEditedTasks);
};
/**
@@ -566,27 +566,38 @@
};
$scope.popup = function (node){
+ //Task identifier
+ var id = node.task.taskId;
var modalInstance = $modal.open({
templateUrl: 'partials/timeModal.html',
controller: ModalInstanceCtrl,
resolve: {
- taskTimes : function(){
- return $scope.data.times[node.task.taskId];
- }
+ taskTimes : function(){
+ return $scope.data.times[id];
+ }
}
+
});
modalInstance.result.then(function (item) {
- console.log(item);
- }, function () {
- //Dismiss
+
+ if(item.index != -1){
+ //changement
+ $scope.data.times[id][item.index].changeCreationDate(item.creationDate);
+ $scope.data.times[id][item.index].changeDuration(item.time);
+
+ //init
+ if(!stockedEditedTimes[id]){stockedEditedTimes[id]=[]; }
+
+ stockedEditedTimes[id].push($scope.data.times[id][item.index]);
+ console.log(stockedEditedTimes);
+ }
});
}
//force the first server connection
actionToServ();
-
// force the first tree creation
$scope.createTree();
@@ -613,55 +624,42 @@
var ModalInstanceCtrl = function ($scope, $modalInstance, taskTimes) {
+
// Les temps de la tache
$scope.times = taskTimes;
- //La tache courante
- $scope.currentTask = null;
+ //Le time selectionne
+ $scope.activTime = null;
- //Le pas des heures et minutes
- $scope.hstep = 1;
- $scope.mstep = 1;
- $scope.aTime = new Date();
- //La date a modifier
- $scope.modifDate= "début";
+ //L'objet retourner
+ $scope.obj={};
+ $scope.obj.creationDate=-1;
+ $scope.obj.time=-1;
+ $scope.obj.index = -1;
- //key:timeId value:Array of time
- var stockTime={};
-
-
//Pour l'affichage
- $scope.getStartTime = function(item){
- return moment(item.creationDate).format("DD-MM-YYYY H:mm:ss");
- }
-
+ $scope.getStartTime = function(item){return moment(item.creationDate).format("DD-MM-YYYY H:mm:ss");}
$scope.getStopTime = function(item){return item.time;}
- //Pour le timePicker
- $scope.select = function(item){
- $scope.currentTask = item;
- $scope.aTime = new Date($scope.currentTask.creationDate);
- }
+ $scope.getStartObjTime = function(){return moment($scope.obj.creationDate).format("DD-MM-YYYY H:mm:ss");}
+ $scope.getStopObjTime = function(){return moment($scope.obj.creationDate + $scope.obj.time).format("DD-MM-YYYY H:mm:ss");}
+ //selectionne un element dans le dropdown
+ $scope.select = function(item, ind){
+ $scope.activTime = item;
- $scope.changeTime = function(item){
+ //On intialise l'objet a envoyer
+ $scope.obj.index = ind;
+ $scope.obj.creationDate=item.creationDate;
+ $scope.obj.time=item.time;
+ $scope.aTime = new Date(item.creationDate);
}
- $scope.dateDebut = function(){
- $scope.modifDate= "début";
- $scope.aTime = new Date($scope.currentTask.creationDate);
-
- }
-
- $scope.dateFin = function(){
- $scope.modifDate= "durée";
- $scope.aTime = new Date($scope.currentTask.creationDate + $scope.currentTask.time );
- }
-
+ // Methode a la fermeture
$scope.ok = function () {
- $modalInstance.close();
+ $modalInstance.close($scope.obj);
};
$scope.cancel = function () {
@@ -669,3 +667,45 @@
};
};
+var radioTimeCtrl = function ($scope){
+
+ //Activated button radio
+ $scope.radioModel = 'Left';
+ $scope.aTime = new Date($scope.activTime.creationDate);
+
+ //Le pas des heures et minutes
+ $scope.hstep = 1;
+ $scope.mstep = 1;
+
+ $scope.changeModel = function(){
+ //TODO obruce : ici il faut mettre des contraintes pour pas depasser 24h
+ //TODO pas depasser dans l'autre sens
+ if(($scope.radioModel || 'null') == 'Left'){
+
+ $scope.obj.creationDate = $scope.aTime.getTime();
+ console.log($scope.obj.creationDate);
+ }else{
+
+ if($scope.aTime.getTime() > $scope.activTime.creationDate){
+ var duree = $scope.aTime.getTime() - $scope.activTime.creationDate ;
+ $scope.obj.time = duree;
+ }else{
+ $scope.aTime = new Date($scope.obj.creationDate );
+ duree = 0;
+ }
+ console.log($scope.obj.time);
+ }
+ }
+
+ //Change l'heure dans le timePicker selon debut/fin
+ $scope.changeFonc=function(){
+ if(($scope.radioModel || 'null') == 'Left'){
+ $scope.aTime = new Date($scope.obj.creationDate);
+ }else{
+ $scope.aTime = new Date($scope.obj.creationDate + $scope.activTime.time);
+ }
+ }
+};
+
+
+
Modified: branches/ng-jtimer/src/main/webapp/partials/timeModal.html
===================================================================
--- branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-14 08:27:44 UTC (rev 2975)
+++ branches/ng-jtimer/src/main/webapp/partials/timeModal.html 2014-05-14 16:22:39 UTC (rev 2976)
@@ -1,40 +1,57 @@
<div>
<h3> Modifier la tâche.</h3>
- <ul>
- <li ng-repeat="item in times" >
+ <div class="btn-group" dropdown is-open="status.isopen" ng-show="activTime == null">
+ <button type="button" class="btn btn-primary dropdown-toggle">
+ Les périodes pour la tâche sélectionnée : <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu" role="menu">
- <span ng-click="select(item)">
- Date de création : {{getStartTime(item)}} - Durée : {{getStopTime(item)| time}}
- </span>
+ <li ng-repeat="(index,item) in times" >
- <!-- Timepicker -->
- <div ng-show = "currentTask == item">
- <hr>
+ <span ng-click="select(item, index)">
+ Début : {{getStartTime(item)}} - Durée : {{getStopTime(item)| time}}
+ </span>
- <!-- Choix -->
- <div class="btn-group" dropdown is-open="status.isopen">
- <button type="button" class="btn btn-primary dropdown-toggle">
- Changer la date de {{modifDate}} de période. <span class="caret"></span>
- </button>
- <ul class="dropdown-menu" role="menu">
- <li ng-click="dateDebut()"><a href="#">Début de la période</a></li>
- <li ng-click="dateFin()"><a href="#">Fin de la période</a></li>
+ </li>
- </ul>
+ </ul>
+ </div>
+
+ <div ng-if = "activTime != null">
+ <hr/>
+ <h4>Période : Début : {{getStartTime(activTime)}} - Durée : {{getStopTime(activTime)| time}}</h4>
+ <alert type="danger" >Choisir une période :</alert>
+
+ <div class = "timepick" ng-controller="radioTimeCtrl">
+ <br/>
+
+
+ <div>
+ <div class="btn-group">
+ <label class="btn btn-primary" ng-model="radioModel" ng-change="changeFonc()" btn-radio="'Left'">Début de période </label>
+ <label class="btn btn-primary" ng-model="radioModel" ng-change="changeFonc()" btn-radio="'Right'">Fin de période </label>
</div>
+ </div>
+ <br/>
+
+ <div class = "timepick">
<timepicker
- ng-model="$parent.$parent.aTime" ng-change="changeTime()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian">
+ ng-model="aTime" ng-change="changeModel()" hour-step="hstep" minute-step="mstep" show-meridian="ismeridian">
</timepicker>
</div>
- </li>
+ <br/>
- </ul>
+ </div>
+ <alert type="info" >Début : {{getStartObjTime()}} - Fin : {{getStopObjTime(activTime)}}</alert>
+ </div>
+
+
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
Modified: branches/ng-jtimer/src/main/webapp/webtimer.appcache
===================================================================
--- branches/ng-jtimer/src/main/webapp/webtimer.appcache 2014-05-14 08:27:44 UTC (rev 2975)
+++ branches/ng-jtimer/src/main/webapp/webtimer.appcache 2014-05-14 16:22:39 UTC (rev 2976)
@@ -6,6 +6,7 @@
partials/about.html
partials/contact.html
partials/tasks.html
+partials/timeModal.html
css/app.css
css/jtimer.css
js/app.js
1
0
Author: echatellier
Date: 2014-05-14 10:27:44 +0200 (Wed, 14 May 2014)
New Revision: 2975
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2975
Log:
Update angular ui bootstrap
Modified:
branches/ng-jtimer/pom.xml
Modified: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml 2014-05-13 16:36:38 UTC (rev 2974)
+++ branches/ng-jtimer/pom.xml 2014-05-14 08:27:44 UTC (rev 2975)
@@ -53,7 +53,7 @@
<dependency>
<groupId>org.nuiton.js</groupId>
<artifactId>nuiton-js-angular-ui-bootstrap</artifactId>
- <version>0.11.0-1</version>
+ <version>0.11.0-2</version>
</dependency>
<dependency>
<groupId>org.nuiton.js</groupId>
1
0
Author: echatellier
Date: 2014-05-13 18:36:38 +0200 (Tue, 13 May 2014)
New Revision: 2974
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2974
Log:
Use released versions
Modified:
branches/ng-jtimer/pom.xml
Modified: branches/ng-jtimer/pom.xml
===================================================================
--- branches/ng-jtimer/pom.xml 2014-05-13 12:39:37 UTC (rev 2973)
+++ branches/ng-jtimer/pom.xml 2014-05-13 16:36:38 UTC (rev 2974)
@@ -48,12 +48,12 @@
<dependency>
<groupId>org.nuiton.js</groupId>
<artifactId>nuiton-js-angularjs</artifactId>
- <version>1.3.0-beta.7-1-SNAPSHOT</version>
+ <version>1.3.0-beta.7-1</version>
</dependency>
<dependency>
<groupId>org.nuiton.js</groupId>
<artifactId>nuiton-js-angular-ui-bootstrap</artifactId>
- <version>0.11.0-1-SNAPSHOT</version>
+ <version>0.11.0-1</version>
</dependency>
<dependency>
<groupId>org.nuiton.js</groupId>
@@ -63,17 +63,17 @@
<dependency>
<groupId>org.nuiton.js</groupId>
<artifactId>nuiton-js-bootstrap</artifactId>
- <version>3.1.1-1-SNAPSHOT</version>
+ <version>3.1.1-1</version>
</dependency>
<dependency>
<groupId>org.nuiton.js</groupId>
<artifactId>nuiton-js-moment</artifactId>
- <version>2.6.0-1-SNAPSHOT</version>
+ <version>2.6.0-1</version>
</dependency>
<dependency>
<groupId>org.nuiton.js</groupId>
<artifactId>nuiton-js-font-awesome</artifactId>
- <version>4.0.3-1-SNAPSHOT</version>
+ <version>4.0.3-1</version>
</dependency>
<dependency>
<groupId>ro.isdc.wro4j</groupId>
1
0
r2973 - in branches/ng-jtimer/src/main: java/org/chorem/jtimer/storage java/org/chorem/jtimer/web webapp/js
by obruce@users.chorem.org 13 May '14
by obruce@users.chorem.org 13 May '14
13 May '14
Author: obruce
Date: 2014-05-13 14:39:37 +0200 (Tue, 13 May 2014)
New Revision: 2973
Url: http://forge.chorem.org/projects/jtimer/repository/revisions/2973
Log:
Correction Storage date en long pour les temps
Modified:
branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java
branches/ng-jtimer/src/main/webapp/js/controllers.js
Modified: branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java
===================================================================
--- branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-12 16:17:30 UTC (rev 2972)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/storage/Storage.java 2014-05-13 12:39:37 UTC (rev 2973)
@@ -9,11 +9,14 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.jtimer.entities.TimerTask;
import org.chorem.jtimer.entities.TimerTime;
+import org.chorem.jtimer.web.TasksResource;
/**
* Implementation du stockage des taches en base de données basée sur h2.
@@ -29,6 +32,8 @@
*/
public class Storage {
+ private final static Logger LOGGER = Logger.getLogger(TasksResource.class.getName());
+
private static final Log log = LogFactory.getLog(Storage.class);
protected static final String TABLE_TASK = "task";
@@ -153,7 +158,7 @@
" PRIMARY KEY (id, taskId))");
statement.executeUpdate("CREATE TABLE " + TABLE_TIME +
"(taskid LONG NOT NULL," +
- " date DATE," +
+ " date LONG," +
" uuid varchar(255) unique," +
" duration LONG," +
" PRIMARY KEY (taskid, date, uuid)," +
@@ -214,7 +219,7 @@
task.setName(rs.getString("name"));
task.setParent(rs.getString("parent"));
task.setTodayTime(0);
- task.setCreationDate(new java.util.Date(rs.getDate("modifdate").getTime()));
+ task.setCreationDate(new java.util.Date(rs.getLong("modifdate")));
task.setTotalTime(rs.getLong("totalduration"));
tasks.add(task);
}
@@ -327,7 +332,7 @@
" VALUES(?, ?, ?, ?)");
statement.setLong(1, task.getNumber());
- statement.setDate(2, new java.sql.Date(date.getTime()));
+ statement.setLong(2, date.getTime()); //TODO
statement.setString(3, uuid);
statement.setLong(4, duration);
statement.executeUpdate();
@@ -346,7 +351,9 @@
" VALUES(?, ?, ?, ?)");
statement.setLong(1, number);
- statement.setDate(2, new java.sql.Date(time.getCreationDate().getTime()));
+ statement.setLong(2, time.getCreationDate().getTime());
+
+ LOGGER.log(Level.WARNING, "Storage add times datetime " +time.getCreationDate().getTime());
statement.setString(3, time.getTimeId());
statement.setLong(4, time.getTime());
statement.executeUpdate();
@@ -385,7 +392,7 @@
time.setTaskId(taskid);
time.setTimeId(rs.getString("uuid"));
time.setTime(rs.getLong("duration"));
- time.setCreationDate(new java.util.Date(rs.getDate("date").getTime()));
+ time.setCreationDate(new java.util.Date(rs.getLong("date")));
times.add(time);
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-05-12 16:17:30 UTC (rev 2972)
+++ branches/ng-jtimer/src/main/java/org/chorem/jtimer/web/TimeResource.java 2014-05-13 12:39:37 UTC (rev 2973)
@@ -18,10 +18,7 @@
public class TimeResource extends ServerResource {
- private GsonBuilder builder;
-
protected Storage storage;
- private final static Logger LOGGER = Logger.getLogger(TasksResource.class.getName());
/**
* Methode qui initialis la resource
@@ -29,22 +26,6 @@
*/
@Override
protected void doInit() throws ResourceException {
-
- //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());
- }
- });
-
storage = (Storage)getContext().getAttributes().get(Storage.class.getName());
}
@@ -59,8 +40,9 @@
String taskId = (String)getRequest().getAttributes().get("taskId");
List<TimerTime> timerTimes = storage.getTimes(taskId);
- Gson gson = builder.create();
+ Gson gson = new Gson();
String json = gson.toJson(timerTimes);
+
return new StringRepresentation(json, MediaType.APPLICATION_JSON);
}
@@ -71,7 +53,6 @@
*/
@Delete
public void deleteTask() {
-
String timeId = (String)getRequest().getAttributes().get("taskId");
storage.deleteTimeWithId(timeId);
}
@@ -85,7 +66,7 @@
String timeId = (String)getRequest().getAttributes().get("taskId");
long number = storage.getTaskNumber(timeId);
- Gson gson = builder.create();
+ Gson gson = new Gson();
String repr1 = representation.getText();
TimerTime t = gson.fromJson(repr1, TimerTime.class);
Modified: branches/ng-jtimer/src/main/webapp/js/controllers.js
===================================================================
--- branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-12 16:17:30 UTC (rev 2972)
+++ branches/ng-jtimer/src/main/webapp/js/controllers.js 2014-05-13 12:39:37 UTC (rev 2973)
@@ -244,7 +244,7 @@
var timer = function() {
$interval(function() {
actionToServ();
- }, 30000); //TODO: for now 10s but for real put at least 2h: 200000000
+ }, 30000); //TODO: for now 30s but for real put at least 2h: 200000000
};
timer();
@@ -253,7 +253,7 @@
*/
var actionToServ = function(){
//Si en ligne on envoie les donnees
- if ( $scope.online == true) {
+ if ( $scope.online) {
pushChangesToServ();
getTasksFromServ();
1
0