Ongoing rewrite work

This commit is contained in:
Jamie Curnow
2018-07-09 11:22:10 +10:00
parent 30924a6922
commit 54d220a191
72 changed files with 3656 additions and 113 deletions

View File

@ -0,0 +1,26 @@
'use strict';
const Backbone = require('backbone');
const model = Backbone.Model.extend({
idAttribute: 'id',
defaults: function () {
return {
created_on: null,
modified_on: null,
owner: null,
domain_name: '',
ssl_enabled: false,
ssl_provider: false,
meta: []
};
}
});
module.exports = {
Model: model,
Collection: Backbone.Collection.extend({
model: model
})
};

View File

@ -0,0 +1,32 @@
'use strict';
const Backbone = require('backbone');
const model = Backbone.Model.extend({
idAttribute: 'id',
defaults: function () {
return {
created_on: null,
modified_on: null,
owner: null,
domain_name: '',
forward_ip: '',
forward_port: 0,
access_list_id: 0,
ssl_enabled: false,
ssl_provider: false,
ssl_forced: false,
caching_enabled: false,
block_exploits: false,
meta: []
};
}
});
module.exports = {
Model: model,
Collection: Backbone.Collection.extend({
model: model
})
};

View File

@ -0,0 +1,29 @@
'use strict';
const Backbone = require('backbone');
const model = Backbone.Model.extend({
idAttribute: 'id',
defaults: function () {
return {
created_on: null,
modified_on: null,
owner: null,
domain_name: '',
forward_domain_name: '',
preserve_path: false,
ssl_enabled: false,
ssl_provider: false,
block_exploits: false,
meta: []
};
}
});
module.exports = {
Model: model,
Collection: Backbone.Collection.extend({
model: model
})
};

View File

@ -0,0 +1,28 @@
'use strict';
const Backbone = require('backbone');
const model = Backbone.Model.extend({
idAttribute: 'id',
defaults: function () {
return {
created_on: null,
modified_on: null,
owner: null,
incoming_port: 0,
forward_ip: '',
forwarding_port: 0,
tcp_forwarding: true,
udp_forwarding: false,
meta: []
};
}
});
module.exports = {
Model: model,
Collection: Backbone.Collection.extend({
model: model
})
};

View File

@ -17,8 +17,33 @@ const model = Backbone.Model.extend({
};
},
/**
* @returns {Boolean}
*/
isAdmin: function () {
return _.indexOf(this.get('roles'), 'admin') !== -1;
},
/**
* Checks if the perm has either `view` or `manage` value
*
* @param {String} item
* @returns {Boolean}
*/
canView: function (item) {
let permissions = this.get('permissions');
return permissions !== null && typeof permissions[item] !== 'undefined' && ['view', 'manage'].indexOf(permissions[item]) !== -1;
},
/**
* Checks if the perm has `manage` value
*
* @param {String} item
* @returns {Boolean}
*/
canManage: function (item) {
let permissions = this.get('permissions');
return permissions !== null && typeof permissions[item] !== 'undefined' && permissions[item] === 'manage';
}
});