diff --git a/frontend/src/api-services/search.service.js b/frontend/src/api-services/search.service.js index 309de93ee3e5da28e6f724a26c471a2556e0f7b3..a336db593ec0edf0591adbd52b5f04de5b770783 100644 --- a/frontend/src/api-services/search.service.js +++ b/frontend/src/api-services/search.service.js @@ -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 = [ { diff --git a/frontend/src/components/GlobalSearch.vue b/frontend/src/components/GlobalSearch.vue index 50e68ff45b2226883a3a1c2a3b2bda3299ee6f1d..5fade8ef273d22b9aead7c24398be3d91f83035d 100644 --- a/frontend/src/components/GlobalSearch.vue +++ b/frontend/src/components/GlobalSearch.vue @@ -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 { diff --git a/frontend/src/icons.js b/frontend/src/icons.js index 514c656016aa5ae4669191a05a9f66e1a47c5a88..09dde85a95acd5355ae536ec19b58edbb00637cd 100644 --- a/frontend/src/icons.js +++ b/frontend/src/icons.js @@ -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 )