infra: physical network and traffic type management

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
diff --git a/docs/api/apis.remaining b/docs/api/apis.remaining
index 9ba6b38..db90256 100644
--- a/docs/api/apis.remaining
+++ b/docs/api/apis.remaining
@@ -26,7 +26,6 @@
 deleteNetworkACL
 deleteNetworkACLList
 deleteNetworkServiceProvider
-deletePhysicalNetwork
 deletePortableIpRange
 deletePrivateGateway
 deleteStaticRoute
@@ -52,7 +51,6 @@
 listSupportedNetworkServices
 listVirtualRouterElements
 listVlanIpRanges
-listVmwareDcs
 moveNetworkAclItem
 releaseDedicatedGuestVlanRange
 releasePublicIpRange
diff --git a/src/config/section/infra.js b/src/config/section/infra.js
index eb000d0..c42cdf6 100644
--- a/src/config/section/infra.js
+++ b/src/config/section/infra.js
@@ -17,7 +17,6 @@
 
 import zones from '@/config/section/infra/zones'
 import phynetworks from '@/config/section/infra/phynetworks'
-import traffictypes from '@/config/section/infra/traffictypes'
 import nsp from '@/config/section/infra/nsp'
 import pods from '@/config/section/infra/pods'
 import clusters from '@/config/section/infra/clusters'
@@ -42,7 +41,6 @@
     },
     zones,
     phynetworks,
-    traffictypes,
     nsp,
     pods,
     clusters,
diff --git a/src/config/section/infra/phynetworks.js b/src/config/section/infra/phynetworks.js
index 45835c5..eaef111 100644
--- a/src/config/section/infra/phynetworks.js
+++ b/src/config/section/infra/phynetworks.js
@@ -27,6 +27,9 @@
     name: 'details',
     component: () => import('@/components/view/DetailsTab.vue')
   }, {
+    name: 'Traffic Types',
+    component: () => import('@/views/infra/traffic/TrafficTypesTab.vue')
+  }, {
     name: 'Network Service Providers',
     component: () => import('@/views/infra/traffic/NspTab.vue')
   }, {
@@ -44,11 +47,86 @@
   }],
   actions: [
     {
+      api: 'createPhysicalNetwork',
+      icon: 'plus',
+      label: 'Create Physical Network',
+      listView: true,
+      args: ['name', 'zoneid', 'isolationmethods', 'vlan', 'tags', 'networkspeed', 'broadcastdomainrange'],
+      mapping: {
+        isolationmethods: {
+          options: ['VLAN', 'VXLAN', 'GRE', 'STT', 'BCF_SEGMENT', 'SSP', 'ODL', 'L3VPN', 'VCS']
+        }
+      }
+    },
+    {
+      api: 'updatePhysicalNetwork',
+      icon: 'play-circle',
+      label: 'Enable Physical Network',
+      dataView: true,
+      args: ['state'],
+      show: (record) => { return record.state === 'Disabled' },
+      mapping: {
+        state: {
+          value: (record) => { return 'Enabled' }
+        }
+      }
+    },
+    {
+      api: 'updatePhysicalNetwork',
+      icon: 'stop',
+      label: 'Disable Physical Network',
+      dataView: true,
+      args: ['state'],
+      show: (record) => { return record.state === 'Enabled' },
+      mapping: {
+        state: {
+          value: (record) => { return 'Disabled' }
+        }
+      }
+    },
+    {
       api: 'updatePhysicalNetwork',
       icon: 'edit',
       label: 'Update Physical Network',
       dataView: true,
       args: ['vlan', 'tags']
+    },
+    {
+      api: 'addTrafficType',
+      icon: 'plus-square',
+      label: 'Add Traffic Type',
+      dataView: true,
+      args: ['traffictype', 'physicalnetworkid', 'isolationmethod'],
+      mapping: {
+        traffictype: {
+          options: ['Public', 'Guest', 'Management', 'Storage']
+        },
+        physicalnetworkid: {
+          value: (record) => { return record.id }
+        },
+        isolationmethod: {
+          options: ['', 'vlan', 'vxlan']
+        }
+      }
+    },
+    {
+      api: 'updateTrafficType',
+      icon: 'branches',
+      label: 'Update Traffic Labels',
+      dataView: true,
+      args: ['id', 'kvmnetworklabel', 'vmwarenetworklabel', 'xennetworklabel', 'hypervnetworklabel', 'ovm3networklabel'],
+      mapping: {
+        id: {
+          api: 'listTrafficTypes',
+          params: (record) => { return { physicalnetworkid: record.id } }
+        }
+      }
+    },
+    {
+      api: 'deletePhysicalNetwork',
+      icon: 'delete',
+      label: 'Delete Physical Network',
+      dataView: true
     }
   ]
 }
diff --git a/src/config/section/infra/traffictypes.js b/src/config/section/infra/traffictypes.js
deleted file mode 100644
index 8bad045..0000000
--- a/src/config/section/infra/traffictypes.js
+++ /dev/null
@@ -1,42 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-export default {
-  name: 'traffictype',
-  title: 'Traffic Types',
-  icon: 'branches',
-  hidden: true,
-  permission: ['listTrafficTypes'],
-  columns: ['traffictype', 'kvmnetworklabel', 'vmwarenetworklabel', 'xennetworklabel', 'physicalnetworkid'],
-  details: ['traffictype', 'kvmnetworklabel', 'vmwarenetworklabel', 'xennetworklabel', 'hypervnetworklabel', 'ovm3networklabel', 'physicalnetworkid'],
-  tabs: [{
-    name: 'details',
-    component: () => import('@/components/view/DetailsTab.vue')
-  }, {
-    name: 'IP Ranges',
-    component: () => import('@/views/infra/traffic/IpRangesTab.vue')
-  }],
-  actions: [
-    {
-      api: 'updateTrafficType',
-      icon: 'edit',
-      label: 'Update Traffic Labels',
-      dataView: true,
-      args: ['kvmnetworklabel', 'vmwarenetworklabel', 'xennetworklabel', 'hypervnetworklabel', 'ovm3networklabel']
-    }
-  ]
-}
diff --git a/src/locales/en.json b/src/locales/en.json
index 1f91a37..22455e5 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -333,7 +333,7 @@
 "key": "Key",
 "keyboardType": "Keyboard type",
 "keypair": "SSH Key Pair",
