From f090e72ead7d2b68e9f8713b695f9571db7c0a77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phanie=20MOALLIC?= Date: Thu, 6 Aug 2020 15:44:47 +0200 Subject: [PATCH] feat(xdsl): add both orderMeeting and searchOrderMeetings actions (#302) Signed-off-by: Stephanie Moallic --- src/api/xdsl/xdsl.v6.service.js | 37 +++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/src/api/xdsl/xdsl.v6.service.js b/src/api/xdsl/xdsl.v6.service.js index 37fd4830..f6505bfb 100644 --- a/src/api/xdsl/xdsl.v6.service.js +++ b/src/api/xdsl/xdsl.v6.service.js @@ -1,4 +1,4 @@ -angular.module('ovh-api-services').service('OvhApiXdslV6', ($resource, OvhApiXdsl, OvhApiTelecomSidebar) => { +angular.module('ovh-api-services').service('OvhApiXdslV6', ($resource, OvhApiXdsl, OvhApiTelecomSidebar, Poller) => { const interceptor = { response(response) { OvhApiTelecomSidebar.resetCache(); @@ -7,9 +7,10 @@ angular.module('ovh-api-services').service('OvhApiXdslV6', ($resource, OvhApiXds }, }; - return $resource( + const xdsl = $resource( '/xdsl/:xdslId', { xdslId: '@id', + serviceName: '@serviceName', }, { query: { method: 'GET', @@ -82,6 +83,38 @@ angular.module('ovh-api-services').service('OvhApiXdslV6', ($resource, OvhApiXds method: 'POST', url: '/xdsl/:xdslId/applyTemplateToModem', }, + orderMeeting: { + method: 'POST', + url: '/xdsl/:serviceName/orderMeeting', + interceptor, + }, }, ); + + xdsl.searchOrderMeetings = function ($scope, opts) { + const url = `/xdsl/${opts.serviceName}/searchOrderMeetings`; + + $scope.$on('$destroy', () => { + Poller.kill({ + scope: $scope.$id, + }); + }); + + return Poller.poll( + url, + null, + { + successRule: { + status(elem) { + return elem.status === 'error' || elem.status === 'ok'; + }, + }, + scope: $scope.$id, + method: 'POST', + retryMaxAttempts: 3, + }, + ); + }; + + return xdsl; });