ode-ngjs-front 1.4.12-develop-integration.202507011402 → 1.4.12-develop-b2school.202507031501
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/dist/ode-ngjs-front.js +2 -2
- package/dist/ode-ngjs-front.js.map +1 -1
- package/dist/ts/directives/business/portal/navbar.directive.d.ts.map +1 -1
- package/dist/ts/directives/business/portal/portal.directive.d.ts.map +1 -1
- package/dist/ts/modules/widgets.module.d.ts +1 -3
- package/dist/ts/modules/widgets.module.d.ts.map +1 -1
- package/dist/ts/services/theme-helper.service.d.ts.map +1 -1
- package/dist/version.txt +1 -1
- package/package.json +2 -3
- package/dist/668.js +0 -21
- package/dist/668.js.map +0 -1
- package/dist/ts/widgets/ptit-observatoire-widget/ptit-observatoire-widget.widget.d.ts +0 -2
- package/dist/ts/widgets/ptit-observatoire-widget/ptit-observatoire-widget.widget.d.ts.map +0 -1
- package/dist/ts/widgets/screen-time-widget/screen-time-widget.widget.d.ts +0 -62
- package/dist/ts/widgets/screen-time-widget/screen-time-widget.widget.d.ts.map +0 -1
- package/dist/widgets/ptit-observatoire-widget/ptit-observatoire-widget.widget.js +0 -2
- package/dist/widgets/ptit-observatoire-widget/ptit-observatoire-widget.widget.js.map +0 -1
- package/dist/widgets/screen-time-widget/screen-time-widget.widget.js +0 -2
- package/dist/widgets/screen-time-widget/screen-time-widget.widget.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ptit-observatoire-widget.widget.d.ts","sourceRoot":"","sources":["../../../../src/ts/widgets/ptit-observatoire-widget/ptit-observatoire-widget.widget.ts"],"names":[],"mappings":"AAgIA,eAAO,MAAM,aAAa,oCAAoC,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Moment } from "moment";
|
|
2
|
-
import 'moment/locale/fr';
|
|
3
|
-
export declare class Controller {
|
|
4
|
-
selectedUser: string;
|
|
5
|
-
viewMode: "weekly" | "daily";
|
|
6
|
-
userData: {
|
|
7
|
-
[key: string]: {
|
|
8
|
-
weekly: any;
|
|
9
|
-
daily: any;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
selectedDailyDate: string;
|
|
13
|
-
weekStart: Moment;
|
|
14
|
-
weekEnd: Moment;
|
|
15
|
-
updateChart: () => void;
|
|
16
|
-
todayOnCampus: number;
|
|
17
|
-
todayOffCampus: number;
|
|
18
|
-
todayTotal: number;
|
|
19
|
-
todaySchoolUsePercentage: number;
|
|
20
|
-
todayOutOfSchoolPercentage: number;
|
|
21
|
-
weeklyAvgOnCampus: number;
|
|
22
|
-
weeklyAvgOffCampus: number;
|
|
23
|
-
weeklyTotalAverage: number;
|
|
24
|
-
weeklyAvgSchoolUsePercentage: number;
|
|
25
|
-
weeklyAvgOutOfSchoolPercentage: number;
|
|
26
|
-
fixedTodayOnCampus: number;
|
|
27
|
-
fixedTodayOffCampus: number;
|
|
28
|
-
fixedTodayTotal: number;
|
|
29
|
-
fixedTodaySchoolUsePercentage: number;
|
|
30
|
-
fixedTodayOutOfSchoolPercentage: number;
|
|
31
|
-
fixedWeeklyAvgOnCampus: number;
|
|
32
|
-
fixedWeeklyAvgOffCampus: number;
|
|
33
|
-
fixedWeeklyTotalAverage: number;
|
|
34
|
-
fixedWeeklyAvgSchoolUsePercentage: number;
|
|
35
|
-
fixedWeeklyAvgOutOfSchoolPercentage: number;
|
|
36
|
-
customWeekMode: boolean;
|
|
37
|
-
customStartDate: string;
|
|
38
|
-
customEndDate: string;
|
|
39
|
-
isParent: boolean;
|
|
40
|
-
hasError: boolean;
|
|
41
|
-
errorMessage: string;
|
|
42
|
-
fetchDataForCurrentUser: () => void;
|
|
43
|
-
fetchLightboxData: () => void;
|
|
44
|
-
showLightbox: boolean;
|
|
45
|
-
showDatePicker: boolean;
|
|
46
|
-
children: {
|
|
47
|
-
id: string;
|
|
48
|
-
name: string;
|
|
49
|
-
userId: string;
|
|
50
|
-
}[];
|
|
51
|
-
selectedChild: null;
|
|
52
|
-
selectedChildHistogram: string;
|
|
53
|
-
toggleDatePicker(show: boolean): void;
|
|
54
|
-
setDateFromPicker(date: string): void;
|
|
55
|
-
toggleLightbox(show: boolean): void;
|
|
56
|
-
changeDay(offset: number): void;
|
|
57
|
-
changeWeek(offset: number): void;
|
|
58
|
-
get selectedDailyDateObj(): Date;
|
|
59
|
-
get weekLabel(): string;
|
|
60
|
-
}
|
|
61
|
-
export declare const odeModuleName = "odeCantineWidgetModule";
|
|
62
|
-
//# sourceMappingURL=screen-time-widget.widget.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"screen-time-widget.widget.d.ts","sourceRoot":"","sources":["../../../../src/ts/widgets/screen-time-widget/screen-time-widget.widget.ts"],"names":[],"mappings":"AAGA,OAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,kBAAkB,CAAC;AAM1B,qBAAa,UAAU;IACZ,YAAY,EAAE,MAAM,CAAM;IAC1B,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAY;IAExC,QAAQ,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,MAAM,EAAE,GAAG,CAAC;YAAC,KAAK,EAAE,GAAG,CAAA;SAAE,CAAA;KAAE,CAAM;IAC9D,iBAAiB,EAAE,MAAM,CAAiC;IAC1D,SAAS,EAAE,MAAM,CAA+B;IAChD,OAAO,EAAE,MAAM,CAA6B;IAE5C,WAAW,EAAE,MAAM,IAAI,CAAa;IAEpC,aAAa,SAAK;IAClB,cAAc,SAAK;IACnB,UAAU,SAAK;IACf,wBAAwB,EAAE,MAAM,CAAK;IACrC,0BAA0B,EAAE,MAAM,CAAK;IAEvC,iBAAiB,SAAK;IACtB,kBAAkB,SAAK;IACvB,kBAAkB,SAAK;IACvB,4BAA4B,EAAE,MAAM,CAAK;IACzC,8BAA8B,EAAE,MAAM,CAAK;IAG3C,kBAAkB,SAAK;IACvB,mBAAmB,SAAK;IACxB,eAAe,SAAK;IACpB,6BAA6B,EAAE,MAAM,CAAK;IAC1C,+BAA+B,EAAE,MAAM,CAAK;IAE5C,sBAAsB,SAAK;IAC3B,uBAAuB,SAAK;IAC5B,uBAAuB,SAAK;IAC5B,iCAAiC,EAAE,MAAM,CAAK;IAC9C,mCAAmC,EAAE,MAAM,CAAK;IAKhD,cAAc,EAAE,OAAO,CAAS;IAChC,eAAe,EAAE,MAAM,CAAM;IAC7B,aAAa,EAAE,MAAM,CAAM;IAE3B,QAAQ,EAAE,OAAO,CAAS;IAE1B,QAAQ,EAAE,OAAO,CAAS;IAC1B,YAAY,EAAE,MAAM,CAAM;IAE1B,uBAAuB,EAAE,MAAM,IAAI,CAAa;IAChD,iBAAiB,EAAE,MAAM,IAAI,CAAa;IAE1C,YAAY,EAAE,OAAO,CAAS;IAC9B,cAAc,EAAE,OAAO,CAAS;IAEhC,QAAQ,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAM;IAC9D,aAAa,OAAQ;IACrB,sBAAsB,SAAM;IAE5B,gBAAgB,CAAC,IAAI,EAAE,OAAO;IAI9B,iBAAiB,CAAC,IAAI,EAAE,MAAM;IAM9B,cAAc,CAAC,IAAI,EAAE,OAAO;IAwB5B,SAAS,CAAC,MAAM,EAAE,MAAM;IAKxB,UAAU,CAAC,MAAM,EAAE,MAAM;IAMhC,IAAW,oBAAoB,IAAI,IAAI,CAEtC;IAED,IAAW,SAAS,IAAI,MAAM,CAI7B;CACJ;AA2WD,eAAO,MAAM,aAAa,2BAA2B,CAAC"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkode_ngjs_front=self.webpackChunkode_ngjs_front||[]).push([[443],{7601:(t,e,r)=>{r.d(e,{Z:()=>i});const i='<style>.ptit-observatoire-widget-container{box-sizing:border-box;background:#358284;padding:10px;border-radius:6px;overflow:hidden}.ptit-observatoire-widget-content{display:flex;flex-direction:column;gap:10px;box-sizing:border-box;width:100%;height:100%;background-color:#fff;border-radius:3px;padding:10px}.ptit-observatoire-widget-form{width:100%;display:flex;flex-direction:column;gap:10px}.ptit-observatoire-widget-select{background-color:#fff;padding:15px;border:1px solid #c1c1ca;color:#c1c1ca;border-radius:10px}.ptit-observatoire-submit-button{display:flex;align-items:center;gap:10px;background-color:#173a37;color:#fff;border:none;padding:10px 15px;border-radius:30px}.ptit-observatoire-plus-icon{display:flex;align-items:center;justify-content:center;line-height:100%;text-align:center;background-color:#2c6262;border-radius:50%;width:30px;height:30px}.ptit-observatoire-modal-form{display:flex;flex-direction:column;gap:15px}.ptit-observatoire-modal-form-legend{text-transform:uppercase;color:#7caaac;font-weight:700}.ptit-observatoire-modal-form-textarea{width:100%}.ptit-observatoire-modal-options-container{display:flex;flex-wrap:wrap;gap:5px}</style> <div class="ptit-observatoire-widget-container"> <div class="ptit-observatoire-widget-content"> <p> <i18n>ptitObservatoire.title</i18n> </p> <div class="widget-body" dnd-nodrag> <form class="ptit-observatoire-widget-form" ng-submit="ctrl.startObservation()"> <select class="ptit-observatoire-widget-select" name="student" ng-model="ctrl.formData.student_id"> <option value="" selected="selected"> </option> <option ng-repeat="student in ctrl.studentsList" value="{{student.id}}"> {{student.fullName}} </option> </select> <button type="submit" class="ptit-observatoire-submit-button"> <span class="ptit-observatoire-plus-icon">+</span> <span> <i18n>ptitObservatoire.newObservation</i18n> </span> </button> </form> </div> </div> <ode-modal visible="ctrl.showLightbox" on-close="ctrl.showLightbox=false" size="lg" dnd-nodrag> <ode-modal-title> <h2> <i18n>ptitObservatoire.modal.title</i18n> </h2> </ode-modal-title> <ode-modal-body> <form class="ptit-observatoire-modal-form" ng-submit="ctrl.handleObservationSubmit(); ctrl.showLightbox=false"> <fieldset> <legend class="ptit-observatoire-modal-form-legend"> <i18n>ptitObservatoire.modal.observation</i18n> </legend> <textarea class="ptit-observatoire-modal-form-textarea" name="content" ng-model="ctrl.formData[\'content\']" i18n-placeholder="ptitObservatoire.modal.textarea.placeholder"></textarea> </fieldset> <fieldset> <legend class="ptit-observatoire-modal-form-legend"> <i18n>ptitObservatoire.modal.evaluation</i18n> </legend> <label for="strengths"> <input type="radio" id="strength" name="assessment_type" ng-model="ctrl.formData[\'assessment_type\']" ng-value="\'strength\'"/> <i18n>ptitObservatoire.modal.evaluation.strength</i18n> </label> <label for="neutral"> <input type="radio" id="neutral" name="assessment_type" ng-model="ctrl.formData[\'assessment_type\']" ng-value="\'neutral\'"/> <i18n>ptitObservatoire.modal.evaluation.neutral</i18n> </label> <label for="difficulties"> <input type="radio" id="difficulties" name="assessment_type" ng-model="ctrl.formData[\'assessment_type\']" ng-value="\'difficulties\'"/> <i18n>ptitObservatoire.modal.evaluation.difficulties</i18n> </label> </fieldset> <fieldset> <legend class="ptit-observatoire-modal-form-legend"> <i18n>ptitObservatoire.modal.categories</i18n> </legend> <div class="ptit-observatoire-modal-options-container"> <label ng-repeat="category in ctrl.observationCategories"> <input type="radio" name="{{category.name}}" ng-model="ctrl.formData[\'category_id\']" ng-value="category.id"/> {{ category.name }} </label> </div> </fieldset> <fieldset> <legend class="ptit-observatoire-modal-form-legend"> <i18n>ptitObservatoire.modal.options</i18n> </legend> <label> <input type="checkbox" ng-model="ctrl.formData[\'private\']"/> <i18n>ptitObservatoire.modal.options.private</i18n> </label> </fieldset> <button type="submit" class="ptit-observatoire-submit-button"> <i18n>ptitObservatoire.modal.save</i18n> </button> </form> </ode-modal-body> </ode-modal> </div>'},5883:function(t,e,r){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},i.apply(this,arguments)},o=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))(function(o,n){function a(t){try{l(i.next(t))}catch(t){n(t)}}function s(t){try{l(i.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(a,s)}l((i=i.apply(t,e||[])).next())})},n=this&&this.__generator||function(t,e){var r,i,o,n,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return n={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function s(n){return function(s){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,i&&(o=2&n[0]?i.return:n[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,n[1])).done)return o;switch(i=0,o&&(n=[2&n[0],o.value]),n[0]){case 0:case 1:o=n;break;case 4:return a.label++,{value:n[1],done:!1};case 5:a.label++,i=n[1],n=[0];continue;case 7:n=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==n[0]&&2!==n[0])){a=0;continue}if(3===n[0]&&(!o||n[1]>o[0]&&n[1]<o[3])){a.label=n[1];break}if(6===n[0]&&a.label<o[1]){a.label=o[1],o=n;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(n);break}o[2]&&a.ops.pop(),a.trys.pop();continue}n=e.call(t,a)}catch(t){n=[6,t],i=0}finally{r=o=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,s])}}},a=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.odeModuleName=void 0;var s=a(r(4202)),l=r(9419),d=r(6731),c=function(){function t(){this.formData={},this.observationCategories=[],this.studentsList=[],this.showLightbox=!1}return t.prototype.startObservation=function(){this.formData.student_id&&(this.showLightbox=!0)},t.prototype.handleObservationSubmit=function(){return o(this,void 0,void 0,function(){var t;return n(this,function(e){switch(e.label){case 0:return t={data:{type:"observations",attributes:i(i({},this.formData),{teacher_id:1,date:(new Date).toISOString().substring(0,10)})}},[4,this.saveObservation(t)];case 1:return e.sent(),[2]}})})},t.prototype.saveObservation=function(t){return o(this,void 0,void 0,function(){var e;return n(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,(0,l.http)().postJson("/appregistry/ptitObservatoire/observations",t)];case 1:return r.sent(),d.notify.success("ptitObservatoire.notify.save.success"),[3,3];case 2:return e=r.sent(),console.error("Error saving observation:",e),d.notify.error("ptitObservatoire.notify.save.error"),[3,3];case 3:return[2]}})})},t}(),u=function(){function t(){this.restrict="E",this.template=r(7601).Z,this.scope={},this.bindToController=!0,this.controller=[c],this.controllerAs="ctrl",this.require=["odePtitObservatoireWidget"]}return t.prototype.link=function(t,e,r,i){return o(this,void 0,void 0,function(){var e,r;return n(this,function(o){switch(o.label){case 0:return(e=i?i[0]:null)?[4,Promise.all([this.getObservationCategories(),this.getStudentsList()])]:[2];case 1:return r=o.sent(),e.observationCategories=r[0],e.studentsList=r[1],t.$applyAsync(),[2]}})})},t.prototype.getStudentsList=function(){return o(this,void 0,void 0,function(){var t;return n(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,(0,l.http)().get("/appregistry/ptitObservatoire/students")];case 1:return[2,e.sent().map(function(t){return{id:t.id,fullName:t.attributes.full_name}})];case 2:return t=e.sent(),console.error("Error fetching students:",t),[2,[]];case 3:return[2]}})})},t.prototype.getObservationCategories=function(){return o(this,void 0,void 0,function(){var t;return n(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,(0,l.http)().get("/appregistry/ptitObservatoire/observations/categories")];case 1:return[2,e.sent().map(function(t){return{id:t.id,name:t.attributes.name}})];case 2:return t=e.sent(),console.error("Error fetching categories:",t),[2,[]];case 3:return[2]}})})},t}();(0,l.notif)().onLangReady().promise.then(function(t){(0,l.conf)().Platform.idiom.addKeys(r(5512))}),e.odeModuleName="odePtitObservatoireWidgetModule",s.default.module(e.odeModuleName,[]).directive("odePtitObservatoireWidget",function(){return new u})},5512:t=>{t.exports=JSON.parse('{"ptitObservatoire.title":"Centraliser mes observations","ptitObservatoire.newObservation":"Nouvelle observation","ptitObservatoire.selectStudent":"Sélectionner un élève","ptitObservatoire.modal.title":"Saisie de l\'Observation","ptitObservatoire.modal.observation":"Observation","ptitObservatoire.modal.evaluation":"Évaluation","ptitObservatoire.modal.evaluation.strength":"Forces","ptitObservatoire.modal.evaluation.neutral":"Neutre","ptitObservatoire.modal.evaluation.difficulties":"Difficultés","ptitObservatoire.modal.categories":"Catégories","ptitObservatoire.modal.options":"Options","ptitObservatoire.modal.options.private":"Observation privée","ptitObservatoire.modal.save":"Enregistrer l\'observation","ptitObservatoire.notify.save.success":"Observation enregistrée avec succès","ptitObservatoire.notify.save.error":"Une erreur est survenue lors de l\'enregistrement de l\'observation","ptitObservatoire.modal.textarea.placeholder":"Je suis bienveillant et factuel : J\'écris ce que j\'ai vu et entendu"}')}}]);
|
|
2
|
-
//# sourceMappingURL=ptit-observatoire-widget.widget.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"widgets/ptit-observatoire-widget/ptit-observatoire-widget.widget.js","mappings":"gIAGA,QAFW,+iI,+wDCDX,iBACA,UACA,UAaA,0BACC,KAAAA,SAAsC,CAAC,EAChC,KAAAC,sBAA+C,GAC/C,KAAAC,aAA0B,GAC1B,KAAAC,cAAe,CAiCvB,QA9BC,YAAAC,iBAAA,WACKC,KAAKL,SAASM,aACjBD,KAAKF,cAAe,EAEtB,EAEM,YAAAI,wBAAN,W,8FAYC,OAXMC,EAAO,CACZC,KAAM,CACLC,KAAM,eACNC,WAAY,EAAF,KACNN,KAAKL,UAAQ,CAChB,WAAc,EACd,MAAQ,IAAIY,MAAOC,cAAcC,UAAU,EAAG,QAKjD,GAAMT,KAAKU,gBAAgBP,I,cAA3B,S,UAGK,YAAAO,gBAAN,SAAsBP,G,8FAEpB,O,sBAAA,IAAM,IAAAQ,QAAOC,SAAS,6CAA8CT,I,cAApE,SACA,EAAAU,OAAOC,QAAQ,wC,+BAEfC,QAAQC,MAAM,4BAA6B,GAC3C,E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-front/./src/ts/widgets/ptit-observatoire-widget/ptit-observatoire-widget.widget.ts"],"sourcesContent":["// Module\nvar code = \"<style>.ptit-observatoire-widget-container{box-sizing:border-box;background:#358284;padding:10px;border-radius:6px;overflow:hidden}.ptit-observatoire-widget-content{display:flex;flex-direction:column;gap:10px;box-sizing:border-box;width:100%;height:100%;background-color:#fff;border-radius:3px;padding:10px}.ptit-observatoire-widget-form{width:100%;display:flex;flex-direction:column;gap:10px}.ptit-observatoire-widget-select{background-color:#fff;padding:15px;border:1px solid #c1c1ca;color:#c1c1ca;border-radius:10px}.ptit-observatoire-submit-button{display:flex;align-items:center;gap:10px;background-color:#173a37;color:#fff;border:none;padding:10px 15px;border-radius:30px}.ptit-observatoire-plus-icon{display:flex;align-items:center;justify-content:center;line-height:100%;text-align:center;background-color:#2c6262;border-radius:50%;width:30px;height:30px}.ptit-observatoire-modal-form{display:flex;flex-direction:column;gap:15px}.ptit-observatoire-modal-form-legend{text-transform:uppercase;color:#7caaac;font-weight:700}.ptit-observatoire-modal-form-textarea{width:100%}.ptit-observatoire-modal-options-container{display:flex;flex-wrap:wrap;gap:5px}</style> <div class=\\\"ptit-observatoire-widget-container\\\"> <div class=\\\"ptit-observatoire-widget-content\\\"> <p> <i18n>ptitObservatoire.title</i18n> </p> <div class=\\\"widget-body\\\" dnd-nodrag> <form class=\\\"ptit-observatoire-widget-form\\\" ng-submit=\\\"ctrl.startObservation()\\\"> <select class=\\\"ptit-observatoire-widget-select\\\" name=\\\"student\\\" ng-model=\\\"ctrl.formData.student_id\\\"> <option value=\\\"\\\" selected=\\\"selected\\\"> </option> <option ng-repeat=\\\"student in ctrl.studentsList\\\" value=\\\"{{student.id}}\\\"> {{student.fullName}} </option> </select> <button type=\\\"submit\\\" class=\\\"ptit-observatoire-submit-button\\\"> <span class=\\\"ptit-observatoire-plus-icon\\\">+</span> <span> <i18n>ptitObservatoire.newObservation</i18n> </span> </button> </form> </div> </div> <ode-modal visible=\\\"ctrl.showLightbox\\\" on-close=\\\"ctrl.showLightbox=false\\\" size=\\\"lg\\\" dnd-nodrag> <ode-modal-title> <h2> <i18n>ptitObservatoire.modal.title</i18n> </h2> </ode-modal-title> <ode-modal-body> <form class=\\\"ptit-observatoire-modal-form\\\" ng-submit=\\\"ctrl.handleObservationSubmit(); ctrl.showLightbox=false\\\"> <fieldset> <legend class=\\\"ptit-observatoire-modal-form-legend\\\"> <i18n>ptitObservatoire.modal.observation</i18n> </legend> <textarea class=\\\"ptit-observatoire-modal-form-textarea\\\" name=\\\"content\\\" ng-model=\\\"ctrl.formData['content']\\\" i18n-placeholder=\\\"ptitObservatoire.modal.textarea.placeholder\\\"></textarea> </fieldset> <fieldset> <legend class=\\\"ptit-observatoire-modal-form-legend\\\"> <i18n>ptitObservatoire.modal.evaluation</i18n> </legend> <label for=\\\"strengths\\\"> <input type=\\\"radio\\\" id=\\\"strength\\\" name=\\\"assessment_type\\\" ng-model=\\\"ctrl.formData['assessment_type']\\\" ng-value=\\\"'strength'\\\"/> <i18n>ptitObservatoire.modal.evaluation.strength</i18n> </label> <label for=\\\"neutral\\\"> <input type=\\\"radio\\\" id=\\\"neutral\\\" name=\\\"assessment_type\\\" ng-model=\\\"ctrl.formData['assessment_type']\\\" ng-value=\\\"'neutral'\\\"/> <i18n>ptitObservatoire.modal.evaluation.neutral</i18n> </label> <label for=\\\"difficulties\\\"> <input type=\\\"radio\\\" id=\\\"difficulties\\\" name=\\\"assessment_type\\\" ng-model=\\\"ctrl.formData['assessment_type']\\\" ng-value=\\\"'difficulties'\\\"/> <i18n>ptitObservatoire.modal.evaluation.difficulties</i18n> </label> </fieldset> <fieldset> <legend class=\\\"ptit-observatoire-modal-form-legend\\\"> <i18n>ptitObservatoire.modal.categories</i18n> </legend> <div class=\\\"ptit-observatoire-modal-options-container\\\"> <label ng-repeat=\\\"category in ctrl.observationCategories\\\"> <input type=\\\"radio\\\" name=\\\"{{category.name}}\\\" ng-model=\\\"ctrl.formData['category_id']\\\" ng-value=\\\"category.id\\\"/> {{ category.name }} </label> </div> </fieldset> <fieldset> <legend class=\\\"ptit-observatoire-modal-form-legend\\\"> <i18n>ptitObservatoire.modal.options</i18n> </legend> <label> <input type=\\\"checkbox\\\" ng-model=\\\"ctrl.formData['private']\\\"/> <i18n>ptitObservatoire.modal.options.private</i18n> </label> </fieldset> <button type=\\\"submit\\\" class=\\\"ptit-observatoire-submit-button\\\"> <i18n>ptitObservatoire.modal.save</i18n> </button> </form> </ode-modal-body> </ode-modal> </div>\";\n// Exports\nexport default code;","import angular, { IAttributes, IController, IDirective, IScope } from \"angular\";\nimport { conf, http, notif } from \"../../utils\";\nimport { notify } from \"../../services\";\n\ninterface Student {\n\tid: number,\n\tfullName: string\n}\n\ninterface ObservationCategory {\n\tid: number,\n\tname: string\n}\n\n/* Controller for the directive */\nclass Controller implements IController {\n\tformData: { [key: string]: string } = {};\n\tpublic observationCategories: ObservationCategory[] = [];\n\tpublic studentsList: Student[] = [];\n\tpublic showLightbox = false;\n\n\n\tstartObservation() {\n\t\tif (this.formData.student_id) {\n\t\t\tthis.showLightbox = true;\n\t\t}\n\t}\n\n\tasync handleObservationSubmit() {\n\t\tconst body = {\n\t\t\tdata: {\n\t\t\t\ttype: \"observations\",\n\t\t\t\tattributes: {\n\t\t\t\t\t...this.formData,\n\t\t\t\t\t\"teacher_id\": 1, // TODO: change when respone updated from ptit observatoire\n\t\t\t\t\t\"date\": new Date().toISOString().substring(0, 10),\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tawait this.saveObservation(body)\n\t}\n\n\tasync saveObservation(body: any): Promise<void> {\n\t\ttry {\n\t\t\tawait http().postJson(\"/appregistry/ptitObservatoire/observations\", body)\n\t\t\tnotify.success(\"ptitObservatoire.notify.save.success\")\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Error saving observation:\", error);\n\t\t\tnotify.error(\"ptitObservatoire.notify.save.error\")\n\t\t}\n\t}\n}\n\n/* Directive */\nclass Directive implements IDirective<IScope, JQLite, IAttributes, IController[]> {\n\trestrict = 'E';\n\ttemplate = require('./ptit-observatoire-widget.widget.html').default;\n\tscope = {};\n\tbindToController = true;\n\tcontroller = [Controller];\n\tcontrollerAs = 'ctrl';\n\trequire = ['odePtitObservatoireWidget'];\n\n\tasync link(scope: IScope, elem: JQLite, attrs: IAttributes, controllers?: IController[]) {\n\t\tconst ctrl: Controller | null = controllers\n\t\t\t? (controllers[0] as Controller)\n\t\t\t: null;\n\t\tif (!ctrl) {\n\t\t\treturn;\n\t\t}\n\n\t\t[ctrl.observationCategories, ctrl.studentsList] = await Promise.all([\n\t\t\tthis.getObservationCategories(),\n\t\t\tthis.getStudentsList(),\n\t\t]);\n\n\t\tscope.$applyAsync();\n\t}\n\n\tasync getStudentsList(): Promise<Student[]> {\n\t\ttry {\n\t\t\tconst res = await http().get(\"/appregistry/ptitObservatoire/students\");\n\n\t\t\treturn res.map((\n\t\t\t\tstudent: { id: number, attributes: { full_name: string } }\n\t\t\t) => ({\n\t\t\t\tid: student.id,\n\t\t\t\tfullName: student.attributes.full_name\n\t\t\t}));\n\t\t} catch (e) {\n\t\t\tconsole.error(\"Error fetching students:\", e);\n\t\t\treturn [];\n\t\t}\n\t}\n\n\tasync getObservationCategories(): Promise<ObservationCategory[]> {\n\t\ttry {\n\t\t\tconst res = await http().get(\"/appregistry/ptitObservatoire/observations/categories\");\n\t\t\treturn res.map((category: { id: number; attributes: { name: string } }) => ({\n\t\t\t\tid: category.id,\n\t\t\t\tname: category.attributes.name,\n\t\t\t}));\n\t\t} catch (e) {\n\t\t\tconsole.error(\"Error fetching categories:\", e);\n\t\t\treturn [];\n\t\t}\n\t}\n}\n\n/** The P'tit observatoire widget. */\nfunction DirectiveFactory() {\n\treturn new Directive();\n}\n\n// Preload translations\nnotif()\n\t.onLangReady()\n\t.promise.then((lang) => {\n\t\tswitch (lang) {\n\t\t\tdefault:\n\t\t\t\tconf().Platform.idiom.addKeys(require(\"./i18n/fr.json\"));\n\t\t\t\tbreak;\n\t\t}\n\t});\n\n// THIS ANGULAR MODULE WILL BE DYNAMICALLY ADDED TO THE APPLICATION.\n// RESPECT THE NAMING CONVENTION BY EXPORTING THE MODULE NAME :\nexport const odeModuleName = \"odePtitObservatoireWidgetModule\";\nangular\n\t.module(odeModuleName, [])\n\t.directive(\"odePtitObservatoireWidget\", DirectiveFactory);\n"],"names":["formData","observationCategories","studentsList","showLightbox","startObservation","this","student_id","handleObservationSubmit","body","data","type","attributes","Date","toISOString","substring","saveObservation","http","postJson","notify","success","console","error","restrict","template","scope","bindToController","controller","Controller","controllerAs","require","link","elem","attrs","controllers","ctrl","Promise","all","getObservationCategories","getStudentsList","$applyAsync","get","map","student","id","fullName","full_name","category","name","notif","onLangReady","promise","then","lang","conf","Platform","idiom","addKeys","odeModuleName","module","directive","Directive"],"sourceRoot":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkode_ngjs_front=self.webpackChunkode_ngjs_front||[]).push([[202],{5688:(e,t,o)=>{o.d(t,{Z:()=>a});const a='<style>.screen-time-summary{padding:16px;font-family:Roboto,sans-serif;display:flex;flex-direction:column;gap:12px}.title{padding-bottom:6px;font-size:16px;color:#4a4a4a;font-weight:700;border-bottom:1px solid #e0e0e0}.summary-row{display:flex;gap:12px}.summary-row:nth-of-type(2){margin-top:10px}.summary-block{flex:1;background:#e5f5ff;border-radius:12px;padding:12px;box-shadow:0 1px 3px rgba(0,0,0,.1)}.summary-block .label{font-size:16px;color:#4a4a4a;font-weight:700;margin-bottom:4px}.summary-block .value{font-size:32px;color:#333}.percentage-bar-container{width:100%;height:10px;background-color:#e0e0e0;border-radius:5px;margin-top:5px;display:flex;overflow:hidden}.percentage-bar{height:100%;transition:width .5s ease-in-out;border-radius:5px}.au-college{background-color:#2a9cc8}.hors-college{background-color:#ecbe30}.legend{display:flex;gap:16px;align-items:center;margin-top:10px;font-size:10px;color:#333}.legend-item{display:flex;align-items:center;gap:6px}.legend-square{width:16px;height:16px;border-radius:4px}.legend-au-college{background-color:#2a9cc8}.legend-hors-college{background-color:#ecbe30}.custom-select{appearance:none;border:none;padding:8px 32px 8px 12px;border-radius:6px;font-size:16px;color:#333;font-family:Roboto,sans-serif;background:#fff url("data:image/svg+xml,%3Csvg fill=\'none\' stroke=\'%23666\' stroke-width=\'2\' viewBox=\'0 0 24 24\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Cpath stroke-linecap=\'round\' stroke-linejoin=\'round\' d=\'M19 9l-7 7-7-7\'%3E%3C/path%3E%3C/svg%3E") no-repeat right 10px center;background-size:16px;cursor:pointer;min-width:150px}.custom-select:focus{outline:0;box-shadow:0 0 0 2px rgba(42,156,200,.3)}.see-more{display:flex;justify-content:flex-end;margin-top:8px;padding-left:4px}.see-more button{background-color:transparent;border:none;font-family:Roboto,sans-serif;font-weight:600;font-size:16px;line-height:24px;padding:6px 12px;cursor:pointer;color:#2a9cc8;border-radius:4px;transition:background-color .2s ease}.see-more button:hover{background-color:#f0f8fc}.centered-controls{margin:0 auto 20px auto;width:fit-content;text-align:center}.close-button-container{display:flex;justify-content:flex-end;margin-top:20px}.close-button{width:84px;height:40px;padding:8px 16px;background:#ff8d2e;color:#fff;font-size:16px;font-weight:700;border:none;border-radius:8px;cursor:pointer;transition:background .3s ease}.close-button:hover{background:#e67c24}.date-controls{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.nav-button{background:0 0;border:none;font-size:24px;cursor:pointer}.date-navigation{display:flex;align-items:center;justify-content:center;gap:1rem}.date-navigation button{background:0 0;border:none;font-size:1.5rem;cursor:pointer}.selected-date{cursor:pointer;font-weight:700}.error-message{background-color:#ffe5e5;color:#c00;border:1px solid #c00;padding:12px;border-radius:6px;font-size:14px;font-weight:500}</style> <div class="screen-time-widget-container"> <div class="screen-time-summary"> <div class="title"> <div class="label">TEMPS D\'ÉCRAN</div> </div> <div ng-if="ctrl.isParent"> <select id="userSelect" class="custom-select" ng-model="ctrl.selectedUser" ng-options="child.userId as child.name for child in ctrl.children" ng-change="ctrl.fetchDataForCurrentUser()"> </select> </div> <div class="error-message" ng-if="ctrl.errorMessage"> {{ ctrl.errorMessage }} </div> <div ng-if="!ctrl.errorMessage"> <div class="summary-row"> <div class="summary-block"> <div class="label">Aujourd\'hui</div> <div class="value">{{ ctrl.todayTotal | duration }}</div> <div class="percentage-bar-container"> <div class="percentage-bar au-college" ng-style="{ width: ctrl.todaySchoolUsePercentage + \'%\' }" title="{{ ctrl.todaySchoolUsePercentage | duration }} au collège"> </div> <div class="percentage-bar hors-college" ng-style="{ width: ctrl.todayOutOfSchoolPercentage + \'%\' }" title="{{ ctrl.todayOutOfSchoolPercentage | duration }} hors collège"></div> </div> </div> </div> <div class="summary-row"> <div class="summary-block"> <div class="label">Moyenne de la semaine</div> <div class="value">{{ ctrl.weeklyTotalAverage | duration }}</div> <div class="percentage-bar-container"> <div class="percentage-bar au-college" ng-style="{ width: ctrl.weeklyAvgSchoolUsePercentage + \'%\' }" title="{{ ctrl.weeklyAvgSchoolUsePercentage | duration }} au Collège"> </div> <div class="percentage-bar hors-college" ng-style="{ width: ctrl.weeklyAvgOutOfSchoolPercentage + \'%\' }" title="{{ ctrl.weeklyAvgOutOfSchoolPercentage | duration}} hors collège"></div> </div> </div> </div> <div class="legend"> <div class="legend-item"> <div class="legend-square legend-au-college"></div> <span>Au collège</span> </div> <div class="legend-item"> <div class="legend-square legend-hors-college"></div> <span>Hors collège</span> </div> <div class="see-more"> <button ng-click="ctrl.toggleLightbox(true)">Voir le détail</button> </div> </div> </div> </div> <ode-modal visible="ctrl.showLightbox" on-close="ctrl.toggleLightbox(false)" size="lg" dnd-nodrag> <ode-modal-title> <h2>Temps d\'écran</h2> </ode-modal-title> <ode-modal-body> <div class="centered-controls"> <label style="font-size:14px" for="userSelect">Utilisateur :</label> <div ng-if="ctrl.isParent"> <select id="userSelect" class="custom-select" ng-model="ctrl.selectedChildHistogram" ng-options="child.userId as child.name for child in ctrl.children" ng-change="ctrl.fetchLightboxData()"> </select> </div> <label for="viewMode">Affichage :</label> <select id="viewMode" class="custom-select" ng-model="ctrl.viewMode" ng-change="ctrl.updateChart()"> <option value="weekly">Hebdomadaire</option> <option value="daily">Quotidien</option> </select> </div> <canvas id="myChart" style="width:100%;height:200px"></canvas> <div class="date-selectors centered-controls" ng-if="ctrl.showLightbox"> <div class="date-navigation" ng-if="ctrl.viewMode === \'daily\'"> <button ng-click="ctrl.changeDay(-1)">←</button> <div ng-if="!ctrl.showDatePicker" class="selected-date" ng-click="ctrl.toggleDatePicker(true)"> {{ ctrl.selectedDailyDateObj | date:\'fullDate\' }} </div> <input type="date" ng-if="ctrl.showDatePicker" ng-model="ctrl.selectedDailyDate" ng-change="ctrl.setDateFromPicker(ctrl.selectedDailyDate)" ng-blur="ctrl.toggleDatePicker(false)" max="{{ ctrl.selectedDailyDate }}"/> <button ng-click="ctrl.changeDay(1)">→</button> </div> <div class="date-navigation" ng-if="ctrl.viewMode === \'weekly\'"> <button ng-click="ctrl.changeWeek(-1)">←</button> <div class="selected-date">{{ ctrl.weekLabel }}</div> <button ng-click="ctrl.changeWeek(1)">→</button> </div> </div> <div class="close-button-container"> <button class="close-button" ng-click="ctrl.toggleLightbox(false)">Fermer</button> </div> </ode-modal-body> </ode-modal> </div>'},58:function(e,t,o){var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.odeModuleName=t.Controller=void 0;var r=a(o(4202)),i=o(9419),s=o(5668),l=a(o(381));o(4470),s.Chart.register.apply(s.Chart,s.registerables),l.default.locale("fr");var n=function(){function e(){this.selectedUser="",this.viewMode="weekly",this.userData={},this.selectedDailyDate=(0,l.default)().format("YYYY-MM-DD"),this.weekStart=(0,l.default)().startOf("isoWeek"),this.weekEnd=(0,l.default)().endOf("isoWeek"),this.updateChart=function(){},this.todayOnCampus=0,this.todayOffCampus=0,this.todayTotal=0,this.todaySchoolUsePercentage=0,this.todayOutOfSchoolPercentage=0,this.weeklyAvgOnCampus=0,this.weeklyAvgOffCampus=0,this.weeklyTotalAverage=0,this.weeklyAvgSchoolUsePercentage=0,this.weeklyAvgOutOfSchoolPercentage=0,this.fixedTodayOnCampus=0,this.fixedTodayOffCampus=0,this.fixedTodayTotal=0,this.fixedTodaySchoolUsePercentage=0,this.fixedTodayOutOfSchoolPercentage=0,this.fixedWeeklyAvgOnCampus=0,this.fixedWeeklyAvgOffCampus=0,this.fixedWeeklyTotalAverage=0,this.fixedWeeklyAvgSchoolUsePercentage=0,this.fixedWeeklyAvgOutOfSchoolPercentage=0,this.customWeekMode=!1,this.customStartDate="",this.customEndDate="",this.isParent=!1,this.hasError=!1,this.errorMessage="",this.fetchDataForCurrentUser=function(){},this.fetchLightboxData=function(){},this.showLightbox=!1,this.showDatePicker=!1,this.children=[],this.selectedChild=null,this.selectedChildHistogram=""}return e.prototype.toggleDatePicker=function(e){this.showDatePicker=e},e.prototype.setDateFromPicker=function(e){this.selectedDailyDate=(0,l.default)(e).format("YYYY-MM-DD"),this.showDatePicker=!1,this.fetchLightboxData()},e.prototype.toggleLightbox=function(e){this.showLightbox=e,e&&(this.fixedTodayOnCampus=this.todayOnCampus,this.fixedTodayOffCampus=this.todayOffCampus,this.fixedTodayTotal=this.todayTotal,this.fixedTodaySchoolUsePercentage=this.todaySchoolUsePercentage,this.fixedTodayOutOfSchoolPercentage=this.todayOutOfSchoolPercentage,this.fixedWeeklyAvgOnCampus=this.weeklyAvgOnCampus,this.fixedWeeklyAvgOffCampus=this.weeklyAvgOffCampus,this.fixedWeeklyTotalAverage=this.weeklyTotalAverage,this.fixedWeeklyAvgSchoolUsePercentage=this.weeklyAvgSchoolUsePercentage,this.fixedWeeklyAvgOutOfSchoolPercentage=this.weeklyAvgOutOfSchoolPercentage,this.selectedDailyDate=(0,l.default)().format("YYYY-MM-DD"),this.weekStart=(0,l.default)().startOf("isoWeek"),this.weekEnd=(0,l.default)().endOf("isoWeek"),this.selectedChildHistogram=this.selectedUser,this.fetchLightboxData())},e.prototype.changeDay=function(e){this.selectedDailyDate=(0,l.default)(this.selectedDailyDate).add(e,"days").format("YYYY-MM-DD"),this.fetchLightboxData()},e.prototype.changeWeek=function(e){this.weekStart=this.weekStart.clone().add(e,"weeks"),this.weekEnd=this.weekStart.clone().endOf("isoWeek"),this.fetchLightboxData()},Object.defineProperty(e.prototype,"selectedDailyDateObj",{get:function(){return new Date(this.selectedDailyDate)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"weekLabel",{get:function(){var e=this.weekStart.format("dddd D MMMM"),t=this.weekEnd.format("dddd D MMMM");return"du ".concat(e," au ").concat(t)},enumerable:!1,configurable:!0}),e}();function c(e,t,o,a,r,i){t.children=d(t);var s="/appregistry/screen-time/".concat(o,"/weekly?startDate=").concat(r,"&endDate=").concat(i,"&mock=false"),l="/appregistry/screen-time/".concat(o,"/daily?date=").concat(a,"&mock=false");return Promise.all([e.get(s),e.get(l)]).then(function(e){var o=e[0],a=e[1];return console.log("weekly: ",o.data),console.log("daily: ",a.data),t.hasError=!1,t.errorMessage="",{weekly:o.data.dailySummaries.reduce(function(e,t){return e[t.date]={duration:t.durationMinutes,schoolUsePercentage:t.schoolUsePercentage/100},e},{}),daily:a.data.durations.map(function(e){return{hour:e.hour,duration:e.durationMinutes,schoolUsePercentage:e.schoolUsePercentage/100}})}}).catch(function(e){return t.hasError=!0,404===(null==e?void 0:e.status)?t.errorMessage="Erreur lors de l’identification de l’utilisateur. Contactez l’administrateur de votre établissement.":t.errorMessage="Un problème technique est survenu. Si le problème persiste contactez l’administrateur de votre établissement.",console.error("Error fetching data for current user and dates:",e),Promise.reject(e)})}function d(e){var t=(0,i.session)().user.children;e.isParent=!1;if(t&&Object.keys(t).length>0){e.isParent=!0;var o=100;return Object.entries(t).map(function(e){var t=e[0],a=e[1],r=(o++).toString();return{id:t,name:"".concat(a.firstName," ").concat(a.lastName),userId:r}})}return[]}t.Controller=n;var u=function(){function e(){this.restrict="E",this.template=o(5688).Z,this.scope={},this.bindToController=!0,this.controller=[n],this.controllerAs="ctrl",this.require=["odeScreenTimeWidget"]}return e.prototype.link=function(e,t,o,a){var n=a?a[0]:null;if(n){var u=r.default.injector(["ng"]).get("$http"),h=(0,i.session)().user.userId;n.fetchDataForCurrentUser();var g=null,f=function(e,t,o,a){return console.log("3"),"".concat(e,"_daily_").concat(t,"_weekly_").concat(o,"_").concat(a)};n.fetchDataForCurrentUser=function(){n.errorMessage="",n.hasError=!1;var t=f(n.selectedUser,(0,l.default)().format("YYYY-MM-DD"),(0,l.default)().startOf("isoWeek").format("YYYY-MM-DD"),(0,l.default)().endOf("isoWeek").format("YYYY-MM-DD"));c(u,n,n.selectedUser,(0,l.default)().format("YYYY-MM-DD"),(0,l.default)().startOf("isoWeek").format("YYYY-MM-DD"),(0,l.default)().endOf("isoWeek").format("YYYY-MM-DD")).then(function(o){var a,r,i,s,c,d,u,h,g,f;n.userData[t]={weekly:o.weekly,daily:o.daily},a=o.weekly,r=0,i=0,s=0,c=(0,l.default)().format("YYYY-MM-DD"),d=0,u=0,h=0,g=0,f=0,Object.keys(a).forEach(function(e){var t=a[e],o=t.duration||0,p=t.schoolUsePercentage||0,y=o*p,m=o*(1-p);r+=y,i+=m,s++,h+=y,g+=m,f+=o,(0,l.default)(e).format("YYYY-MM-DD")===c&&(d=y,u=m,n.todaySchoolUsePercentage=100*t.schoolUsePercentage,n.todayOutOfSchoolPercentage=100-100*t.schoolUsePercentage)}),n.todayOnCampus=d,n.todayOffCampus=u,n.todayTotal=d+u,n.weeklyAvgOnCampus=s>0?r/s:0,n.weeklyAvgOffCampus=s>0?i/s:0,n.weeklyTotalAverage=n.weeklyAvgOnCampus+n.weeklyAvgOffCampus,f>0?(n.weeklyAvgSchoolUsePercentage=h/f*100,n.weeklyAvgOutOfSchoolPercentage=g/f*100):(n.weeklyAvgSchoolUsePercentage=0,n.weeklyAvgOutOfSchoolPercentage=0),e.$applyAsync()}).catch(function(t){e.$applyAsync(),console.error("Error fetching initial data for current user:",t)})},n.fetchLightboxData=function(){var t=n.selectedChildHistogram||n.selectedUser;if(t){var o=f(t,n.selectedDailyDate,n.weekStart.format("YYYY-MM-DD"),n.weekEnd.format("YYYY-MM-DD"));n.userData[o]?n.showLightbox&&setTimeout(function(){return n.updateChart()},50):c(u,n,t,n.selectedDailyDate,n.weekStart.format("YYYY-MM-DD"),n.weekEnd.format("YYYY-MM-DD")).then(function(t){n.userData[o]={weekly:t.weekly,daily:t.daily},n.showLightbox&&setTimeout(function(){return n.updateChart()},50),e.$applyAsync()}).catch(function(e){console.error("Error fetching data for lightbox:",e)})}},n.updateChart=function(){var e=t[0].querySelector("#myChart");if(e){var o=e.getContext("2d");if(o){g&&g.destroy();var a=[],r=[],i=[],c=n.selectedChildHistogram||n.selectedUser,d=f(c,n.selectedDailyDate,n.weekStart.format("YYYY-MM-DD"),n.weekEnd.format("YYYY-MM-DD")),u=n.userData[d];if(u){var h="weekly"===n.viewMode?u.weekly:u.daily;if(h){if("weekly"===n.viewMode)Object.keys(h).sort().forEach(function(e){var t=h[e];a.push((0,l.default)(e).format("ddd D")),r.push(t.duration*t.schoolUsePercentage),i.push(t.duration*(1-t.schoolUsePercentage))});else h.forEach(function(e){a.push("".concat(e.hour,"h")),r.push(e.duration*e.schoolUsePercentage),i.push(e.duration*(1-e.schoolUsePercentage))});g=new s.Chart(o,{type:"bar",data:{labels:a,datasets:[{label:"Usage scolaire",data:r,backgroundColor:"#2A9CC8"},{label:"Usage hors scolaire",data:i,backgroundColor:"#ECBE30"}]},options:{plugins:{tooltip:{callbacks:{label:function(e){var t=e.raw;return"".concat(e.dataset.label,": ").concat(t," minutes")}}}},responsive:!0,scales:{x:{stacked:!0},y:{stacked:!0,beginAtZero:!0,title:{display:!0,text:"Minutes"}}}}})}}}}},n.children=d(n),n.isParent&&n.children.length>0?(n.selectedUser||(n.selectedUser=n.children[0].userId),n.fetchDataForCurrentUser()):!n.isParent&&h?(n.selectedUser=h,n.fetchDataForCurrentUser()):(n.hasError=!0,n.errorMessage="Aucun utilisateur disponible pour afficher les données de temps d'écran.",e.$applyAsync()),e.$watch(function(){return n.viewMode},function(e,t){e!==t&&n.showLightbox&&setTimeout(function(){return n.updateChart()},50)}),e.$watch(function(){return n.selectedChildHistogram},function(e,t){e!==t&&n.showLightbox&&n.fetchLightboxData()}),e.$watch(function(){return n.showLightbox},function(e){e?setTimeout(function(){n.updateChart()},100):g&&(g.destroy(),g=null)})}},e}();t.odeModuleName="odeCantineWidgetModule",r.default.module(t.odeModuleName,[]).filter("duration",function(){return function(e){if(isNaN(e)||null===e||e<0)return"0m";var t=Math.floor(e),o=Math.floor(t/60),a=t%60,r="";return o>0&&(r+="".concat(o,"h")),(a>0||0===o&&0===t)&&(r+="".concat(a,"m")),r.trim()||"0m"}}).directive("odeScreenTimeWidget",function(){return new u}),(0,i.notif)().onLangReady().promise.then(function(e){(0,i.conf)().Platform.idiom.addKeys(o(1245))})},1245:e=>{e.exports={}}}]);
|
|
2
|
-
//# sourceMappingURL=screen-time-widget.widget.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"widgets/screen-time-widget/screen-time-widget.widget.js","mappings":"gIAGA,QAFW,unN,8LCDX,iBACA,UACA,UACA,YACA,QAEA,EAAAA,MAAMC,SAAQ,MAAd,EAAAD,MAAkB,EAAAE,eAClB,UAAOC,OAAO,MAGd,8BACW,KAAAC,aAAuB,GACvB,KAAAC,SAA+B,SAE/B,KAAAC,SAA2D,CAAC,EAC5D,KAAAC,mBAA4B,eAASC,OAAO,cAC5C,KAAAC,WAAoB,eAASC,QAAQ,WACrC,KAAAC,SAAkB,eAASC,MAAM,WAEjC,KAAAC,YAA0B,WAAQ,EAElC,KAAAC,cAAgB,EAChB,KAAAC,eAAiB,EACjB,KAAAC,WAAa,EACb,KAAAC,yBAAmC,EACnC,KAAAC,2BAAqC,EAErC,KAAAC,kBAAoB,EACpB,KAAAC,mBAAqB,EACrB,KAAAC,mBAAqB,EACrB,KAAAC,6BAAuC,EACvC,KAAAC,+BAAyC,EAGz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OAPIF,EAAQ,IACRE,GAAU,UAAGF,EAAK,OAElBC,EAAU,GAAgB,IAAVD,GAAgC,IAAjBH,KAC/BK,GAAU,UAAGD,EAAO,MAGjBC,EAAOC,QAAU,IAC5B,CACJ,GAGCC,UAAU,sBAnCf,WACI,OAAO,IAAIC,CACf,IAoCA,IAAAC,SACKC,cACAC,QAAQhI,KAAK,SAACiI,IAGH,IAAAC,QAAOC,SAASC,MAAMC,QAAQ,EAAQ,MAGlD,E","sources":["webpack://ode-ngjs-front/./src/ts/widgets/screen-time-widget/screen-time-widget.widget.html","webpack://ode-ngjs-front/./src/ts/widgets/screen-time-widget/screen-time-widget.widget.ts"],"sourcesContent":["// Module\nvar code = \"<style>.screen-time-summary{padding:16px;font-family:Roboto,sans-serif;display:flex;flex-direction:column;gap:12px}.title{padding-bottom:6px;font-size:16px;color:#4a4a4a;font-weight:700;border-bottom:1px solid #e0e0e0}.summary-row{display:flex;gap:12px}.summary-row:nth-of-type(2){margin-top:10px}.summary-block{flex:1;background:#e5f5ff;border-radius:12px;padding:12px;box-shadow:0 1px 3px rgba(0,0,0,.1)}.summary-block .label{font-size:16px;color:#4a4a4a;font-weight:700;margin-bottom:4px}.summary-block .value{font-size:32px;color:#333}.percentage-bar-container{width:100%;height:10px;background-color:#e0e0e0;border-radius:5px;margin-top:5px;display:flex;overflow:hidden}.percentage-bar{height:100%;transition:width .5s ease-in-out;border-radius:5px}.au-college{background-color:#2a9cc8}.hors-college{background-color:#ecbe30}.legend{display:flex;gap:16px;align-items:center;margin-top:10px;font-size:10px;color:#333}.legend-item{display:flex;align-items:center;gap:6px}.legend-square{width:16px;height:16px;border-radius:4px}.legend-au-college{background-color:#2a9cc8}.legend-hors-college{background-color:#ecbe30}.custom-select{appearance:none;border:none;padding:8px 32px 8px 12px;border-radius:6px;font-size:16px;color:#333;font-family:Roboto,sans-serif;background:#fff url(\\\"data:image/svg+xml,%3Csvg fill='none' stroke='%23666' stroke-width='2' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E\\\") no-repeat right 10px center;background-size:16px;cursor:pointer;min-width:150px}.custom-select:focus{outline:0;box-shadow:0 0 0 2px rgba(42,156,200,.3)}.see-more{display:flex;justify-content:flex-end;margin-top:8px;padding-left:4px}.see-more button{background-color:transparent;border:none;font-family:Roboto,sans-serif;font-weight:600;font-size:16px;line-height:24px;padding:6px 12px;cursor:pointer;color:#2a9cc8;border-radius:4px;transition:background-color .2s ease}.see-more button:hover{background-color:#f0f8fc}.centered-controls{margin:0 auto 20px auto;width:fit-content;text-align:center}.close-button-container{display:flex;justify-content:flex-end;margin-top:20px}.close-button{width:84px;height:40px;padding:8px 16px;background:#ff8d2e;color:#fff;font-size:16px;font-weight:700;border:none;border-radius:8px;cursor:pointer;transition:background .3s ease}.close-button:hover{background:#e67c24}.date-controls{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.nav-button{background:0 0;border:none;font-size:24px;cursor:pointer}.date-navigation{display:flex;align-items:center;justify-content:center;gap:1rem}.date-navigation button{background:0 0;border:none;font-size:1.5rem;cursor:pointer}.selected-date{cursor:pointer;font-weight:700}.error-message{background-color:#ffe5e5;color:#c00;border:1px solid #c00;padding:12px;border-radius:6px;font-size:14px;font-weight:500}</style> <div class=\\\"screen-time-widget-container\\\"> <div class=\\\"screen-time-summary\\\"> <div class=\\\"title\\\"> <div class=\\\"label\\\">TEMPS D'ÉCRAN</div> </div> <div ng-if=\\\"ctrl.isParent\\\"> <select id=\\\"userSelect\\\" class=\\\"custom-select\\\" ng-model=\\\"ctrl.selectedUser\\\" ng-options=\\\"child.userId as child.name for child in ctrl.children\\\" ng-change=\\\"ctrl.fetchDataForCurrentUser()\\\"> </select> </div> <div class=\\\"error-message\\\" ng-if=\\\"ctrl.errorMessage\\\"> {{ ctrl.errorMessage }} </div> <div ng-if=\\\"!ctrl.errorMessage\\\"> <div class=\\\"summary-row\\\"> <div class=\\\"summary-block\\\"> <div class=\\\"label\\\">Aujourd'hui</div> <div class=\\\"value\\\">{{ ctrl.todayTotal | duration }}</div> <div class=\\\"percentage-bar-container\\\"> <div class=\\\"percentage-bar au-college\\\" ng-style=\\\"{ width: ctrl.todaySchoolUsePercentage + '%' }\\\" title=\\\"{{ ctrl.todaySchoolUsePercentage | duration }} au collège\\\"> </div> <div class=\\\"percentage-bar hors-college\\\" ng-style=\\\"{ width: ctrl.todayOutOfSchoolPercentage + '%' }\\\" title=\\\"{{ ctrl.todayOutOfSchoolPercentage | duration }} hors collège\\\"></div> </div> </div> </div> <div class=\\\"summary-row\\\"> <div class=\\\"summary-block\\\"> <div class=\\\"label\\\">Moyenne de la semaine</div> <div class=\\\"value\\\">{{ ctrl.weeklyTotalAverage | duration }}</div> <div class=\\\"percentage-bar-container\\\"> <div class=\\\"percentage-bar au-college\\\" ng-style=\\\"{ width: ctrl.weeklyAvgSchoolUsePercentage + '%' }\\\" title=\\\"{{ ctrl.weeklyAvgSchoolUsePercentage | duration }} au Collège\\\"> </div> <div class=\\\"percentage-bar hors-college\\\" ng-style=\\\"{ width: ctrl.weeklyAvgOutOfSchoolPercentage + '%' }\\\" title=\\\"{{ ctrl.weeklyAvgOutOfSchoolPercentage | duration}} hors collège\\\"></div> </div> </div> </div> <div class=\\\"legend\\\"> <div class=\\\"legend-item\\\"> <div class=\\\"legend-square legend-au-college\\\"></div> <span>Au collège</span> </div> <div class=\\\"legend-item\\\"> <div class=\\\"legend-square legend-hors-college\\\"></div> <span>Hors collège</span> </div> <div class=\\\"see-more\\\"> <button ng-click=\\\"ctrl.toggleLightbox(true)\\\">Voir le détail</button> </div> </div> </div> </div> <ode-modal visible=\\\"ctrl.showLightbox\\\" on-close=\\\"ctrl.toggleLightbox(false)\\\" size=\\\"lg\\\" dnd-nodrag> <ode-modal-title> <h2>Temps d'écran</h2> </ode-modal-title> <ode-modal-body> <div class=\\\"centered-controls\\\"> <label style=\\\"font-size:14px\\\" for=\\\"userSelect\\\">Utilisateur :</label> <div ng-if=\\\"ctrl.isParent\\\"> <select id=\\\"userSelect\\\" class=\\\"custom-select\\\" ng-model=\\\"ctrl.selectedChildHistogram\\\" ng-options=\\\"child.userId as child.name for child in ctrl.children\\\" ng-change=\\\"ctrl.fetchLightboxData()\\\"> </select> </div> <label for=\\\"viewMode\\\">Affichage :</label> <select id=\\\"viewMode\\\" class=\\\"custom-select\\\" ng-model=\\\"ctrl.viewMode\\\" ng-change=\\\"ctrl.updateChart()\\\"> <option value=\\\"weekly\\\">Hebdomadaire</option> <option value=\\\"daily\\\">Quotidien</option> </select> </div> <canvas id=\\\"myChart\\\" style=\\\"width:100%;height:200px\\\"></canvas> <div class=\\\"date-selectors centered-controls\\\" ng-if=\\\"ctrl.showLightbox\\\"> <div class=\\\"date-navigation\\\" ng-if=\\\"ctrl.viewMode === 'daily'\\\"> <button ng-click=\\\"ctrl.changeDay(-1)\\\">←</button> <div ng-if=\\\"!ctrl.showDatePicker\\\" class=\\\"selected-date\\\" ng-click=\\\"ctrl.toggleDatePicker(true)\\\"> {{ ctrl.selectedDailyDateObj | date:'fullDate' }} </div> <input type=\\\"date\\\" ng-if=\\\"ctrl.showDatePicker\\\" ng-model=\\\"ctrl.selectedDailyDate\\\" ng-change=\\\"ctrl.setDateFromPicker(ctrl.selectedDailyDate)\\\" ng-blur=\\\"ctrl.toggleDatePicker(false)\\\" max=\\\"{{ ctrl.selectedDailyDate }}\\\"/> <button ng-click=\\\"ctrl.changeDay(1)\\\">→</button> </div> <div class=\\\"date-navigation\\\" ng-if=\\\"ctrl.viewMode === 'weekly'\\\"> <button ng-click=\\\"ctrl.changeWeek(-1)\\\">←</button> <div class=\\\"selected-date\\\">{{ ctrl.weekLabel }}</div> <button ng-click=\\\"ctrl.changeWeek(1)\\\">→</button> </div> </div> <div class=\\\"close-button-container\\\"> <button class=\\\"close-button\\\" ng-click=\\\"ctrl.toggleLightbox(false)\\\">Fermer</button> </div> </ode-modal-body> </ode-modal> </div>\";\n// Exports\nexport default code;","import angular, { IAttributes, IController, IDirective, IScope, IHttpService } from \"angular\";\nimport { conf, notif, session } from \"../../utils\";\nimport { Chart, registerables } from \"chart.js\";\nimport moment, { Moment } from \"moment\";\nimport 'moment/locale/fr';\n\nChart.register(...registerables);\nmoment.locale('fr');\n\n// Controller\nexport class Controller {\n public selectedUser: string = \"\";\n public viewMode: \"weekly\" | \"daily\" = \"weekly\";\n\n public userData: { [key: string]: { weekly: any, daily: any } } = {};\n public selectedDailyDate: string = moment().format('YYYY-MM-DD');\n public weekStart: Moment = moment().startOf('isoWeek'); // Monday\n public weekEnd: Moment = moment().endOf('isoWeek'); // Sunday\n\n public updateChart: () => void = () => { };\n\n public todayOnCampus = 0;\n public todayOffCampus = 0;\n public todayTotal = 0;\n public todaySchoolUsePercentage: number = 0;\n public todayOutOfSchoolPercentage: number = 0;\n\n public weeklyAvgOnCampus = 0;\n public weeklyAvgOffCampus = 0;\n public weeklyTotalAverage = 0;\n public weeklyAvgSchoolUsePercentage: number = 0;\n public weeklyAvgOutOfSchoolPercentage: number = 0;\n\n // new props\n public fixedTodayOnCampus = 0;\n public fixedTodayOffCampus = 0;\n public fixedTodayTotal = 0;\n public fixedTodaySchoolUsePercentage: number = 0;\n public fixedTodayOutOfSchoolPercentage: number = 0;\n\n public fixedWeeklyAvgOnCampus = 0;\n public fixedWeeklyAvgOffCampus = 0;\n public fixedWeeklyTotalAverage = 0;\n public fixedWeeklyAvgSchoolUsePercentage: number = 0;\n public fixedWeeklyAvgOutOfSchoolPercentage: number = 0;\n\n\n // end of new \n\n public customWeekMode: boolean = false;\n public customStartDate: string = \"\";\n public customEndDate: string = \"\";\n\n public isParent: boolean = false;\n\n public hasError: boolean = false;\n public errorMessage: string = \"\";\n\n public fetchDataForCurrentUser: () => void = () => { };\n public fetchLightboxData: () => void = () => { };\n\n public showLightbox: boolean = false;\n public showDatePicker: boolean = false;\n\n public children: { id: string; name: string; userId: string }[] = [];\n public selectedChild = null;\n public selectedChildHistogram = \"\";\n\n public toggleDatePicker(show: boolean) {\n this.showDatePicker = show;\n }\n\n public setDateFromPicker(date: string) {\n this.selectedDailyDate = moment(date).format('YYYY-MM-DD');\n this.showDatePicker = false;\n this.fetchLightboxData();\n }\n\n public toggleLightbox(show: boolean) {\n this.showLightbox = show;\n if (show) {\n // Store the current summary values when lightbox opens\n this.fixedTodayOnCampus = this.todayOnCampus;\n this.fixedTodayOffCampus = this.todayOffCampus;\n this.fixedTodayTotal = this.todayTotal;\n this.fixedTodaySchoolUsePercentage = this.todaySchoolUsePercentage;\n this.fixedTodayOutOfSchoolPercentage = this.todayOutOfSchoolPercentage;\n this.fixedWeeklyAvgOnCampus = this.weeklyAvgOnCampus;\n this.fixedWeeklyAvgOffCampus = this.weeklyAvgOffCampus;\n this.fixedWeeklyTotalAverage = this.weeklyTotalAverage;\n this.fixedWeeklyAvgSchoolUsePercentage = this.weeklyAvgSchoolUsePercentage;\n this.fixedWeeklyAvgOutOfSchoolPercentage = this.weeklyAvgOutOfSchoolPercentage;\n\n // Initialize lightbox dates to current date/week\n this.selectedDailyDate = moment().format('YYYY-MM-DD');\n this.weekStart = moment().startOf('isoWeek');\n this.weekEnd = moment().endOf('isoWeek');\n this.selectedChildHistogram = this.selectedUser;\n this.fetchLightboxData();\n }\n }\n\n public changeDay(offset: number) {\n this.selectedDailyDate = moment(this.selectedDailyDate).add(offset, 'days').format('YYYY-MM-DD');\n this.fetchLightboxData();\n }\n\n public changeWeek(offset: number) {\n this.weekStart = this.weekStart.clone().add(offset, 'weeks');\n this.weekEnd = this.weekStart.clone().endOf('isoWeek');\n this.fetchLightboxData();\n }\n\n public get selectedDailyDateObj(): Date {\n return new Date(this.selectedDailyDate);\n }\n\n public get weekLabel(): string {\n const start = this.weekStart.format('dddd D MMMM');\n const end = this.weekEnd.format('dddd D MMMM');\n return `du ${start} au ${end}`;\n }\n}\n\nfunction fetchAllScreenTimeDataForUserAndDates($http: IHttpService, ctrl: Controller, userId: string, dailyDate: string, startDate: string, endDate: string): Promise<{ weekly: any, daily: any }> {\n ctrl.children = fetchChildren(ctrl);\n\n const weeklyEndpoint = `/appregistry/screen-time/${userId}/weekly?startDate=${startDate}&endDate=${endDate}&mock=false`;\n const dailyEndpoint = `/appregistry/screen-time/${userId}/daily?date=${dailyDate}&mock=false`;\n\n return Promise.all([\n $http.get(weeklyEndpoint),\n $http.get(dailyEndpoint)\n ]).then(([weeklyResponse, dailyResponse]: [any, any]) => {\n console.log(\"weekly: \", weeklyResponse.data);\n console.log(\"daily: \", dailyResponse.data);\n ctrl.hasError = false;\n ctrl.errorMessage = \"\";\n return {\n weekly: weeklyResponse.data.dailySummaries.reduce((acc: any, day: any) => {\n acc[day.date] = {\n duration: day.durationMinutes,\n schoolUsePercentage: day.schoolUsePercentage / 100 // convert to ratio\n };\n return acc;\n }, {}),\n daily: dailyResponse.data.durations.map((hour: any) => ({\n hour: hour.hour,\n duration: hour.durationMinutes,\n schoolUsePercentage: hour.schoolUsePercentage / 100 // convert to ratio\n }))\n };\n }).catch(error => {\n ctrl.hasError = true;\n\n if (error?.status === 404) {\n ctrl.errorMessage = \"Erreur lors de l’identification de l’utilisateur. Contactez l’administrateur de votre établissement.\";\n } else {\n ctrl.errorMessage = \"Un problème technique est survenu. Si le problème persiste contactez l’administrateur de votre établissement.\";\n }\n\n console.error(\"Error fetching data for current user and dates:\", error);\n return Promise.reject(error);\n });\n}\n\nfunction fetchChildren(ctrl: Controller) {\n const childrenObj = session().user.children;\n ctrl.isParent = false;\n\n const USE_MOCK_IDS = true;\n\n if (childrenObj && Object.keys(childrenObj).length > 0) {\n ctrl.isParent = true;\n\n // Replace userIds with mocked values: 100, 101, 102, ...\n let mockIdCounter = 100;\n\n return Object.entries(childrenObj).map(([userId, childData]) => {\n const child = childData as { firstName: string; lastName: string };\n const mockedId = (mockIdCounter++).toString(); // To remove and use real Id\n return {\n id: userId,\n name: `${child.firstName} ${child.lastName}`,\n userId: USE_MOCK_IDS ? mockedId : userId\n };\n });\n } else {\n return [];\n }\n}\n\nclass Directive implements IDirective<IScope, JQLite, IAttributes, IController[]> {\n restrict = \"E\";\n template = require(\"./screen-time-widget.widget.html\").default;\n scope = {};\n bindToController = true;\n controller = [Controller];\n controllerAs = \"ctrl\";\n require = [\"odeScreenTimeWidget\"];\n\n link(scope: IScope, elem: angular.IAugmentedJQuery, attrs: IAttributes, controllers?: IController[]) {\n const ctrl: Controller | null = controllers ? (controllers[0] as Controller) : null;\n if (!ctrl) return;\n\n const $http = angular.injector([\"ng\"]).get<IHttpService>(\"$http\");\n const currentUserId = session().user.userId;\n\n ctrl.fetchDataForCurrentUser();\n\n let chartInstance: Chart | null = null;\n\n // Function to update the summary values from the pre-fetched weekly data\n const updateSummary = (weeklyData: any) => {\n let totalOnCampus = 0;\n let totalOffCampus = 0;\n let daysCount = 0;\n const today = moment().format(\"YYYY-MM-DD\");\n let todayOnCampusTemp = 0;\n let todayOffCampusTemp = 0;\n\n let weeklyTotalSchoolUseDuration = 0;\n let weeklyTotalOutOfSchoolDuration = 0;\n let weeklyTotalOverallDuration = 0;\n\n Object.keys(weeklyData).forEach(dateStr => {\n const entry = weeklyData[dateStr];\n const duration = entry.duration || 0;\n const schoolUsePct = entry.schoolUsePercentage || 0;\n\n const onCampus = duration * schoolUsePct;\n const offCampus = duration * (1 - schoolUsePct);\n\n totalOnCampus += onCampus;\n totalOffCampus += offCampus;\n daysCount++;\n\n weeklyTotalSchoolUseDuration += onCampus;\n weeklyTotalOutOfSchoolDuration += offCampus;\n weeklyTotalOverallDuration += duration;\n\n if (moment(dateStr).format(\"YYYY-MM-DD\") === today) {\n todayOnCampusTemp = onCampus;\n todayOffCampusTemp = offCampus;\n ctrl.todaySchoolUsePercentage = entry.schoolUsePercentage * 100;\n ctrl.todayOutOfSchoolPercentage = 100 - (entry.schoolUsePercentage * 100);\n }\n });\n\n ctrl.todayOnCampus = todayOnCampusTemp;\n ctrl.todayOffCampus = todayOffCampusTemp;\n ctrl.todayTotal = todayOnCampusTemp + todayOffCampusTemp;\n ctrl.weeklyAvgOnCampus = daysCount > 0 ? totalOnCampus / daysCount : 0;\n ctrl.weeklyAvgOffCampus = daysCount > 0 ? totalOffCampus / daysCount : 0;\n ctrl.weeklyTotalAverage = ctrl.weeklyAvgOnCampus + ctrl.weeklyAvgOffCampus;\n\n if (weeklyTotalOverallDuration > 0) {\n ctrl.weeklyAvgSchoolUsePercentage = (weeklyTotalSchoolUseDuration / weeklyTotalOverallDuration) * 100;\n ctrl.weeklyAvgOutOfSchoolPercentage = (weeklyTotalOutOfSchoolDuration / weeklyTotalOverallDuration) * 100;\n } else {\n ctrl.weeklyAvgSchoolUsePercentage = 0;\n ctrl.weeklyAvgOutOfSchoolPercentage = 0;\n }\n };\n\n // Helper to generate a unique key for caching data based on user and date range\n const generateDataKey = (userId: string, dailyDate: string, startDate: string, endDate: string) => {\n console.log(\"3\");\n return `${userId}_daily_${dailyDate}_weekly_${startDate}_${endDate}`;\n };\n\n // New function assigned to ctrl.fetchDataForCurrentUser to be called from HTML\n ctrl.fetchDataForCurrentUser = () => {\n ctrl.errorMessage = \"\";\n ctrl.hasError = false;\n const currentKey = generateDataKey(\n ctrl.selectedUser,\n moment().format('YYYY-MM-DD'), // Always use today's date for initial load\n moment().startOf('isoWeek').format('YYYY-MM-DD'),\n moment().endOf('isoWeek').format('YYYY-MM-DD')\n );\n\n // Fetch initial summary data (today and current week)\n fetchAllScreenTimeDataForUserAndDates(\n $http,\n ctrl,\n ctrl.selectedUser,\n moment().format('YYYY-MM-DD'),\n moment().startOf('isoWeek').format('YYYY-MM-DD'),\n moment().endOf('isoWeek').format('YYYY-MM-DD')\n ).then((data) => {\n ctrl.userData[currentKey] = { weekly: data.weekly, daily: data.daily };\n updateSummary(data.weekly); // Update the main summary values\n scope.$applyAsync();\n }).catch(error => {\n scope.$applyAsync();\n console.error(\"Error fetching initial data for current user:\", error);\n });\n };\n\n ctrl.fetchLightboxData = () => {\n\n const userIdForLightbox = ctrl.selectedChildHistogram || ctrl.selectedUser;\n\n if (!userIdForLightbox) return;\n\n const currentKey = generateDataKey(\n userIdForLightbox,\n ctrl.selectedDailyDate,\n ctrl.weekStart.format('YYYY-MM-DD'),\n ctrl.weekEnd.format('YYYY-MM-DD')\n );\n\n // Check if data is already cached\n if (ctrl.userData[currentKey]) {\n if (ctrl.showLightbox) {\n setTimeout(() => ctrl.updateChart(), 50);\n }\n } else {\n fetchAllScreenTimeDataForUserAndDates(\n $http,\n ctrl,\n userIdForLightbox,\n ctrl.selectedDailyDate,\n ctrl.weekStart.format('YYYY-MM-DD'),\n ctrl.weekEnd.format('YYYY-MM-DD')\n ).then((data) => {\n ctrl.userData[currentKey] = { weekly: data.weekly, daily: data.daily };\n if (ctrl.showLightbox) {\n setTimeout(() => ctrl.updateChart(), 50);\n }\n scope.$applyAsync();\n }).catch(error => {\n console.error(\"Error fetching data for lightbox:\", error);\n });\n }\n };\n\n ctrl.updateChart = () => {\n const canvas = elem[0].querySelector<HTMLCanvasElement>(\"#myChart\");\n if (!canvas) return;\n\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return;\n\n if (chartInstance) chartInstance.destroy();\n\n let labels: string[] = [];\n let appTimes: number[] = [];\n let otherTimes: number[] = [];\n\n const userIdForChart = ctrl.selectedChildHistogram || ctrl.selectedUser;\n\n // Use the dates from the lightbox controls for the chart data key\n const currentDataKey = generateDataKey(\n userIdForChart,\n ctrl.selectedDailyDate,\n ctrl.weekStart.format('YYYY-MM-DD'),\n ctrl.weekEnd.format('YYYY-MM-DD')\n );\n const currentUserAndDateData = ctrl.userData[currentDataKey];\n\n if (!currentUserAndDateData) return;\n\n const dataToUse: any = ctrl.viewMode === \"weekly\" ? currentUserAndDateData.weekly : currentUserAndDateData.daily;\n if (!dataToUse) return;\n\n if (ctrl.viewMode === \"weekly\") {\n const sortedDates = Object.keys(dataToUse).sort();\n\n sortedDates.forEach(dateStr => {\n const entry = dataToUse[dateStr];\n labels.push(moment(dateStr).format(\"ddd D\"));\n appTimes.push(entry.duration * entry.schoolUsePercentage);\n otherTimes.push(entry.duration * (1 - entry.schoolUsePercentage));\n });\n } else {\n dataToUse.forEach((hourData: any) => {\n labels.push(`${hourData.hour}h`);\n appTimes.push(hourData.duration * hourData.schoolUsePercentage);\n otherTimes.push(hourData.duration * (1 - hourData.schoolUsePercentage));\n });\n }\n\n chartInstance = new Chart(ctx, {\n type: \"bar\",\n data: {\n labels,\n datasets: [\n {\n label: \"Usage scolaire\",\n data: appTimes,\n backgroundColor: \"#2A9CC8\"\n },\n {\n label: \"Usage hors scolaire\",\n data: otherTimes,\n backgroundColor: \"#ECBE30\"\n }\n ]\n },\n options: {\n plugins: {\n tooltip: {\n callbacks: {\n label: function (context) {\n const value = context.raw;\n return `${context.dataset.label}: ${value} minutes`;\n }\n }\n }\n },\n responsive: true,\n scales: {\n x: {\n stacked: true\n },\n y: {\n stacked: true,\n beginAtZero: true,\n title: {\n display: true,\n text: \"Minutes\"\n }\n }\n }\n }\n });\n };\n\n ctrl.children = fetchChildren(ctrl);\n\n // Determine the user whose data should be fetched on load\n if (ctrl.isParent && ctrl.children.length > 0) {\n // If a parent, and has children, default to the first child if no child is selected yet\n if (!ctrl.selectedUser) {\n ctrl.selectedUser = ctrl.children[0].userId;\n }\n ctrl.fetchDataForCurrentUser();\n } else if (!ctrl.isParent && currentUserId) {\n // If not a parent, and current user ID is available, fetch data for themselves\n ctrl.selectedUser = currentUserId; // Set selectedUser to the current logged-in user's ID\n ctrl.fetchDataForCurrentUser();\n } else {\n // No children AND no current user ID (or other error condition)\n ctrl.hasError = true;\n ctrl.errorMessage = \"Aucun utilisateur disponible pour afficher les données de temps d'écran.\";\n scope.$applyAsync(); // Ensure the error message is displayed\n }\n\n // Watch for changes in view mode (within lightbox): only updates the chart\n scope.$watch(() => ctrl.viewMode, (newVal, oldVal) => {\n if (newVal !== oldVal && ctrl.showLightbox) {\n setTimeout(() => ctrl.updateChart(), 50);\n }\n });\n // Watch for selectedUser changes within the lightbox to update chart data\n scope.$watch(() => ctrl.selectedChildHistogram, (newVal, oldVal) => { // Changed from ctrl.selectedUser\n if (newVal !== oldVal && ctrl.showLightbox) {\n ctrl.fetchLightboxData();\n }\n });\n\n // Watch for lightbox visibility changes\n scope.$watch(() => ctrl.showLightbox, (isVisible: boolean) => {\n if (isVisible) {\n setTimeout(() => {\n ctrl.updateChart();\n }, 100);\n } else {\n if (chartInstance) {\n chartInstance.destroy();\n chartInstance = null;\n }\n }\n });\n }\n}\n\n// Factory function for the directive\nfunction DirectiveFactory() {\n return new Directive();\n}\n\n// Define the module name\nexport const odeModuleName = \"odeCantineWidgetModule\";\n\n// Angular module definition\nangular\n .module(odeModuleName, [])\n // Define the custom 'duration' filter\n .filter('duration', function () {\n return function (input: number) {\n if (isNaN(input) || input === null || input < 0) {\n return '0m';\n }\n\n const totalMinutes = Math.floor(input);\n const hours = Math.floor(totalMinutes / 60);\n const minutes = totalMinutes % 60;\n\n let result = '';\n\n if (hours > 0) {\n result += `${hours}h`;\n }\n if (minutes > 0 || (hours === 0 && totalMinutes === 0)) {\n result += `${minutes}m`;\n }\n\n return result.trim() || '0m';\n };\n })\n\n // Register the directive\n .directive(\"odeScreenTimeWidget\", DirectiveFactory);\n\n// Internationalization setup\nnotif()\n .onLangReady()\n .promise.then((lang) => {\n switch (lang) {\n default:\n conf().Platform.idiom.addKeys(require(\"./i18n/fr.json\"));\n break;\n }\n });\n"],"names":["Chart","register","registerables","locale","selectedUser","viewMode","userData","selectedDailyDate","format","weekStart","startOf","weekEnd","endOf","updateChart","todayOnCampus","todayOffCampus","todayTotal","todaySchoolUsePercentage","todayOutOfSchoolPercentage","weeklyAvgOnCampus","weeklyAvgOffCampus","weeklyTotalAverage","weeklyAvgSchoolUsePercentage","weeklyAvgOutOfSchoolPercentage","fixedTodayOnCampus","fixedTodayOffCampus","fixedTodayTotal","fixedTodaySchoolUsePercentage","fixedTodayOutOfSchoolPercentage","fixedWeeklyAvgOnCampus","fixedWeeklyAvgOffCampus","fixedWeeklyTotalAverage","fixedWeeklyAvgSchoolUsePercentage","fixedWeeklyAvgOutOfSchoolPercentage","customWeekMode","customStartDate","customEndDate","isParent","hasError","errorMessage","fetchDataForCurrentUser","fetchLightboxData","showLightbox","showDatePicker","children","selectedChild","selectedChildHistogram","toggleDatePicker","show","this","setDateFromPicker","date","toggleLightbox","changeDay","offset","add","changeWeek","clone","Date","start","end","fetchAllScreenTimeDataForUserAndDates","$http","ctrl","userId","dailyDate","startDate","endDate","fetchChildren","weeklyEndpoint","dailyEndpoint","Promise","all","get","then","weeklyResponse","dailyResponse","console","log","data","weekly","dailySummaries","reduce","acc","day","duration","durationMinutes","schoolUsePercentage","daily","durations","map","hour","catch","error","status","reject","childrenObj","session","user","Object","keys","length","entries","child","mockedId","toString","id","name","firstName","lastName","Controller","restrict","template","scope","bindToController","controller","controllerAs","require","link","elem","attrs","controllers","injector","currentUserId","chartInstance","generateDataKey","currentKey","weeklyData","totalOnCampus","totalOffCampus","daysCount","today","todayOnCampusTemp","todayOffCampusTemp","weeklyTotalSchoolUseDuration","weeklyTotalOutOfSchoolDuration","weeklyTotalOverallDuration","forEach","dateStr","entry","schoolUsePct","onCampus","offCampus","$applyAsync","userIdForLightbox","setTimeout","canvas","querySelector","ctx","getContext","destroy","labels","appTimes","otherTimes","userIdForChart","currentDataKey","currentUserAndDateData","dataToUse","sort","push","hourData","type","datasets","label","backgroundColor","options","plugins","tooltip","callbacks","context","value","raw","dataset","responsive","scales","x","stacked","y","beginAtZero","title","display","text","$watch","newVal","oldVal","isVisible","odeModuleName","module","filter","input","isNaN","totalMinutes","Math","floor","hours","minutes","result","trim","directive","Directive","notif","onLangReady","promise","lang","conf","Platform","idiom","addKeys"],"sourceRoot":""}
|