Browse Source

UI: Improvement Add asset dialog

pull/8931/head
Artem Dzhereleiko 3 years ago
parent
commit
efaaf9e791
  1. 5
      ui-ngx/src/app/modules/home/components/profile/asset-profile-autocomplete.component.html
  2. 10
      ui-ngx/src/app/modules/home/components/profile/asset-profile-autocomplete.component.ts
  3. 2
      ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.html
  4. 4
      ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.ts
  5. 2
      ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.html
  6. 5
      ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.ts
  7. 21
      ui-ngx/src/app/modules/home/pages/asset/asset.component.html
  8. 2
      ui-ngx/src/app/modules/home/pages/asset/asset.component.ts
  9. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

5
ui-ngx/src/app/modules/home/components/profile/asset-profile-autocomplete.component.html

@ -43,6 +43,11 @@
(click)="editAssetProfile($event)">
<mat-icon class="material-icons">edit</mat-icon>
</button>
<button mat-button color="primary" matSuffix
(click)="createAssetProfile($event, '')"
*ngIf="!selectAssetProfileFormGroup.get('assetProfile').value && !disabled && addNewProfile">
<span style="white-space: nowrap">{{ 'notification.create-new' | translate }}</span>
</button>
<mat-autocomplete
class="tb-autocomplete"
(closed)="onPanelClosed()"

10
ui-ngx/src/app/modules/home/components/profile/asset-profile-autocomplete.component.ts

