Remove dead code, make silence immutable
This commit is contained in:
parent
09bcb8c71a
commit
1918379668
33
api.go
33
api.go
|
@ -75,7 +75,6 @@ func (api *API) Register(r *route.Router) {
|
|||
r.Post("/silences", api.addSilence)
|
||||
|
||||
r.Get("/silence/:sid", api.getSilence)
|
||||
r.Put("/silence/:sid", api.setSilence)
|
||||
r.Del("/silence/:sid", api.delSilence)
|
||||
}
|
||||
|
||||
|
@ -290,38 +289,6 @@ func (api *API) getSilence(w http.ResponseWriter, r *http.Request) {
|
|||
respond(w, &sil)
|
||||
}
|
||||
|
||||
func (api *API) setSilence(w http.ResponseWriter, r *http.Request) {
|
||||
var sil types.Silence
|
||||
if err := receive(r, &sil); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
sids := route.Param(api.context(r), "sid")
|
||||
sid, err := strconv.ParseUint(sids, 10, 64)
|
||||
if err != nil {
|
||||
respondError(w, apiError{
|
||||
typ: errorBadData,
|
||||
err: err,
|
||||
}, nil)
|
||||
}
|
||||
sil.ID = sid
|
||||
|
||||
sid, err = api.silences.Set(&sil)
|
||||
if err != nil {
|
||||
respondError(w, apiError{
|
||||
typ: errorBadData,
|
||||
err: err,
|
||||
}, &sil)
|
||||
return
|
||||
}
|
||||
respond(w, struct {
|
||||
SilenceID uint64 `json:"silenceId"`
|
||||
}{
|
||||
SilenceID: sid,
|
||||
})
|
||||
}
|
||||
|
||||
func (api *API) delSilence(w http.ResponseWriter, r *http.Request) {
|
||||
sids := route.Param(api.context(r), "sid")
|
||||
sid, err := strconv.ParseUint(sids, 10, 64)
|
||||
|
|
|
@ -58,52 +58,6 @@ angular.module('am.directives').directive('silenceForm',
|
|||
|
||||
angular.module('am.services', ['ngResource']);
|
||||
|
||||
angular.module('am.services').factory('RecursionHelper',
|
||||
function($compile) {
|
||||
return {
|
||||
/**
|
||||
* Manually compiles the element, fixing the recursion loop.
|
||||
* @param element
|
||||
* @param [link] A post-link function, or an object with function(s) registered via pre and post properties.
|
||||
* @returns An object containing the linking functions.
|
||||
*/
|
||||
compile: function(element, link) {
|
||||
// Normalize the link parameter
|
||||
if (angular.isFunction(link)) {
|
||||
link = {
|
||||
post: link
|
||||
};
|
||||
}
|
||||
|
||||
// Break the recursion loop by removing the contents
|
||||
var contents = element.contents().remove();
|
||||
var compiledContents;
|
||||
return {
|
||||
pre: (link && link.pre) ? link.pre : null,
|
||||
/**
|
||||
* Compiles and re-adds the contents
|
||||
*/
|
||||
post: function(scope, element) {
|
||||
// Compile the contents
|
||||
if (!compiledContents) {
|
||||
compiledContents = $compile(contents);
|
||||
}
|
||||
// Re-add the compiled contents to the element
|
||||
compiledContents(scope, function(clone) {
|
||||
element.append(clone);
|
||||
});
|
||||
|
||||
// Call the post-linking function, if any
|
||||
if (link && link.post) {
|
||||
link.post.apply(null, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
angular.module('am.services').factory('Silence',
|
||||
function($resource) {
|
||||
return $resource('', {
|
||||
|
@ -121,10 +75,6 @@ angular.module('am.services').factory('Silence',
|
|||
method: 'GET',
|
||||
url: '/api/v1/silence/:id'
|
||||
},
|
||||
'save': {
|
||||
method: 'POST',
|
||||
url: '/api/v1/silence/:id'
|
||||
},
|
||||
'delete': {
|
||||
method: 'DELETE',
|
||||
url: '/api/v1/silence/:id'
|
||||
|
|
Loading…
Reference in New Issue