|
@@ -20,7 +20,8 @@ import { |
|
@@ -20,7 +20,8 @@ import { |
20
|
checkBoxCell,
|
20
|
checkBoxCell,
|
21
|
DateEntityTableColumn,
|
21
|
DateEntityTableColumn,
|
22
|
EntityTableColumn,
|
22
|
EntityTableColumn,
|
23
|
- EntityTableConfig
|
23
|
+ EntityTableConfig,
|
|
|
24
|
+ HeaderActionDescriptor
|
24
|
} from '@home/models/entity/entities-table-config.models';
|
25
|
} from '@home/models/entity/entities-table-config.models';
|
25
|
import { TranslateService } from '@ngx-translate/core';
|
26
|
import { TranslateService } from '@ngx-translate/core';
|
26
|
import { DatePipe } from '@angular/common';
|
27
|
import { DatePipe } from '@angular/common';
|
|
@@ -33,14 +34,15 @@ import { |
|
@@ -33,14 +34,15 @@ import { |
33
|
deviceTransportTypeTranslationMap
|
34
|
deviceTransportTypeTranslationMap
|
34
|
} from '@shared/models/device.models';
|
35
|
} from '@shared/models/device.models';
|
35
|
import { DeviceProfileService } from '@core/http/device-profile.service';
|
36
|
import { DeviceProfileService } from '@core/http/device-profile.service';
|
36
|
-import { DeviceProfileComponent } from '../../components/profile/device-profile.component';
|
37
|
+import { DeviceProfileComponent } from '@home/components/profile/device-profile.component';
|
37
|
import { DeviceProfileTabsComponent } from './device-profile-tabs.component';
|
38
|
import { DeviceProfileTabsComponent } from './device-profile-tabs.component';
|
38
|
import { Observable } from 'rxjs';
|
39
|
import { Observable } from 'rxjs';
|
39
|
import { MatDialog } from '@angular/material/dialog';
|
40
|
import { MatDialog } from '@angular/material/dialog';
|
40
|
import {
|
41
|
import {
|
41
|
AddDeviceProfileDialogComponent,
|
42
|
AddDeviceProfileDialogComponent,
|
42
|
AddDeviceProfileDialogData
|
43
|
AddDeviceProfileDialogData
|
43
|
-} from '../../components/profile/add-device-profile-dialog.component';
|
44
|
+} from '@home/components/profile/add-device-profile-dialog.component';
|
|
|
45
|
+import { ImportExportService } from '@home/components/import-export/import-export.service';
|
44
|
|
46
|
|
45
|
@Injectable()
|
47
|
@Injectable()
|
46
|
export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableConfig<DeviceProfile>> {
|
48
|
export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableConfig<DeviceProfile>> {
|
|
@@ -48,6 +50,7 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
|
@@ -48,6 +50,7 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
48
|
private readonly config: EntityTableConfig<DeviceProfile> = new EntityTableConfig<DeviceProfile>();
|
50
|
private readonly config: EntityTableConfig<DeviceProfile> = new EntityTableConfig<DeviceProfile>();
|
49
|
|
51
|
|
50
|
constructor(private deviceProfileService: DeviceProfileService,
|
52
|
constructor(private deviceProfileService: DeviceProfileService,
|
|
|
53
|
+ private importExport: ImportExportService,
|
51
|
private translate: TranslateService,
|
54
|
private translate: TranslateService,
|
52
|
private datePipe: DatePipe,
|
55
|
private datePipe: DatePipe,
|
53
|
private dialogService: DialogService,
|
56
|
private dialogService: DialogService,
|
|
@@ -81,6 +84,12 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
|
@@ -81,6 +84,12 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
81
|
|
84
|
|
82
|
this.config.cellActionDescriptors.push(
|
85
|
this.config.cellActionDescriptors.push(
|
83
|
{
|
86
|
{
|
|
|
87
|
+ name: this.translate.instant('device-profile.export'),
|
|
|
88
|
+ icon: 'file_download',
|
|
|
89
|
+ isEnabled: () => true,
|
|
|
90
|
+ onAction: ($event, entity) => this.exportDeviceProfile($event, entity)
|
|
|
91
|
+ },
|
|
|
92
|
+ {
|
84
|
name: this.translate.instant('device-profile.set-default'),
|
93
|
name: this.translate.instant('device-profile.set-default'),
|
85
|
icon: 'flag',
|
94
|
icon: 'flag',
|
86
|
isEnabled: (deviceProfile) => !deviceProfile.default,
|
95
|
isEnabled: (deviceProfile) => !deviceProfile.default,
|
|
@@ -101,7 +110,7 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
|
@@ -101,7 +110,7 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
101
|
this.config.onEntityAction = action => this.onDeviceProfileAction(action);
|
110
|
this.config.onEntityAction = action => this.onDeviceProfileAction(action);
|
102
|
this.config.deleteEnabled = (deviceProfile) => deviceProfile && !deviceProfile.default;
|
111
|
this.config.deleteEnabled = (deviceProfile) => deviceProfile && !deviceProfile.default;
|
103
|
this.config.entitySelectionEnabled = (deviceProfile) => deviceProfile && !deviceProfile.default;
|
112
|
this.config.entitySelectionEnabled = (deviceProfile) => deviceProfile && !deviceProfile.default;
|
104
|
- this.config.addEntity = () => this.addDeviceProfile();
|
113
|
+ this.config.addActionDescriptors = this.configureAddActions();
|
105
|
}
|
114
|
}
|
106
|
|
115
|
|
107
|
resolve(): EntityTableConfig<DeviceProfile> {
|
116
|
resolve(): EntityTableConfig<DeviceProfile> {
|
|
@@ -110,6 +119,25 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
|
@@ -110,6 +119,25 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
110
|
return this.config;
|
119
|
return this.config;
|
111
|
}
|
120
|
}
|
112
|
|
121
|
|
|
|
122
|
+ configureAddActions(): Array<HeaderActionDescriptor> {
|
|
|
123
|
+ const actions: Array<HeaderActionDescriptor> = [];
|
|
|
124
|
+ actions.push(
|
|
|
125
|
+ {
|
|
|
126
|
+ name: this.translate.instant('device-profile.create-device-profile'),
|
|
|
127
|
+ icon: 'insert_drive_file',
|
|
|
128
|
+ isEnabled: () => true,
|
|
|
129
|
+ onAction: () => this.addDeviceProfile()
|
|
|
130
|
+ },
|
|
|
131
|
+ {
|
|
|
132
|
+ name: this.translate.instant('device-profile.import'),
|
|
|
133
|
+ icon: 'file_upload',
|
|
|
134
|
+ isEnabled: () => true,
|
|
|
135
|
+ onAction: ($event) => this.importDeviceProfile($event)
|
|
|
136
|
+ }
|
|
|
137
|
+ );
|
|
|
138
|
+ return actions;
|
|
|
139
|
+ }
|
|
|
140
|
+
|
113
|
addDeviceProfile(): Observable<DeviceProfile> {
|
141
|
addDeviceProfile(): Observable<DeviceProfile> {
|
114
|
return this.dialog.open<AddDeviceProfileDialogComponent, AddDeviceProfileDialogData,
|
142
|
return this.dialog.open<AddDeviceProfileDialogComponent, AddDeviceProfileDialogData,
|
115
|
DeviceProfile>(AddDeviceProfileDialogComponent, {
|
143
|
DeviceProfile>(AddDeviceProfileDialogComponent, {
|
|
@@ -144,11 +172,31 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
|
@@ -144,11 +172,31 @@ export class DeviceProfilesTableConfigResolver implements Resolve<EntityTableCon |
144
|
);
|
172
|
);
|
145
|
}
|
173
|
}
|
146
|
|
174
|
|
|
|
175
|
+ importDeviceProfile($event: Event) {
|
|
|
176
|
+ this.importExport.importDeviceProfile().subscribe(
|
|
|
177
|
+ (deviceProfile) => {
|
|
|
178
|
+ if (deviceProfile) {
|
|
|
179
|
+ this.config.table.updateData();
|
|
|
180
|
+ }
|
|
|
181
|
+ }
|
|
|
182
|
+ );
|
|
|
183
|
+ }
|
|
|
184
|
+
|
|
|
185
|
+ exportDeviceProfile($event: Event, deviceProfile: DeviceProfile) {
|
|
|
186
|
+ if ($event) {
|
|
|
187
|
+ $event.stopPropagation();
|
|
|
188
|
+ }
|
|
|
189
|
+ this.importExport.exportDeviceProfile(deviceProfile.id.id);
|
|
|
190
|
+ }
|
|
|
191
|
+
|
147
|
onDeviceProfileAction(action: EntityAction<DeviceProfile>): boolean {
|
192
|
onDeviceProfileAction(action: EntityAction<DeviceProfile>): boolean {
|
148
|
switch (action.action) {
|
193
|
switch (action.action) {
|
149
|
case 'setDefault':
|
194
|
case 'setDefault':
|
150
|
this.setDefaultDeviceProfile(action.event, action.entity);
|
195
|
this.setDefaultDeviceProfile(action.event, action.entity);
|
151
|
return true;
|
196
|
return true;
|
|
|
197
|
+ case 'export':
|
|
|
198
|
+ this.exportDeviceProfile(action.event, action.entity);
|
|
|
199
|
+ return true;
|
152
|
}
|
200
|
}
|
153
|
return false;
|
201
|
return false;
|
154
|
}
|
202
|
}
|