Permalink
Browse files

widgets are timeUnit sensitive, made sub-packages for models, added and

API method to get oauth keys, adapted the properties code so they are
now automatically reloaded when edited
  • Loading branch information...
1 parent 3fc07d8 commit c3111d69dd8dfcbdcf98678a5e8deeac434c59ff @ckemmler ckemmler committed Mar 13, 2012
Showing with 107 additions and 53 deletions.
  1. +1 −1 .settings/org.eclipse.m2e.core.prefs
  2. +1 −1 fluxtream-connectors/.settings/org.eclipse.m2e.core.prefs
  3. +2 −2 fluxtream-core-webapp/.settings/org.eclipse.m2e.core.prefs
  4. +30 −1 fluxtream-core-webapp/src/main/java/com/fluxtream/api/GuestResource.java
  5. +3 −2 fluxtream-core-webapp/src/main/java/com/fluxtream/mvc/models/HomeModel.java
  6. +1 −1 fluxtream-core-webapp/src/main/java/com/fluxtream/mvc/models/{ → guest}/GuestModel.java
  7. +1 −1 fluxtream-core/.settings/org.eclipse.m2e.core.prefs
  8. +0 −3 fluxtream-web/.classpath
  9. +2 −2 fluxtream-web/.settings/org.eclipse.m2e.core.prefs
  10. +3 −6 fluxtream-web/src/main/java/com/fluxtream/mvc/controllers/NavController.java
  11. +23 −10 fluxtream-web/src/main/webapp/js/applications/log/App.js
  12. +2 −2 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/DiaryWidget.js
  13. 0 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/{diary.html → dayDiary.html}
  14. +5 −0 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/monthDiary.html
  15. +5 −0 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/weekDiary.html
  16. +5 −0 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/yearDiary.html
  17. +2 −1 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/SummaryWidget.js
  18. +1 −0 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/daySummary.html
  19. +1 −0 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/monthSummary.html
  20. +0 −1 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/summary.html
  21. +1 −0 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/weekSummary.html
  22. +1 −0 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/yearSummary.html
  23. +2 −2 fluxtream-webapp/.settings/org.eclipse.m2e.core.prefs
  24. +2 −2 fluxtream-webapp/buildNumber.properties
  25. +13 −4 fluxtream-webapp/src/main/webapp/WEB-INF/applicationContext.xml
  26. +0 −11 pom.xml
View
2 .settings/org.eclipse.m2e.core.prefs
@@ -1,4 +1,4 @@
-#Mon Feb 27 20:11:24 CET 2012
+#Tue Mar 13 00:03:04 CET 2012
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
View
2 fluxtream-connectors/.settings/org.eclipse.m2e.core.prefs
@@ -1,4 +1,4 @@
-#Mon Feb 27 20:15:03 CET 2012
+#Tue Mar 13 00:02:41 CET 2012
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
View
4 fluxtream-core-webapp/.settings/org.eclipse.m2e.core.prefs
@@ -1,5 +1,5 @@
-#Mon Feb 27 20:15:18 CET 2012
+#Mon Mar 12 23:51:57 CET 2012
activeProfiles=
eclipse.preferences.version=1
-resolveWorkspaceProjects=true
+resolveWorkspaceProjects=false
version=1
View
31 fluxtream-core-webapp/src/main/java/com/fluxtream/api/GuestResource.java
@@ -2,16 +2,22 @@
import javax.ws.rs.GET;
import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
+import com.fluxtream.Configuration;
+import com.fluxtream.connectors.Connector;
+import com.fluxtream.domain.ApiKey;
import com.fluxtream.domain.Guest;
import com.fluxtream.mvc.controllers.ControllerHelper;
-import com.fluxtream.mvc.models.GuestModel;
+import com.fluxtream.mvc.models.StatusModel;
+import com.fluxtream.mvc.models.guest.GuestModel;
+import com.fluxtream.mvc.models.guest.OAuthTokensModel;
import com.fluxtream.services.GuestService;
import com.google.gson.Gson;
@@ -25,6 +31,9 @@
Gson gson = new Gson();
+ @Autowired
+ Configuration env;
+
@GET
@Path("/")
@Produces({ MediaType.APPLICATION_JSON })
@@ -38,6 +47,26 @@ public String getCurrentGuest() throws InstantiationException,
// NewRelic.setTransactionName(null, "/api/log/all/date");
return gson.toJson(guestModel);
}
+
+ @GET
+ @Path("/{connector}/oauthTokens")
+ @Produces({ MediaType.APPLICATION_JSON })
+ public String getOAuthTokens(@PathParam("connector") String connectorName) throws InstantiationException,
+ IllegalAccessException, ClassNotFoundException {
+ long guestId = ControllerHelper.getGuestId();
+
+ ApiKey apiKey = guestService.getApiKey(guestId, Connector.getConnector(connectorName));
+ if (apiKey!=null) {
+ OAuthTokensModel oauthTokensModel = new OAuthTokensModel();
+ oauthTokensModel.accessToken = apiKey.getAttributeValue("accessToken", env);
+ oauthTokensModel.tokenSecret = apiKey.getAttributeValue("tokenSecret", env);
+
+ return gson.toJson(oauthTokensModel);
+ } else {
+ StatusModel result = new StatusModel(false, "Guest does not have that connector: " + connectorName);
+ return gson.toJson(result);
+ }
+ }
}
View
5 fluxtream-core-webapp/src/main/java/com/fluxtream/mvc/models/HomeModel.java
@@ -114,7 +114,7 @@ public TimeZone getTimeZone() {
}
public void setYear(int year) {
- setDayTimeUnit();
+ setYearTimeUnit();
fromCalendar.set(Calendar.YEAR, year);
fromCalendar.set(Calendar.WEEK_OF_YEAR, 0);
fromCalendar.set(Calendar.HOUR_OF_DAY, 0);
@@ -123,7 +123,8 @@ public void setYear(int year) {
fromCalendar.set(Calendar.MILLISECOND, 0);
fromCalendar = TimeUtils.setFromMidnight(fromCalendar);
toCalendar.set(Calendar.YEAR, year);
- toCalendar.set(Calendar.WEEK_OF_YEAR, 0);
+ toCalendar.set(Calendar.MONTH, Calendar.DECEMBER);
+ toCalendar.set(Calendar.DAY_OF_MONTH, 31);
toCalendar.set(Calendar.HOUR_OF_DAY, 23);
toCalendar.set(Calendar.MINUTE, 59);
toCalendar.set(Calendar.SECOND, 59);
View
2 .../com/fluxtream/mvc/models/GuestModel.java → ...luxtream/mvc/models/guest/GuestModel.java
@@ -1,4 +1,4 @@
-package com.fluxtream.mvc.models;
+package com.fluxtream.mvc.models.guest;
import com.fluxtream.domain.Guest;
View
2 fluxtream-core/.settings/org.eclipse.m2e.core.prefs
@@ -1,4 +1,4 @@
-#Mon Feb 27 20:15:11 CET 2012
+#Mon Mar 12 23:54:25 CET 2012
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
View
3 fluxtream-web/.classpath
@@ -5,8 +5,5 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/fluxtream-connectors"/>
- <classpathentry combineaccessrules="false" kind="src" path="/fluxtream-core"/>
- <classpathentry combineaccessrules="false" kind="src" path="/fluxtream-core-webapp"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
View
4 fluxtream-web/.settings/org.eclipse.m2e.core.prefs
@@ -1,5 +1,5 @@
-#Mon Feb 27 20:15:27 CET 2012
+#Mon Mar 12 23:52:02 CET 2012
activeProfiles=
eclipse.preferences.version=1
-resolveWorkspaceProjects=true
+resolveWorkspaceProjects=false
version=1
View
9 fluxtream-web/src/main/java/com/fluxtream/mvc/controllers/NavController.java
@@ -88,16 +88,15 @@ public void gotoDate(@PathVariable("date") String date,
}
@RequestMapping(value = "/nav/setWeek.json")
- public void setYear(@RequestParam("year") int year,
+ public void setWeek(@RequestParam("year") int year,
@RequestParam("week") int week,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
- logger.info("action=setYear year=" + year);
+ logger.info("action=setWeek year=" + year + " week=" + week);
response.setContentType("application/json; charset=utf-8");
HomeModel homeModel = (HomeModel) request.getSession().getAttribute(
"homeModel");
homeModel.setWeek(year, week);
- updateComment(homeModel, request);
response.getWriter().write(homeModel.toJSONString(env, getConfigState(request)));
}
@@ -106,12 +105,11 @@ public void setMonth(@RequestParam("year") int year,
@RequestParam("month") int month,
HttpServletRequest request, HttpServletResponse response)
throws IOException {
- logger.info("action=setYear year=" + year);
+ logger.info("action=setMonth year=" + year + " month=" + month);
response.setContentType("application/json; charset=utf-8");
HomeModel homeModel = (HomeModel) request.getSession().getAttribute(
"homeModel");
homeModel.setMonth(year, month);
- updateComment(homeModel, request);
response.getWriter().write(homeModel.toJSONString(env, getConfigState(request)));
}
@@ -124,7 +122,6 @@ public void setYear(@RequestParam("year") int year,
HomeModel homeModel = (HomeModel) request.getSession().getAttribute(
"homeModel");
homeModel.setYear(year);
- updateComment(homeModel, request);
response.getWriter().write(homeModel.toJSONString(env, getConfigState(request)));
}
View
33 fluxtream-web/src/main/webapp/js/applications/log/App.js
@@ -98,7 +98,6 @@ define(["core/Application",
Log.renderState(widget+state);
});
}
- $("."+this.currentWidget + "-tab").parent().addClass("active");
}
function fetchState(url) {
@@ -152,18 +151,32 @@ define(["core/Application",
_.bindAll(this);
for (var i=0; i<widgets[Log.timeUnit].length; i++) {
FlxState.router.route("app/log/:widget/date/:date", "", function(widget, date) {
- Log.render(widget + "/date/" + date);
- })
+ var w = widgetExistsForTimeUnit(widget, Log.timeUnit)?widget:widgets[Log.timeUnit][0];
+ Log.render(w + "/date/" + date);
+ });
FlxState.router.route("app/log/:widget/year/:year", "", function(widget, year) {
- Log.render(widget + "/year/" + year);
- })
+ var w = widgetExistsForTimeUnit(widget, Log.timeUnit)?widget:widgets[Log.timeUnit][0];
+ Log.render(w + "/year/" + year);
+ });
FlxState.router.route("app/log/:widget/month/:year/:month", "", function(widget, year, month) {
- Log.render(widget + "/month/" + year + "/" + month);
- })
+ var w = widgetExistsForTimeUnit(widget, Log.timeUnit)?widget:widgets[Log.timeUnit][0];
+ Log.render(w + "/month/" + year + "/" + month);
+ });
FlxState.router.route("app/log/:widget/week/:year/:week", "", function(widget, year, week) {
- Log.render(widget + "/week/" + year + "/" + week);
- })
+ var w = widgetExistsForTimeUnit(widget, Log.timeUnit)?widget:widgets[Log.timeUnit][0];
+ Log.render(w + "/week/" + year + "/" + week);
+ });
+ }
+ }
+
+ function widgetExistsForTimeUnit(widget, unit) {
+ var widgetExistsForTimeUnit = false;
+ for (var i=0; i<widgets[unit].length; i++) {
+ if (widgets[unit][i]===widget)
+ widgetExistsForTimeUnit = true;
}
+ console.log("widgetExistsForTimeUnit: " + widgetExistsForTimeUnit);
+ return widgetExistsForTimeUnit;
}
function incrementTimespan() {
@@ -191,7 +204,7 @@ define(["core/Application",
}
function gotoYear(year) {
- fetchState("/nav/setYear.json?year=" + year);
+ fetchState("/nav/setYear.json?year=" + year));
}
function bindNavigationEvents() {
View
4 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/DiaryWidget.js
@@ -1,7 +1,7 @@
define(["applications/log/widgets/diary/Status"], function(status) {
- function render(digest) {
- require(["text!applications/log/widgets/diary/diary.html"], function(template) {
+ function render(digest, timeUnit) {
+ require(["text!applications/log/widgets/diary/" + timeUnit.toLowerCase() + "Diary.html"], function(template) {
$("#widgets").append(template);
status.handleComments();
});
View
0 ...applications/log/widgets/diary/diary.html → ...lications/log/widgets/diary/dayDiary.html
File renamed without changes.
View
5 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/monthDiary.html
@@ -0,0 +1,5 @@
+<div class="row-fluid">
+ <div class="span12 editor">
+ <input class="diaryTitle" type="text" placeholder="This month..."></input>
+ </div>
+</div>
View
5 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/weekDiary.html
@@ -0,0 +1,5 @@
+<div class="row-fluid">
+ <div class="span12 editor">
+ <input class="diaryTitle" type="text" placeholder="This week..."></input>
+ </div>
+</div>
View
5 fluxtream-web/src/main/webapp/js/applications/log/widgets/diary/yearDiary.html
@@ -0,0 +1,5 @@
+<div class="row-fluid">
+ <div class="span12 editor">
+ <input class="diaryTitle" type="text" placeholder="This year..."></input>
+ </div>
+</div>
View
3 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/SummaryWidget.js
@@ -1,7 +1,8 @@
define([], function() {
function render(digest, timeUnit) {
- require(["text!applications/log/widgets/summary/summary.html"], function(template) {
+ console.log("timeUnit: " + timeUnit);
+ require(["text!applications/log/widgets/summary/" + timeUnit.toLowerCase() + "Summary.html"], function(template) {
$("#widgets").append(template);
});
}
View
1 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/daySummary.html
@@ -0,0 +1 @@
+<div id="summaryWidget"class="span12">Hello, this is the day summary widget</div>
View
1 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/monthSummary.html
@@ -0,0 +1 @@
+<div id="summaryWidget"class="span12">Hello, this is the month summary widget</div>
View
1 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/summary.html
@@ -1 +0,0 @@
-<div id="summaryWidget"class="span12">Hello, this is the summary widget</div>
View
1 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/weekSummary.html
@@ -0,0 +1 @@
+<div id="summaryWidget"class="span12">Hello, this is the week summary widget</div>
View
1 fluxtream-web/src/main/webapp/js/applications/log/widgets/summary/yearSummary.html
@@ -0,0 +1 @@
+<div id="summaryWidget"class="span12">Hello, this is the year summary widget</div>
View
4 fluxtream-webapp/.settings/org.eclipse.m2e.core.prefs
@@ -1,5 +1,5 @@
-#Mon Feb 27 20:15:36 CET 2012
+#Mon Mar 12 23:52:09 CET 2012
activeProfiles=
eclipse.preferences.version=1
-resolveWorkspaceProjects=true
+resolveWorkspaceProjects=false
version=1
View
4 fluxtream-webapp/buildNumber.properties
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
-#Fri Mar 09 18:07:09 CET 2012
-buildNumber0=758
+#Tue Mar 13 15:34:29 CET 2012
+buildNumber0=765
View
17 fluxtream-webapp/src/main/webapp/WEB-INF/applicationContext.xml
@@ -77,11 +77,20 @@
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
- <util:properties id="commonProperties" location="classpath:common.properties"/>
- <util:properties id="targetEnvProperties" location="classpath:${TARGET_ENV}.properties"/>
- <util:properties id="connectorsProperties" location="classpath:connectors.properties"/>
- <util:properties id="oauthProperties" location="classpath:oauth.properties"/>
<util:properties id="countries" location="classpath:countries.properties"/>
+
+ <bean id="commonProperties" class="com.fluxtream.AutoReloadProperties">
+ <constructor-arg value="common.properties"/>
+ </bean>
+ <bean id="targetEnvProperties" class="com.fluxtream.AutoReloadProperties">
+ <constructor-arg value="${TARGET_ENV}.properties"/>
+ </bean>
+ <bean id="connectorsProperties" class="com.fluxtream.AutoReloadProperties">
+ <constructor-arg value="connectors.properties"/>
+ </bean>
+ <bean id="oauthProperties" class="com.fluxtream.AutoReloadProperties">
+ <constructor-arg value="oauth.properties"/>
+ </bean>
<bean id="configuration" class="com.fluxtream.Configuration">
<property name="commonProperties" ref="commonProperties"/>
View
11 pom.xml
@@ -33,21 +33,10 @@
</plugins>
</build>
<repositories>
- <!-- <repository> -->
- <!-- <id>spring-milestone</id> -->
- <!-- <name>Spring Maven MILESTONE Repository</name> -->
- <!-- <url>http://maven.springframework.org/milestone</url> -->
- <!-- </repository> -->
<repository>
<id>Github Imaginatio</id>
<url>https://github.com/Imaginatio/Maven-repository/raw/master</url>
</repository>
- <repository>
- <id>maven2-repository.dev.java.net</id>
- <name>Java.net Repository for Maven</name>
- <url>http://download.java.net/maven/2/</url>
- <layout>default</layout>
- </repository>
</repositories>
<dependencies>
<dependency>

0 comments on commit c3111d6

Please sign in to comment.