refactor: Moved URL services
This commit is contained in:
@@ -5,7 +5,7 @@ import { provideClientHydration } from '@angular/platform-browser';
|
||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||
import { provideHttpClient, withFetch } from '@angular/common/http';
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
import { UrlService } from '../services/url.service';
|
||||
import { UrlService } from './services/url.service';
|
||||
import { API_URL } from './tokens';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { GroupOfUserService } from '../../../services/group-of-user.service';
|
||||
import { GroupOfUser } from '../../../models/user-management.api.models';
|
||||
import { GuiColumn } from '@generic-ui/ngx-grid';
|
||||
import { GuiGridModule, GuiColumn } from '@generic-ui/ngx-grid';
|
||||
import { BaseTableComponent } from '../base-table/base-table.component';
|
||||
import { ColorModeService } from '../../../services/color-mode.service';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
imports: [CommonModule, FormsModule, GuiGridModule ],
|
||||
selector: 'app-group-user-table',
|
||||
templateUrl: '../base-table/base-table.component.html',
|
||||
styleUrl: './group-user-table.component.css'
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UrlService } from './url.service';
|
||||
|
||||
describe('UrlService', () => {
|
||||
let service: UrlService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(UrlService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Injectable, Inject, inject } from '@angular/core';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { Meta } from '@angular/platform-browser';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UrlService {
|
||||
document: Document;
|
||||
meta: Meta;
|
||||
|
||||
constructor() {
|
||||
this.document = inject(DOCUMENT)
|
||||
this.meta = inject(Meta)
|
||||
}
|
||||
|
||||
getBaseHref(): string {
|
||||
const baseElement = this.document.querySelector('base');
|
||||
return baseElement?.getAttribute('href') || '/';
|
||||
}
|
||||
|
||||
getApiUrl(): string | null {
|
||||
const apiMetaTag = this.meta.getTag('name="api-url"');
|
||||
return apiMetaTag ? apiMetaTag.content : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user