Browse Source

UI: Widgets bindles version control support

pull/6704/head
Igor Kulikov 4 years ago
parent
commit
9ff4a9e725
  1. 4
      ui-ngx/src/app/modules/home/pages/widget/widget-library.module.ts
  2. 23
      ui-ngx/src/app/modules/home/pages/widget/widgets-bundle-tabs.component.html
  3. 43
      ui-ngx/src/app/modules/home/pages/widget/widgets-bundle-tabs.component.ts
  4. 2
      ui-ngx/src/app/modules/home/pages/widget/widgets-bundles-table-config.resolver.ts
  5. 3
      ui-ngx/src/app/shared/models/entity-type.models.ts
  6. 3
      ui-ngx/src/app/shared/models/vc.models.ts
  7. 4
      ui-ngx/src/app/shared/models/widgets-bundle.model.ts
  8. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

4
ui-ngx/src/app/modules/home/pages/widget/widget-library.module.ts

@ -24,6 +24,7 @@ import { WidgetLibraryComponent } from './widget-library.component';
import { WidgetEditorComponent } from '@home/pages/widget/widget-editor.component';
import { SelectWidgetTypeDialogComponent } from '@home/pages/widget/select-widget-type-dialog.component';
import { SaveWidgetTypeAsDialogComponent } from './save-widget-type-as-dialog.component';
import { WidgetsBundleTabsComponent } from '@home/pages/widget/widgets-bundle-tabs.component';
@NgModule({
declarations: [
@ -31,7 +32,8 @@ import { SaveWidgetTypeAsDialogComponent } from './save-widget-type-as-dialog.co
WidgetLibraryComponent,
WidgetEditorComponent,
SelectWidgetTypeDialogComponent,
SaveWidgetTypeAsDialogComponent
SaveWidgetTypeAsDialogComponent,
WidgetsBundleTabsComponent
],
imports: [
CommonModule,

23
ui-ngx/src/app/modules/home/pages/widget/widgets-bundle-tabs.component.html

@ -0,0 +1,23 @@
<!--
Copyright © 2016-2022 The Thingsboard Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mat-tab *ngIf="isTenantWidgetsBundle() && authUser.authority === authorities.TENANT_ADMIN"
label="{{ 'version-control.version-control' | translate }}" #versionControlTab="matTab">
<tb-version-control detailsMode="true" singleEntityMode="true"
(versionRestored)="entitiesTableConfig.updateData()"
[active]="versionControlTab.isActive" [entityId]="entity.id" [entityName]="entity.title" [externalEntityId]="entity.externalId || entity.id"></tb-version-control>
</mat-tab>

43
ui-ngx/src/app/modules/home/pages/widget/widgets-bundle-tabs.component.ts

@ -0,0 +1,43 @@
///
/// Copyright © 2016-2022 The Thingsboard Authors
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
import { Component } from '@angular/core';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { EntityTabsComponent } from '../../components/entity/entity-tabs.component';
import { WidgetsBundle } from '@shared/models/widgets-bundle.model';
import { NULL_UUID } from '@shared/models/id/has-uuid';
@Component({
selector: 'tb-widgets-bundle-tabs',
templateUrl: './widgets-bundle-tabs.component.html',
styleUrls: []
})
export class WidgetsBundleTabsComponent extends EntityTabsComponent<WidgetsBundle> {
constructor(protected store: Store<AppState>) {
super(store);
}
isTenantWidgetsBundle() {
return this.entity && this.entity.tenantId.id !== NULL_UUID;
}
ngOnInit() {
super.ngOnInit();
}
}

2
ui-ngx/src/app/modules/home/pages/widget/widgets-bundles-table-config.resolver.ts

@ -39,6 +39,7 @@ import { DialogService } from '@core/services/dialog.service';
import { ImportExportService } from '@home/components/import-export/import-export.service';
import { Direction } from '@shared/models/page/sort-order';
import { map } from 'rxjs/operators';
import { WidgetsBundleTabsComponent } from '@home/pages/widget/widgets-bundle-tabs.component';
@Injectable()
export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableConfig<WidgetsBundle>> {
@ -55,6 +56,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
this.config.entityType = EntityType.WIDGETS_BUNDLE;
this.config.entityComponent = WidgetsBundleComponent;
this.config.entityTabsComponent = WidgetsBundleTabsComponent;
this.config.entityTranslations = entityTypeTranslations.get(EntityType.WIDGETS_BUNDLE);
this.config.entityResources = entityTypeResources.get(EntityType.WIDGETS_BUNDLE);
this.config.defaultSortOrder = {property: 'title', direction: Direction.ASC};

3
ui-ngx/src/app/shared/models/entity-type.models.ts

@ -251,6 +251,9 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti
[
EntityType.WIDGETS_BUNDLE,
{
type: 'entity.type-widgets-bundle',
typePlural: 'entity.type-widgets-bundles',
list: 'entity.list-of-widgets-bundles',
details: 'widgets-bundle.widgets-bundle-details',
add: 'widgets-bundle.add',
noEntities: 'widgets-bundle.no-widgets-bundles-text',

3
ui-ngx/src/app/shared/models/vc.models.ts

@ -27,7 +27,8 @@ export const exportableEntityTypes: Array<EntityType> = [
EntityType.DASHBOARD,
EntityType.CUSTOMER,
EntityType.DEVICE_PROFILE,
EntityType.RULE_CHAIN
EntityType.RULE_CHAIN,
EntityType.WIDGETS_BUNDLE
];
export interface VersionCreateConfig {

4
ui-ngx/src/app/shared/models/widgets-bundle.model.ts

@ -14,11 +14,11 @@
/// limitations under the License.
///
import { BaseData } from '@shared/models/base-data';
import { BaseData, ExportableEntity } from '@shared/models/base-data';
import { TenantId } from '@shared/models/id/tenant-id';
import { WidgetsBundleId } from '@shared/models/id/widgets-bundle-id';
export interface WidgetsBundle extends BaseData<WidgetsBundleId> {
export interface WidgetsBundle extends BaseData<WidgetsBundleId>, ExportableEntity<WidgetsBundleId> {
tenantId: TenantId;
alias: string;
title: string;

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

@ -1843,6 +1843,9 @@
"type-current-tenant": "Current Tenant",
"type-current-user": "Current User",
"type-current-user-owner": "Current User Owner",
"type-widgets-bundle": "Widgets bundle",
"type-widgets-bundles": "Widgets bundles",
"list-of-widgets-bundles": "{ count, plural, 1 {One widgets bundle} other {List of # widget bundles} }",
"search": "Search entities",
"selected-entities": "{ count, plural, 1 {1 entity} other {# entities} } selected",
"entity-name": "Entity name",

Loading…
Cancel
Save