Sandbox-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 2015
- 5 participants
- 271 discussions
Author: ygrego
Date: 2015-05-27 16:03:00 +0000 (Wed, 27 May 2015)
New Revision: 1504
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1504
Log:
Rename severals tags.
Modified:
oipf/data/oipfChannels.xml
Modified: oipf/data/oipfChannels.xml
===================================================================
--- oipf/data/oipfChannels.xml 2015-05-27 09:00:46 UTC (rev 1503)
+++ oipf/data/oipfChannels.xml 2015-05-27 16:03:00 UTC (rev 1504)
@@ -31,7 +31,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>D17</name>
@@ -64,7 +64,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>FRANCE_2</name>
@@ -97,7 +97,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>FRANCE_3</name>
@@ -130,7 +130,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>FRANCE_4</name>
@@ -163,7 +163,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>FRANCE_5</name>
@@ -196,7 +196,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>M6</name>
@@ -229,7 +229,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>NRJ_12</name>
@@ -262,7 +262,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>NT1</name>
@@ -295,7 +295,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>RTL9</name>
@@ -328,7 +328,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>TF1</name>
@@ -361,7 +361,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>TMC</name>
@@ -394,7 +394,7 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
<channel>
<name>W9</name>
@@ -427,6 +427,6 @@
<hidden>false</hidden>
<is3D>false</is3D>
<isHD>false</isHD>
- <logoUR>null</logoUR>
+ <logoURL>null</logoURL>
</channel>
</channelList>
\ No newline at end of file
1
0
Author: ygrego
Date: 2015-05-27 09:00:46 +0000 (Wed, 27 May 2015)
New Revision: 1503
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1503
Log:
Addition of javascript file "XmlToJson"
Modified:
oipf/view/test.html
Modified: oipf/view/test.html
===================================================================
--- oipf/view/test.html 2015-05-26 16:16:18 UTC (rev 1502)
+++ oipf/view/test.html 2015-05-27 09:00:46 UTC (rev 1503)
@@ -34,6 +34,7 @@
<script src="../js/utils/DateUtils.js" type="text/javascript"></script>
<script src="../js/utils/XmlParser.js" type="text/javascript"></script>
<script src="../js/utils/ProgrammeService.js" type="text/javascript"></script>
+ <script src="../js/utils/XmlToJson.js" type="text/javascript"></script>
<script src="../js/configuration/ConfigDefaultProperties.js" type="text/javascript"></script>
<script src="../js/configuration/CapabilitiesProperties.js" type="text/javascript"></script>
1
0
Author: jruchaud
Date: 2015-05-26 16:16:18 +0000 (Tue, 26 May 2015)
New Revision: 1502
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1502
Log:
Remove useless grunt file
Removed:
wit/gruntfile.js
Deleted: wit/gruntfile.js
===================================================================
--- wit/gruntfile.js 2015-05-26 16:15:26 UTC (rev 1501)
+++ wit/gruntfile.js 2015-05-26 16:16:18 UTC (rev 1502)
@@ -1,30 +0,0 @@
-"use strict";
-
-module.exports = function(grunt) {
-
- grunt.initOptions = function() {
- };
-
- grunt.initConfig({
- nodewebkit: {
- options: {
-// platforms: ['win','osx',"linux"],
- platforms: ["linux64"],
- version: "0.12.2",
- buildDir: "./webkitbuilds" // Where the build version of my node-webkit app is saved
- },
- src: [ // Your node-webkit app
- "./*.html",
- "./node_modules/**",
- "./package.json",
- "./font/**",
- "./img/**",
- "./css/**",
- "./js/**"
- ]
- }
- });
-
- grunt.loadNpmTasks("grunt-node-webkit-builder");
- grunt.registerTask("default", ["nodewebkit"]);
-};
1
0
Author: jruchaud
Date: 2015-05-26 16:15:26 +0000 (Tue, 26 May 2015)
New Revision: 1501
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1501
Log:
Fix move components
Modified:
wit/gulpfile.js
wit/js/App.js
wit/js/GuiManager.js
wit/js/components/root/EditionLogs.js
wit/js/components/root/Options.js
wit/js/components/root/Rapport.js
wit/js/components/root/Timer.js
Modified: wit/gulpfile.js
===================================================================
--- wit/gulpfile.js 2015-05-26 16:08:21 UTC (rev 1500)
+++ wit/gulpfile.js 2015-05-26 16:15:26 UTC (rev 1501)
@@ -22,13 +22,14 @@
}
var paths = {
+ nw: "webkitbuilds",
build: "build",
scripts: "./js/**/*.js",
less: "./css/**/*.less"
};
-gulp.task("clean", function(cb) {
- del([paths.build], cb);
+gulp.task("clean", function() {
+ del([paths.build, paths.build]);
});
gulp.task("scripts", function() {
@@ -90,13 +91,13 @@
var nw = new NwBuilder({
version: "0.12.2",
platforms: ["linux64"],
- buildDir: "./webkitbuilds",
+ buildDir: paths.nw,
files: [
- "./*.html",
"./node_modules/**",
"./package.json",
"./font/**",
"./img/**",
+ "./pages/**",
"./build/**"
]
});
@@ -110,4 +111,4 @@
});
});
-gulp.task("default", ["watch", "scripts", "less"]);
+gulp.task("default", ["clean", "scripts", "less", "watch"]);
Modified: wit/js/App.js
===================================================================
--- wit/js/App.js 2015-05-26 16:08:21 UTC (rev 1500)
+++ wit/js/App.js 2015-05-26 16:15:26 UTC (rev 1501)
@@ -1,12 +1,12 @@
"use strict";
var React = require("react");
-var Routes = require("./router/Routes.js");
-var Link = require("./router/Link.js");
-var Timer = require("./pages/Timer.js");
-var Rapport = require("./pages/Rapport.js");
-var Options = require("./pages/Options.js");
-var EditionLogs = require("./pages/EditionLogs.js");
+var Routes = require("./router/Routes");
+var Link = require("./router/Link");
+var Timer = require("./components/root/Timer");
+var Rapport = require("./components/root/Rapport");
+var Options = require("./components/root/Options");
+var EditionLogs = require("./components/root/EditionLogs");
class App extends React.Component {
Modified: wit/js/GuiManager.js
===================================================================
--- wit/js/GuiManager.js 2015-05-26 16:08:21 UTC (rev 1500)
+++ wit/js/GuiManager.js 2015-05-26 16:15:26 UTC (rev 1501)
@@ -1,8 +1,8 @@
"use strict";
var gui = global.window.nwDispatcher.requireNwGui();
-//var timer = require("./services/TimerService.js");
-//var user = require("./services/UserActivityService.js");
+var timer = require("./services/TimerService.js");
+var user = require("./services/UserActivityService.js");
class GuiManager {
@@ -12,8 +12,8 @@
this.popups = [];
// Subscriptions to services
- //timer.subscribeIdle(this.openWindow.bind(this, "idle.html"));
- //user.subscribeActivityChange(this.openWindow.bind(this, "activityChange.html"));
+ timer.subscribeIdle(this.openWindow.bind(this, "idle.html"));
+ user.subscribeActivityChange(this.openWindow.bind(this, "activityChange.html"));
}
createTray() {
Modified: wit/js/components/root/EditionLogs.js
===================================================================
--- wit/js/components/root/EditionLogs.js 2015-05-26 16:08:21 UTC (rev 1500)
+++ wit/js/components/root/EditionLogs.js 2015-05-26 16:15:26 UTC (rev 1501)
@@ -1,11 +1,11 @@
"use strict";
var moment = require("moment");
-var db = require("../services/database");
+var db = require("../../services/database");
var React = require("react");
-var FilterBar = require("../components/FilterBar");
-var LogsTable = require("../components/LogsTable");
+var FilterBar = require("../FilterBar");
+var LogsTable = require("../LogsTable");
class EditionLogs extends React.Component {
Modified: wit/js/components/root/Options.js
===================================================================
--- wit/js/components/root/Options.js 2015-05-26 16:08:21 UTC (rev 1500)
+++ wit/js/components/root/Options.js 2015-05-26 16:15:26 UTC (rev 1501)
@@ -1,7 +1,7 @@
"use strict";
var React = require("react");
-var config = require("../services/ConfigurationService");
+var config = require("../../services/ConfigurationService");
class Options extends React.Component {
Modified: wit/js/components/root/Rapport.js
===================================================================
--- wit/js/components/root/Rapport.js 2015-05-26 16:08:21 UTC (rev 1500)
+++ wit/js/components/root/Rapport.js 2015-05-26 16:15:26 UTC (rev 1501)
@@ -3,8 +3,8 @@
var moment = require("moment");
var React = require("react");
-var FilterBar = require("../components/FilterBar");
-var FilterLogs = require("../components/FilterLogs");
+var FilterBar = require("../FilterBar");
+var FilterLogs = require("../FilterLogs");
class Rapport extends React.Component {
Modified: wit/js/components/root/Timer.js
===================================================================
--- wit/js/components/root/Timer.js 2015-05-26 16:08:21 UTC (rev 1500)
+++ wit/js/components/root/Timer.js 2015-05-26 16:15:26 UTC (rev 1501)
@@ -1,9 +1,9 @@
"use strict";
var React = require("react");
-var Tags = require("../components/Tags");
-var Time = require("../components/Time");
-var ActionsBar = require("../components/ActionsBar");
+var Tags = require("../Tags");
+var Time = require("../Time");
+var ActionsBar = require("../ActionsBar");
class Timer extends React.Component {
render() {
1
0
Author: smaisonneuve
Date: 2015-05-26 16:08:21 +0000 (Tue, 26 May 2015)
New Revision: 1500
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1500
Log:
[Refactoring] Turning TimerService and UserActivityService into classed
Modified:
wit/js/components/Tags.js
wit/js/main.js
wit/js/services/SessionsService.js
wit/js/services/TimerService.js
wit/js/services/UserActivityService.js
Modified: wit/js/components/Tags.js
===================================================================
--- wit/js/components/Tags.js 2015-05-26 15:59:19 UTC (rev 1499)
+++ wit/js/components/Tags.js 2015-05-26 16:08:21 UTC (rev 1500)
@@ -3,6 +3,7 @@
var React = require("react");
var timer = require("../services/TimerService");
var InputTag = require("./InputTag");
+var InputTag = require("../components/InputTag.js");
class Tags extends React.Component {
Modified: wit/js/main.js
===================================================================
--- wit/js/main.js 2015-05-26 15:59:19 UTC (rev 1499)
+++ wit/js/main.js 2015-05-26 16:08:21 UTC (rev 1500)
@@ -7,7 +7,10 @@
// Alias
// Total time during day
-var noTimer = require("./services/NoTimerService");
+var timer = require("./services/TimerService.js");
+var user = require("./services/UserActivityService.js");
+var noTimer = require("./services/NoTimerService.js");
+
noTimer.detect();
var GuiManager = require("./GuiManager");
Modified: wit/js/services/SessionsService.js
===================================================================
--- wit/js/services/SessionsService.js 2015-05-26 15:59:19 UTC (rev 1499)
+++ wit/js/services/SessionsService.js 2015-05-26 16:08:21 UTC (rev 1500)
@@ -60,7 +60,7 @@
var rst;
if (!startDate || !endDate) {
- log.error("[UserActivityService] getSessions : parameter missing !");
+ log.error("[SessionsService] getSessions : parameter missing !");
} else {
var d1 = moment(startDate), d2 = moment(endDate);
Modified: wit/js/services/TimerService.js
===================================================================
--- wit/js/services/TimerService.js 2015-05-26 15:59:19 UTC (rev 1499)
+++ wit/js/services/TimerService.js 2015-05-26 16:08:21 UTC (rev 1500)
@@ -1,232 +1,246 @@
"use strict";
+var config = require("./ConfigurationService");
+var db = require("./database");
+
var moment = require("moment");
-var db = require("./database.js");
var x11 = require("x11");
var log = require("loglevel");
var events = require("events");
var eventEmitter = new events.EventEmitter();
-var tags = ["wit", "js", "dev"];
-var time = null;
-var idleTime = null;
-var dayTime = 0;
+class TimerService {
+ constructor() {
-var historyIndex = -1;
+ this.tags = ["wit", "js", "dev"];
+ this.time = null;
+ this.idleTime = null;
+ this.dayTime = 0;
+ this.timeChangeTimer = null;
+ this.historyIndex = -1;
-x11.createClient(function(err0, display) {
- if (err0) {
- log.error(err0);
- return;
+ this.initXClient();
}
- var X = display.client;
- X.require("screen-saver", function(err1, SS) {
+ initXClient() {
+ x11.createClient(function(err0, display) {
+ if (err0) {
+ log.error(err0);
+ return;
+ }
- var queryIdle = function() {
- SS.QueryInfo(display.screen[0].root, function(err2, info) {
-// console.log('Idle time ' + info.idle + "ms");
+ var X = display.client;
+ X.require("screen-saver", function(err1, SS) {
- if (time) {
- var configIdleTime = scope.config.getIdleTime();
- var durationIdleTime = moment.duration(configIdleTime, "m");
+ var queryIdle = function() {
+ SS.QueryInfo(display.screen[0].root, function(err2, info) {
+ // console.log('Idle time ' + info.idle + "ms");
- if (info.idle >= durationIdleTime.asMilliseconds() && !idleTime) {
- idleTime = new Date();
- eventEmitter.emit("onIdle");
- }
- }
+ if (this.time) {
+ var configIdleTime = config.getIdleTime();
+ var durationIdleTime = moment.duration(configIdleTime, "m");
- setTimeout(queryIdle, 1000);
- });
- };
+ if (info.idle >= durationIdleTime.asMilliseconds() && !this.idleTime) {
+ this.idleTime = new Date();
+ eventEmitter.emit("onIdle");
+ }
+ }
- queryIdle();
- });
+ setTimeout(queryIdle, 1000);
+ }.bind(this));
+ }.bind(this);
- X.on("error", log.error);
-});
+ queryIdle();
+ }.bind(this));
-var timeChangeTimer = null;
+ X.on("error", log.error);
+ }.bind(this));
+ }
-var timeChange = function() {
- clearTimeout(timeChangeTimer);
+ timeChange() {
+ clearTimeout(this.timeChangeTimer);
- eventEmitter.emit("onTimeChanged");
- if (time) {
- timeChangeTimer = setTimeout(timeChange.bind(), 1000);
+ eventEmitter.emit("onTimeChanged");
+ if (this.time) {
+ this.timeChangeTimer = setTimeout(this.timeChange.bind(this), 1000);
+ }
}
-};
-var insertLog = function(t, start, end) {
- dayTime += moment(end).diff(moment(start));
- db.insertLog(t, start, end);
-};
+ insertLog(t, start, end) {
+ this.dayTime += moment(end).diff(moment(start));
+ db.insertLog(t, start, end);
+ };
-exports.start = function() {
+ start() {
- // Come from to keep idle
- if (time) {
- var diff = moment(idleTime).diff(moment(time));
- time = moment().subtract(diff, "ms").toDate();
- } else {
- time = new Date();
- }
+ // Come from to keep idle
+ if (this.time) {
+ var diff = moment(this.idleTime).diff(moment(this.time));
+ this.time = moment().subtract(diff, "ms").toDate();
+ } else {
+ this.time = new Date();
+ }
- idleTime = null;
- historyIndex = -1;
+ this.idleTime = null;
+ this.historyIndex = -1;
- timeChange();
+ this.timeChange();
+ }
- scope.user.resumeActivityDetection();
-};
+ stop(force) {
-exports.stop = function(force) {
+ if (this.idleTime && force) {
+ this.time = null;
+ this.idleTime = null;
+ this.timeChange();
+ }
- if (idleTime && force) {
- time = null;
- idleTime = null;
- timeChange();
+ if (this.time && !this.idleTime) {
+ this.insertLog(this.tags, this.time, new Date());
+ this.time = null;
+ this.timeChange();
+ }
}
- if (time && !idleTime) {
- insertLog(tags, time, new Date());
- time = null;
- timeChange();
+ getTime() {
+ if (this.time) {
+ var start = moment();
+ var diff = moment(start.diff(this.time)).utcOffset(0);
+ return diff.format("HH:mm:ss");
+ }
}
-};
-exports.getTime = function() {
- if (time) {
- var start = moment();
- var diff = moment(start.diff(time)).utcOffset(0);
- return diff.format("HH:mm:ss");
+ getTags() {
+ return this.tags;
}
-};
-exports.getTags = function() {
- return tags;
-};
+ addTag(tag) {
+ this.tags.push(tag);
+ eventEmitter.emit("onTagsChanged");
+ }
-exports.addTag = function(tag) {
- tags.push(tag);
- eventEmitter.emit("onTagsChanged");
-};
+ removeTag(index) {
+ this.tags.splice(index, 1);
+ eventEmitter.emit("onTagsChanged");
+ }
-exports.removeTag = function(index) {
- tags.splice(index, 1);
- eventEmitter.emit("onTagsChanged");
-};
+ subscribeTagsChanged(callback) {
+ eventEmitter.on("onTagsChanged", callback);
+ }
+ subscribeTimeChanged(callback) {
+ eventEmitter.on("onTimeChanged", callback);
+ }
-exports.subscribeTagsChanged = function(callback) {
- eventEmitter.on("onTagsChanged", callback);
-};
+ subscribeIdle(callback) {
+ eventEmitter.on("onIdle", callback);
+ }
-exports.subscribeTimeChanged = function(callback) {
- eventEmitter.on("onTimeChanged", callback);
-};
+ unsubscribeTagsChanged(callback) {
+ eventEmitter.removeListener("onTagsChanged", callback);
+ }
-exports.subscribeIdle = function(callback) {
- eventEmitter.on("onIdle", callback);
-};
+ unsubscribeTimeChanged(callback) {
+ eventEmitter.removeListener("onTimeChanged", callback);
+ }
-exports.unsubscribeTagsChanged = function(callback) {
- eventEmitter.removeListener("onTagsChanged", callback);
-};
+ unsubscribeIdle(callback) {
+ eventEmitter.removeListener("onIdle", callback);
+ }
-exports.unsubscribeTimeChanged = function(callback) {
- eventEmitter.removeListener("onTimeChanged", callback);
-};
+ keepIdle() {
+ this.idleTime = null;
+ }
-exports.unsubscribeIdle = function(callback) {
- eventEmitter.removeListener("onIdle", callback);
-};
+ removeIdle() {
+ this.insertLog(this.tags, this.time, this.idleTime);
+ this.time = null;
+ this.idleTime = null;
-exports.keepIdle = function() {
- scope.user.resumeActivityDetection();
- idleTime = null;
-};
+ this.timeChange();
-exports.removeIdle = function() {
- insertLog(tags, time, idleTime);
- time = null;
- idleTime = null;
+ this.start();
+ }
- timeChange();
+ editTime(value) {
+ if (this.time) {
+ var d = moment.duration(value);
+ this.idleTime = moment().subtract(d.asMilliseconds(), "ms").toDate();
+ this.reassignIdle();
+ }
+ }
- exports.start();
-};
-
-exports.editTime = function(value) {
- if (time) {
- var d = moment.duration(value);
- idleTime = moment().subtract(d.asMilliseconds(), "ms").toDate();
- this.reassignIdle();
+ reassignIdle() {
+ this.reassignTimeFrom(this.idleTime);
}
-};
-exports.reassignIdle = function() {
- exports.reassignTimeFrom(idleTime);
-};
+ reassignTimeFrom(newStartTime) {
+ this.insertLog(this.tags, this.time, newStartTime);
+ this.time = newStartTime;
+ this.idleTime = new Date();
-exports.reassignTimeFrom = function(newStartTime) {
- insertLog(tags, time, newStartTime);
- time = newStartTime;
- idleTime = new Date();
+ clearTimeout(this.timeChangeTimer);
+ eventEmitter.emit("onTimeChanged");
+ };
- clearTimeout(timeChangeTimer);
- eventEmitter.emit("onTimeChanged");
-};
+ getDayTime() {
+ var diff = this.dayTime;
+ if (this.time) {
+ var now = moment();
+ diff += now.diff(this.time);
+ }
-exports.getDayTime = function() {
- var diff = dayTime;
- if (time) {
- var now = moment();
- diff += now.diff(time);
+ var value = moment(diff).utcOffset(0);
+ return value.format("HH:mm:ss");
}
- var value = moment(diff).utcOffset(0);
- return value.format("HH:mm:ss");
-};
+ deleteLog(id) {
+ db.deleteLog(id);
+ }
-exports.deleteLog = function(id) {
- db.deleteLog(id);
-};
+ setTagsFromHistory() {
-// History
-var setTagsFromHistory = function() {
+ db.getHistory(this.historyIndex)
+ .then(function(logs) {
- db.getHistory(historyIndex)
- .then(function(logs) {
+ if (logs && logs.length) {
+ var row = logs[0];
+ this.tags = row.tags.slice(0);
+ } else {
+ this.tags = [];
+ }
+ eventEmitter.emit("onTagsChanged");
+ }.bind(this));
+ }
- if (logs && logs.length) {
- var row = logs[0];
- tags = row.tags.slice(0);
- } else {
- tags = [];
+ prevHistory() {
+ this.historyIndex++;
+ this.setTagsFromHistory();
+ }
+
+ nextHistory() {
+ if (this.historyIndex === -1) {
+ return;
}
- eventEmitter.emit("onTagsChanged");
- });
-};
-exports.prevHistory = function() {
- historyIndex++;
+ this.historyIndex--;
+ this.setTagsFromHistory();
+ }
- setTagsFromHistory();
-};
-
-exports.nextHistory = function() {
- if (historyIndex === -1) {
- return;
+ getLastTags() {
+ return db.getLastTags();
}
+}
- historyIndex--;
+// Export TimerService as a singleton
- setTagsFromHistory();
+TimerService.instance = null;
+TimerService.getInstance = function() {
+ if (this.instance === null) {
+ this.instance = new TimerService();
+ }
+ return this.instance;
};
-exports.getLastTags = function() {
- return db.getLastTags();
-};
+module.exports = TimerService.getInstance();
Modified: wit/js/services/UserActivityService.js
===================================================================
--- wit/js/services/UserActivityService.js 2015-05-26 15:59:19 UTC (rev 1499)
+++ wit/js/services/UserActivityService.js 2015-05-26 16:08:21 UTC (rev 1500)
@@ -1,5 +1,9 @@
"use strict";
+var config = require("./ConfigurationService");
+var sessions = require("./SessionsService");
+var timer = require("./TimerService");
+
var x11 = require("x11");
var xprop = require("xprop");
var moment = require("moment");
@@ -8,216 +12,224 @@
var events = require("events");
var eventEmitter = new events.EventEmitter();
-var activityChangeTimer;
-var disableActivityDetection = false;
+class UserActivityService {
+ constructor() {
+ this.activityChangeTimer = null;
+ this.disableActivityDetection = false;
+ this.initActivityListener();
+ this.subscribeToTimerChange();
+ }
-///////////////
-// Utilities //
-///////////////
+ /**
+ * Listen to active window change and window title change
+ * Some part of the code has been derived from :
+ * http://stackoverflow.com/questions/19840459/linux-get-notification-on-focus…
+ */
+ initActivityListener() {
+ x11.createClient(function(err, display) {
+ var xClient = display.client;
-var onActiveWindowChange = function(xClient, ev) {
- if (ev.name === "PropertyNotify") {
+ xClient.ChangeWindowAttributes(display.screen[0].root, {
+ eventMask: x11.eventMask.PropertyChange
+ });
- xClient.GetAtomName(ev.atom, function(err, name) {
+ // Init windows session with the currently active window
+ //addWindowSession(X, display.screen[0].root);
- // if the property change refers to the currently active window, retrieve new active window name
+ // Listen to client display events to identify when the currently active window has change
+ xClient.on("event", this.onActiveWindowChange.bind(this, xClient));
+ }.bind(this));
+ }
- if (name === "_NET_ACTIVE_WINDOW") {
-
- registerWindowEvents(xClient, ev);
- addWindowSession(xClient, ev);
-
- } else if (name === "_NET_WM_NAME") {
-
- updateWindowSession(ev);
+ /**
+ * Subscriber to timer change :
+ * If timer change occured while activity change detection is on going,
+ * stop activity change detection process (means the user has handled it)
+ */
+ subscribeToTimerChange() {
+ timer.subscribeTimeChanged(function() {
+ if (!timer.getTime()) {
+ clearTimeout(this.activityChangeTimer);
}
- });
+ }.bind(this));
}
-};
-var getActiveWindowId = function(xClient, ev) {
- return new Promise(function(resolve, reject) {
+ onActiveWindowChange(xClient, ev) {
+ if (ev.name === "PropertyNotify") {
- if (!ev.wid) {
+ xClient.GetAtomName(ev.atom, function(err, name) {
- reject();
+ // if the property change refers to the currently active window, retrieve new active window name
- } else {
+ if (name === "_NET_ACTIVE_WINDOW") {
- xClient.GetProperty(0, ev.wid, ev.atom, xClient.atoms.WINDOW, 0, 4, function(err, prop) {
- if (err || !prop.data.length) {
- log.warn("Couldn't retrieve active window property");
- reject();
+ this.registerWindowEvents(xClient, ev);
+ this.addWindowSession(xClient, ev);
- } else {
- var wid = prop.data.readUInt32LE(0);
+ } else if (name === "_NET_WM_NAME") {
- if (wid) {
- resolve(wid);
-
- } else {
- log.warn("Couldn't retrieve active window property");
- reject();
- }
+ this.updateWindowSession(ev);
}
- });
+ }.bind(this));
}
+ }
- });
-};
+ getActiveWindowId(xClient, ev) {
+ return new Promise(function(resolve, reject) {
-var getWindowName = function(windowId) {
- return new Promise(function(resolve, reject) {
+ if (!ev.wid) {
- if (!windowId) {
+ reject();
- reject();
+ } else {
- } else {
+ xClient.GetProperty(0, ev.wid, ev.atom, xClient.atoms.WINDOW, 0, 4, function(err, prop) {
+ if (err || !prop.data.length) {
+ log.warn("Couldn't retrieve active window property");
+ reject();
- xprop({prop: "_NET_WM_NAME", id: windowId}, function(err, properties) {
+ } else {
+ var wid = prop.data.readUInt32LE(0);
- if (err) {
- log.warn("Couldn't retrieve window name for id :", windowId);
- reject();
+ if (wid) {
+ resolve(wid);
- } else {
- resolve(properties.length && properties[0].value);
- }
- });
- }
- });
-};
+ } else {
+ log.warn("Couldn't retrieve active window property");
+ reject();
+ }
+ }
+ });
+ }
-var registerWindowEvents = function(xClient, ev) {
- getActiveWindowId(xClient, ev)
- .then(function(wid) {
- xClient.ChangeWindowAttributes(wid, {
- eventMask: x11.eventMask.PropertyChange
});
- });
-};
+ }
-var setupActivityDetection = function(session) {
- if (disableActivityDetection || !session || !scope.timer.getTime()) {
+ getWindowName(windowId) {
+ return new Promise(function(resolve, reject) {
- clearTimeout(activityChangeTimer); // stop activity detection
+ if (!windowId) {
- } else {
+ reject();
- var now = moment();
- if (now.diff(session.startDate, "m") >= scope.config.getActivityTime()) {
+ } else {
- // The user has stayed more than "config.getActivityTime()" minutes on a window
- // and now has just switched to another window.
- // If it stays at list as long as he did on the previous one, let's notify it to him
+ xprop({prop: "_NET_WM_NAME", id: windowId}, function(err, properties) {
- activityChangeTimer = setTimeout(
- eventEmitter.emit.bind(eventEmitter, "onActivityChange", now.toDate()),
- moment.duration(scope.config.getActivityTime(), "m").as("ms")
- );
- activityChangeTimer.crtActivityName = session.name;
- activityChangeTimer.changeDetectedDate = now.toDate();
+ if (err) {
+ log.warn("Couldn't retrieve window name for id :", windowId);
+ reject();
- } else if (session.name === activityChangeTimer.crtActivityName) {
+ } else {
+ resolve(properties.length && properties[0].value);
+ }
+ });
+ }
+ });
+ }
- // The user is back to the window from which we initiated the activity timer,
- // it seems to indicate that he is still working on the same activity. Let's clear the timer.
-
- clearTimeout(activityChangeTimer);
- }
+ registerWindowEvents(xClient, ev) {
+ this.getActiveWindowId(xClient, ev)
+ .then(function(wid) {
+ xClient.ChangeWindowAttributes(wid, {
+ eventMask: x11.eventMask.PropertyChange
+ });
+ });
}
-};
-/**
- * Current active window is still the same
- * but it's title has changed.
- * Trace it by creating a new session with the same shape attributes than the previous one
- */
-var updateWindowSession = function(ev) {
- return getWindowName(ev.wid)
- .then(function(windowName) {
+ setupActivityDetection(session) {
+ if (this.disableActivityDetection || !session || !timer.getTime()) {
- // Let's create a new session but with same color attributes than the last one,
- // since the active window has not really changed, only some of its attributes
+ clearTimeout(this.activityChangeTimer); // stop activity detection
- var crtSession = scope.sessions.getCrtSession();
- if (crtSession && crtSession.name !== windowName) {
- scope.sessions.createNewSession(windowName, crtSession.color);
- }
+ } else {
- });
-};
+ var now = moment();
+ if (now.diff(session.startDate, "m") >= config.getActivityTime()) {
-/**
- * Create a new window session
- */
-var addWindowSession = function(xClient, ev) {
- var ss = scope.sessions;
- var crtSession = ss.getCrtSession();
+ // The user has stayed more than "config.getActivityTime()" minutes on a window
+ // and now has just switched to another window.
+ // If it stays at list as long as he did on the previous one, let's notify it to him
- return getActiveWindowId(xClient, ev)
- .then(getWindowName)
- .then(ss.createNewSession.bind(ss))
- .then(setupActivityDetection.bind(null, crtSession));
-};
+ this.activityChangeTimer = setTimeout(
+ eventEmitter.emit.bind(eventEmitter, "onActivityChange", now.toDate()),
+ moment.duration(config.getActivityTime(), "m").as("ms")
+ );
+ this.activityChangeTimer.crtActivityName = session.name;
+ this.activityChangeTimer.changeDetectedDate = now.toDate();
-///////////////
-// Exports //
-///////////////
+ } else if (session.name === this.activityChangeTimer.crtActivityName) {
-/**
- * Offers an api for services interesting in activity change detection
- */
-exports.subscribeActivityChange = function(callback) {
- eventEmitter.on("onActivityChange", callback);
-};
+ // The user is back to the window from which we initiated the activity timer,
+ // it seems to indicate that he is still working on the same activity. Let's clear the timer.
-exports.getActivityChangeDetectedDate = function() {
- return activityChangeTimer && activityChangeTimer.changeDetectedDate;
-};
+ clearTimeout(this.activityChangeTimer);
+ }
+ }
+ }
-exports.suspendActivityDetection = function() {
- disableActivityDetection = true;
- clearTimeout(activityChangeTimer);
-};
+ /**
+ * Current active window is still the same
+ * but it's title has changed.
+ * Trace it by creating a new session with the same shape attributes than the previous one
+ */
+ updateWindowSession(ev) {
+ return this.getWindowName(ev.wid)
+ .then(function(windowName) {
-exports.resumeActivityDetection = function() {
- disableActivityDetection = false;
-};
+ // Let's create a new session but with same color attributes than the last one,
+ // since the active window has not really changed, only some of its attributes
+ var crtSession = sessions.getCrtSession();
+ if (crtSession && crtSession.name !== windowName) {
+ sessions.createNewSession(windowName, crtSession.color);
+ }
-///////////////////////////////
-// Init activity detection //
-///////////////////////////////
+ });
+ }
-/*
- * Listen to active window change and window title change
- * Some part of the code has been derived from :
- * http://stackoverflow.com/questions/19840459/linux-get-notification-on-focus…
- */
-x11.createClient(function(err, display) {
- var xClient = display.client;
+ /**
+ * Create a new window session
+ */
+ addWindowSession(xClient, ev) {
+ var crtSession = sessions.getCrtSession();
- xClient.ChangeWindowAttributes(display.screen[0].root, {
- eventMask: x11.eventMask.PropertyChange
- });
+ return this.getActiveWindowId(xClient, ev)
+ .then(this.getWindowName.bind(this))
+ .then(sessions.createNewSession.bind(sessions))
+ .then(this.setupActivityDetection.bind(this, crtSession));
+ };
- // Init windows session with the currently active window
-// addWindowSession(X, display.screen[0].root);
+ /**
+ * Offers an api for services interesting in activity change detection
+ */
+ subscribeActivityChange(callback) {
+ eventEmitter.on("onActivityChange", callback);
+ }
- // Listen to client display events to identify when the currently active window has change
- xClient.on("event", onActiveWindowChange.bind(null, xClient));
-});
+ getActivityChangeDetectedDate() {
+ return this.activityChangeTimer && this.activityChangeTimer.changeDetectedDate;
+ }
-/**
- * Subscriber to timer change :
- * If timer change occured while activity change detection is on going,
- * stop activity change detection process (means the user has handled it)
- */
-scope.timer.subscribeTimeChanged(function() {
- if (!scope.timer.getTime()) {
- clearTimeout(activityChangeTimer);
+ suspendActivityDetection() {
+ this.disableActivityDetection = true;
+ clearTimeout(this.activityChangeTimer);
}
-});
+
+ resumeActivityDetection() {
+ this.disableActivityDetection = false;
+ }
+}
+
+// Export UserActivityService as a singleton
+
+UserActivityService.instance = null;
+UserActivityService.getInstance = function() {
+ if (this.instance === null) {
+ this.instance = new UserActivityService();
+ }
+ return this.instance;
+};
+
+module.exports = UserActivityService.getInstance();
1
0
Author: jruchaud
Date: 2015-05-26 15:59:19 +0000 (Tue, 26 May 2015)
New Revision: 1499
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1499
Log:
Create GuiManager
Added:
wit/js/GuiManager.js
Removed:
wit/js/gui.js
wit/pages/test.html
Modified:
wit/js/main.js
wit/pages/activityChange.html
wit/pages/idle.html
Added: wit/js/GuiManager.js
===================================================================
--- wit/js/GuiManager.js (rev 0)
+++ wit/js/GuiManager.js 2015-05-26 15:59:19 UTC (rev 1499)
@@ -0,0 +1,85 @@
+"use strict";
+
+var gui = global.window.nwDispatcher.requireNwGui();
+//var timer = require("./services/TimerService.js");
+//var user = require("./services/UserActivityService.js");
+
+class GuiManager {
+
+ constructor() {
+ this.createTray();
+
+ this.popups = [];
+
+ // Subscriptions to services
+ //timer.subscribeIdle(this.openWindow.bind(this, "idle.html"));
+ //user.subscribeActivityChange(this.openWindow.bind(this, "activityChange.html"));
+ }
+
+ createTray() {
+ // Reference to window and tray
+ var win = gui.Window.get();
+ win.removeAllListeners("minimize");
+
+ var tray;
+
+ // Get the minimize event
+ win.on("minimize", function() {
+ tray = new gui.Tray({icon: "img/stopwatch-34108_640.png"});
+
+ var menu = new gui.Menu();
+ menu.append(new gui.MenuItem({label: "play"}));
+ menu.append(new gui.MenuItem({label: "stop"}));
+ tray.menu = menu;
+
+ // Show window and remove tray when clicked
+ tray.on("click", function() {
+ win.show();
+ this.remove();
+ tray = null;
+ });
+
+ // Hide window
+ this.hide();
+ });
+
+ win.on("focus", function() {
+ if (tray) {
+ tray.remove();
+ tray = null;
+ }
+ });
+ }
+
+ // global.guiManager.openWindow("idle.html")
+ openWindow(file) {
+ var current = gui.Window.get();
+ current.hide();
+
+ user.suspendActivityDetection();
+
+ var window = gui.Window.open(file, {
+ position: "center",
+ focus: true,
+ toolbar: false,
+ frame: true,
+ width: 480,
+ height: 300
+ });
+
+ this.popups.push(window);
+
+ window.on("close", function() {
+ this.hide(); // Pretend to be closed already
+ this.close(true);
+
+ this.popups.splice(this.popups.indexOf(window), 1);
+
+ if (!this.popups.length) {
+ current.show();
+ }
+ });
+ }
+}
+
+module.exports = GuiManager;
Deleted: wit/js/gui.js
===================================================================
--- wit/js/gui.js 2015-05-26 15:35:57 UTC (rev 1498)
+++ wit/js/gui.js 2015-05-26 15:59:19 UTC (rev 1499)
@@ -1,73 +0,0 @@
-"use strict";
-
-// Load library
-var gui = require("nw.gui");
-
-// Reference to window and tray
-var win = gui.Window.get();
-win.removeAllListeners("minimize");
-
-var tray;
-
-// Get the minimize event
-win.on("minimize", function() {
- tray = new gui.Tray({icon: "img/stopwatch-34108_640.png"});
-
- var menu = new gui.Menu();
- menu.append(new gui.MenuItem({label: "play"}));
- menu.append(new gui.MenuItem({label: "stop"}));
- tray.menu = menu;
-
- // Show window and remove tray when clicked
- tray.on("click", function() {
- win.show();
- this.remove();
- tray = null;
- });
-
- // Hide window
- this.hide();
-});
-
-win.on("focus", function() {
- if (tray) {
- tray.remove();
- tray = null;
- }
-});
-
-var popups = [];
-var openWindow = function(file) {
- var gui = global.window.nwDispatcher.requireNwGui();
-
- var current = gui.Window.get();
- current.hide();
-
- scope.user.suspendActivityDetection();
-
- var window = gui.Window.open(file, {
- position: "center",
- focus: true,
- toolbar: false,
- frame: true,
- width: 480,
- height: 300
- });
-
- popups.push(window);
-
- window.on("close", function() {
- this.hide(); // Pretend to be closed already
- this.close(true);
-
- popups.splice(popups.indexOf(window), 1);
-
- if (!popups.length) {
- current.show();
- }
- });
-};
-
-// Subscriptions to services
-scope.timer.subscribeIdle(openWindow.bind(null, "idle.html"));
-scope.user.subscribeActivityChange(openWindow.bind(null, "activityChange.html"));
Modified: wit/js/main.js
===================================================================
--- wit/js/main.js 2015-05-26 15:35:57 UTC (rev 1498)
+++ wit/js/main.js 2015-05-26 15:59:19 UTC (rev 1499)
@@ -7,16 +7,16 @@
// Alias
// Total time during day
-var noTimer = require("./services/NoTimerService.js");
+var noTimer = require("./services/NoTimerService");
noTimer.detect();
-//var printer = require("./js/services/PrinterService.js");
-//scope.printer = printer;
+var GuiManager = require("./GuiManager");
+global.guiManager = new GuiManager();
// React conf //
window.onload = function() {
var React = require("react");
- var App = require("./App.js");
+ var App = require("./App");
React.render(<App/>, document.body);
};
Modified: wit/pages/activityChange.html
===================================================================
--- wit/pages/activityChange.html 2015-05-26 15:35:57 UTC (rev 1498)
+++ wit/pages/activityChange.html 2015-05-26 15:59:19 UTC (rev 1499)
@@ -1,7 +1,7 @@
<html>
<head>
<title>WIT activity</title>
- <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
+ <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
<style>
h1 {
@@ -12,8 +12,8 @@
<script>
var gui = require('nw.gui');
var window = gui.Window.get();
- var timer = global.scope.timer;
- var user = global.user;
+ var timer = require("../build/services/TimerService.js");
+ var user = require("../build/services/UserActivityService.js");
var keepTiming = function() {
user.resumeActivityDetection();
Modified: wit/pages/idle.html
===================================================================
--- wit/pages/idle.html 2015-05-26 15:35:57 UTC (rev 1498)
+++ wit/pages/idle.html 2015-05-26 15:59:19 UTC (rev 1499)
@@ -1,7 +1,7 @@
<html>
<head>
<title>WIT idle</title>
- <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
+ <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
<style>
h1 {
@@ -12,7 +12,7 @@
<script>
var gui = require('nw.gui');
var window = gui.Window.get();
- var timer = global.scope.timer;
+ var timer = require("../build/services/TimerService.js");
var keepIdle = function() {
timer.keepIdle();
Deleted: wit/pages/test.html
===================================================================
--- wit/pages/test.html 2015-05-26 15:35:57 UTC (rev 1498)
+++ wit/pages/test.html 2015-05-26 15:59:19 UTC (rev 1499)
@@ -1,69 +0,0 @@
-<html>
- <head>
- <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
- <style>
- @font-face {
- font-family: Digital;
- src: url(../font/DIGITALDREAM.ttf);
- }
-
- .digit {
- font-family: Digital;
- text-align: center;
- }
-
- .nav > li > a {
- padding: 15px;
- }
-
- </style>
- </head>
- <body>
- <div class="container-fluid">
-
- <div class="navbar navbar-default">
- <div class="navbar-header pull-left">
- <a class="navbar-brand" href="#">WIT</a>
- </div>
-
- <div class="nav navbar-header pull-right">
- <ul class="nav pull-right">
- <li class="pull-left"><a href="#">Timer</a></li>
- <li class="pull-left"><a href="#">Rapport</a></li>
- <li class="pull-left"><a href="#">Tags</a></li>
- <li class="pull-left"><a href="#">Options</a></li>
- </ul>
- </div>
- </div>
-
- <h1 class="digit">00:00:00</h1>
-
- <ul class="list-group">
- <li class="list-group-item">Cras justo odio</li>
- <li class="list-group-item">Dapibus ac facilisis in</li>
- <li class="list-group-item">Morbi leo risus</li>
- <li class="list-group-item">Porta ac consectetur ac</li>
- <li class="list-group-item">Vestibulum at eros</li>
- </ul>
-
- <div class="text-center">
- <div class="btn-group" role="group">
- <button type="button" class="btn btn-primary btn-lg">
- <span class="glyphicon glyphicon-backward" aria-hidden="true"></span>
- </button>
- <button type="button" class="btn btn-primary btn-lg">
- <span class="glyphicon glyphicon-play" aria-hidden="true"></span>
- </button>
- <button type="button" class="btn btn-primary btn-lg">
- <span class="glyphicon glyphicon-stop" aria-hidden="true"></span>
- </button>
- <button type="button" class="btn btn-primary btn-lg">
- <span class="glyphicon glyphicon-forward" aria-hidden="true"></span>
- </button>
- </div>
- </div>
-
- </div>
-
- </body>
-</html>
\ No newline at end of file
1
0
26 May '15
Author: jruchaud
Date: 2015-05-26 15:35:57 +0000 (Tue, 26 May 2015)
New Revision: 1498
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1498
Log:
Reorganize html
Added:
wit/js/components/root/
wit/js/components/root/EditionLogs.js
wit/js/components/root/Options.js
wit/js/components/root/Rapport.js
wit/js/components/root/Timer.js
wit/pages/
wit/pages/activityChange.html
wit/pages/idle.html
wit/pages/index.html
wit/pages/test.html
Removed:
wit/activityChange.html
wit/idle.html
wit/index.html
wit/js/pages/
wit/test.html
Modified:
wit/js/main.js
wit/package.json
Deleted: wit/activityChange.html
===================================================================
--- wit/activityChange.html 2015-05-26 15:19:33 UTC (rev 1497)
+++ wit/activityChange.html 2015-05-26 15:35:57 UTC (rev 1498)
@@ -1,55 +0,0 @@
-<html>
- <head>
- <title>WIT activity</title>
- <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
-
- <style>
- h1 {
- text-align: center;
- }
- </style>
-
- <script>
- var gui = require('nw.gui');
- var window = gui.Window.get();
- var timer = global.scope.timer;
- var user = global.user;
-
- var keepTiming = function() {
- user.resumeActivityDetection();
- window.close();
- };
- var stopTiming = function() {
- timer.stop();
- window.close();
- };
- var startNewActivity = function() {
- timer.reassignTimeFrom(user.getActivityChangeDetectedDate());
- window.close();
- };
-
- timer.subscribeIdle(window.close.bind(window));
- </script>
- </head>
-
- <body>
- <div class="container-fluid">
- <h1>Activity change detected</h1>
- <div class="alert alert-danger" role="alert"> Are you still working on the same activity ?</div>
-
- <button type="button" class="btn btn-primary btn-lg btn-block" onclick="keepTiming()">
- <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
- Yes ! Please keep timing current activity
- </button>
- <button type="button" class="btn btn-primary btn-lg btn-block" onclick="stopTiming()">
- <span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
- No, stop the timer !
- </button>
- <button type="button" class="btn btn-primary btn-lg btn-block" onclick="startNewActivity()">
- <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
- No, right, i would like to time a new activity.
- </button>
- </div>
- </body>
-
-</html>
Deleted: wit/idle.html
===================================================================
--- wit/idle.html 2015-05-26 15:19:33 UTC (rev 1497)
+++ wit/idle.html 2015-05-26 15:35:57 UTC (rev 1498)
@@ -1,52 +0,0 @@
-<html>
- <head>
- <title>WIT idle</title>
- <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
-
- <style>
- h1 {
- text-align: center;
- }
- </style>
-
- <script>
- var gui = require('nw.gui');
- var window = gui.Window.get();
- var timer = global.scope.timer;
-
- var keepIdle = function() {
- timer.keepIdle();
- window.close();
- };
- var removeIdle = function() {
- timer.removeIdle();
- window.close();
- };
- var reassignIdle = function() {
- timer.reassignIdle();
- window.close();
- };
- </script>
- </head>
-
- <body>
- <div class="container-fluid">
- <h1>Idle detected</h1>
- <div class="alert alert-danger" role="alert">Idle detcted, please select your option:</div>
-
- <button type="button" class="btn btn-primary btn-lg btn-block" onclick="keepIdle()">
- <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
- Keep idle for current time
- </button>
- <button type="button" class="btn btn-primary btn-lg btn-block" onclick="removeIdle()">
- <span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
- Remove idle for current time
- </button>
- <button type="button" class="btn btn-primary btn-lg btn-block" onclick="reassignIdle()">
- <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
- Reassign idle time
- </button>
- </div>
- </body>
-
-</html>
Deleted: wit/index.html
===================================================================
--- wit/index.html 2015-05-26 15:19:33 UTC (rev 1497)
+++ wit/index.html 2015-05-26 15:35:57 UTC (rev 1498)
@@ -1,20 +0,0 @@
-<html>
- <head>
- <title>WIT</title>
-
- <script>
- global.document = window.document;
- global.navigator = window.navigator;
- global.localStorage = window.localStorage;
- </script>
-
- <script async="true" type="text/javascript" src="build/main.js"></script>
-
- <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
- <link rel="stylesheet" type="text/css" href="build/style.css" />
- <link rel="stylesheet" type="text/css" href="build/timeline.css" />
- </head>
-
- <body></body>
-
-</html>
Added: wit/js/components/root/EditionLogs.js
===================================================================
--- wit/js/components/root/EditionLogs.js (rev 0)
+++ wit/js/components/root/EditionLogs.js 2015-05-26 15:35:57 UTC (rev 1498)
@@ -0,0 +1,55 @@
+"use strict";
+
+var moment = require("moment");
+var db = require("../services/database");
+
+var React = require("react");
+var FilterBar = require("../components/FilterBar");
+var LogsTable = require("../components/LogsTable");
+
+class EditionLogs extends React.Component {
+
+ constructor(props) {
+ super(props);
+ this.state = {
+ startDate: moment().subtract(1, "h"),
+ endDate: moment(),
+ result: null
+ };
+ }
+
+ handleSearchResult(result, startDate, endDate) {
+ this.setState({
+ startDate: startDate,
+ endDate: endDate,
+ result: result
+ });
+ }
+
+ onAdd() {
+
+ var tags = this.refs.tags.getDOMNode().value.split(",");
+ var startDate = moment(this.refs.beginDate.getDOMNode().value);
+ var endDate = moment(this.refs.endDate.getDOMNode().value);
+
+ return db.insertLog(tags, startDate, endDate);
+ }
+
+ render() {
+ return <div>
+ <h1>Search log</h1>
+ <FilterBar onSearchResult={this.handleSearchResult}/>
+ <LogsTable data={this.state.result}/>
+
+ <div>
+ <h1>Add log</h1>
+ <input ref="beginDate" type="datetime-local" className="form-control" required></input>
+ <input ref="endDate" type="datetime-local" className="form-control" required></input>
+ <input ref="tags" type="text" className="form-control" required placeholder="Enter tags with comma"></input>
+ <button onClick={this.onAdd} className="btn btn-primary btn-block">Add</button>
+ </div>
+ </div>;
+ }
+}
+
+module.exports = EditionLogs;
Added: wit/js/components/root/Options.js
===================================================================
--- wit/js/components/root/Options.js (rev 0)
+++ wit/js/components/root/Options.js 2015-05-26 15:35:57 UTC (rev 1498)
@@ -0,0 +1,71 @@
+"use strict";
+
+var React = require("react");
+var config = require("../services/ConfigurationService");
+
+class Options extends React.Component {
+
+ setIdleTime(e) {
+ config.setIdleTime(e.target.value);
+ }
+
+ setActivityTime(e) {
+ config.setActivityTime(e.target.value);
+ }
+
+ setNoTimer(e) {
+ config.setNoTimer(e.target.value);
+ }
+
+ setWeekDay(e) {
+ config.setWeekDay(e.target.value);
+ }
+
+ render() {
+ var idleTime = config.getIdleTime();
+ var activityTime = config.getActivityTime();
+ var noTimer = config.getNoTimer();
+ var weekDay = config.getWeekDay();
+
+ return <div className="form-horizontal">
+
+ <div className="form-group">
+ <label for="idleTime" className="col-sm-2 control-label">Idle time (minutes)</label>
+ <div className="col-sm-10">
+ <input type="number" className="form-control" defaultValue={idleTime} min="0" step="1" onChange={this.setIdleTime}/>
+ </div>
+ </div>
+
+ <div className="form-group">
+ <label for="idleTime" className="col-sm-2 control-label">Activity time (minutes)</label>
+ <div className="col-sm-10">
+ <input type="number" className="form-control" id="activityTime" defaultValue={activityTime} min="0" step="1" onChange={this.setActivityTime}/>
+ </div>
+ </div>
+
+ <div className="form-group">
+ <label for="noTimer" className="col-sm-2 control-label">No timer (minutes)</label>
+ <div className="col-sm-10">
+ <input type="number" className="form-control" defaultValue={noTimer} min="0" step="1" onChange={this.setNoTimer}/>
+ </div>
+ </div>
+
+ <div className="form-group">
+ <label for="idleTime" className="col-sm-2 control-label">Week day</label>
+ <div className="col-sm-10">
+ <select name="select" className="form-control" id="weekDay" defaultValue={weekDay} onChange={this.setWeekDay}>
+ <option value="0">monday</option>
+ <option value="1">tuesday</option>
+ <option value="2">wednesday</option>
+ <option value="3">thursday</option>
+ <option value="4">friday</option>
+ <option value="5">saturday</option>
+ <option value="6">sunday</option>
+ </select>
+ </div>
+ </div>
+ </div>;
+ }
+}
+
+module.exports = Options;
Added: wit/js/components/root/Rapport.js
===================================================================
--- wit/js/components/root/Rapport.js (rev 0)
+++ wit/js/components/root/Rapport.js 2015-05-26 15:35:57 UTC (rev 1498)
@@ -0,0 +1,36 @@
+"use strict";
+
+var moment = require("moment");
+
+var React = require("react");
+var FilterBar = require("../components/FilterBar");
+var FilterLogs = require("../components/FilterLogs");
+
+class Rapport extends React.Component {
+
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ startDate: moment().subtract(1, "h"),
+ endDate: moment(),
+ result: []
+ };
+ }
+
+ handleSearchResult(result) {
+ this.setState({
+ result: result
+ });
+ }
+
+ render() {
+ return <div>
+ <h1>Search by date</h1>
+ <FilterBar onSearchResult={this.handleSearchResult}/>
+ <FilterLogs data={this.state}/>
+ </div>;
+ }
+}
+
+module.exports = Rapport;
Added: wit/js/components/root/Timer.js
===================================================================
--- wit/js/components/root/Timer.js (rev 0)
+++ wit/js/components/root/Timer.js 2015-05-26 15:35:57 UTC (rev 1498)
@@ -0,0 +1,18 @@
+"use strict";
+
+var React = require("react");
+var Tags = require("../components/Tags");
+var Time = require("../components/Time");
+var ActionsBar = require("../components/ActionsBar");
+
+class Timer extends React.Component {
+ render() {
+ return <div>
+ <Time />
+ <Tags />
+ <ActionsBar />
+ </div>;
+ }
+}
+
+module.exports = Timer;
Modified: wit/js/main.js
===================================================================
--- wit/js/main.js 2015-05-26 15:19:33 UTC (rev 1497)
+++ wit/js/main.js 2015-05-26 15:35:57 UTC (rev 1498)
@@ -7,7 +7,7 @@
// Alias
// Total time during day
-var noTimer = require("./js/services/NoTimerService.js");
+var noTimer = require("./services/NoTimerService.js");
noTimer.detect();
//var printer = require("./js/services/PrinterService.js");
@@ -16,7 +16,7 @@
// React conf //
window.onload = function() {
var React = require("react");
- var App = require("./build/App.js");
+ var App = require("./App.js");
React.render(<App/>, document.body);
};
Modified: wit/package.json
===================================================================
--- wit/package.json 2015-05-26 15:19:33 UTC (rev 1497)
+++ wit/package.json 2015-05-26 15:35:57 UTC (rev 1498)
@@ -1,6 +1,6 @@
{
"name": "wit",
- "main": "index.html",
+ "main": "./pages/index.html",
"version": "1.0.0",
"single-instance": false,
"window": {
@@ -36,7 +36,6 @@
},
"devDependencies": {
"del": "^1.2.0",
- "grunt": "^0.4.5",
"grunt-node-webkit-builder": "^1.0.2",
"gulp": "^3.8.11",
"gulp-babel": "^5.1.0",
Added: wit/pages/activityChange.html
===================================================================
--- wit/pages/activityChange.html (rev 0)
+++ wit/pages/activityChange.html 2015-05-26 15:35:57 UTC (rev 1498)
@@ -0,0 +1,55 @@
+<html>
+ <head>
+ <title>WIT activity</title>
+ <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
+
+ <style>
+ h1 {
+ text-align: center;
+ }
+ </style>
+
+ <script>
+ var gui = require('nw.gui');
+ var window = gui.Window.get();
+ var timer = global.scope.timer;
+ var user = global.user;
+
+ var keepTiming = function() {
+ user.resumeActivityDetection();
+ window.close();
+ };
+ var stopTiming = function() {
+ timer.stop();
+ window.close();
+ };
+ var startNewActivity = function() {
+ timer.reassignTimeFrom(user.getActivityChangeDetectedDate());
+ window.close();
+ };
+
+ timer.subscribeIdle(window.close.bind(window));
+ </script>
+ </head>
+
+ <body>
+ <div class="container-fluid">
+ <h1>Activity change detected</h1>
+ <div class="alert alert-danger" role="alert"> Are you still working on the same activity ?</div>
+
+ <button type="button" class="btn btn-primary btn-lg btn-block" onclick="keepTiming()">
+ <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
+ Yes ! Please keep timing current activity
+ </button>
+ <button type="button" class="btn btn-primary btn-lg btn-block" onclick="stopTiming()">
+ <span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
+ No, stop the timer !
+ </button>
+ <button type="button" class="btn btn-primary btn-lg btn-block" onclick="startNewActivity()">
+ <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
+ No, right, i would like to time a new activity.
+ </button>
+ </div>
+ </body>
+
+</html>
Added: wit/pages/idle.html
===================================================================
--- wit/pages/idle.html (rev 0)
+++ wit/pages/idle.html 2015-05-26 15:35:57 UTC (rev 1498)
@@ -0,0 +1,52 @@
+<html>
+ <head>
+ <title>WIT idle</title>
+ <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
+
+ <style>
+ h1 {
+ text-align: center;
+ }
+ </style>
+
+ <script>
+ var gui = require('nw.gui');
+ var window = gui.Window.get();
+ var timer = global.scope.timer;
+
+ var keepIdle = function() {
+ timer.keepIdle();
+ window.close();
+ };
+ var removeIdle = function() {
+ timer.removeIdle();
+ window.close();
+ };
+ var reassignIdle = function() {
+ timer.reassignIdle();
+ window.close();
+ };
+ </script>
+ </head>
+
+ <body>
+ <div class="container-fluid">
+ <h1>Idle detected</h1>
+ <div class="alert alert-danger" role="alert">Idle detcted, please select your option:</div>
+
+ <button type="button" class="btn btn-primary btn-lg btn-block" onclick="keepIdle()">
+ <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
+ Keep idle for current time
+ </button>
+ <button type="button" class="btn btn-primary btn-lg btn-block" onclick="removeIdle()">
+ <span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
+ Remove idle for current time
+ </button>
+ <button type="button" class="btn btn-primary btn-lg btn-block" onclick="reassignIdle()">
+ <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
+ Reassign idle time
+ </button>
+ </div>
+ </body>
+
+</html>
Added: wit/pages/index.html
===================================================================
--- wit/pages/index.html (rev 0)
+++ wit/pages/index.html 2015-05-26 15:35:57 UTC (rev 1498)
@@ -0,0 +1,20 @@
+<html>
+ <head>
+ <title>WIT</title>
+
+ <script>
+ global.document = window.document;
+ global.navigator = window.navigator;
+ global.localStorage = window.localStorage;
+
+ var main = require("../build/main.js");
+ </script>
+
+ <link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
+ <link rel="stylesheet" type="text/css" href="../build/style.css" />
+ <link rel="stylesheet" type="text/css" href="../build/timeline.css" />
+ </head>
+
+ <body></body>
+
+</html>
Added: wit/pages/test.html
===================================================================
--- wit/pages/test.html (rev 0)
+++ wit/pages/test.html 2015-05-26 15:35:57 UTC (rev 1498)
@@ -0,0 +1,69 @@
+<html>
+ <head>
+ <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
+ <style>
+ @font-face {
+ font-family: Digital;
+ src: url(../font/DIGITALDREAM.ttf);
+ }
+
+ .digit {
+ font-family: Digital;
+ text-align: center;
+ }
+
+ .nav > li > a {
+ padding: 15px;
+ }
+
+ </style>
+ </head>
+ <body>
+ <div class="container-fluid">
+
+ <div class="navbar navbar-default">
+ <div class="navbar-header pull-left">
+ <a class="navbar-brand" href="#">WIT</a>
+ </div>
+
+ <div class="nav navbar-header pull-right">
+ <ul class="nav pull-right">
+ <li class="pull-left"><a href="#">Timer</a></li>
+ <li class="pull-left"><a href="#">Rapport</a></li>
+ <li class="pull-left"><a href="#">Tags</a></li>
+ <li class="pull-left"><a href="#">Options</a></li>
+ </ul>
+ </div>
+ </div>
+
+ <h1 class="digit">00:00:00</h1>
+
+ <ul class="list-group">
+ <li class="list-group-item">Cras justo odio</li>
+ <li class="list-group-item">Dapibus ac facilisis in</li>
+ <li class="list-group-item">Morbi leo risus</li>
+ <li class="list-group-item">Porta ac consectetur ac</li>
+ <li class="list-group-item">Vestibulum at eros</li>
+ </ul>
+
+ <div class="text-center">
+ <div class="btn-group" role="group">
+ <button type="button" class="btn btn-primary btn-lg">
+ <span class="glyphicon glyphicon-backward" aria-hidden="true"></span>
+ </button>
+ <button type="button" class="btn btn-primary btn-lg">
+ <span class="glyphicon glyphicon-play" aria-hidden="true"></span>
+ </button>
+ <button type="button" class="btn btn-primary btn-lg">
+ <span class="glyphicon glyphicon-stop" aria-hidden="true"></span>
+ </button>
+ <button type="button" class="btn btn-primary btn-lg">
+ <span class="glyphicon glyphicon-forward" aria-hidden="true"></span>
+ </button>
+ </div>
+ </div>
+
+ </div>
+
+ </body>
+</html>
\ No newline at end of file
Deleted: wit/test.html
===================================================================
--- wit/test.html 2015-05-26 15:19:33 UTC (rev 1497)
+++ wit/test.html 2015-05-26 15:35:57 UTC (rev 1498)
@@ -1,69 +0,0 @@
-<html>
- <head>
- <link rel="stylesheet" href="./node_modules/bootstrap/dist/css/bootstrap.min.css">
- <style>
- @font-face {
- font-family: Digital;
- src: url(../font/DIGITALDREAM.ttf);
- }
-
- .digit {
- font-family: Digital;
- text-align: center;
- }
-
- .nav > li > a {
- padding: 15px;
- }
-
- </style>
- </head>
- <body>
- <div class="container-fluid">
-
- <div class="navbar navbar-default">
- <div class="navbar-header pull-left">
- <a class="navbar-brand" href="#">WIT</a>
- </div>
-
- <div class="nav navbar-header pull-right">
- <ul class="nav pull-right">
- <li class="pull-left"><a href="#">Timer</a></li>
- <li class="pull-left"><a href="#">Rapport</a></li>
- <li class="pull-left"><a href="#">Tags</a></li>
- <li class="pull-left"><a href="#">Options</a></li>
- </ul>
- </div>
- </div>
-
- <h1 class="digit">00:00:00</h1>
-
- <ul class="list-group">
- <li class="list-group-item">Cras justo odio</li>
- <li class="list-group-item">Dapibus ac facilisis in</li>
- <li class="list-group-item">Morbi leo risus</li>
- <li class="list-group-item">Porta ac consectetur ac</li>
- <li class="list-group-item">Vestibulum at eros</li>
- </ul>
-
- <div class="text-center">
- <div class="btn-group" role="group">
- <button type="button" class="btn btn-primary btn-lg">
- <span class="glyphicon glyphicon-backward" aria-hidden="true"></span>
- </button>
- <button type="button" class="btn btn-primary btn-lg">
- <span class="glyphicon glyphicon-play" aria-hidden="true"></span>
- </button>
- <button type="button" class="btn btn-primary btn-lg">
- <span class="glyphicon glyphicon-stop" aria-hidden="true"></span>
- </button>
- <button type="button" class="btn btn-primary btn-lg">
- <span class="glyphicon glyphicon-forward" aria-hidden="true"></span>
- </button>
- </div>
- </div>
-
- </div>
-
- </body>
-</html>
\ No newline at end of file
1
0
Author: jruchaud
Date: 2015-05-26 15:19:33 +0000 (Tue, 26 May 2015)
New Revision: 1497
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1497
Log:
Create PrinterService
Added:
wit/js/services/PrinterService.js
Removed:
wit/js/utils/
Added: wit/js/services/PrinterService.js
===================================================================
--- wit/js/services/PrinterService.js (rev 0)
+++ wit/js/services/PrinterService.js 2015-05-26 15:19:33 UTC (rev 1497)
@@ -0,0 +1,98 @@
+"use strict";
+
+class Printer {
+
+ constructor() {
+ this.contentFormatters = {
+ csv: this._getCSV.bind(this),
+ txt: this._getTXT.bind(this)
+ };
+ }
+
+ static get CSV() {
+ return "csv";
+ }
+
+ static get TXT() {
+ return "txt";
+ }
+
+ _getCSV() {
+ let result = "";
+
+ let nodes = document.querySelectorAll("tr");
+ for (let r = 0, lr = nodes.length; r < lr; r++) {
+ let row = nodes[r].children;
+
+ for (let c = 0, lc = row.length; c < lc; c++) {
+ let col = row[c];
+ result += col.textContent + ";";
+ }
+ result += "\n";
+ }
+
+ return result;
+ }
+
+ _getTXT(logs) {
+ let result = "";
+
+ let dates = Object.keys(logs.data);
+ for (let date of dates) {
+ result += date + "\n--------\n";
+ result += "\n" + this._getTXTRow(logs.tags, date, [], logs.data[date]) + "\n";
+ }
+
+ return result;
+ }
+
+ _getTXTRow(existingTags, date, tags, tagObject) {
+ let r = "";
+
+ if (tagObject.duration) {
+ let filterTags = tags.filter(function(tag) {
+ return existingTags[tag];
+ });
+
+ if (filterTags.length) {
+ r += tagObject.duration + " - " + filterTags.join(", ") + "\n";
+ }
+ }
+
+ let keys = Object.keys(tagObject);
+ for (let k of keys) {
+ if (k !== "diff" && k !== "duration") {
+ r += this._getTXTRow(existingTags, date, tags.concat(k), tagObject[k]);
+ }
+ }
+
+ return r;
+ }
+
+ clipboard(format, logs) {
+ let formatter = this.contentFormatters[format];
+
+ if (formatter) {
+ let content = formatter(logs);
+
+ let gui = require("nw.gui");
+ let clipboard = gui.Clipboard.get();
+
+ clipboard.set(content, "text");
+ }
+ }
+
+ mail(format, logs) {
+ let formatter = this.contentFormatters[format];
+
+ if (formatter) {
+ let content = formatter(logs);
+ content = content.replace(/\n/g, "%0A").replace(/;/g, "%3B").replace(/-/g, "%2D");
+
+ let link = "mailto:?body=" + content;
+ window.location.href = link;
+ }
+ }
+}
+
+module.exports = Printer;
1
0
Author: jruchaud
Date: 2015-05-26 15:01:53 +0000 (Tue, 26 May 2015)
New Revision: 1496
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1496
Log:
Fix router
Modified:
wit/js/components/FilterBar.js
wit/js/components/FilterLogs.js
wit/js/components/LogsTable.js
wit/js/components/Timeline.js
Modified: wit/js/components/FilterBar.js
===================================================================
--- wit/js/components/FilterBar.js 2015-05-26 14:47:48 UTC (rev 1495)
+++ wit/js/components/FilterBar.js 2015-05-26 15:01:53 UTC (rev 1496)
@@ -1,11 +1,12 @@
"use strict";
var React = require("react");
+var moment = require("moment");
+var db = require("../services/database.js");
class FilterBar extends React.Component {
componentDidMount() {
- var moment = require("moment");
var now = moment();
now.add(1, "days");
@@ -19,9 +20,6 @@
}
search() {
- var moment = require("moment");
- var db = require("./js/services/database.js");
-
var startDate = moment(this.refs.beginDate.getDOMNode().value),
endDate = moment(this.refs.endDate.getDOMNode().value);
Modified: wit/js/components/FilterLogs.js
===================================================================
--- wit/js/components/FilterLogs.js 2015-05-26 14:47:48 UTC (rev 1495)
+++ wit/js/components/FilterLogs.js 2015-05-26 15:01:53 UTC (rev 1496)
@@ -2,29 +2,31 @@
var React = require("react");
var nonce = require("nonce")();
+var printer = require("../services/PrinterService");
+var Timeline = require("./Timeline");
+var moment = require("moment");
class FilterLogs extends React.Component {
constructor(props) {
super(props);
- this.printer = new Printer();
this.state = {data: null, tags: {}};
}
onClipboardCSV() {
- this.printer.clipboard(Printer.CSV);
+ printer.clipboard(printer.CSV);
}
onClipboardTXT() {
- this.printer.clipboard(Printer.TXT, this.state);
+ printer.clipboard(printer.TXT, this.state);
}
onMailCSV() {
- this.printer.mail(Printer.CSV);
+ printer.mail(printer.CSV);
}
onMailTXT() {
- this.printer.mail(Printer.TXT, this.state);
+ printer.mail(printer.TXT, this.state);
}
onShowSummary() {
@@ -71,7 +73,6 @@
tags = {};
currentState.data.result.forEach(function(log) {
- var moment = require("moment");
var date = moment(log.startDate).format("MM/DD/YY");
var diff = moment(moment(log.endDate).diff(log.startDate)).utcOffset(0);
Modified: wit/js/components/LogsTable.js
===================================================================
--- wit/js/components/LogsTable.js 2015-05-26 14:47:48 UTC (rev 1495)
+++ wit/js/components/LogsTable.js 2015-05-26 15:01:53 UTC (rev 1496)
@@ -2,6 +2,7 @@
var React = require("react");
var timer = require("../services/TimerService.js");
+var moment = require("moment");
class LogsTable extends React.Component {
@@ -17,7 +18,6 @@
}
render() {
- var moment = require("moment");
var items = [];
var classString = "";
Modified: wit/js/components/Timeline.js
===================================================================
--- wit/js/components/Timeline.js 2015-05-26 14:47:48 UTC (rev 1495)
+++ wit/js/components/Timeline.js 2015-05-26 15:01:53 UTC (rev 1496)
@@ -2,8 +2,9 @@
var React = require("react");
var sess = require("../services/SessionsService.js");
-
var TimelineSession = require("./TimelineSession.js");
+var moment = require("moment");
+var nonce = require("nonce")();
class Timeline extends React.Component {
@@ -13,7 +14,6 @@
}
componentDidMount() {
- var moment = require("moment");
var startDate;
if (this.props.data.startDate) {
@@ -44,8 +44,6 @@
// Create a wrapper for each window session
- var moment = require("moment");
-
var startDate;
if (this.props.data.startDate) {
startDate = moment(this.props.data.startDate);
@@ -57,8 +55,7 @@
}
var _normalize = this._normalize,
- timeRange = endDate && endDate.diff(startDate),
- nonce = require("nonce")();
+ timeRange = endDate && endDate.diff(startDate);
items = items.concat(
sessions.map(function(session) {
@@ -89,8 +86,6 @@
* this function will remove the session part outside the scope
*/
_normalize(session, startDate, endDate) {
- var moment = require("moment");
-
session.startDate = moment(session.startDate);
session.endDate = moment(session.endDate);
1
0
Author: jruchaud
Date: 2015-05-26 14:47:48 +0000 (Tue, 26 May 2015)
New Revision: 1495
Url: http://forge.nuiton.org/projects/sandbox/repository/revisions/1495
Log:
Fix router
Modified:
wit/js/App.js
wit/js/components/Tags.js
wit/js/router/Link.js
wit/js/router/Routes.js
Modified: wit/js/App.js
===================================================================
--- wit/js/App.js 2015-05-26 14:35:34 UTC (rev 1494)
+++ wit/js/App.js 2015-05-26 14:47:48 UTC (rev 1495)
@@ -35,14 +35,14 @@
<div className="nav navbar-header pull-right">
<ul className="nav pull-right">
- <li className="pull-left"><Link onClick={this.closeAll} to="Timer">Timer</Link></li>
+ <li className="pull-left"><Link onClick={this.closeAll.bind(this)} to="Timer">Timer</Link></li>
<li ref="rapportDropdown" className="dropdown pull-left">
- <a className="dropdown-toggle" onClick={this.openRapport}>
+ <a className="dropdown-toggle" onClick={this.openRapport.bind(this)}>
Rapport <span className="caret"></span>
</a>
<ul className="dropdown-menu">
- <li><Link onClick={this.closeAll} to="Rapport">By date</Link></li>
+ <li><Link onClick={this.closeAll.bind(this)} to="Rapport">By date</Link></li>
<li><a href="#">By week</a></li>
<li><a href="#">By month</a></li>
<li><a href="#">By Year</a></li>
@@ -50,17 +50,17 @@
</li>
<li ref="editionDropdown" className="dropdown pull-left">
- <a className="dropdown-toggle" onClick={this.openEdition}>
+ <a className="dropdown-toggle" onClick={this.openEdition.bind(this)}>
Edition <span className="caret"></span>
</a>
<ul className="dropdown-menu">
- <li><Link onClick={this.closeAll} to="EditionLogs">Logs</Link></li>
+ <li><Link onClick={this.closeAll.bind(this)} to="EditionLogs">Logs</Link></li>
<li><a href="#">Tags</a></li>
<li><a href="#">Activities</a></li>
</ul>
</li>
- <li className="pull-left"><Link onClick={this.closeAll} to="Options">Options</Link></li>
+ <li className="pull-left"><Link onClick={this.closeAll.bind(this)} to="Options">Options</Link></li>
</ul>
</div>
</div>
Modified: wit/js/components/Tags.js
===================================================================
--- wit/js/components/Tags.js 2015-05-26 14:35:34 UTC (rev 1494)
+++ wit/js/components/Tags.js 2015-05-26 14:47:48 UTC (rev 1495)
@@ -1,7 +1,8 @@
"use strict";
var React = require("react");
-var timer = require("../services/TimerService.js");
+var timer = require("../services/TimerService");
+var InputTag = require("./InputTag");
class Tags extends React.Component {
Modified: wit/js/router/Link.js
===================================================================
--- wit/js/router/Link.js 2015-05-26 14:35:34 UTC (rev 1494)
+++ wit/js/router/Link.js 2015-05-26 14:47:48 UTC (rev 1495)
@@ -4,16 +4,20 @@
class Link extends React.Component {
+ constructor(props) {
+ super(props);
+ }
+
goTo() {
if (this.props.onClick) {
this.props.onClick();
}
- router.display(this.props.to);
+ global.router.display(this.props.to);
}
render() {
- return <a href="#" onClick={this.goTo}>{this.props.children}</a>;
+ return <a href="#" onClick={this.goTo.bind(this)}>{this.props.children}</a>;
}
}
Modified: wit/js/router/Routes.js
===================================================================
--- wit/js/router/Routes.js 2015-05-26 14:35:34 UTC (rev 1494)
+++ wit/js/router/Routes.js 2015-05-26 14:47:48 UTC (rev 1495)
@@ -7,23 +7,21 @@
constructor(props) {
super(props);
this.state = {index: 0};
+ global.router = this;
}
- componentWillMount() {
- window.router = this;
- }
-
display(to) {
var children = this.props.children;
for (var i = 0, l = children.length; i < l; i++) {
var child = children[i];
- if (child.type.displayName === to) {
+ if (child.type.name === to) {
this.setState({index: i});
break;
}
}
+
}
getChild() {
1
0