UI: Change queueId to queueName
This commit is contained in:
parent
113bfa9d05
commit
ff9e6505b3
@ -35,6 +35,10 @@ export class QueueService {
|
||||
return this.http.get<QueueInfo>(`/api/queues/${queueId}`, defaultHttpOptionsFromConfig(config));
|
||||
}
|
||||
|
||||
public getQueueByName(queueName: string, config?: RequestConfig): Observable<QueueInfo> {
|
||||
return this.http.get<QueueInfo>(`/api/queues/name/${queueName}`, defaultHttpOptionsFromConfig(config));
|
||||
}
|
||||
|
||||
public getTenantQueuesByServiceType(pageLink: PageLink,
|
||||
serviceType: ServiceType,
|
||||
config?: RequestConfig): Observable<PageData<QueueInfo>> {
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
</tb-dashboard-autocomplete>
|
||||
<tb-queue-autocomplete
|
||||
[queueType]="serviceType"
|
||||
formControlName="defaultQueueId">
|
||||
formControlName="defaultQueueName">
|
||||
</tb-queue-autocomplete>
|
||||
<mat-form-field fxHide class="mat-block">
|
||||
<mat-label translate>device-profile.type</mat-label>
|
||||
|
||||
@ -50,7 +50,6 @@ import { StepperSelectionEvent } from '@angular/cdk/stepper';
|
||||
import { deepTrim } from '@core/utils';
|
||||
import { ServiceType } from '@shared/models/queue.models';
|
||||
import { DashboardId } from '@shared/models/id/dashboard-id';
|
||||
import { QueueId } from '@shared/models/id/queue-id';
|
||||
|
||||
export interface AddDeviceProfileDialogData {
|
||||
deviceProfileName: string;
|
||||
@ -111,7 +110,7 @@ export class AddDeviceProfileDialogComponent extends
|
||||
image: [null, []],
|
||||
defaultRuleChainId: [null, []],
|
||||
defaultDashboardId: [null, []],
|
||||
defaultQueueId: [null, []],
|
||||
defaultQueueName: [null, []],
|
||||
description: ['', []]
|
||||
}
|
||||
);
|
||||
@ -188,6 +187,7 @@ export class AddDeviceProfileDialogComponent extends
|
||||
name: this.deviceProfileDetailsFormGroup.get('name').value,
|
||||
type: this.deviceProfileDetailsFormGroup.get('type').value,
|
||||
image: this.deviceProfileDetailsFormGroup.get('image').value,
|
||||
defaultQueueName: this.deviceProfileDetailsFormGroup.get('defaultQueueName').value,
|
||||
transportType: this.transportConfigFormGroup.get('transportType').value,
|
||||
provisionType: deviceProvisionConfiguration.type,
|
||||
provisionDeviceKey,
|
||||
@ -205,9 +205,6 @@ export class AddDeviceProfileDialogComponent extends
|
||||
if (this.deviceProfileDetailsFormGroup.get('defaultDashboardId').value) {
|
||||
deviceProfile.defaultDashboardId = new DashboardId(this.deviceProfileDetailsFormGroup.get('defaultDashboardId').value);
|
||||
}
|
||||
if (this.deviceProfileDetailsFormGroup.get('defaultQueueId').value) {
|
||||
deviceProfile.defaultQueueId = new QueueId(this.deviceProfileDetailsFormGroup.get('defaultQueueId').value);
|
||||
}
|
||||
this.deviceProfileService.saveDeviceProfile(deepTrim(deviceProfile)).subscribe(
|
||||
(savedDeviceProfile) => {
|
||||
this.dialogRef.close(savedDeviceProfile);
|
||||
|
||||
@ -75,7 +75,7 @@
|
||||
</tb-dashboard-autocomplete>
|
||||
<tb-queue-autocomplete
|
||||
[queueType]="serviceType"
|
||||
formControlName="defaultQueueId">
|
||||
formControlName="defaultQueueName">
|
||||
</tb-queue-autocomplete>
|
||||
<tb-ota-package-autocomplete
|
||||
[useFullEntityId]="true"
|
||||
|
||||
@ -42,7 +42,6 @@ import { ServiceType } from '@shared/models/queue.models';
|
||||
import { EntityId } from '@shared/models/id/entity-id';
|
||||
import { OtaUpdateType } from '@shared/models/ota-package.models';
|
||||
import { DashboardId } from '@shared/models/id/dashboard-id';
|
||||
import { QueueId } from '@shared/models/id/queue-id';
|
||||
|
||||
@Component({
|
||||
selector: 'tb-device-profile',
|
||||
@ -118,7 +117,7 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
|
||||
}),
|
||||
defaultRuleChainId: [entity && entity.defaultRuleChainId ? entity.defaultRuleChainId.id : null, []],
|
||||
defaultDashboardId: [entity && entity.defaultDashboardId ? entity.defaultDashboardId.id : null, []],
|
||||
defaultQueueId: [entity && entity.defaultQueueId ? entity.defaultQueueId.id : null, []],
|
||||
defaultQueueName: [entity ? entity.defaultQueueName : null, []],
|
||||
firmwareId: [entity ? entity.firmwareId : null],
|
||||
softwareId: [entity ? entity.softwareId : null],
|
||||
description: [entity ? entity.description : '', []],
|
||||
@ -198,7 +197,7 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
|
||||
}}, {emitEvent: false});
|
||||
this.entityForm.patchValue({defaultRuleChainId: entity.defaultRuleChainId ? entity.defaultRuleChainId.id : null}, {emitEvent: false});
|
||||
this.entityForm.patchValue({defaultDashboardId: entity.defaultDashboardId ? entity.defaultDashboardId.id : null}, {emitEvent: false});
|
||||
this.entityForm.patchValue({defaultQueueId: entity.defaultQueueId ? entity.defaultQueueId.id : null}, {emitEvent: false});
|
||||
this.entityForm.patchValue({defaultQueueName: entity.defaultQueueName}, {emitEvent: false});
|
||||
this.entityForm.patchValue({firmwareId: entity.firmwareId}, {emitEvent: false});
|
||||
this.entityForm.patchValue({softwareId: entity.softwareId}, {emitEvent: false});
|
||||
this.entityForm.patchValue({description: entity.description}, {emitEvent: false});
|
||||
@ -211,9 +210,6 @@ export class DeviceProfileComponent extends EntityComponent<DeviceProfile> {
|
||||
if (formValue.defaultDashboardId) {
|
||||
formValue.defaultDashboardId = new DashboardId(formValue.defaultDashboardId);
|
||||
}
|
||||
if (formValue.defaultQueueId) {
|
||||
formValue.defaultQueueId = new QueueId(formValue.defaultQueueId);
|
||||
}
|
||||
const deviceProvisionConfiguration: DeviceProvisionConfiguration = formValue.profileData.provisionConfiguration;
|
||||
formValue.provisionType = deviceProvisionConfiguration.type;
|
||||
formValue.provisionDeviceKey = deviceProvisionConfiguration.provisionDeviceKey;
|
||||
|
||||
@ -95,7 +95,7 @@
|
||||
<tb-queue-autocomplete
|
||||
[ngClass]="{invisible: deviceWizardFormGroup.get('addProfileType').value !== 1}"
|
||||
[queueType]="serviceType"
|
||||
formControlName="defaultQueueId">
|
||||
formControlName="defaultQueueName">
|
||||
</tb-queue-autocomplete>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -49,7 +49,6 @@ import { MediaBreakpoints } from '@shared/models/constants';
|
||||
import { RuleChainId } from '@shared/models/id/rule-chain-id';
|
||||
import { ServiceType } from '@shared/models/queue.models';
|
||||
import { deepTrim } from '@core/utils';
|
||||
import { QueueId } from '@shared/models/id/queue-id';
|
||||
|
||||
@Component({
|
||||
selector: 'tb-device-wizard',
|
||||
@ -114,7 +113,7 @@ export class DeviceWizardDialogComponent extends
|
||||
deviceProfileId: [null, Validators.required],
|
||||
newDeviceProfileTitle: [{value: null, disabled: true}],
|
||||
defaultRuleChainId: [{value: null, disabled: true}],
|
||||
defaultQueueId: [{value: null, disabled: true}],
|
||||
defaultQueueName: [{value: null, disabled: true}],
|
||||
description: ['']
|
||||
}
|
||||
);
|
||||
@ -127,7 +126,7 @@ export class DeviceWizardDialogComponent extends
|
||||
this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators(null);
|
||||
this.deviceWizardFormGroup.get('newDeviceProfileTitle').disable();
|
||||
this.deviceWizardFormGroup.get('defaultRuleChainId').disable();
|
||||
this.deviceWizardFormGroup.get('defaultQueueId').disable();
|
||||
this.deviceWizardFormGroup.get('defaultQueueName').disable();
|
||||
this.deviceWizardFormGroup.updateValueAndValidity();
|
||||
this.createProfile = false;
|
||||
} else {
|
||||
@ -136,7 +135,7 @@ export class DeviceWizardDialogComponent extends
|
||||
this.deviceWizardFormGroup.get('newDeviceProfileTitle').setValidators([Validators.required]);
|
||||
this.deviceWizardFormGroup.get('newDeviceProfileTitle').enable();
|
||||
this.deviceWizardFormGroup.get('defaultRuleChainId').enable();
|
||||
this.deviceWizardFormGroup.get('defaultQueueId').enable();
|
||||
this.deviceWizardFormGroup.get('defaultQueueName').enable();
|
||||
|
||||
this.deviceWizardFormGroup.updateValueAndValidity();
|
||||
this.createProfile = true;
|
||||
@ -298,6 +297,7 @@ export class DeviceWizardDialogComponent extends
|
||||
const deviceProfile: DeviceProfile = {
|
||||
name: this.deviceWizardFormGroup.get('newDeviceProfileTitle').value,
|
||||
type: DeviceProfileType.DEFAULT,
|
||||
defaultQueueName: this.deviceWizardFormGroup.get('defaultQueueName').value,
|
||||
transportType: this.transportConfigFormGroup.get('transportType').value,
|
||||
provisionType: deviceProvisionConfiguration.type,
|
||||
provisionDeviceKey,
|
||||
@ -311,9 +311,6 @@ export class DeviceWizardDialogComponent extends
|
||||
if (this.deviceWizardFormGroup.get('defaultRuleChainId').value) {
|
||||
deviceProfile.defaultRuleChainId = new RuleChainId(this.deviceWizardFormGroup.get('defaultRuleChainId').value);
|
||||
}
|
||||
if (this.deviceWizardFormGroup.get('defaultQueueId').value) {
|
||||
deviceProfile.defaultQueueId = new QueueId(this.deviceWizardFormGroup.get('defaultQueueId').value);
|
||||
}
|
||||
return this.deviceProfileService.saveDeviceProfile(deepTrim(deviceProfile)).pipe(
|
||||
tap((profile) => {
|
||||
this.currentDeviceProfileTransportType = profile.transportType;
|
||||
|
||||
@ -18,11 +18,11 @@
|
||||
<mat-form-field [formGroup]="selectQueueFormGroup" class="mat-block autocomplete-queue">
|
||||
<input matInput type="text" placeholder="{{ 'queue.queue-name' | translate }}"
|
||||
#queueInput
|
||||
formControlName="queueId"
|
||||
formControlName="queueName"
|
||||
(focusin)="onFocus()"
|
||||
[required]="required"
|
||||
[matAutocomplete]="queueAutocomplete">
|
||||
<button *ngIf="selectQueueFormGroup.get('queueId').value && !disabled"
|
||||
<button *ngIf="selectQueueFormGroup.get('queueName').value && !disabled"
|
||||
type="button"
|
||||
matSuffix mat-button mat-icon-button aria-label="Clear"
|
||||
(click)="clear()">
|
||||
@ -50,7 +50,7 @@
|
||||
</div>
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
<mat-error *ngIf="selectQueueFormGroup.get('queueId').hasError('required')">
|
||||
<mat-error *ngIf="selectQueueFormGroup.get('queueName').hasError('required')">
|
||||
{{ 'queue.queue-required' | translate }}
|
||||
</mat-error>
|
||||
</mat-form-field>
|
||||
|
||||
@ -23,7 +23,6 @@ import { AppState } from '@core/core.state';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
||||
import { EntityId } from '@shared/models/id/entity-id';
|
||||
import { EntityType } from '@shared/models/entity-type.models';
|
||||
import { BaseData } from '@shared/models/base-data';
|
||||
import { EntityService } from '@core/http/entity.service';
|
||||
import { TruncatePipe } from '@shared/pipe/truncate.pipe';
|
||||
@ -87,7 +86,7 @@ export class QueueAutocompleteComponent implements ControlValueAccessor, OnInit
|
||||
private queueService: QueueService,
|
||||
private fb: FormBuilder) {
|
||||
this.selectQueueFormGroup = this.fb.group({
|
||||
queueId: [null]
|
||||
queueName: [null]
|
||||
});
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ export class QueueAutocompleteComponent implements ControlValueAccessor, OnInit
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.filteredQueues = this.selectQueueFormGroup.get('queueId').valueChanges
|
||||
this.filteredQueues = this.selectQueueFormGroup.get('queueName').valueChanges
|
||||
.pipe(
|
||||
debounceTime(150),
|
||||
tap(value => {
|
||||
@ -123,15 +122,6 @@ export class QueueAutocompleteComponent implements ControlValueAccessor, OnInit
|
||||
|
||||
ngAfterViewInit(): void {}
|
||||
|
||||
getCurrentEntity(): BaseData<EntityId> | null {
|
||||
const currentRuleChain = this.selectQueueFormGroup.get('queueId').value;
|
||||
if (currentRuleChain && typeof currentRuleChain !== 'string') {
|
||||
return currentRuleChain as BaseData<EntityId>;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
setDisabledState(isDisabled: boolean): void {
|
||||
this.disabled = isDisabled;
|
||||
if (this.disabled) {
|
||||
@ -148,15 +138,14 @@ export class QueueAutocompleteComponent implements ControlValueAccessor, OnInit
|
||||
writeValue(value: string | null): void {
|
||||
this.searchText = '';
|
||||
if (value != null) {
|
||||
const targetEntityType = EntityType.QUEUE;
|
||||
this.entityService.getEntity(targetEntityType, value, {ignoreLoading: true, ignoreErrors: true}).subscribe(
|
||||
this.queueService.getQueueByName(value, {ignoreLoading: true, ignoreErrors: true}).subscribe(
|
||||
(entity) => {
|
||||
this.modelValue = entity.id.id;
|
||||
this.selectQueueFormGroup.get('queueId').patchValue(entity, {emitEvent: false});
|
||||
this.modelValue = entity.name;
|
||||
this.selectQueueFormGroup.get('queueName').patchValue(entity, {emitEvent: false});
|
||||
},
|
||||
() => {
|
||||
this.modelValue = null;
|
||||
this.selectQueueFormGroup.get('queueId').patchValue('', {emitEvent: false});
|
||||
this.selectQueueFormGroup.get('queueName').patchValue('', {emitEvent: false});
|
||||
if (value !== null) {
|
||||
this.propagateChange(this.modelValue);
|
||||
}
|
||||
@ -164,20 +153,20 @@ export class QueueAutocompleteComponent implements ControlValueAccessor, OnInit
|
||||
);
|
||||
} else {
|
||||
this.modelValue = null;
|
||||
this.selectQueueFormGroup.get('queueId').patchValue('', {emitEvent: false});
|
||||
this.selectQueueFormGroup.get('queueName').patchValue('', {emitEvent: false});
|
||||
}
|
||||
this.dirty = true;
|
||||
}
|
||||
|
||||
onFocus() {
|
||||
if (this.dirty) {
|
||||
this.selectQueueFormGroup.get('queueId').updateValueAndValidity({onlySelf: true, emitEvent: true});
|
||||
this.selectQueueFormGroup.get('queueName').updateValueAndValidity({onlySelf: true, emitEvent: true});
|
||||
this.dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.selectQueueFormGroup.get('queueId').patchValue('', {emitEvent: false});
|
||||
this.selectQueueFormGroup.get('queueName').patchValue('', {emitEvent: false});
|
||||
}
|
||||
|
||||
updateView(value: string | null) {
|
||||
@ -214,7 +203,7 @@ export class QueueAutocompleteComponent implements ControlValueAccessor, OnInit
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.selectQueueFormGroup.get('queueId').patchValue('', {emitEvent: true});
|
||||
this.selectQueueFormGroup.get('queueName').patchValue('', {emitEvent: true});
|
||||
setTimeout(() => {
|
||||
this.queueInput.nativeElement.blur();
|
||||
this.queueInput.nativeElement.focus();
|
||||
|
||||
@ -29,7 +29,6 @@ import * as _moment from 'moment';
|
||||
import { AbstractControl, ValidationErrors } from '@angular/forms';
|
||||
import { OtaPackageId } from '@shared/models/id/ota-package-id';
|
||||
import { DashboardId } from '@shared/models/id/dashboard-id';
|
||||
import { QueueId } from '@shared/models/id/queue-id';
|
||||
import { DataType } from '@shared/models/constants';
|
||||
import {
|
||||
getDefaultProfileClientLwM2mSettingsConfig,
|
||||
@ -576,7 +575,7 @@ export interface DeviceProfile extends BaseData<DeviceProfileId>, ExportableEnti
|
||||
provisionDeviceKey?: string;
|
||||
defaultRuleChainId?: RuleChainId;
|
||||
defaultDashboardId?: DashboardId;
|
||||
defaultQueueId?: QueueId;
|
||||
defaultQueueName?: string;
|
||||
firmwareId?: OtaPackageId;
|
||||
softwareId?: OtaPackageId;
|
||||
profileData: DeviceProfileData;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user