@ -46,6 +46,7 @@ import { AssetProfile, AssetProfileInfo } from '@shared/models/asset.models';
import { AssetProfileService } from '@core/http/asset-profile.service';
import { AssetProfileDialogComponent, AssetProfileDialogData } from './asset-profile-dialog.component';
import { SubscriptSizing } from '@angular/material/form-field';
import { coerceBoolean } from '@shared/decorators/coercion';
@Component({
selector: 'tb-asset-profile-autocomplete',
@ -84,14 +85,9 @@ export class AssetProfileAutocompleteComponent implements ControlValueAccessor,
@Input()
showDetailsPageLink = false;
private requiredValue: boolean;
get required(): boolean {
return this.requiredValue;
}
@Input()
set required(value: boolean) {
this.requiredValue = coerceBooleanProperty(value);
}
@coerceBoolean()
required = false;
@Input()
disabled: boolean;

2
ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.html

@ -45,7 +45,7 @@
</button>
<button mat-button color="primary" matSuffix
(click)="createDeviceProfile($event, '')"
*ngIf="!selectDeviceProfileFormGroup.get('deviceProfile').value && !disabled && addNewProfile && showCreateNewButton">
*ngIf="!selectDeviceProfileFormGroup.get('deviceProfile').value && !disabled && addNewProfile">
<span style="white-space: nowrap">{{ 'notification.create-new' | translate }}</span>
</button>
<mat-autocomplete

4
ui-ngx/src/app/modules/home/components/profile/device-profile-autocomplete.component.ts

@ -88,10 +88,6 @@ export class DeviceProfileAutocompleteComponent implements ControlValueAccessor,
@coerceBoolean()
addNewProfile = true;
@Input()
@coerceBoolean()
showCreateNewButton = false;
@Input()
showDetailsPageLink = false;

2
ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.html

@ -60,7 +60,6 @@
<tb-device-profile-autocomplete
required
addNewProfile
showCreateNewButton
selectDefaultProfile
formControlName="deviceProfileId"
(deviceProfileChanged)="deviceProfileChanged($event)">
@ -76,6 +75,7 @@
</div>
<tb-entity-autocomplete
formControlName="customerId"
useFullEntityId
labelText="device.wizard.customer-to-assign-device"
[entityType]="entityType.CUSTOMER">
</tb-entity-autocomplete>

5
ui-ngx/src/app/modules/home/components/wizard/device-wizard-dialog.component.ts

@ -147,11 +147,8 @@ export class DeviceWizardDialogComponent extends DialogComponent<DeviceWizardDia
overwriteActivityTime: this.deviceWizardFormGroup.get('overwriteActivityTime').value,
description: this.deviceWizardFormGroup.get('description').value
},
customerId: null
customerId: this.deviceWizardFormGroup.get('customerId').value
};
if (this.deviceWizardFormGroup.get('customerId').value) {
device.customerId = new CustomerId(this.deviceWizardFormGroup.get('customerId').value);
}
if (this.addDeviceWizardStepper.steps.last.completed || this.addDeviceWizardStepper.selectedIndex > 0) {
return this.deviceService.saveDeviceWithCredentials(deepTrim(device), deepTrim(this.credentialsFormGroup.value.credential)).pipe(
catchError((e: HttpErrorResponse) => {

21
ui-ngx/src/app/modules/home/pages/asset/asset.component.html

@ -86,13 +86,6 @@
{{ 'asset.name-max-length' | translate }}
</mat-error>
</mat-form-field>
<tb-asset-profile-autocomplete
[selectDefaultProfile]="isAdd"
required
formControlName="assetProfileId"
[showDetailsPageLink]="true"
(assetProfileUpdated)="onAssetProfileUpdated()">
</tb-asset-profile-autocomplete>
<mat-form-field class="mat-block">
<mat-label translate>asset.label</mat-label>
<input matInput formControlName="label">
@ -100,6 +93,20 @@
{{ 'asset.label-max-length' | translate }}
</mat-error>
</mat-form-field>
<tb-asset-profile-autocomplete
[selectDefaultProfile]="isAdd"
required
formControlName="assetProfileId"
[showDetailsPageLink]="true"
(assetProfileUpdated)="onAssetProfileUpdated()">
</tb-asset-profile-autocomplete>
<tb-entity-autocomplete
*ngIf="isAdd"
useFullEntityId
formControlName="customerId"
labelText="asset.customer-to-assign-asset"
[entityType]="entityType.CUSTOMER">
</tb-entity-autocomplete>
<div formGroupName="additionalInfo">
<mat-form-field class="mat-block">
<mat-label translate>asset.description</mat-label>

2
ui-ngx/src/app/modules/home/pages/asset/asset.component.ts

@ -69,6 +69,7 @@ export class AssetComponent extends EntityComponent<AssetInfo> {
name: [entity ? entity.name : '', [Validators.required, Validators.maxLength(255)]],
assetProfileId: [entity ? entity.assetProfileId : null, [Validators.required]],
label: [entity ? entity.label : '', Validators.maxLength(255)],
customerId: [entity ? entity.customerId : ''],
additionalInfo: this.fb.group(
{
description: [entity && entity.additionalInfo ? entity.additionalInfo.description : ''],
@ -82,6 +83,7 @@ export class AssetComponent extends EntityComponent<AssetInfo> {
this.entityForm.patchValue({name: entity.name});
this.entityForm.patchValue({assetProfileId: entity.assetProfileId});
this.entityForm.patchValue({label: entity.label});
this.entityForm.patchValue({customerId: entity.customerId});
this.entityForm.patchValue({additionalInfo: {description: entity.additionalInfo ? entity.additionalInfo.description : ''}});
}

3
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -685,7 +685,8 @@
"unassign-asset-from-edge-text": "After the confirmation the asset will be unassigned and won't be accessible by the edge.",
"unassign-assets-from-edge-title": "Are you sure you want to unassign { count, plural, =1 {1 asset} other {# assets} }?",
"unassign-assets-from-edge-text": "After the confirmation all selected assets will be unassigned and won't be accessible by the edge.",
"selected-assets": "{ count, plural, =1 {1 asset} other {# assets} } selected"
"selected-assets": "{ count, plural, =1 {1 asset} other {# assets} } selected",
"customer-to-assign-asset": "Customer to assign the asset"
},
"attribute": {
"attributes": "Attributes",

Loading…
Cancel
Save