feature: New diagnostics page, showing SSH keys found. (#344)
This commit is contained in:
parent
a1adc2a85d
commit
fb6aaa52c7
|
|
@ -29,6 +29,8 @@ type webUISettings struct {
|
||||||
PageTitle string
|
PageTitle string
|
||||||
SectionNavigationStyle string
|
SectionNavigationStyle string
|
||||||
DefaultIconForBack string
|
DefaultIconForBack string
|
||||||
|
SshFoundKey string
|
||||||
|
SshFoundConfig string
|
||||||
}
|
}
|
||||||
|
|
||||||
func findWebuiDir() string {
|
func findWebuiDir() string {
|
||||||
|
|
@ -111,8 +113,11 @@ func generateWebUISettings(w http.ResponseWriter, r *http.Request) {
|
||||||
PageTitle: cfg.PageTitle,
|
PageTitle: cfg.PageTitle,
|
||||||
SectionNavigationStyle: cfg.SectionNavigationStyle,
|
SectionNavigationStyle: cfg.SectionNavigationStyle,
|
||||||
DefaultIconForBack: cfg.DefaultIconForBack,
|
DefaultIconForBack: cfg.DefaultIconForBack,
|
||||||
|
SshFoundKey: installationinfo.Runtime.SshFoundKey,
|
||||||
|
SshFoundConfig: installationinfo.Runtime.SshFoundConfig,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
w.Header().Add("Content-Type", "application/json")
|
||||||
_, err := w.Write([]byte(jsonRet))
|
_, err := w.Write([]byte(jsonRet))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ type runtimeInfo struct {
|
||||||
LastBrowserUserAgent string
|
LastBrowserUserAgent string
|
||||||
User string
|
User string
|
||||||
Uid string
|
Uid string
|
||||||
FoundSshKey string
|
SshFoundKey string
|
||||||
|
SshFoundConfig string
|
||||||
AvailableVersion string
|
AvailableVersion string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -29,20 +30,26 @@ var Runtime = &runtimeInfo{
|
||||||
OSReleasePrettyName: getOsReleasePrettyName(),
|
OSReleasePrettyName: getOsReleasePrettyName(),
|
||||||
User: os.Getenv("USER"),
|
User: os.Getenv("USER"),
|
||||||
Uid: os.Getenv("UID"),
|
Uid: os.Getenv("UID"),
|
||||||
}
|
SshFoundKey: searchForSshKey(),
|
||||||
|
SshFoundConfig: searchForSshConfig(),
|
||||||
func refreshRuntimeInfo() {
|
|
||||||
Runtime.FoundSshKey = searchForSshKey()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchForSshKey() string {
|
func searchForSshKey() string {
|
||||||
path, _ := filepath.Abs(path.Join(os.Getenv("HOME"), ".ssh/id_rsa"))
|
return searchForHomeFile(".ssh/id_rsa")
|
||||||
|
}
|
||||||
|
|
||||||
|
func searchForSshConfig() string {
|
||||||
|
return searchForHomeFile(".ssh/config")
|
||||||
|
}
|
||||||
|
|
||||||
|
func searchForHomeFile(file string) string {
|
||||||
|
path, _ := filepath.Abs(path.Join(os.Getenv("HOME"), file))
|
||||||
|
|
||||||
if _, err := os.Stat(path); err == nil {
|
if _, err := os.Stat(path); err == nil {
|
||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
return "none-found at " + path
|
return "not found at " + path
|
||||||
}
|
}
|
||||||
|
|
||||||
func isInContainer() bool {
|
func isInContainer() bool {
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,6 @@ func configToSosreport(cfg *config.Config) *sosReportConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetSosReport() string {
|
func GetSosReport() string {
|
||||||
refreshRuntimeInfo()
|
|
||||||
|
|
||||||
ret := ""
|
ret := ""
|
||||||
|
|
||||||
ret += "### SOSREPORT START (copy all text to SOSREPORT END)\n"
|
ret += "### SOSREPORT START (copy all text to SOSREPORT END)\n"
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul id = "supplemental-links">
|
<ul id = "supplemental-links">
|
||||||
|
<li title = "Diagnostics">
|
||||||
|
<a id = "showDiagnostics" href = "#Diagnostics">Diagnostics</a>
|
||||||
|
</li>
|
||||||
<li title = "Logs">
|
<li title = "Logs">
|
||||||
<a id = "showLogs" href = "#Logs">Logs</a>
|
<a id = "showLogs" href = "#Logs">Logs</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
@ -60,6 +63,27 @@
|
||||||
</table>
|
</table>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section id = "contentDiagnostics" title = "Diagnostics" hidden>
|
||||||
|
<h2>Diagnostics</h2>
|
||||||
|
<div id = "diagnostics" class = "ta-left">
|
||||||
|
<p><strong>Note:</strong> Diagnostics are only generated on OliveTin startup - they are not updated in real-time or when you refresh this page. They are intended as a "quick reference" to help you.</p>
|
||||||
|
<p>If you are having problems with OliveTin and want to raise a support request, please don't take a screenshot or copy text from this page, but instead it is highly recommended to include a <a href = "https://docs.olivetin.app/sosreport.html">sosreport</a> which is more detailed, and makes it easier to help you.</p>
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<th colspan = "0">SSH</th>
|
||||||
|
<tr>
|
||||||
|
<td>Found Key</td>
|
||||||
|
<td id = "diagnostics-sshfoundkey">?</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Found Config</td>
|
||||||
|
<td id = "diagnostics-sshfoundconfig">?</td>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section id = "contentActions" title = "Actions" hidden >
|
<section id = "contentActions" title = "Actions" hidden >
|
||||||
<fieldset id = "root-group" title = "Actions">
|
<fieldset id = "root-group" title = "Actions">
|
||||||
<legend hidden>Actions</legend>
|
<legend hidden>Actions</legend>
|
||||||
|
|
|
||||||
|
|
@ -187,9 +187,18 @@ export function setupSectionNavigation (style) {
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('showActions').onclick = () => { showSection('Actions') }
|
document.getElementById('showActions').onclick = () => { showSection('Actions') }
|
||||||
|
document.getElementById('showDiagnostics').onclick = () => {
|
||||||
|
refreshDiagnostics()
|
||||||
|
showSection('Diagnostics')
|
||||||
|
}
|
||||||
document.getElementById('showLogs').onclick = () => { showSection('Logs') }
|
document.getElementById('showLogs').onclick = () => { showSection('Logs') }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshDiagnostics () {
|
||||||
|
document.getElementById('diagnostics-sshfoundkey').innerHTML = window.settings.SshFoundKey
|
||||||
|
document.getElementById('diagnostics-sshfoundconfig').innerHTML = window.settings.SshFoundConfig
|
||||||
|
}
|
||||||
|
|
||||||
function marshalDashboardStructureToHtml (json) {
|
function marshalDashboardStructureToHtml (json) {
|
||||||
const nav = document.getElementById('navigation-links')
|
const nav = document.getElementById('navigation-links')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -483,6 +483,10 @@ div.display {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ta-left {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
.xterm {
|
.xterm {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue