Skip to content

Commit

Permalink
show a little indicator depending on whether the file has been found …
Browse files Browse the repository at this point in the history
…or not
  • Loading branch information
niuage committed Nov 18, 2015
1 parent 7709d4b commit a5968e8
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 24 deletions.
9 changes: 8 additions & 1 deletion app/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ <h2>Log monitoring</h2>
<p class="hint">Only the commands sent from these characters will be sent to pathofmaps.com.</p>
<textarea placeholder="Enter your character names, one on each line"><%= characters %></textarea>

<label>Path to PoE logs (Client.txt)</label>
<label>
Path to PoE logs (Client.txt)
<% if (validLogPath) { %>
<span class="check valid"></span>
<% } else { %>
<span class="check invalid"></span>
<% } %>
</label>
<p class="hint">
Full path of the Client.txt log file.
</p>
Expand Down
5 changes: 4 additions & 1 deletion app/lib/log_watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Log } from "./log"
class LogWatcher {
constructor() {
radio.channel("settings").on("change:logs_path", _.bind(function(logsPath) {
console.log(logsPath)
try {
fs.lstatSync(logsPath);
this.start(logsPath);
Expand All @@ -28,6 +27,8 @@ class LogWatcher {
start(logsPath) {
this.stop();

radio.channel("logs").trigger("watch:start");

this.setLogsFile(logsPath);

this.refreshLogsPeriodically();
Expand All @@ -47,6 +48,8 @@ class LogWatcher {
stop() {
if (!this.started) return;

radio.channel("logs").trigger("watch:stop");

this.stopRefreshing();
this.stopWatching();
this.logFile = null;
Expand Down
1 change: 0 additions & 1 deletion app/lib/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
class Map {
constructor(mapData) {
this.mapData = mapData;
console.log(this.mapData);
}

isValid() {
Expand Down
5 changes: 0 additions & 5 deletions app/lib/models/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ var Setting = Backbone.Model.extend({
},

initialize: function() {
this.set("token", window.storage.get("token"));
this.set("characters", window.storage.get("characters"));
this.set("logs_path", window.storage.get("logs_path"));

_.each(["token", "characters", "logs_path"], _.bind(function(attr) {
var changeEvent = "change:" + attr
this.on(changeEvent, function() {
console.log(attr + " changed")
radio.channel("settings").trigger(changeEvent, this.get(attr))
storage.set(attr, this.get(attr))
})
Expand Down
15 changes: 0 additions & 15 deletions app/lib/popom.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ class Popom {

this.renderSettingsForm();

// radio.channel("settings").on({
// "change:token": function(token) {
// console.log("token changed:", token)
// storage.set("token", token);
// },
// "change:characters": function(characters) {
// console.log("characters changed:", characters)
// storage.set("characters", characters);
// },
// "change:logs_path": function(logs_path) {
// console.log("logs_path changed:", logs_path)
// ;
// },
// })

app.on('window-all-closed', _.bind(this.stop, this));
}

Expand Down
29 changes: 28 additions & 1 deletion app/lib/views/settings_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,25 @@ var SettingsForm = Backbone.View.extend({
"paste [data-logs-path-input]": "logsPathChanged"
},

validLogPath: false,

initialize: function(options) {
this.render();

radio.channel("logs").on({
"watch:start": _.bind(this.validLogs, this),
"watch:stop": _.bind(this.invalidLogs, this)
});

this.model.set("token", window.storage.get("token"));
this.model.set("characters", window.storage.get("characters"));
this.model.set("logs_path", window.storage.get("logs_path"));
},

serializeData: function() {
return _.extend(this.model.toJSON(), {
validLogPath: this.validLogPath
})
},

tokenChanged: function() {
Expand Down Expand Up @@ -53,8 +70,18 @@ var SettingsForm = Backbone.View.extend({
return(this._template = _.template($("#settings-form-template").html()));
},

validLogs: function() {
this.validLogPath = true;
this.render();
},

invalidLogs: function() {
this.validLogPath = false;
this.render();
},

render: function() {
this.$el.html(this.template()(this.model.toJSON()));
this.$el.html(this.template()(this.serializeData()));
}
})

Expand Down
15 changes: 15 additions & 0 deletions app/stylesheets/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,18 @@ textarea {
.right {
float: right !important;
}

.check {
border-radius: 50%;
height: 15px;
width: 15px;
display: inline-block;
}

.check.invalid {
background: red;
}

.check.valid {
background: green;
}

0 comments on commit a5968e8

Please sign in to comment.