/* * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { BaseElement, element } from '../../../base-ui/BaseElement.js'; import LitSwitch, { LitSwitchChangeEvent } from '../../../base-ui/switch/lit-switch.js'; import '../../../base-ui/select/LitAllocationSelect.js'; import '../../../base-ui/switch/lit-switch.js'; import { LitAllocationSelect } from '../../../base-ui/select/LitAllocationSelect.js'; import { SpRecordTrace } from '../SpRecordTrace.js'; import { Cmd } from '../../../command/Cmd.js'; import { CmdConstant } from '../../../command/CmdConstant.js'; import { HdcDeviceManager } from '../../../hdc/HdcDeviceManager.js'; @element('sp-hisys-event') export class SpHisysEvent extends BaseElement { private eventProcessInput: LitAllocationSelect | undefined | null; private selectProcess: HTMLInputElement | undefined | null; set startSamp(start: boolean) { if (start) { this.setAttribute('startSamp', ''); } else { this.removeAttribute('startSamp'); let eventInput = this.eventProcessInput?.shadowRoot?.querySelector('#singleInput'); eventInput!.value = ''; } } get process(): string { if (this.eventProcessInput!.value.length > 0) { return this.eventProcessInput!.value; } return ''; } get startSamp(): boolean { return this.hasAttribute('startSamp'); } initElements(): void { let hisysEventSwitch = this.shadowRoot?.querySelector('lit-switch') as LitSwitch; hisysEventSwitch.addEventListener('change', (event: CustomEventInit) => { let detail = event.detail; if (detail!.checked) { this.startSamp = true; this.unDisable(); } else { this.startSamp = false; this.disable(); } }); this.eventProcessInput = this.shadowRoot?.querySelector('lit-allocation-select'); let hisyEventProcessInput = this.eventProcessInput?.shadowRoot?.querySelector('.multipleSelect') as HTMLDivElement; this.selectProcess = this.eventProcessInput!.shadowRoot?.querySelector('input') as HTMLInputElement; hisyEventProcessInput!.addEventListener('mousedown', (ev) => { if (SpRecordTrace.serialNumber === '') { this.eventProcessInput!.processData = []; this.eventProcessInput!.initData(); } }); hisyEventProcessInput!.addEventListener('mouseup', () => { if (SpRecordTrace.serialNumber === '') { this.eventProcessInput!.processData = []; this.eventProcessInput!.initData(); } else { Cmd.getProcess().then((processList) => { this.eventProcessInput!.processData = processList; this.eventProcessInput!.initData(); }); } }); this.disable(); } private unDisable(): void { let hisysEventConfigVals = this.shadowRoot?.querySelectorAll('.config'); hisysEventConfigVals!.forEach((hisysEventConfigVal) => { hisysEventConfigVal.removeAttribute('disabled'); }); } private disable(): void { let hisysEventConfigVals = this.shadowRoot?.querySelectorAll('.config'); hisysEventConfigVals!.forEach((hisysEventConfigVal) => { if (hisysEventConfigVal.title !== 'Start Hisystem Event Tracker Record') { hisysEventConfigVal.setAttribute('disabled', ''); } }); } initHtml(): string { return `
Start Hisystem Event Tracker Record
AppName Record AppName
`; } }