Merge pull request #12208 from ArtemDzhereleiko/AD/hot-fix/ota-autocomplete-device-profile

Fixed error toast when editing device details
This commit is contained in:
Igor Kulikov 2024-12-11 18:17:34 +02:00 committed by GitHub
commit f5ea88d708
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,7 +31,7 @@ import { OtaPackageService } from '@core/http/ota-package.service';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { Direction } from '@shared/models/page/sort-order'; import { Direction } from '@shared/models/page/sort-order';
import { emptyPageData } from '@shared/models/page/page-data'; import { emptyPageData } from '@shared/models/page/page-data';
import { getEntityDetailsPageURL } from '@core/utils'; import { getEntityDetailsPageURL, isDefinedAndNotNull } from '@core/utils';
import { AuthUser } from '@shared/models/user.model'; import { AuthUser } from '@shared/models/user.model';
import { getCurrentAuthUser } from '@core/auth/auth.selectors'; import { getCurrentAuthUser } from '@core/auth/auth.selectors';
import { Authority } from '@shared/models/authority.enum'; import { Authority } from '@shared/models/authority.enum';
@ -64,19 +64,19 @@ export class OtaPackageAutocompleteComponent implements ControlValueAccessor, On
this.reset(); this.reset();
} }
private deviceProfile: string; private deviceProfileIdValue: string;
get deviceProfileId(): string { get deviceProfileId(): string {
return this.deviceProfile; return this.deviceProfileIdValue;
} }
@Input() @Input()
set deviceProfileId(value: string) { set deviceProfileId(value: string) {
if (this.deviceProfile !== value) { if (this.deviceProfileIdValue !== value) {
if (this.deviceProfile) { if (this.deviceProfileIdValue) {
this.reset(); this.reset();
} }
this.deviceProfile = value; this.deviceProfileIdValue = value;
} }
} }
@ -257,16 +257,20 @@ export class OtaPackageAutocompleteComponent implements ControlValueAccessor, On
} }
fetchPackages(searchText?: string): Observable<Array<OtaPackageInfo>> { fetchPackages(searchText?: string): Observable<Array<OtaPackageInfo>> {
this.searchText = searchText; if (isDefinedAndNotNull(this.deviceProfileId)) {
const pageLink = new PageLink(50, 0, searchText, { this.searchText = searchText;
property: 'title', const pageLink = new PageLink(50, 0, searchText, {
direction: Direction.ASC property: 'title',
}); direction: Direction.ASC
return this.otaPackageService.getOtaPackagesInfoByDeviceProfileId(pageLink, this.deviceProfileId, this.type, });
{ignoreLoading: true}).pipe( return this.otaPackageService.getOtaPackagesInfoByDeviceProfileId(pageLink, this.deviceProfileId, this.type,
catchError(() => of(emptyPageData<OtaPackageInfo>())), {ignoreLoading: true}).pipe(
map((data) => data && data.data.length ? data.data : null) catchError(() => of(emptyPageData<OtaPackageInfo>())),
); map((data) => data && data.data.length ? data.data : null)
);
} else {
return of([]);
}
} }
clear() { clear() {