Skip to content

Commit 31a6393

Browse files
committed
multiple fixes
1 parent 8b9b070 commit 31a6393

File tree

2 files changed

+30
-22
lines changed

2 files changed

+30
-22
lines changed

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

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ export class ApiComponent implements OnInit {
293293
}
294294

295295
////////////////////////////////////////////////////////////////////////////////////
296-
////////////////////// MIST EDGEFUNCTION
296+
////////////////////// MIST EDGE FUNCTION
297297
forgeEdge(host: string, detail: string): void {
298298
if (detail == "edgedetail") {
299299
this.obj_name = "mxedge";
@@ -315,9 +315,19 @@ export class ApiComponent implements OnInit {
315315
}
316316

317317
////////////////////////////////////////////////////////////////////////////////////
318-
////////////////////////////////////////////////////////////////////////////////////
319-
////////////////////// DISCOVERED SWITCHES URL FUNCTION DISPATCHER
320-
discoveredSwitchUrl(res: RegExpExecArray): void {
318+
////////////////////// DISCOVERED SWITCHES FUNCTION
319+
forgeSiteDiscoveredSwitchUrl(host: string, mac: string = null): void {
320+
if (mac) {
321+
this.quick_links.push({
322+
url: "https://api." + host + "/api/v1/sites/" + this.site_id + "/stats/discovered_switches/search?system_name=" + mac,
323+
name: "discovered switch"
324+
})
325+
} else if (!this.obj_id) {
326+
this.quick_links.push({
327+
url: "https://api." + host + "/api/v1/sites/" + this.site_id + "/stats/discovered_switches/search",
328+
name: "discovered switches"
329+
})
330+
}
321331
}
322332
////////////////////////////////////////////////////////////////////////////////////
323333
////////////////////////////////////////////////////////////////////////////////////
@@ -328,8 +338,8 @@ export class ApiComponent implements OnInit {
328338
const uuid_re = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
329339
console.log(res.groups)
330340
if (res.groups.host && res.groups.org_id && res.groups.obj) {
331-
this.obj_id = res.groups.uuid_1;
332-
this.site_id = res.groups.uuid_2;
341+
this.obj_id = res.groups.obj_id;
342+
this.site_id = res.groups.site_id;
333343
switch (res.groups.obj.toLowerCase()) {
334344
// SITE
335345
case "ap":
@@ -341,20 +351,18 @@ export class ApiComponent implements OnInit {
341351
this.forgeSiteObjectEvents("devices", res.groups.obj, res.groups.host, res.groups.detail);
342352
break;
343353
case "switch":
344-
const is_uuid = uuid_re.test(res.groups.uuid_1)
345-
if (!res.groups.uuid_1 || is_uuid) {
354+
const is_uuid = uuid_re.test(this.obj_id)
355+
if (this.obj_id && !is_uuid) {
356+
this.obj_name = "discoveredswitch";
357+
this.setName("discoveredswitch", "detail");
358+
this.forgeSiteDiscoveredSwitchUrl(res.groups.host, this.obj_id);
359+
} else {
346360
this.setName(res.groups.obj, res.groups.detail);
347361
if (!res.groups.details) extra_params = "type=" + res.groups.obj;
348362
this.forgeSiteObject("devices", res.groups.host, res.groups.detail, extra_params);
349363
this.forgeSiteObjectStats("devices", res.groups.host, res.groups.detail, extra_params);
350364
this.forgeSiteObjectEvents("devices", res.groups.obj, res.groups.host, res.groups.detail);
351-
} else {
352-
this.obj_name = "discoveredswitch";
353-
this.setName("discoveredswitch", "detail");
354-
this.quick_links.push({
355-
url: "https://api." + res.groups.host + "/api/v1/sites/" + this.site_id + "/stats/discovered_switches/search?system_name=" + res.groups.uuid_1,
356-
name: "discovered switch"
357-
})
365+
this.forgeSiteDiscoveredSwitchUrl(res.groups.host);
358366
}
359367
break;
360368
case "assets":
@@ -437,7 +445,7 @@ export class ApiComponent implements OnInit {
437445
break;
438446
case "configuration":
439447
this.setName("site", res.groups.detail);
440-
this.forgeSite(res.groups.host, res.groups.uuid_1);
448+
this.forgeSite(res.groups.host, this.obj_id);
441449
break;
442450
case "rftemplates":
443451
case "templates":
@@ -475,8 +483,8 @@ export class ApiComponent implements OnInit {
475483
insightsUrl(res: RegExpExecArray): void {
476484
console.log(res)
477485
this.org_id = res.groups.org_id;
478-
this.site_id = res.groups.uuid_2;
479-
this.obj_id = res.groups.uuid_1;
486+
this.site_id = res.groups.site_id;
487+
this.obj_id = res.groups.obj_id;
480488
let extra_params = null;
481489
if (res.groups.start && res.groups.stop) {
482490
extra_params = "start=" + res.groups.start + "&end=" + res.groups.stop;
@@ -491,7 +499,7 @@ export class ApiComponent implements OnInit {
491499
break;
492500
case "client":
493501
this.setName("client", "insights");
494-
//this.forgeSiteObject("clients", res.groups.host, "detail");
502+
this.forgeSiteObjectSearch("clients", res.groups.host, "detail");
495503
this.forgeSiteObjectStats("clients", res.groups.host, "detail", extra_params);
496504
this.forgeSiteObjectEvents("clients", null, res.groups.host, "detail", extra_params);
497505
break;
@@ -532,8 +540,8 @@ export class ApiComponent implements OnInit {
532540
// API URL ENTRYPOINT
533541

534542
generateApiUrl() {
535-
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]+)\/)?((?<uuid_1>[a-z0-9-]+)\/)((?<period>[a-z0-9]+)\/)?((?<start>[0-9]*)\/)?((?<stop>[0-9]*)\/)?(?<uuid_2>[0-9a-f-]*)?/iys;
536-
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)\/)?([0-9]\/)?((?<uuid_1>[0-9a-f-]*)\/)?(?<uuid_2>[0-9a-f-]*)?/yis;
543+
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;
544+
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)\/)?([0-9]\/)?((?<obj_id>[0-9a-z_-]*)\/)?(?<site_id>[0-9a-f-]*)?/yis;
537545

538546
const insights = insights_re.exec(this.tabUrl)
539547
const common = common_re.exec(this.tabUrl)

src/angular/src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 3,
33
"name": "Mist Extension",
44
"short_name": "mist-chrome-extension",
5-
"version": "1.3.1",
5+
"version": "1.3.2",
66
"description": "Chrome Extension for Mist Developpers to provide easier access to Mist APIs",
77
"icons": {
88
"16": "assets/icon16.png",

0 commit comments

Comments
 (0)