BASEPATH
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ COPY webapp/frontend /scrutiny/src
|
|||||||
RUN npm install -g @angular/cli@9.1.4 && \
|
RUN npm install -g @angular/cli@9.1.4 && \
|
||||||
mkdir -p /scrutiny/dist && \
|
mkdir -p /scrutiny/dist && \
|
||||||
npm install && \
|
npm install && \
|
||||||
ng build --output-path=/scrutiny/dist --deploy-url="/web/" --base-href="/web/" --prod
|
ng build --output-path=/scrutiny/dist --prod
|
||||||
|
|
||||||
|
|
||||||
########
|
########
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type AppEngine struct {
|
type AppEngine struct {
|
||||||
@@ -29,17 +28,10 @@ func (ae *AppEngine) Setup(logger logrus.FieldLogger) *gin.Engine {
|
|||||||
r.Use(gin.Recovery())
|
r.Use(gin.Recovery())
|
||||||
|
|
||||||
basePath := ae.Config.GetString("web.src.backend.basepath")
|
basePath := ae.Config.GetString("web.src.backend.basepath")
|
||||||
if len(basePath) > 0 {
|
logger.Debugf("basepath: %s", basePath)
|
||||||
r.Group(basePath, func(c *gin.Context) {
|
base := r.Group(basePath)
|
||||||
c.Request.URL.Path = strings.TrimPrefix(c.Request.URL.Path, basePath)
|
{
|
||||||
r.HandleContext(c)
|
api := base.Group("/api")
|
||||||
})
|
|
||||||
} else {
|
|
||||||
basePath = "/"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
api := r.Group("/api")
|
|
||||||
{
|
{
|
||||||
api.GET("/health", func(c *gin.Context) {
|
api.GET("/health", func(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
@@ -54,12 +46,13 @@ func (ae *AppEngine) Setup(logger logrus.FieldLogger) *gin.Engine {
|
|||||||
api.POST("/device/:wwn/selftest", handler.UploadDeviceSelfTests)
|
api.POST("/device/:wwn/selftest", handler.UploadDeviceSelfTests)
|
||||||
api.GET("/device/:wwn/details", handler.GetDeviceDetails) //used by Details
|
api.GET("/device/:wwn/details", handler.GetDeviceDetails) //used by Details
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Static request routing
|
//Static request routing
|
||||||
r.StaticFS("/web", http.Dir(ae.Config.GetString("web.src.frontend.path")))
|
base.StaticFS("/web", http.Dir(ae.Config.GetString("web.src.frontend.path")))
|
||||||
|
|
||||||
//redirect base url to /web
|
//redirect base url to /web
|
||||||
r.GET("/", func(c *gin.Context) {
|
base.GET("/", func(c *gin.Context) {
|
||||||
c.Redirect(http.StatusFound, basePath + "/web")
|
c.Redirect(http.StatusFound, basePath + "/web")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { NgModule, enableProdMode } from '@angular/core';
|
|||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { ExtraOptions, PreloadAllModules, RouterModule } from '@angular/router';
|
import { ExtraOptions, PreloadAllModules, RouterModule } from '@angular/router';
|
||||||
|
import { APP_BASE_HREF } from '@angular/common';
|
||||||
import { MarkdownModule } from 'ngx-markdown';
|
import { MarkdownModule } from 'ngx-markdown';
|
||||||
import { TreoModule } from '@treo';
|
import { TreoModule } from '@treo';
|
||||||
import { TreoConfigModule } from '@treo/services/config';
|
import { TreoConfigModule } from '@treo/services/config';
|
||||||
@@ -11,7 +12,7 @@ import { appConfig } from 'app/core/config/app.config';
|
|||||||
import { mockDataServices } from 'app/data/mock';
|
import { mockDataServices } from 'app/data/mock';
|
||||||
import { LayoutModule } from 'app/layout/layout.module';
|
import { LayoutModule } from 'app/layout/layout.module';
|
||||||
import { AppComponent } from 'app/app.component';
|
import { AppComponent } from 'app/app.component';
|
||||||
import { appRoutes } from 'app/app.routing';
|
import { appRoutes, getAppBaseHref } from 'app/app.routing';
|
||||||
|
|
||||||
const routerConfig: ExtraOptions = {
|
const routerConfig: ExtraOptions = {
|
||||||
scrollPositionRestoration: 'enabled',
|
scrollPositionRestoration: 'enabled',
|
||||||
@@ -54,7 +55,13 @@ if (process.env.NODE_ENV === 'production') {
|
|||||||
],
|
],
|
||||||
bootstrap : [
|
bootstrap : [
|
||||||
AppComponent
|
AppComponent
|
||||||
]
|
],
|
||||||
|
providers: [
|
||||||
|
{
|
||||||
|
provide: APP_BASE_HREF,
|
||||||
|
useValue: getAppBaseHref()
|
||||||
|
}
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class AppModule
|
export class AppModule
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,6 +2,17 @@ import { Route } from '@angular/router';
|
|||||||
import { LayoutComponent } from 'app/layout/layout.component';
|
import { LayoutComponent } from 'app/layout/layout.component';
|
||||||
import { EmptyLayoutComponent } from 'app/layout/layouts/empty/empty.component';
|
import { EmptyLayoutComponent } from 'app/layout/layouts/empty/empty.component';
|
||||||
|
|
||||||
|
// @formatter:off
|
||||||
|
export function getAppBaseHref(): string {
|
||||||
|
return getBasePath() + '/web';
|
||||||
|
}
|
||||||
|
|
||||||
|
// @formatter:off
|
||||||
|
// tslint:disable:max-line-length
|
||||||
|
export function getBasePath(): string {
|
||||||
|
return window.location.pathname.split('/web').slice(0, 1)[0];
|
||||||
|
}
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
// tslint:disable:max-line-length
|
// tslint:disable:max-line-length
|
||||||
export const appRoutes: Route[] = [
|
export const appRoutes: Route[] = [
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { MatFormField } from '@angular/material/form-field';
|
|||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { debounceTime, filter, map, takeUntil } from 'rxjs/operators';
|
import { debounceTime, filter, map, takeUntil } from 'rxjs/operators';
|
||||||
import { TreoAnimations } from '@treo/animations/public-api';
|
import { TreoAnimations } from '@treo/animations/public-api';
|
||||||
|
import { getBasePath } from 'app/app.routing';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector : 'search',
|
selector : 'search',
|
||||||
@@ -199,7 +200,7 @@ export class SearchComponent implements OnInit, OnDestroy
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe((value) => {
|
.subscribe((value) => {
|
||||||
this._httpClient.post('api/common/search', {query: value})
|
this._httpClient.post(getBasePath() + '/api/common/search', {query: value})
|
||||||
.subscribe((response: any) => {
|
.subscribe((response: any) => {
|
||||||
this.results = response.results;
|
this.results = response.results;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap } from 'rxjs/operators';
|
||||||
|
import { getBasePath } from 'app/app.routing';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -45,7 +46,7 @@ export class DashboardService
|
|||||||
*/
|
*/
|
||||||
getData(): Observable<any>
|
getData(): Observable<any>
|
||||||
{
|
{
|
||||||
return this._httpClient.get('/api/summary').pipe(
|
return this._httpClient.get(getBasePath() + '/api/summary').pipe(
|
||||||
tap((response: any) => {
|
tap((response: any) => {
|
||||||
this._data.next(response);
|
this._data.next(response);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { BehaviorSubject, Observable } from 'rxjs';
|
import { BehaviorSubject, Observable } from 'rxjs';
|
||||||
import { tap } from 'rxjs/operators';
|
import { tap } from 'rxjs/operators';
|
||||||
|
import { getBasePath } from 'app/app.routing';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -45,7 +46,7 @@ export class DetailService
|
|||||||
*/
|
*/
|
||||||
getData(wwn): Observable<any>
|
getData(wwn): Observable<any>
|
||||||
{
|
{
|
||||||
return this._httpClient.get(`/api/device/${wwn}/details`).pipe(
|
return this._httpClient.get(getBasePath() + `/api/device/${wwn}/details`).pipe(
|
||||||
tap((response: any) => {
|
tap((response: any) => {
|
||||||
this._data.next(response);
|
this._data.next(response);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>
|
<browserconfig><msapplication><tile><square70x70logo src="./ms-icon-70x70.png"/><square150x150logo src="./ms-icon-150x150.png"/><square310x310logo src="./ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>scrutiny</title>
|
<title>scrutiny</title>
|
||||||
<base href="/">
|
|
||||||
|
|
||||||
<meta name="viewport"
|
<meta name="viewport"
|
||||||
content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0">
|
content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0">
|
||||||
@@ -22,7 +21,7 @@
|
|||||||
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
|
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
|
||||||
<link rel="icon" type="image/png" sizes="96x96" href="favicon-96x96.png">
|
<link rel="icon" type="image/png" sizes="96x96" href="favicon-96x96.png">
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
|
||||||
<link rel="manifest" href="manifest.json">
|
<link rel="manifest" href="./manifest.json" crossorigin="use-credentials">
|
||||||
<meta name="msapplication-TileColor" content="#ffffff">
|
<meta name="msapplication-TileColor" content="#ffffff">
|
||||||
<meta name="msapplication-TileImage" content="ms-icon-144x144.png">
|
<meta name="msapplication-TileImage" content="ms-icon-144x144.png">
|
||||||
<meta name="theme-color" content="#ffffff">
|
<meta name="theme-color" content="#ffffff">
|
||||||
|
|||||||
@@ -2,37 +2,37 @@
|
|||||||
"name": "App",
|
"name": "App",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "\/android-icon-36x36.png",
|
"src": ".\/android-icon-36x36.png",
|
||||||
"sizes": "36x36",
|
"sizes": "36x36",
|
||||||
"type": "image\/png",
|
"type": "image\/png",
|
||||||
"density": "0.75"
|
"density": "0.75"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "\/android-icon-48x48.png",
|
"src": ".\/android-icon-48x48.png",
|
||||||
"sizes": "48x48",
|
"sizes": "48x48",
|
||||||
"type": "image\/png",
|
"type": "image\/png",
|
||||||
"density": "1.0"
|
"density": "1.0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "\/android-icon-72x72.png",
|
"src": ".\/android-icon-72x72.png",
|
||||||
"sizes": "72x72",
|
"sizes": "72x72",
|
||||||
"type": "image\/png",
|
"type": "image\/png",
|
||||||
"density": "1.5"
|
"density": "1.5"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "\/android-icon-96x96.png",
|
"src": ".\/android-icon-96x96.png",
|
||||||
"sizes": "96x96",
|
"sizes": "96x96",
|
||||||
"type": "image\/png",
|
"type": "image\/png",
|
||||||
"density": "2.0"
|
"density": "2.0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "\/android-icon-144x144.png",
|
"src": ".\/android-icon-144x144.png",
|
||||||
"sizes": "144x144",
|
"sizes": "144x144",
|
||||||
"type": "image\/png",
|
"type": "image\/png",
|
||||||
"density": "3.0"
|
"density": "3.0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "\/android-icon-192x192.png",
|
"src": ".\/android-icon-192x192.png",
|
||||||
"sizes": "192x192",
|
"sizes": "192x192",
|
||||||
"type": "image\/png",
|
"type": "image\/png",
|
||||||
"density": "4.0"
|
"density": "4.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user