-"kvmnetworklabel": "KVM traffic label",
+"kvmnetworklabel": "KVM Traffic Label",
 "l2gatewayserviceuuid": "L2 Gateway Service Uuid",
 "l3gatewayserviceuuid": "L3 Gateway Service Uuid",
 "label.accept.project.invitation": "Accept project invitation",
@@ -765,10 +765,10 @@
 "overrideguesttraffic": "Override Guest-Traffic",
 "overridepublictraffic": "Override Public-Traffic",
 "ovm3cluster": "Native Clustering",
-"ovm3networklabel": "OVM3 traffic label",
+"ovm3networklabel": "OVM3 Traffic Label",
 "ovm3pool": "Native Pooling",
 "ovm3vip": "Master Vip IP",
-"ovmnetworklabel": "OVM traffic label",
+"ovmnetworklabel": "OVM Traffic Label",
 "palp": "Palo Alto Log Profile",
 "parentName": "Parent",
 "passive": "Passive",
@@ -1010,7 +1010,7 @@
 "vmwaredcId": "VMware Datacenter ID",
 "vmwaredcName": "VMware Datacenter Name",
 "vmwaredcVcenter": "VMware Datacenter vCenter",
-"vmwarenetworklabel": "VMware traffic label",
+"vmwarenetworklabel": "VMware Traffic Label",
 "volume": "Volume",
 "volumeChecksum": "MD5 checksum",
 "volumeFileUpload": "Local file",
@@ -1044,7 +1044,7 @@
 "vsmstoragevlanid": "Storage VLAN ID",
 "vsmusername": "Nexus 1000v Username",
 "vsmusername_req": "Nexus 1000v Username",
-"xennetworklabel": "XenServer traffic label",
+"xennetworklabel": "XenServer Traffic Label",
 "xenserverToolsVersion61plus": "Original XS Version is 6.1+",
 "zone": "Zone",
 "zones": "Zones",
diff --git a/src/views/AutogenView.vue b/src/views/AutogenView.vue
index 13ddffc..aad6ee1 100644
--- a/src/views/AutogenView.vue
+++ b/src/views/AutogenView.vue
@@ -147,7 +147,7 @@
                   }"
                 >
                   <a-select-option v-for="(opt, optIndex) in field.opts" :key="optIndex">
-                    {{ opt.name || opt.description }}
+                    {{ opt.name || opt.description || opt.traffictype }}
                   </a-select-option>
                 </a-select>
               </span>
diff --git a/src/views/infra/traffic/TrafficTypesTab.vue b/src/views/infra/traffic/TrafficTypesTab.vue
new file mode 100644
index 0000000..a38963c
--- /dev/null
+++ b/src/views/infra/traffic/TrafficTypesTab.vue
@@ -0,0 +1,95 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+<template>
+  <a-spin :spinning="fetchLoading">
+    <a-tabs :animated="false" defaultActiveKey="0" tabPosition="left" type="card">
+      <a-tab-pane v-for="(item, index) in traffictypes" :tab="item.traffictype" :key="index">
+        <div>
+          <strong>{{ $t('id') }}</strong> {{ item.id }}
+        </div>
+        <div v-for="(type, idx) in ['kvmnetworklabel', 'vmwarenetworklabel', 'xennetworklabel', 'hypervnetworklabel', 'ovm3networklabel']" :key="idx">
+          <strong>{{ $t(type) }}</strong>
+          {{ item[type] || 'Use default gateway' }}
+        </div>
+        <div v-if="item.traffictype === 'Public'">
+          Insert here form/component to manage public IP ranges
+          <IpRangesTab :resource="resource" />
+        </div>
+      </a-tab-pane>
+    </a-tabs>
+  </a-spin>
+</template>
+
+<script>
+import { api } from '@/api'
+import Status from '@/components/widgets/Status'
+import IpRangesTab from './IpRangesTab'
+
+export default {
+  name: 'NspTab',
+  components: {
+    IpRangesTab,
+    Status
+  },
+  props: {
+    resource: {
+      type: Object,
+      required: true
+    },
+    loading: {
+      type: Boolean,
+      default: false
+    }
+  },
+  data () {
+    return {
+      traffictypes: [],
+      fetchLoading: false
+    }
+  },
+  mounted () {
+    this.fetchData()
+  },
+  watch: {
+    loading (newData, oldData) {
+      if (!newData && this.resource.id) {
+        this.fetchData()
+      }
+    }
+  },
+  methods: {
+    fetchData () {
+      this.fetchLoading = true
+      api('listTrafficTypes', { physicalnetworkid: this.resource.id }).then(json => {
+        this.traffictypes = json.listtraffictypesresponse.traffictype
+      }).catch(error => {
+        this.$notification.error({
+          message: 'Request Failed',
+          description: error.response.headers['x-description']
+        })
+      }).finally(() => {
+        this.fetchLoading = false
+      })
+    }
+  }
+}
+</script>
+
+<style lang="less" scoped>
+
+</style>