Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Heolink committed Feb 13, 2016
1 parent f22b1a2 commit 1aaa147
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 29 deletions.
3 changes: 2 additions & 1 deletion build/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h5 class="nav-group-title">History <small>({{ history.length }}/{{ settings.his
</span>

</nav>

</div>

<div class="pane">
Expand Down Expand Up @@ -43,7 +44,7 @@ <h5 class="nav-group-title">History <small>({{ history.length }}/{{ settings.his
<button class="uk-button uk-margin-small-top" @click="cancelFilter()">reset</button>
</fieldset>
<fieldset data-uk-margin="" class="uk-margin-small-bottom">
<legend>Add ip / domains</legend>
<legend>Ajout d'un host</legend>
<input class="uk-margin-small-top" @keyup.enter="doneAddIp()"
@keyup.esc="cancelAddIp()" v-model="newIp" placeholder="IP" type="text">
<input class="uk-margin-small-top mousetrap" @keyup.enter="doneAddIp()"
Expand Down
42 changes: 29 additions & 13 deletions build/js/Conponents/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var Settings = require('../Settings');
var dbHistory = new Datastore({ filename: pathConfig + '/history.db', autoload: true });
var hosts = new Hosts();
var prevKeyPress = null;
var raw = true;
var home = {
template: fs.readFileSync(remote.app.getAppPath() + '/build/home.html', 'UTF8'),
data: function () {
Expand All @@ -25,7 +26,7 @@ var home = {
},
master: null,
settings: {},
raw: true,
raw: raw,
ipEdited: null,
ipAdd: null,
domainAdd: null,
Expand All @@ -40,6 +41,7 @@ var home = {
};
},
asyncData: function (resolve, reject) {
var _this = this;
var that = this;
hosts.read().then(function (d) {
hosts.watch(function () {
Expand All @@ -51,16 +53,20 @@ var home = {
'hosts_datas': d,
master: d
});
if (_this.raw == false) {
_this.buildEditor();
}
}, function error(d) {
reject(d);
});
dbHistory.find({}).sort({ created_at: -1 }).exec(function (err, docs) {
resolve({ history: docs });
});
Settings.read(function (settings) {
raw = (settings.defaultView == 'raw') ? true : false;
resolve({
settings: settings,
raw: (settings.defaultView == 'raw') ? true : false
raw: raw
});
});
},
Expand All @@ -69,9 +75,22 @@ var home = {
mousetrap.bind(['command+s', 'ctrl+s'], function (e) {
_this.save(e);
});
this.$watch('hosts_datas', function (n, o) {
_this['hostObject'] = [];
var lines = n.split("\n");
this.$watch('raw', function (n, o) {
if (n == true) {
return;
}
_this.buildEditor();
});
/*
this.$watch('hosts_datas', (n, o) => {
});
*/
},
methods: {
buildEditor: function () {
this['hostObject'] = [];
var lines = this.hosts_datas.split("\n");
for (var lineNumber in lines) {
var line = lines[lineNumber].trim();
if (line.match(/^#/)) {
Expand All @@ -90,7 +109,7 @@ var home = {
}).map(function (v, k) {
return { 'domain': v.trim(), 'comment': true };
});
_this['hostObject'].push({
this['hostObject'].push({
ip: ipComented,
lineNumber: lineNumber,
domains: domains,
Expand Down Expand Up @@ -120,17 +139,15 @@ var home = {
}
return { 'domain': v.trim(), 'comment': c };
});
_this['hostObject'].push({
this['hostObject'].push({
ip: ip,
lineNumber: lineNumber,
domains: domains,
comment: false
});
}
}
});
},
methods: {
},
filterDomains: function (ip) {
var _this = this;
if (!this.filterDomain && !this['filterIp']) {
Expand Down Expand Up @@ -385,11 +402,10 @@ var home = {
}
}
for (var _b = 0, _c = this.lineRemove; _b < _c.length; _b++) {
var line = _c[_b];
linesHost.splice(line, 1);
var l = _c[_b];
linesHost.splice(l, 1);
}
this.hosts_datas = linesHost.join("\n");
console.log(this.hosts_datas);
this.lineRemove = [];
//this.save();
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"start": "DEV=true electron .",
"package": "electron-packager . hosty --platform=darwin --arch=x64 --version=0.36.4 --out=dist --overwrite --icon=./icons/icon.icns --ignore='^/dist$' --ignore='^/icons$' --ignore='^/typings$' --ignore='^/src$' --prune",
"package:linux": "electron-packager . hosty --platform=linux --arch=x64 --version=0.36.4 --out=dist --overwrite --ignore='^/dist$' --ignore='^/icons$' --ignore='^/typings$' --ignore='^/src$' --prune",
"package:win32": "electron-packager . hosty --platform=win32 --arch=x64 --version=0.36.4 --out=dist --overwrite --ignore='^/dist$' --ignore='^/icons$' --ignore='^/typings$' --ignore='^/src$' --prune"
"package:win32": "electron-packager . hosty --platform=win32 --arch=x64 --version=0.36.4 --out=dist --overwrite --ignore='^/dist$' --ignore='^/icons$' --ignore='^/typings$' --ignore='^/src$' --prune",
"package:all":"npm run package && npm run package:linux && npm run package:win32"
},
"devDependencies": {
"electron-packager": "^5.2.1",
Expand Down
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ http://electron.atom.io

http://vuejs.org

http://photonkit.com
http://photonkit.com

http://getuikit.com/
44 changes: 31 additions & 13 deletions src/Conponents/Home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var dbHistory = new Datastore({ filename: pathConfig + '/history.db', autoload:
var hosts = new Hosts();
var prevKeyPress = null;

var raw = true;

var home = {
template: fs.readFileSync(remote.app.getAppPath()+'/build/home.html', 'UTF8'),
data: function() {
Expand All @@ -31,7 +33,7 @@ var home = {
},
master: null,
settings: {},
raw: true,
raw: raw,
ipEdited: null,
ipAdd: null,
domainAdd: null,
Expand All @@ -56,8 +58,11 @@ var home = {
});
resolve({
'hosts_datas': d,
master: d
master: d
})
if( this.raw == false ) {
this.buildEditor();
}
},
function error(d){
reject(d)
Expand All @@ -67,23 +72,39 @@ var home = {
resolve({history:docs})
});
Settings.read(function(settings){
raw = (settings.defaultView == 'raw') ? true : false;
resolve({
settings:settings,
raw: (settings.defaultView == 'raw') ? true : false
raw: raw
})
})
},
created: function () {

mousetrap.bind(['command+s', 'ctrl+s'], (e) => {

this.save(e);

})



this.$watch('raw', (n,o) => {
if( n == true ) {
return;
}
this.buildEditor();
})
/*
this.$watch('hosts_datas', (n, o) => {
});
*/

},
methods: {
buildEditor: function()
{
this['hostObject'] = []
var lines = n.split("\n");
var lines = this.hosts_datas.split("\n");
for(var lineNumber in lines) {
var line = lines[lineNumber].trim();
if( line.match(/^#/) ) {
Expand Down Expand Up @@ -143,10 +164,7 @@ var home = {
});
}
}
});

},
methods: {
},
filterDomains: function( ip )
{
if( !this.filterDomain && !this['filterIp'] ) {
Expand Down Expand Up @@ -424,11 +442,11 @@ var home = {

}
}
for( var line of this.lineRemove) {
linesHost.splice(line, 1);
for( var l of this.lineRemove) {
linesHost.splice(l, 1);
}
this.hosts_datas = linesHost.join("\n");
console.log(this.hosts_datas)

this.lineRemove = [];
//this.save();
}
Expand Down

0 comments on commit 1aaa147

Please sign in to comment.