mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
strip html from colors from logs (#1604)
This commit is contained in:
@@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router'
|
||||
import { getPkgId } from '@start9labs/shared'
|
||||
import { ToastController } from '@ionic/angular'
|
||||
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||
import { copyToClipboard } from 'src/app/util/web.util'
|
||||
import { copyToClipboard, strip } from 'src/app/util/web.util'
|
||||
|
||||
@Component({
|
||||
selector: 'app-logs',
|
||||
@@ -41,7 +41,7 @@ export class AppLogsPage {
|
||||
const logs = document
|
||||
.getElementById('template')
|
||||
?.cloneNode(true) as HTMLElement
|
||||
const formatted = '```' + logs.innerHTML + '```'
|
||||
const formatted = '```' + strip(logs.innerHTML) + '```'
|
||||
const success = await copyToClipboard(formatted)
|
||||
const message = success
|
||||
? 'Copied to clipboard!'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Component } from '@angular/core'
|
||||
import { ToastController } from '@ionic/angular'
|
||||
import { ApiService } from 'src/app/services/api/embassy-api.service'
|
||||
import { copyToClipboard } from 'src/app/util/web.util'
|
||||
import { copyToClipboard, strip } from 'src/app/util/web.util'
|
||||
|
||||
@Component({
|
||||
selector: 'server-logs',
|
||||
@@ -17,7 +17,7 @@ export class ServerLogsPage {
|
||||
constructor(
|
||||
private readonly embassyApi: ApiService,
|
||||
private readonly toastCtrl: ToastController,
|
||||
) { }
|
||||
) {}
|
||||
|
||||
fetchFetchLogs() {
|
||||
return async (params: {
|
||||
@@ -37,7 +37,7 @@ export class ServerLogsPage {
|
||||
const logs = document
|
||||
.getElementById('template')
|
||||
?.cloneNode(true) as HTMLElement
|
||||
const formatted = '```' + logs.innerHTML + '```'
|
||||
const formatted = '```' + strip(logs.innerHTML) + '```'
|
||||
const success = await copyToClipboard(formatted)
|
||||
const message = success
|
||||
? 'Copied to clipboard!'
|
||||
|
||||
@@ -21,3 +21,8 @@ export async function copyToClipboard(str: string): Promise<boolean> {
|
||||
return copy
|
||||
}
|
||||
}
|
||||
|
||||
export function strip(html: string) {
|
||||
let doc = new DOMParser().parseFromString(html, 'text/html')
|
||||
return doc.body.textContent || ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user