This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(xdsl): add auto diagnostic routes
- Loading branch information
Jérémy DE CESARE
committed
Aug 28, 2018
1 parent
236a89b
commit 4360d0d
Showing
5 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/xdsl/diagnostic/lines/xdsl-diagnostic-lines.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
angular.module("ovh-api-services").service("OvhApiXdslDiagnosticLines", function ($injector, $cacheFactory) { | ||
"use strict"; | ||
|
||
var cache = $cacheFactory("OvhApiXdslDiagnosticLines"); | ||
|
||
return { | ||
v6: function () { | ||
return $injector.get("OvhApiXdslDiagnosticLinesV6"); | ||
}, | ||
resetCache: cache.removeAll, | ||
cache: cache | ||
}; | ||
}); |
66 changes: 66 additions & 0 deletions
66
src/xdsl/diagnostic/lines/xdsl-diagnostic-lines.v6.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
angular.module("ovh-api-services").service("OvhApiXdslDiagnosticLinesV6", function ($resource, Poller, OvhApiXdslDiagnosticLines) { | ||
"use strict"; | ||
|
||
var routes = { | ||
base: "/xdsl/:serviceName/lines/:number/diagnostic", | ||
cancel: "/xdsl/:serviceName/lines/:number/diagnostic/cancel", | ||
run: "/xdsl/:serviceName/lines/:number/diagnostic/run" | ||
}; | ||
|
||
var interceptor = function (response) { | ||
OvhApiXdslDiagnosticLines.resetCache(); | ||
return response; | ||
}; | ||
|
||
var diagnostic = $resource(routes.base, { | ||
serviceName: "@serviceName", | ||
number: "@number" | ||
}, { | ||
cancelDiagnostic: { | ||
url: routes.cancel, | ||
method: "POST", | ||
isArray: false, | ||
interceptor: interceptor | ||
} | ||
}); | ||
|
||
diagnostic.runDiagnostic = function (opts) { | ||
// Replacement of each :myRouteParam by the corresponding json property | ||
// (Example: :serviceName by opts.serviceName) | ||
var url = routes.run.replace(/\/:(\w*)\//g, function (match, replacement) { | ||
return "/" + opts[replacement] + "/"; | ||
}); | ||
|
||
return Poller.poll( | ||
url, | ||
{ | ||
cache: false | ||
}, | ||
{ | ||
method: "post", | ||
postData: _.omit(opts, ["serviceName", "number"]), | ||
interval: 30000, | ||
successRule: function (response) { | ||
if (response.status !== "problem") { | ||
return true; | ||
} | ||
|
||
return _.isEqual(_.get(response, "data.error", ""), "monitoringTodoAlreadyExists"); | ||
}, | ||
errorRule: function (response) { | ||
return _.isEqual(response.status, "problem") && | ||
!_.isEqual(_.get(response, "data.error", ""), "monitoringTodoAlreadyExists"); | ||
}, | ||
namespace: "xdsl_diagnostic_run" | ||
} | ||
); | ||
}; | ||
|
||
diagnostic.killPollerDiagnostic = function () { | ||
return Poller.kill({ | ||
namespace: "xdsl_diagnostic_run" | ||
}); | ||
}; | ||
|
||
return diagnostic; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters