@datagrok/compute 1.14.1 → 1.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datagrok/compute",
3
3
  "friendlyName": "Compute",
4
- "version": "1.14.1",
4
+ "version": "1.14.2",
5
5
  "author": {
6
6
  "name": "Aufar Zakiev",
7
7
  "email": "aufar.zakiev@softwarecountry.com"
@@ -13,7 +13,7 @@
13
13
  "directory": "packages/Compute"
14
14
  },
15
15
  "dependencies": {
16
- "@datagrok-libraries/compute-utils": "^1.14.1",
16
+ "@datagrok-libraries/compute-utils": "^1.14.2",
17
17
  "cash-dom": "latest",
18
18
  "datagrok-api": "^1.16.3",
19
19
  "dayjs": "=1.11.7",
@@ -1,6 +1,11 @@
1
1
  import * as grok from 'datagrok-api/grok';
2
2
  import * as ui from 'datagrok-api/ui';
3
3
  import * as DG from 'datagrok-api/dg';
4
+ import $ from 'cash-dom';
5
+
6
+ const getBalloonContainer = () => {
7
+ return document.querySelector('.d4-balloon-container')
8
+ }
4
9
 
5
10
  export class OutliersSelectionViewer extends DG.JsViewer {
6
11
  constructor() {
@@ -51,41 +56,57 @@ export class OutliersSelectionViewer extends DG.JsViewer {
51
56
  groupsListGrid.root.style.minWidth = '230px';
52
57
  groupsListGrid.columns.setVisible([OUTLIER_RATIONALE_COL_LABEL, OUTLIER_COUNT_COL_LABEL, 'Actions']);
53
58
 
59
+ this.root.append(
60
+ ui.divV([
61
+ ui.divV([
62
+ groupsListGrid.root,
63
+ ], {style: {'height': '75%'}}),
64
+ ], {style: {'height': '100%'}})
65
+ );
66
+
67
+ const confirmOutliers = () => {
68
+ if (!groupsListGrid.dataFrame) return;
69
+
70
+ //@ts-ignore
71
+ inputData.col(IS_OUTLIER_COL_LABEL)?.markers.assign('true', DG.MARKER_TYPE.OUTLIER);
72
+
73
+ const newRationale =
74
+ groupsListGrid.dataFrame?.cell(groupsListGrid.dataFrame.rowCount-1, OUTLIER_RATIONALE_COL_LABEL).value;
75
+
76
+ inputData.selection.getSelectedIndexes().forEach((selectedIndex: number) => {
77
+ inputData.col(IS_OUTLIER_COL_LABEL)!.set(selectedIndex, true, false);
78
+ inputData.col(OUTLIER_RATIONALE_COL_LABEL)!.set(
79
+ selectedIndex,
80
+ newRationale,
81
+ false,
82
+ );
83
+ });
84
+ inputData.selection.setAll(false);
85
+ inputData.fireValuesChanged();
86
+
87
+ $(getBalloonContainer()).empty();
88
+ };
89
+
90
+ const cancelOutliers = () => {
91
+ if (!groupsListGrid.dataFrame) return;
92
+
93
+ groupsListGrid.dataFrame.rows.removeAt(groupsListGrid.dataFrame.rowCount-1);
94
+ inputData.selection.setAll(false);
95
+
96
+ $(getBalloonContainer()).empty();
97
+ }
98
+
54
99
  groupsListGrid.onCellPrepare((gc) => {
55
100
  if (!gc.isTableCell) {
56
101
  return;
57
102
  }
58
103
 
59
104
  const confirmBtn = () => ui.div(
60
- ui.iconFA('check', () => {
61
- if (!groupsListGrid.dataFrame) return;
62
-
63
- //@ts-ignore
64
- inputData.col(IS_OUTLIER_COL_LABEL)?.markers.assign('true', DG.MARKER_TYPE.OUTLIER);
65
-
66
- const newRationale =
67
- groupsListGrid.dataFrame?.cell(groupsListGrid.dataFrame.rowCount-1, OUTLIER_RATIONALE_COL_LABEL).value;
68
-
69
- inputData.selection.getSelectedIndexes().forEach((selectedIndex: number) => {
70
- inputData.col(IS_OUTLIER_COL_LABEL)!.set(selectedIndex, true, false);
71
- inputData.col(OUTLIER_RATIONALE_COL_LABEL)!.set(
72
- selectedIndex,
73
- newRationale,
74
- false,
75
- );
76
- });
77
- inputData.selection.setAll(false);
78
- inputData.fireValuesChanged();
79
- }, 'Confirm the outliers'), {style: {'text-align': 'center', 'margin': '6px'}},
105
+ ui.iconFA('check', confirmOutliers, 'Confirm the outliers'), {style: {'text-align': 'center', 'margin': '6px'}},
80
106
  );
81
107
 
82
108
  const cancelBtn = () => ui.div(
83
- ui.iconFA('times', () => {
84
- if (!groupsListGrid.dataFrame) return;
85
-
86
- groupsListGrid.dataFrame.rows.removeAt(groupsListGrid.dataFrame.rowCount-1);
87
- inputData.selection.setAll(false);
88
- }, 'Cancel the outliers'), {style: {'text-align': 'center', 'margin': '6px'}},
109
+ ui.iconFA('times', cancelOutliers, 'Cancel the outliers'), {style: {'text-align': 'center', 'margin': '6px'}},
89
110
  );
90
111
 
91
112
  const deleteBtn = (rationale: string) => ui.div(
@@ -131,7 +152,7 @@ export class OutliersSelectionViewer extends DG.JsViewer {
131
152
  }
132
153
  });
133
154
 
134
- const updateGroupsTable = () => {
155
+ const updateGroupsDf = () => {
135
156
  if ((inputData.columns as DG.ColumnList).byName(OUTLIER_RATIONALE_COL_LABEL)) {
136
157
  for (let i = 0; i < inputData.rowCount; i++) {
137
158
  if (inputData.columns.byName(IS_OUTLIER_COL_LABEL).get(i)) {
@@ -166,10 +187,22 @@ export class OutliersSelectionViewer extends DG.JsViewer {
166
187
  });
167
188
  };
168
189
 
169
- inputData.onDataChanged.subscribe(updateGroupsTable);
190
+ inputData.onDataChanged.subscribe(updateGroupsDf);
191
+
170
192
  inputData.onSelectionChanged.subscribe(() => {
171
193
  if (!groupsListGrid.dataFrame || !inputData.selection.trueCount) return;
172
194
 
195
+ const balloon = getBalloonContainer();
196
+ if (!balloon || $(balloon).is(':empty')) {
197
+ grok.shell.info(ui.div([
198
+ ui.divText('Confirm selected points as outliers?'),
199
+ ui.divH([
200
+ ui.button('Confirm', confirmOutliers),
201
+ ui.button('Cancel', cancelOutliers)
202
+ ])
203
+ ]))
204
+ }
205
+
173
206
  const isConfirmedColumn = (groupsListGrid.dataFrame.columns as DG.ColumnList)
174
207
  .byName(IS_GROUP_CONFIRMED_LABEL).toList();
175
208
 
@@ -187,14 +220,6 @@ export class OutliersSelectionViewer extends DG.JsViewer {
187
220
 
188
221
  inputData.selection.setAll(false);
189
222
 
190
- updateGroupsTable();
191
-
192
- this.root.innerHTML = '';
193
- this.root.appendChild(
194
- ui.divV([
195
- ui.divV([
196
- groupsListGrid.root,
197
- ], {style: {'height': '75%'}}),
198
- ], {style: {'height': '100%'}}));
223
+ updateGroupsDf();
199
224
  }
200
225
  }