From 19183796681819ff83e636e8d14b418bbfd41e37 Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Mon, 9 Nov 2015 12:34:31 +0100 Subject: [PATCH] Remove dead code, make silence immutable --- api.go | 33 -------------------------------- ui/app/js/app.js | 50 ------------------------------------------------ 2 files changed, 83 deletions(-) diff --git a/api.go b/api.go index 8627f6fb..775a40b0 100644 --- a/api.go +++ b/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) diff --git a/ui/app/js/app.js b/ui/app/js/app.js index aa4f2917..e11dcea2 100644 --- a/ui/app/js/app.js +++ b/ui/app/js/app.js @@ -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'