ffffng/server/utils/urlBuilder.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

'use strict';
angular.module('ffffng').factory('UrlBuilder', function (_, config) {
function formUrl(route, queryParams) {
var url = config.server.baseUrl;
if (route || queryParams) {
url += '/#!/';
}
if (route) {
url += route;
}
if (queryParams) {
url += '?';
url += _.join(
_.map(
queryParams,
function (value, key) {
return encodeURIComponent(key) + '=' + encodeURIComponent(value);
}
),
'&'
);
}
return url;
}
return {
editNodeUrl: function () {
return formUrl('update');
},
2016-05-23 22:36:27 +02:00
monitoringConfirmUrl: function (nodeSecrets) {
return formUrl('monitoring/confirm', { token: nodeSecrets.monitoringToken });
},
2016-05-23 22:36:27 +02:00
monitoringDisableUrl: function (nodeSecrets) {
return formUrl('monitoring/disable', { token: nodeSecrets.monitoringToken });
}
};
});