Browse Source

UI: Added to JavaScript library details audit logs and version control

pull/12186/head
Vladyslav_Prykhodko 2 years ago
parent
commit
fde6756bca
  1. 4
      ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.html
  2. 9
      ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.ts
  3. 2
      ui-ngx/src/app/modules/home/pages/admin/admin.module.ts
  4. 2
      ui-ngx/src/app/modules/home/pages/admin/resource/js-library-table-config.resolver.ts
  5. 27
      ui-ngx/src/app/modules/home/pages/admin/resource/resource-tabs.component.html
  6. 36
      ui-ngx/src/app/modules/home/pages/admin/resource/resource-tabs.component.ts
  7. 12
      ui-ngx/src/app/shared/models/vc.models.ts

4
ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.html

@ -41,10 +41,10 @@
<mat-checkbox *ngIf="entityId.entityType === entityTypes.DEVICE" formControlName="saveCredentials" style="margin-bottom: 16px;">
{{ 'version-control.export-credentials' | translate }}
</mat-checkbox>
<mat-checkbox formControlName="saveAttributes" style="margin-bottom: 16px;">
<mat-checkbox *ngIf="!entityTypesWithoutRelatedData.has(entityId.entityType)" formControlName="saveAttributes" style="margin-bottom: 16px;">
{{ 'version-control.export-attributes' | translate }}
</mat-checkbox>
<mat-checkbox formControlName="saveRelations" style="margin-bottom: 16px;">
<mat-checkbox *ngIf="!entityTypesWithoutRelatedData.has(entityId.entityType)" formControlName="saveRelations" style="margin-bottom: 16px;">
{{ 'version-control.export-relations' | translate }}
</mat-checkbox>
</div>

9
ui-ngx/src/app/modules/home/components/vc/entity-version-create.component.ts

