|
64 | 64 | <a-row |
65 | 65 | v-for="param in vnfOperation.requiredParameters" |
66 | 66 | :key="param.name" |
67 | | - gutter="16" |
| 67 | + gutter="12" |
68 | 68 | style="margin-bottom: 1rem; align-items: center;" |
69 | 69 | > |
70 | 70 | <a-col :span="12"> |
71 | | - <strong>{{ param.description }}</strong> |
| 71 | + {{ param.description }} |
72 | 72 | </a-col> |
73 | 73 |
|
74 | 74 | <a-col :span="6"> |
|
94 | 94 | import { getAPI, postAPI } from '@/api' |
95 | 95 | import Status from '@/components/widgets/Status' |
96 | 96 | import { h } from 'vue' |
| 97 | +import yaml from 'js-yaml' |
97 | 98 |
|
98 | 99 | export default { |
99 | 100 | name: 'VnfAppliancesTab', |
@@ -188,7 +189,9 @@ export default { |
188 | 189 | '{"name":"destination_port","type":"string","description":"Destination port number or any"},' + |
189 | 190 | '{"name":"descr","type":"string","description":"Description of the firewall rule"},' + |
190 | 191 | '{"name":"vnf_rule_id","type":"string","description":"Unique identifier for the VNF firewall rule"}]') |
191 | | - this.vnfOperation.optionalParameters = '' |
| 192 | + console.log('yaml 1 = ' + yaml.dump(this.vnfOperation.requiredParameters)) |
| 193 | + this.vnfOperation.optionalParameters = yaml.load('firewall: {action: pass, interface: lan, protocol: tcp}') |
| 194 | + console.log('yaml 2 = ' + yaml.dump(this.vnfOperation.optionalParameters)) |
192 | 195 | } |
193 | 196 | if (this.vnfOperation.autoSubmit) { |
194 | 197 | this.handleSubmit() |
@@ -216,20 +219,68 @@ export default { |
216 | 219 | '{"uuid":"123e4567-e89b-12d3-a456-426614174000","id":1,"action":"pass","enabled":true,"interface":"lan","direction":"in","ipprotocol":"inet","protocol":"tcp","source_net":"192.168.1.0/24","source_port":"any","destination_net":"any","destination_port":443,"description":"Allow LAN → any on HTTPS"},' + |
217 | 220 | '{"uuid":"123e4567-e89b-12d3-a456-426614174001","id":2,"action":"block","enabled":true,"interface":"lan","direction":"in","ipprotocol":"inet","protocol":"any","source_net":"any","source_port":"any","destination_net":"192.168.1.0/24","destination_port":"any","description":"Block any inbound to LAN subnet"},' + |
218 | 221 | '{"uuid":"123e4567-e89b-12d3-a456-426614174002","id":3,"action":"pass","enabled":true,"interface":"wan","direction":"in","ipprotocol":"inet","protocol":"tcp","source_net":"any","source_port":"any","destination_net":"203.0.113.10","destination_port":22,"description":"Allow SSH access to firewall host"}]}' |
| 222 | + } else if (this.vnfOperationName === 'FIREWALL_RULE_CREATE') { |
| 223 | + this.vnfOperationResponse = '{"result":' + |
| 224 | + '{"uuid":"123e4567-e89b-12d3-a456-426614174002","id":3,"action":"pass","enabled":true,"interface":"wan","direction":"in","ipprotocol":"inet","protocol":"tcp","source_net":"any","source_port":"any","destination_net":"203.0.113.10","destination_port":22,"description":"Allow SSH access to firewall host"}}' |
219 | 225 | } |
220 | 226 | this.processVnfOperationResponse() |
221 | 227 | }) |
222 | 228 | }, |
223 | 229 | processVnfOperationResponse () { |
224 | 230 | const message = this.$t('label.vnf.operation.response') + ' : ' + this.vnfOperationName |
225 | 231 | this.vnfOperationResponseNode = [h('p', `${message}`)] |
226 | | - let parsedVnfOperationResponse = JSON.parse(this.vnfOperationResponse)?.result |
| 232 | + const parsedVnfOperationResponse = JSON.parse(this.vnfOperationResponse)?.result |
227 | 233 | if (!parsedVnfOperationResponse) { |
228 | 234 | this.vnfOperationResponseNode = h('div', this.vnfOperationResponseNode) |
229 | 235 | return |
230 | 236 | } |
231 | | - if (parsedVnfOperationResponse && !Array.isArray(parsedVnfOperationResponse) && typeof parsedVnfOperationResponse === 'object' && Object.keys(parsedVnfOperationResponse).length > 0) { |
232 | | - parsedVnfOperationResponse = [parsedVnfOperationResponse] |
| 237 | + if (!Array.isArray(parsedVnfOperationResponse) && typeof parsedVnfOperationResponse === 'object' && Object.keys(parsedVnfOperationResponse).length > 0) { |
| 238 | + this.vnfOperationResponseNode.push( |
| 239 | + h('div', { |
| 240 | + style: { |
| 241 | + marginTop: '1em', |
| 242 | + maxHeight: '50vh', |
| 243 | + maxWidth: '100%', |
| 244 | + overflow: 'auto', |
| 245 | + backgroundColor: '#f6f6f6', |
| 246 | + border: '1px solid #ddd', |
| 247 | + borderRadius: '4px', |
| 248 | + display: 'block' |
| 249 | + } |
| 250 | + }, [ |
| 251 | + h('table', { |
| 252 | + style: { |
| 253 | + width: '100%', |
| 254 | + minWidth: 'max-content', |
| 255 | + borderCollapse: 'collapse', |
| 256 | + whiteSpace: 'pre-wrap' |
| 257 | + } |
| 258 | + }, [ |
| 259 | + h('tbody', |
| 260 | + Object.keys(parsedVnfOperationResponse).map(key => |
| 261 | + h('tr', [ |
| 262 | + h('td', { |
| 263 | + style: { |
| 264 | + padding: '8px', |
| 265 | + border: '1px solid #ddd', |
| 266 | + textAlign: 'left', |
| 267 | + fontWeight: 'bold', |
| 268 | + backgroundColor: '#fafafa' |
| 269 | + } |
| 270 | + }, key), |
| 271 | + h('td', { |
| 272 | + style: { |
| 273 | + padding: '8px', |
| 274 | + border: '1px solid #ddd', |
| 275 | + textAlign: 'left' |
| 276 | + } |
| 277 | + }, String(parsedVnfOperationResponse[key])) |
| 278 | + ]) |
| 279 | + ) |
| 280 | + ) |
| 281 | + ]) |
| 282 | + ]) |
| 283 | + ) |
233 | 284 | } |
234 | 285 |
|
235 | 286 | if (Array.isArray(parsedVnfOperationResponse) && parsedVnfOperationResponse.length > 0) { |
|
0 commit comments