Skip to content

Commit

Permalink
webapp: add config.* files missing from 2b3c181
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-h committed Jan 27, 2022
1 parent 250cdb1 commit 97e1c48
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mythtv/html/backend/src/app/services/config.service.spec.ts
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { ConfigService } from './config.service';

describe('ConfigServiceService', () => {
let service: ConfigService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ConfigService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
30 changes: 30 additions & 0 deletions mythtv/html/backend/src/app/services/config.service.ts
@@ -0,0 +1,30 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams, HttpErrorResponse } from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
import { MythConnectionInfo, Database } from './interfaces/myth.interface';
import { MythDatabaseStatus, MythCountryList, MythLanguageList, Country, Language } from './interfaces/config.interface';

@Injectable({
providedIn: 'root'
})
export class ConfigService {

constructor(private httpClient: HttpClient) { }

public GetDatabaseStatus(): Observable<MythDatabaseStatus> {
return this.httpClient.get<MythDatabaseStatus>('/Config/GetDatabaseStatus')
}

public SetDatabaseCredentials(data: Database): Observable<Database> {
return this.httpClient.post<Database>('/Config/SetDatabaseCredentials', data)
}
public GetCountries(): Observable<MythCountryList> {
return this.httpClient.get<MythCountryList>('/Config/GetCountries')
}

public GetLanguages(): Observable<MythLanguageList> {
return this.httpClient.get<MythLanguageList>('/Config/GetLanguages')
}
}

@@ -0,0 +1,44 @@
export interface MythDatabaseStatus {
DatabaseStatus: {
Host: string; // can be hostname or ip address
Port: number; // default is 3306
UserName: string;
Password: string;
Name: string; // default is mythconverg
Ping: boolean;
Type: string;
LocalEnabled: boolean;
LocalHostName: string;

Connected: boolean;
HaveDatabase: boolean;
SchemaVersion: number;
}
}

export interface Language {
Code: string;
Language: string;
NativeLanguage?: string;
Image?: string;
}

export interface MythLanguageList {
LanguageList: {
Languages: Language[]
}
}

export interface Country {
Code: string;
Country: string;
NativeCountry?: string;
Image?: string;
}

export interface MythCountryList {
CountryList: {
Countries: Country[]
}
}

0 comments on commit 97e1c48

Please sign in to comment.