소스 검색

add support for fork host

pull/1/head
Jonathan Cobb 4 년 전
부모
커밋
a45c053235
4개의 변경된 파일60개의 추가작업 그리고 13개의 파일을 삭제
  1. +11
    -1
      src/_services/network.service.js
  2. +14
    -5
      src/_store/networks.module.js
  3. +6
    -4
      src/_store/system.module.js
  4. +29
    -3
      src/account/NewNetworkPage.vue

+ 11
- 1
src/_services/network.service.js 파일 보기

@@ -6,6 +6,7 @@ export const networkService = {
getNetworkById,
getNearestRegions,
startNetwork,
forkNetwork,
getStatusesByNetworkId,
getNodesByNetworkId,
stopNetwork,
@@ -27,11 +28,20 @@ function getNearestRegions(footprint, messages, errors) {
return fetch(`${config.apiUrl}/me/regions/closest${footprintParam}`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getCloudAndRegion(cloud, region) {
return (typeof cloud === 'undefined' || typeof region === 'undefined' || cloud === null || region === null) ? "" : `?cloud=${cloud}&region=${region}`;
}

function startNetwork(userId, planId, cloud, region, messages, errors) {
const cloudAndRegion = (typeof cloud === 'undefined' || typeof region === 'undefined' || cloud === null || region === null) ? "" : `?cloud=${cloud}&region=${region}`;
const cloudAndRegion = getCloudAndRegion(cloud, region);
return fetch(`${config.apiUrl}/users/${userId}/networks/${planId}/actions/start${cloudAndRegion}`, util.postWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function forkNetwork(userId, planId, forkHost, cloud, region, messages, errors) {
const cloudAndRegion = getCloudAndRegion(cloud, region);
return fetch(`${config.apiUrl}/users/${userId}/networks/${planId}/actions/fork/${forkHost}${cloudAndRegion}`, util.postWithAuth()).then(util.handleCrudResponse(messages, errors));
}

function getStatusesByNetworkId(userId, networkId, messages, errors) {
return fetch(`${config.apiUrl}/users/${userId}/networks/${networkId}/actions/status`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors));
}


+ 14
- 5
src/_store/networks.module.js 파일 보기

@@ -45,11 +45,20 @@ const actions = {
accountPlanService.newAccountPlan(userId, accountPlan, messages, errors)
.then(
plan => {
networkService.startNetwork(userId, plan.name, cloud, region, messages, errors)
.then(
newNodeNotification => commit('addPlanAndStartNetworkSuccess', newNodeNotification),
error => commit('addPlanSuccessStartNetworkFailure', error)
);
if (accountPlan.forkHost && accountPlan.forkHost !== '') {
networkService.forkNetwork(userId, plan.name, accountPlan.forkHost, cloud, region, messages, errors)
.then(
newNodeNotification => commit('addPlanAndStartNetworkSuccess', newNodeNotification),
error => commit('addPlanSuccessStartNetworkFailure', error)
);

} else {
networkService.startNetwork(userId, plan.name, cloud, region, messages, errors)
.then(
newNodeNotification => commit('addPlanAndStartNetworkSuccess', newNodeNotification),
error => commit('addPlanSuccessStartNetworkFailure', error)
);
}
},
error => commit('addPlanFailure', error)
);


+ 6
- 4
src/_store/system.module.js 파일 보기

@@ -151,10 +151,6 @@ const getters = {
href: '/me',
title: messages.label_menu_account,
icon: messages.label_menu_account_icon
}, {
href: '/devices',
title: messages.label_menu_devices,
icon: messages.label_menu_devices_icon
}, {
href: '/notifications',
title: messages.label_menu_notifications,
@@ -170,6 +166,12 @@ const getters = {
title: messages.label_menu_networks,
icon: messages.label_menu_networks_icon
});
} else {
menu.splice(3, 0, {
href: '/devices',
title: messages.label_menu_devices,
icon: messages.label_menu_devices_icon
});
}
if (configs.paymentsEnabled) {
menu.splice(4, 0,{


+ 29
- 3
src/account/NewNetworkPage.vue 파일 보기

@@ -30,8 +30,32 @@
</div>
<div v-else>
<form @submit.prevent="handleSubmit">

<div v-if="configs && configs.sageLauncher && configs.sageLauncher === true && user && user.admin === true">
<!-- network type -->
<div class="form-group">
<label for="networkType">{{messages.field_label_network_type}}</label>
<select v-model="networkType" name="networkType" class="form-control">
<option value="bubble">{{messages.field_label_network_type_regular}}</option>
<option value="fork">{{messages.field_label_network_type_fork}}</option>
</select>
</div>
<!-- fork host -->
<div v-if="networkType === 'fork'" class="form-group">
<label for="forkHost">{{messages.field_label_network_fork_host}}</label>
<input type="text" v-model="accountPlan.forkHost" name="forkHost" class="form-control" :class="{ 'is-invalid': submitted && errors.has('forkHost') }" />
<div v-if="submitted && errors.has('forkHost')" class="invalid-feedback">{{ errors.first('forkHost') }}</div>
{{messages.field_description_network_fork_host}}
</div>
<!-- OR, name -->
<div v-else class="form-group">
<label for="name">{{messages.field_label_network_name}}</label>
<input type="text" v-model="accountPlan.name" v-validate="'required'" name="name" class="form-control" :class="{ 'is-invalid': submitted && errors.has('name') }" />
<div v-if="submitted && errors.has('name')" class="invalid-feedback">{{ errors.first('name') }}</div>
</div>
</div>
<!-- name -->
<div class="form-group">
<div v-else class="form-group">
<label for="name">{{messages.field_label_network_name}}</label>
<input type="text" v-model="accountPlan.name" v-validate="'required'" name="name" class="form-control" :class="{ 'is-invalid': submitted && errors.has('name') }" />
<div v-if="submitted && errors.has('name')" class="invalid-feedback">{{ errors.first('name') }}</div>
@@ -237,8 +261,10 @@
paymentMethodType: null,
paymentInfo: null
},
sshKey: ''
sshKey: '',
forkHost: ''
},
networkType: 'bubble',
cloudRegionUuid: null,
regions: [],
customize: {
@@ -270,7 +296,7 @@
};
},
computed: {
...mapState('system', ['messages', 'locales', 'timezones', 'detectedTimezone', 'detectedLocale']),
...mapState('system', ['messages', 'locales', 'timezones', 'detectedTimezone', 'detectedLocale', 'configs']),
...mapState('domains', ['domains']),
...mapState('plans', ['plans']),
...mapState('footprints', ['footprints']),


불러오는 중...
취소
저장