-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(octavia): add pool edition view
ref: MANAGER-12302 Signed-off-by: Jacques Larique <[email protected]>
- Loading branch information
Jacques Larique
committed
Nov 30, 2023
1 parent
0f8a777
commit 6e3efc4
Showing
23 changed files
with
259 additions
and
29 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
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
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
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
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
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
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
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
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
19 changes: 19 additions & 0 deletions
19
...er/modules/octavia-load-balancer/src/load-balancers/load-balancer/pools/edit/component.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,19 @@ | ||
import controller from './controller'; | ||
import template from './template.html'; | ||
|
||
export default { | ||
bindings: { | ||
projectId: '<', | ||
region: '<', | ||
poolId: '<', | ||
pool: '<', | ||
algorithms: '<', | ||
poolProtocols: '<', | ||
sessionPersistenceTypes: '<', | ||
trackEditAction: '<', | ||
trackEditPage: '<', | ||
goBack: '<', | ||
}, | ||
controller, | ||
template, | ||
}; |
5 changes: 5 additions & 0 deletions
5
...er/modules/octavia-load-balancer/src/load-balancers/load-balancer/pools/edit/constants.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,5 @@ | ||
export const TRACKING_HIT_PREFIX = 'edit'; | ||
|
||
export default { | ||
TRACKING_HIT_PREFIX, | ||
}; |
69 changes: 69 additions & 0 deletions
69
...r/modules/octavia-load-balancer/src/load-balancers/load-balancer/pools/edit/controller.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,69 @@ | ||
export default class OctaviaLoadBalancerPoolsEditCtrl { | ||
/* @ngInject */ | ||
constructor(OctaviaLoadBalancerPoolsService, Alerter, $translate) { | ||
this.OctaviaLoadBalancerPoolsService = OctaviaLoadBalancerPoolsService; | ||
this.Alerter = Alerter; | ||
this.$translate = $translate; | ||
} | ||
|
||
$onInit() { | ||
this.loading = false; | ||
this.model = { | ||
name: this.pool.name, | ||
algorithm: this.pool.algorithm, | ||
protocol: this.pool.protocol, | ||
persistentSession: this.pool.sessionPersistence, | ||
cookieName: this.pool.sessionPersistence.cookieName, | ||
hasSession: this.pool.sessionPersistence.type !== 'disabled', | ||
}; | ||
} | ||
|
||
submit() { | ||
this.loading = true; | ||
this.trackEditAction('confirm'); | ||
const sessionPersistence = this.model.hasSession | ||
? { | ||
type: this.model.persistentSession.value, | ||
cookieName: this.model.cookieName, | ||
} | ||
: undefined; | ||
this.OctaviaLoadBalancerPoolsService.editPool( | ||
this.projectId, | ||
this.region, | ||
this.poolId, | ||
this.model.name, | ||
this.model.algorithm.value, | ||
sessionPersistence, | ||
) | ||
.then(async () => { | ||
this.trackEditPage('success'); | ||
this.Alerter.set( | ||
'alert-success', | ||
this.$translate.instant('octavia_load_balancer_pools_edit_success', { | ||
pool: this.model.name, | ||
}), | ||
null, | ||
'octavia.alerts.global', | ||
); | ||
await this.goBack(true); | ||
}) | ||
.catch((error) => { | ||
this.trackEditPage('error'); | ||
this.Alerter.error( | ||
this.$translate.instant('octavia_load_balancer_global_error', { | ||
message: error.data?.message, | ||
requestId: error.headers('X-Ovh-Queryid'), | ||
}), | ||
'octavia.alerts.global', | ||
); | ||
}) | ||
.finally(() => { | ||
this.loading = false; | ||
}); | ||
} | ||
|
||
cancel() { | ||
this.trackEditAction('cancel'); | ||
this.goBack(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...anager/modules/octavia-load-balancer/src/load-balancers/load-balancer/pools/edit/index.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,22 @@ | ||
import angular from 'angular'; | ||
import '@uirouter/angularjs'; | ||
import 'oclazyload'; | ||
|
||
const moduleName = 'ovhManagerOctaviaLoadBalancerDashboardPoolsEditLazyLoading'; | ||
|
||
angular.module(moduleName, ['ui.router', 'oc.lazyLoad']).config( | ||
/* @ngInject */ ($stateProvider) => { | ||
$stateProvider.state('octavia-load-balancer.loadbalancer.pools.edit.**', { | ||
url: '/:poolId/edit', | ||
lazyLoad: ($transition$) => { | ||
const $ocLazyLoad = $transition$.injector().get('$ocLazyLoad'); | ||
|
||
return import('./module').then((mod) => | ||
$ocLazyLoad.inject(mod.default || mod), | ||
); | ||
}, | ||
}); | ||
}, | ||
); | ||
|
||
export default moduleName; |
15 changes: 15 additions & 0 deletions
15
...nager/modules/octavia-load-balancer/src/load-balancers/load-balancer/pools/edit/module.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,15 @@ | ||
import angular from 'angular'; | ||
|
||
import component from './component'; | ||
import routing from './routing'; | ||
|
||
import poolComponents from '../components'; | ||
|
||
const moduleName = 'ovhManagerOctaviaLoadBalancerPoolsEdit'; | ||
|
||
angular | ||
.module(moduleName, [poolComponents]) | ||
.config(routing) | ||
.component('octaviaLoadBalancerPoolsEdit', component); | ||
|
||
export default moduleName; |
39 changes: 39 additions & 0 deletions
39
...ager/modules/octavia-load-balancer/src/load-balancers/load-balancer/pools/edit/routing.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,39 @@ | ||
import { TRACKING_HIT_PREFIX } from './constants'; | ||
import { TRACKING_SUFFIX } from '../constants'; | ||
import { TRACKING_NAME } from '../../constants'; | ||
|
||
export default /* @ngInject */ ($stateProvider) => { | ||
$stateProvider.state('octavia-load-balancer.loadbalancer.pools.edit', { | ||
url: '/:poolId/edit', | ||
views: { | ||
loadbalancerPoolsView: 'octaviaLoadBalancerPoolsEdit', | ||
}, | ||
resolve: { | ||
breadcrumb: () => null, | ||
poolId: /* @ngInject */ ($transition$) => $transition$.params().poolId, | ||
pool: /* @ngInject */ ( | ||
OctaviaLoadBalancerPoolsService, | ||
projectId, | ||
region, | ||
poolId, | ||
) => OctaviaLoadBalancerPoolsService.getPool(projectId, region, poolId), | ||
goBack: /* @ngInject */ ($state, poolId) => (reload) => | ||
$state.go( | ||
'octavia-load-balancer.loadbalancer.pools.detail', | ||
{ | ||
poolId, | ||
}, | ||
reload | ||
? { reload: 'octavia-load-balancer.loadbalancer.pools.detail' } | ||
: null, | ||
), | ||
trackEditAction: /* @ngInject */ (trackAction) => (hit) => | ||
trackAction(`${TRACKING_HIT_PREFIX}::${hit}`), | ||
trackEditPage: /* @ngInject */ (trackPage) => (hit) => | ||
trackPage(`${TRACKING_HIT_PREFIX}-${hit}`), | ||
}, | ||
atInternet: { | ||
rename: `${TRACKING_NAME}::${TRACKING_SUFFIX}::${TRACKING_HIT_PREFIX}`, | ||
}, | ||
}); | ||
}; |
14 changes: 14 additions & 0 deletions
14
...r/modules/octavia-load-balancer/src/load-balancers/load-balancer/pools/edit/template.html
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,14 @@ | ||
<div class="text-center" data-ng-if="$ctrl.loading"> | ||
<oui-spinner></oui-spinner> | ||
</div> | ||
|
||
<octavia-load-balancer-pool-form | ||
data-ng-if="!$ctrl.loading" | ||
data-algorithms="$ctrl.algorithms" | ||
data-protocols="$ctrl.poolProtocols" | ||
data-session-persistence-types="$ctrl.sessionPersistenceTypes" | ||
data-model="$ctrl.model" | ||
data-is-editing="true" | ||
data-on-submit="$ctrl.submit()" | ||
data-on-cancel="$ctrl.cancel()" | ||
></octavia-load-balancer-pool-form> |
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
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
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
Oops, something went wrong.