Open node in form and map.
This commit is contained in:
parent
5b9d2e615b
commit
03083b819b
|
@ -43,6 +43,7 @@
|
|||
<script src="js/app.js"></script>
|
||||
<script src="js/validation/constraints.js"></script>
|
||||
<script src="js/views/taskActionButton.js"></script>
|
||||
<script src="js/config.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
<script src="/config.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, RestangularProvider, Constraints) {
|
||||
angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, RestangularProvider, Constraints, config) {
|
||||
RestangularProvider.addFullRequestInterceptor(function(element, operation, what, url, headers, params) {
|
||||
if (operation === 'getList') {
|
||||
if (params._filters) {
|
||||
|
@ -92,10 +92,16 @@ angular.module('ffffngAdmin').config(function(NgAdminConfigurationProvider, Rest
|
|||
'<input type="text" ng-model="value" placeholder="Search" class="form-control"></input>' +
|
||||
'<span class="input-group-addon"><i class="fa fa-search"></i></span></div>'),
|
||||
])
|
||||
.listActions([
|
||||
'edit',
|
||||
'delete'
|
||||
])
|
||||
.listActions(
|
||||
'<ma-edit-button entry="entry" entity="entity" size="sm"></ma-edit-button> ' +
|
||||
'<ma-delete-button entry="entry" entity="entity" size="sm"></ma-delete-button> ' +
|
||||
'<form style="display: inline-block" action="/#!/update" method="POST" target="_blank">' +
|
||||
'<input type="hidden" name="token" value="{{entry.values.token}}"/>' +
|
||||
'<button class="btn btn-primary btn-sm" type="submit"><i class="fa fa-external-link"></i> Open</button>' +
|
||||
'</form> ' +
|
||||
'<a class="btn btn-success btn-sm" href="' + config.map.mapUrl +
|
||||
'/#!v:m;n:{{entry.values.mapId}}" target="_blank"><i class="fa fa-map-o"></i> Map</a>'
|
||||
)
|
||||
;
|
||||
|
||||
nodes
|
|
@ -31,4 +31,10 @@ angular.module('ffffng')
|
|||
$scope.cancel = function () {
|
||||
Navigator.home();
|
||||
};
|
||||
|
||||
if (window.__nodeToken) {
|
||||
var token = window.__nodeToken;
|
||||
window.__nodeToken = undefined;
|
||||
$scope.onSubmitToken(token);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -24,6 +24,7 @@ angular.module('ffffng').factory('app', function (fs, config, _) {
|
|||
app.use('/internal', auth.connect(internalAuth));
|
||||
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
var adminDir = __dirname + '/../admin';
|
||||
var clientDir = __dirname + '/../client';
|
||||
|
|
|
@ -76,6 +76,4 @@ var config = deepExtend({}, defaultConfig, configJSON);
|
|||
|
||||
module.exports = config;
|
||||
|
||||
angular.module('ffffng').factory('config', function () {
|
||||
return config;
|
||||
});
|
||||
angular.module('ffffng').constant('config', config);
|
||||
|
|
|
@ -19,6 +19,7 @@ require('./utils/resources');
|
|||
require('./utils/strings');
|
||||
require('./utils/urlBuilder');
|
||||
|
||||
require('./resources/frontendResource');
|
||||
require('./resources/taskResource');
|
||||
require('./resources/nodeResource');
|
||||
require('./resources/monitoringResource');
|
||||
|
|
31
server/resources/frontendResource.js
Normal file
31
server/resources/frontendResource.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ffffng').factory('FrontendResource', function (
|
||||
Logger,
|
||||
Resources,
|
||||
ErrorTypes,
|
||||
fs
|
||||
) {
|
||||
var indexHtml = __dirname + '/../../client/index.html';
|
||||
|
||||
return {
|
||||
render: function (req, res) {
|
||||
var data = Resources.getData(req);
|
||||
|
||||
fs.readFile(indexHtml, 'utf8', function (err, body) {
|
||||
if (err) {
|
||||
Logger.tag('frontend').error('Could not read file: ', indexHtml, err);
|
||||
return Resources.error(res, {data: 'Internal error.', type: ErrorTypes.internalError});
|
||||
}
|
||||
|
||||
return Resources.successHtml(
|
||||
res,
|
||||
body.replace(
|
||||
/<body/,
|
||||
'<script>window.__nodeToken = \''+ data.token + '\';</script><body'
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
|
@ -2,12 +2,15 @@
|
|||
|
||||
angular.module('ffffng').factory('Router', function (
|
||||
app,
|
||||
FrontendResource,
|
||||
NodeResource,
|
||||
MonitoringResource,
|
||||
TaskResource
|
||||
) {
|
||||
return {
|
||||
init: function () {
|
||||
app.post('/', FrontendResource.render);
|
||||
|
||||
app.post('/api/node', NodeResource.create);
|
||||
app.put('/api/node/:token', NodeResource.update);
|
||||
app.delete('/api/node/:token', NodeResource.delete);
|
||||
|
|
|
@ -212,7 +212,10 @@ angular.module('ffffng')
|
|||
}
|
||||
|
||||
_.each(entries, function (value, key) {
|
||||
if (key === 'monitoring') {
|
||||
if (key === 'mac') {
|
||||
node['mac'] = value;
|
||||
node['mapId'] = _.toLower(value).replace(/:/g, '')
|
||||
} else if (key === 'monitoring') {
|
||||
var active = value === 'aktiv';
|
||||
var pending = value === 'pending';
|
||||
node.monitoring = active || pending;
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ffffng')
|
||||
.factory('config', function () {
|
||||
return <%= JSON.stringify(config) %>;
|
||||
});
|
||||
angular.module('ffffng').constant('config', <%= JSON.stringify(config) %>);
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('ffffng').factory('Resources', function (_, Constraints, Validator, ErrorTypes) {
|
||||
function respond(res, httpCode, data) {
|
||||
res.writeHead(httpCode, {'Content-Type': 'application/json'});
|
||||
res.end(JSON.stringify(data));
|
||||
function respond(res, httpCode, data, type) {
|
||||
switch (type) {
|
||||
case 'html':
|
||||
res.writeHead(httpCode, {'Content-Type': 'text/html'});
|
||||
res.end(data);
|
||||
break;
|
||||
|
||||
default:
|
||||
res.writeHead(httpCode, {'Content-Type': 'application/json'});
|
||||
res.end(JSON.stringify(data));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -84,11 +93,15 @@ angular.module('ffffng').factory('Resources', function (_, Constraints, Validato
|
|||
},
|
||||
|
||||
success: function (res, data) {
|
||||
respond(res, 200, data);
|
||||
respond(res, 200, data, 'json');
|
||||
},
|
||||
|
||||
successHtml: function (res, html) {
|
||||
respond(res, 200, html, 'html');
|
||||
},
|
||||
|
||||
error: function (res, err) {
|
||||
respond(res, err.type.code, err.data);
|
||||
respond(res, err.type.code, err.data, 'json');
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue