Skip to content

Commit 7d7d652

Browse files
committed
aédding site, ap, switch, gateway and client SLE
1 parent 0b6b6f2 commit 7d7d652

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

src/angular/src/app/pages/api/api.component.ts

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,21 @@ export class ApiComponent implements OnInit {
358358
name: "Worst sites by " + worstsle
359359
});
360360
}
361+
362+
////////////////////////////////////////////////////////////////////////////////////
363+
////////////////////// SLE FUNCTION
364+
forgeSlehUrl(host: string, scope: string, site_id: string, scope_id: string, sles: string[], extra_params: string = null): void {
365+
/*
366+
host: mist.com, eu.mist.com, gc1.mist.com
367+
scope: wifi, wire, wan
368+
*/
369+
sles.forEach(sle => {
370+
this.quick_links.push({
371+
url: "https://api." + host + "/api/v1/sites/" + site_id + "/sle/" + scope + "/" + scope_id + "/metric/" + sle + "/summary-trend?" + extra_params,
372+
name: sle + " " + scope + " SLE"
373+
});
374+
})
375+
}
361376
////////////////////////////////////////////////////////////////////////////////////
362377
////////////////////////////////////////////////////////////////////////////////////
363378
////////////////////// COMMON URL FUNCTION DISPATCHER
@@ -593,18 +608,79 @@ export class ApiComponent implements OnInit {
593608
}
594609
////////////////////////////////////////////////////////////////////////////////////
595610
////////////////////////////////////////////////////////////////////////////////////
611+
////////////////////// SLE URL FUNCTION DISPATCHER
612+
613+
sleUrl(res: RegExpExecArray): void {
614+
console.log(res)
615+
this.org_id = res.groups.org_id;
616+
this.site_id = res.groups.site_id;
617+
let extra_params = null;
618+
let scope = "";
619+
if (res.groups.scope != "site") {
620+
this.setName(res.groups.scope, "sle");
621+
this.obj_id = res.groups.scope_id;
622+
}
623+
if (res.groups.scope == "juniperSwitch") {
624+
scope = "switch";
625+
} else if (res.groups.scope == "juniperGateway") {
626+
scope = "gateway";
627+
} else if (res.groups.scope == "device") {
628+
scope = "ap";
629+
}else {
630+
scope = res.groups.scope;
631+
}
632+
if (res.groups.start && res.groups.stop) {
633+
extra_params = "start=" + res.groups.start + "&end=" + res.groups.stop;
634+
}
635+
if (res.groups.host && res.groups.org_id) {
636+
let sles: string[] = []
637+
switch (res.groups.detail) {
638+
case "serviceLevels":
639+
sles = [
640+
"time-to-connect",
641+
"failed-to-connect",
642+
"roaming",
643+
"throughput",
644+
"coverage",
645+
"capacity",
646+
"ap-availability"
647+
]
648+
break;
649+
case "wiredServiceLevels":
650+
sles = [
651+
"switch-stc",
652+
"switch-health",
653+
"switch-throughput"
654+
]
655+
break;
656+
case "wanServiceLevels":
657+
sles = [
658+
"gateway-health",
659+
"wan-link-health"
660+
]
661+
break;
662+
}
663+
this.forgeSlehUrl(res.groups.host, scope, res.groups.site_id, res.groups.scope_id, sles, extra_params)
664+
}
665+
}
666+
////////////////////////////////////////////////////////////////////////////////////
667+
////////////////////////////////////////////////////////////////////////////////////
596668
// API URL ENTRYPOINT
597669

598670
generateApiUrl() {
599671
const orgsle_re = /https:\/\/manage\.(?<host>[a-z0-1.]*mist\.com)\/admin\/\?org_id=(?<org_id>[0-9a-f-]*)#!dashboard\/(?<scope>siteComparison|wiredSiteComparison|wanSiteComparison)\/(?<sle>[a-z-]*)\/(?<worstsle>[a-z-]*)\/([a-z-_]*)\/(?<period>[0-9a-z-]*)\/(?<start>[0-9]*)\/(?<stop>[0-9]*)/iys;
672+
const sle_re = /https:\/\/manage\.(?<host>[a-z0-1.]*mist\.com)\/admin\/\?org_id=(?<org_id>[0-9a-f-]*)#!dashboard\/(?<detail>serviceLevels|wiredserviceLevels|wanserviceLevels)\/(?<scope>[a-z-]*)\/(?<scope_id>[a-f0-9-]*)\/(?<period>[0-9a-z-]*)\/(?<start>[0-9]*)\/(?<stop>[0-9]*)\/(?<site_id>[a-f0-9-]*)/iys;
600673
const insights_re = /https:\/\/(manage|integration)\.(?<host>[a-z0-1.]*mist\.com)\/admin\/\?org_id=(?<org_id>[0-9a-f-]*)#!dashboard\/insights\/((?<obj>[a-z]+)\/)?((?<obj_id>[a-z0-9-]+)\/)((?<period>[a-z0-9]+)\/)?((?<start>[0-9]*)\/)?((?<stop>[0-9]*)\/)?(?<site_id>[0-9a-f-]*)?/iys;
601674
const common_re = /https:\/\/(manage|integration)\.(?<host>[a-z0-1.]*mist\.com)\/admin\/\?org_id=(?<org_id>[0-9a-f-]*)#!(?<obj>[a-z]+)\/?((?<detail>detail|template|site|rfTemplate|admin|edgedetail|clusterdetail|new|view)\/)?([0-9]\/)?((?<obj_id>[0-9a-z_-]*)\/)?(?<site_id>[0-9a-f-]*)?/yis;
602675

603676
const orgsle = orgsle_re.exec(this.tabUrl);
677+
const sle = sle_re.exec(this.tabUrl);
604678
const insights = insights_re.exec(this.tabUrl);
605679
const common = common_re.exec(this.tabUrl);
606680
if (orgsle) {
607681
this.orgSleUrl(orgsle);
682+
} else if (sle) {
683+
this.sleUrl(sle);
608684
} else if (insights) {
609685
this.insightsUrl(insights);
610686
} else if (common) {

0 commit comments

Comments
 (0)