Fixed LogService baseUrl
This commit is contained in:
parent
aa39597541
commit
70c4c91035
208
Birdmap.API/ClientApp/src/components/logs/LogService.js
Normal file
208
Birdmap.API/ClientApp/src/components/logs/LogService.js
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
"use strict";
|
||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
//----------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// Generated using the NSwag toolchain v13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
|
||||||
|
// </auto-generated>
|
||||||
|
//----------------------
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
var __extends = (this && this.__extends) || (function () {
|
||||||
|
var extendStatics = function (d, b) {
|
||||||
|
extendStatics = Object.setPrototypeOf ||
|
||||||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||||
|
return extendStatics(d, b);
|
||||||
|
};
|
||||||
|
return function (d, b) {
|
||||||
|
extendStatics(d, b);
|
||||||
|
function __() { this.constructor = d; }
|
||||||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.ApiException = exports.HttpStatusCode = void 0;
|
||||||
|
var LogService = /** @class */ (function () {
|
||||||
|
function LogService(baseUrl, http) {
|
||||||
|
this.jsonParseReviver = undefined;
|
||||||
|
this.http = http ? http : window;
|
||||||
|
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "api/logs";
|
||||||
|
}
|
||||||
|
LogService.prototype.getAll = function () {
|
||||||
|
var _this = this;
|
||||||
|
var url_ = this.baseUrl + "/all";
|
||||||
|
url_ = url_.replace(/[?&]$/, "");
|
||||||
|
var options_ = {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/json",
|
||||||
|
'Authorization': sessionStorage.getItem('user')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return this.http.fetch(url_, options_).then(function (_response) {
|
||||||
|
return _this.processGetAll(_response);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
LogService.prototype.processGetAll = function (response) {
|
||||||
|
var _this = this;
|
||||||
|
var status = response.status;
|
||||||
|
var _headers = {};
|
||||||
|
if (response.headers && response.headers.forEach) {
|
||||||
|
response.headers.forEach(function (v, k) { return _headers[k] = v; });
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (status === 200) {
|
||||||
|
return response.text().then(function (_responseText) {
|
||||||
|
var result200 = null;
|
||||||
|
var resultData200 = _responseText === "" ? null : JSON.parse(_responseText, _this.jsonParseReviver);
|
||||||
|
if (Array.isArray(resultData200)) {
|
||||||
|
result200 = [];
|
||||||
|
for (var _i = 0, resultData200_1 = resultData200; _i < resultData200_1.length; _i++) {
|
||||||
|
var item = resultData200_1[_i];
|
||||||
|
result200.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result200;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (status !== 200 && status !== 204) {
|
||||||
|
return response.text().then(function (_responseText) {
|
||||||
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Promise.resolve(null);
|
||||||
|
};
|
||||||
|
LogService.prototype.getFiles = function (filenames) {
|
||||||
|
var _this = this;
|
||||||
|
var url_ = this.baseUrl + "?";
|
||||||
|
if (filenames !== undefined && filenames !== null)
|
||||||
|
filenames && filenames.forEach(function (item) { url_ += "filenames=" + encodeURIComponent("" + item) + "&"; });
|
||||||
|
url_ = url_.replace(/[?&]$/, "");
|
||||||
|
var options_ = {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Accept": "application/octet-stream",
|
||||||
|
'Authorization': sessionStorage.getItem('user')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return this.http.fetch(url_, options_).then(function (_response) {
|
||||||
|
return _this.processGetFiles(_response);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
LogService.prototype.processGetFiles = function (response) {
|
||||||
|
var status = response.status;
|
||||||
|
var _headers = {};
|
||||||
|
if (response.headers && response.headers.forEach) {
|
||||||
|
response.headers.forEach(function (v, k) { return _headers[k] = v; });
|
||||||
|
}
|
||||||
|
;
|
||||||
|
if (status === 200 || status === 206) {
|
||||||
|
var contentDisposition = response.headers ? response.headers.get("content-disposition") : undefined;
|
||||||
|
var fileNameMatch = contentDisposition ? /filename="?([^"]*?)"?(;|$)/g.exec(contentDisposition) : undefined;
|
||||||
|
var fileName_1 = fileNameMatch && fileNameMatch.length > 1 ? fileNameMatch[1] : undefined;
|
||||||
|
return response.blob().then(function (blob) { return { fileName: fileName_1, data: blob, status: status, headers: _headers }; });
|
||||||
|
}
|
||||||
|
else if (status !== 200 && status !== 204) {
|
||||||
|
return response.text().then(function (_responseText) {
|
||||||
|
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Promise.resolve(null);
|
||||||
|
};
|
||||||
|
return LogService;
|
||||||
|
}());
|
||||||
|
exports.default = LogService;
|
||||||
|
var HttpStatusCode;
|
||||||
|
(function (HttpStatusCode) {
|
||||||
|
HttpStatusCode["Continue"] = "Continue";
|
||||||
|
HttpStatusCode["SwitchingProtocols"] = "SwitchingProtocols";
|
||||||
|
HttpStatusCode["Processing"] = "Processing";
|
||||||
|
HttpStatusCode["EarlyHints"] = "EarlyHints";
|
||||||
|
HttpStatusCode["OK"] = "OK";
|
||||||
|
HttpStatusCode["Created"] = "Created";
|
||||||
|
HttpStatusCode["Accepted"] = "Accepted";
|
||||||
|
HttpStatusCode["NonAuthoritativeInformation"] = "NonAuthoritativeInformation";
|
||||||
|
HttpStatusCode["NoContent"] = "NoContent";
|
||||||
|
HttpStatusCode["ResetContent"] = "ResetContent";
|
||||||
|
HttpStatusCode["PartialContent"] = "PartialContent";
|
||||||
|
HttpStatusCode["MultiStatus"] = "MultiStatus";
|
||||||
|
HttpStatusCode["AlreadyReported"] = "AlreadyReported";
|
||||||
|
HttpStatusCode["IMUsed"] = "IMUsed";
|
||||||
|
HttpStatusCode["MultipleChoices"] = "Ambiguous";
|
||||||
|
HttpStatusCode["Ambiguous"] = "Ambiguous";
|
||||||
|
HttpStatusCode["MovedPermanently"] = "Moved";
|
||||||
|
HttpStatusCode["Moved"] = "Moved";
|
||||||
|
HttpStatusCode["Found"] = "Redirect";
|
||||||
|
HttpStatusCode["Redirect"] = "Redirect";
|
||||||
|
HttpStatusCode["SeeOther"] = "RedirectMethod";
|
||||||
|
HttpStatusCode["RedirectMethod"] = "RedirectMethod";
|
||||||
|
HttpStatusCode["NotModified"] = "NotModified";
|
||||||
|
HttpStatusCode["UseProxy"] = "UseProxy";
|
||||||
|
HttpStatusCode["Unused"] = "Unused";
|
||||||
|
HttpStatusCode["TemporaryRedirect"] = "TemporaryRedirect";
|
||||||
|
HttpStatusCode["RedirectKeepVerb"] = "TemporaryRedirect";
|
||||||
|
HttpStatusCode["PermanentRedirect"] = "PermanentRedirect";
|
||||||
|
HttpStatusCode["BadRequest"] = "BadRequest";
|
||||||
|
HttpStatusCode["Unauthorized"] = "Unauthorized";
|
||||||
|
HttpStatusCode["PaymentRequired"] = "PaymentRequired";
|
||||||
|
HttpStatusCode["Forbidden"] = "Forbidden";
|
||||||
|
HttpStatusCode["NotFound"] = "NotFound";
|
||||||
|
HttpStatusCode["MethodNotAllowed"] = "MethodNotAllowed";
|
||||||
|
HttpStatusCode["NotAcceptable"] = "NotAcceptable";
|
||||||
|
HttpStatusCode["ProxyAuthenticationRequired"] = "ProxyAuthenticationRequired";
|
||||||
|
HttpStatusCode["RequestTimeout"] = "RequestTimeout";
|
||||||
|
HttpStatusCode["Conflict"] = "Conflict";
|
||||||
|
HttpStatusCode["Gone"] = "Gone";
|
||||||
|
HttpStatusCode["LengthRequired"] = "LengthRequired";
|
||||||
|
HttpStatusCode["PreconditionFailed"] = "PreconditionFailed";
|
||||||
|
HttpStatusCode["RequestEntityTooLarge"] = "RequestEntityTooLarge";
|
||||||
|
HttpStatusCode["RequestUriTooLong"] = "RequestUriTooLong";
|
||||||
|
HttpStatusCode["UnsupportedMediaType"] = "UnsupportedMediaType";
|
||||||
|
HttpStatusCode["RequestedRangeNotSatisfiable"] = "RequestedRangeNotSatisfiable";
|
||||||
|
HttpStatusCode["ExpectationFailed"] = "ExpectationFailed";
|
||||||
|
HttpStatusCode["MisdirectedRequest"] = "MisdirectedRequest";
|
||||||
|
HttpStatusCode["UnprocessableEntity"] = "UnprocessableEntity";
|
||||||
|
HttpStatusCode["Locked"] = "Locked";
|
||||||
|
HttpStatusCode["FailedDependency"] = "FailedDependency";
|
||||||
|
HttpStatusCode["UpgradeRequired"] = "UpgradeRequired";
|
||||||
|
HttpStatusCode["PreconditionRequired"] = "PreconditionRequired";
|
||||||
|
HttpStatusCode["TooManyRequests"] = "TooManyRequests";
|
||||||
|
HttpStatusCode["RequestHeaderFieldsTooLarge"] = "RequestHeaderFieldsTooLarge";
|
||||||
|
HttpStatusCode["UnavailableForLegalReasons"] = "UnavailableForLegalReasons";
|
||||||
|
HttpStatusCode["InternalServerError"] = "InternalServerError";
|
||||||
|
HttpStatusCode["NotImplemented"] = "NotImplemented";
|
||||||
|
HttpStatusCode["BadGateway"] = "BadGateway";
|
||||||
|
HttpStatusCode["ServiceUnavailable"] = "ServiceUnavailable";
|
||||||
|
HttpStatusCode["GatewayTimeout"] = "GatewayTimeout";
|
||||||
|
HttpStatusCode["HttpVersionNotSupported"] = "HttpVersionNotSupported";
|
||||||
|
HttpStatusCode["VariantAlsoNegotiates"] = "VariantAlsoNegotiates";
|
||||||
|
HttpStatusCode["InsufficientStorage"] = "InsufficientStorage";
|
||||||
|
HttpStatusCode["LoopDetected"] = "LoopDetected";
|
||||||
|
HttpStatusCode["NotExtended"] = "NotExtended";
|
||||||
|
HttpStatusCode["NetworkAuthenticationRequired"] = "NetworkAuthenticationRequired";
|
||||||
|
})(HttpStatusCode = exports.HttpStatusCode || (exports.HttpStatusCode = {}));
|
||||||
|
var ApiException = /** @class */ (function (_super) {
|
||||||
|
__extends(ApiException, _super);
|
||||||
|
function ApiException(message, status, response, headers, result) {
|
||||||
|
var _this = _super.call(this) || this;
|
||||||
|
_this.isApiException = true;
|
||||||
|
_this.message = message;
|
||||||
|
_this.status = status;
|
||||||
|
_this.response = response;
|
||||||
|
_this.headers = headers;
|
||||||
|
_this.result = result;
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
ApiException.isApiException = function (obj) {
|
||||||
|
return obj.isApiException === true;
|
||||||
|
};
|
||||||
|
return ApiException;
|
||||||
|
}(Error));
|
||||||
|
exports.ApiException = ApiException;
|
||||||
|
function throwException(message, status, response, headers, result) {
|
||||||
|
if (result !== null && result !== undefined)
|
||||||
|
throw result;
|
||||||
|
else
|
||||||
|
throw new ApiException(message, status, response, headers, null);
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=LogService.js.map
|
File diff suppressed because one or more lines are too long
@ -15,11 +15,11 @@ export default class LogService {
|
|||||||
|
|
||||||
constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
|
constructor(baseUrl?: string, http?: { fetch(url: RequestInfo, init?: RequestInit): Promise<Response> }) {
|
||||||
this.http = http ? http : <any>window;
|
this.http = http ? http : <any>window;
|
||||||
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "https://localhost:44331";
|
this.baseUrl = baseUrl !== undefined && baseUrl !== null ? baseUrl : "api/logs";
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(): Promise<string[]> {
|
getAll(): Promise<string[]> {
|
||||||
let url_ = this.baseUrl + "/api/Logs/all";
|
let url_ = this.baseUrl + "/all";
|
||||||
url_ = url_.replace(/[?&]$/, "");
|
url_ = url_.replace(/[?&]$/, "");
|
||||||
|
|
||||||
let options_ = <RequestInit>{
|
let options_ = <RequestInit>{
|
||||||
@ -58,7 +58,7 @@ export default class LogService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFiles(filenames: string[] | null | undefined): Promise<FileResponse | null> {
|
getFiles(filenames: string[] | null | undefined): Promise<FileResponse | null> {
|
||||||
let url_ = this.baseUrl + "/api/Logs?";
|
let url_ = this.baseUrl + "?";
|
||||||
if (filenames !== undefined && filenames !== null)
|
if (filenames !== undefined && filenames !== null)
|
||||||
filenames && filenames.forEach(item => { url_ += "filenames=" + encodeURIComponent("" + item) + "&"; });
|
filenames && filenames.forEach(item => { url_ += "filenames=" + encodeURIComponent("" + item) + "&"; });
|
||||||
url_ = url_.replace(/[?&]$/, "");
|
url_ = url_.replace(/[?&]$/, "");
|
||||||
|
Loading…
Reference in New Issue
Block a user