Open node in form and map.
This commit is contained in:
parent
5b9d2e615b
commit
03083b819b
12 changed files with 80 additions and 19 deletions
server/utils
|
@ -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…
Add table
Add a link
Reference in a new issue