migrate alert-box in lib, up route airwatch demo layout

This commit is contained in:
Tykayn 2025-08-11 11:56:52 +02:00 committed by tykayn
parent fe63fec58f
commit d0b5ad10f6
15 changed files with 174 additions and 9 deletions

View file

@ -0,0 +1,7 @@
<button class="button copy" (click)="copy()">
<i class="ri-file-copy-2-fill"></i>
<span class="label">
Copy
</span>
</button>

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Copy } from './copy';
describe('Copy', () => {
let component: Copy;
let fixture: ComponentFixture<Copy>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [Copy]
})
.compileComponents();
fixture = TestBed.createComponent(Copy);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,54 @@
import {Component, Input} from '@angular/core';
@Component({
selector: 'app-copy',
imports: [],
templateUrl: './copy.html',
styleUrl: './copy.scss'
})
export class Copy {
@Input() textToCopy = "";
copy() {
this.copyTextToClipboard(this.textToCopy)
}
fallbackCopyTextToClipboard(text: any) {
var textArea = document.createElement("textarea");
textArea.value = text;
// Avoid scrolling to bottom
textArea.style.top = "0";
textArea.style.left = "0";
textArea.style.position = "fixed";
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
console.log('Fallback: Copying text command was ' + msg);
} catch (err) {
console.error('Fallback: Oops, unable to copy', err);
}
document.body.removeChild(textArea);
}
copyTextToClipboard(text: string) {
console.log("copier", text)
if (!navigator.clipboard) {
this.fallbackCopyTextToClipboard(text);
return;
}
navigator.clipboard.writeText(text).then(function () {
console.log('Async: Copying to clipboard was successful!');
}, function (err) {
console.error('Async: Could not copy text: ', err);
});
}
}

View file

@ -38,7 +38,6 @@
justify-content: center;
align-items: center;
z-index: 1000;
}
.feedback-modal {