Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NAS-127717 / 13.0 / Add syslog_tls_certificate_authority field #9836

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading