libey-ng-component-library 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -527,6 +527,23 @@
527
527
  }
528
528
  return '';
529
529
  };
530
+ SigWebTablet.SigWebGetVersion = function (prop) {
531
+ try {
532
+ var xhr = this.SigWebcreateXHR();
533
+ if (xhr) {
534
+ xhr.open('GET', this.baseUri + prop + '?noCache=' + this.generateUUID(), false);
535
+ xhr.send(null);
536
+ if (xhr.readyState == 4 && xhr.status == 200) {
537
+ return xhr.responseText;
538
+ }
539
+ }
540
+ }
541
+ catch (error) {
542
+ console.error('Error en SigWebGetVersion:', error);
543
+ return null;
544
+ }
545
+ return null;
546
+ };
530
547
  SigWebTablet.SigWebGetProperty = function (prop) {
531
548
  var xhr = this.SigWebcreateXHR();
532
549
  if (xhr) {
@@ -788,7 +805,9 @@
788
805
  SigWebTablet.GetVersionString = function () {
789
806
  var Prop = 'Version';
790
807
  Prop = Prop;
791
- var Str = this.SigWebGetProperty(Prop);
808
+ var Str = this.SigWebGetVersion(Prop);
809
+ if (Str == null)
810
+ return Str;
792
811
  var trimStr = Str.slice(1, Str.length - 2);
793
812
  return trimStr;
794
813
  };
@@ -1824,8 +1843,10 @@
1824
1843
  minWidth: 5,
1825
1844
  canvasWidth: this.widthView,
1826
1845
  canvasHeight: this.heightView,
1827
- backgroundColor: 'rgba(242,242,242,1)',
1828
1846
  };
1847
+ this.FileValidated = false;
1848
+ this.NotDriver = false;
1849
+ this.UploadFile = null;
1829
1850
  }
1830
1851
  LibeyNgSignatureComponent.prototype.ngAfterViewInit = function () {
1831
1852
  this.InitDevice();
@@ -1836,6 +1857,9 @@
1836
1857
  };
1837
1858
  LibeyNgSignatureComponent.prototype.ChangeDevice = function () {
1838
1859
  var _this = this;
1860
+ this.NotDriver = false;
1861
+ this.UploadFile = null;
1862
+ this.File = null;
1839
1863
  setTimeout(function () {
1840
1864
  _this.InitDevice();
1841
1865
  }, 200);
@@ -1854,64 +1878,129 @@
1854
1878
  SigWebTablet.SetTabletState(0, this.tmr, null);
1855
1879
  };
