Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 54 additions & 16 deletions web/dashboard/src/business/network/ingresses/ingress-search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ export default {
var map = {}
var result = []
lines.forEach(m => {
if (!map[m.targte + "-" + m.source]) {
if (!map[m.target + "-" + m.source]) {
result.push(m)
map[m.targte + "-" + m.source] = true
map[m.target + "-" + m.source] = true
}
})
return result
Expand Down Expand Up @@ -155,11 +155,58 @@ export default {
}
return { linkDataArray: linkDataArray, nodes: nodes, podsNodes: podsNodes }
},
toEnd(s) {
const str = s || "";
if (str.endsWith("/")) {
return str;
} else {
return str + "/";
}
},
toEndExp(s) {
const str = s || "";
if (str.endsWith("/")) {
return str;
} else {
return str + "(/|$)";
}
},
matchUrl(ingress, url,host ,path,pathType) {

let urlForMatch ="";
if (ingress.spec.tls != null && ingress.spec.tls.length > 0) {
urlForMatch=urlForMatch+"https://"+host+path;
} else {
urlForMatch=urlForMatch+"http://"+host+path;
}
if(pathType == "Prefix"){
return this.toEnd(url).startsWith(this.toEnd(urlForMatch))
} else if(pathType == "Exact"){
return this.toEnd(url) == this.toEnd(urlForMatch)
} else if(pathType == "ImplementationSpecific"){
if(this.toEnd(url).startsWith(this.toEnd(urlForMatch))){
return true
} else {
if(this.toEnd(url).match(this.toEndExp(urlForMatch))){
return true
} else {
return false
}
}
} else {
return this.toEnd(url).startsWith(this.toEnd(urlForMatch))
}
},
async renderCharts() {
if (document.getElementById("ingress-search-charts") == null) {
return
}
if (!this.search_url && !this.search_url.startsWith("http")) {
if (!this.search_url || this.search_url ==""){
this.$message.error("please input the url for ingress search")
return
}
if (!this.search_url || !this.search_url.startsWith("http")) {
this.$message.error("url is invalid")
return
}
this.loading = true
Expand Down Expand Up @@ -189,23 +236,14 @@ export default {
if (rule.host == search_host) {
is_same_domain = true

if (ingress.spec.tls != null && ingress.spec.tls.length > 0) {

for (var k = 0; k < rule.http.paths.length; k++) {
var path = rule.http.paths[k]
if (this.search_url.startsWith("https://" + rule.host + path.path)) {
is_same_path = true
break
}
}
} else {
for (var k = 0; k < rule.http.paths.length; k++) {
for (var k = 0; k < rule.http.paths.length; k++) {
var path = rule.http.paths[k]
if (this.search_url.startsWith("http://" + rule.host + path.path)) {

if(this.matchUrl(ingress,this.search_url,rule.host,path.path,path.pathType)){
is_same_path = true
break
}
}

}
}
}
Expand Down