strip html from colors from logs (#1604)

This commit is contained in:
Lucy C
2022-07-01 15:41:09 -06:00
committed by GitHub
parent f9b0f6ae35
commit cb9c01d94b
3 changed files with 10 additions and 5 deletions

View File

@@ -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!'

View File

@@ -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!'

View File

@@ -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 || ''
}