-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update essentials version chore: update styles to remove background
- Loading branch information
1 parent
ff69441
commit 3c81d49
Showing
18 changed files
with
351 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
eox_nelp/static/tenant_stats/js/tenant_stats.js.LICENSE.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
object-assign | ||
(c) Sindre Sorhus | ||
@license MIT | ||
*/ | ||
|
||
/*! | ||
Copyright (c) 2018 Jed Watson. | ||
Licensed under the MIT License (MIT), see | ||
http://jedwatson.github.io/classnames | ||
*/ | ||
|
||
/*! | ||
localForage -- Offline Storage, Improved | ||
Version 1.10.0 | ||
https://localforage.github.io/localForage | ||
(c) 2013-2017 Mozilla, Apache License 2.0 | ||
*/ | ||
|
||
/*! | ||
* cookie | ||
* Copyright(c) 2012-2014 Roman Shtylman | ||
* Copyright(c) 2015 Douglas Christopher Wilson | ||
* MIT Licensed | ||
*/ | ||
|
||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ | ||
|
||
/** | ||
* @mui/styled-engine v5.13.2 | ||
* | ||
* @license MIT | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** @license React v0.19.1 | ||
* scheduler.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** @license React v16.13.1 | ||
* react-is.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** @license React v16.14.0 | ||
* react-dom.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** @license React v16.14.0 | ||
* react-jsx-runtime.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/** @license React v16.14.0 | ||
* react.production.min.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ |
Empty file.
29 changes: 29 additions & 0 deletions
29
eox_nelp/stats/frontend/src/components/TenantStats/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { useState} from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { APP_INIT_ERROR, APP_READY, subscribe, initialize } from '@edx/frontend-platform'; | ||
import { getLocale, getMessages, IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import { StatsContainer, messages as essentialsMessages } from '@edunext/frontend-essentials' | ||
|
||
import './index.scss'; | ||
|
||
function LaunchStatsContainer() { | ||
const [locale, setLocale] = useState(getLocale()); | ||
|
||
return ( | ||
<IntlProvider locale={locale} messages={getMessages()}> | ||
<StatsContainer | ||
showVideos={showVideos} | ||
showCourses={showCourses} | ||
showProblems={showProblems} | ||
showLearners={showLearners} | ||
showInstructors={showInstructors} | ||
/> | ||
</IntlProvider> | ||
); | ||
} | ||
|
||
subscribe(APP_READY, () => { | ||
ReactDOM.render(<LaunchStatsContainer />, document.getElementById('tenant-stats')); | ||
}); | ||
|
||
initialize({ messages: [essentialsMessages]}); |
16 changes: 16 additions & 0 deletions
16
eox_nelp/stats/frontend/src/components/TenantStats/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@import "~@edx/brand/paragon/fonts"; | ||
@import "~@edx/brand/paragon/variables"; | ||
@import "~@edx/paragon/scss/core/core"; | ||
@import "~@edx/brand/paragon/overrides"; | ||
|
||
body { | ||
background-color: transparent; | ||
|
||
#tenant-stats{ | ||
.stats-container{ | ||
margin: 0; | ||
width: auto; | ||
} | ||
} | ||
} | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%namespace name='static' file='static_content.html'/> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Tenant Stats</title> | ||
<link rel="stylesheet" href="${static.url('tenant_stats/css/tenant_stats.css')}"> | ||
</head> | ||
<body> | ||
<div id="tenant-stats"></div> | ||
<script> | ||
var showVideos = "true" === "${showVideos}"; | ||
var showCourses = "true" === "${showCourses}"; | ||
var showProblems = "true" === "${showProblems}"; | ||
var showLearners = "true" === "${showLearners}"; | ||
var showInstructors = "true" === "${showInstructors}"; | ||
</script> | ||
<script src="${static.url('tenant_stats/js/tenant_stats.js')}"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"""This file contains all the test for the stats views.py file. | ||
Classes: | ||
GetTenantStatsTestCase: Test get_tenant_stats function based view. | ||
""" | ||
from ddt import data, ddt | ||
from django.test import Client, TestCase | ||
from django.urls import reverse | ||
from rest_framework import status | ||
|
||
|
||
@ddt | ||
class GetTenantStatsTestCase(TestCase): | ||
""" Test get_tenant_stats function based view.""" | ||
|
||
def setUp(self): # pylint: disable=invalid-name | ||
""" | ||
Set base variables and objects across experience test cases. | ||
""" | ||
self.client = Client() | ||
self.template_name = "tenant_stats.html" | ||
|
||
def test_get_default_stats(self): | ||
""" | ||
Test that the default behavior, that is just render the tenant-stats div | ||
Expected behavior: | ||
- Status code 200. | ||
- template name is as expected. | ||
- tenant-stats div exist | ||
""" | ||
url_endpoint = reverse("stats:tenant") | ||
|
||
response = self.client.get(url_endpoint) | ||
|
||
self.assertEqual(status.HTTP_200_OK, response.status_code) | ||
self.assertEqual(self.template_name, response.templates[0].name) | ||
self.assertContains(response, '<div id="tenant-stats"></div') | ||
|
||
@data("showVideos", "showCourse", "showProblems", "showInstructors", "showLearners") | ||
def test_get_specific_stat(self, query_param): | ||
""" | ||
Test that the view render successfully when a query param is included | ||
Expected behavior: | ||
- Status code 200. | ||
- template name is as expected. | ||
- tenant-stats div exist | ||
- the query param is 'true' | ||
- CSS was included | ||
- JS was included | ||
""" | ||
url_endpoint = f"{reverse('stats:tenant')}?{query_param}=true" | ||
|
||
response = self.client.get(url_endpoint) | ||
|
||
self.assertEqual(status.HTTP_200_OK, response.status_code) | ||
self.assertEqual(self.template_name, response.templates[0].name) | ||
self.assertContains(response, '<div id="tenant-stats"></div') | ||
self.assertEqual("true", response.context[query_param]) | ||
self.assertContains(response, "tenant_stats/css/tenant_stats.css") | ||
self.assertContains(response, "tenant_stats/js/tenant_stats.js") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"""frontend templates urls for course_experience""" | ||
from django.urls import path | ||
|
||
from eox_nelp.stats.views import get_tenant_stats | ||
|
||
app_name = "eox_nelp" # pylint: disable=invalid-name | ||
|
||
urlpatterns = [ | ||
path('tenant/', get_tenant_stats, name='tenant') | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""Stats Views file. | ||
Contains all the views for stats | ||
classes: | ||
get_tenant_stats: function based view. | ||
""" | ||
|
||
from eox_nelp.templates_config import render_to_response | ||
|
||
|
||
def get_tenant_stats(request): | ||
""" | ||
Simple function based view that renders the StatsContainer essential component. | ||
By default this show nothing since this requires the specific query para to show the content. | ||
Examples: | ||
renders just video card /eox-nelp/stats/tenant/?showVideos=true | ||
render multiple components | ||
/eox-nelp/stats/tenant/?showVideos=true&showCourses=true&showInstructors=true | ||
The available options are: | ||
showVideos | ||
showCourses | ||
showLearners | ||
showInstructors | ||
showProblems | ||
""" | ||
|
||
context = { | ||
"showCourses": "false", | ||
"showVideos": "false", | ||
"showProblems": "false", | ||
"showLearners": "false", | ||
"showInstructors": "false", | ||
} | ||
context.update(request.GET.dict()) | ||
|
||
return render_to_response("tenant_stats.html", context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters