@dhis2/analytics 20.6.5 → 20.8.0

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/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # [20.8.0](https://github.com/dhis2/analytics/compare/v20.7.1...v20.8.0) (2022-06-02)
2
+
3
+
4
+ ### Features
5
+
6
+ * add basic and extended color sets ([#1264](https://github.com/dhis2/analytics/issues/1264)) ([95f4926](https://github.com/dhis2/analytics/commit/95f49263bc559157c1de1db8b3648fb37bdd165a)), closes [#1242](https://github.com/dhis2/analytics/issues/1242) [#1248](https://github.com/dhis2/analytics/issues/1248)
7
+
8
+ ## [20.7.1](https://github.com/dhis2/analytics/compare/v20.7.0...v20.7.1) (2022-04-06)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * filter on displayName to get objects in current language DHIS2-13015 ([#1198](https://github.com/dhis2/analytics/issues/1198)) ([bba6bf7](https://github.com/dhis2/analytics/commit/bba6bf7ac063ad42a30cdd5a8eece145b3ff26fb))
14
+
15
+ # [20.7.0](https://github.com/dhis2/analytics/compare/v20.6.5...v20.7.0) (2021-11-11)
16
+
17
+
18
+ ### Features
19
+
20
+ * implement AboutAOUnit component ([#1082](https://github.com/dhis2/analytics/issues/1082)) ([8ab8e27](https://github.com/dhis2/analytics/commit/8ab8e271077ce24b9f032303dad8999ce65b47d3))
21
+
1
22
  ## [20.6.5](https://github.com/dhis2/analytics/compare/v20.6.4...v20.6.5) (2021-10-27)
2
23
 
3
24
 
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _style = _interopRequireDefault(require("styled-jsx/style"));
9
+
10
+ var _appRuntime = require("@dhis2/app-runtime");
11
+
12
+ var _d2I18n = _interopRequireDefault(require("@dhis2/d2-i18n"));
13
+
14
+ var _ui = require("@dhis2/ui");
15
+
16
+ var _classnames = _interopRequireDefault(require("classnames"));
17
+
18
+ var _moment = _interopRequireDefault(require("moment"));
19
+
20
+ var _propTypes = _interopRequireDefault(require("prop-types"));
21
+
22
+ var _react = _interopRequireWildcard(require("react"));
23
+
24
+ var _AboutAOUnit = _interopRequireDefault(require("./styles/AboutAOUnit.style"));
25
+
26
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
27
+
28
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
+
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ const READ_ONLY = 'r';
33
+ const READ_AND_WRITE = 'rw';
34
+
35
+ const getQueries = type => ({
36
+ ao: {
37
+ resource: type,
38
+ id: ({
39
+ id
40
+ }) => id,
41
+ params: {
42
+ fields: 'id,displayDescription,created,createdBy[displayName],lastUpdated,subscribed,publicAccess,userAccesses[displayName,access],userGroupAccesses[displayName,access]'
43
+ }
44
+ },
45
+ dataStatistics: {
46
+ resource: 'dataStatistics/favorites',
47
+ id: ({
48
+ id
49
+ }) => id
50
+ }
51
+ });
52
+
53
+ const getSubscribeMutation = (type, id) => ({
54
+ resource: "".concat(type, "/").concat(id, "/subscriber"),
55
+ type: 'create'
56
+ });
57
+
58
+ const getUnsubscribeMutation = (type, id) => ({
59
+ resource: "".concat(type, "/").concat(id, "/subscriber"),
60
+ type: 'delete'
61
+ });
62
+
63
+ const AboutAOUnit = ({
64
+ type,
65
+ id
66
+ }) => {
67
+ const [isExpanded, setIsExpanded] = (0, _react.useState)(true);
68
+ const queries = (0, _react.useMemo)(() => getQueries(type), []);
69
+ const {
70
+ data,
71
+ loading: dataIsLoading,
72
+ refetch
73
+ } = (0, _appRuntime.useDataQuery)(queries, {
74
+ lazy: true
75
+ });
76
+ const subscribeMutation = (0, _react.useMemo)(() => getSubscribeMutation(type, id), []);
77
+ const unsubscribeMutation = (0, _react.useMemo)(() => getUnsubscribeMutation(type, id), []);
78
+ const [subscribe, {
79
+ loading: subscribeIsLoading
80
+ }] = (0, _appRuntime.useDataMutation)(subscribeMutation, {
81
+ onComplete: res => {
82
+ if (res.status === 'OK') {
83
+ refetch({
84
+ id
85
+ });
86
+ }
87
+ }
88
+ });
89
+ const [unsubscribe, {
90
+ loading: unsubscribeIsLoading
91
+ }] = (0, _appRuntime.useDataMutation)(unsubscribeMutation, {
92
+ onComplete: res => {
93
+ if (res.status === 'OK') {
94
+ refetch({
95
+ id
96
+ });
97
+ }
98
+ }
99
+ });
100
+ (0, _react.useEffect)(() => {
101
+ if (id) {
102
+ refetch({
103
+ id
104
+ });
105
+ }
106
+ }, [type, id]);
107
+
108
+ const getAccessLevelString = access => {
109
+ const re = new RegExp("(?<accessLevel>".concat(READ_AND_WRITE, "?)"));
110
+ const accessMatch = re.exec(access);
111
+
112
+ switch (accessMatch.groups.accessLevel) {
113
+ case READ_ONLY:
114
+ return _d2I18n.default.t('view only');
115
+
116
+ case READ_AND_WRITE:
117
+ return _d2I18n.default.t('view and edit');
118
+ }
119
+ };
120
+
121
+ const getSharingSummary = ao => {
122
+ const sharingText = [];
123
+ const re = new RegExp("^".concat(READ_AND_WRITE, "?"));
124
+
125
+ if (re.test(ao.publicAccess)) {
126
+ sharingText.push(_d2I18n.default.t('all users ({{accessLevel}})', {
127
+ accessLevel: getAccessLevelString(ao.publicAccess)
128
+ }));
129
+ }
130
+
131
+ const userAccesses = ao.userAccesses;
132
+ const groupAccesses = ao.userGroupAccesses;
133
+ userAccesses.concat(groupAccesses).forEach(accessRule => {
134
+ sharingText.push(_d2I18n.default.t('{{userOrGroup}} ({{accessLevel}})', {
135
+ userOrGroup: accessRule.displayName,
136
+ accessLevel: getAccessLevelString(accessRule.access)
137
+ }));
138
+ });
139
+ return sharingText.length ? _d2I18n.default.t('Shared with {{commaSeparatedListOfUsersAndGroups}}', {
140
+ commaSeparatedListOfUsersAndGroups: sharingText.join(', ')
141
+ }) : _d2I18n.default.t('Not shared with any users or groups');
142
+ };
143
+
144
+ return /*#__PURE__*/_react.default.createElement("div", {
145
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + ((0, _classnames.default)('container', {
146
+ expanded: isExpanded
147
+ }) || "")
148
+ }, /*#__PURE__*/_react.default.createElement("div", {
149
+ onClick: () => setIsExpanded(!isExpanded),
150
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "header"
151
+ }, _d2I18n.default.t('About this visualization'), isExpanded ? /*#__PURE__*/_react.default.createElement(_ui.IconChevronUp24, {
152
+ color: _ui.colors.grey700
153
+ }) : /*#__PURE__*/_react.default.createElement(_ui.IconChevronDown24, {
154
+ color: _ui.colors.grey700
155
+ })), isExpanded && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, dataIsLoading && /*#__PURE__*/_react.default.createElement("div", {
156
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "loader"
157
+ }, /*#__PURE__*/_react.default.createElement(_ui.CircularLoader, {
158
+ small: true
159
+ })), data && /*#__PURE__*/_react.default.createElement("div", {
160
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "content"
161
+ }, /*#__PURE__*/_react.default.createElement("p", {
162
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + ((0, _classnames.default)('detailLine', {
163
+ noDescription: !data.ao.displayDescription
164
+ }) || "")
165
+ }, data.ao.displayDescription ? data.ao.displayDescription : _d2I18n.default.t('No description')), /*#__PURE__*/_react.default.createElement("div", {
166
+ className: "jsx-".concat(_AboutAOUnit.default.__hash)
167
+ }, /*#__PURE__*/_react.default.createElement("p", {
168
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "detailLine"
169
+ }, /*#__PURE__*/_react.default.createElement(_ui.IconShare16, {
170
+ color: _ui.colors.grey700
171
+ }), getSharingSummary(data.ao)), /*#__PURE__*/_react.default.createElement("p", {
172
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "detailLine"
173
+ }, /*#__PURE__*/_react.default.createElement(_ui.IconClock16, {
174
+ color: _ui.colors.grey700
175
+ }), _d2I18n.default.t('Last updated {{time}}', {
176
+ time: (0, _moment.default)(data.ao.lastUpdated).fromNow()
177
+ })), /*#__PURE__*/_react.default.createElement("p", {
178
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "detailLine"
179
+ }, /*#__PURE__*/_react.default.createElement(_ui.IconUser16, {
180
+ color: _ui.colors.grey700
181
+ }), _d2I18n.default.t('Created {{time}} by {{author}}', {
182
+ time: (0, _moment.default)(data.ao.created).fromNow(),
183
+ author: data.ao.createdBy.displayName
184
+ })), /*#__PURE__*/_react.default.createElement("p", {
185
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "detailLine"
186
+ }, /*#__PURE__*/_react.default.createElement(_ui.IconView16, {
187
+ color: _ui.colors.grey700
188
+ }), _d2I18n.default.t('Viewed {{count}} times', {
189
+ count: data.dataStatistics.views,
190
+ defaultValue: 'Viewed 1 time',
191
+ defaultValue_plural: 'Viewed {{count}} times'
192
+ }))), /*#__PURE__*/_react.default.createElement("div", {
193
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "subsection"
194
+ }, /*#__PURE__*/_react.default.createElement("span", {
195
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "subsectionTitle"
196
+ }, _d2I18n.default.t('Notifications')), data.ao.subscribed ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
197
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "subscriptionLabel"
198
+ }, _d2I18n.default.t("You're subscribed and getting updates about new interpretations.")), /*#__PURE__*/_react.default.createElement(_ui.Button, {
199
+ icon: /*#__PURE__*/_react.default.createElement(_ui.IconSubscribeOff24, {
200
+ color: _ui.colors.grey700
201
+ }),
202
+ secondary: true,
203
+ small: true,
204
+ disabled: unsubscribeIsLoading,
205
+ onClick: unsubscribe
206
+ }, _d2I18n.default.t('Unsubscribe'))) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("p", {
207
+ className: "jsx-".concat(_AboutAOUnit.default.__hash) + " " + "subscriptionLabel"
208
+ }, _d2I18n.default.t('Subscribe to get updates about new interpretations.')), /*#__PURE__*/_react.default.createElement(_ui.Button, {
209
+ icon: /*#__PURE__*/_react.default.createElement(_ui.IconSubscribe24, {
210
+ color: _ui.colors.grey700
211
+ }),
212
+ secondary: true,
213
+ small: true,
214
+ disabled: subscribeIsLoading,
215
+ onClick: subscribe
216
+ }, _d2I18n.default.t('Subscribe')))))), /*#__PURE__*/_react.default.createElement(_style.default, {
217
+ id: _AboutAOUnit.default.__hash
218
+ }, _AboutAOUnit.default));
219
+ };
220
+
221
+ AboutAOUnit.propTypes = {
222
+ id: _propTypes.default.string.isRequired,
223
+ type: _propTypes.default.string.isRequired
224
+ };
225
+ var _default = AboutAOUnit;
226
+ exports.default = _default;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _ui = require("@dhis2/ui");
9
+
10
+ const _defaultExport = [".container.jsx-633421833{padding:".concat(_ui.spacers.dp16, ";border-bottom:1px solid ").concat(_ui.colors.grey400, ";background-color:").concat(_ui.colors.white, ";}"), ".expanded.jsx-633421833{padding-bottom:".concat(_ui.spacers.dp32, ";}"), ".loader.jsx-633421833{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".header.jsx-633421833{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;font-size:".concat(_ui.spacers.dp16, ";font-weight:500;line-height:21px;color:").concat(_ui.colors.grey900, ";}"), ".content.jsx-633421833{font-size:14px;line-height:18px;color:".concat(_ui.colors.grey900, ";}"), ".detailLine.jsx-633421833{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin:0;padding:".concat(_ui.spacers.dp12, " 0 0 0;gap:").concat(_ui.spacers.dp8, ";}"), ".detailLine.jsx-633421833 svg.jsx-633421833{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".noDescription.jsx-633421833{color:".concat(_ui.colors.grey600, ";}"), ".subsection.jsx-633421833{margin-top:".concat(_ui.spacers.dp24, ";}"), ".subsectionTitle.jsx-633421833{color:".concat(_ui.colors.grey700, ";font-weight:500;}"), ".subscriptionLabel.jsx-633421833{margin:".concat(_ui.spacers.dp12, " 0 ").concat(_ui.spacers.dp8, " 0;}"), ".subsection.jsx-633421833 button.jsx-633421833{margin-top:".concat(_ui.spacers.dp8, ";}")];
11
+ _defaultExport.__hash = "633421833";
12
+ var _default = _defaultExport;
13
+ exports.default = _default;
@@ -122,7 +122,7 @@ const OpenFileDialog = ({
122
122
  }
123
123
 
124
124
  if (filters.searchTerm) {
125
- queryFilters.push("name:ilike:".concat(filters.searchTerm));
125
+ queryFilters.push("displayName:ilike:".concat(filters.searchTerm));
126
126
  } // for ER 2.38 only show line list ER types
127
127
 
128
128
 
@@ -87,6 +87,12 @@ Object.defineProperty(exports, "LegendKey", {
87
87
  return _LegendKey.default;
88
88
  }
89
89
  });
90
+ Object.defineProperty(exports, "AboutAOUnit", {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _AboutAOUnit.default;
94
+ }
95
+ });
90
96
  Object.defineProperty(exports, "Analytics", {
91
97
  enumerable: true,
92
98
  get: function () {
@@ -951,6 +957,18 @@ Object.defineProperty(exports, "COLOR_SET_DEFAULT", {
951
957
  return _colorSets.COLOR_SET_DEFAULT;
952
958
  }
953
959
  });
960
+ Object.defineProperty(exports, "COLOR_SET_BASIC", {
961
+ enumerable: true,
962
+ get: function () {
963
+ return _colorSets.COLOR_SET_BASIC;
964
+ }
965
+ });
966
+ Object.defineProperty(exports, "COLOR_SET_EXTENDED", {
967
+ enumerable: true,
968
+ get: function () {
969
+ return _colorSets.COLOR_SET_EXTENDED;
970
+ }
971
+ });
954
972
  Object.defineProperty(exports, "COLOR_SET_BRIGHT", {
955
973
  enumerable: true,
956
974
  get: function () {
@@ -1142,6 +1160,8 @@ var _VisTypeIcon = _interopRequireDefault(require("./components/VisTypeIcon"));
1142
1160
 
1143
1161
  var _LegendKey = _interopRequireDefault(require("./components/LegendKey/LegendKey"));
1144
1162
 
1163
+ var _AboutAOUnit = _interopRequireDefault(require("./components/AboutAOUnit/AboutAOUnit"));
1164
+
1145
1165
  var _Analytics = _interopRequireDefault(require("./api/analytics/Analytics"));
1146
1166
 
1147
1167
  var _dimensions = require("./api/dimensions");
@@ -1,4 +1,21 @@
1
1
  {
2
+ "view only": "view only",
3
+ "view and edit": "view and edit",
4
+ "all users ({{accessLevel}})": "all users ({{accessLevel}})",
5
+ "{{userOrGroup}} ({{accessLevel}})": "{{userOrGroup}} ({{accessLevel}})",
6
+ "Shared with {{commaSeparatedListOfUsersAndGroups}}": "Shared with {{commaSeparatedListOfUsersAndGroups}}",
7
+ "Not shared with any users or groups": "Not shared with any users or groups",
8
+ "About this visualization": "About this visualization",
9
+ "No description": "No description",
10
+ "Last updated {{time}}": "Last updated {{time}}",
11
+ "Created {{time}} by {{author}}": "Created {{time}} by {{author}}",
12
+ "Viewed {{count}} times": "Viewed 1 time",
13
+ "Viewed {{count}} times_plural": "Viewed {{count}} times",
14
+ "Notifications": "Notifications",
15
+ "You're subscribed and getting updates about new interpretations.": "You're subscribed and getting updates about new interpretations.",
16
+ "Unsubscribe": "Unsubscribe",
17
+ "Subscribe to get updates about new interpretations.": "Subscribe to get updates about new interpretations.",
18
+ "Subscribe": "Subscribe",
2
19
  "Data Type": "Data Type",
3
20
  "All types": "All types",
4
21
  "Totals only": "Totals only",
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.colorSets = exports.COLOR_SET_PATTERNS = exports.COLOR_SET_COLOR_BLIND = exports.COLOR_SET_GRAY = exports.COLOR_SET_DARK = exports.COLOR_SET_BRIGHT = exports.COLOR_SET_DEFAULT = void 0;
6
+ exports.colorSets = exports.COLOR_SET_PATTERNS = exports.COLOR_SET_COLOR_BLIND = exports.COLOR_SET_GRAY = exports.COLOR_SET_DARK = exports.COLOR_SET_BRIGHT = exports.COLOR_SET_EXTENDED = exports.COLOR_SET_BASIC = exports.COLOR_SET_DEFAULT = void 0;
7
7
 
8
8
  var _highcharts = _interopRequireDefault(require("highcharts"));
9
9
 
@@ -14,6 +14,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  (0, _patternFill.default)(_highcharts.default);
15
15
  const COLOR_SET_DEFAULT = 'DEFAULT';
16
16
  exports.COLOR_SET_DEFAULT = COLOR_SET_DEFAULT;
17
+ const COLOR_SET_BASIC = 'BASIC';
18
+ exports.COLOR_SET_BASIC = COLOR_SET_BASIC;
19
+ const COLOR_SET_EXTENDED = 'EXTENDED';
20
+ exports.COLOR_SET_EXTENDED = COLOR_SET_EXTENDED;
17
21
  const COLOR_SET_BRIGHT = 'BRIGHT';
18
22
  exports.COLOR_SET_BRIGHT = COLOR_SET_BRIGHT;
19
23
  const COLOR_SET_DARK = 'DARK';
@@ -28,6 +32,12 @@ const colorSets = {
28
32
  [COLOR_SET_DEFAULT]: {
29
33
  colors: ['#a8bf24', '#518cc3', '#d74554', '#ff9e21', '#968f8f', '#ba3ba1', '#ffda54', '#45beae', '#b98037', '#676767', '#6b2dd4', '#47792c', '#fcbdbd', '#830000', '#a5ffc0', '#000078', '#817c00', '#bdf023', '#fffac4']
30
34
  },
35
+ [COLOR_SET_BASIC]: {
36
+ colors: ['#348F41', '#9F2241', '#DDDDDD', '#B4A269']
37
+ },
38
+ [COLOR_SET_EXTENDED]: {
39
+ colors: ['#194F90', '#AE1857', '#5B7E96', '#FFB71B', '#1DCAD3', '#FF5C35', '#8F4899', '#DAE343', '#385CAD', '#E81F76', '#009383', '#522B39']
40
+ },
31
41
  [COLOR_SET_BRIGHT]: {
32
42
  colors: ['#fd7f6f', '#8bd3c7', '#beb9db', '#7eb0d5', '#ffb55a', '#fdcce5', '#ffffaf', '#d9d9d9', '#bd7ebe', '#cbecc4', '#9fe778', '#ffef65']
33
43
  },
@@ -0,0 +1,203 @@
1
+ import _JSXStyle from "styled-jsx/style";
2
+ import { useDataQuery, useDataMutation } from '@dhis2/app-runtime';
3
+ import i18n from '@dhis2/d2-i18n';
4
+ import { Button, CircularLoader, IconChevronDown24, IconChevronUp24, IconClock16, IconShare16, IconSubscribe24, IconSubscribeOff24, IconUser16, IconView16, colors } from '@dhis2/ui';
5
+ import cx from 'classnames';
6
+ import moment from 'moment';
7
+ import PropTypes from 'prop-types';
8
+ import React, { useEffect, useMemo, useState } from 'react';
9
+ import styles from './styles/AboutAOUnit.style';
10
+ const READ_ONLY = 'r';
11
+ const READ_AND_WRITE = 'rw';
12
+
13
+ const getQueries = type => ({
14
+ ao: {
15
+ resource: type,
16
+ id: ({
17
+ id
18
+ }) => id,
19
+ params: {
20
+ fields: 'id,displayDescription,created,createdBy[displayName],lastUpdated,subscribed,publicAccess,userAccesses[displayName,access],userGroupAccesses[displayName,access]'
21
+ }
22
+ },
23
+ dataStatistics: {
24
+ resource: 'dataStatistics/favorites',
25
+ id: ({
26
+ id
27
+ }) => id
28
+ }
29
+ });
30
+
31
+ const getSubscribeMutation = (type, id) => ({
32
+ resource: "".concat(type, "/").concat(id, "/subscriber"),
33
+ type: 'create'
34
+ });
35
+
36
+ const getUnsubscribeMutation = (type, id) => ({
37
+ resource: "".concat(type, "/").concat(id, "/subscriber"),
38
+ type: 'delete'
39
+ });
40
+
41
+ const AboutAOUnit = ({
42
+ type,
43
+ id
44
+ }) => {
45
+ const [isExpanded, setIsExpanded] = useState(true);
46
+ const queries = useMemo(() => getQueries(type), []);
47
+ const {
48
+ data,
49
+ loading: dataIsLoading,
50
+ refetch
51
+ } = useDataQuery(queries, {
52
+ lazy: true
53
+ });
54
+ const subscribeMutation = useMemo(() => getSubscribeMutation(type, id), []);
55
+ const unsubscribeMutation = useMemo(() => getUnsubscribeMutation(type, id), []);
56
+ const [subscribe, {
57
+ loading: subscribeIsLoading
58
+ }] = useDataMutation(subscribeMutation, {
59
+ onComplete: res => {
60
+ if (res.status === 'OK') {
61
+ refetch({
62
+ id
63
+ });
64
+ }
65
+ }
66
+ });
67
+ const [unsubscribe, {
68
+ loading: unsubscribeIsLoading
69
+ }] = useDataMutation(unsubscribeMutation, {
70
+ onComplete: res => {
71
+ if (res.status === 'OK') {
72
+ refetch({
73
+ id
74
+ });
75
+ }
76
+ }
77
+ });
78
+ useEffect(() => {
79
+ if (id) {
80
+ refetch({
81
+ id
82
+ });
83
+ }
84
+ }, [type, id]);
85
+
86
+ const getAccessLevelString = access => {
87
+ const re = new RegExp("(?<accessLevel>".concat(READ_AND_WRITE, "?)"));
88
+ const accessMatch = re.exec(access);
89
+
90
+ switch (accessMatch.groups.accessLevel) {
91
+ case READ_ONLY:
92
+ return i18n.t('view only');
93
+
94
+ case READ_AND_WRITE:
95
+ return i18n.t('view and edit');
96
+ }
97
+ };
98
+
99
+ const getSharingSummary = ao => {
100
+ const sharingText = [];
101
+ const re = new RegExp("^".concat(READ_AND_WRITE, "?"));
102
+
103
+ if (re.test(ao.publicAccess)) {
104
+ sharingText.push(i18n.t('all users ({{accessLevel}})', {
105
+ accessLevel: getAccessLevelString(ao.publicAccess)
106
+ }));
107
+ }
108
+
109
+ const userAccesses = ao.userAccesses;
110
+ const groupAccesses = ao.userGroupAccesses;
111
+ userAccesses.concat(groupAccesses).forEach(accessRule => {
112
+ sharingText.push(i18n.t('{{userOrGroup}} ({{accessLevel}})', {
113
+ userOrGroup: accessRule.displayName,
114
+ accessLevel: getAccessLevelString(accessRule.access)
115
+ }));
116
+ });
117
+ return sharingText.length ? i18n.t('Shared with {{commaSeparatedListOfUsersAndGroups}}', {
118
+ commaSeparatedListOfUsersAndGroups: sharingText.join(', ')
119
+ }) : i18n.t('Not shared with any users or groups');
120
+ };
121
+
122
+ return /*#__PURE__*/React.createElement("div", {
123
+ className: "jsx-".concat(styles.__hash) + " " + (cx('container', {
124
+ expanded: isExpanded
125
+ }) || "")
126
+ }, /*#__PURE__*/React.createElement("div", {
127
+ onClick: () => setIsExpanded(!isExpanded),
128
+ className: "jsx-".concat(styles.__hash) + " " + "header"
129
+ }, i18n.t('About this visualization'), isExpanded ? /*#__PURE__*/React.createElement(IconChevronUp24, {
130
+ color: colors.grey700
131
+ }) : /*#__PURE__*/React.createElement(IconChevronDown24, {
132
+ color: colors.grey700
133
+ })), isExpanded && /*#__PURE__*/React.createElement(React.Fragment, null, dataIsLoading && /*#__PURE__*/React.createElement("div", {
134
+ className: "jsx-".concat(styles.__hash) + " " + "loader"
135
+ }, /*#__PURE__*/React.createElement(CircularLoader, {
136
+ small: true
137
+ })), data && /*#__PURE__*/React.createElement("div", {
138
+ className: "jsx-".concat(styles.__hash) + " " + "content"
139
+ }, /*#__PURE__*/React.createElement("p", {
140
+ className: "jsx-".concat(styles.__hash) + " " + (cx('detailLine', {
141
+ noDescription: !data.ao.displayDescription
142
+ }) || "")
143
+ }, data.ao.displayDescription ? data.ao.displayDescription : i18n.t('No description')), /*#__PURE__*/React.createElement("div", {
144
+ className: "jsx-".concat(styles.__hash)
145
+ }, /*#__PURE__*/React.createElement("p", {
146
+ className: "jsx-".concat(styles.__hash) + " " + "detailLine"
147
+ }, /*#__PURE__*/React.createElement(IconShare16, {
148
+ color: colors.grey700
149
+ }), getSharingSummary(data.ao)), /*#__PURE__*/React.createElement("p", {
150
+ className: "jsx-".concat(styles.__hash) + " " + "detailLine"
151
+ }, /*#__PURE__*/React.createElement(IconClock16, {
152
+ color: colors.grey700
153
+ }), i18n.t('Last updated {{time}}', {
154
+ time: moment(data.ao.lastUpdated).fromNow()
155
+ })), /*#__PURE__*/React.createElement("p", {
156
+ className: "jsx-".concat(styles.__hash) + " " + "detailLine"
157
+ }, /*#__PURE__*/React.createElement(IconUser16, {
158
+ color: colors.grey700
159
+ }), i18n.t('Created {{time}} by {{author}}', {
160
+ time: moment(data.ao.created).fromNow(),
161
+ author: data.ao.createdBy.displayName
162
+ })), /*#__PURE__*/React.createElement("p", {
163
+ className: "jsx-".concat(styles.__hash) + " " + "detailLine"
164
+ }, /*#__PURE__*/React.createElement(IconView16, {
165
+ color: colors.grey700
166
+ }), i18n.t('Viewed {{count}} times', {
167
+ count: data.dataStatistics.views,
168
+ defaultValue: 'Viewed 1 time',
169
+ defaultValue_plural: 'Viewed {{count}} times'
170
+ }))), /*#__PURE__*/React.createElement("div", {
171
+ className: "jsx-".concat(styles.__hash) + " " + "subsection"
172
+ }, /*#__PURE__*/React.createElement("span", {
173
+ className: "jsx-".concat(styles.__hash) + " " + "subsectionTitle"
174
+ }, i18n.t('Notifications')), data.ao.subscribed ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", {
175
+ className: "jsx-".concat(styles.__hash) + " " + "subscriptionLabel"
176
+ }, i18n.t("You're subscribed and getting updates about new interpretations.")), /*#__PURE__*/React.createElement(Button, {
177
+ icon: /*#__PURE__*/React.createElement(IconSubscribeOff24, {
178
+ color: colors.grey700
179
+ }),
180
+ secondary: true,
181
+ small: true,
182
+ disabled: unsubscribeIsLoading,
183
+ onClick: unsubscribe
184
+ }, i18n.t('Unsubscribe'))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", {
185
+ className: "jsx-".concat(styles.__hash) + " " + "subscriptionLabel"
186
+ }, i18n.t('Subscribe to get updates about new interpretations.')), /*#__PURE__*/React.createElement(Button, {
187
+ icon: /*#__PURE__*/React.createElement(IconSubscribe24, {
188
+ color: colors.grey700
189
+ }),
190
+ secondary: true,
191
+ small: true,
192
+ disabled: subscribeIsLoading,
193
+ onClick: subscribe
194
+ }, i18n.t('Subscribe')))))), /*#__PURE__*/React.createElement(_JSXStyle, {
195
+ id: styles.__hash
196
+ }, styles));
197
+ };
198
+
199
+ AboutAOUnit.propTypes = {
200
+ id: PropTypes.string.isRequired,
201
+ type: PropTypes.string.isRequired
202
+ };
203
+ export default AboutAOUnit;
@@ -0,0 +1,4 @@
1
+ import { colors, spacers } from '@dhis2/ui';
2
+ const _defaultExport = [".container.jsx-633421833{padding:".concat(spacers.dp16, ";border-bottom:1px solid ").concat(colors.grey400, ";background-color:").concat(colors.white, ";}"), ".expanded.jsx-633421833{padding-bottom:".concat(spacers.dp32, ";}"), ".loader.jsx-633421833{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}", ".header.jsx-633421833{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;font-size:".concat(spacers.dp16, ";font-weight:500;line-height:21px;color:").concat(colors.grey900, ";}"), ".content.jsx-633421833{font-size:14px;line-height:18px;color:".concat(colors.grey900, ";}"), ".detailLine.jsx-633421833{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;margin:0;padding:".concat(spacers.dp12, " 0 0 0;gap:").concat(spacers.dp8, ";}"), ".detailLine.jsx-633421833 svg.jsx-633421833{-webkit-flex-shrink:0;-ms-flex-negative:0;flex-shrink:0;}", ".noDescription.jsx-633421833{color:".concat(colors.grey600, ";}"), ".subsection.jsx-633421833{margin-top:".concat(spacers.dp24, ";}"), ".subsectionTitle.jsx-633421833{color:".concat(colors.grey700, ";font-weight:500;}"), ".subscriptionLabel.jsx-633421833{margin:".concat(spacers.dp12, " 0 ").concat(spacers.dp8, " 0;}"), ".subsection.jsx-633421833 button.jsx-633421833{margin-top:".concat(spacers.dp8, ";}")];
3
+ _defaultExport.__hash = "633421833";
4
+ export default _defaultExport;
@@ -96,7 +96,7 @@ export const OpenFileDialog = ({
96
96
  }
97
97
 
98
98
  if (filters.searchTerm) {
99
- queryFilters.push("name:ilike:".concat(filters.searchTerm));
99
+ queryFilters.push("displayName:ilike:".concat(filters.searchTerm));
100
100
  } // for ER 2.38 only show line list ER types
101
101
 
102
102
 
package/build/es/index.js CHANGED
@@ -12,7 +12,8 @@ export { default as DimensionMenu } from './components/DimensionMenu';
12
12
  export { default as PivotTable } from './components/PivotTable/PivotTable';
13
13
  export { default as FileMenu } from './components/FileMenu/FileMenu';
14
14
  export { default as VisTypeIcon } from './components/VisTypeIcon';
15
- export { default as LegendKey } from './components/LegendKey/LegendKey'; // Api
15
+ export { default as LegendKey } from './components/LegendKey/LegendKey';
16
+ export { default as AboutAOUnit } from './components/AboutAOUnit/AboutAOUnit'; // Api
16
17
 
17
18
  export { default as Analytics } from './api/analytics/Analytics';
18
19
  export { apiFetchDimensions, apiFetchRecommendedIds } from './api/dimensions';
@@ -79,7 +80,7 @@ export { FONT_STYLE_VISUALIZATION_TITLE, FONT_STYLE_VISUALIZATION_SUBTITLE, FONT
79
80
 
80
81
  export { LEGEND_DISPLAY_STRATEGY_BY_DATA_ITEM, LEGEND_DISPLAY_STRATEGY_FIXED, LEGEND_DISPLAY_STYLE_FILL, LEGEND_DISPLAY_STYLE_TEXT } from './modules/legends'; // Utils: colorSets
81
82
 
82
- export { COLOR_SET_DEFAULT, COLOR_SET_BRIGHT, COLOR_SET_DARK, COLOR_SET_GRAY, COLOR_SET_COLOR_BLIND, COLOR_SET_PATTERNS, colorSets } from './visualizations/util/colors/colorSets'; // Utils: periods
83
+ export { COLOR_SET_DEFAULT, COLOR_SET_BASIC, COLOR_SET_EXTENDED, COLOR_SET_BRIGHT, COLOR_SET_DARK, COLOR_SET_GRAY, COLOR_SET_COLOR_BLIND, COLOR_SET_PATTERNS, colorSets } from './visualizations/util/colors/colorSets'; // Utils: periods
83
84
 
84
85
  export { DAILY, WEEKLY, WEEKLYWED, WEEKLYTHU, WEEKLYSAT, WEEKLYSUN, BIWEEKLY, MONTHLY, BIMONTHLY, QUARTERLY, SIXMONTHLY, SIXMONTHLYAPR, YEARLY, FINANCIAL, FYNOV, FYOCT, FYJUL, FYAPR } from './components/PeriodDimension/utils';
85
86
  export { getRelativePeriodsOptionsById } from './components/PeriodDimension/utils/relativePeriods';
@@ -1,4 +1,21 @@
1
1
  {
2
+ "view only": "view only",
3
+ "view and edit": "view and edit",
4
+ "all users ({{accessLevel}})": "all users ({{accessLevel}})",
5
+ "{{userOrGroup}} ({{accessLevel}})": "{{userOrGroup}} ({{accessLevel}})",
6
+ "Shared with {{commaSeparatedListOfUsersAndGroups}}": "Shared with {{commaSeparatedListOfUsersAndGroups}}",
7
+ "Not shared with any users or groups": "Not shared with any users or groups",
8
+ "About this visualization": "About this visualization",
9
+ "No description": "No description",
10
+ "Last updated {{time}}": "Last updated {{time}}",
11
+ "Created {{time}} by {{author}}": "Created {{time}} by {{author}}",
12
+ "Viewed {{count}} times": "Viewed 1 time",
13
+ "Viewed {{count}} times_plural": "Viewed {{count}} times",
14
+ "Notifications": "Notifications",
15
+ "You're subscribed and getting updates about new interpretations.": "You're subscribed and getting updates about new interpretations.",
16
+ "Unsubscribe": "Unsubscribe",
17
+ "Subscribe to get updates about new interpretations.": "Subscribe to get updates about new interpretations.",
18
+ "Subscribe": "Subscribe",
2
19
  "Data Type": "Data Type",
3
20
  "All types": "All types",
4
21
  "Totals only": "Totals only",
@@ -2,6 +2,8 @@ import H from 'highcharts';
2
2
  import HPF from 'highcharts/modules/pattern-fill';
3
3
  HPF(H);
4
4
  export const COLOR_SET_DEFAULT = 'DEFAULT';
5
+ export const COLOR_SET_BASIC = 'BASIC';
6
+ export const COLOR_SET_EXTENDED = 'EXTENDED';
5
7
  export const COLOR_SET_BRIGHT = 'BRIGHT';
6
8
  export const COLOR_SET_DARK = 'DARK';
7
9
  export const COLOR_SET_GRAY = 'GRAY';
@@ -11,6 +13,12 @@ export const colorSets = {
11
13
  [COLOR_SET_DEFAULT]: {
12
14
  colors: ['#a8bf24', '#518cc3', '#d74554', '#ff9e21', '#968f8f', '#ba3ba1', '#ffda54', '#45beae', '#b98037', '#676767', '#6b2dd4', '#47792c', '#fcbdbd', '#830000', '#a5ffc0', '#000078', '#817c00', '#bdf023', '#fffac4']
13
15
  },
16
+ [COLOR_SET_BASIC]: {
17
+ colors: ['#348F41', '#9F2241', '#DDDDDD', '#B4A269']
18
+ },
19
+ [COLOR_SET_EXTENDED]: {
20
+ colors: ['#194F90', '#AE1857', '#5B7E96', '#FFB71B', '#1DCAD3', '#FF5C35', '#8F4899', '#DAE343', '#385CAD', '#E81F76', '#009383', '#522B39']
21
+ },
14
22
  [COLOR_SET_BRIGHT]: {
15
23
  colors: ['#fd7f6f', '#8bd3c7', '#beb9db', '#7eb0d5', '#ffb55a', '#fdcce5', '#ffffaf', '#d9d9d9', '#bd7ebe', '#cbecc4', '#9fe778', '#ffef65']
16
24
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2/analytics",
3
- "version": "20.6.5",
3
+ "version": "20.8.0",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/es/index.js",
6
6
  "exports": {