Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses-legacy
Commits
b2803e65
Commit
b2803e65
authored
4 years ago
by
Leonardo Piccioni de Almeida
Browse files
Options
Download
Email Patches
Plain Diff
Refactor data fetching to child components
parent
0c1e54ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
31 deletions
+51
-31
courses_legacy/static/js/reports/role-participation-report/role-participation-report.component.js
...rticipation-report/role-participation-report.component.js
+42
-8
courses_legacy/static/js/reports/user-participation-report/user-participation-report.component.js
...rticipation-report/user-participation-report.component.js
+2
-16
courses_legacy/templates/components/role-participation-report.template.html
...plates/components/role-participation-report.template.html
+5
-5
courses_legacy/templates/components/user-participation-report.template.html
...plates/components/user-participation-report.template.html
+2
-2
No files found.
courses_legacy/static/js/reports/role-participation-report/role-participation-report.component.js
View file @
b2803e65
...
...
@@ -8,27 +8,61 @@
controller
:
RoleParticipationReportCtrl
,
bindings
:
{
date
:
'
<
'
,
rol
es
:
'
<
'
,
total
:
'
<
'
,
citi
es
:
'
<
'
,
networks
:
'
<
'
,
ntes
:
'
<
'
,
redes
:
'
<
'
,
cities
:
'
<
'
},
});
RoleParticipationReportCtrl
.
$inject
=
[
'
$scope
'
];
RoleParticipationReportCtrl
.
$inject
=
[
'
$scope
'
,
'
RoleParticipationReport
'
];
function
RoleParticipationReportCtrl
(
$scope
)
{
function
RoleParticipationReportCtrl
(
$scope
,
RoleParticipationReport
)
{
var
ctrl
=
this
;
ctrl
.
city
=
''
;
ctrl
.
fetchRoles
=
fetchRoles
;
ctrl
.
minimized
=
false
;
ctrl
.
network
=
''
;
ctrl
.
nte
=
''
;
ctrl
.
roles
=
null
;
ctrl
.
toggleDetails
=
toggleDetails
;
ctrl
.
total
=
null
;
ctrl
.
$on
Init
=
function
()
{
ctrl
.
$on
Changes
=
function
()
{
fetchRoles
();
};
function
fetchRoles
()
{
var
params
=
{
date
:
ctrl
.
date
};
if
(
ctrl
.
city
)
{
}
if
(
ctrl
.
network
)
{
}
if
(
ctrl
.
nte
)
{
}
RoleParticipationReport
.
get
(
params
,
(
data
)
=>
{
ctrl
.
roles
=
data
;
ctrl
.
roles
.
$promise
=
undefined
;
ctrl
.
roles
.
$resolved
=
undefined
;
ctrl
.
total
=
{
actives
:
0
,
not_actives
:
0
,
not_involved
:
0
,
total
:
0
};
Object
.
values
(
ctrl
.
roles
).
forEach
((
role
)
=>
{
if
(
role
!==
undefined
)
{
ctrl
.
total
.
actives
+=
role
.
actives
;
ctrl
.
total
.
not_actives
+=
role
.
not_actives
;
ctrl
.
total
.
not_involved
+=
role
.
not_involved
;
ctrl
.
total
.
total
+=
role
.
actives
+
role
.
not_actives
+
role
.
not_involved
;
}
});
});
}
function
toggleDetails
()
{
ctrl
.
minimized
=
!
ctrl
.
minimized
;
}
...
...
This diff is collapsed.
Click to expand it.
courses_legacy/static/js/reports/user-participation-report/user-participation-report.component.js
View file @
b2803e65
...
...
@@ -18,27 +18,13 @@
var
ctrl
=
this
;
ctrl
.
date
=
new
Date
();
ctrl
.
filters
=
null
;
ctrl
.
formatDate
=
formatDate
;
ctrl
.
formattedDate
=
formatDate
(
ctrl
.
date
);
ctrl
.
report_filters
=
null
;
ctrl
.
$onInit
=
function
()
{
GeneralFilterOptions
.
get
({},
(
data
)
=>
{
ctrl
.
report_filters
=
data
;
});
RoleParticipationReport
.
get
({},
(
data
)
=>
{
ctrl
.
roles_reports
=
data
;
ctrl
.
roles_reports
.
$promise
=
undefined
;
ctrl
.
roles_reports
.
$resolved
=
undefined
;
ctrl
.
roles_total
=
{
'
actives
'
:
0
,
'
not_actives
'
:
0
,
'
not_involved
'
:
0
,
'
total
'
:
0
}
Object
.
entries
(
ctrl
.
roles_reports
).
forEach
(([
role
,
participation
])
=>
{
if
(
participation
!==
undefined
)
{
ctrl
.
roles_total
[
'
actives
'
]
+=
participation
.
actives
;
ctrl
.
roles_total
[
'
not_actives
'
]
+=
participation
.
not_actives
;
ctrl
.
roles_total
[
'
not_involved
'
]
+=
participation
.
not_involved
;
ctrl
.
roles_total
[
'
total
'
]
+=
participation
.
actives
+
participation
.
not_actives
+
participation
.
not_involved
;
}
});
ctrl
.
filters
=
data
;
});
};
...
...
This diff is collapsed.
Click to expand it.
courses_legacy/templates/components/role-participation-report.template.html
View file @
b2803e65
{% verbatim %}
<section
class=
"widget container-fluid"
>
<section
class=
"widget container-fluid"
ng-if=
"$ctrl.roles"
>
<header
class=
"widget-header"
>
<div
class=
"row"
>
<div
class=
"col-sm-12 col-md-12"
>
...
...
@@ -18,15 +18,15 @@
<main
class=
"widget-body"
ng-if=
"!$ctrl.minimized"
>
<div
class=
"filter-row"
>
<span>
Filtre a lista:
</span>
<select
name=
"nte"
aria-label=
"NTE"
>
<select
name=
"nte"
aria-label=
"NTE"
ng-model=
"$ctrl.nte"
ng-blur=
"$ctrl.fetchRoles()"
>
<option
value=
""
>
Selecione o NTE
</option>
<option
ng-repeat=
"nte in $ctrl.ntes"
ng-value=
"nte"
>
{{ nte }}
</option>
</select>
<select
name=
"network"
aria-label=
"Rede"
>
<select
name=
"network"
aria-label=
"Rede"
ng-model=
"$ctrl.network"
ng-blur=
"$ctrl.fetchRoles()"
>
<option
value=
""
>
Selecione a Rede
</option>
<option
ng-repeat=
"
rede
in $ctrl.
rede
s"
ng-value=
"
rede"
>
{{ rede
}}
</option>
<option
ng-repeat=
"
network
in $ctrl.
network
s"
ng-value=
"
network"
>
{{ network
}}
</option>
</select>
<select
name=
"city"
aria-label=
"Município"
>
<select
name=
"city"
aria-label=
"Município"
ng-model=
"$ctrl.city"
ng-blur=
"$ctrl.fetchRoles()"
>
<option
value=
""
>
Selecione o Município
</option>
<option
ng-repeat=
"city in $ctrl.cities"
ng-value=
"city"
>
{{ city }}
</option>
</select>
...
...
This diff is collapsed.
Click to expand it.
courses_legacy/templates/components/user-participation-report.template.html
View file @
b2803e65
...
...
@@ -16,11 +16,11 @@
<user-participation-graphics-report
date=
"$ctrl.formattedDate"
></user-participation-graphics-report>
<city-participation-report-list
ng-if=
"$ctrl.
report_
filters"
date=
"$ctrl.formattedDate"
roles=
"$ctrl.
report_
filters.funcoes"
></city-participation-report-list>
<city-participation-report-list
ng-if=
"$ctrl.filters"
date=
"$ctrl.formattedDate"
roles=
"$ctrl.filters.funcoes"
></city-participation-report-list>
<classroom-participation-report
date=
"$ctrl.formattedDate"
></classroom-participation-report>
<role-participation-report
teste
=
"$ctrl.
report_filters.ntes"
roles=
"$ctrl.roles_reports"
total=
"$ctrl.roles_total"
nt
es=
"$ctrl.
report_
filters.
ntes"
rede
s=
"$ctrl.
report_
filters.redes"
citi
es=
"$ctrl.
report_
filters.
municipio
s"
></role-participation-report>
<role-participation-report
ng-if
=
"$ctrl.
filters"
date=
"$ctrl.formattedDate"
citi
es=
"$ctrl.filters.
municipios"
network
s=
"$ctrl.filters.redes"
nt
es=
"$ctrl.filters.
nte
s"
></role-participation-report>
</div>
{% endverbatim %}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment