2018-08-14 05:13:59 -04:00
|
|
|
var angular = require('angular');
|
|
|
|
|
2018-08-14 08:42:05 -04:00
|
|
|
angular.module('KeySvc', []).service('KeyService', ['$http', function($http) {
|
|
|
|
this.createKey = (identifier, scope, cb) =>
|
2018-08-14 05:13:59 -04:00
|
|
|
$http({
|
2018-08-14 08:42:05 -04:00
|
|
|
method: 'POST',
|
|
|
|
url: '/api/keys/create',
|
|
|
|
data: {
|
|
|
|
identifier: identifier,
|
|
|
|
scope: scope
|
|
|
|
}
|
|
|
|
}).then(res => {
|
|
|
|
cb(null, res.data)
|
|
|
|
}).catch(err => {
|
|
|
|
cb(err);
|
2018-08-14 05:13:59 -04:00
|
|
|
});
|
|
|
|
|
2018-08-14 08:42:05 -04:00
|
|
|
this.deleteKey = (key, cb) =>
|
2018-08-14 05:13:59 -04:00
|
|
|
$http({
|
|
|
|
method: 'POST',
|
|
|
|
url: '/api/keys/delete',
|
|
|
|
data: {
|
|
|
|
key: key
|
|
|
|
}
|
2018-08-14 08:42:05 -04:00
|
|
|
}).then(res => {
|
|
|
|
cb(null, res.data);
|
|
|
|
}).catch(err => {
|
|
|
|
cb(err);
|
2018-08-14 05:13:59 -04:00
|
|
|
});
|
|
|
|
|
2018-08-14 08:42:05 -04:00
|
|
|
this.getAllKeys = cb =>
|
2018-08-14 05:13:59 -04:00
|
|
|
$http({
|
2018-08-14 08:42:05 -04:00
|
|
|
method: 'GET',
|
|
|
|
url: '/api/keys/get'
|
|
|
|
}).then(res => {
|
|
|
|
cb(null, res.data);
|
|
|
|
}).catch(err => {
|
|
|
|
cb(err);
|
2018-08-14 05:13:59 -04:00
|
|
|
});
|
|
|
|
}]);
|