Skip to content

Commit 84a1f05

Browse files
style: add styling for automation (#2450)
--------- Co-authored-by: Antoine Hurard <antoine.reliefapps@gmail.com>
1 parent beaafbc commit 84a1f05

File tree

17 files changed

+437
-193
lines changed

17 files changed

+437
-193
lines changed

libs/shared/src/i18n/en.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,28 @@
653653
"ariaLabel": "Select page of applications"
654654
}
655655
},
656+
"automation": {
657+
"actions": {
658+
"add.layer": "Add layer",
659+
"add.tab": "Add tab",
660+
"display.collapse": "Collapse the display",
661+
"display.expand": "Expand the display",
662+
"map.click": "On map click",
663+
"map.get.country": "Get country from map",
664+
"open.tab": "Open tab",
665+
"remove.layer": "Remove layer",
666+
"remove.tab": "Remove tab",
667+
"set.context": "Set context"
668+
},
669+
"addRule": "Add a new automation rule",
670+
"component": {
671+
"add": "Add a new component",
672+
"select": "Select a component"
673+
},
674+
"configuration": "Automation configuration",
675+
"ruleName": "Name of the automation rule",
676+
"rules": "Automation rules"
677+
},
656678
"calculatedFields": {
657679
"add": "Create a new Calculated field",
658680
"delete": {

libs/shared/src/i18n/fr.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,28 @@
659659
"ariaLabel": "Sélectionnez la page d'applications"
660660
}
661661
},
662+
"automation": {
663+
"actions": {
664+
"add.layer": "Ajouter une couche",
665+
"add.tab": "Ajouter un onglet",
666+
"display.collapse": "Réduire l'affichage",
667+
"display.expand": "Développer l'affichage",
668+
"map.click": "En cliquant sur la carte",
669+
"map.get.country": "Obtenir le pays sur la carte",
670+
"open.tab": "Ouvrir un onglet",
671+
"remove.layer": "Supprimer une couche",
672+
"remove.tab": "Supprimer un onglet",
673+
"set.context": "Définir le contexte"
674+
},
675+
"addRule": "Ajouter une nouvelle règle d'automatisation",
676+
"component": {
677+
"add": "Ajoutez un nouveau composant",
678+
"select": "Sélectionnez un composant"
679+
},
680+
"configuration": "Configuration de l'automatisation",
681+
"ruleName": "Nom de la règle d'automatisation",
682+
"rules": "Règles d'automatisation"
683+
},
662684
"calculatedFields": {
663685
"add": "Créer un nouveau champ dérivé",
664686
"delete": {

libs/shared/src/i18n/test.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,28 @@
653653
"ariaLabel": "******"
654654
}
655655
},
656+
"automation": {
657+
"actions": {
658+
"add.layer": "******",
659+
"add.tab": "******",
660+
"display.collapse": "******",
661+
"display.expand": "******",
662+
"map.click": "******",
663+
"map.get.country": "******",
664+
"open.tab": "******",
665+
"remove.layer": "******",
666+
"remove.tab": "******",
667+
"set.context": "******"
668+
},
669+
"addRule": "******",
670+
"component": {
671+
"add": "******",
672+
"select": "******"
673+
},
674+
"configuration": "******",
675+
"ruleName": "******",
676+
"rules": "******"
677+
},
656678
"calculatedFields": {
657679
"add": "******",
658680
"delete": {

libs/shared/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export * from './lib/models/layout.model';
5555
export * from './lib/models/aggregation.model';
5656
export * from './lib/models/reference-data.model';
5757
export * from './lib/models/metadata.model';
58+
export * from './lib/models/automation.model';
5859

5960
// === COMPONENTS ===
6061
export * from './lib/components/aggregation/edit-aggregation-modal/edit-aggregation-modal.component';

libs/shared/src/lib/components/ui/map/map.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { MapPolygonsService } from '../../../services/map/map-polygons.service';
6464
import { DOCUMENT } from '@angular/common';
6565
import { ShadowDomService } from '@oort-front/ui';
6666
import { DashboardAutomationService } from '../../../services/dashboard-automation/dashboard-automation.service';
67+
import { ActionComponent, ActionType } from '../../../models/automation.model';
6768

6869
/** Component for the map widget */
6970
@Component({
@@ -319,11 +320,11 @@ export class MapComponent
319320

320321
if (this.mapSettingsValue.automationRules) {
321322
for (const rule of this.mapSettingsValue.automationRules) {
322-
const trigger = get(rule, 'components[0]');
323+
const trigger: ActionComponent = get(rule, 'components[0]');
323324
if (
324325
trigger &&
325326
trigger.component === 'trigger' &&
326-
trigger.type === 'map.click'
327+
trigger.type === ActionType.mapClick
327328
) {
328329
// Save rule in map object to populate to all layers attached to it
329330
if ((this.map as any)._rules) {

libs/shared/src/lib/components/widgets/common/tab-widget-automations/tab-widget-automations.component.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<div class="flex justify-between">
2-
<h2>Automation rules</h2>
2+
<h2>{{ 'components.automation.rules' | translate }}</h2>
33
<ui-button
44
class="mb-6"
55
category="secondary"
66
variant="primary"
77
(click)="addEditRule()"
88
>
9-
Add a new automation rule
9+
{{ 'components.automation.addRule' | translate }}
1010
</ui-button>
1111
</div>
1212
<ng-template #emptyTmpl>
@@ -38,14 +38,6 @@ <h2>Automation rules</h2>
3838
<th uiCellHeader *cdkHeaderCellDef></th>
3939
<td uiCell *cdkCellDef="let element; let i = index">
4040
<div class="flex gap-2 text-neutral-500 justify-end">
41-
<ui-button
42-
variant="danger"
43-
[isIcon]="true"
44-
icon="delete"
45-
(click)="removeRow(i)"
46-
[uiTooltip]="'common.delete' | translate"
47-
>
48-
</ui-button>
4941
<ui-button
5042
uiSuffix
5143
variant="primary"
@@ -54,6 +46,14 @@ <h2>Automation rules</h2>
5446
(click)="addEditRule(i)"
5547
[uiTooltip]="'common.edit' | translate"
5648
></ui-button>
49+
<ui-button
50+
variant="danger"
51+
[isIcon]="true"
52+
icon="delete"
53+
(click)="removeRow(i)"
54+
[uiTooltip]="'common.delete' | translate"
55+
>
56+
</ui-button>
5757
</div>
5858
</td>
5959
</ng-container>

libs/shared/src/lib/components/widgets/common/widget-automation/automation-component-selector/automation-component-selector.component.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
<ui-dialog>
2-
<ng-container ngProjectAs="header">Select a component</ng-container>
1+
<ui-dialog size="medium">
2+
<ng-container ngProjectAs="header"
3+
><h3 class="font-semibold">
4+
{{ 'components.automation.component.select' | translate }}
5+
</h3></ng-container
6+
>
37
<ng-container ngProjectAs="content">
4-
<div class="flex gap-2 flex-wrap flex-row">
8+
<div class="flex flex-wrap justify-between">
59
<div
610
*ngFor="let action of actionComponents"
11+
class="mb-4 mx-0.5 border border-gray-300 rounded-lg p-2 cursor-pointer hover:shadow-md"
712
(click)="onSelect(action)"
8-
class="relative flex flex-row justify-between bg-white shadow border border-gray-300 rounded-lg ring ring-white items-center p-2"
913
>
10-
<h3 class="!m-0">{{ action.type }}</h3>
14+
<h3 class="!m-0">
15+
{{ 'components.automation.actions.' + action.type | translate }}
16+
</h3>
1117
</div>
1218
</div>
1319
</ng-container>

libs/shared/src/lib/components/widgets/common/widget-automation/automation-component-selector/automation-component-selector.component.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,80 @@
11
import { Component } from '@angular/core';
22
import { CommonModule } from '@angular/common';
3-
import { ButtonModule, DialogModule } from '@oort-front/ui';
3+
import { ButtonModule, DialogModule, TooltipModule } from '@oort-front/ui';
44
import { TranslateModule } from '@ngx-translate/core';
55
import { DialogRef } from '@angular/cdk/dialog';
6+
import {
7+
ActionWithValue,
8+
ActionType,
9+
} from '../../../../../models/automation.model';
610

711
/** Available action components */
8-
const ACTION_COMPONENTS = [
9-
{
10-
component: 'trigger',
11-
type: 'map.click',
12-
},
12+
const ACTION_COMPONENTS: ActionWithValue[] = [
13+
{ component: 'trigger', type: ActionType.mapClick },
1314
{
1415
component: 'action',
15-
type: 'add.layer',
16+
type: ActionType.addLayer,
1617
value: {
1718
widget: null,
1819
layers: null,
1920
},
2021
},
2122
{
2223
component: 'action',
23-
type: 'remove.layer',
24+
type: ActionType.removeLayer,
2425
value: {
2526
widget: null,
2627
layers: null,
2728
},
2829
},
2930
{
3031
component: 'action',
31-
type: 'add.tab',
32+
type: ActionType.addTab,
3233
value: {
3334
widget: null,
3435
tabs: null,
3536
},
3637
},
3738
{
3839
component: 'action',
39-
type: 'open.tab',
40+
type: ActionType.openTab,
4041
value: {
4142
widget: null,
4243
tab: null,
4344
},
4445
},
4546
{
4647
component: 'action',
47-
type: 'remove.tab',
48+
type: ActionType.removeTab,
4849
value: {
4950
widget: null,
5051
tabs: null,
5152
},
5253
},
5354
{
5455
component: 'action',
55-
type: 'display.collapse',
56+
type: ActionType.displayCollapse,
5657
value: {
5758
widget: null,
5859
},
5960
},
6061
{
6162
component: 'action',
62-
type: 'display.expand',
63+
type: ActionType.displayExpand,
6364
value: {
6465
widget: null,
6566
},
6667
},
6768
{
6869
component: 'action',
69-
type: 'set.context',
70+
type: ActionType.setContext,
7071
value: {
7172
mapping: '',
7273
},
7374
},
7475
{
7576
component: 'action',
76-
type: 'map.get.country',
77+
type: ActionType.mapGetCountry,
7778
},
7879
];
7980

@@ -83,7 +84,13 @@ const ACTION_COMPONENTS = [
8384
@Component({
8485
selector: 'shared-automation-component-selector',
8586
standalone: true,
86-
imports: [CommonModule, DialogModule, TranslateModule, ButtonModule],
87+
imports: [
88+
CommonModule,
89+
DialogModule,
90+
TranslateModule,
91+
ButtonModule,
92+
TooltipModule,
93+
],
8794
templateUrl: './automation-component-selector.component.html',
8895
styleUrls: ['./automation-component-selector.component.scss'],
8996
})

libs/shared/src/lib/components/widgets/common/widget-automation/edit-automation-component/edit-automation-component.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ui-dialog size="medium">
22
<ng-container ngProjectAs="header">
3-
<h3>{{ data.type }}</h3>
3+
<h3>{{ 'components.automation.actions.' + data.type | translate }}</h3>
44
</ng-container>
55
<ng-container ngProjectAs="content">
66
<ng-container *ngIf="editor" [formGroup]="formGroup.controls.value">
@@ -14,10 +14,10 @@ <h3>{{ data.type }}</h3>
1414
<ui-select-menu
1515
*ngIf="property.async"
1616
[formControlName]="property.name"
17-
[multiselect]="property.multiselect"
17+
[multiselect]="property.multiselect || false"
1818
>
1919
<ui-select-option
20-
*ngFor="let choice of property.choices | async"
20+
*ngFor="let choice of $any(property).choices | async"
2121
[value]="choice.value"
2222
>
2323
{{ choice.text }}
@@ -27,10 +27,10 @@ <h3>{{ data.type }}</h3>
2727
<ui-select-menu
2828
*ngIf="!property.async"
2929
[formControlName]="property.name"
30-
[multiselect]="property.multiselect"
30+
[multiselect]="property.multiselect || false"
3131
>
3232
<ui-select-option
33-
*ngFor="let choice of property.choices"
33+
*ngFor="let choice of $any(property).choices"
3434
[value]="choice.value"
3535
>
3636
{{ choice.text }}

0 commit comments

Comments
 (0)