@ -18,6 +18,7 @@ import { ChangeDetectorRef, Component, Input, OnDestroy, OnInit } from '@angular
import { PageComponent } from '@shared/components/page.component';
import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms';
import {
entityTypesWithoutRelatedData,
SingleEntityVersionCreateRequest,
VersionCreateRequestType,
VersionCreationResult
@ -62,6 +63,8 @@ export class EntityVersionCreateComponent extends PageComponent implements OnIni
entityTypes = EntityType;
entityTypesWithoutRelatedData = entityTypesWithoutRelatedData;
resultMessage: string;
versionCreateResult$: Observable<VersionCreationResult>;
@ -108,8 +111,10 @@ export class EntityVersionCreateComponent extends PageComponent implements OnIni
branch: this.createVersionFormGroup.get('branch').value,
versionName: this.createVersionFormGroup.get('versionName').value,
config: {
saveRelations: this.createVersionFormGroup.get('saveRelations').value,
saveAttributes: this.createVersionFormGroup.get('saveAttributes').value,
saveRelations: !entityTypesWithoutRelatedData.has(this.entityId.entityType)
? this.createVersionFormGroup.get('saveRelations').value : false,
saveAttributes: !entityTypesWithoutRelatedData.has(this.entityId.entityType)
? this.createVersionFormGroup.get('saveAttributes').value : false,
saveCredentials: this.entityId.entityType === EntityType.DEVICE ? this.createVersionFormGroup.get('saveCredentials').value : false
},
type: VersionCreateRequestType.SINGLE_ENTITY

2
ui-ngx/src/app/modules/home/pages/admin/admin.module.ts

@ -27,6 +27,7 @@ import { SmsProviderComponent } from '@home/pages/admin/sms-provider.component';
import { SendTestSmsDialogComponent } from '@home/pages/admin/send-test-sms-dialog.component';
import { HomeSettingsComponent } from '@home/pages/admin/home-settings.component';
import { ResourcesLibraryComponent } from '@home/pages/admin/resource/resources-library.component';
import { ResourceTabsComponent } from '@home/pages/admin/resource/resource-tabs.component';
import { ResourcesTableHeaderComponent } from '@home/pages/admin/resource/resources-table-header.component';
import { QueueComponent } from '@home/pages/admin/queue/queue.component';
import { RepositoryAdminSettingsComponent } from '@home/pages/admin/repository-admin-settings.component';
@ -47,6 +48,7 @@ import { NgxFlowModule } from '@flowjs/ngx-flow';
SecuritySettingsComponent,
HomeSettingsComponent,
ResourcesLibraryComponent,
ResourceTabsComponent,
ResourcesTableHeaderComponent,
JsResourceComponent,
JsLibraryTableHeaderComponent,

2
ui-ngx/src/app/modules/home/pages/admin/resource/js-library-table-config.resolver.ts

@ -43,6 +43,7 @@ import { EntityAction } from '@home/models/entity/entity-component.models';
import { JsLibraryTableHeaderComponent } from '@home/pages/admin/resource/js-library-table-header.component';
import { JsResourceComponent } from '@home/pages/admin/resource/js-resource.component';
import { switchMap } from 'rxjs/operators';
import { ResourceTabsComponent } from '@home/pages/admin/resource/resource-tabs.component';
@Injectable()
export class JsLibraryTableConfigResolver {
@ -57,6 +58,7 @@ export class JsLibraryTableConfigResolver {
this.config.entityType = EntityType.TB_RESOURCE;
this.config.entityComponent = JsResourceComponent;
this.config.entityTabsComponent = ResourceTabsComponent;
this.config.entityTranslations = {
details: 'javascript.javascript-resource-details',
add: 'javascript.add',

27
ui-ngx/src/app/modules/home/pages/admin/resource/resource-tabs.component.html

@ -0,0 +1,27 @@
<!--
Copyright © 2016-2024 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="entity && entity.tenantId.id !== NULL_UUID && authUser.authority === authorities.TENANT_ADMIN && !isEdit" #auditLogsTab="matTab"
label="{{ 'audit-log.audit-logs' | translate }}">
<tb-audit-log-table detailsMode="true" [active]="auditLogsTab.isActive" [auditLogMode]="auditLogModes.ENTITY" [entityId]="entity.id"></tb-audit-log-table>
</mat-tab>
<mat-tab *ngIf="entity && entity.tenantId.id !== NULL_UUID && authUser.authority === authorities.TENANT_ADMIN && !isEdit"
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.name" [externalEntityId]="entity.externalId || entity.id"></tb-version-control>
</mat-tab>

36
ui-ngx/src/app/modules/home/pages/admin/resource/resource-tabs.component.ts

@ -0,0 +1,36 @@
///
/// Copyright © 2016-2024 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 { EntityTabsComponent } from '@home/components/entity/entity-tabs.component';
import { Resource } from '@shared/models/resource.models';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import { NULL_UUID } from '@shared/models/id/has-uuid';
@Component({
selector: 'tb-resource-tabs',
templateUrl: './resource-tabs.component.html',
styleUrls: []
})
export class ResourceTabsComponent extends EntityTabsComponent<Resource> {
readonly NULL_UUID = NULL_UUID;
constructor(protected store: Store<AppState>) {
super(store);
}
}

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

@ -15,7 +15,7 @@
///
import { EntityId } from '@shared/models/id/entity-id';
import { EntityType } from '@shared/models/entity-type.models';
import { AliasEntityType, EntityType } from '@shared/models/entity-type.models';
import { ExportableEntity } from '@shared/models/base-data';
import { EntityRelation } from '@shared/models/relation.models';
import { Device, DeviceCredentials } from '@shared/models/device.models';
@ -38,7 +38,7 @@ export const exportableEntityTypes: Array<EntityType> = [
EntityType.NOTIFICATION_RULE
];
export const entityTypesWithoutRelatedData: Set<EntityType> = new Set([
export const entityTypesWithoutRelatedData: Set<EntityType | AliasEntityType> = new Set([
EntityType.NOTIFICATION_TEMPLATE,
EntityType.NOTIFICATION_TARGET,
EntityType.NOTIFICATION_RULE,
@ -104,8 +104,8 @@ export function createDefaultEntityTypesVersionCreate(): {[entityType: string]:
for (const entityType of exportableEntityTypes) {
res[entityType] = {
syncStrategy: null,
saveAttributes: true,
saveRelations: true,
saveAttributes: !entityTypesWithoutRelatedData.has(entityType),
saveRelations: !entityTypesWithoutRelatedData.has(entityType),
saveCredentials: true,
allEntities: true,
entityIds: []
@ -151,8 +151,8 @@ export function createDefaultEntityTypesVersionLoad(): {[entityType: string]: En
const res: {[entityType: string]: EntityTypeVersionLoadConfig} = {};
for (const entityType of exportableEntityTypes) {
res[entityType] = {
loadAttributes: true,
loadRelations: true,
loadAttributes: !entityTypesWithoutRelatedData.has(entityType),
loadRelations: !entityTypesWithoutRelatedData.has(entityType),
loadCredentials: true,
removeOtherEntities: false,
findExistingEntityByName: true

Loading…
Cancel
Save