未验证 提交 db3f8bf5 编写于 作者: M Marcin Maciaszczyk 提交者: GitHub

Add option to disable access denied notifications (#5004)

* Add option to disable access denied notifications

* Fix settings access and styling
Co-authored-by: NSebastian Florek <sebastian.florek@loodse.com>
上级 4d047bbc
......@@ -5056,6 +5056,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5063,7 +5079,7 @@
<target>Speichern</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5073,7 +5089,7 @@
<target>Neu laden</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -5070,6 +5070,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5077,7 +5093,7 @@
<target>Enregistrer</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5087,7 +5103,7 @@
<target>Recharger</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -5011,6 +5011,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5018,7 +5034,7 @@
<target>保存</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5028,7 +5044,7 @@
<target>リロード</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -5142,6 +5142,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5151,7 +5167,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5163,7 +5179,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -3416,13 +3416,27 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
</source>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -3431,7 +3445,7 @@
</source>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -5145,6 +5145,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5154,7 +5170,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5166,7 +5182,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -5145,6 +5145,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5154,7 +5170,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5166,7 +5182,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -5145,6 +5145,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5154,7 +5170,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5166,7 +5182,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -5145,6 +5145,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5154,7 +5170,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5166,7 +5182,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -5145,6 +5145,22 @@
<context context-type="linenumber">83</context>
</context-group>
</trans-unit>
<trans-unit id="a4f3393592e5ebfd34408e85c3bd576d88839191" datatype="html">
<source>Disable access denied notification</source>
<target state="new">Disable access denied notification</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">100</context>
</context-group>
</trans-unit>
<trans-unit id="b6484080715a11bad65395e51d42e6ae4aa3c856" datatype="html">
<source>Hides all access denied warnings in the notification panel.</source>
<target state="new">Hides all access denied warnings in the notification panel.</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">102</context>
</context-group>
</trans-unit>
<trans-unit id="f8b53b407af242e77dc3391947f23988f3451e64" datatype="html">
<source>
Save
......@@ -5154,7 +5170,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">105</context>
<context context-type="linenumber">116</context>
</context-group>
</trans-unit>
<trans-unit id="713f3afed85462e92402e8e3523c6dcdb362ce17" datatype="html">
......@@ -5166,7 +5182,7 @@
</target>
<context-group purpose="location">
<context context-type="sourcefile">../src/app/frontend/settings/global/template.html</context>
<context context-type="linenumber">112</context>
<context context-type="linenumber">123</context>
</context-group>
</trans-unit>
<trans-unit id="d440068d2406e98fd156b9dcab7f0998e707a38b" datatype="html">
......
......@@ -89,10 +89,11 @@ func UnmarshalPinnedResources(data string) (*[]PinnedResource, error) {
// Settings is a single instance of settings without context.
type Settings struct {
ClusterName string `json:"clusterName"`
ItemsPerPage int `json:"itemsPerPage"`
LogsAutoRefreshTimeInterval int `json:"logsAutoRefreshTimeInterval"`
ResourceAutoRefreshTimeInterval int `json:"resourceAutoRefreshTimeInterval"`
ClusterName string `json:"clusterName"`
ItemsPerPage int `json:"itemsPerPage"`
LogsAutoRefreshTimeInterval int `json:"logsAutoRefreshTimeInterval"`
ResourceAutoRefreshTimeInterval int `json:"resourceAutoRefreshTimeInterval"`
DisableAccessDeniedNotifications bool `json:"disableAccessDeniedNotifications"`
}
// Marshal settings into JSON object.
......@@ -110,10 +111,11 @@ func Unmarshal(data string) (*Settings, error) {
// defaultSettings contains default values for every setting.
var defaultSettings = Settings{
ClusterName: "",
ItemsPerPage: 10,
LogsAutoRefreshTimeInterval: 5,
ResourceAutoRefreshTimeInterval: 5,
ClusterName: "",
ItemsPerPage: 10,
LogsAutoRefreshTimeInterval: 5,
ResourceAutoRefreshTimeInterval: 5,
DisableAccessDeniedNotifications: false,
}
// GetDefaultSettings returns settings structure, that should be used if there are no
......
......@@ -84,12 +84,7 @@ func (self *SettingsHandler) handleSettingsGlobalCanI(request *restful.Request,
}
func (self *SettingsHandler) handleSettingsGlobalGet(request *restful.Request, response *restful.Response) {
client, err := self.clientManager.Client(request)
if err != nil {
errors.HandleInternalError(response, err)
return
}
client := self.clientManager.InsecureClient()
result := self.manager.GetGlobalSettings(client)
response.WriteHeaderAndEntity(http.StatusOK, result)
}
......@@ -115,12 +110,7 @@ func (self *SettingsHandler) handleSettingsGlobalSave(request *restful.Request,
}
func (self *SettingsHandler) handleSettingsGetPinned(request *restful.Request, response *restful.Response) {
client, err := self.clientManager.Client(request)
if err != nil {
errors.HandleInternalError(response, err)
return
}
client := self.clientManager.InsecureClient()
result := self.manager.GetPinnedResources(client)
response.WriteHeaderAndEntity(http.StatusOK, result)
}
......
......@@ -23,7 +23,7 @@ import {Notification, NotificationsService} from '../../common/services/global/n
styleUrls: ['./style.scss'],
animations: [Animations.easeOut],
})
export class NotificationsComponent implements OnInit {
export class NotificationsComponent {
isOpen_ = false;
notifications: Notification[] = [];
......@@ -32,12 +32,6 @@ export class NotificationsComponent implements OnInit {
private readonly element_: ElementRef,
) {}
ngOnInit(): void {
// this.transition_.onExit({}, () => {
// this.close_();
// });
}
@HostListener('document:click', ['$event'])
private onOutsideClick_(event: Event): void {
if (!this.element_.nativeElement.contains(event.target) && this.isOpen()) {
......
......@@ -157,11 +157,11 @@ export class NamespaceSelectorComponent implements OnInit, OnDestroy {
if (namespaceList.errors.length > 0) {
for (const err of namespaceList.errors) {
this.notifications_.push(err.ErrStatus.message, NotificationSeverity.error);
this.notifications_.pushErrors([err]);
}
}
},
undefined,
() => {},
() => {
this.onNamespaceLoaded_();
},
......
......@@ -13,12 +13,12 @@
// limitations under the License.
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {EventEmitter, Injectable} from '@angular/core';
import {Injectable} from '@angular/core';
import {GlobalSettings} from '@api/backendapi';
import {onSettingsFailCallback, onSettingsLoadCallback} from '@api/frontendapi';
import {ReplaySubject} from 'rxjs';
import {of, ReplaySubject} from 'rxjs';
import {Observable} from 'rxjs/Observable';
import {publishReplay, refCount} from 'rxjs/operators';
import {catchError, switchMap} from 'rxjs/operators';
import {AuthorizerService} from './authorizer';
......@@ -32,6 +32,7 @@ export class GlobalSettingsService {
clusterName: '',
logsAutoRefreshTimeInterval: 5,
resourceAutoRefreshTimeInterval: 5,
disableAccessDeniedNotifications: false,
};
private isInitialized_ = false;
......@@ -49,8 +50,8 @@ export class GlobalSettingsService {
}
load(onLoad?: onSettingsLoadCallback, onFail?: onSettingsFailCallback): void {
this.authorizer_
.proxyGET<GlobalSettings>(this.endpoint_)
this.http_
.get<GlobalSettings>(this.endpoint_)
.toPromise()
.then(
settings => {
......@@ -67,6 +68,13 @@ export class GlobalSettingsService {
);
}
canI(): Observable<boolean> {
return this.authorizer_
.proxyGET<GlobalSettings>(this.endpoint_)
.pipe(switchMap(_ => of(true)))
.pipe(catchError(_ => of(false)));
}
save(settings: GlobalSettings): Observable<GlobalSettings> {
const httpOptions = {
method: 'PUT',
......@@ -92,4 +100,8 @@ export class GlobalSettingsService {
getResourceAutoRefreshTimeInterval(): number {
return this.settings_.resourceAutoRefreshTimeInterval;
}
getDisableAccessDeniedNotifications(): boolean {
return this.settings_.disableAccessDeniedNotifications;
}
}
......@@ -14,6 +14,7 @@
import {Injectable} from '@angular/core';
import {K8sError} from '@api/backendapi';
import {GlobalSettingsService} from './globalsettings';
export class Notification {
message: string;
......@@ -53,18 +54,39 @@ export enum NotificationSeverity {
export class NotificationsService {
private notifications_: Notification[] = [];
constructor(private readonly _globalSettingsService: GlobalSettingsService) {}
push(message: string, severity: NotificationSeverity): void {
console.log(message);
// Do not add same notifications multiple times
if (this.notifications_.some(notification => notification.message === message)) {
return;
}
this.notifications_ = [new Notification(message, severity), ...this.notifications_];
}
pushErrors(errors: K8sError[]): void {
if (errors) {
errors.forEach(error => {
this.push(error.ErrStatus.message, NotificationSeverity.error);
if (this._shouldAddNotification(error)) {
this.push(error.ErrStatus.message, NotificationSeverity.error);
}
});
}
}
private _shouldAddNotification(error: K8sError): boolean {
return (
!this._globalSettingsService.getDisableAccessDeniedNotifications() ||
!this._isAccessDeniedError(error)
);
}
private _isAccessDeniedError(error: K8sError): boolean {
return error.ErrStatus.code === 403;
}
remove(index: number): void {
this.notifications_.splice(index, 1);
}
......
......@@ -263,6 +263,10 @@ router-outlet::after {
width: 2 * $baseline-grid;
}
.mat-slider {
margin-left: -$baseline-grid;
}
.kd-comma-separated-item {
display: inline-block;
......
......@@ -12,22 +12,30 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import {Component, OnInit} from '@angular/core';
import {Component, OnDestroy, OnInit} from '@angular/core';
import {NgForm} from '@angular/forms';
import {MatDialog} from '@angular/material/dialog';
import {GlobalSettings} from '@api/backendapi';
import {Subject} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
import {GlobalSettingsService} from '../../common/services/global/globalsettings';
import {TitleService} from '../../common/services/global/title';
import {SaveAnywayDialog} from './saveanywaysdialog/dialog';
@Component({selector: 'kd-global-settings', templateUrl: './template.html'})
export class GlobalSettingsComponent implements OnInit {
@Component({
selector: 'kd-global-settings',
templateUrl: './template.html',
styleUrls: ['style.scss'],
})
export class GlobalSettingsComponent implements OnInit, OnDestroy {
// Keep it in sync with ConcurrentSettingsChangeError constant from the backend.
private readonly concurrentChangeErr_ = 'settings changed since last reload';
settings: GlobalSettings = {} as GlobalSettings;
hasLoadError = false;
private readonly unsubscribe_ = new Subject<void>();
constructor(
private readonly settings_: GlobalSettingsService,
private readonly dialog_: MatDialog,
......@@ -38,6 +46,11 @@ export class GlobalSettingsComponent implements OnInit {
this.load();
}
ngOnDestroy(): void {
this.unsubscribe_.next();
this.unsubscribe_.complete();
}
isInitialized(): boolean {
return this.settings_.isInitialized();
}
......@@ -47,6 +60,10 @@ export class GlobalSettingsComponent implements OnInit {
form.resetForm();
}
this.settings_
.canI()
.pipe(takeUntil(this.unsubscribe_))
.subscribe(canI => (this.hasLoadError = !canI));
this.settings_.load(this.onLoad.bind(this), this.onLoadError.bind(this));
}
......@@ -55,6 +72,7 @@ export class GlobalSettingsComponent implements OnInit {
this.settings.clusterName = this.settings_.getClusterName();
this.settings.logsAutoRefreshTimeInterval = this.settings_.getLogsAutoRefreshTimeInterval();
this.settings.resourceAutoRefreshTimeInterval = this.settings_.getResourceAutoRefreshTimeInterval();
this.settings.disableAccessDeniedNotifications = this.settings_.getDisableAccessDeniedNotifications();
}
onLoadError(): void {
......
// Copyright 2017 The Kubernetes Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
@import '../../variables';
kd-settings-entry {
min-height: 7 * $baseline-grid;
}
......@@ -97,6 +97,17 @@ limitations under the License.
</span>
</div>
</kd-settings-entry>
<kd-settings-entry key="Disable access denied notification"
i18n-key
desc="Hides all access denied warnings in the notification panel."
i18n-desc>
<div fxFlex
fxLayoutAlign=" center">
<mat-slide-toggle color="primary"
name="disableAccessDeniedNotifications"
[(ngModel)]="settings.disableAccessDeniedNotifications"></mat-slide-toggle>
</div>
</kd-settings-entry>
<br><br>
<button [disabled]="form.pristine"
type="submit"
......
......@@ -1042,6 +1042,7 @@ export interface GlobalSettings {
itemsPerPage: number;
logsAutoRefreshTimeInterval: number;
resourceAutoRefreshTimeInterval: number;
disableAccessDeniedNotifications: boolean;
}
export interface PinnedResource {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册