1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-frontend/public/js/stores/FeatureToggleServerFacade.js

100 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
const reqwest = require('reqwest');
2016-06-18 21:53:18 +02:00
const TYPE = 'json';
const CONTENT_TYPE = 'application/json';
2016-06-18 21:53:18 +02:00
const FeatureToggleServerFacade = {
2016-07-02 11:54:50 +02:00
updateFeature (feature, cb) {
reqwest({
2016-06-18 21:53:18 +02:00
url: `features/${feature.name}`,
method: 'put',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
},
2016-07-02 11:54:50 +02:00
success () {
cb();
2016-06-18 21:55:46 +02:00
},
});
},
2016-07-02 11:54:50 +02:00
createFeature (feature, cb) {
reqwest({
url: 'features',
method: 'post',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
},
2016-07-02 11:54:50 +02:00
success () {
cb();
2016-06-18 21:55:46 +02:00
},
});
},
2016-07-02 11:54:50 +02:00
archiveFeature (feature, cb) {
reqwest({
2016-06-18 21:53:18 +02:00
url: `features/${feature.name}`,
method: 'delete',
type: TYPE,
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
},
2016-07-02 11:54:50 +02:00
success () {
cb();
2016-06-18 21:55:46 +02:00
},
});
},
2016-07-02 11:54:50 +02:00
getFeatures (cb) {
reqwest({
url: 'features',
method: 'get',
type: TYPE,
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
},
2016-07-02 11:54:50 +02:00
success (data) {
cb(null, data.features);
2016-06-18 21:55:46 +02:00
},
});
},
2016-07-02 11:54:50 +02:00
getArchivedFeatures (cb) {
reqwest({
url: 'archive/features',
method: 'get',
type: TYPE,
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
},
2016-07-02 11:54:50 +02:00
success (data) {
cb(null, data.features);
2016-06-18 21:55:46 +02:00
},
});
},
2016-07-02 11:54:50 +02:00
reviveFeature (feature, cb) {
reqwest({
url: 'archive/revive',
method: 'post',
type: TYPE,
contentType: CONTENT_TYPE,
data: JSON.stringify(feature),
2016-07-02 11:54:50 +02:00
error (error) {
cb(error);
},
2016-07-02 11:54:50 +02:00
success () {
cb();
2016-06-18 21:55:46 +02:00
},
});
2016-06-18 21:55:46 +02:00
},
};
module.exports = FeatureToggleServerFacade;