New base code for mempool blockchain explorerer
This commit is contained in:
1
frontend/src/app/components/qrcode/qrcode.component.html
Normal file
1
frontend/src/app/components/qrcode/qrcode.component.html
Normal file
@@ -0,0 +1 @@
|
||||
<canvas #canvas></canvas>
|
||||
25
frontend/src/app/components/qrcode/qrcode.component.spec.ts
Normal file
25
frontend/src/app/components/qrcode/qrcode.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { QrcodeComponent } from './qrcode.component';
|
||||
|
||||
describe('QrcodeComponent', () => {
|
||||
let component: QrcodeComponent;
|
||||
let fixture: ComponentFixture<QrcodeComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ QrcodeComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(QrcodeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
43
frontend/src/app/components/qrcode/qrcode.component.ts
Normal file
43
frontend/src/app/components/qrcode/qrcode.component.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { Component, Input, AfterViewInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
|
||||
import * as QRCode from 'qrcode/build/qrcode.js';
|
||||
|
||||
@Component({
|
||||
selector: 'app-qrcode',
|
||||
templateUrl: './qrcode.component.html',
|
||||
styleUrls: ['./qrcode.component.scss']
|
||||
})
|
||||
export class QrcodeComponent implements AfterViewInit, OnDestroy {
|
||||
@Input() data: string;
|
||||
@ViewChild('canvas') canvas: ElementRef;
|
||||
|
||||
qrcodeObject: any;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngAfterViewInit() {
|
||||
const opts = {
|
||||
errorCorrectionLevel: 'H',
|
||||
margin: 0,
|
||||
color: {
|
||||
dark: '#000',
|
||||
light: '#fff'
|
||||
},
|
||||
width: 125,
|
||||
height: 125,
|
||||
};
|
||||
|
||||
if (!this.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
QRCode.toCanvas(this.canvas.nativeElement, this.data.toUpperCase(), opts, (error: any) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user