Skip to content
Snippets Groups Projects
Commit 1d65f8f0 authored by Janis Streib's avatar Janis Streib :owl:
Browse files

ADD: search by vlan (closes #157)

parent d333dde5
No related branches found
No related tags found
No related merge requests found
Pipeline #274938 passed with warnings
......@@ -65,6 +65,18 @@ export default {
]
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) {
const ta = [
{
......
......@@ -148,6 +148,7 @@ export default {
this.search_res.forEach(item => {
let index = -1
let record_composit = null
let compiled_term = null
switch (item.type.toLowerCase()) {
case 'dns.record':
record_composit = item.term.fqdn + ' IN ' + item.term.type + ' ' + item.term.data
......@@ -231,6 +232,35 @@ export default {
}
}
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
......@@ -244,6 +274,9 @@ export default {
if (type.startsWith('dns.')) {
return 'map-signs'
}
if (type === 'nd.vlan') {
return 'ethernet'
}
if (type.startsWith('nd.')) {
return 'network-wired'
}
......@@ -313,8 +346,11 @@ export default {
this.descriminator = this.getSearchDiscriminator()
const term = this.cutDescriminator().trim()
const termIsIP = ipaddress.isValid(term.split('/')[0])
const termIsNumeric = !isNaN(parseInt(term))
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.searchBCDSubnet(this.$store.state.netdb_axios_config, term, true), 'nd.ip_subnet')
} else {
......@@ -322,7 +358,9 @@ export default {
this.dispatch_search(SearchService.searchRecordRegex(this.$store.state.netdb_axios_config, term, true), 'dns.record')
}
} 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.searchBCDSubnet(this.$store.state.netdb_axios_config, term, null), 'nd.ip_subnet')
} else {
......
......@@ -46,7 +46,8 @@ import {
faRadiation,
faMapSigns,
faNetworkWired,
faHistory
faHistory,
faEthernet
} from '@fortawesome/free-solid-svg-icons'
import {
......@@ -113,5 +114,6 @@ library.add(
faRadiation,
faMapSigns,
faNetworkWired,
faHistory
faHistory,
faEthernet
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment