platform-plugin-aspects 0.3.1__tar.gz → 0.4.0__tar.gz

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.
Files changed (47) hide show
  1. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/CHANGELOG.rst +8 -0
  2. {platform-plugin-aspects-0.3.1/platform_plugin_aspects.egg-info → platform-plugin-aspects-0.4.0}/PKG-INFO +9 -1
  3. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/__init__.py +1 -1
  4. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/extensions/filters.py +2 -2
  5. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/settings/common.py +6 -1
  6. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/settings/production.py +2 -4
  7. platform-plugin-aspects-0.4.0/platform_plugin_aspects/static/css/superset.css +53 -0
  8. platform-plugin-aspects-0.4.0/platform_plugin_aspects/static/html/superset.html +37 -0
  9. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/static/js/embed_dashboard.js +6 -3
  10. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/templates/instructor_dashboard/aspects.html +1 -1
  11. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/utils.py +12 -12
  12. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/xblock.py +11 -2
  13. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0/platform_plugin_aspects.egg-info}/PKG-INFO +9 -1
  14. platform-plugin-aspects-0.3.1/platform_plugin_aspects/static/css/superset.css +0 -5
  15. platform-plugin-aspects-0.3.1/platform_plugin_aspects/static/html/superset.html +0 -25
  16. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/LICENSE +0 -0
  17. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/MANIFEST.in +0 -0
  18. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/README.rst +0 -0
  19. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/apps.py +0 -0
  20. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/extensions/__init__.py +0 -0
  21. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/management/__init__.py +0 -0
  22. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/management/commands/__init__.py +0 -0
  23. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/management/commands/dump_data_to_clickhouse.py +0 -0
  24. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/settings/__init__.py +0 -0
  25. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/signals.py +0 -0
  26. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/sinks/__init__.py +0 -0
  27. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/sinks/base_sink.py +0 -0
  28. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/sinks/course_overview_sink.py +0 -0
  29. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/sinks/external_id_sink.py +0 -0
  30. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/sinks/serializers.py +0 -0
  31. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/sinks/user_profile_sink.py +0 -0
  32. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/sinks/user_retire_sink.py +0 -0
  33. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/static/html/superset_student.html +0 -0
  34. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/static/js/install_required.js +0 -0
  35. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/static/js/superset.js +0 -0
  36. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/tasks.py +0 -0
  37. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects/waffle.py +0 -0
  38. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects.egg-info/SOURCES.txt +0 -0
  39. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects.egg-info/dependency_links.txt +0 -0
  40. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects.egg-info/entry_points.txt +0 -0
  41. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects.egg-info/not-zip-safe +0 -0
  42. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects.egg-info/requires.txt +0 -0
  43. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/platform_plugin_aspects.egg-info/top_level.txt +0 -0
  44. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/requirements/base.in +0 -0
  45. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/requirements/constraints.txt +0 -0
  46. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/setup.cfg +0 -0
  47. {platform-plugin-aspects-0.3.1 → platform-plugin-aspects-0.4.0}/setup.py +0 -0
@@ -16,6 +16,14 @@ Unreleased
16
16
 
17
17
  *
18
18
 
19
+ 0.4.0 - 2024-03-18
20
+ ******************
21
+
22
+ Added
23
+ =====
24
+
25
+ * Embed multiple Superset Dashboards.
26
+
19
27
  0.3.1 - 2024-03-14
20
28
  ******************
21
29
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platform-plugin-aspects
3
- Version: 0.3.1
3
+ Version: 0.4.0
4
4
  Summary: Aspects plugins for edx-platform
5
5
  Home-page: https://github.com/openedx/platform-plugin-aspects
6
6
  Author: Open edX Project
@@ -149,6 +149,14 @@ Unreleased
149
149
 
150
150
  *
151
151
 
152
+ 0.4.0 - 2024-03-18
153
+ ******************
154
+
155
+ Added
156
+ =====
157
+
158
+ * Embed multiple Superset Dashboards.
159
+
152
160
  0.3.1 - 2024-03-14
153
161
  ******************
154
162
 
@@ -5,6 +5,6 @@ Aspects plugins for edx-platform.
5
5
  import os
6
6
  from pathlib import Path
7
7
 
8
- __version__ = "0.3.1"
8
+ __version__ = "0.4.0"
9
9
 
10
10
  ROOT_DIRECTORY = Path(os.path.dirname(os.path.abspath(__file__)))
@@ -35,7 +35,7 @@ class AddSupersetTab(PipelineStep):
35
35
  _ (str): instructor dashboard template name.
36
36
  """
37
37
  course = context["course"]
38
- dashboard_uuid = settings.ASPECTS_INSTRUCTOR_DASHBOARD_UUID
38
+ dashboards = settings.ASPECTS_INSTRUCTOR_DASHBOARDS
39
39
  extra_filters_format = settings.SUPERSET_EXTRA_FILTERS_FORMAT
40
40
 
41
41
  filters = ASPECTS_SECURITY_FILTERS_FORMAT + extra_filters_format
@@ -45,7 +45,7 @@ class AddSupersetTab(PipelineStep):
45
45
  context = generate_superset_context(
46
46
  context,
47
47
  user,
48
- dashboard_uuid=dashboard_uuid,
48
+ dashboards=dashboards,
49
49
  filters=filters,
50
50
  )
51
51
 
@@ -20,7 +20,12 @@ def plugin_settings(settings):
20
20
  "username": "superset",
21
21
  "password": "superset",
22
22
  }
23
- settings.ASPECTS_INSTRUCTOR_DASHBOARD_UUID = "1d6bf904-f53f-47fd-b1c9-6cd7e284d286"
23
+ settings.ASPECTS_INSTRUCTOR_DASHBOARDS = [
24
+ {
25
+ "name": "Instructor Dashboard",
26
+ "uuid": "1d6bf904-f53f-47fd-b1c9-6cd7e284d286",
27
+ },
28
+ ]
24
29
  settings.SUPERSET_EXTRA_FILTERS_FORMAT = []
25
30
  settings.EVENT_SINK_CLICKHOUSE_BACKEND_CONFIG = {
26
31
  # URL to a running ClickHouse server's HTTP interface. ex: https://foo.openedx.org:8443/ or
@@ -11,10 +11,8 @@ def plugin_settings(settings):
11
11
  settings.SUPERSET_CONFIG = getattr(settings, "ENV_TOKENS", {}).get(
12
12
  "SUPERSET_CONFIG", settings.SUPERSET_CONFIG
13
13
  )
14
- settings.ASPECTS_INSTRUCTOR_DASHBOARD_UUID = getattr(
15
- settings, "ENV_TOKENS", {}
16
- ).get(
17
- "ASPECTS_INSTRUCTOR_DASHBOARD_UUID", settings.ASPECTS_INSTRUCTOR_DASHBOARD_UUID
14
+ settings.ASPECTS_INSTRUCTOR_DASHBOARDS = getattr(settings, "ENV_TOKENS", {}).get(
15
+ "ASPECTS_INSTRUCTOR_DASHBOARDS", settings.ASPECTS_INSTRUCTOR_DASHBOARDS
18
16
  )
19
17
  settings.SUPERSET_EXTRA_FILTERS_FORMAT = getattr(settings, "ENV_TOKENS", {}).get(
20
18
  "SUPERSET_EXTRA_FILTERS_FORMAT", settings.SUPERSET_EXTRA_FILTERS_FORMAT
@@ -0,0 +1,53 @@
1
+ .superset-embedded-container>iframe {
2
+ height: 920px;
3
+ width: 100%;
4
+ display: block;
5
+ border: none;
6
+ }
7
+
8
+ .aspects-tabs {
9
+ position: relative;
10
+ min-height: 920px;
11
+ /* This part sucks */
12
+ clear: both;
13
+ margin: 25px 0;
14
+ }
15
+
16
+ .aspects-tab {
17
+ float: left;
18
+ }
19
+
20
+ .aspects-tab label {
21
+ background: #eee;
22
+ padding: 10px;
23
+ border: 1px solid #ccc;
24
+ margin-left: -1px;
25
+ position: relative;
26
+ left: 1px;
27
+ bottom: 5px;
28
+ }
29
+
30
+ .aspects-tab [type=radio] {
31
+ display: none;
32
+ }
33
+
34
+ .aspects-content {
35
+ position: absolute;
36
+ top: 28px;
37
+ left: 0;
38
+ background: white;
39
+ right: 0;
40
+ bottom: 0;
41
+ padding: 0;
42
+ border: 1px solid #ccc;
43
+ }
44
+
45
+ [type=radio]:checked~label {
46
+ background: white;
47
+ border-bottom: 1px solid white;
48
+ z-index: 2;
49
+ }
50
+
51
+ [type=radio]:checked~label~.aspects-content {
52
+ z-index: 1;
53
+ }
@@ -0,0 +1,37 @@
1
+ {% load i18n %}
2
+
3
+ <script src="https://unpkg.com/@superset-ui/embedded-sdk"></script>
4
+
5
+ <div class="aspects-wrapper" width="fit-content">
6
+ <h2>{{display_name}}</h2>
7
+
8
+ {% if exception %}
9
+ <p>{% trans 'Superset is not configured properly. Please contact your system administrator.'%}</p>
10
+ <p>{{exception}}</p>
11
+ {% elif not superset_dashboards %}
12
+ <p>Dashboard UUID is not set. Please set the dashboard UUID in the Studio.</p>
13
+ {% elif superset_url and superset_token %} {% if xblock_id %}
14
+ <div class="superset-embedded-container" id="superset-embedded-container-{{xblock_id}}"></div>
15
+ {% else %}
16
+ <div class="aspects-tabs">
17
+ {% for dashboard in superset_dashboards %}
18
+ <div class="aspects-tab">
19
+ {% if forloop.counter == 1 %}
20
+ <input type="radio" id="tab-{{forloop.counter}}" name="tab-group-1" checked="checked" />
21
+ {% else %}
22
+ <input type="radio" id="tab-{{forloop.counter}}" name="tab-group-1" />
23
+ {% endif %}
24
+ <label for="tab-{{forloop.counter}}">{{dashboard.name}}</label>
25
+ <div class="aspects-content superset-embedded-container" id="superset-embedded-container-{{dashboard.uuid}}"></div>
26
+ </div>
27
+ {% endfor %}
28
+ </div>
29
+ {% endif %}
30
+
31
+ <script type="text/javascript">
32
+ window.superset_dashboards = {{superset_dashboards | safe }};
33
+ window.superset_url = "{{superset_url}}";
34
+ window.superset_token = "{{superset_token}}";
35
+ </script>
36
+ {% endif %}
37
+ </div>
@@ -24,7 +24,10 @@ function embedDashboard(dashboard_uuid, superset_url, superset_token, xblock_id)
24
24
  when the dashboard is loaded
25
25
  */
26
26
  });
27
- }
28
- if (window.dashboard_uuid !== undefined) {
29
- embedDashboard(window.dashboard_uuid, window.superset_url, window.superset_token, window.xblock_id);
27
+ };
28
+
29
+ if (window.superset_dashboards !== undefined) {
30
+ window.superset_dashboards.forEach(function(dashboard) {
31
+ embedDashboard(dashboard.uuid, window.superset_url, window.superset_token, dashboard.uuid);
32
+ });
30
33
  }
@@ -14,7 +14,7 @@ superset_url = section_data.get("superset_url")
14
14
  <section class="superset">
15
15
  % if superset_url:
16
16
  <div class="superset-link">
17
- <a href="${superset_url}">${_("Go to Superset")}</a>
17
+ <a href="${superset_url}login/openedxsso">${_("Go to Superset to create new or further customize the reports below.")}</a>
18
18
  </div>
19
19
  % endif
20
20
  ${HTML(section_data['fragment'].body_html())}
@@ -28,7 +28,7 @@ def _(text):
28
28
  def generate_superset_context( # pylint: disable=dangerous-default-value
29
29
  context,
30
30
  user,
31
- dashboard_uuid=None,
31
+ dashboards,
32
32
  filters=[],
33
33
  ):
34
34
  """
@@ -38,17 +38,17 @@ def generate_superset_context( # pylint: disable=dangerous-default-value
38
38
  context (dict): the context for the instructor dashboard. It must include a course object
39
39
  user (XBlockUser or User): the current user.
40
40
  superset_config (dict): superset config.
41
- dashboard_uuid (str): superset dashboard uuid.
41
+ dashboards (list): list of superset dashboard uuid.
42
42
  filters (list): list of filters to apply to the dashboard.
43
43
  """
44
44
  course = context["course"]
45
45
  superset_config = settings.SUPERSET_CONFIG
46
46
 
47
- superset_token, dashboard_uuid = _generate_guest_token(
47
+ superset_token, dashboards = _generate_guest_token(
48
48
  user=user,
49
49
  course=course,
50
50
  superset_config=superset_config,
51
- dashboard_uuid=dashboard_uuid,
51
+ dashboards=dashboards,
52
52
  filters=filters,
53
53
  )
54
54
 
@@ -57,21 +57,21 @@ def generate_superset_context( # pylint: disable=dangerous-default-value
57
57
  context.update(
58
58
  {
59
59
  "superset_token": superset_token,
60
- "dashboard_uuid": dashboard_uuid,
60
+ "superset_dashboards": dashboards,
61
61
  "superset_url": superset_url,
62
62
  }
63
63
  )
64
64
  else:
65
65
  context.update(
66
66
  {
67
- "exception": str(dashboard_uuid),
67
+ "exception": str(dashboards),
68
68
  }
69
69
  )
70
70
 
71
71
  return context
72
72
 
73
73
 
74
- def _generate_guest_token(user, course, superset_config, dashboard_uuid, filters):
74
+ def _generate_guest_token(user, course, superset_config, dashboards, filters):
75
75
  """
76
76
  Generate a Superset guest token for the user.
77
77
 
@@ -102,16 +102,16 @@ def _generate_guest_token(user, course, superset_config, dashboard_uuid, filters
102
102
 
103
103
  formatted_filters = [filter.format(course=course, user=user) for filter in filters]
104
104
 
105
- if not dashboard_uuid:
106
- dashboard_uuid = settings.ASPECTS_INSTRUCTOR_DASHBOARD_UUID
107
-
108
105
  data = {
109
106
  "user": _superset_user_data(user),
110
- "resources": [{"type": "dashboard", "id": dashboard_uuid}],
107
+ "resources": [
108
+ {"type": "dashboard", "id": dashboard["uuid"]} for dashboard in dashboards
109
+ ],
111
110
  "rls": [{"clause": filter} for filter in formatted_filters],
112
111
  }
113
112
 
114
113
  try:
114
+ logger.info(f"Requesting guest token from Superset, {data}")
115
115
  response = client.session.post(
116
116
  url=f"{superset_internal_host}api/v1/security/guest_token/",
117
117
  json=data,
@@ -120,7 +120,7 @@ def _generate_guest_token(user, course, superset_config, dashboard_uuid, filters
120
120
  response.raise_for_status()
121
121
  token = response.json()["token"]
122
122
 
123
- return token, dashboard_uuid
123
+ return token, dashboards
124
124
  except Exception as exc: # pylint: disable=broad-except
125
125
  logger.error(exc)
126
126
  return None, exc
@@ -55,6 +55,15 @@ class SupersetXBlock(StudioEditableXBlockMixin, XBlock):
55
55
  scope=Scope.settings,
56
56
  )
57
57
 
58
+ def dashboards(self):
59
+ """
60
+ Return an array of dashboards configured for this XBlock.
61
+ """
62
+ if self.dashboard_uuid:
63
+ return [{"name": self.display_name, "uuid": self.dashboard_uuid}]
64
+ else:
65
+ return []
66
+
58
67
  def render_template(self, template_path, context=None) -> str:
59
68
  """
60
69
  Render a template with the given context.
@@ -104,7 +113,7 @@ class SupersetXBlock(StudioEditableXBlockMixin, XBlock):
104
113
  context = generate_superset_context(
105
114
  context=context,
106
115
  user=user,
107
- dashboard_uuid=self.dashboard_uuid,
116
+ dashboards=self.dashboards(),
108
117
  filters=self.filters,
109
118
  )
110
119
  context["xblock_id"] = str(self.scope_ids.usage_id.block_id)
@@ -125,7 +134,7 @@ class SupersetXBlock(StudioEditableXBlockMixin, XBlock):
125
134
  frag.initialize_js(
126
135
  "SupersetXBlock",
127
136
  json_args={
128
- "dashboard_uuid": context.get("dashboard_uuid"),
137
+ "dashboard_uuid": self.dashboard_uuid,
129
138
  "superset_url": context.get("superset_url"),
130
139
  "superset_token": context.get("superset_token"),
131
140
  "xblock_id": context.get("xblock_id"),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: platform-plugin-aspects
3
- Version: 0.3.1
3
+ Version: 0.4.0
4
4
  Summary: Aspects plugins for edx-platform
5
5
  Home-page: https://github.com/openedx/platform-plugin-aspects
6
6
  Author: Open edX Project
@@ -149,6 +149,14 @@ Unreleased
149
149
 
150
150
  *
151
151
 
152
+ 0.4.0 - 2024-03-18
153
+ ******************
154
+
155
+ Added
156
+ =====
157
+
158
+ * Embed multiple Superset Dashboards.
159
+
152
160
  0.3.1 - 2024-03-14
153
161
  ******************
154
162
 
@@ -1,5 +0,0 @@
1
- .superset-embedded-container > iframe {
2
- height: 720px;
3
- width: 100%;
4
- display: block;
5
- }
@@ -1,25 +0,0 @@
1
- {% load i18n %}
2
-
3
- <script src="https://unpkg.com/@superset-ui/embedded-sdk"></script>
4
-
5
- <div class="email-notifier-instructor-wrapper" width="parent">
6
- <h2>{{display_name}}</h2>
7
-
8
- {% if exception %}
9
- <p>{% trans 'Superset is not configured properly. Please contact your system administrator.'%}</p>
10
- <p>
11
- {{exception}}
12
- </p>
13
- {% elif not dashboard_uuid %}
14
- <p>
15
- Dashboard UUID is not set. Please set the dashboard UUID in the Studio. {{dashboard_uuid}}
16
- </p>
17
- {% elif superset_url and superset_token %}
18
- <div class="superset-embedded-container" id="superset-embedded-container-{{xblock_id}}"></div>
19
- <script type="text/javascript">
20
- window.dashboard_uuid ="{{dashboard_uuid}}";
21
- window.superset_url = "{{superset_url}}";
22
- window.superset_token = "{{superset_token}}";
23
- </script>
24
- {% endif %}
25
- </div>