mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
complete settings view model for logs ui
This commit is contained in:
parent
69ada73dd4
commit
375d8b066c
@ -52,6 +52,7 @@ export class SettingsViewModel extends ViewModel {
|
|||||||
this.maxSentImageSizeLimit = 4000;
|
this.maxSentImageSizeLimit = 4000;
|
||||||
this.pushNotifications = new PushNotificationStatus();
|
this.pushNotifications = new PushNotificationStatus();
|
||||||
this._activeTheme = undefined;
|
this._activeTheme = undefined;
|
||||||
|
this._logsFeedbackMessage = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
get _session() {
|
get _session() {
|
||||||
@ -153,19 +154,49 @@ export class SettingsViewModel extends ViewModel {
|
|||||||
this.platform.saveFileAs(logExport.asBlob(), `hydrogen-logs-${this.platform.clock.now()}.json`);
|
this.platform.saveFileAs(logExport.asBlob(), `hydrogen-logs-${this.platform.clock.now()}.json`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get canSendLogsToServer() {
|
||||||
|
return !!this.platform.config.bugReportEndpointUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
get logsServer() {
|
||||||
|
const {bugReportEndpointUrl} = this.platform.config;
|
||||||
|
try {
|
||||||
|
if (bugReportEndpointUrl) {
|
||||||
|
return new URL(bugReportEndpointUrl).hostname;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
async sendLogsToServer() {
|
async sendLogsToServer() {
|
||||||
const logExport = await this.logger.export();
|
const {bugReportEndpointUrl} = this.platform.config;
|
||||||
await submitLogsToRageshakeServer(
|
if (bugReportEndpointUrl) {
|
||||||
{
|
this._logsFeedbackMessage = this.i18n`Sending logs…`;
|
||||||
app: "hydrogen",
|
this.emitChange();
|
||||||
userAgent: "<missing>",
|
try {
|
||||||
version: DEFINE_VERSION,
|
const logExport = await this.logger.export();
|
||||||
text: "Submit logs from settings",
|
await submitLogsToRageshakeServer(
|
||||||
},
|
{
|
||||||
logExport.asBlob(),
|
app: "hydrogen",
|
||||||
this.platform.config.bugReportEndpointUrl,
|
userAgent: this.platform.description,
|
||||||
this.platform.request
|
version: DEFINE_VERSION,
|
||||||
);
|
text: `Submit logs from settings for user ${this._session.userId} on device ${this._session.deviceId}`,
|
||||||
|
},
|
||||||
|
logExport.asBlob(),
|
||||||
|
bugReportEndpointUrl,
|
||||||
|
this.platform.request
|
||||||
|
);
|
||||||
|
this._logsFeedbackMessage = this.i18n`Logs sent succesfully!`;
|
||||||
|
this.emitChange();
|
||||||
|
} catch (err) {
|
||||||
|
this._logsFeedbackMessage = err.message;
|
||||||
|
this.emitChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get logsFeedbackMessage() {
|
||||||
|
return this._logsFeedbackMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
async togglePushNotifications() {
|
async togglePushNotifications() {
|
||||||
|
@ -17,10 +17,12 @@ limitations under the License.
|
|||||||
|
|
||||||
import {BlobHandle} from "../../platform/web/dom/BlobHandle.js";
|
import {BlobHandle} from "../../platform/web/dom/BlobHandle.js";
|
||||||
|
|
||||||
|
export type RequestBody = BlobHandle | string | Map<string, string | {blob: BlobHandle, name: string}>;
|
||||||
|
|
||||||
export type EncodedBody = {
|
export type EncodedBody = {
|
||||||
mimeType: string;
|
mimeType: string;
|
||||||
// the map gets transformed to a FormData object on the web
|
// the map gets transformed to a FormData object on the web
|
||||||
body: BlobHandle | string | Map<string, string | {blob: BlobHandle, name: string}>;
|
body: RequestBody
|
||||||
}
|
}
|
||||||
|
|
||||||
export function encodeQueryParams(queryParams?: object): string {
|
export function encodeQueryParams(queryParams?: object): string {
|
||||||
|
@ -15,13 +15,13 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type {RequestResult} from "../web/dom/request/fetch.js";
|
import type {RequestResult} from "../web/dom/request/fetch.js";
|
||||||
import type {EncodedBody} from "../../matrix/net/common";
|
import type {RequestBody} from "../../matrix/net/common";
|
||||||
import type {ILogItem} from "../../logging/types";
|
import type {ILogItem} from "../../logging/types";
|
||||||
|
|
||||||
export interface IRequestOptions {
|
export interface IRequestOptions {
|
||||||
uploadProgress?: (loadedBytes: number) => void;
|
uploadProgress?: (loadedBytes: number) => void;
|
||||||
timeout?: number;
|
timeout?: number;
|
||||||
body?: EncodedBody;
|
body?: RequestBody;
|
||||||
headers?: Map<string, string|number>;
|
headers?: Map<string, string|number>;
|
||||||
cache?: boolean;
|
cache?: boolean;
|
||||||
method?: string;
|
method?: string;
|
||||||
|
@ -345,6 +345,10 @@ export class Platform {
|
|||||||
head.appendChild(styleTag);
|
head.appendChild(styleTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get description() {
|
||||||
|
return navigator.userAgent ?? "<unknown>";
|
||||||
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
this._disposables.dispose();
|
this._disposables.dispose();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user