Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class SystemEventsComponent implements OnInit {
@ViewChild("eventsform") currentForm!: NgForm;
eventList!: SystemEventList;

hostName = '';
events: SystemEvent[] = [];

successCount = 0;
Expand All @@ -31,11 +32,18 @@ export class SystemEventsComponent implements OnInit {
kClearSettingValue = "<clear_setting_value>";

constructor(private configService: ConfigService, private translate: TranslateService,
public setupService: SetupService, private mythService: MythService, public router: Router) {
this.configService.GetSystemEvents().subscribe(data => {
this.eventList = data;
this.events = data.SystemEventList.SystemEvents;
});
public setupService: SetupService, private mythService: MythService, public router: Router) {
this.mythService.GetHostName().subscribe({
next: data => {
this.hostName = data.String;
this.configService.GetSystemEvents().subscribe(data => {
this.eventList = data;
this.events = data.SystemEventList.SystemEvents;
});
},
error: () => this.errorCount++
})

this.translate.get(this.warningText).subscribe(data => {
this.warningText = data
});
Expand Down Expand Up @@ -66,19 +74,19 @@ export class SystemEventsComponent implements OnInit {
this.successCount = 0;
this.errorCount = 0;
this.expectedCount = 0;
const hostName = this.setupService.getHostName();
// const hostName = this.setupService.getHostName();

this.events.forEach(entry => {
let value = entry.Value.trim();
if (value)
// value = this.kClearSettingValue;
this.mythService.PutSetting({
HostName: hostName, Key: entry.Key,
HostName: this.hostName, Key: entry.Key,
Value: value
}).subscribe(this.jqbObserver);
else
this.mythService.DeleteSetting({
HostName: hostName, Key: entry.Key
HostName: this.hostName, Key: entry.Key
}).subscribe(this.jqbObserver);
this.expectedCount++;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ <h2>{{ 'common.instructions' | translate }}</h2>
<p>
{{ 'setupwizard.sqlinstructions' | translate }}
</p>
<div class="flex pb-3">
<div class="flex-none flex align-items-center label block pr-5">
Sql Server Type:
</div>
<div class="flex-none flex align-items-center pr-5">
<p-radioButton name="dbtype" value="MySQL" [(ngModel)]="dbtype"
inputId="mysql" (ngModelChange)="setCommandList()"></p-radioButton>
<label for="mysql">MySql</label>
</div>
<div class="flex-none flex align-items-center">
<p-radioButton name="dbtype" value="MariaDB" [(ngModel)]="dbtype"
inputId="mariadb" (ngModelChange)="setCommandList()"></p-radioButton>
<label for="mariadb">MariaDB</label>
</div>
</div>

<table style="white-space: 'pre-line'">
<tr>
<td class="align-items-center bg-blue-100" style="font-family: monospace;">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class DbsetupComponent implements OnInit {
commandlist = '';
mySqlCommand = 'sudo mysql -u root < setup.sql'
tzCommand = 'mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql -u root mysql'
dbtype = "MySQL";

msg_testconnection = 'setupwizard.testConnection';
msg_connectionsuccess = 'setupwizard.connectionsuccess';
Expand Down Expand Up @@ -105,15 +106,23 @@ export class DbsetupComponent implements OnInit {
else {
this.messageService.add({ severity: 'error', life: 5000, summary: this.msg_testconnection, detail: this.msg_connectionfail });
this.connectionFail = true;
this.commandlist =
`CREATE DATABASE IF NOT EXISTS ${this.m_wizardData.Database.Name};\n` +
`ALTER DATABASE ${this.m_wizardData.Database.Name} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;\n` +
`CREATE USER IF NOT EXISTS '${this.m_wizardData.Database.UserName}'@'localhost' IDENTIFIED WITH mysql_native_password by '${this.m_wizardData.Database.Password}';\n` +
`GRANT ALL ON ${this.m_wizardData.Database.Name}.* TO '${this.m_wizardData.Database.UserName}'@'localhost';`
this.setCommandList();
}
});
}

setCommandList() {
let pwType = '';
if (this.dbtype == 'MySQL')
pwType = 'WITH mysql_native_password';
this.commandlist =
`CREATE DATABASE IF NOT EXISTS ${this.m_wizardData.Database.Name};\n` +
`CREATE USER IF NOT EXISTS '${this.m_wizardData.Database.UserName}'@'localhost' IDENTIFIED ${pwType} by '${this.m_wizardData.Database.Password}';\n` +
`CREATE USER IF NOT EXISTS '${this.m_wizardData.Database.UserName}'@'%' IDENTIFIED ${pwType} by '${this.m_wizardData.Database.Password}';\n` +
`GRANT ALL ON ${this.m_wizardData.Database.Name}.* TO '${this.m_wizardData.Database.UserName}'@'localhost';\n` +
`GRANT ALL ON ${this.m_wizardData.Database.Name}.* TO '${this.m_wizardData.Database.UserName}'@'%';`
}

confirm(message?: string): Observable<boolean> {
const confirmation = window.confirm(message);
return of(confirmation);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { StorageGroupDirList } from "./storagegroup.interface";

export interface MythHostName {
String: string; // That's what the service returns as the key
}
Expand Down
54 changes: 29 additions & 25 deletions mythtv/html/backend/src/app/services/setup.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,43 @@ export class SetupService {


constructor(private mythService: MythService, private translate: TranslateService) {
this.mythService.GetHostName().subscribe(data => {
this.m_hostName = data.String;
});
}

Init(): void {
this.m_initialized = true;
}

getHostName(): string {
return this.m_hostName;
}

m_HostAddressData!: HostAddress;
m_HostAddressData: HostAddress = {
successCount: 0,
errorCount: 0,
thisHostName: this.m_hostName,
BackendServerPort: 6543,
BackendStatusPort: 6544,
SecurityPin: '0000',
AllowConnFromAll: false,
ListenOnAllIps: true,
BackendServerIP: '127.0.0.1',
BackendServerIP6: '::1',
AllowLinkLocal: true,
BackendServerAddr: '',
IsMasterBackend: true,
MasterServerName: this.m_hostName,
};

getHostAddressData(): HostAddress {
this.m_HostAddressData = {
successCount: 0,
errorCount: 0,
thisHostName: this.m_hostName,
BackendServerPort: 6543,
BackendStatusPort: 6544,
SecurityPin: '0000',
AllowConnFromAll: false,
ListenOnAllIps: true,
BackendServerIP: '127.0.0.1',
BackendServerIP6: '::1',
AllowLinkLocal: true,
BackendServerAddr: '',
IsMasterBackend: true,
MasterServerName: this.m_hostName,
};
this.mythService.GetHostName().subscribe({
next: data => {
this.m_hostName = data.String;
this.m_HostAddressData.thisHostName = this.m_hostName;
this.m_HostAddressData.MasterServerName = this.m_hostName;
this.getHostSettings();
},
error: () => this.m_HostAddressData.errorCount++
})
return this.m_HostAddressData;
}

getHostSettings () {
this.mythService.GetSetting({ HostName: this.m_hostName, Key: "BackendServerPort", Default:"6543" })
.subscribe({
next: data => this.m_HostAddressData.BackendServerPort = Number(data.String),
Expand Down Expand Up @@ -106,7 +111,6 @@ export class SetupService {
error: () => this.m_HostAddressData.errorCount++
});

return this.m_HostAddressData;
}

HostAddressObs = {
Expand Down