Skip to content

Commit

Permalink
NAS-127717 / 13.0 / Add syslog_tls_certificate_authority field (#9836)
Browse files Browse the repository at this point in the history
* NAS-125844 / 13.0 / Javascript error trying to edit disk in web UI (#9461)

* Fix edit disk action when name is path

* Fix remarks

---------

Co-authored-by: Boris Vasilenko <[email protected]>

* Add `syslog_tls_certificate_authority` field

---------

Co-authored-by: Boris Vasilenko <[email protected]>
  • Loading branch information
bvasilenko and bvasilenko authored Mar 26, 2024
1 parent 6289f77 commit 85dc49d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
4 changes: 4 additions & 0 deletions src/app/helptext/system/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,8 @@ The system only sends logs matching this level or higher.',
tooltip: T('The preconfigured system <i>Certificate</i> to use for authenticating\
the TLS protocol connection to the remote system log server.'),
},

syslog_tls_certificate_authority: {
placeholder: T('Syslog TLS Certificate Authority'),
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,11 @@ export class VolumeStatusComponent implements OnInit {
id: 'edit',
label: helptext.actions_label.edit,
onClick: (row) => {
const pIndex = row.name.lastIndexOf('p');
const diskName = pIndex > -1 ? row.name.substring(0, pIndex) : row.name;
const devname = this.trimDiskName(this.getLeaf(row.name), 'p');

this.ws.call('disk.query', [
[
['devname', '=', diskName],
['devname', '=', devname],
],
]).subscribe((res) => {
this.editDiskRoute.push(this.pk, 'edit', res[0].identifier);
Expand All @@ -246,12 +245,7 @@ export class VolumeStatusComponent implements OnInit {
id: 'offline',
label: helptext.actions_label.offline,
onClick: (row) => {
let name = row.name;
// if use path as name, show the full path
if (!_.startsWith(name, '/')) {
const pIndex = name.lastIndexOf('p');
name = pIndex > -1 ? name.substring(0, pIndex) : name;
}
const name = this.trimDiskName(row.name, 'p');
this.dialogService.confirm(
helptext.offline_disk.title,
helptext.offline_disk.message + name + '?' + (this.pool.encrypt == 0 ? '' : helptext.offline_disk.encryptPoolWarning),
Expand Down Expand Up @@ -279,8 +273,7 @@ export class VolumeStatusComponent implements OnInit {
id: 'online',
label: helptext.actions_label.online,
onClick: (row) => {
const pIndex = row.name.lastIndexOf('p');
const diskName = pIndex > -1 ? row.name.substring(0, pIndex) : row.name;
const diskName = this.trimDiskName(row.name, 'p');

this.dialogService.confirm(
helptext.online_disk.title,
Expand Down Expand Up @@ -309,11 +302,7 @@ export class VolumeStatusComponent implements OnInit {
id: 'replace',
label: helptext.actions_label.replace,
onClick: (row) => {
let name = row.name;
if (!_.startsWith(name, '/')) {
const pIndex = name.lastIndexOf('p');
name = pIndex > -1 ? name.substring(0, pIndex) : name;
}
const name = this.trimDiskName(row.name, 'p');
const pk = this.pk;
_.find(this.replaceDiskFormFields, { name: 'label' }).value = row.guid;

Expand Down Expand Up @@ -358,11 +347,7 @@ export class VolumeStatusComponent implements OnInit {
id: 'remove',
label: helptext.actions_label.remove,
onClick: (row) => {
let diskName = row.name;
if (!_.startsWith(row.name, '/')) {
const pIndex = row.name.lastIndexOf('p');
diskName = pIndex > -1 ? row.name.substring(0, pIndex) : row.name;
}
const diskName = this.trimDiskName(row.name, 'p');

this.dialogService.confirm(
helptext.remove_disk.title,
Expand Down Expand Up @@ -390,8 +375,7 @@ export class VolumeStatusComponent implements OnInit {
id: 'detach',
label: helptext.actions_label.detach,
onClick: (row) => {
const pIndex = row.name.lastIndexOf('p');
const diskName = pIndex > -1 ? row.name.substring(0, pIndex) : row.name;
const diskName = this.trimDiskName(row.name, 'p');

this.dialogService.confirm(
helptext.detach_disk.title,
Expand Down Expand Up @@ -484,11 +468,7 @@ export class VolumeStatusComponent implements OnInit {
id: 'Remove',
label: helptext.actions_label.remove,
onClick: (row) => {
let diskName = row.name;
if (!_.startsWith(row.name, '/')) {
const pIndex = row.name.lastIndexOf('p');
diskName = pIndex > -1 ? row.name.substring(0, pIndex) : row.name;
}
const diskName = this.trimDiskName(row.name, 'p');

this.dialogService.confirm(
helptext.remove_disk.title,
Expand Down Expand Up @@ -608,4 +588,12 @@ export class VolumeStatusComponent implements OnInit {
return this.localeService.formatDateTime(new Date(data.$date));
}
}

private getLeaf(url: string): string {
return url.split('/').pop();
}

private trimDiskName(diskName: string, trimSubstring: string): string {
return _.startsWith(diskName, '/') ? diskName : diskName.split(trimSubstring)[0];
}
}
21 changes: 21 additions & 0 deletions src/app/pages/system/advanced/advanced.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,21 @@ export class AdvancedComponent implements OnDestroy {
},
],
},
{
type: 'select',
name: 'syslog_tls_certificate_authority',
placeholder: helptext_system_advanced.syslog_tls_certificate_authority.placeholder,
options: [],
relation: [
{
action: 'SHOW',
when: [{
name: 'syslog_transport',
value: 'TLS',
}],
},
],
},
],
},
{ name: 'divider', divider: true },
Expand Down Expand Up @@ -413,6 +428,12 @@ export class AdvancedComponent implements OnDestroy {
syslog_tls_certificate_field.options.push({ label: cert.name, value: cert.id });
}
});
const syslog_tls_certificate_authority_field = this.fieldSets.config('syslog_tls_certificate_authority');
this.ws.call('certificateauthority.query').subscribe((certs) => {
for (const cert of certs) {
syslog_tls_certificate_authority_field.options.push({ label: cert.name, value: cert.id });
}
});
}
afterInit(entityEdit: any) {
this.ws.call('failover.licensed').subscribe((is_ha) => {
Expand Down

0 comments on commit 85dc49d

Please sign in to comment.