mirror of
https://github.com/google/nomulus
synced 2026-08-15 19:56:08 +00:00
If we don't explicitly handle random unexpected exceptions, the error that the front end receives includes a big ole stacktrace, which is unhelpful for regular users and possibly bad to expose. Instead, we should provide a vague "something went wrong" message. Separately, we can create a default SnackBar options and use that (we want it longer than 1.5 seconds because that's pretty short).
77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
// Copyright 2023 The Nomulus Authors. All Rights Reserved.
|
|
//
|
|
// 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 { HttpErrorResponse } from '@angular/common/http';
|
|
import { Component } from '@angular/core';
|
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
import {
|
|
Registrar,
|
|
RegistrarService,
|
|
} from 'src/app/registrar/registrar.service';
|
|
|
|
import { WhoisService } from './whois.service';
|
|
|
|
@Component({
|
|
selector: 'app-whois',
|
|
templateUrl: './whois.component.html',
|
|
styleUrls: ['./whois.component.scss'],
|
|
providers: [WhoisService],
|
|
})
|
|
export default class WhoisComponent {
|
|
public static PATH = 'whois';
|
|
loading = false;
|
|
inEdit = false;
|
|
registrar: Registrar;
|
|
|
|
constructor(
|
|
public whoisService: WhoisService,
|
|
public registrarService: RegistrarService,
|
|
private _snackBar: MatSnackBar
|
|
) {
|
|
this.registrar = JSON.parse(
|
|
JSON.stringify(this.registrarService.registrar)
|
|
);
|
|
}
|
|
|
|
enableEdit() {
|
|
this.inEdit = true;
|
|
}
|
|
|
|
cancel() {
|
|
this.inEdit = false;
|
|
this.resetDataSource();
|
|
}
|
|
|
|
save() {
|
|
this.loading = true;
|
|
this.whoisService.saveChanges(this.registrar).subscribe({
|
|
complete: () => {
|
|
this.loading = false;
|
|
this.resetDataSource();
|
|
},
|
|
error: (err: HttpErrorResponse) => {
|
|
this._snackBar.open(err.error);
|
|
this.loading = false;
|
|
},
|
|
});
|
|
this.cancel();
|
|
}
|
|
|
|
resetDataSource() {
|
|
this.registrar = JSON.parse(
|
|
JSON.stringify(this.registrarService.registrar)
|
|
);
|
|
}
|
|
}
|