1856
1880
  LibeyNgSignatureComponent.prototype.onSign = function () {
1857
- console.log('onSign Clicked!');
1858
- SigWebTablet.SetDisplayXSize(this.widthRender);
1859
- SigWebTablet.SetDisplayYSize(this.heightRender);
1860
- SigWebTablet.SetTabletState(0, this.tmr, null);
1861
- SigWebTablet.SetJustifyMode(0);
1862
- SigWebTablet.ClearTablet();
1863
- if (this.tmr == null) {
1864
- this.tmr = SigWebTablet.SetTabletState(1, this.cnvContext, 50);
1881
+ this.NotDriver = false;
1882
+ this.UploadFile = null;
1883
+ var driver = SigWebTablet.GetVersionString();
1884
+ if (driver == null) {
1885
+ this.NotDriver = true;
1865
1886
  }
1866
1887
  else {
1888
+ this.NotDriver = false;
1889
+ console.log('onSign Clicked!');
1890
+ SigWebTablet.SetDisplayXSize(this.widthRender);
1891
+ SigWebTablet.SetDisplayYSize(this.heightRender);
1867
1892
  SigWebTablet.SetTabletState(0, this.tmr, null);
1868
- this.tmr = null;
1869
- this.tmr = SigWebTablet.SetTabletState(1, this.cnvContext, 50);
1893
+ SigWebTablet.SetJustifyMode(0);
1894
+ SigWebTablet.ClearTablet();
1895
+ if (this.tmr == null) {
1896
+ this.tmr = SigWebTablet.SetTabletState(1, this.cnvContext, 50);
1897
+ }
1898
+ else {
1899
+ SigWebTablet.SetTabletState(0, this.tmr, null);
1900
+ this.tmr = null;
1901
+ this.tmr = SigWebTablet.SetTabletState(1, this.cnvContext, 50);
1902
+ }
1870
1903
  }
1871
1904
  };
1872
1905
  LibeyNgSignatureComponent.prototype.onClear = function () {
1873
- if (this.DeviceType == 'pinpad') {
1874
- SigWebTablet.ClearTablet();
1875
- if (this.cnvContext) {
1876
- this.cnvContext.clearRect(0, 0, this.canvas.nativeElement.width, this.canvas.nativeElement.height);
1906
+ if (this.UploadFile == null) {
1907
+ if (this.DeviceType == 'pinpad') {
1908
+ SigWebTablet.ClearTablet();
1909
+ if (this.cnvContext) {
1910
+ this.cnvContext.clearRect(0, 0, this.canvas.nativeElement.width, this.canvas.nativeElement.height);
1911
+ }
1912
+ }
1913
+ if (this.DeviceType == 'mousepad') {
1914
+ this.signaturePad.clear();
1877
1915
  }
1878
1916
  }
1879
- if (this.DeviceType == 'mousepad') {
1880
- this.signaturePad.clear();
1917
+ else {
1918
+ this.File = null;
1919
+ this.UploadFile = null;
1920
+ this.ChangeDevice();
1881
1921
  }
1882
1922
  };
1883
1923
  LibeyNgSignatureComponent.prototype.onDone = function () {
1884
1924
  var _this = this;
1885
- if (this.DeviceType == 'pinpad') {
1886
- // if (Number(SigWebTablet.NumberOfTabletPoints()) === 0) {
1887
- // alert('Por favor firme antes de continuar');
1888
- // } else {
1889
- SigWebTablet.SetTabletState(0, this.tmr, null);
1890
- SigWebTablet.SetSigCompressionMode(1);
1891
- var result = new OutputMessage();
1892
- result.bioSigData = SigWebTablet.GetSigString();
1893
- result.sigImgData = SigWebTablet.GetSigString();
1894
- SigWebTablet.SetImageXSize(this.widthRender);
1895
- SigWebTablet.SetImageYSize(this.heightRender);
1896
- SigWebTablet.SetImagePenWidth(5);
1897
- SigWebTablet.GetSigImageB64(function (base64) {
1898
- result.sigString = "data:image/png;base64," + base64;
1899
- _this.OutputSignature.emit(result);
1900
- });
1901
- // }
1925
+ var result = new OutputMessage();
1926
+ if (this.UploadFile == null) {
1927
+ if (this.DeviceType == 'pinpad') {
1928
+ // if (Number(SigWebTablet.NumberOfTabletPoints()) === 0) {
1929
+ // alert('Por favor firme antes de continuar');
1930
+ // } else {
1931
+ SigWebTablet.SetTabletState(0, this.tmr, null);
1932
+ SigWebTablet.SetSigCompressionMode(1);
1933
+ result.bioSigData = SigWebTablet.GetSigString();
1934
+ result.sigImgData = SigWebTablet.GetSigString();
1935
+ SigWebTablet.SetImageXSize(this.widthRender);
1936
+ SigWebTablet.SetImageYSize(this.heightRender);
1937
+ SigWebTablet.SetImagePenWidth(5);
1938
+ SigWebTablet.GetSigImageB64(function (base64) {
1939
+ result.sigString = "data:image/png;base64," + base64;
1940
+ _this.OutputSignature.emit(result);
1941
+ });
1942
+ // }
1943
+ }
1944
+ if (this.DeviceType == 'mousepad') {
1945
+ var result = new OutputMessage();
1946
+ result.sigString = this.signaturePad.toDataURL();
1947
+ this.OutputSignature.emit(result);
1948
+ }
1902
1949
  }
1903
- if (this.DeviceType == 'mousepad') {
1904
- var result = new OutputMessage();
1905
- result.sigString = this.signaturePad.toDataURL();
1950
+ else {
1951
+ result.sigString = this.UploadFile;
1906
1952
  this.OutputSignature.emit(result);
1907
1953
  }
1908
1954
  };
1909
- LibeyNgSignatureComponent.prototype.drawComplete = function () { };
1910
- LibeyNgSignatureComponent.prototype.drawStart = function () { };
1955
+ LibeyNgSignatureComponent.prototype.fileEvent = function (event) {
1956
+ var _this = this;
1957
+ this.UploadFile = null;
1958
+ this.FileValidated = false;
1959
+ var file = event.target.files[0];
1960
+ if (file.type == 'image/jpeg' || file.type == 'image/png') {
1961
+ this.FileValidated = false;
1962
+ var newWidth = this.widthRender;
1963
+ var newHeight = this.heightRender;
1964
+ this.resizeImage(file, newWidth, newHeight)
1965
+ .then(function (resizedImageDataUrl) {
1966
+ _this.UploadFile = resizedImageDataUrl;
1967
+ })
1968
+ .catch(function (error) {
1969
+ console.error('Error al redimensionar la imagen:', error);
1970
+ });
1971
+ }
1972
+ else {
1973
+ this.File = null;
1974
+ this.UploadFile = null;
1975
+ this.FileValidated = true;
1976
+ }
1977
+ };
1978
+ LibeyNgSignatureComponent.prototype.resizeImage = function (image, newWidth, newHeight) {
1979
+ return new Promise(function (resolve, reject) {
1980
+ var reader = new FileReader();
1981
+ reader.onload = function (e) {
1982
+ var img = new Image();
1983
+ img.src = e.target.result;
1984
+ img.onload = function () {
1985
+ var canvas = document.createElement('canvas');
1986
+ var ctx = canvas.getContext('2d');
1987
+ canvas.width = newWidth;
1988
+ canvas.height = newHeight;
1989
+ ctx.drawImage(img, 0, 0, newWidth, newHeight);
1990
+ var resizedImageDataUrl = canvas.toDataURL(image.type);
1991
+ resolve(resizedImageDataUrl);
1992
+ };
1993
+ img.onerror = function (error) {
1994
+ reject(error);
1995
+ };
1996
+ };
1997
+ reader.readAsDataURL(image);
1998
+ });
1999
+ };
1911
2000
  return LibeyNgSignatureComponent;
1912
2001
  }());
1913
2002
  LibeyNgSignatureComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LibeyNgSignatureComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
1914
- LibeyNgSignatureComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: LibeyNgSignatureComponent, selector: "lib-libey-ng-signature", inputs: { DeviceType: "DeviceType" }, outputs: { OutputSignature: "OutputSignature" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["sigImg"], descendants: true }, { propertyName: "signaturePad", first: true, predicate: i1.SignaturePad, descendants: true }], ngImport: i0__namespace, template: "<div class=\"container\">\n <div *ngIf=\"DeviceType=='pinpad'\">\n <canvas #sigImg [width]=\"widthView\" [height]=\"heightView\" style=\"background-color: rgba(242,242,242,1);\"></canvas> \n </div>\n <div *ngIf=\"DeviceType=='mousepad'\">\n <signature-pad [options]=\"signaturePadOptions\" (onBeginEvent)=\"drawStart()\" (onEndEvent)=\"drawComplete()\"></signature-pad>\n </div>\n <div class=\"row\">\n <button *ngIf=\"DeviceType=='pinpad'\" mat-raised-button (click)=\"onSign()\">Firmar</button>\n <button mat-raised-button (click)=\"onClear()\">Limpiar</button>\n <button mat-raised-button (click)=\"onDone()\">Guardar</button>\n </div>\n <div class=\"row\">\n <ng-select [(ngModel)]=\"DeviceType\" class=\"ng-select\" placeholder=\"Seleccionar\" [clearable]=\"false\"\n (change)=\"ChangeDevice()\">\n <ng-option [value]=\"'pinpad'\">Pinpad</ng-option>\n <ng-option [value]=\"'mousepad'\">Mousepad</ng-option>\n </ng-select>\n </div>\n</div>", styles: [".container{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center}.row{display:flex;justify-content:center;grid-gap:10px;gap:10px}\n"], components: [{ type: i1__namespace$1.SignaturePad, selector: "signature-pad", inputs: ["options"], outputs: ["onBeginEvent", "onEndEvent"] }, { type: i2__namespace.NgSelectComponent, selector: "ng-select", inputs: ["markFirst", "dropdownPosition", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "bufferAmount", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "bindLabel", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "virtualScroll", "openOnEnter", "appendTo", "bindValue", "appearance", "maxSelectedItems", "groupBy", "groupValue", "tabIndex", "typeahead"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }, { type: i2__namespace.ɵr, selector: "ng-option", inputs: ["disabled", "value"] }], directives: [{ type: i1__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4__namespace.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4__namespace.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
2003
+ LibeyNgSignatureComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: LibeyNgSignatureComponent, selector: "lib-libey-ng-signature", inputs: { DeviceType: "DeviceType" }, outputs: { OutputSignature: "OutputSignature" }, viewQueries: [{ propertyName: "canvas", first: true, predicate: ["sigImg"], descendants: true }, { propertyName: "signaturePad", first: true, predicate: i1.SignaturePad, descendants: true }], ngImport: i0__namespace, template: "<div class=\"container\">\n <div *ngIf=\"UploadFile==null\">\n <div *ngIf=\"DeviceType=='pinpad'\" style=\"cursor: pointer; border: 1px ridge #d2d2d2;\">\n <canvas (click)=\"onSign()\" #sigImg [width]=\"widthView\" [height]=\"heightView\"></canvas> \n </div>\n <div *ngIf=\"DeviceType=='mousepad'\" style=\"border: 1px ridge #d2d2d2;\">\n <signature-pad [options]=\"signaturePadOptions\"></signature-pad>\n </div>\n </div>\n <div *ngIf=\"UploadFile!=null\" style=\"border: 1px ridge #d2d2d2;\">\n <img [src]=\"UploadFile\" [width]=\"widthView\" [height]=\"heightView\" />\n </div>\n</div>\n<div class=\"row\">\n <div class=\"col-md-12\" style=\"padding-top: 17px !important; padding-bottom: 17px !important;\">\n <input type=\"file\" (change)=\"fileEvent($event)\" [(ngModel)]=\"File\" class=\"form-control form-control-ph\"\n accept=\"image/png, image/jpeg\" style=\"border: none;\">\n <label *ngIf=\"FileValidated\" [ngClass]=\"'text-danger'\">Archivo requerido. Formatos permitidos (jpeg, jpg, png)</label>\n </div>\n</div>\n<div class=\"row\">\n <div class=\"col-md-6\">\n <ng-select [(ngModel)]=\"DeviceType\" class=\"ng-select\" placeholder=\"Seleccionar\" [clearable]=\"false\"\n (change)=\"ChangeDevice()\">\n <ng-option [value]=\"'pinpad'\">Pinpad</ng-option>\n <ng-option [value]=\"'mousepad'\">Mousepad</ng-option>\n </ng-select>\n <label *ngIf=\"NotDriver\" [ngClass]=\"'text-danger'\">No tiene el driver instalado</label>\n </div>\n <div class=\"col-md-6\">\n <p class=\"text-primary font-link-rp\" style=\"text-align: right; cursor: pointer;\" (click)=\"onClear()\">\n Limpiar firma\n </p>\n </div>\n</div>\n\n<div class=\"modal-footer mt-15 mb-4\">\n <button type=\"button\" class=\"btn btn-primary btn-save-rp\" (click)=\"onDone()\"> \n <i class=\"icon-save-white\"></i> Guardar\n </button>\n</div>", styles: [".container{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center}\n"], components: [{ type: i1__namespace$1.SignaturePad, selector: "signature-pad", inputs: ["options"], outputs: ["onBeginEvent", "onEndEvent"] }, { type: i2__namespace.NgSelectComponent, selector: "ng-select", inputs: ["markFirst", "dropdownPosition", "loading", "closeOnSelect", "hideSelected", "selectOnTab", "bufferAmount", "selectableGroup", "selectableGroupAsModel", "searchFn", "trackByFn", "clearOnBackspace", "labelForId", "inputAttrs", "readonly", "searchWhileComposing", "minTermLength", "editableSearchTerm", "keyDownFn", "multiple", "addTag", "searchable", "clearable", "isOpen", "items", "compareWith", "clearSearchOnAdd", "bindLabel", "placeholder", "notFoundText", "typeToSearchText", "addTagText", "loadingText", "clearAllText", "virtualScroll", "openOnEnter", "appendTo", "bindValue", "appearance", "maxSelectedItems", "groupBy", "groupValue", "tabIndex", "typeahead"], outputs: ["blur", "focus", "change", "open", "close", "search", "clear", "add", "remove", "scroll", "scrollToEnd"] }, { type: i2__namespace.ɵr, selector: "ng-option", inputs: ["disabled", "value"] }], directives: [{ type: i1__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4__namespace.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4__namespace.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4__namespace.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i1__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
1915
2004
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: LibeyNgSignatureComponent, decorators: [{
1916
2005
  type: i0.Component,
1917
2006
  args: [{