Skip to content

Commit db0d0cc

Browse files
marie-jjleveugle
authored andcommitted
feat(pci): add components for instance creation
1 parent 43636ff commit db0d0cc

32 files changed

+1103
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import controller from './flavor-billing.controller';
2+
import template from './flavor-billing.html';
3+
4+
export default {
5+
controller,
6+
template,
7+
bindings: {
8+
flavor: '<',
9+
number: '<?',
10+
monthlyBilling: '=?',
11+
},
12+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export default class FlavorBillingController {
2+
$onInit() {
3+
this.monthly = true;
4+
this.number = this.number || 1;
5+
}
6+
7+
selectBilling(monthlyBilling) {
8+
this.monthlyBilling = monthlyBilling;
9+
}
10+
11+
getPrice(price) {
12+
return this.number * price.value;
13+
}
14+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="row">
2+
<oui-select-picker
3+
class="d-inline-block col-md-6 col-lg-4 my-3"
4+
data-name="flavor-billing"
5+
data-label="{{:: 'pci_project_flavors_billing_monthly' | translate }}"
6+
data-model="$ctrl.monthly"
7+
data-values="[true]"
8+
data-variant="light"
9+
data-on-change="$ctrl.selectBilling(modelValue)">
10+
<oui-select-picker-section data-ng-if="$ctrl.flavor">
11+
<span
12+
data-translate="pci_project_flavors_billing_price_monthly"
13+
data-translate-values="{ price: ($ctrl.getPrice($ctrl.flavor.prices.monthly) | currency: $ctrl.flavor.prices.currencyCode) }">
14+
</span>
15+
</oui-select-picker-section>
16+
</oui-select-picker>
17+
<oui-select-picker
18+
class="d-inline-block col-md-6 col-lg-4 my-3"
19+
data-name="flavor-billing"
20+
data-label="{{:: 'pci_project_flavors_billing_hourly' | translate }}"
21+
data-model="$ctrl.monthly"
22+
data-values="[false]"
23+
data-variant="light"
24+
data-on-change="$ctrl.selectBilling(modelValue)">
25+
<oui-select-picker-section data-ng-if="$ctrl.flavor">
26+
<span
27+
data-translate="pci_project_flavors_billing_price_hourly"
28+
data-translate-values="{ price: ($ctrl.getPrice($ctrl.flavor.prices.hourly) | currency: $ctrl.flavor.prices.currencyCode) }">
29+
</span>
30+
</oui-select-picker-section>
31+
</oui-select-picker>
32+
</div>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export const DEFAULT_OS = 'linux';
2+
3+
export const CATEGORIES = [
4+
{
5+
category: 'balanced',
6+
pattern: /eg/,
7+
},
8+
{
9+
category: 'cpu',
10+
pattern: /cpu|hg/,
11+
},
12+
{
13+
category: 'ram',
14+
pattern: /ram/,
15+
},
16+
{
17+
category: 'accelerated',
18+
pattern: /gpu|nvme/,
19+
},
20+
{
21+
category: 'vps',
22+
pattern: /vps/,
23+
},
24+
];
25+
26+
export const FLEX_TYPE = /flex$/;
27+
28+
export const LEGACY_FLAVORS = /eg|sp|hg|vps-ssd/;
29+
30+
export const SSD_DISK_TYPES = [/ssd/, /nvme/];
31+
32+
export default {
33+
DEFAULT_OS,
34+
FLEX_TYPE,
35+
LEGACY_FLAVORS,
36+
SSD_DISK_TYPES,
37+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import angular from 'angular';
2+
import '@ovh-ux/ng-translate-async-loader';
3+
import '@ovh-ux/ng-ovh-cloud-universe-components';
4+
import 'angular-translate';
5+
import 'ovh-ui-angular';
6+
7+
import component from './flavor-billing.component';
8+
9+
const moduleName = 'ovhManagerPciFlavorBilling';
10+
11+
angular
12+
.module(moduleName, [
13+
'oui',
14+
'ngOvhCloudUniverseComponents',
15+
'ngTranslateAsyncLoader',
16+
'pascalprecht.translate',
17+
])
18+
.component('pciProjectFlavorBilling', component)
19+
.run(/* @ngTranslationsInject:json ./translations */);
20+
21+
export default moduleName;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"pci_project_flavors_billing_hourly": "Horaire",
3+
"pci_project_flavors_billing_monthly": "Mensuel",
4+
"pci_project_flavors_billing_price_hourly": "{{price}} HT/h",
5+
"pci_project_flavors_billing_price_monthly": "{{price}} HT/mois"
6+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import find from 'lodash/find';
2+
import map from 'lodash/map';
3+
import omit from 'lodash/omit';
4+
import union from 'lodash/union';
5+
6+
import { DEFAULT_OS } from './flavors-list.constants';
7+
8+
export default class FlavorGroup {
9+
constructor(flavors) {
10+
Object.assign(this, omit(find(flavors, { osType: DEFAULT_OS }), [
11+
'region', 'id', 'osType', 'planCodes',
12+
]));
13+
this.availableRegions = union(...map(flavors, 'regions'));
14+
this.flavors = flavors;
15+
}
16+
17+
isAvailableInRegion(region) {
18+
return this.availableRegions.includes(region);
19+
}
20+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { FLEX_TYPE, LEGACY_FLAVORS, SSD_DISK_TYPES } from './flavors-list.constants';
2+
3+
export default class Flavors {
4+
constructor(flavor) {
5+
Object.assign(this, flavor);
6+
7+
this.setDiskType();
8+
}
9+
10+
setDiskType() {
11+
this.diskType = SSD_DISK_TYPES.some(diskType => diskType.test(this.type)) ? 'ssd' : 'ceph';
12+
}
13+
14+
isLegacy() {
15+
return LEGACY_FLAVORS.test(this.name);
16+
}
17+
18+
isAvailable() {
19+
return this.available;
20+
}
21+
22+
isFlex() {
23+
return FLEX_TYPE.test(this.name);
24+
}
25+
26+
hasSsdDisk() {
27+
return this.diskType === 'ssd';
28+
}
29+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import controller from './flavors-list.controller';
2+
import template from './flavors-list.html';
3+
4+
export default {
5+
controller,
6+
template,
7+
bindings: {
8+
selectedFlavor: '=?',
9+
displaySelectedFlavor: '<',
10+
serviceName: '@',
11+
},
12+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export const DEFAULT_OS = 'linux';
2+
3+
export const CATEGORIES = [
4+
{
5+
category: 'balanced',
6+
pattern: /eg/,
7+
},
8+
{
9+
category: 'cpu',
10+
pattern: /cpu|hg/,
11+
},
12+
{
13+
category: 'ram',
14+
pattern: /ram/,
15+
},
16+
{
17+
category: 'accelerated',
18+
pattern: /gpu|nvme/,
19+
},
20+
{
21+
category: 'vps',
22+
pattern: /vps/,
23+
},
24+
];
25+
26+
export const FLEX_TYPE = /flex$/;
27+
28+
export const LEGACY_FLAVORS = /eg|sp|hg|vps-ssd/;
29+
30+
export const SSD_DISK_TYPES = [/ssd/, /nvme/];
31+
32+
export default {
33+
DEFAULT_OS,
34+
FLEX_TYPE,
35+
LEGACY_FLAVORS,
36+
SSD_DISK_TYPES,
37+
};

0 commit comments

Comments
 (0)