Commit 1d65f8f0 authored by Janis Streib's avatar Janis Streib 🦉
Browse files

ADD: search by vlan (closes #157)

parent d333dde5
Pipeline #117652 passed with stages
in 4 minutes and 56 seconds
...@@ -65,6 +65,18 @@ export default { ...@@ -65,6 +65,18 @@ export default {
] ]
return TransactionService.execute(config, ta) return TransactionService.execute(config, ta)
}, },
searchVlan(config, term) {
const ta = [
{
name: 'nd.vlan.list',
old: apiutil.denullify_dict({
id: term,
fetch_limit: 20
})
}
]
return TransactionService.execute(config, ta)
},
searchBCDSubnet(config, term, own) { searchBCDSubnet(config, term, own) {
const ta = [ const ta = [
{ {
......
...@@ -148,6 +148,7 @@ export default { ...@@ -148,6 +148,7 @@ export default {
this.search_res.forEach(item => { this.search_res.forEach(item => {
let index = -1 let index = -1
let record_composit = null let record_composit = null
let compiled_term = null
switch (item.type.toLowerCase()) { switch (item.type.toLowerCase()) {
case 'dns.record': case 'dns.record':
record_composit = item.term.fqdn + ' IN ' + item.term.type + ' ' + item.term.data record_composit = item.term.fqdn + ' IN ' + item.term.type + ' ' + item.term.data
...@@ -231,6 +232,35 @@ export default { ...@@ -231,6 +232,35 @@ export default {
} }
} }
break break
case 'nd.vlan':
compiled_term = item.term.name + ' (' + item.term.id + '@' + item.term.net_instnc + ')'
if (isRegex) {
suggestions.push({
name:
['',
compiled_term,
''
],
type: item.type,
url: '/dnsvs/bcds/' + item.term.bcd
})
} else {
index = compiled_term.toLowerCase().indexOf(search.toLowerCase())
if (index !== -1) {
suggestions.push({
name:
[compiled_term.substring(0, index),
compiled_term
.substring(index, index + search.length),
compiled_term
.substring(index + search.length)
],
type: item.type,
url: '/dnsvs/bcds/' + item.term.bcd
})
}
}
break
} }
}) })
return suggestions return suggestions
...@@ -244,6 +274,9 @@ export default { ...@@ -244,6 +274,9 @@ export default {
if (type.startsWith('dns.')) { if (type.startsWith('dns.')) {
return 'map-signs' return 'map-signs'
} }
if (type === 'nd.vlan') {
return 'ethernet'
}
if (type.startsWith('nd.')) { if (type.startsWith('nd.')) {
return 'network-wired' return 'network-wired'
} }
...@@ -313,8 +346,11 @@ export default { ...@@ -313,8 +346,11 @@ export default {
this.descriminator = this.getSearchDiscriminator() this.descriminator = this.getSearchDiscriminator()
const term = this.cutDescriminator().trim() const term = this.cutDescriminator().trim()
const termIsIP = ipaddress.isValid(term.split('/')[0]) const termIsIP = ipaddress.isValid(term.split('/')[0])
const termIsNumeric = !isNaN(parseInt(term))
if (this.descriminator == null) { // Nur is_own, ohne regex if (this.descriminator == null) { // Nur is_own, ohne regex
if (termIsIP) { if (termIsNumeric) {
this.dispatch_search(SearchService.searchVlan(this.$store.state.netdb_axios_config, parseInt(term)), 'nd.vlan')
} else if (termIsIP) {
this.dispatch_search(SearchService.searchRRByIP(this.$store.state.netdb_axios_config, term, true), 'dns.record') this.dispatch_search(SearchService.searchRRByIP(this.$store.state.netdb_axios_config, term, true), 'dns.record')
this.dispatch_search(SearchService.searchBCDSubnet(this.$store.state.netdb_axios_config, term, true), 'nd.ip_subnet') this.dispatch_search(SearchService.searchBCDSubnet(this.$store.state.netdb_axios_config, term, true), 'nd.ip_subnet')
} else { } else {
...@@ -322,7 +358,9 @@ export default { ...@@ -322,7 +358,9 @@ export default {
this.dispatch_search(SearchService.searchRecordRegex(this.$store.state.netdb_axios_config, term, true), 'dns.record') this.dispatch_search(SearchService.searchRecordRegex(this.$store.state.netdb_axios_config, term, true), 'dns.record')
} }
} else if (this.descriminator === 'dnsvs') { } else if (this.descriminator === 'dnsvs') {
if (termIsIP) { if (termIsNumeric) {
this.dispatch_search(SearchService.searchVlan(this.$store.state.netdb_axios_config, parseInt(term)), 'nd.vlan')
} else if (termIsIP) {
this.dispatch_search(SearchService.searchRRByIP(this.$store.state.netdb_axios_config, term, null), 'dns.record') this.dispatch_search(SearchService.searchRRByIP(this.$store.state.netdb_axios_config, term, null), 'dns.record')
this.dispatch_search(SearchService.searchBCDSubnet(this.$store.state.netdb_axios_config, term, null), 'nd.ip_subnet') this.dispatch_search(SearchService.searchBCDSubnet(this.$store.state.netdb_axios_config, term, null), 'nd.ip_subnet')
} else { } else {
......
...@@ -46,7 +46,8 @@ import { ...@@ -46,7 +46,8 @@ import {
faRadiation, faRadiation,
faMapSigns, faMapSigns,
faNetworkWired, faNetworkWired,
faHistory faHistory,
faEthernet
} from '@fortawesome/free-solid-svg-icons' } from '@fortawesome/free-solid-svg-icons'
import { import {
...@@ -113,5 +114,6 @@ library.add( ...@@ -113,5 +114,6 @@ library.add(
faRadiation, faRadiation,
faMapSigns, faMapSigns,
faNetworkWired, faNetworkWired,
faHistory faHistory,
faEthernet
) )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment