Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-8001] Metadata side bar - handle AI predictions #9801

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ A collection of Angular components for generic use.
| [Card View component](core/components/card-view.component.md) | Displays a configurable property list renderer. | [Source](../lib/core/src/lib/card-view/components/card-view/card-view.component.ts) |
| [Comment list component](core/components/comment-list.component.md) | Shows a list of comments. | [Source](../lib/core/src/lib/comments/comment-list/comment-list.component.ts) |
| [Comments Component](core/components/comments.component.md) | Displays comments from users involved in a specified environment and allows an involved user to add a comment to a environment. | [Source](../lib/core/src/lib/comments/comments.component.ts) |
| [Content Enrichment Menu Component](core/components/content-enrichment-menu.component.md) | Allows the user to handle AI predictions by confirming or rejecting changes. | [Source](../lib/core/src/lib/prediction/components/content-enrichment-menu/content-enrichment-menu.component.ts) |
| [Data Column Component](core/components/data-column.component.md) | Defines column properties for DataTable, Tasklist, Document List and other components. | [Source](../lib/core/src/lib/datatable/data-column/data-column.component.ts) |
| [DataTable component](core/components/datatable.component.md) | Displays data as a table with customizable columns and presentation. | [Source](../lib/core/src/lib/datatable/components/datatable/datatable.component.ts) |
| [Dynamic Chip List component](core/components/dynamic-chip-list.component.md) | This component shows dynamic list of chips which render depending on free space. | [Source](../lib/core/src/lib/dynamic-chip-list/dynamic-chip-list.component.ts) |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Title: Card View Content Update Service
Added: v6.0.0
Status: Active
Last reviewed: 2022-11-25
Last reviewed: 2024-06-11
---

