Splitting site field: Now we track site and domain.

This commit is contained in:
baldo 2018-12-17 20:06:39 +01:00
parent 7cec2788f8
commit 84b20b209e
8 changed files with 46 additions and 6 deletions

View file

@ -158,7 +158,8 @@ Dann die `config.json` anpassen nach belieben. Es gibt die folgenden Konfigurati
* **`client.community.name`** Name der Freifunk-Community, z. B.: `"Freifunk Musterstadt"` * **`client.community.name`** Name der Freifunk-Community, z. B.: `"Freifunk Musterstadt"`
* **`client.community.domain`** Domain der Freifunk-Community, z. B.: `"musterstadt.freifunk.net"` * **`client.community.domain`** Domain der Freifunk-Community, z. B.: `"musterstadt.freifunk.net"`
* **`client.community.contactEmail`** Kontakt-E-Mail-Adresse der Freifunk-Community, z. B.: `"kontakt@musterstadt.freifunk.net"` * **`client.community.contactEmail`** Kontakt-E-Mail-Adresse der Freifunk-Community, z. B.: `"kontakt@musterstadt.freifunk.net"`
* **`client.community.sites`** Liste der gültige Site-Codes in der `nodes.json`, z. B.: `["ffms-domain1", "ffms-domain2"]` * **`client.community.sites`** Liste der gültige Site-Codes in der `nodes.json`, z. B.: `["ffms-site1", "ffms-site2"]`
* **`client.community.domains`** Liste der gültige Domänen-Codes in der `nodes.json`, z. B.: `["ffms-domain1", "ffms-domain2"]`
* **`client.legal.privacyUrl`** optional: URL zum Impressum, z. B.: `"http://map.musterstadt.freifunk.net/impressum"` * **`client.legal.privacyUrl`** optional: URL zum Impressum, z. B.: `"http://map.musterstadt.freifunk.net/impressum"`
* **`client.legal.imprintUrl`** optional: URL zur Datenschutzerklärung, z. B.: `"http://map.musterstadt.freifunk.net/datenschutz"` * **`client.legal.imprintUrl`** optional: URL zur Datenschutzerklärung, z. B.: `"http://map.musterstadt.freifunk.net/datenschutz"`

View file

@ -55,6 +55,15 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest
}); });
} }
var domainChoices = [];
for (var i = 0; i < config.community.domains.length; i++) {
var domain = config.community.domains[i];
domainChoices.push({
label: domain,
value: domain
});
}
var header = var header =
'<div class="navbar-header">' + '<div class="navbar-header">' +
'<a class="navbar-brand" href="#" ng-click="appController.displayHome()">' + '<a class="navbar-brand" href="#" ng-click="appController.displayHome()">' +
@ -139,6 +148,7 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest
: '<i class="fa fa-times vpn-key-unset" aria-hidden="true" title="no VPN key"></i>'; : '<i class="fa fa-times vpn-key-unset" aria-hidden="true" title="no VPN key"></i>';
}), }),
nga.field('site').map(nullable).cssClasses(nodeClasses), nga.field('site').map(nullable).cssClasses(nodeClasses),
nga.field('domain').map(nullable).cssClasses(nodeClasses),
nga.field('coords').label('GPS').cssClasses(nodeClasses).template(function (node) { nga.field('coords').label('GPS').cssClasses(nodeClasses).template(function (node) {
return node.values.coords return node.values.coords
? '<i class="fa fa-map-marker coords-set" aria-hidden="true" title="coordinates set"></i>' ? '<i class="fa fa-map-marker coords-set" aria-hidden="true" title="coordinates set"></i>'
@ -170,6 +180,10 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest
.label('Site') .label('Site')
.pinned(false) .pinned(false)
.choices(siteChoices), .choices(siteChoices),
nga.field('domain', 'choice')
.label('Domäne')
.pinned(false)
.choices(domainChoices),
nga.field('hasKey', 'choice') nga.field('hasKey', 'choice')
.label('VPN key') .label('VPN key')
.pinned(false) .pinned(false)
@ -270,6 +284,7 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest
nga.field('hostname').cssClasses(monitoringStateClasses), nga.field('hostname').cssClasses(monitoringStateClasses),
nga.field('mac').cssClasses(monitoringStateClasses), nga.field('mac').cssClasses(monitoringStateClasses),
nga.field('site').map(nullable).cssClasses(monitoringStateClasses), nga.field('site').map(nullable).cssClasses(monitoringStateClasses),
nga.field('domain').map(nullable).cssClasses(monitoringStateClasses),
nga.field('monitoring_state').cssClasses(monitoringStateClasses).template(function (monitoringState) { nga.field('monitoring_state').cssClasses(monitoringStateClasses).template(function (monitoringState) {
switch (monitoringState.values.monitoring_state) { switch (monitoringState.values.monitoring_state) {
case 'active': case 'active':

View file

@ -42,7 +42,8 @@
"name": "Freifunk Musterstadt", "name": "Freifunk Musterstadt",
"domain": "musterstadt.freifunk.net", "domain": "musterstadt.freifunk.net",
"contactEmail": "kontakt@musterstadt.freifunk.net", "contactEmail": "kontakt@musterstadt.freifunk.net",
"sites": ["ffms-domain1", "ffms-domain2"] "sites": ["ffms-site1", "ffms-site2"],
"domains": ["ffms-domain1", "ffms-domain2"]
}, },
"legal": { "legal": {
"privacyUrl": "http://map.musterstadt.freifunk.net/datenschutz", "privacyUrl": "http://map.musterstadt.freifunk.net/datenschutz",

View file

@ -97,7 +97,8 @@ var defaultConfig = {
name: 'Freifunk Musterstadt', name: 'Freifunk Musterstadt',
domain: 'musterstadt.freifunk.net', domain: 'musterstadt.freifunk.net',
contactEmail: 'kontakt@musterstadt.freifunk.net', contactEmail: 'kontakt@musterstadt.freifunk.net',
sites: [] sites: [],
domains: []
}, },
legal: { legal: {
privacyUrl: null, privacyUrl: null,

View file

@ -0,0 +1 @@
ALTER TABLE node_state ADD COLUMN domain VARCHAR(32);

View file

@ -128,6 +128,7 @@ angular.module('ffffng').factory('NodeResource', function (
if (nodeState) { if (nodeState) {
return deepExtend({}, node, { return deepExtend({}, node, {
site: nodeState.site, site: nodeState.site,
domain: nodeState.domain,
onlineState: nodeState.state onlineState: nodeState.state
}); });
} }
@ -144,6 +145,7 @@ angular.module('ffffng').factory('NodeResource', function (
'token', 'token',
'mac', 'mac',
'site', 'site',
'domain',
'key', 'key',
'onlineState' 'onlineState'
], ],
@ -161,6 +163,7 @@ angular.module('ffffng').factory('NodeResource', function (
'mac', 'mac',
'key', 'key',
'site', 'site',
'domain',
'coords', 'coords',
'onlineState', 'onlineState',
'monitoringState' 'monitoringState'

View file

@ -44,12 +44,13 @@ angular.module('ffffng')
return Database.run( return Database.run(
'INSERT INTO node_state ' + 'INSERT INTO node_state ' +
'(hostname, mac, site, monitoring_state, state, last_seen, import_timestamp, last_status_mail_sent, last_status_mail_type) ' + '(hostname, mac, site, domain, monitoring_state, state, last_seen, import_timestamp, last_status_mail_sent, last_status_mail_type) ' +
'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
[ [
node.hostname, node.hostname,
node.mac, node.mac,
nodeData.site, nodeData.site,
nodeData.domain,
node.monitoringState, node.monitoringState,
nodeData.state, nodeData.state,
nodeData.lastSeen.unix(), nodeData.lastSeen.unix(),
@ -84,6 +85,7 @@ angular.module('ffffng')
'SET ' + 'SET ' +
'hostname = ?, ' + 'hostname = ?, ' +
'site = ?, ' + 'site = ?, ' +
'domain = ?, ' +
'monitoring_state = ?, ' + 'monitoring_state = ?, ' +
'state = ?, ' + 'state = ?, ' +
'last_seen = ?, ' + 'last_seen = ?, ' +
@ -93,6 +95,7 @@ angular.module('ffffng')
[ [
node.hostname, node.hostname,
nodeData.site || row.site, nodeData.site || row.site,
nodeData.domain || row.domain,
node.monitoringState, node.monitoringState,
nodeData.state, nodeData.state,
nodeData.lastSeen.unix(), nodeData.lastSeen.unix(),
@ -119,6 +122,7 @@ angular.module('ffffng')
nodeDataForStoring = { nodeDataForStoring = {
mac: node.mac, mac: node.mac,
site: _.isUndefined(row) ? null : row.site, site: _.isUndefined(row) ? null : row.site,
domain: _.isUndefined(row) ? null : row.domain,
state: 'OFFLINE', state: 'OFFLINE',
// jshint -W106 // jshint -W106
lastSeen: _.isUndefined(row) ? moment() : moment.unix(row.last_seen), lastSeen: _.isUndefined(row) ? moment() : moment.unix(row.last_seen),
@ -197,12 +201,20 @@ angular.module('ffffng')
} }
// jshint +W106 // jshint +W106
var domain = null;
// jshint -W106
if (_.isPlainObject(nodeData.nodeinfo.system) && _.isString(nodeData.nodeinfo.system.domain_code)) {
domain = nodeData.nodeinfo.system.domain_code;
}
// jshint +W106
return { return {
mac: mac, mac: mac,
importTimestamp: importTimestamp, importTimestamp: importTimestamp,
state: isOnline ? 'ONLINE' : 'OFFLINE', state: isOnline ? 'ONLINE' : 'OFFLINE',
lastSeen: lastSeen, lastSeen: lastSeen,
site: site site: site,
domain: domain
}; };
} }
@ -564,6 +576,7 @@ angular.module('ffffng')
'hostname', 'hostname',
'mac', 'mac',
'site', 'site',
'domain',
'monitoring_state', 'monitoring_state',
'state', 'state',
'last_seen', 'last_seen',

View file

@ -70,6 +70,11 @@ angular.module('ffffng').constant('Constraints', {
type: 'string', type: 'string',
regex: /^[a-z0-9_-]{1,32}$/, regex: /^[a-z0-9_-]{1,32}$/,
optional: true optional: true
},
domain: {
type: 'string',
regex: /^[a-z0-9_-]{1,32}$/,
optional: true
} }
}, },
rest: { rest: {