diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-15 15:30:14 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-18 11:37:18 +0200 |
commit | 42b40636991b97fe818007fab19091764fc5db73 (patch) | |
tree | db431787c06ce898d22e91ff771f795219274fc6 /client/src/app/+admin | |
parent | 654d4ede7fa4d0faa71e49bcfab6b65a686397b2 (diff) | |
download | PeerTube-42b40636991b97fe818007fab19091764fc5db73.tar.gz PeerTube-42b40636991b97fe818007fab19091764fc5db73.tar.zst PeerTube-42b40636991b97fe818007fab19091764fc5db73.zip |
Add ability for client to create server logs
Diffstat (limited to 'client/src/app/+admin')
5 files changed, 14 insertions, 11 deletions
diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.ts b/client/src/app/+admin/overview/users/user-list/user-list.component.ts index 3e1a5f6b8..99987fdff 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.ts | |||
@@ -2,11 +2,12 @@ import { SortMeta } from 'primeng/api' | |||
2 | import { Component, OnInit, ViewChild } from '@angular/core' | 2 | import { Component, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { AuthService, ConfirmService, LocalStorageService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' | 4 | import { AuthService, ConfirmService, LocalStorageService, Notifier, RestPagination, RestTable, ServerService } from '@app/core' |
5 | import { prepareIcu, getAPIHost } from '@app/helpers' | 5 | import { getAPIHost, prepareIcu } from '@app/helpers' |
6 | import { AdvancedInputFilter } from '@app/shared/shared-forms' | 6 | import { AdvancedInputFilter } from '@app/shared/shared-forms' |
7 | import { Actor, DropdownAction } from '@app/shared/shared-main' | 7 | import { Actor, DropdownAction } from '@app/shared/shared-main' |
8 | import { AccountMutedStatus, BlocklistService, UserBanModalComponent, UserModerationDisplayType } from '@app/shared/shared-moderation' | 8 | import { AccountMutedStatus, BlocklistService, UserBanModalComponent, UserModerationDisplayType } from '@app/shared/shared-moderation' |
9 | import { UserAdminService } from '@app/shared/shared-users' | 9 | import { UserAdminService } from '@app/shared/shared-users' |
10 | import { logger } from '@root-helpers/logger' | ||
10 | import { User, UserRole } from '@shared/models' | 11 | import { User, UserRole } from '@shared/models' |
11 | 12 | ||
12 | type UserForList = User & { | 13 | type UserForList = User & { |
@@ -149,7 +150,7 @@ export class UserListComponent extends RestTable implements OnInit { | |||
149 | this.selectedColumns = JSON.parse(result) | 150 | this.selectedColumns = JSON.parse(result) |
150 | return | 151 | return |
151 | } catch (err) { | 152 | } catch (err) { |
152 | console.error('Cannot load selected columns.', err) | 153 | logger.error('Cannot load selected columns.', err) |
153 | } | 154 | } |
154 | } | 155 | } |
155 | 156 | ||
diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts index d39c2ea1c..b02c054a2 100644 --- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts +++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts | |||
@@ -4,6 +4,7 @@ import { Component, OnInit } from '@angular/core' | |||
4 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ActivatedRoute, Router } from '@angular/router' |
5 | import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' | 5 | import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' |
6 | import { ComponentPagination, ConfirmService, hasMoreItems, Notifier, PluginService } from '@app/core' | 6 | import { ComponentPagination, ConfirmService, hasMoreItems, Notifier, PluginService } from '@app/core' |
7 | import { logger } from '@root-helpers/logger' | ||
7 | import { PeerTubePluginIndex, PluginType } from '@shared/models' | 8 | import { PeerTubePluginIndex, PluginType } from '@shared/models' |
8 | 9 | ||
9 | @Component({ | 10 | @Component({ |
@@ -94,7 +95,7 @@ export class PluginSearchComponent implements OnInit { | |||
94 | }, | 95 | }, |
95 | 96 | ||
96 | error: err => { | 97 | error: err => { |
97 | console.error(err) | 98 | logger.error(err) |
98 | 99 | ||
99 | const message = $localize`The plugin index is not available. Please retry later.` | 100 | const message = $localize`The plugin index is not available. Please retry later.` |
100 | this.notifier.error(message) | 101 | this.notifier.error(message) |
diff --git a/client/src/app/+admin/system/logs/log-row.model.ts b/client/src/app/+admin/system/logs/log-row.model.ts index 615778210..e83c7b064 100644 --- a/client/src/app/+admin/system/logs/log-row.model.ts +++ b/client/src/app/+admin/system/logs/log-row.model.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import { LogLevel } from '@shared/models' | ||
2 | import omit from 'lodash-es/omit' | 1 | import omit from 'lodash-es/omit' |
2 | import { logger } from '@root-helpers/logger' | ||
3 | import { ServerLogLevel } from '@shared/models' | ||
3 | 4 | ||
4 | export class LogRow { | 5 | export class LogRow { |
5 | date: Date | 6 | date: Date |
6 | localeDate: string | 7 | localeDate: string |
7 | level: LogLevel | 8 | level: ServerLogLevel |
8 | message: string | 9 | message: string |
9 | meta: string | 10 | meta: string |
10 | 11 | ||
@@ -33,7 +34,7 @@ export class LogRow { | |||
33 | this.meta = JSON.stringify(message, null, 2) | 34 | this.meta = JSON.stringify(message, null, 2) |
34 | this.message = '' | 35 | this.message = '' |
35 | } catch (err) { | 36 | } catch (err) { |
36 | console.error('Cannot parse audit message.', err) | 37 | logger.error('Cannot parse audit message.', err) |
37 | } | 38 | } |
38 | } | 39 | } |
39 | } | 40 | } |
diff --git a/client/src/app/+admin/system/logs/logs.component.ts b/client/src/app/+admin/system/logs/logs.component.ts index 06237522a..939e710d7 100644 --- a/client/src/app/+admin/system/logs/logs.component.ts +++ b/client/src/app/+admin/system/logs/logs.component.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' |
2 | import { LocalStorageService, Notifier } from '@app/core' | 2 | import { LocalStorageService, Notifier } from '@app/core' |
3 | import { LogLevel } from '@shared/models' | 3 | import { ServerLogLevel } from '@shared/models' |
4 | import { LogRow } from './log-row.model' | 4 | import { LogRow } from './log-row.model' |
5 | import { LogsService } from './logs.service' | 5 | import { LogsService } from './logs.service' |
6 | 6 | ||
@@ -17,11 +17,11 @@ export class LogsComponent implements OnInit { | |||
17 | 17 | ||
18 | logs: LogRow[] = [] | 18 | logs: LogRow[] = [] |
19 | timeChoices: { id: string, label: string, dateFormat: string }[] = [] | 19 | timeChoices: { id: string, label: string, dateFormat: string }[] = [] |
20 | levelChoices: { id: LogLevel, label: string }[] = [] | 20 | levelChoices: { id: ServerLogLevel, label: string }[] = [] |
21 | logTypeChoices: { id: 'audit' | 'standard', label: string }[] = [] | 21 | logTypeChoices: { id: 'audit' | 'standard', label: string }[] = [] |
22 | 22 | ||
23 | startDate: string | 23 | startDate: string |
24 | level: LogLevel | 24 | level: ServerLogLevel |
25 | logType: 'audit' | 'standard' | 25 | logType: 'audit' | 'standard' |
26 | tagsOneOf: string[] = [] | 26 | tagsOneOf: string[] = [] |
27 | 27 | ||
diff --git a/client/src/app/+admin/system/logs/logs.service.ts b/client/src/app/+admin/system/logs/logs.service.ts index ea7e08b9b..933a074a8 100644 --- a/client/src/app/+admin/system/logs/logs.service.ts +++ b/client/src/app/+admin/system/logs/logs.service.ts | |||
@@ -3,7 +3,7 @@ import { catchError, map } from 'rxjs/operators' | |||
3 | import { HttpClient, HttpParams } from '@angular/common/http' | 3 | import { HttpClient, HttpParams } from '@angular/common/http' |
4 | import { Injectable } from '@angular/core' | 4 | import { Injectable } from '@angular/core' |
5 | import { RestExtractor, RestService } from '@app/core' | 5 | import { RestExtractor, RestService } from '@app/core' |
6 | import { LogLevel } from '@shared/models' | 6 | import { ServerLogLevel } from '@shared/models' |
7 | import { environment } from '../../../../environments/environment' | 7 | import { environment } from '../../../../environments/environment' |
8 | import { LogRow } from './log-row.model' | 8 | import { LogRow } from './log-row.model' |
9 | 9 | ||
@@ -22,7 +22,7 @@ export class LogsService { | |||
22 | isAuditLog: boolean | 22 | isAuditLog: boolean |
23 | startDate: string | 23 | startDate: string |
24 | tagsOneOf?: string[] | 24 | tagsOneOf?: string[] |
25 | level?: LogLevel | 25 | level?: ServerLogLevel |
26 | endDate?: string | 26 | endDate?: string |
27 | }): Observable<any[]> { | 27 | }): Observable<any[]> { |
28 | const { isAuditLog, startDate, endDate, tagsOneOf } = options | 28 | const { isAuditLog, startDate, endDate, tagsOneOf } = options |