# [Card View Content Update Service](../../../lib/content-services/src/lib/common/services/card-view-content-update.service.ts "Defined in card-view-content-update.service.ts")
Expand All @@ -25,6 +25,9 @@ Implements [`BaseCardViewContentUpdate`](../../../lib/content-services/src/lib/i
- **updateNodeAspect**(node: [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md))<br/>
Update node aspect observable.
- _node:_ [`MinimalNode`](https://github.com/Alfresco/alfresco-js-api/blob/master/src/alfresco-core-rest-api/docs/NodeMinimalEntry.md) -
- **onPredictionStatusChanged**(notification: [`PredictionStatusUpdate[]`](../../core/interfaces/prediction-status-update.interface.md))<br/>
Clears predictions for properties and sets the previous value, if provided.
- _notification:_ [`PredictionStatusUpdate[]`](../../core/interfaces/prediction-status-update.interface.md) -

## Properties

Expand Down
32 changes: 32 additions & 0 deletions docs/core/components/content-enrichment-menu.component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
Title: Content Enrichment Menu Component
Added: v6.10.0
Status: Active
Last reviewed: 2024-06-11
---

# [Content Enrichment Menu Component](../../../lib/core/src/lib/prediction/components/content-enrichment-menu/content-enrichment-menu.component.ts "Defined in content-enrichment-menu.component.ts")

Allows the user to handle AI predictions by confirming or rejecting changes.

![Content Enrichment Menu Component](../../docassets/images/content-enrichment-menu.png)

## Basic Usage

```html
<mat-form-field>
<mat-label>Form field</mat-label>
<adf-content-enrichment-menu matPrefix [prediction]="prediction"></adf-content-enrichment-menu>
<input matInput>
</mat-form-field>
```

### Properties

| Name | Type | Default value | Description |
|------------|----------------------------------------------------------------------------------|---------------|-----------------------------------|
| prediction | [`Prediction`](../../../lib/js-api/src/api/hxi-connector-api/docs/Prediction.md) | | Prediction for the node property. |

## See also

- [Prediction Status Update Interface](../interfaces/prediction-status-update.interface.md)
9 changes: 8 additions & 1 deletion docs/core/interfaces/base-card-view-update.interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Title: Base Card View Update Interface
Added: v6.0.0
Status: Active
Last reviewed: 2022-11-25
Last reviewed: 2024-06-11
---

# [Base Card View Update interface](../../../lib/core/src/lib/card-view/interfaces/base-card-view-update.interface.ts "Defined in base-card-view-update.interface.ts")
Expand All @@ -16,10 +16,12 @@ export interface BaseCardViewUpdate {
itemUpdated$: Subject<UpdateNotification>;
itemClicked$: Subject<ClickNotification>;
updateItem$: Subject<CardViewBaseItemModel>;
predictionStatusChanged$: Subject<PredictionStatusUpdate[]>;

update(property: CardViewBaseItemModel, newValue: any);
clicked(property: CardViewBaseItemModel);
updateElement(notification: CardViewBaseItemModel);
onPredictionStatusChanged(notification: PredictionStatusUpdate[]);
}
```

Expand All @@ -30,6 +32,7 @@ export interface BaseCardViewUpdate {
| itemUpdated$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`UpdateNotification`](../../../lib/core/src/lib/card-view/interfaces/update-notification.interface.ts)`>` | The current updated item. |
| itemClicked$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`ClickNotification`](../../../lib/core/src/lib/card-view/interfaces/click-notification.interface.ts)`>` | The current clicked item. |
| updateItem$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts)`>` | The current model for the update item. |
| predictionStatusChanged$ | [`Subject`](http://reactivex.io/documentation/subject.html)`<`[`PredictionStatusUpdate[]`](./prediction-status-update.interface.md)`>` | Notification of prediction status change. |

### Methods

Expand All @@ -48,6 +51,10 @@ export interface BaseCardViewUpdate {
Update updateItem$ observable.
- notification:\_ [`CardViewBaseItemModel`](../../../lib/core/src/lib/card-view/models/card-view-baseitem.model.ts) - The notification.

- **onPredictionStatusChanged**(notification: [`PredictionStatusUpdate[]`](./prediction-status-update.interface.md))<br/>
Update predictionStatusChanged$ observable.
- notification:\_ [`PredictionStatusUpdate[]`](./prediction-status-update.interface.md) - The notification.

## See also

- [CardViewUpdate service](../services/card-view-update.service.md)
4 changes: 3 additions & 1 deletion docs/core/interfaces/card-view-item.interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Title: Card View Item interface
Added: v2.0.0
Status: Active
Last reviewed: 2018-05-08
Last reviewed: 2024-06-11
---

# [Card View Item interface](../../../lib/core/src/lib/card-view/interfaces/card-view-item.interface.ts "Defined in card-view-item.interface.ts")
Expand All @@ -22,6 +22,7 @@ export interface CardViewItem {
editable?: boolean;
icon?: string;
data?: any;
prediction?: Prediction;
}
```

Expand All @@ -38,6 +39,7 @@ export interface CardViewItem {
| clickable | boolean | false | Toggles whether the item is clickable |
| icon | string | | The material icon to show beside clickable items |
| data | any | null | Any custom data which is needed to be provided and stored in the model for any reason. During an update or a click event this can be a container of any custom data which can be useful for 3rd party codes. |
| prediction | Prediction | null | Property prediction. |

## Details

Expand Down
28 changes: 28 additions & 0 deletions docs/core/interfaces/prediction-status-update.interface.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
Title: Prediction Status Update Interface
Added: v6.10.0
Status: Active
Last reviewed: 2024-06-11
---

# [Prediction Status Update Interface](../../../lib/core/src/lib/prediction/interfaces/prediction-status-update.interface.ts "Defined in prediction-status-update.interface.ts")

## Basic usage

```ts
export interface PredictionStatusUpdate {
key: string;
previousValue?: any;
}
```

## Properties

| Name | Type | Description |
|---------------|----------|-------------------------------|
| key | `string` | Key of the property. |
| previousValue | `any` | Previous human entered value. |

## See also

- [BaseCardViewUpdate interface](../interfaces/base-card-view-update.interface.md)
19 changes: 19 additions & 0 deletions docs/core/services/card-view-update.service.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,27 @@ Example
this.cardViewUpdateService.updateElement(cardViewBaseItemModel)
```

## Clear predictions for properties and set previous value

`onPredictionStatusChanged` function helps to clear predictions and set previous value (if provided) for the card view item. It takes the [`PredictionStatusUpdate[]`](../interfaces/prediction-status-update.interface.md) as a parameter.

Example

```javascript
this.cardViewUpdateService.onPredictionStatusChanged(notification);
```

You can subscribe to the `predictionStatusChanged$` to be informed about prediction status changes.

```ts
ngOnInit() {
this.cardViewUpdateService.predictionStatusChanged$.subscribe(this.respondToPredictionStatusChange.bind(this));
}
```

## See also

- [Card view component](../components/card-view.component.md)
- [UpdateNotification interface](../interfaces/update-notification.interface.md)
- [ClickNotification interface](../interfaces/click-notification.interface.md)
- [PredictionStatusUpdate interface](../interfaces/prediction-status-update.interface.md)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions docs/versionIndex.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ backend services have been tested with each released version of ADF.

## Versions

- [v6.10.0](#v6100)
- [v6.8.0](#v680)
- [v6.7.0](#v670)
- [v6.4.0](#v640)
Expand Down Expand Up @@ -46,6 +47,15 @@ backend services have been tested with each released version of ADF.
- [v2.1.0](#v210)
- [v2.0.0](#v200)

## v6.10.0
swapnil-verma-gl marked this conversation as resolved.
Show resolved Hide resolved

<!--6100 start-->

- [Content Enrichment Menu Component](core/components/content-enrichment-menu.component.md)
- [Prediction Status Update Interface](core/interfaces/prediction-status-update.interface.md)

<!--6100 end-->

## v6.8.0

<!--680 start-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@
import { Node } from '@alfresco/js-api';
import { fakeAsync, TestBed } from '@angular/core/testing';
import { CardViewContentUpdateService } from './card-view-content-update.service';
import { CardViewUpdateService, PredictionStatusUpdate } from '@alfresco/adf-core';

describe('CardViewContentUpdateService', () => {
let cardViewContentUpdateService: CardViewContentUpdateService;
let cardViewUpdateService: CardViewUpdateService;

beforeEach(() => {
cardViewContentUpdateService = TestBed.inject(CardViewContentUpdateService);
cardViewUpdateService = TestBed.inject(CardViewUpdateService);
});

it('should send updated node when aspect changed', fakeAsync(() => {
Expand All @@ -34,4 +37,12 @@ describe('CardViewContentUpdateService', () => {

cardViewContentUpdateService.updateNodeAspect(fakeNode);
}));

it('should call onPredictionStatusChanged on cardViewUpdateService', () => {
spyOn(cardViewUpdateService, 'onPredictionStatusChanged');
const mockNotification: PredictionStatusUpdate[] = [{ key: 'test', previousValue: 'value' }];
cardViewContentUpdateService.onPredictionStatusChanged(mockNotification);

expect(cardViewUpdateService.onPredictionStatusChanged).toHaveBeenCalledWith(mockNotification);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { UpdateNotification, CardViewBaseItemModel, CardViewUpdateService } from '@alfresco/adf-core';
import { UpdateNotification, CardViewBaseItemModel, CardViewUpdateService, PredictionStatusUpdate } from '@alfresco/adf-core';
import { Node } from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
Expand All @@ -40,6 +40,10 @@ export class CardViewContentUpdateService implements BaseCardViewContentUpdate {
this.cardViewUpdateService.updateElement(notification);
}

onPredictionStatusChanged(notification: PredictionStatusUpdate[]) {
this.cardViewUpdateService.onPredictionStatusChanged(notification);
}

updateNodeAspect(node: Node) {
this.updatedAspect$.next(node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { NodeAspectService } from '../../../aspect-list/services/node-aspect.ser
import { ContentMetadataService } from '../../services/content-metadata.service';
import { AllowableOperationsEnum } from '../../../common/models/allowable-operations.enum';
import { of } from 'rxjs';
import { AlfrescoApiService, AlfrescoApiServiceMock, AuthModule, PipeModule, TranslationMock, TranslationService } from '@alfresco/adf-core';
import { AlfrescoApiService, AlfrescoApiServiceMock, AuthModule, PipeModule, TranslationMock, TranslationService, CONTENT_ENRICHMENT } from '@alfresco/adf-core';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
import { versionCompatibilityFactory } from '../../../version-compatibility/version-compatibility-factory';
Expand All @@ -37,6 +37,7 @@ import { MatTooltipModule } from '@angular/material/tooltip';
import { CategoryService } from '../../../category';
import { TagService } from '../../../tag';
import { PropertyDescriptorsService } from '../../public-api';
import { provideMockFeatureFlags } from '@alfresco/adf-core/feature-flags';

describe('ContentMetadataCardComponent', () => {
let component: ContentMetadataCardComponent;
Expand Down Expand Up @@ -72,7 +73,8 @@ describe('ContentMetadataCardComponent', () => {
useFactory: versionCompatibilityFactory,
deps: [VersionCompatibilityService],
multi: true
}
},
provideMockFeatureFlags({[CONTENT_ENRICHMENT.EXPERIENCE_INSIGHT]: true})
]
});
fixture = TestBed.createComponent(ContentMetadataCardComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ $panel-properties-height: 56px !default;
font-size: 19px;
line-height: 20px;
}

adf-content-enrichment-menu button.adf-ai-button {
margin-left: -10px;
}
}
}

Expand Down
Loading
Loading