The React logo SVG file was removed as it was no longer needed. Introduced an auto-generated API client class (`ApiClient.ts`) for handling server communication and added new components for the navigation menu and higher-order layouts (`NavMenu`, `with_main_layout.ts.tsx`). Updated `yarn.lock` to replace legacy URL references.
146 lines
4.8 KiB
TypeScript
146 lines
4.8 KiB
TypeScript
//----------------------
|
|
// <auto-generated>
|
|
// Generated using the NSwag toolchain v14.2.0.0 (NJsonSchema v11.1.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org)
|
|
// </auto-generated>
|
|
//----------------------
|
|
|
|
/* tslint:disable */
|
|
/* eslint-disable */
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
export class Client {
|
|
private http: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> };
|
|
private baseUrl: string;
|
|
protected jsonParseReviver: ((key: string, value: any) => any) | undefined = undefined;
|
|
|
|
constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
|
|
this.http = http ? http : window as any;
|
|
this.baseUrl = baseUrl ?? "http://localhost:5175";
|
|
}
|
|
|
|
getWeatherForecast(): Promise<WeatherForecast[]> {
|
|
let url_ = this.baseUrl + "/weatherforecast";
|
|
url_ = url_.replace(/[?&]$/, "");
|
|
|
|
let options_: RequestInit = {
|
|
method: "GET",
|
|
headers: {
|
|
"Accept": "application/json"
|
|
}
|
|
};
|
|
|
|
return this.http.fetch(url_, options_).then((_response: Response) => {
|
|
return this.processGetWeatherForecast(_response);
|
|
});
|
|
}
|
|
|
|
protected processGetWeatherForecast(response: Response): Promise<WeatherForecast[]> {
|
|
const status = response.status;
|
|
let _headers: any = {}; if (response.headers && response.headers.forEach) { response.headers.forEach((v: any, k: any) => _headers[k] = v); };
|
|
if (status === 200) {
|
|
return response.text().then((_responseText) => {
|
|
let result200: any = null;
|
|
let resultData200 = _responseText === "" ? null : JSON.parse(_responseText, this.jsonParseReviver);
|
|
if (Array.isArray(resultData200)) {
|
|
result200 = [] as any;
|
|
for (let item of resultData200)
|
|
result200!.push(WeatherForecast.fromJS(item));
|
|
}
|
|
else {
|
|
result200 = <any>null;
|
|
}
|
|
return result200;
|
|
});
|
|
} else if (status !== 200 && status !== 204) {
|
|
return response.text().then((_responseText) => {
|
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
|
});
|
|
}
|
|
return Promise.resolve<WeatherForecast[]>(null as any);
|
|
}
|
|
}
|
|
|
|
export class WeatherForecast implements IWeatherForecast {
|
|
date?: Date;
|
|
temperatureC?: number;
|
|
summary?: string | undefined;
|
|
temperatureF?: number;
|
|
|
|
constructor(data?: IWeatherForecast) {
|
|
if (data) {
|
|
for (var property in data) {
|
|
if (data.hasOwnProperty(property))
|
|
(<any>this)[property] = (<any>data)[property];
|
|
}
|
|
}
|
|
}
|
|
|
|
init(_data?: any) {
|
|
if (_data) {
|
|
this.date = _data["date"] ? new Date(_data["date"].toString()) : <any>undefined;
|
|
this.temperatureC = _data["temperatureC"];
|
|
this.summary = _data["summary"];
|
|
this.temperatureF = _data["temperatureF"];
|
|
}
|
|
}
|
|
|
|
static fromJS(data: any): WeatherForecast {
|
|
data = typeof data === 'object' ? data : {};
|
|
let result = new WeatherForecast();
|
|
result.init(data);
|
|
return result;
|
|
}
|
|
|
|
toJSON(data?: any) {
|
|
data = typeof data === 'object' ? data : {};
|
|
data["date"] = this.date ? formatDate(this.date) : <any>undefined;
|
|
data["temperatureC"] = this.temperatureC;
|
|
data["summary"] = this.summary;
|
|
data["temperatureF"] = this.temperatureF;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
export interface IWeatherForecast {
|
|
date?: Date;
|
|
temperatureC?: number;
|
|
summary?: string | undefined;
|
|
temperatureF?: number;
|
|
}
|
|
|
|
function formatDate(d: Date) {
|
|
return d.getFullYear() + '-' +
|
|
(d.getMonth() < 9 ? ('0' + (d.getMonth()+1)) : (d.getMonth()+1)) + '-' +
|
|
(d.getDate() < 10 ? ('0' + d.getDate()) : d.getDate());
|
|
}
|
|
|
|
export class SwaggerException extends Error {
|
|
message: string;
|
|
status: number;
|
|
response: string;
|
|
headers: { [key: string]: any; };
|
|
result: any;
|
|
|
|
constructor(message: string, status: number, response: string, headers: { [key: string]: any; }, result: any) {
|
|
super();
|
|
|
|
this.message = message;
|
|
this.status = status;
|
|
this.response = response;
|
|
this.headers = headers;
|
|
this.result = result;
|
|
}
|
|
|
|
protected isSwaggerException = true;
|
|
|
|
static isSwaggerException(obj: any): obj is SwaggerException {
|
|
return obj.isSwaggerException === true;
|
|
}
|
|
}
|
|
|
|
function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any {
|
|
if (result !== null && result !== undefined)
|
|
throw result;
|
|
else
|
|
throw new SwaggerException(message, status, response, headers, null);
|
|
} |