|
|
@ -31,11 +31,10 @@ 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'; |
|
|
import { NULL_UUID } from '@shared/models/id/has-uuid'; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'tb-ota-package-autocomplete', |
|
|
selector: 'tb-ota-package-autocomplete', |
|
|
@ -65,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 ?? NULL_UUID; |
|
|
this.deviceProfileIdValue = value; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -258,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() { |
|
|
|