WS fixes
This commit is contained in:
@@ -68,6 +68,7 @@ MIT license
|
|||||||
//re-factor element index's
|
//re-factor element index's
|
||||||
for(var i = 0; i < this.length; i++){
|
for(var i = 0; i < this.length; i++){
|
||||||
if( i >= index){
|
if( i >= index){
|
||||||
|
|
||||||
this[i].__jq_$el.attr( 'jq-repeat-index', i+shift );
|
this[i].__jq_$el.attr( 'jq-repeat-index', i+shift );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,7 +82,7 @@ MIT license
|
|||||||
//figure out new elements index
|
//figure out new elements index
|
||||||
var key = I + index;
|
var key = I + index;
|
||||||
// apply values to template
|
// apply values to template
|
||||||
var render = Mustache.render(this.__jqTemplate, toAdd[I] );
|
var render = Mustache.render(this.__jqTemplate, toAdd[I]);
|
||||||
|
|
||||||
//set call name and index keys to DOM element
|
//set call name and index keys to DOM element
|
||||||
var $render = $( render ).addClass( 'jq-repeat-'+ this.__jqRepeatId ).attr( 'jq-repeat-index', key );
|
var $render = $( render ).addClass( 'jq-repeat-'+ this.__jqRepeatId ).attr( 'jq-repeat-index', key );
|
||||||
@@ -195,15 +196,28 @@ MIT license
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var object = $.extend( true, {}, this[index], update );
|
var object = $.extend( true, {}, this[index], update );
|
||||||
return this.splice( index, 1, object )[0];
|
|
||||||
|
var $render = $(Mustache.render(this.__jqTemplate, object));
|
||||||
|
$render.attr('jq-repeat-index', index);
|
||||||
|
this[index].__jq_$el.replaceWith($render);
|
||||||
|
|
||||||
|
this[index].__jq_$el = $render;
|
||||||
|
this.__update(this[index].__jq_$el, this[index], this);
|
||||||
};
|
};
|
||||||
|
|
||||||
result.__put = function($el, item, list){
|
result.__put = function($el, item, list){
|
||||||
$el.show();
|
$el.show();
|
||||||
};
|
};
|
||||||
|
|
||||||
result.__take = function($el, item, list){
|
result.__take = function($el, item, list){
|
||||||
$el.remove();
|
$el.remove();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
result.__update = function($el, item, list){
|
||||||
|
console.log('here', $el)
|
||||||
|
$el.show();
|
||||||
|
};
|
||||||
|
|
||||||
result.__setPut = function(fn) {
|
result.__setPut = function(fn) {
|
||||||
Object.defineProperty(this, '__put', {
|
Object.defineProperty(this, '__put', {
|
||||||
value: fn,
|
value: fn,
|
||||||
@@ -211,7 +225,7 @@ MIT license
|
|||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
result.__setTake = function(fn) {
|
result.__setTake = function(fn) {
|
||||||
Object.defineProperty(this, '__take', {
|
Object.defineProperty(this, '__take', {
|
||||||
@@ -220,7 +234,16 @@ MIT license
|
|||||||
enumerable: false,
|
enumerable: false,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
result.__setUpdate = function(fn) {
|
||||||
|
Object.defineProperty(this, '__update', {
|
||||||
|
value: fn,
|
||||||
|
writable: true,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var $this = $( element );
|
var $this = $( element );
|
||||||
result.__jqRepeatId = $this.attr( 'jq-repeat' );
|
result.__jqRepeatId = $this.attr( 'jq-repeat' );
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class LetsEncrypt{
|
|||||||
static AcmeClient = AcmeClient;
|
static AcmeClient = AcmeClient;
|
||||||
|
|
||||||
constructor(options){
|
constructor(options){
|
||||||
this.loadAccountKey(options.accountKeyPath || '~/le_key', (key)=>{
|
this.loadAccountKey(options.accountKeyPath || './le_key.cert', (key)=>{
|
||||||
this.client = new AcmeClient.Client({
|
this.client = new AcmeClient.Client({
|
||||||
directoryUrl: options.directoryUrl || AcmeClient.directory.letsencrypt.production,
|
directoryUrl: options.directoryUrl || AcmeClient.directory.letsencrypt.production,
|
||||||
accountKey: key,
|
accountKey: key,
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ function ModelPs(model){
|
|||||||
},
|
},
|
||||||
get(target, propKey, receiver) {
|
get(target, propKey, receiver) {
|
||||||
if(propKey == 'constructor') return target.constructor;
|
if(propKey == 'constructor') return target.constructor;
|
||||||
if(propKey === 'isproxy') return 'YESSSSSSSSS'
|
|
||||||
const targetValue = Reflect.get(target, propKey, receiver);
|
const targetValue = Reflect.get(target, propKey, receiver);
|
||||||
if (typeof targetValue === 'function') {
|
if (typeof targetValue === 'function') {
|
||||||
return function(...args){
|
return function(...args){
|
||||||
let res = targetValue.apply(this, args); // (A)
|
// let res = targetValue.apply(this, args); // (A)
|
||||||
|
let res = Reflect.apply(targetValue, this, args);
|
||||||
if(targetValue.constructor.name === 'AsyncFunction'){
|
if(targetValue.constructor.name === 'AsyncFunction'){
|
||||||
res.then(function(res){
|
res.then(function(res){
|
||||||
publish(propKey, res, ...args);
|
publish(propKey, res, ...args);
|
||||||
|
|||||||
+25
-29
@@ -127,36 +127,33 @@ class Table{
|
|||||||
try{
|
try{
|
||||||
// Check to see if entry name changed.
|
// Check to see if entry name changed.
|
||||||
if(data[this.constructor._key] && data[this.constructor._key] !== this[this.constructor._key]){
|
if(data[this.constructor._key] && data[this.constructor._key] !== this[this.constructor._key]){
|
||||||
|
// Remove the index key from the tables members list.
|
||||||
|
await client.SREM(
|
||||||
|
redisPrefix(this.constructor.name),
|
||||||
|
this[this.constructor._key]
|
||||||
|
);
|
||||||
|
|
||||||
// Merge the current data into with the updated data
|
// Add the key to the members for this redis table
|
||||||
let newData = Object.assign({}, this, data);
|
await client.SADD(
|
||||||
|
redisPrefix(this.constructor.name),
|
||||||
|
data[this.constructor._key]
|
||||||
|
);
|
||||||
|
|
||||||
// Remove the updated failed so it doesnt keep it
|
|
||||||
delete newData.updated;
|
|
||||||
|
|
||||||
// Create a new record for the updated entry. If that succeeds,
|
|
||||||
// delete the old recored
|
|
||||||
let newObject = await this.constructor.create(newData);
|
|
||||||
|
|
||||||
if(newObject){
|
|
||||||
await this.remove();
|
|
||||||
return newObject;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
// Update what ever fields that where passed.
|
|
||||||
|
|
||||||
// Validate the passed data, ignoring required fields.
|
|
||||||
data = objValidate.processKeys(this.constructor._keyMap, data, true);
|
|
||||||
|
|
||||||
// Loop over the data fields and apply them to redis
|
|
||||||
for(let key of Object.keys(data)){
|
|
||||||
this[key] = data[key];
|
|
||||||
await client.HSET(
|
|
||||||
redisPrefix(`${this.constructor.name}_${this[this.constructor._key]}`),
|
|
||||||
key, String(data[key])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// Update what ever fields that where passed.
|
||||||
|
|
||||||
|
// Validate the passed data, ignoring required fields.
|
||||||
|
data = objValidate.processKeys(this.constructor._keyMap, data, true);
|
||||||
|
|
||||||
|
// Loop over the data fields and apply them to redis
|
||||||
|
for(let key of Object.keys(data)){
|
||||||
|
this[key] = data[key];
|
||||||
|
await client.HSET(
|
||||||
|
redisPrefix(`${this.constructor.name}_${this[this.constructor._key]}`),
|
||||||
|
key, String(data[key])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
@@ -171,7 +168,6 @@ class Table{
|
|||||||
|
|
||||||
try{
|
try{
|
||||||
// Remove the index key from the tables members list.
|
// Remove the index key from the tables members list.
|
||||||
|
|
||||||
await client.SREM(
|
await client.SREM(
|
||||||
redisPrefix(this.constructor.name),
|
redisPrefix(this.constructor.name),
|
||||||
this[this.constructor._key]
|
this[this.constructor._key]
|
||||||
@@ -183,7 +179,7 @@ class Table{
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Return the number of removed values to the caller.
|
// Return the number of removed values to the caller.
|
||||||
return count;
|
return this;
|
||||||
|
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
+36
-10
@@ -54,9 +54,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$.scope.hosts.__setPut(function($el, item, list){
|
$.scope.hosts.__setPut(function($el, item, list){
|
||||||
$el.addClass('bg-success');
|
$el.addClass('table-success');
|
||||||
$el.fadeIn(1000, function(){
|
$el.fadeIn(2000, function(){
|
||||||
$el.removeClass('bg-success');
|
$el.removeClass('table-success');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -64,7 +64,6 @@
|
|||||||
|
|
||||||
function cancleHostEdit(){
|
function cancleHostEdit(){
|
||||||
$('#hostsTable').find('tr').each(function(idx, el){
|
$('#hostsTable').find('tr').each(function(idx, el){
|
||||||
console.log('here?')
|
|
||||||
$(el).removeClass('table-warning');
|
$(el).removeClass('table-warning');
|
||||||
});
|
});
|
||||||
$('.editWindow').slideUp('fast');
|
$('.editWindow').slideUp('fast');
|
||||||
@@ -104,7 +103,7 @@
|
|||||||
populateHosts(); //populate the table
|
populateHosts(); //populate the table
|
||||||
|
|
||||||
$.scope.hosts.__setTake(function($el, item, list){
|
$.scope.hosts.__setTake(function($el, item, list){
|
||||||
$el.addClass('bg-danger');
|
$el.addClass('table-danger');
|
||||||
$el.fadeOut(1000, function(){
|
$el.fadeOut(1000, function(){
|
||||||
$el.remove()
|
$el.remove()
|
||||||
});
|
});
|
||||||
@@ -114,6 +113,33 @@
|
|||||||
console.log(topic, data);
|
console.log(topic, data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.subscribe(/^model:Host:create/, function(data, topic){
|
||||||
|
let [a,b, action, host] = topic.split(':');
|
||||||
|
|
||||||
|
if($.scope.hosts.indexOf(host) >= 0){
|
||||||
|
$.scope.hosts.update(host, parseHostRow(data));
|
||||||
|
}else{
|
||||||
|
$.scope.hosts.splice(0,0, parseHostRow(data))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.subscribe(/^model:Host:update/, function(data, topic){
|
||||||
|
let [a,b, action, host] = topic.split(':');
|
||||||
|
|
||||||
|
if($.scope.hosts.indexOf(host) >= 0){
|
||||||
|
$.scope.hosts.update(host, parseHostRow(data));
|
||||||
|
}else{
|
||||||
|
$.scope.hosts.splice(0,0, parseHostRow(data))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.subscribe(/^model:Host:remove/, function(data, topic){
|
||||||
|
let [a,b, action, host] = topic.split(':');
|
||||||
|
|
||||||
|
$.scope.hosts.remove(host);
|
||||||
|
});
|
||||||
|
|
||||||
//search bar html event logic stolen from here
|
//search bar html event logic stolen from here
|
||||||
// https://github.com/WebDevSimplified/js-search-bar/blob/main/script.js
|
// https://github.com/WebDevSimplified/js-search-bar/blob/main/script.js
|
||||||
$('[host-search]').on("input", function() {
|
$('[host-search]').on("input", function() {
|
||||||
@@ -150,11 +176,11 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($.scope.hosts.indexOf(data.__requestedHost) >= 0){
|
// if($.scope.hosts.indexOf(data.__requestedHost) >= 0){
|
||||||
$.scope.hosts.update(data.__requestedHost, parseHostRow(data));
|
// $.scope.hosts.update(data.__requestedHost, parseHostRow(data));
|
||||||
}else{
|
// }else{
|
||||||
$.scope.hosts.splice(0,0, parseHostRow(data))
|
// // $.scope.hosts.splice(0,0, parseHostRow(data))
|
||||||
}
|
// }
|
||||||
|
|
||||||
if(action == 'edit') $('.editWindow').slideUp('fast');
|
if(action == 'edit') $('.editWindow').slideUp('fast');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user