Skip to content

Commit

Permalink
Bugfix 3.5.x
Browse files Browse the repository at this point in the history
- Aggiornamento gestione logo ente creditore
  • Loading branch information
simo-git committed Oct 21, 2021
1 parent fe652e4 commit e3e707f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,35 +150,51 @@ export class DominioViewComponent implements IFormComponent, OnInit, AfterViewIn
}

protected _reloadFile(_url: string, bypass: boolean = false) {
let _result = _url;

if(!bypass && _url.indexOf('data:image/svg+xml;') != -1 && _url.indexOf('base64,') != -1) {
const _result: string = _url;
const svg: boolean = (_url.indexOf('data:image/svg+xml;') != -1 && _url.indexOf('base64,') != -1);
if (!bypass) {
let _hasColor: boolean = false;
let _bsvg = _url.split('base64,')[1];
let _xsvg = atob(_bsvg);
let re = RegExp('(#[a-z0-9]{6})','gmi');
let _tmp;
let _results = [];
while ((_tmp = re.exec(_xsvg)) !== null) {
const _atmp = this._getRGB(_tmp[0]);
if (_atmp[0] !== _atmp[1] && _atmp[0] !== _atmp[2] && _atmp[1] !== _atmp[2]) {
_hasColor = true;
let _map_results = [];
let _xsvg = '';
if (svg) {
let _bsvg = _url.split('base64,')[1];
_xsvg = atob(_bsvg);
let re = RegExp('(#[a-z0-9]{6})','gmi');
let _tmp;
while ((_tmp = re.exec(_xsvg)) !== null) {
const _atmp = this._getRGB(_tmp[0]);
if (_atmp[0] !== _atmp[1] && _atmp[0] !== _atmp[2] && _atmp[1] !== _atmp[2]) {
_hasColor = true;
}
_results.push(_tmp[0]);
}
_results.push(_tmp[0]);
_map_results = _results.map((_color) => {
return this.us.desaturateColor(_color);
}, this);
}
let _map_results = _results.map((_color) => {
return this.us.desaturateColor(_color);
}, this);
if(_hasColor && _results && _results.length != 0 && _map_results && _map_results.length != 0) {
this._askForConversion({ original: _result, xsvg: _xsvg, results: _results, map: _map_results });
} else {
this._base64File = this._sanitizer.bypassSecurityTrustUrl((_result.indexOf('base64,')!==-1?_result:UtilService.RootByTOA() + _result));
this._base64File = this._sanitizer.bypassSecurityTrustUrl(_result);
}
} else {
this._base64File = this._sanitizer.bypassSecurityTrustUrl((_result.indexOf('base64,')!==-1?_result:UtilService.RootByTOA() + _result));
this.__asyncLoadingLogo(_result);
}
}

protected __asyncLoadingLogo(uri: string) {
this.gps.multiExportService([uri], ['application/*'], ['text']).subscribe(
(responses: any) => {
const bin: string = responses[0].body;
this._base64File = this._sanitizer.bypassSecurityTrustUrl(bin);
},
(error: any) => {
this._base64File = '';
console.log('Logo Error', error);
});
}

protected _getRGB(hexVal) {
let commaSeperated = '';
hexVal = hexVal.substring(1, hexVal.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
</mat-card>
<mat-card class="shadow no-border-radius mb-4" *ngIf="!logoError && logo">
<img class="d-block card-logo-dominio link-key-value-fill-mat-card px-3 py-3" [src]="logo" (error)="_onError($event)"/>
<img class="card-logo-dominio" [src]="logo" (error)="_onError($event)"/>
</mat-card>
<link-filter-card (over-icon-click)="_iconCardClick(_UNITA, $event)" (add-icon-click)="_addEdit(_UNITA)" [card-title]="'Unità operative'"
[data-list]="unita_operative" [show-actions]="_PLUS_CREDIT" [show-over-icons]="_PLUS_CREDIT" [next-page]="_paginatorOptions.unita.next"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,11 @@ export class DominiViewComponent implements IModalDialog, OnInit, AfterViewInit
}

this.logoError = false;
this.logo = json.logo?this._sanitizer.bypassSecurityTrustUrl(UtilService.RootByTOA()+json.logo):this.NO_LOGO;
if (json.logo) {
this.__asyncLoadingLogo(json.logo);
} else {
this.logo = this.NO_LOGO;
}

this.informazioni = _dettaglio.info.slice(0);
this.informazioniPA = _dettaglio.infoPA.slice(0);
Expand Down Expand Up @@ -315,6 +319,18 @@ export class DominiViewComponent implements IModalDialog, OnInit, AfterViewInit
this._isIntermediato = json.intermediato;
}

protected __asyncLoadingLogo(uri: string) {
this.gps.multiExportService([uri], ['application/*'], ['text']).subscribe(
(responses: any) => {
const bin: string = responses[0].body || '';
this.logo = this._sanitizer.bypassSecurityTrustUrl(bin);
},
(error: any) => {
this.logoError = true;
console.log('Logo Error', error);
});
}

protected elencoUnitaOperative(jsonList: any[]) {
let p: Parameters;
let _duo = jsonList.map(function(item) {
Expand Down

0 comments on commit e3e707f

Please sign in to comment.