2017-12-23 20:47:41 -05:00
|
|
|
import { Component } from "@angular/core";
|
|
|
|
import { Router } from "@angular/router";
|
2017-12-24 04:02:57 -05:00
|
|
|
import { AdminApiService } from "../shared/services/admin/admin-api.service";
|
2017-12-23 20:47:41 -05:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
templateUrl: "./admin.component.html",
|
|
|
|
styleUrls: ["./admin.component.scss"],
|
|
|
|
})
|
|
|
|
export class AdminComponent {
|
|
|
|
|
2017-12-23 21:45:34 -05:00
|
|
|
public version = "";
|
|
|
|
|
|
|
|
constructor(private router: Router, adminApi: AdminApiService) {
|
|
|
|
adminApi.getVersion().then(r => this.version = r.version);
|
2017-12-23 20:47:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public goto(adminRoute: string) {
|
|
|
|
const currentRoute = this.router.routerState.snapshot.url;
|
|
|
|
const baseRoute = currentRoute.substring(0, currentRoute.indexOf("/admin"));
|
|
|
|
|
|
|
|
const route = adminRoute ? [baseRoute, "admin", adminRoute] : [baseRoute, "admin"];
|
|
|
|
this.router.navigate(route);
|
|
|
|
}
|
|
|
|
|
|
|
|
public isActive(adminRoute: string, exact?: boolean) {
|
|
|
|
let currentRoute = this.router.routerState.snapshot.url;
|
|
|
|
currentRoute = currentRoute.substring(currentRoute.indexOf('/admin'));
|
|
|
|
|
|
|
|
// Specifically for the dashboard handling
|
|
|
|
if (adminRoute === "" && !currentRoute.endsWith("/")) currentRoute = currentRoute + "/";
|
|
|
|
|
|
|
|
if (exact) return currentRoute === "/admin/" + adminRoute;
|
|
|
|
return currentRoute.startsWith("/admin/" + adminRoute);
|
|
|
|
}
|
|
|
|
}
|