diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-22 15:29:32 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-22 15:29:32 +0100 |
commit | 1f30a1853e38c20a45722dbd6d38aaaec63839e8 (patch) | |
tree | cdce8cc9fcc62d9b3343c9478b1dbcefedcea972 /client/src/app/+admin | |
parent | 78967fca4cacbc247fa6fb62d64b2d6825a10804 (diff) | |
download | PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.tar.gz PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.tar.zst PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.zip |
Add confirm when admin use custom js/css
Diffstat (limited to 'client/src/app/+admin')
6 files changed, 69 insertions, 53 deletions
diff --git a/client/src/app/+admin/config/config.routes.ts b/client/src/app/+admin/config/config.routes.ts index a46b0ddfd..2ca2f8fde 100644 --- a/client/src/app/+admin/config/config.routes.ts +++ b/client/src/app/+admin/config/config.routes.ts | |||
@@ -23,7 +23,7 @@ export const ConfigRoutes: Routes = [ | |||
23 | component: EditCustomConfigComponent, | 23 | component: EditCustomConfigComponent, |
24 | data: { | 24 | data: { |
25 | meta: { | 25 | meta: { |
26 | title: 'Following list' | 26 | title: 'Edit custom configuration' |
27 | } | 27 | } |
28 | } | 28 | } |
29 | } | 29 | } |
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 027268536..ccec89a8e 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts | |||
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core' | |||
2 | import { FormBuilder, FormGroup } from '@angular/forms' | 2 | import { FormBuilder, FormGroup } from '@angular/forms' |
3 | import { Router } from '@angular/router' | 3 | import { Router } from '@angular/router' |
4 | import { ConfigService } from '@app/+admin/config/shared/config.service' | 4 | import { ConfigService } from '@app/+admin/config/shared/config.service' |
5 | import { ConfirmService } from '@app/core' | ||
5 | import { ServerService } from '@app/core/server/server.service' | 6 | import { ServerService } from '@app/core/server/server.service' |
6 | import { FormReactive, USER_VIDEO_QUOTA } from '@app/shared' | 7 | import { FormReactive, USER_VIDEO_QUOTA } from '@app/shared' |
7 | import { | 8 | import { |
@@ -61,12 +62,16 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
61 | userVideoQuota: USER_VIDEO_QUOTA.MESSAGES | 62 | userVideoQuota: USER_VIDEO_QUOTA.MESSAGES |
62 | } | 63 | } |
63 | 64 | ||
65 | private oldCustomJavascript: string | ||
66 | private oldCustomCSS: string | ||
67 | |||
64 | constructor ( | 68 | constructor ( |
65 | private formBuilder: FormBuilder, | 69 | private formBuilder: FormBuilder, |
66 | private router: Router, | 70 | private router: Router, |
67 | private notificationsService: NotificationsService, | 71 | private notificationsService: NotificationsService, |
68 | private configService: ConfigService, | 72 | private configService: ConfigService, |
69 | private serverService: ServerService | 73 | private serverService: ServerService, |
74 | private confirmService: ConfirmService | ||
70 | ) { | 75 | ) { |
71 | super() | 76 | super() |
72 | } | 77 | } |
@@ -109,6 +114,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
109 | res => { | 114 | res => { |
110 | this.customConfig = res | 115 | this.customConfig = res |
111 | 116 | ||
117 | this.oldCustomCSS = this.customConfig.instance.customizations.css | ||
118 | this.oldCustomJavascript = this.customConfig.instance.customizations.javascript | ||
119 | |||
112 | this.updateForm() | 120 | this.updateForm() |
113 | }, | 121 | }, |
114 | 122 | ||
@@ -124,7 +132,27 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { | |||
124 | return this.form.value['signupEnabled'] === true | 132 | return this.form.value['signupEnabled'] === true |
125 | } | 133 | } |
126 | 134 | ||
127 | formValidated () { | 135 | async formValidated () { |
136 | const newCustomizationJavascript = this.form.value['customizationJavascript'] | ||
137 | const newCustomizationCSS = this.form.value['customizationCSS'] | ||
138 | |||
139 | const customizations = [] | ||
140 | if (newCustomizationJavascript && newCustomizationJavascript !== this.oldCustomJavascript) customizations.push('JavaScript') | ||
141 | if (newCustomizationCSS && newCustomizationCSS !== this.oldCustomCSS) customizations.push('CSS') | ||
142 | |||
143 | if (customizations.length !== 0) { | ||
144 | const customizationsText = customizations.join('/') | ||
145 | |||
146 | const message = `You set custom ${customizationsText}. ` + | ||
147 | 'This could lead to security issues or bugs if you do not understand it. ' + | ||
148 | 'Are you sure you want to update the configuration?' | ||
149 | const label = `Please type "I understand the ${customizationsText} I set" to confirm.` | ||
150 | const expectedInputValue = `I understand the ${customizationsText} I set` | ||
151 | |||
152 | const confirmRes = await this.confirmService.confirmWithInput(message, label, expectedInputValue) | ||
153 | if (confirmRes === false) return | ||
154 | } | ||
155 | |||
128 | const data = { | 156 | const data = { |
129 | instance: { | 157 | instance: { |
130 | name: this.form.value['instanceName'], | 158 | name: this.form.value['instanceName'], |
diff --git a/client/src/app/+admin/follows/following-add/following-add.component.ts b/client/src/app/+admin/follows/following-add/following-add.component.ts index bf842129d..c296c8852 100644 --- a/client/src/app/+admin/follows/following-add/following-add.component.ts +++ b/client/src/app/+admin/follows/following-add/following-add.component.ts | |||
@@ -43,7 +43,7 @@ export class FollowingAddComponent { | |||
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | addFollowing () { | 46 | async addFollowing () { |
47 | this.error = '' | 47 | this.error = '' |
48 | 48 | ||
49 | const hosts = this.getNotEmptyHosts() | 49 | const hosts = this.getNotEmptyHosts() |
@@ -57,20 +57,17 @@ export class FollowingAddComponent { | |||
57 | } | 57 | } |
58 | 58 | ||
59 | const confirmMessage = 'If you confirm, you will send a follow request to:<br /> - ' + hosts.join('<br /> - ') | 59 | const confirmMessage = 'If you confirm, you will send a follow request to:<br /> - ' + hosts.join('<br /> - ') |
60 | this.confirmService.confirm(confirmMessage, 'Follow new server(s)').subscribe( | 60 | const res = await this.confirmService.confirm(confirmMessage, 'Follow new server(s)') |
61 | res => { | 61 | if (res === false) return |
62 | if (res === false) return | ||
63 | 62 | ||
64 | this.followService.follow(hosts).subscribe( | 63 | this.followService.follow(hosts).subscribe( |
65 | status => { | 64 | () => { |
66 | this.notificationsService.success('Success', 'Follow request(s) sent!') | 65 | this.notificationsService.success('Success', 'Follow request(s) sent!') |
67 | 66 | ||
68 | setTimeout(() => this.router.navigate([ '/admin/follows/following-list' ]), 500) | 67 | setTimeout(() => this.router.navigate([ '/admin/follows/following-list' ]), 500) |
69 | }, | 68 | }, |
70 | 69 | ||
71 | err => this.notificationsService.error('Error', err.message) | 70 | err => this.notificationsService.error('Error', err.message) |
72 | ) | ||
73 | } | ||
74 | ) | 71 | ) |
75 | } | 72 | } |
76 | 73 | ||
diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts index d4f8d0309..ad1bd4536 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.ts +++ b/client/src/app/+admin/follows/following-list/following-list.component.ts | |||
@@ -25,20 +25,17 @@ export class FollowingListComponent extends RestTable { | |||
25 | super() | 25 | super() |
26 | } | 26 | } |
27 | 27 | ||
28 | removeFollowing (follow: AccountFollow) { | 28 | async removeFollowing (follow: AccountFollow) { |
29 | this.confirmService.confirm(`Do you really want to unfollow ${follow.following.host}?`, 'Unfollow').subscribe( | 29 | const res = await this.confirmService.confirm(`Do you really want to unfollow ${follow.following.host}?`, 'Unfollow') |
30 | res => { | 30 | if (res === false) return |
31 | if (res === false) return | ||
32 | 31 | ||
33 | this.followService.unfollow(follow).subscribe( | 32 | this.followService.unfollow(follow).subscribe( |
34 | () => { | 33 | () => { |
35 | this.notificationsService.success('Success', `You are not following ${follow.following.host} anymore.`) | 34 | this.notificationsService.success('Success', `You are not following ${follow.following.host} anymore.`) |
36 | this.loadData() | 35 | this.loadData() |
37 | }, | 36 | }, |
38 | 37 | ||
39 | err => this.notificationsService.error('Error', err.message) | 38 | err => this.notificationsService.error('Error', err.message) |
40 | ) | ||
41 | } | ||
42 | ) | 39 | ) |
43 | } | 40 | } |
44 | 41 | ||
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts index 1e8e1af49..512152808 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/users/user-list/user-list.component.ts | |||
@@ -1,10 +1,10 @@ | |||
1 | import { Component } from '@angular/core' | 1 | import { Component } from '@angular/core' |
2 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
3 | 2 | ||
4 | import { NotificationsService } from 'angular2-notifications' | 3 | import { NotificationsService } from 'angular2-notifications' |
4 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
5 | 5 | ||
6 | import { ConfirmService } from '../../../core' | 6 | import { ConfirmService } from '../../../core' |
7 | import { RestTable, RestPagination, User } from '../../../shared' | 7 | import { RestPagination, RestTable, User } from '../../../shared' |
8 | import { UserService } from '../shared' | 8 | import { UserService } from '../shared' |
9 | 9 | ||
10 | @Component({ | 10 | @Component({ |
@@ -27,25 +27,22 @@ export class UserListComponent extends RestTable { | |||
27 | super() | 27 | super() |
28 | } | 28 | } |
29 | 29 | ||
30 | removeUser (user: User) { | 30 | async removeUser (user: User) { |
31 | if (user.username === 'root') { | 31 | if (user.username === 'root') { |
32 | this.notificationsService.error('Error', 'You cannot delete root.') | 32 | this.notificationsService.error('Error', 'You cannot delete root.') |
33 | return | 33 | return |
34 | } | 34 | } |
35 | 35 | ||
36 | this.confirmService.confirm('Do you really want to delete this user?', 'Delete').subscribe( | 36 | const res = await this.confirmService.confirm('Do you really want to delete this user?', 'Delete') |
37 | res => { | 37 | if (res === false) return |
38 | if (res === false) return | ||
39 | 38 | ||
40 | this.userService.removeUser(user).subscribe( | 39 | this.userService.removeUser(user).subscribe( |
41 | () => { | 40 | () => { |
42 | this.notificationsService.success('Success', `User ${user.username} deleted.`) | 41 | this.notificationsService.success('Success', `User ${user.username} deleted.`) |
43 | this.loadData() | 42 | this.loadData() |
44 | }, | 43 | }, |
45 | 44 | ||
46 | err => this.notificationsService.error('Error', err.message) | 45 | err => this.notificationsService.error('Error', err.message) |
47 | ) | ||
48 | } | ||
49 | ) | 46 | ) |
50 | } | 47 | } |
51 | 48 | ||
diff --git a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts index 56024b247..f4cf21259 100644 --- a/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts +++ b/client/src/app/+admin/video-blacklist/video-blacklist-list/video-blacklist-list.component.ts | |||
@@ -31,22 +31,19 @@ export class VideoBlacklistListComponent extends RestTable implements OnInit { | |||
31 | this.loadData() | 31 | this.loadData() |
32 | } | 32 | } |
33 | 33 | ||
34 | removeVideoFromBlacklist (entry: BlacklistedVideo) { | 34 | async removeVideoFromBlacklist (entry: BlacklistedVideo) { |
35 | const confirmMessage = 'Do you really want to remove this video from the blacklist ? It will be available again in the video list.' | 35 | const confirmMessage = 'Do you really want to remove this video from the blacklist ? It will be available again in the video list.' |
36 | 36 | ||
37 | this.confirmService.confirm(confirmMessage, 'Remove').subscribe( | 37 | const res = await this.confirmService.confirm(confirmMessage, 'Remove') |
38 | res => { | 38 | if (res === false) return |
39 | if (res === false) return | ||
40 | 39 | ||
41 | this.videoBlacklistService.removeVideoFromBlacklist(entry.videoId).subscribe( | 40 | this.videoBlacklistService.removeVideoFromBlacklist(entry.videoId).subscribe( |
42 | status => { | 41 | () => { |
43 | this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`) | 42 | this.notificationsService.success('Success', `Video ${entry.name} removed from the blacklist.`) |
44 | this.loadData() | 43 | this.loadData() |
45 | }, | 44 | }, |
46 | 45 | ||
47 | err => this.notificationsService.error('Error', err.message) | 46 | err => this.notificationsService.error('Error', err.message) |
48 | ) | ||
49 | } | ||
50 | ) | 47 | ) |
51 | } | 48 | } |
52 | 49 | ||