\r\n
\r\n
\r\n\r\n\t
\r\n\r\n
\r\n\r\n
\r\n","import { Component, ViewEncapsulation, OnInit, OnDestroy, HostListener, Inject }\tfrom '@angular/core';\r\nimport { MatDialog, MatDialogRef, MAT_DIALOG_DATA } \t\t\t\tfrom '@angular/material';\r\nimport { EditionProcessusModalComponent } \t\t\t\tfrom './modals/editionProcessusModal.component';\r\nimport { ConfirmDeleteProcessusModalComponent } \t\t\tfrom './modals/confirmDeleteProcessusModal.component';\r\nimport { InfosDeleteProcessusModalComponent } \t\t\t\tfrom './modals/infosDeleteProcessusModal.component';\r\n\r\nimport { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';\r\n\r\nimport { AdminData }\tfrom '../../../providers/admin-data';\r\nimport { AdminService } from '../../../services/admin.service';\r\nimport { SpecialTime }\tfrom '../../../classes/specialTime.class';\r\n\r\nimport { Observable } from 'rxjs/Rx';\r\n\r\nimport * as htmlEncode\tfrom 'js-htmlencode';\r\nimport * as _\t\t\tfrom 'underscore';\r\nimport { NavigationStart, Router } from '@angular/router';\r\n\r\n\r\n\r\n\r\n@Component({\r\n selector:\t\t'app-admin-system',\r\n encapsulation:\tViewEncapsulation.None,\r\n templateUrl:\t'./admin-system.component.html',\r\n styleUrls:\t\t['./admin-system.component.scss']\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class AdminSystemComponent implements OnInit, OnDestroy\r\n{\r\n\tprivate routeSub:any; // subscription to route observer\r\n\r\n\r\n\r\n public moFromGroupMain: FormGroup;\r\n\r\n public moFormCtrlUrlMailServer:\t\t\tFormControl;\r\n public moFormCtrlMailContact:\t\t\tFormControl;\r\n public moFormCtrlMailNoReply:\t\t\tFormControl;\r\n public moFormCtrlTypeMailServer:\t\tFormControl;\r\n public moFormCtrlHostMailServer:\t\tFormControl;\r\n public moFormCtrlPortMailServer:\t\tFormControl;\r\n public moFormCtrlSecureMailServer:\t\tFormControl;\r\n public moFormCtrlUseAccount:\t\t\tFormControl;\r\n public moFormCtrlLoginAccount:\t\t\tFormControl;\r\n\tpublic moFormCtrlPasswordAccount:\t\tFormControl;\r\n\tpublic moFormCtrlNumericEnabled:\t\tFormControl;\r\n\tpublic moFormCtrlSpecialTimeEnabled:\tFormControl;\r\n\t//public moFormCtrlSpecialTimeArray:\tFormControl;\r\n\r\n\tpublic moFormCtrlSpecialTimeName:\t\tFormControl;\r\n\tpublic moFormCtrlSpecialTimeType:\t\tFormControl;\r\n\r\n public moAdminSubscription:\tany;\r\n public mbShowItemGeneral\t\t= true;\r\n\tpublic mbShowItemProcessus = false;\r\n\tpublic mbShowItemMail\t\t\t= false;\r\n\r\n public urlMailServer:\tany;\r\n public mailContact:\t\tany;\r\n public mailNoReply:\t\tany;\r\n\r\n public hostMailServer:\t\tany;\r\n public portMailServer:\t\tany;\r\n public typeMailServer:\t\tstring\t= 'postfix';\r\n public secureMailServer:\tboolean = false;\r\n\r\n\r\n public useAccount:\t\tboolean = false;\r\n public loginAccount:\tstring\t= '';\r\n public passwordAccount: string\t= '';\r\n\r\n public mainParametersUpdated: boolean = false;\r\n\r\n public typesMailsServer: any[] = [\r\n {\r\n value: 'postfix',\r\n text: 'Postfix'\r\n\t\t},\r\n\t\t{\r\n value: 'smtp',\r\n text: 'SMTP'\r\n }\r\n\t];\r\n\r\n\tpublic numericEnabled: \t\tboolean \t\t= false;\r\n\tpublic specialTimeArray: \tSpecialTime[] \t= [];\r\n\tpublic specialTimeEnabled: \tboolean \t\t= false;\r\n\r\n\tpublic scenariosAvailable:\t\tany[] = [];\r\n\tpublic mailsTemplatesAvailable: any[] = [];\r\n\r\n public titleScenarioSelected:\t\tany;\r\n\tpublic scenarioSelected:\t\t\tany;\r\n\tpublic titleMailTemplateSelected:\tany;\r\n\tpublic mailTemplateSelected:\t\tany;\r\n\tpublic quill:\t\t\t\t\t\tany;\r\n\r\n\tpublic specialTimeName:\t\tstring \t= '';\r\n\tpublic specialTimeType:\t\tstring \t= '';\r\n\tpublic canValidParams: \t\tboolean = false;\r\n\tpublic RouterSubscription: \tany;\r\n\r\n\tquillModules =\r\n\t{\r\n\t\ttoolbar:\r\n\t\t{\r\n\t\t\tcontainer: [\r\n\t\t\t\t[{ 'font': [''] }],\r\n\t\t\t\t[{ 'size': ['small', false, 'large', 'huge'] }],\r\n\t\t\t\t['bold', 'italic', 'underline', 'strike'],\r\n\t\t\t\t[{ 'header': 1 }, { 'header': 2 }],\r\n\t\t\t\t[{ 'color': [''] }, { 'background': [''] }],\r\n\t\t\t\t[{ 'list': 'ordered' }, { 'list': 'bullet' }],\r\n\t\t\t\t[{ 'align': [''] }]\r\n\t\t\t]\r\n\t\t},\r\n//\t\timageResize: true,\r\n\t\tformula: true\r\n\t};\r\n\r\n\tloading = true;\r\n\r\n\t/**\r\n\t *\r\n\t * @param dialog\r\n\t * @param adminService\r\n\t * @param adminData\r\n\t * @param fb\r\n\t */\r\n constructor(public dialog:\t\t\tMatDialog,\r\n public adminService:\tAdminService,\r\n public adminData:\t\tAdminData,\r\n\t\t\t\tpublic router:\t\t\tRouter,\r\n public fb:\t\t\t\tFormBuilder)\r\n {\r\n this.mainParametersUpdated = false;\r\n\t\tthis.adminService.getAllAdminParameters();\r\n\t\t\r\n\t\tlet isFirst = true;\r\n\t\tthis.RouterSubscription = router.events.subscribe((val) => \r\n\t\t{\r\n\t\t\tif (val instanceof NavigationStart && isFirst && this.moFromGroupMain.dirty) \r\n\t\t\t{\r\n\t\t\t\tlet result = confirm(\"Voulez vous vraiment quitter cette page ? Des paramètres n'ont pas été enregistrés et vont être perdus\");\r\n\t\t\t\tif(!result)\r\n\t\t\t\t{\r\n\t\t\t\t\trouter.navigateByUrl('/admin');\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tisFirst = false;\r\n\t\t\t\t\tthis.router.navigate([val.url]); \r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t});\r\n\t}\r\n\t\r\n/*\r\n\t\r\n\t@HostListener('window:beforeunload', ['$event'])\r\n\tbeforeunloadHandler(event: any)\r\n\t{\r\n\r\n\t}\r\n\t@HostListener('window:unload', ['$event']) \r\n\tunloadHandler(event: any) { \r\n\t} \r\n\r\n\t@HostListener('window:beforeunload', ['$event'])\r\n\tonBeforeUnload(event: any)\r\n\t{\r\n\t\t\r\n\t\tlet result = confirm('ok');\r\n\t\tif(result)\r\n\t\t{\r\n\t\t\tevent.preventDefault();\r\n\t\t}\r\n\t}\r\n*/\r\n\t \r\n\t/**\r\n\t *\r\n\t */\r\n public ngOnInit()\r\n\t{\r\n this.moAdminSubscription = this.adminData.adminEmitter.subscribe((value: any) =>\r\n\t\t{\r\n if (value === 'admin::parameters::read')\r\n\t\t\t{\r\n this._initParameters();\r\n }\r\n\r\n if (value === 'admin::parameters::update')\r\n\t\t\t{\r\n this._initParameters();\r\n\r\n //On a mis à jour des informations dans la fenètre générale\r\n if (this.mbShowItemGeneral === true)\r\n {\r\n this.mainParametersUpdated = true;\r\n }\r\n\t\t\t}\r\n\r\n\t\t\t\tif (typeof value === 'object' && value.length > 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (value[0] === 'admin::scenario::delete')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tconst result = value[1];\r\n\t\t\t\t\t\tconst scenarioToDelete = this.scenariosAvailable.find((scenario: any) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn scenario.id === result.idScenario;\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\tif (result.deleted === true)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.scenariosAvailable = _.filter(this.scenariosAvailable, (scenario: any) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn scenario.id !== result.idScenario;\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\tthis.scenarioSelected\t\t\t\t= this.scenariosAvailable[0];\r\n\t\t\t\t\t\t\tthis.titleScenarioSelected\t\t\t= this.scenarioSelected.title;\r\n\t\t\t\t\t\t\tthis.adminData.scenariosAvailable\t= this.scenariosAvailable;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tthis.dialog.open(InfosDeleteProcessusModalComponent,\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\theight:\t\t\t'30%',\r\n\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\twidth:\t\t\t'40%',\r\n\t\t\t\t\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tdeleted:\t\tresult.deleted,\r\n\t\t\t\t\t\t\t\t\tscenarioUsed:\tresult.scenarioUsed,\r\n\t\t\t\t\t\t\t\t\tscenario:\t\tscenarioToDelete\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t});\r\n\r\n\r\n this.moFormCtrlUrlMailServer\t\t= this.fb.control(this.urlMailServer);\r\n this.moFormCtrlMailContact\t\t\t= this.fb.control(this.mailContact);\r\n this.moFormCtrlMailNoReply\t\t\t= this.fb.control(this.mailNoReply);\r\n this.moFormCtrlTypeMailServer\t\t= this.fb.control(this.typeMailServer);\r\n this.moFormCtrlHostMailServer\t\t= this.fb.control(this.hostMailServer);\r\n this.moFormCtrlPortMailServer\t\t= this.fb.control(this.portMailServer);\r\n this.moFormCtrlSecureMailServer \t= this.fb.control(this.secureMailServer);\r\n this.moFormCtrlUseAccount\t\t\t= this.fb.control(this.useAccount);\r\n this.moFormCtrlLoginAccount\t\t\t= this.fb.control(this.loginAccount);\r\n\t\tthis.moFormCtrlPasswordAccount\t\t= this.fb.control(this.passwordAccount);\r\n\t\tthis.moFormCtrlNumericEnabled\t\t= this.fb.control(this.numericEnabled);\r\n\t\tthis.moFormCtrlSpecialTimeEnabled\t= this.fb.control(this.specialTimeEnabled);\r\n\t\t// this.moFormCtrlSpecialTimeArray\t\t= this.fb.control(this.specialTimeArray);\r\n\t\tthis.moFormCtrlSpecialTimeName\t\t= this.fb.control(this.specialTimeName);\r\n\t\tthis.moFormCtrlSpecialTimeType\t\t= this.fb.control(this.specialTimeType);\r\n\r\n\r\n this.moFromGroupMain = this.fb.group(\r\n\t\t{\r\n\t\t\turlMailServer:\t\t\tthis.moFormCtrlUrlMailServer,\r\n\t\t\tmailContact:\t\t\tthis.moFormCtrlMailContact,\r\n\t\t\tmailNoReply:\t\t\tthis.moFormCtrlMailNoReply,\r\n\t\t\ttypeMailServer:\t\t\tthis.moFormCtrlTypeMailServer,\r\n\t\t\thostMailServer:\t\t\tthis.moFormCtrlHostMailServer,\r\n\t\t\tportMailServer:\t\t\tthis.moFormCtrlPortMailServer,\r\n\t\t\tsecureMailServer:\t\tthis.moFormCtrlSecureMailServer,\r\n\t\t\tuseAccount:\t\t \tthis.moFormCtrlUseAccount,\r\n\t\t\tloginAccount:\t\t\tthis.moFormCtrlLoginAccount,\r\n\t\t\tpasswordAccount:\t\tthis.moFormCtrlPasswordAccount,\r\n\t\t\tnumericEnabled:\t\t\tthis.moFormCtrlNumericEnabled,\r\n\t\t\tspecialTimeEnabled:\t\tthis.moFormCtrlSpecialTimeEnabled,\r\n\t\t\tspecialTimeName:\t\tthis.moFormCtrlSpecialTimeName,\r\n\t\t\tspecialTimeType:\t\tthis.moFormCtrlSpecialTimeType\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public ngOnDestroy()\r\n\t{\r\n if (this.moAdminSubscription)\r\n\t\t{\r\n\t\t\tthis.moAdminSubscription.unsubscribe();\r\n\t\t\tthis.RouterSubscription.unsubscribe();\r\n\t\t}\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic addSpecialTime()\r\n\t{\r\n\r\n\t\tif ( this.specialTimeName !== '' && this.specialTimeType !== '')\r\n\t\t{\r\n\t\t\tlet nNewId = 0;\r\n\r\n\t\t\tfor (let specialTime of this.specialTimeArray)\r\n\t\t\t{\r\n\t\t\t\tif(nNewId <= specialTime.id)\r\n\t\t\t\t{\r\n\t\t\t\t\tnNewId = specialTime.id + 1; \r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlet bIsUnique = true;\r\n\t\t\t\r\n\t\t\tfor (let specialTime of this.specialTimeArray)\r\n\t\t\t{\r\n\t\t\t\tif(this.specialTimeType === specialTime.type)\r\n\t\t\t\t{\r\n\t\t\t\t\tbIsUnique = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (bIsUnique)\r\n\t\t\t{\r\n\t\t\t\tconst oSpecialTime: SpecialTime = new SpecialTime(nNewId, this.specialTimeName, this.specialTimeType);\r\n\r\n\t\t\t\tthis.specialTimeArray.push(oSpecialTime);\r\n\t\t\t\tthis.specialTimeName \t= '';\r\n\t\t\t\tthis.specialTimeType \t= ''; \r\n\t\t\t\tthis.canValidParams \t= true;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.specialTimeName \t= '';\r\n\t\t\t\tthis.specialTimeType \t= '';\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t}\r\n\t} \r\n\r\n\r\n\tshowSpecialTimeAlert()\r\n\t{\r\n\t\tlet bReturn = false;\r\n\r\n\t\tfor (let specialTime of this.specialTimeArray)\r\n\t\t{\r\n\t\t\tif(this.specialTimeType === specialTime.type)\r\n\t\t\t{\r\n\t\t\t\tbReturn = true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn bReturn;\r\n\r\n\t}\r\n\r\n\tpublic canAddSpecialTime()\r\n\t{\r\n\t\tlet bReturn = true;\r\n\r\n\t\tif(!this.specialTimeName || !this.specialTimeType)\r\n\t\t{\r\n\t\t\tbReturn = false;\r\n\t\t}\r\n\r\n\t\t\r\n\t\tfor (let specialTime of this.specialTimeArray)\r\n\t\t{\r\n\t\t\tif(this.specialTimeType === specialTime.type)\r\n\t\t\t{\r\n\t\t\t\tbReturn = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn bReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic delSpecialTime(psId: number)\r\n\t{\r\n\t\tlet newSpecialTimeArray: SpecialTime[] = [];\r\n\t\tfor (let specialTime of this.specialTimeArray)\r\n\t\t{\r\n\t\t\tif (specialTime.id !== psId)\r\n\t\t\t{\r\n\t\t\t\tnewSpecialTimeArray.push(specialTime);\r\n\t\t\t} \r\n\t\t}\r\n\t\tthis.specialTimeArray = newSpecialTimeArray;\r\n\t\tthis.canValidParams = true;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param tabName\r\n\t */\r\n public switch_tab(tabName: any)\r\n {\r\n this.mbShowItemGeneral\t\t= false;\r\n\t\tthis.mbShowItemProcessus\t= false;\r\n\t\tthis.mbShowItemMail\t\t\t= false;\r\n\t\tthis.mainParametersUpdated\t= false;\r\n\r\n switch (tabName)\r\n\t\t{\r\n\t\t\tcase 'general':\r\n\t\t\t\tthis.mbShowItemGeneral = true;\r\n\t\t\t\tbreak;\r\n case 'processus':\r\n\t\t\t\tthis.mbShowItemProcessus = true;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'mail':\r\n\t\t\t\tthis.mbShowItemMail = true;\r\n\t\t\t\t//Initialisation des templates de mail\r\n\t\t\t\tthis.initMailsTemplates();\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public updateMainParameters()\r\n {\r\n let datas: any = {};\r\n\r\n if (this.moFormCtrlUrlMailServer.dirty)\t\t\tdatas['domaine']\t\t\t= htmlEncode.htmlEncode(this.urlMailServer);\r\n if (this.moFormCtrlMailContact.dirty)\t\t\tdatas['@admin']\t\t\t\t= htmlEncode.htmlEncode(this.mailContact);\r\n if (this.moFormCtrlMailNoReply.dirty)\t\t\tdatas['@sys']\t\t\t\t= htmlEncode.htmlEncode(this.mailNoReply);\r\n if (this.moFormCtrlTypeMailServer.dirty)\t\tdatas['typemailserver']\t\t= htmlEncode.htmlEncode(this.typeMailServer);\r\n if (this.moFormCtrlHostMailServer.dirty)\t\tdatas['hostmailserver']\t\t= htmlEncode.htmlEncode(this.hostMailServer);\r\n if (this.moFormCtrlPortMailServer.dirty)\t\tdatas['portmailserver']\t\t= htmlEncode.htmlEncode(this.portMailServer);\r\n if (this.moFormCtrlSecureMailServer.dirty)\t\tdatas['secure']\t\t\t\t= this.secureMailServer ? 1 : 0;\r\n if (this.moFormCtrlUseAccount.dirty)\t\t\tdatas['useaccount']\t\t\t= this.useAccount\t\t? 1 : 0;\r\n if (this.moFormCtrlLoginAccount.dirty)\t\t\tdatas['loginaccount']\t\t= htmlEncode.htmlEncode(this.loginAccount);\r\n\t\tif (this.moFormCtrlPasswordAccount.dirty)\t\tdatas['passwdaccount']\t\t= htmlEncode.htmlEncode(this.passwordAccount);\r\n\t\tif (this.moFormCtrlNumericEnabled.dirty)\t\tdatas['numericEnabled']\t\t= this.numericEnabled ? 1 : 0;\r\n\t\tif (this.moFormCtrlSpecialTimeEnabled.dirty)\tdatas['specialTimeEnabled']\t= this.specialTimeEnabled ? 1 : 0;\r\n\r\n\t\tconst specialTimeArrayJson: any[] = [];\r\n\r\n\r\n\t\tfor (const specialTime of this.specialTimeArray)\r\n\t\t{\r\n\t\t\tspecialTimeArrayJson.push(specialTime.toJson());\r\n\t\t}\r\n\r\n\t\tif(specialTimeArrayJson.length > 0)\r\n\t\t{\r\n\t\t\tdatas['specialTimeArray']\t= JSON.stringify(specialTimeArrayJson);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tdatas['specialTimeArray'] = {};\r\n\t\t}\r\n\r\n\t\t// if (this.moFormCtrlSpecialtimeEnabled.dirty)\tdatas['specialtimeEnabled']\t= this.specialtimeEnabled ? 1 : 0;\r\n\r\n\t\tthis.adminService.updateAdminParameters(datas);\r\n\t\tthis.canValidParams = false;\r\n }\r\n\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public createNewProcess()\r\n\t{\r\n\t\tthis.dialog.open(EditionProcessusModalComponent,\r\n\t\t{\r\n\t\t\theight: \t\t'80%',\r\n\t\t\tpanelClass: \t'responsive_modal',\r\n\t\t\twidth: \t\t\t'75%',\r\n\t\t\tdisableClose: \ttrue,\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic canDeleteCurrentProcess()\r\n\t{\r\n\t\tlet result = true;\r\n\r\n\t\tif (!this.scenarioSelected || this.scenarioSelected.id === 0)\r\n\t\t{\r\n\t\t\tresult = false;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic deleteCurrentProcess()\r\n\t{\r\n\t\tconst dialogRef = this.dialog.open(ConfirmDeleteProcessusModalComponent,\r\n\t\t{\r\n\t\t\t\theight:\t\t\t'30%',\r\n\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\twidth:\t\t\t'40%',\r\n\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\tdata:\r\n\t\t\t\t{\r\n\t\t\t\t\tscenario: this.scenarioSelected\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\tdialogRef.afterClosed().subscribe((result: any) =>\r\n\t\t{\r\n\t\t\tif (result === true)\r\n\t\t\t{\r\n\t\t\t\tthis.adminService.deleteScenario(this.scenarioSelected.id);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public changeScenarioSelected()\r\n {\r\n this.scenarioSelected = _.find(this.scenariosAvailable, (scenario: any) => { return scenario.title === this.titleScenarioSelected; });\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param event\r\n\t */\r\n\tpublic changeTemplateMailSelected(event: any)\r\n {\r\n\t\tthis.titleMailTemplateSelected\t= event;\r\n this.mailTemplateSelected\t\t= _.find(this.mailsTemplatesAvailable, (template: any) => { return template.title === this.titleMailTemplateSelected; });\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param event\r\n\t */\r\n\tpublic onEditorCreated(event: any)\r\n\t{\r\n\t\tthis.quill = event;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param jeton\r\n\t */\r\n\tpublic onClickJeton(jeton: any)\r\n\t{\r\n\t\tconst range = this.quill.getSelection();\r\n\t\tif (range)\r\n\t\t{\r\n\t\t\tif (range.length === 0)\r\n\t\t\t{\r\n\t\t\t\tthis.quill.insertText(range.index, '{{' + jeton + '}}');\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.quill.deleteText(range.index, range.length);\r\n\t\t\t\tthis.quill.insertText(range.index, '{{' + jeton + '}}');\r\n\t\t\t}\r\n\r\n\t\t\tconst elementContentQuill = document.getElementsByClassName('ql-editor');\r\n\r\n\t\t\tif (elementContentQuill.length > 0)\r\n\t\t\t{\r\n\t\t\t\tconst element\t\t\t\t\t\t\t= elementContentQuill[0];\r\n\t\t\t\tthis.mailTemplateSelected.datas.content = element.innerHTML;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tconst elementTitleTemplate: any = document.getElementById('titleTemplate');\r\n\t\t\tconst startPosition:\t\tany = elementTitleTemplate['selectionStart'];\r\n\t\t\tconst endPosition:\t\t\tany = elementTitleTemplate['selectionEnd'];\r\n\r\n\t\t\tif (this.mailTemplateSelected.datas.title)\r\n\t\t\t{\r\n\t\t\t\tconst substr1 = this.mailTemplateSelected.datas.title.substring(0, startPosition);\r\n\t\t\t\tconst substr2 = this.mailTemplateSelected.datas.title.substring(endPosition);\r\n\r\n\t\t\t\tthis.mailTemplateSelected.datas.title = substr1 + '{{' + jeton + '}}' + substr2;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Initialisation des modèles de mail telles qu'ils sont en base de données\r\n\t */\r\n\tpublic initMailsTemplates()\r\n\t{\r\n\t\tif (this.adminData.mailsTemplates && this.adminData.mailsTemplates.length > 0)\r\n\t\t{\r\n\t\t\tthis.mailsTemplatesAvailable = [];\r\n\r\n\t\t\tfor (const template of this.adminData.mailsTemplates)\r\n\t\t\t{\r\n\t\t\t\tconst tempTemplate = Object.assign({}, template);\r\n\r\n\t\t\t\tif (template.datas)\r\n\t\t\t\t{\r\n\t\t\t\t\ttempTemplate.datas = Object.assign({}, template.datas);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.mailsTemplatesAvailable.push(tempTemplate);\r\n\t\t\t}\r\n\r\n\t\t\tthis.mailTemplateSelected\t\t= this.mailsTemplatesAvailable[0];\r\n\t\t\tthis.titleMailTemplateSelected\t= this.mailTemplateSelected.title;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Sauvegarde des modèles de mail\r\n\t */\r\n\tpublic saveMailsTemplates()\r\n\t{\r\n\t\tthis.adminData.mailsTemplates = [];\r\n\r\n\t\tfor (const template of this.mailsTemplatesAvailable)\r\n\t\t{\r\n\t\t\tthis.adminData.mailsTemplates.push(Object.assign({}, template));\r\n\t\t}\r\n\r\n\t\tthis.adminService.updateAdminMailsTemplates(this.adminData.mailsTemplates);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n private _initParameters()\r\n {\r\n //Initialisation des paramètres généraux\r\n if (this.adminData.generalParameters)\r\n {\r\n this.urlMailServer\t\t\t= this.adminData.generalParameters['domain'];\r\n this.mailContact\t\t\t= this.adminData.generalParameters['mailAdmin'];\r\n this.mailNoReply\t\t\t= this.adminData.generalParameters['mailSystem'];\r\n this.typeMailServer\t\t\t= this.adminData.generalParameters['typeMailServer'];\r\n this.hostMailServer\t\t\t= this.adminData.generalParameters['hostMailServer'];\r\n this.portMailServer\t\t\t= this.adminData.generalParameters['portMailServer'];\r\n this.secureMailServer\t\t= Number(this.adminData.generalParameters['secure'])\t\t\t\t=== 1;\r\n this.useAccount\t\t\t\t= Number(this.adminData.generalParameters['useAccount'])\t\t\t=== 1;\r\n this.loginAccount\t\t\t= this.adminData.generalParameters['loginAccount'];\r\n\t\t\tthis.passwordAccount\t\t= this.adminData.generalParameters['passwdAccount'];\r\n\t\t\tthis.numericEnabled\t\t\t= Number(this.adminData.generalParameters['numericEnabled']) \t\t=== 1;\r\n\t\t\tthis.specialTimeEnabled\t\t= Number(this.adminData.generalParameters['specialTimeEnabled']) \t=== 1;\r\n\t\t\tthis.specialTimeArray\t\t= this.adminData.generalParameters['specialTimeArray'];\r\n\r\n\t\t\t// todo\r\n\t\t\t//this.specialTimeEnabledArray\t\t= Number(this.adminData.generalParameters['specialTimeEnabled']) \t=== 1;\r\n }\r\n\r\n //Initialisation des scénarios\r\n if (this.adminData.scenariosAvailable && this.adminData.scenariosAvailable.length > 0)\r\n {\r\n this.scenarioSelected\t\t= this.adminData.scenariosAvailable[0];\r\n this.titleScenarioSelected\t= this.scenarioSelected.title;\r\n this.scenariosAvailable\t\t= this.adminData.scenariosAvailable;\r\n\t\t}\r\n\t}\r\n}\r\n","
\r\n","import { Component, Inject } from '@angular/core';\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';\r\n\r\n\r\n@Component({\r\n selector:\t\t'confirm-delete-processus-modal',\r\n templateUrl:\t'confirmDeleteProcessusModal.component.html',\r\n styleUrls:\t\t['./confirmDeleteProcessusModal.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class ConfirmDeleteProcessusModalComponent\r\n{\r\n\tpublic scenario: any;\r\n\r\n\r\n\tconstructor(public dialogRef: MatDialogRef
, @Inject(MAT_DIALOG_DATA) public data: any)\r\n\t{\r\n\t\tif (data && data.scenario)\r\n\t\t{\r\n\t\t\tthis.scenario = data.scenario;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic validate()\r\n\t{\r\n\t\tthis.dialogRef.close(true);\r\n\t}\r\n\r\n\r\n\tpublic close()\r\n\t{\r\n\t\tthis.dialogRef.close(false);\r\n\t}\r\n}\r\n","\r\n","import { Component, Inject, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';\r\n\r\nimport { AdminData }\t\t\t from '../../../../providers/admin-data';\r\nimport { AdminService } from '../../../../services/admin.service';\r\n\r\n\r\nimport * as _ from 'underscore';\r\n\r\n\r\n@Component({\r\n selector:\t\t'edition-processus-modal',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n templateUrl:\t'editionProcessusModal.component.html',\r\n styleUrls:\t\t['./editionProcessusModal.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class EditionProcessusModalComponent implements OnInit, OnDestroy\r\n{\r\n\r\n public itemSelected:\t\tstring\t= 'infos';\r\n public titleModal:\t\t\tstring\t= 'Edition scénario';\r\n public titleValidateButton: string\t= 'Ajouter un scénario';\r\n public objProcess:\t\t\tany\t\t= {};\r\n\r\n\r\n /**\r\n * \r\n * @param dialogRef \r\n * @param adminService \r\n * @param adminData \r\n * @param data \r\n */\r\n constructor(public dialogRef:\t\tMatDialogRef,\r\n public adminService:\tAdminService,\r\n public adminData:\t\tAdminData,\r\n @Inject(MAT_DIALOG_DATA) public data: any)\r\n {\r\n\t\tthis.objProcess =\r\n\t\t{\r\n\t\t\tid:\t\t\t\tthis.adminData.scenariosAvailable.length,\r\n\t\t\ttitle:\t\t\t'',\r\n\t\t\tdescription:\t'',\r\n\t\t\tsteps:\t\t\t[]\r\n\t\t};\r\n\t}\r\n\t\r\n\r\n /**\r\n * \r\n */\r\n public ngOnInit()\r\n\t{\r\n }\r\n\r\n\r\n /**\r\n * \r\n */\r\n\tpublic ngOnDestroy()\r\n\t{\r\n\r\n }\r\n\r\n\r\n /**\r\n * \r\n * @param rubrique \r\n */\r\n public switch_tab(rubrique: string)\r\n {\r\n this.itemSelected = rubrique;\r\n }\r\n\r\n\r\n /**\r\n * \r\n */\r\n public canValidateNewProcess()\r\n {\r\n let result = true;\r\n\r\n if (this.objProcess.title === undefined || this.objProcess.title === '' || this.objProcess.steps.length === 0) \r\n\t\t{\r\n result = false;\r\n }\r\n\r\n return result;\r\n }\r\n\t\r\n\r\n /**\r\n * \r\n */\r\n public validate()\r\n {\r\n let scenariosToSend = this.adminData.scenariosAvailable.concat(this.objProcess);\r\n\r\n\t\tlet datas: any =\r\n\t\t\t{\r\n\t\t\t\tscenarios: JSON.stringify(scenariosToSend)\r\n\t\t\t};\r\n\t\tthis.adminService.updateAdminParameters(datas);\r\n this.dialogRef.close();\r\n }\r\n\r\n\r\n /**\r\n * \r\n */\r\n public close()\r\n {\r\n this.dialogRef.close();\r\n }\r\n}\r\n","\r\n","import { Component, Inject } from '@angular/core';\r\nimport { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';\r\n\r\n\r\n@Component({\r\n selector:\t\t'infos-delete-processus-modal',\r\n templateUrl:\t'infosDeleteProcessusModal.component.html',\r\n styleUrls:\t\t['./infosDeleteProcessusModal.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class InfosDeleteProcessusModalComponent\r\n{\r\n\tpublic deleted:\t\t\tany;\r\n\tpublic scenarioUsed:\tany;\r\n\tpublic scenario:\t\tany;\r\n\tpublic titleModal:\t\tany;\r\n\tpublic messageModal:\tany;\r\n\t\r\n\r\n constructor(public dialogRef:\t\tMatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any)\r\n {\r\n\t\tif (data && data.deleted !== undefined && data.scenarioUsed !== undefined && data.scenario !== undefined)\r\n\t\t{\r\n\t\t\tthis.deleted\t\t= data.deleted;\r\n\t\t\tthis.scenarioUsed\t= data.scenarioUsed;\r\n\t\t\tthis.scenario\t\t= data.scenario;\r\n\r\n\t\t\tif (this.deleted === true)\r\n\t\t\t{\r\n\t\t\t\tthis.titleModal\t\t= 'Confirmation suppression de scénario';\r\n\t\t\t\tthis.messageModal\t= 'Le scénario suivant a bien été supprimé :';\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.titleModal = 'Erreur suppression de scénario';\r\n\r\n\t\t\t\tif (this.scenarioUsed === true)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.messageModal = 'Le scénario suivant n\\'as pas pu être supprimé car il est utilisé par une épreuve existante :';\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.messageModal = 'Le scénario suivant n\\'as pas pu être supprimé, veuillez rééssayer ultérieurement :';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n public validate()\r\n {\r\n this.dialogRef.close();\r\n }\r\n}\r\n","\r\n\t
\r\n\t\t\r\n\t\t\t \r\n\t\t \r\n\t \r\n
\r\n\r\n\r\n\t
\r\n\t\t
\r\n\t\t
Merci d'ajouter ou de sélectionner un utilisateur \r\n\t\t
Ajouter un utilisateur \r\n\t
\r\n
\r\n\r\n\r\n\t
\r\n\t\t
\r\n\r\n\t\t
\r\n\r\n\t\t
\r\n\r\n\t\t
\r\n\t\t
\r\n\t\t\t{{ 'adminUsers.edit' | translate }} \r\n\t\t\t{{ 'adminUsers.resetRsa' | translate }} \r\n\t\t\t{{ 'adminUsers.giveFilesKeys' | translate }} \r\n\t\t\t\r\n\t\t\t\t{{ 'adminUsers.disable' | translate }} \r\n\t\t\t\t{{ 'adminUsers.enable' | translate }} \r\n\t\t\t \r\n\t\t\t{{ 'adminUsers.delete' | translate }} \r\n\t\t
\r\n\t
\r\n
\r\n\r\n\r\n\t add \r\n
\r\n","import { Component, ViewEncapsulation, OnInit, OnDestroy }\tfrom '@angular/core';\r\nimport { MatDialog }\t\t\t\t\t\t\t\t\t\tfrom '@angular/material';\r\n\r\nimport { UserData }\t\t\t\t\t\t\t\tfrom '../../../providers/user-data';\r\nimport { UserModalComponent }\t\t\t\t\tfrom '../../../modal/user/userModal.component';\r\nimport { ConfirmResetRsaModalComponent }\t\tfrom '../../../modal/confirmResetRsa/confirmResetRsaModal.component';\r\nimport { ConfirmDeleteUserModalComponent }\t\tfrom '../../../modal/confirmDeleteUser/confirmDeleteUserModal.component';\r\nimport { ConfirmGiveFilesKeysModalComponent }\tfrom '../../../modal/confirmGiveFilesKeys/confirmGiveFilesKeysModal.component';\r\n\r\nimport { UserService } from '../../../services/user.service';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n\r\n@Component({\r\n selector:\t\t'app-admin-users',\r\n encapsulation:\tViewEncapsulation.None,\r\n templateUrl:\t'./admin-users.component.html',\r\n styleUrls:\t\t['./admin-users.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class AdminUsersComponent implements OnInit, OnDestroy\r\n{\r\n public users:\t\t\t\tany[] = [];\r\n public selectedUser:\t\tany;\r\n public moUserSubscription:\tany;\r\n\r\n public userDataChanged:\t\tany\t\t= {};\r\n public hasUserDataChanger:\tboolean = false;\r\n\r\n public arrayProfessions:\tstring[] = [];\r\n public arrayMatieres:\t\tstring[] = [];\r\n\r\n constructor(public userData:\tUserData,\r\n public userService: UserService,\r\n public dialog:\t\tMatDialog)\r\n {\r\n this._initUsers();\r\n }\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n public ngOnInit()\r\n\t{\r\n\r\n this.moUserSubscription = this.userData.globalEmitter.subscribe((value: string) =>\r\n\t\t{\r\n\t\t\t//Evènement récupéré lorsqu'un nouvel utilisateur à été ajouté\r\n\t\t\t//On ajoute donc le nouvel utilisateur dans la liste\r\n\t\t\tif (value[0] === 'user::add')\r\n\t\t\t{\r\n\t\t\t\tif (value[1])\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.displayDetailUser(value[1]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (value[0] === 'user::update')\r\n\t\t\t{\r\n\t\t\t\tthis._initUsers();\r\n\t\t\t}\r\n\t\t});\r\n }\r\n\t\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n public ngOnDestroy()\r\n\t{\r\n\t\tif (this.moUserSubscription)\r\n\t\t{\r\n\t\t\tthis.moUserSubscription.unsubscribe();\r\n\t\t}\r\n }\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param user \r\n\t */\r\n public displayDetailUser(user: any)\r\n {\r\n if (user)\r\n {\r\n this.userDataChanged\t= {};\r\n this.hasUserDataChanger = false;\r\n\t\t\tthis.selectedUser\t\t= user;\r\n\t\t\tthis.arrayProfessions = this.selectedUser.publics.professions;\r\n\t\t\t\r\n\t\t\tif (typeof this.arrayProfessions === 'string')\r\n\t\t\t{\r\n\t\t\t\tthis.arrayProfessions = JSON.parse(this.arrayProfessions);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.arrayProfessions = this.arrayProfessions;\r\n\t\t\t}\r\n\r\n\t\t\tthis.arrayMatieres = this.selectedUser.publics.matieres;\r\n\r\n\t\t\tif (typeof this.arrayMatieres === 'string')\r\n\t\t\t{\r\n\t\t\t\tthis.arrayMatieres = JSON.parse(this.arrayMatieres);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.arrayMatieres = this.arrayMatieres;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic addNewUser()\r\n\t{\r\n\t\tlet dialogRef = this.dialog.open(UserModalComponent,\r\n\t\t{\r\n\t\t\theight:\t\t\t'80%',\r\n\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\twidth:\t\t\t'75%',\r\n\t\t\tdisableClose:\ttrue,\r\n\t\t});\r\n\r\n\r\n\t\tdialogRef.afterClosed().subscribe((result: any) =>\r\n\t\t{\r\n\t\t});\r\n\t}\r\n\t\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic displayModalAccount()\r\n\t{\r\n\t\tlet dialogRef = this.dialog.open(UserModalComponent,\r\n\t\t{\r\n\t\t\theight:\t\t\t'80%',\r\n\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\twidth:\t\t\t'75%',\r\n\t\t\tdisableClose:\ttrue,\r\n\t\t\tdata:\r\n\t\t\t{\r\n\t\t\t\t'edition':\t\ttrue,\r\n\t\t\t\tuserSelected:\tthis.selectedUser\r\n\t\t\t}\r\n\t\t});\r\n\r\n\r\n\t\tdialogRef.afterClosed().subscribe((result: any) =>\r\n\t\t{\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic toggleEnableAccount()\r\n\t{\r\n\t\tif (this.selectedUser.enabled === true)\r\n\t\t{\r\n\t\t\t//On désactive le compte\r\n\t\t\tthis.userService.toggleEnabledUser(this.selectedUser.mail, false);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t//On le réactive\r\n\t\t\tthis.userService.toggleEnabledUser(this.selectedUser.mail, true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Réinitialisation de la clé RSA de l'utilisateur selectionné\r\n\t */\r\n\tpublic resetRsaKey(user: any)\r\n\t{\r\n\t\tconst dialogRef = this.dialog.open(ConfirmResetRsaModalComponent,\r\n\t\t{\r\n\t\t\theight:\t\t\t'200px',\r\n\t\t\tpanelClass:\t\t'responsive_mini_modal',\r\n\t\t\twidth:\t\t\t'50%',\r\n\t\t\tdisableClose:\ttrue,\r\n\t\t\tdata:\r\n\t\t\t{\r\n\t\t\t\tuser: user\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tdialogRef.afterClosed().subscribe((result: any) =>\r\n\t\t{\r\n\t\t\tif (result === true && user.mail)\r\n\t\t\t{\r\n\t\t\t\tthis.userService.resetRsaKeyUSer(user.mail);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic giveFilesKeys(user: any)\r\n\t{\r\n\t\tconst dialogRef = this.dialog.open(ConfirmGiveFilesKeysModalComponent,\r\n\t\t{\r\n\t\t\theight:\t\t\t'250px',\r\n\t\t\tpanelClass:\t\t'responsive_mini_modal',\r\n\t\t\twidth:\t\t\t'50%',\r\n\t\t\tdisableClose:\ttrue,\r\n\t\t\tdata:\r\n\t\t\t{\r\n\t\t\t\tuser: user\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tdialogRef.afterClosed().subscribe((result: any) =>\r\n\t\t{\r\n\t\t\tif (result === true)\r\n\t\t\t{\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic deleteAccount()\r\n\t{\r\n\t\tconst dialogRef = this.dialog.open(ConfirmDeleteUserModalComponent,\r\n\t\t{\r\n\t\t\theight:\t\t\t'200px',\r\n\t\t\twidth:\t\t\t'50%',\r\n\t\t\tpanelClass:\t\t'responsive_mini_modal',\r\n\t\t\tdisableClose:\ttrue,\r\n\t\t\tdata:\r\n\t\t\t{\r\n\t\t\t\t'user': this.selectedUser,\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tdialogRef.afterClosed().subscribe((result: any) => \r\n\t\t{\r\n\t\t\tif (result === true)\r\n\t\t\t{\r\n\t\t\t\tthis.userService.deleteUser(this.selectedUser.mail);\r\n\t\t\t\tthis.selectedUser = null;\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tprivate _initUsers()\r\n\t{\r\n\t\tthis.users\t\t\t= [];\r\n\t\tconst objUsers\t\t= this.userData.getUsers();\r\n\t\tconst currentUserId\t= this.userData.getUserId();\r\n\r\n\t\tlet newUser: any;\r\n\t\tfor (const key in objUsers)\r\n\t\t{\r\n\t\t\tif (currentUserId !== key)\r\n\t\t\t{\r\n\t\t\t\tnewUser\t\t\t\t\t= objUsers[key];\r\n\t\t\t\tnewUser.completeName\t= newUser.infos.nom + ' ' + newUser.infos.prenom;\r\n\t\t\t\tthis.users.push(newUser);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param pjUser \r\n\t */\r\n\tpublic isSelected(pjUser: any)\r\n\t{\r\n\t\tlet bReturn = false;\r\n\t\tif (this.selectedUser)\r\n\t\t{\r\n\t\t\tif (pjUser.mail === this.selectedUser.mail)\r\n\t\t\t{\r\n\t\t\t\tbReturn = true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn bReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * A revoir car un super admin doit pouvoir delete un admins\r\n\t */\r\n\tpublic isCurrentUserAdminOrSuperUser()\r\n\t{\r\n\t\tlet bReturn = false;\r\n\r\n\t\tif (this.selectedUser)\r\n\t\t{\r\n\t\t\tif (this.selectedUser.publics && (this.selectedUser.publics.isAdmin === 'true' || this.selectedUser.publics.isSuperUser === 'true'))\r\n\t\t\t{\r\n\t\t\t\tbReturn = true;\r\n\t\t\t} \r\n\r\n\t\t\t// Si l'user courant est super, il doit pouvoir delete un admin\r\n\t\t\tif (this.selectedUser.publics && (this.selectedUser.publics.isAdmin === 'true' && this.userData.status === 'superviseur'))\r\n\t\t\t{\r\n\t\t\t\tbReturn = false;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\treturn bReturn;\r\n\t}\r\n\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic hasCurrentUserRsaKey()\r\n\t{\r\n\t\tlet bReturn = false;\r\n\r\n\t\tif (this.selectedUser)\r\n\t\t{\r\n\t\t\tif (this.selectedUser.publics && this.selectedUser.publics.rsaPublicKey !== undefined && this.selectedUser.publics.rsaPublicKey !== '')\r\n\t\t\t{\r\n\t\t\t\tbReturn = true;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn bReturn;\r\n\t}\r\n\t\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic canMakeActionOnCurrentUser()\r\n\t{\r\n\t\tlet bReturn = true;\r\n\t\t// Si l'utlisateur courant est un super user, il ne peut pas faire d'action sur les autres super user\r\n\t\tif (this.userData.isSuperviseur() === true)\r\n\t\t{\r\n\t\t\tif (this.selectedUser.publics && this.selectedUser.publics.isSuperUser === 'true')\r\n\t\t\t{\r\n\t\t\t\tbReturn = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Si l'utlisateur courant est admin, il ne peut pas faire d'action sur les autres super user et admin\r\n\t\tif (this.userData.isAdmin() === true)\r\n\t\t{\r\n\t\t\tif (this.selectedUser.publics && (this.selectedUser.publics.isSuperUser === 'true' || this.selectedUser.publics.isAdmin === 'true'))\r\n\t\t\t{\r\n\t\t\t\tbReturn = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Si l'utlisateur courant est un user simple, il ne peut rien faire (de toute facon il ne devrait même pas être la)\r\n\t\tif (this.userData.isSimpleUser() === true)\r\n\t\t{\r\n\t\t\tbReturn = false;\r\n\t\t}\r\n\r\n\t\treturn bReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param user \r\n\t */\r\n\tpublic getCodeMachine(user: any)\r\n\t{\r\n\t\tlet result = '';\r\n\r\n\t\tif (user && user.privates && user.privates.fp)\r\n\t\t{\r\n\t\t\tlet fp = user.privates.fp;\r\n\t\t\tif (typeof fp === 'string')\r\n\t\t\t{\r\n\t\t\t\tfp = JSON.parse(fp);\r\n\t\t\t}\r\n\r\n\t\t\tif (fp.code)\r\n\t\t\t{\r\n\t\t\t\tresult = fp.code;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n}\r\n","\r\n\t\r\n\t
\r\n\t\t
\r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t \r\n\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t \r\n\t\t \r\n\t
\r\n
\r\n","import { Component, ViewEncapsulation, ViewChild, OnInit }\t\tfrom '@angular/core';\r\n\r\nimport { AppComponent }\tfrom '../../app.component';\r\nimport { Router, ActivatedRoute, NavigationEnd }\t\tfrom '@angular/router';\r\n\r\nimport { UserData }\t\t\tfrom '../../providers/user-data';\r\n\r\n\r\n@Component({\r\n selector:\t\t'admin',\r\n templateUrl:\t'./admin.component.html',\r\n encapsulation:\tViewEncapsulation.None,\r\n styleUrls:\t\t['./admin.component.scss']\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class AdminComponent implements OnInit\r\n{\r\n\tpublic panelSelected:\t\t\t\t\tnumber\t= 0;\r\n public isChatPanelSelected:\t\t\t\tboolean\t= true;\r\n public isForumtPanelSelected:\t\t\tboolean\t= false;\r\n public isNotificationstPanelSelected:\tboolean\t= false;\r\n public mbLoadState:\t\t\t\t\t\tboolean\t= false;\r\n\tpublic matTabs:\t\t\t\t\t\t\tany;\r\n\r\n /**\r\n * Creates an instance of CommunityPage.\r\n *\r\n * @param {PopoverController} popoverCtrl\r\n * @param {NavController} nav\r\n *\r\n * @memberOf CommunityPage\r\n */\r\n\tconstructor( public userData:\tUserData,\r\n\t\t\t\t public router:\t\tRouter)\r\n\t{\r\n\t\tthis.panelSelected = 0;\r\n\r\n\t\t//\tToodo => récup l'index en cours, et en fonction on affiche\r\n\t\t//\tappComponent.setPageTitle('Communauté - Messagerie');\r\n\t\t//this.matTabs.position = 1;\r\n\r\n\t\tif (!this.userData.isAdmin() && !this.userData.isSuperviseur())\r\n\t\t{\r\n\t\t\tthis.router.navigate(['/home']);\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis.panelSelected = 0;\r\n\t\tthis.refreshTab(0);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnChange()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t *\r\n\t * @memberOf CommunityPage\r\n\t */\r\n\tpublic updateSegment(): void\r\n\t{\r\n\t\t// this.isChatPanelSelected \t\t\t= this.panelSelected === 0 ? true : false\t\t;\r\n\t\t// this.isForumtPanelSelected \t\t\t= this.panelSelected === 1 ? true : false\t\t;\r\n\t\t// this.isNotificationstPanelSelected \t= this.panelSelected === 2 ? true : false;\r\n\t}\r\n\r\n\r\n /**\r\n *\r\n */\r\n\tpublic addCommunityItem(nameButton: any)\r\n\t{\r\n\t\tswitch (nameButton)\r\n\t\t{\r\n\t\t\tcase 'newTopic':\r\n\t\t\tbreak;\r\n\t\t\tcase 'publicConversation':\r\n\t\t\tcase 'privateGroup':\r\n\t\t\t//\t\t\tcase 'privateConversation':\r\n\t\t\t//\t\t\t\tlet popover = this.popoverCtrl.create(PopoverCreateChat, {type: nameButton}, {cssClass: 'popover-create-chat'});\r\n\t\t\t//\t\t\t\tpopover.present();\r\n\t\t\t//\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Retourne true une fois la page chargée\r\n\t *\r\n\t * @returns\r\n\t *\r\n\t * @memberOf WorkspacePage\r\n\t */\r\n\tpublic isLoaded(): boolean\r\n\t{\r\n\t\treturn this.mbLoadState;\r\n\t}\r\n\r\n\r\n /**\r\n * Display message for chat, topic and notifications creation. Display equally error messages\r\n *\r\n * @returns\r\n *\r\n * @memberOf WorkspacePage\r\n */\r\n\tpublic presentToast(message: any)\r\n\t{\r\n\t\t//\t\tlet toast = this.toastCtrl.create({\r\n\t\t//\t\t\tmessage: message,\r\n\t\t//\t\t\tduration: 3000\r\n\t\t//\t\t});\r\n\t\t//\t\ttoast.present();\r\n \t}\r\n\r\n\r\n\t/**\r\n\t * Call on every modification of the tab\r\n\t */\r\n\tpublic refreshTab(e: any)\r\n\t{\r\n\r\n\t\t// En fonction de l'index on va choisir quelle section est à afficher\r\n\t}\r\n}\r\n","\r\n\r\n\t
\r\n\t\t keyboard_arrow_left \r\n\r\n\t
\r\n\t
\r\n\t\t{{ viewDate | calendarDate:(view + 'ViewTitle'):'fr' }}\r\n\t
\r\n\t
\r\n\t\tkeyboard_arrow_right \r\n\t
\r\n\t
\r\n
\r\n\r\n\r\n\t\r\n\t \r\n\t\r\n\t \r\n\t\r\n\t \r\n
\r\n\r\n","import { Component, ChangeDetectionStrategy, EventEmitter, ViewChild, Output, TemplateRef, ViewEncapsulation, OnInit, OnDestroy }\tfrom '@angular/core';\r\n\r\nimport { startOfMonth, endOfMonth, isSameDay, isSameMonth }\tfrom 'date-fns';\r\nimport { CalendarEventTimesChangedEvent }\t\t\t\t\tfrom 'angular-calendar';\r\n\r\nimport { Subject }\t\t\t\t\tfrom 'rxjs';\r\nimport { UserData }\t\t\t\t\tfrom '../../providers/user-data';\r\nimport { WorkspaceData }\t\t\tfrom '../../providers/workspace-data';\r\nimport { TaskData }\t\t\t\t\tfrom '../../providers/task-data';\r\nimport { SocketService }\t\t\tfrom '../../services/socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../../models/message.model';\r\n\r\n\r\nconst colors: any =\r\n\t{\r\n\t\tred:\r\n\t\t{\r\n\t\t\tprimary:\t'#ad2121',\r\n\t\t\tsecondary:\t'#FAE3E3'\r\n\t\t},\r\n\t\tblue:\r\n\t\t{\r\n\t\t\tprimary:\t'#1e90ff',\r\n\t\t\tsecondary:\t'#D1E8FF'\r\n\t\t},\r\n\t\tyellow:\r\n\t\t{\r\n\t\t\tprimary:\t'#e3bc08',\r\n\t\t\tsecondary:\t'#FDF1BA'\r\n\t\t}\r\n\t};\r\n\r\n\r\n@Component({\r\n\tchangeDetection:\tChangeDetectionStrategy.OnPush,\r\n\tselector:\t\t\t'app-calendar',\r\n\tencapsulation:\t\tViewEncapsulation.None,\r\n\ttemplateUrl:\t\t'./calendar.component.html',\r\n\tstyleUrls:\t\t\t['./calendar.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class CalendarComponent implements OnInit, OnDestroy\r\n{\r\n\r\n\t@ViewChild('modalContent') modalContent: TemplateRef;\r\n\t@Output() viewDateChange: EventEmitter\t= new EventEmitter();\r\n\t@Output() clickDateEvent: EventEmitter\t\t= new EventEmitter();\r\n\r\n\r\n\tpublic refresh: Subject = new Subject();\r\n\r\n\tpublic view:\t\t\t\tstring\t= 'month';\r\n\tpublic viewDate:\t\t\tDate\t= new Date();\r\n\tpublic events:\t\t\t\tany[]\t= [];\r\n\tpublic socket:\t\t\t\tany\t\t= undefined;\r\n\tpublic activeDayIsOpen:\t\tboolean = true;\r\n\tpublic moDateSubscription:\tany;\r\n\r\n\tpublic modalData:\r\n\t{\r\n\t\taction: string;\r\n\t\tevent:\tany;\r\n\t};\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param userData \r\n\t * @param socketService \r\n\t * @param workspaceData \r\n\t * @param taskData \r\n\t */\r\n\tconstructor(public userData:\t\tUserData,\r\n\t\t\t\tpublic socketService:\tSocketService,\r\n\t\t\t\tpublic workspaceData:\tWorkspaceData,\r\n\t\t\t\tpublic taskData:\t\tTaskData)\r\n\t{\r\n\t}\r\n\t\r\n\t\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis.moDateSubscription = this.userData.globalEmitter.subscribe((value: string) =>\r\n\t\t{\r\n\t\t\t//Evènement récupéré lorsqu'un nouveau classeur à été ajouté\r\n\t\t\t//On ajoute donc le dernier elément de la structure dans user data\r\n\t\t\t//dans les classeurs du composant\r\n\t\t\tif (value === 'calendar:newDate')\r\n\t\t\t{\r\n\t\t\t\tthis._initCalendarFromUserDatas();\r\n\t\t\t}\r\n\r\n\t\t});\r\n\r\n\t\tthis.viewDateChange.subscribe((viewDate: any) =>\r\n\t\t{\r\n\r\n\t\t\tlet month = (viewDate.getFullYear() * 100 + (viewDate.getMonth() + 1));\r\n\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.socket = socket;\r\n\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t'what': SocketWhat.request,\r\n\t\t\t\t\t\t\t'cmd':\t'calendar',\r\n\t\t\t\t\t\t\t'args': { month: month }\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\t//On apelle une fois l'initialisation pour traiter les éventuelles\r\n\t\t//dates existantes dans le localstorage\r\n\t\tthis._initCalendarFromUserDatas();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnDestroy()\r\n\t{\r\n\t\tif (this.moDateSubscription)\r\n\t\t{\r\n\t\t\tthis.moDateSubscription.unsubscribe();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Ouvre un évent à partir d'un clic sur un jour\r\n\t */\r\n\tpublic dayClicked({ date, events }: { date: Date; events: any[] }): void\r\n\t{\r\n\t\tif (isSameMonth(date, this.viewDate))\r\n\t\t{\r\n\t\t\tif ((isSameDay(this.viewDate, date) && this.activeDayIsOpen === true) || events.length === 0 )\r\n\t\t\t{\r\n\t\t\t\tthis.activeDayIsOpen = false;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.activeDayIsOpen\t= true;\r\n\t\t\t\tthis.viewDate\t\t\t= date;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param param0 \r\n\t */\r\n\tpublic eventTimesChanged({event, newStart, newEnd }: CalendarEventTimesChangedEvent): void\r\n\t{\r\n\t\tevent.start = newStart;\r\n\t\tevent.end\t= newEnd;\r\n\r\n\t\tthis.handleEvent('Dropped or resized', event);\r\n\t\tthis.refresh.next();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param action \r\n\t * @param event \r\n\t */\r\n\tpublic handleEvent(action: string, event: any): void\r\n\t{\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tlet idSplitted = event.id.split('::');\r\n\t\t\tif (idSplitted.length > 1 && idSplitted[0] === '*task')\r\n\t\t\t{\r\n\t\t\t\tlet task = this.taskData.getTaskById(idSplitted[1]);\r\n\t\t\t\tthis.clickDateEvent.emit(task);\r\n\t\t\t}\r\n\t\t}\r\n\t\t// this.modalData = { event, action };\r\n\t\t// this.modal.open(this.modalContent, { size: 'lg' });\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tprivate _initCalendarFromUserDatas()\r\n\t{\r\n\t\tlet calendarDatas\t= this.userData.getCalendarDatas();\r\n\t\tthis.events\t\t\t= [];\r\n\r\n\t\tfor (let dateKey of Object.keys(calendarDatas))\r\n\t\t{\r\n\t\t\tif (calendarDatas[dateKey])\r\n\t\t\t{\r\n\t\t\t\tlet date = calendarDatas[dateKey];\r\n\r\n\t\t\t\tif (date.unique)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet objDate = new Date(date.unique.date);\r\n\t\t\t\t\tthis.events.push(\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstart: objDate,\r\n\t\t\t\t\t\t\ttitle: date.unique.libelle,\r\n\t\t\t\t\t\t\tcolor: colors.blue,\r\n\t\t\t\t\t\t\tid: date.unique.id\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (date.inter)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet objDate = new Date(date.inter.date);\r\n\t\t\t\t\tthis.events.push(\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstart:\tstartOfMonth(objDate),\r\n\t\t\t\t\t\t\tend:\tendOfMonth(objDate),\r\n\t\t\t\t\t\t\ttitle:\tdate.inter.libelle,\r\n\t\t\t\t\t\t\tcolor:\tcolors.yellow,\r\n\t\t\t\t\t\t\tid: \tdate.inter.id\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (date.debut)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet objDate = new Date(date.debut.date);\r\n\r\n\t\t\t\t\tlet newEvent: any =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstart:\tobjDate,\r\n\t\t\t\t\t\t\tend:\tendOfMonth(objDate),\r\n\t\t\t\t\t\t\ttitle:\tdate.debut.libelle,\r\n\t\t\t\t\t\t\tcolor:\tcolors.yellow,\r\n\t\t\t\t\t\t\tid: \tdate.debut.id\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (date.fin)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnewEvent.end = new Date(date.fin.date);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.events.push(newEvent);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.refresh.next();\r\n\t}\r\n}"," \r\n\r\n\t \r\n
","import { Component, Input, ViewChild, ElementRef, HostListener, AfterViewInit, AfterViewChecked, ViewEncapsulation } from '@angular/core';\r\n\r\ndeclare var Caman: any;\r\n\r\n@Component({\r\n\tselector:\t\t'app-canvas',\r\n\ttemplateUrl:\t'./canvas.component.html',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\tstyleUrls:\t\t['./canvas.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class CanvasComponent implements AfterViewInit, AfterViewChecked\r\n{\r\n\r\n\t@ViewChild('img') img:\t\tElementRef;\r\n\t@Input() src:\t\t\t\tstring;\r\n\t@Input() containerWidth:\tnumber;\r\n\t@Input() containerHeight:\tnumber;\r\n\r\n\t@Input()\r\n set canvasId(canvasId: any)\r\n {\r\n this.idCanvas = canvasId;\r\n }\r\n\r\n\tpublic ctx:\t\t\t\t\tCanvasRenderingContext2D;\r\n\tpublic element:\t\t\t\tHTMLImageElement;\r\n\tpublic elementOriginal:\t\tHTMLImageElement;\r\n\r\n\tpublic canvas:\t\tany;\r\n\tpublic idCanvas:\tstring;\r\n\tpublic width:\t\tnumber;\r\n\tpublic height:\t\tnumber;\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param canvas \r\n\t * @param img \r\n\t */\r\n\tconstructor(canvas: ElementRef, img: ElementRef)\r\n\t{\r\n\t\tthis.width\t\t= window.innerWidth;\r\n\t\tthis.height\t\t= window.innerHeight;\r\n\t\tthis.idCanvas\t= 'target5';\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngAfterViewInit()\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Récupération des éléments de la page pour transformation\r\n\t\t// ---------------------------------------\r\n\t\tthis.canvas\t= document.getElementById(this.idCanvas);\r\n\t\tif (this.canvas)\r\n\t\t{\r\n\t\t\tthis.ctx\t\t\t\t= this.canvas.getContext('2d');\r\n\t\t\tthis.element\t\t\t= this.img.nativeElement;\r\n\t\t\tthis.elementOriginal\t= this.img.nativeElement;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Sale => julien's tips\r\n\t */\r\n\tpublic getSrc()\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Récupération de la source de l'image\r\n\t\t// ---------------------------------------\r\n\t\tthis.width\t= this.img.nativeElement.clientWidth;\r\n\t\tthis.height = this.img.nativeElement.clientHeight;\r\n\t\tthis.canvas = document.getElementById(this.idCanvas);\r\n\r\n\t\treturn this.src;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic getWidth()\r\n\t{\r\n\t\treturn this.width;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic getHeight()\r\n\t{\r\n\t\treturn this.height;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngAfterViewChecked()\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Trigger au changement de l'url de l'image (modif par l'user)\r\n\t\t// ---------------------------------------\r\n\t\tthis.img.nativeElement.onload = () =>\r\n\t\t{\r\n\t\t\tthis.canvas\t\t= document.getElementById(this.idCanvas);\r\n\t\t\tthis.element\t= this.img.nativeElement;\r\n\r\n\t\t\tthis.render();\r\n\t\t};\r\n\r\n\t\tthis.render();\r\n\t}\r\n\r\n\r\n\t@HostListener('window:resize')\r\n\tpublic resize()\r\n\t{\r\n\t\tthis.render();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic clear()\r\n\t{\r\n\t\tthis.ctx.clearRect(0, 0, this.width, this.height);\r\n\t}\r\n\t\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic render()\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Une fois l'image découpé on la place dans le canvas pour la découpe\r\n\t\t// ---------------------------------------\r\n\t\ttry\r\n\t\t{\r\n\t\t\tthis.canvas\t\t= document.getElementById(this.idCanvas);\r\n\r\n\t\t\tif (this.canvas)\r\n\t\t\t{\r\n\t\t\t\tthis.ctx\t\t= this.canvas.getContext('2d');\r\n\t\t\t\tthis.clear();\r\n\r\n\t\t\t\tif (this.containerWidth && this.containerHeight)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet coeffResize;\r\n\t\t\t\t\tlet newX = 0;\r\n\t\t\t\t\tlet newY = 0;\r\n\r\n\t\t\t\t\tlet realContainerWidth;\r\n\t\t\t\t\tlet realContainerHeight;\r\n\r\n\t\t\t\t\trealContainerWidth\t= this.containerWidth\t> this.canvas.width\t\t? this.canvas.width\t\t: this.containerWidth;\r\n\t\t\t\t\trealContainerHeight = this.containerHeight\t> this.canvas.height\t? this.canvas.height\t: this.containerHeight;\r\n\r\n\t\t\t\t\tif (this.width > this.height)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcoeffResize = this.width / realContainerWidth;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcoeffResize = this.height / realContainerHeight;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.width\t= Math.round(this.width / coeffResize);\r\n\t\t\t\t\tthis.height = Math.round(this.height / coeffResize);\r\n\r\n\t\t\t\t\tnewX = Math.round((realContainerWidth\t- this.width)\t/ 2);\r\n\t\t\t\t\tnewY = Math.round((realContainerHeight\t- this.height)\t/ 2);\r\n\r\n\t\t\t\t\tnewX = newX > 0 ? newX : 0;\r\n\t\t\t\t\tnewY = newY > 0 ? newY : 0;\r\n\r\n\t\t\t\t\tthis.ctx.drawImage(this.element, newX, newY, this.width, this.height);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.ctx.drawImage(this.element, 0, 0, this.width, this.height);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tcatch(error) \r\n\t\t{\r\n\t\t\tconsole.error(error);\r\n\t\t}\r\n\t}\r\n}","import { NgModule } from '@angular/core';\r\nimport { CommonModule }\tfrom '@angular/common';\r\n\r\nimport { CanvasComponent } from './canvas.component';\r\n\r\n@NgModule({\r\n declarations: [\r\n CanvasComponent,\r\n ],\r\n imports: [\r\n ],\r\n exports: [\r\n CanvasComponent\r\n ]\r\n})\r\nexport class CanvasModule {}\r\n","\r\n\t\r\n\r\n\t
\r\n\t\t
\r\n\t\t\r\n\t\t
\r\n\r\n\r\n\t\t
\r\n\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t
\r\n\r\n\t\t\t\t\t\r\n\r\n\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t\t\r\n\t\t\t
\r\n\t\t
\r\n\t
\r\n\r\n\t
\r\n\t\t\r\n\t\t\r\n\t\t{{ 'chat.send' | translate }} \r\n\t
\r\n
","import { Component, Input, ViewEncapsulation, OnInit, EventEmitter, Output, OnChanges, ViewChild, ElementRef } from '@angular/core';\r\n\r\nimport { SocketService }\tfrom '../../../services/socket.service';\r\nimport { ChatHttpService }\tfrom '../../../services/http/chatHttp.service';\r\nimport { RoomService }\t\tfrom '../../../services/room.service';\r\nimport { UserData }\t\t\tfrom '../../../providers/user-data';\r\nimport { ChatData }\t\t\tfrom '../../../providers/chat-data';\r\n\r\ndeclare var socketCluster: any;\r\nimport { timer as Timer} from 'rxjs/observable/timer';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n//\t\tScrollGlue ,\r\n//declare var emoji = require('node-emoji')\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'app-chat-detail',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\ttemplateUrl:\t'./chat-detail.component.html',\r\n\toutputs:\t\t['_sendMessageEmitter: onSendMessage'],\r\n\tstyleUrls:\t\t['./chat-detail.component.scss']\r\n\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class ChatDetailComponent implements OnChanges, OnInit\r\n{\r\n\t@Input() displayMessage:\tboolean;\r\n\t@Input() isRoomSelected:\tany;\r\n\t@ViewChild('message2') vc:\t\t\tElementRef;\r\n\t@ViewChild('textArea') textArea:\tElementRef;\r\n\r\n\tpublic _sendMessageEmitter: EventEmitter = new EventEmitter();\r\n\r\n\tpublic lastMessageTix:\t\tstring;\r\n\tpublic currentUser:\t\t\tstring;\r\n\tpublic messages:\t\t\tany;\r\n\tpublic message:\t\t\t\tany = '';\r\n\tpublic mustScrollBottom:\tboolean = false;\r\n\r\n\tlastDate:\tstring;\r\n\tdateObj:\tany;\r\n\tmonth:\t\tany; //months from 1-12\r\n\tday:\t\tany;\r\n\tyear:\t\tany;\r\n\r\n\r\n\t/**\r\n\t * Creates an instance of ChatDetail.\r\n\t *\r\n\t * @param { ChatService } chatService\r\n\t *\r\n\t * @memberOf ChatDetail\r\n\t */\r\n\tconstructor(public socketService:\tSocketService,\r\n\t\t\t\tpublic userData:\t\tUserData,\r\n\t\t\t\tpublic roomService:\t\tRoomService,\r\n\t\t\t\tpublic chatData:\t\tChatData,\r\n\t\t\t\tpublic chatHttpService:\tChatHttpService)\r\n\t{\r\n\r\n\t\t// récupération de l'utilisateur en cours\r\n\t\tthis.currentUser\t= userData.getUserId();\r\n\t\tthis.dateObj\t\t= new Date();\r\n\t\tthis.month\t\t\t= this.dateObj.getUTCMonth() + 1; //months from 1-12\r\n\t\tthis.day\t\t\t= this.dateObj.getUTCDate();\r\n\t\tthis.year\t\t\t= this.dateObj.getUTCFullYear();\r\n\r\n\t\tthis.lastDate = this.year + '' + this.month + '' + this.day;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\t// Récupération de l'utilisateur courant, pour l'emission des sockets\r\n\t\tthis.getMessagesAvailable();\r\n\t\tthis.mustScrollBottom = true;\r\n\t\tthis.userData.globalEmitter.subscribe((value: any[]) => this.chatControl(value[0], value[1]),\r\n\t\t\t(error: Error) => console.log(error),\r\n\t\t\t() => console.log('done'));\r\n\r\n\t\tthis.scrollToBottom();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param key \r\n\t * @param value \r\n\t */\r\n\tpublic chatControl(key: any, value: any)\r\n\t{\r\n\t\tif(key === 'notify' && value === 'scrollBottom')\r\n\t\t{\r\n\t\t\tthis.scrollToBottom();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tngAfterViewChecked()\r\n\t{\r\n\t\tif (this.mustScrollBottom === true)\r\n\t\t{\r\n\t\t\tthis.mustScrollBottom = false;\r\n\t\t\tthis.scrollToBottom();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tscrollToBottom(): void\r\n\t{\r\n\t\tlet timer2 = Timer(100);\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\ttimer2.subscribe((t2: any) =>\r\n\t\t{\r\n\t\t\tthis.vc.nativeElement.scrollTop = this.vc.nativeElement.scrollHeight;\r\n\t\t});\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngOnChanges()\r\n\t{\r\n\t\t// Récupération de l'utilisateur courant, pour l'emission des sockets\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @returns Une liste de message en fonction du compte\r\n\t *\r\n\t * @memberOf ChatDetail\r\n\t */\r\n\tpublic getMessagesAvailable()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic clearTextArea()\r\n\t{\r\n\t\tthis.message = '';\r\n\t\tthis.textArea.nativeElement.value = '';\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Au cluc sur envoyer, ou la touche \"enter\", permet d'envoyer le contenu du textarea sous forme de message\r\n\t * Sauf si ce contenu est vide.\r\n\t *\r\n\t *\r\n\t * TODO => prévoir de vider le textarea\taprès l'envoi\r\n\t */\r\n\tpublic send()\r\n\t{\r\n\t\tif (this.message !== '' && this.message !== undefined && this.message !== '\\n')\r\n\t\t{\r\n\t\t\tthis._sendMessageEmitter.emit(this.message);\r\n\t\t\tthis.clearTextArea();\r\n\t\t}\r\n\t\tif (this.message === undefined || this.message === '\\n')\r\n\t\t{\r\n\t\t\tthis.clearTextArea();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Est appelé à chaque modification du textarea, permet de garder à jours le message à envoyer une fois le btn send cliqué.\r\n\t */\r\n\tpublic refreshMessage(poValue: any)\r\n\t{\r\n\t\tthis.message = poValue;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Handle keypress event, for sending chat message\r\n\t */\r\n\tpublic eventHandler(event: KeyboardEvent): void\r\n\t{\r\n\t\tif ((event.key === \"Enter\" && !event.shiftKey) && (this.message !== '' && this.message !== undefined && this.message !== '\\n' && this.message !== null))\r\n\t\t{\r\n\t\t\tevent.preventDefault();\r\n\t\t\tthis.message = this.replaceBr(this.message);\r\n\t\t\tthis.send();\r\n\t\t}\r\n\r\n\t\telse if (event.key === \"Enter\" && !event.shiftKey && (this.message === '\\n' || this.message === undefined || this.message === null || this.message === ''))\r\n\t\t{\r\n\t\t\tevent.preventDefault();\r\n\t\t\tif (this.message)\r\n\t\t\t{\r\n\t\t\t\tthis.message = this.replace(this.message);\r\n\t\t\t}\r\n\t\t\tthis.clearTextArea();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Handle keypress event, for sending chat message\r\n\t */\r\n\tpublic eventHandlerUp(event: KeyboardEvent): void\r\n\t{\r\n\t\tevent.preventDefault();\r\n\r\n\t\tif (event.key === \"Enter\" && !event.shiftKey && (this.message === '\\n' || this.message === undefined || this.message === null || this.message === ''))\r\n\t\t{\r\n\t\t\tthis.clearTextArea();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param v \r\n\t */\r\n\temojiAdded(v: any)\r\n\t{\r\n\t\tthis.message = v;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param chaine \r\n\t */\r\n\treplace(chaine: any)\r\n\t{\r\n\t\treturn (chaine.replace(/\\n/g, \"\"));\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param chaine \r\n\t */\r\n\treplaceBr(chaine: any)\r\n\t{\r\n\t\treturn (chaine.replace(/\\n/g, \" \"));\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic handlerFunction()\r\n\t{\r\n\t\tif (this.chatData.selectedRoom)\r\n\t\t{\r\n\t\t\tthis.roomService.getMessagesBucket(this.chatData.selectedRoom.id, this.chatData.selectedRoom.firstId, 100, 'true');\r\n\t\t}\r\n\t}\r\n}\r\n\r\n","\r\n\t
\r\n\t\t\r\n\t\t\t\t\r\n\t\t\t\t\r\n\t\t\t\t \r\n\t\t\t \r\n\t\t \r\n\t \r\n
\r\n\r\n \r\n\r\n\t
\r\n\t\t
\r\n\t\t\t
{{ 'chat.chooseConversation' | translate }} \r\n\t\t\t
Ajouter une conversation \r\n\t
\r\n
\r\n\r\n\tadd \r\n
\r\n\r\n\t\r\n\t\t \r\n\t \r\n
\r\n","import { Component, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core';\r\nimport { MatDialog }\t\t\t\t\t\t\t\tfrom '@angular/material';\r\nimport { TranslateService } \t\t\t\t\t\tfrom '@ngx-translate/core';\r\n\r\nimport { Piece }\t\t\t\tfrom '../../../classes/piece.class';\r\nimport { User }\t\t\t\t\tfrom '../../../classes/user.class';\r\nimport { Message }\t\t\t\tfrom '../../../classes/message.class';\r\nimport { UserData }\t\t\t\tfrom '../../../providers/user-data';\r\nimport { ChatData }\t\t\t\tfrom '../../../providers/chat-data';\r\nimport { SocketService }\t\tfrom '../../../services/socket.service';\r\nimport { UserService }\t\t\tfrom '../../../services/user.service';\r\nimport { RoomService }\t\t\tfrom '../../../services/room.service';\r\nimport { Filter, OrderType }\tfrom '../../../components/search-bar/popover-search-filter/classes/filter.class';\r\nimport { SocketWhat }\t\t\tfrom '../../../models/message.model';\r\nimport { ISocketData }\t\t\tfrom '../../../models/message.model';\r\n\r\nimport { ModalCreateChatComponent } from '../modals/modal-create-chat/modal-create-chat.component';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n\r\n@Component({\r\n selector:\t\t'app-chat-list',\r\n encapsulation:\tViewEncapsulation.None,\r\n templateUrl:\t'./chat-list.component.html',\r\n styleUrls:\t\t['./chat-list.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * Composant parent du chat. Gère la liste des personnes et demande\r\n * au composant détail d'afficher la bonne conversation\r\n */\r\nexport class ChatListComponent implements OnInit, OnDestroy\r\n{\r\n public pieces:\t\t\t\tPiece[];\r\n public users:\t\t\t\tUser[];\r\n\r\n\t//Todo clean : voir à quoi il peut bien servir lui\r\n public datasPieces:\t\tstring;\r\n public piecesAvailable:\tany = {};\r\n public filters:\t\t\tFilter[];\r\n public separatorSearch:\tstring;\r\n public dataProperties:\tany[];\r\n public displayMessage:\tboolean;\r\n\r\n public room:\t\t\tstring = '';\r\n public selectedRoomId:\tstring = '';\r\n public newRoom:\t\t\tstring = '';\r\n public currentUser:\t\tstring = '';\r\n\r\n //a clean\r\n public isLoading:\t\tboolean = false;\r\n public showFab:\t\t\tboolean = false;\r\n public firstLoad:\t\tboolean = true;\r\n public messages:\t\tany;\r\n public socket:\t\t\tany;\r\n public channels:\t\tany;\r\n public selectedOption:\tstring;\r\n public userToken:\t\tany;\r\n\r\n public me:\t\t\t\tany;\r\n public fingerPrint:\t\tany;\r\n\tpublic isFormOpen:\t\tboolean = false;\r\n\tpublic isRoomSelected:\tboolean = false;\r\n\tpublic messagesReaded:\tany;\r\n\tpublic listener:\t\tany;\r\n\r\n\r\n\t/**\r\n\t * Creates an instance of ChatList.\r\n\t *\r\n\t * @param {ChatService} chatService\r\n\t * Todo finir de renseigner les params\r\n\t * @memberOf ChatList\r\n\t */\r\n constructor(\r\n\t\tpublic translate:\t\tTranslateService,\r\n public userData:\t\tUserData,\r\n public chatData:\t\tChatData,\r\n public roomService:\t\tRoomService,\r\n public socketService:\tSocketService,\r\n public dialog:\t\t\tMatDialog)\r\n\t\t{\r\n\t\t\tthis.translate.get('chat.filterName').subscribe((filterName: string) =>\r\n\t\t\t{\r\n\t\t\t\tthis.translate.get('chat.filterMessage').subscribe((filterMessage: string) =>\r\n\t\t\t\t{\r\n\t\t\t\t\t// Liste des filtres disponible\r\n\t\t\t\t\tthis.filters =\r\n\t\t\t\t\t[\r\n\t\t\t\t\t\tnew Filter('name', \t\t\tfilterName, \ttrue, \t[{ 'name': 'default', 'order': OrderType.ASC }]),\r\n\t\t\t\t\t\tnew Filter('lastMessage', \tfilterMessage, \tfalse, \t[{ 'name': 'dateMessage', 'order': OrderType.DESC }])\r\n\t\t\t\t\t];\r\n\r\n\t\t\t\t});\r\n });\r\n\r\n\t\t\t// Infos pour la recherche\r\n\t\t\tthis.separatorSearch\t= ':';\r\n\t\t\tthis.datasPieces\t\t= JSON.stringify(this.chatData.rooms);\r\n\t\t\tthis.dataProperties\t\t=\r\n\t\t\t\t[\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttagName: 'default',\r\n\t\t\t\t\t\tpaths: [['_name']]\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttagName: 'etablissement',\r\n\t\t\t\t\t\tpaths: [['_users', '_etablissement']]\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttagName: 'session',\r\n\t\t\t\t\t\tpaths: [['_users', '_session']]\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttagName: 'examen',\r\n\t\t\t\t\t\tpaths: [['_users', '_examen']]\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttagName: 'status',\r\n\t\t\t\t\t\tpaths: [['_users', '_status']]\r\n\t\t\t\t\t},\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttagName: 'dateMessage',\r\n\t\t\t\t\t\tpaths: [['_messages', '_date']]\r\n\t\t\t\t\t}\r\n\t\t\t\t];\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis.listener = this.userData.globalEmitter.subscribe((value: any[]) => this.chatControl(value[0], value[1]),\r\n\t\t\t(error: Error) => console.log(error),\r\n\t\t\t() => console.log('done'));\r\n\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Récupérations des infos de base\r\n\t\t// ---------------------------------------\r\n\t\tthis.currentUser\t= this.userData.getUserId();\r\n\t\tthis.userToken\t\t= this.userData.getTokenKey();\r\n\t\tthis.isLoading\t\t= true;\r\n\t\tlet array: any\t\t= [];\r\n\t\tthis.users\t\t\t= array;\r\n\t\tthis.channels\t\t= {};\r\n\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// A partir de la liste des messages on retrouve les users par rooms\r\n\t\t// ---------------------------------------\r\n\t\t/**\r\n\t\t * Récupération du socket global pour faire des appels depuis ce fichier\r\n\t\t */\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tthis.socket = socket;\r\n\t\t});\r\n\r\n\r\n\t\tthis.isLoading = false;\r\n\r\n\t\tif (this.chatData.selectedRoom !== null && this.chatData.selectedRoom !== undefined)\r\n\t\t{\r\n\t\t\tthis.openPiece(this.chatData.selectedRoom);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Ouvre la modal pour créer une conversation\r\n\t */\r\n\tpublic openDialog()\r\n\t{\r\n\t\tthis.showFab = true;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Ferme la modal de création de conversation\r\n\t */\r\n\tpublic closeDialog()\r\n\t{\r\n\t\tthis.showFab = false;\r\n\t}\r\n\r\n\t/**\r\n\t * Toggle de la modal de conversation\r\n\t */\r\n\tpublic toggleDialog()\r\n\t{\r\n\t\tthis.showFab = !this.showFab;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Activé au clic sur le +.\r\n\t * Envoie une demande de récupération de la liste des users.\r\n\t * A la reception de celle ci la fonction openForm est apzellé\r\n\t */\r\n\tpublic addCommunityItem()\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Récupération de la liste des users pour pourvoir créer la liste des personnes invitable\r\n\t\t// ---------------------------------------\r\n\t\tlet userId: string = this.userData.getUserId();\r\n\t\tlet eSocketWhat: SocketWhat.request;\r\n\r\n\r\n\t\t// Demande de la liste des utilisateurs, un écouteur est placé,\r\n\t\t// lorsque la réponse arrive la modal s'ouvre automatiquement\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tthis.socket = socket;\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t\t'name': userId,\r\n\t\t\t\t\t\t'what': eSocketWhat,\r\n\t\t\t\t\t\t'cmd':\t'user',\r\n\t\t\t\t\t\t'args': { mail:'' }\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis.openForm('chat::getUsers');\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Controller qui à partir d'une commande reçu apelle la bonne fonction\r\n\t * Pour le moment permet d'ouvrir la modale de creation et d'ouvrir une room\r\n\t * après la demande de récup d'info\r\n\t */\r\n\tpublic chatControl(value: any, data: any = null)\r\n\t{\r\n\r\n\t\t// this.piecesAvailable.pieces.push(newPiece);\r\n\t\t// ---------------------------------------\r\n\t\t// TODO: Faire un switch\r\n\t\t// ---------------------------------------\r\n\t\tif (value === 'chat::getUsers' && !this.isFormOpen)\r\n\t\t{\r\n\t\t\tthis.openForm(value);\r\n\t\t}\r\n\r\n\t\tif (value === 'chat::openRoomAfterData')\r\n\t\t{\r\n\t\t\tthis.openRoomAfterData();\r\n\t\t}\r\n\r\n\t\tif (value === 'chat::newMessage')\r\n\t\t{\r\n\t\t\tthis.newMessageReceived(data);\r\n\t\t}\r\n\r\n\t\tif (value === 'notify2')\r\n\t\t{\r\n//\t\t\tthis.chatData.setSelectedRoomBy(data);\r\n\t\t\tthis.roomService.getMessagesBucket(data);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic majRooms(newPiece: any)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Ici rajouter la room à afficher\r\n\t\t// ---------------------------------------\r\n\t\tthis.piecesAvailable.pieces.push(newPiece);\r\n\t}\r\n\r\n\r\n\r\n\t/**\r\n\t * Ouverture du formulaire de création de room,\r\n\t * est automatiquement appelé à la reception de la liste des users.\r\n\t * (un clic sur le btn plus envoie la demande de la liste des users disponible.)\r\n\t */\r\n\tpublic openForm(value: string)\r\n\t{\r\n\t\t// Vérification que la commande qui active l'ouverture est la bonne.\r\n\t\t// On vérifie aussi que le chat ne soit pas déjà ouvert (cas du double clic sur le +)\r\n\t\tif (!this.isFormOpen)\r\n\t\t{\r\n\t\t\t// MAJ de la variable, pour bloquer les futures ouvertures temps que le form n'est pas fermé\r\n\t\t\tthis.isFormOpen = true;\r\n\r\n\t\t\t// Récupération de la liste des users depuis le localstorage et on la passe au formulaire.\r\n\t\t\tlet userList = this.userData.getUsers();\r\n\r\n\t\t\t// Les rooms déjà ouverte pour récup les users déjà en cours\r\n\t\t\tlet rooms = this.chatData.rooms;\r\n\t\t\tlet arrayOfUserRoom = [];\r\n\t\t\tlet userList2 = [];\r\n\r\n\t\t\t// On met tt ça ds un tableau\r\n\t\t\tfor (let room of rooms)\r\n\t\t\t{\r\n\t\t\t\tfor (let user of room.users)\r\n\t\t\t\t{\r\n\t\t\t\t\tarrayOfUserRoom.push(user.mail);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// On rajoute le mail de l'user en cours\r\n\t\t\tarrayOfUserRoom.push(this.userData.getUserId());\r\n\r\n\t\t\tfor (let key in userList)\r\n\t\t\t{\r\n\t\t\t\tlet finded = false;\r\n\r\n\t\t\t\t// On compare les mails dispo et les mails déjà en chat\r\n\t\t\t\tfor (let user of arrayOfUserRoom)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (key === user)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfinded = true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (!finded)\r\n\t\t\t\t{\r\n\t\t\t\t\tuserList2.push(userList[key]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Ouverture de la modal de selection d'user\r\n\t\t\tlet dialogRef = this.dialog.open(ModalCreateChatComponent,\r\n\t\t\t\t{\r\n\t\t\t\t\theight:\t\t\t'50%',\r\n\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\twidth:\t\t\t'60%',\r\n\t\t\t\t\tdata:\t\t\t{'userList': userList2},\r\n\t\t\t\t\tdisableClose:\tfalse\r\n\t\t\t\t});\r\n\t\t\tlet userId = localStorage.getItem('userid');\r\n\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// Après la fermeture, création de la room via socket\r\n\t\t\t// ---------------------------------------\r\n\t\t\tdialogRef.afterClosed().subscribe((result: any) =>\r\n\t\t\t{\r\n\t\t\t\t// vérification du result.. si c'est false = erreur, du coup on va pas ajouter\r\n\t\t\t\tif (result)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.isFormOpen = false;\r\n\t\t\t\t\tlet eSocketWhat: SocketWhat.request;\r\n\r\n\r\n\t\t\t\t\t// Lib auto permet d'avoir un nom automatique en fonction de la personne avec qui on communique.\r\n\t\t\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (socket)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.socket = socket;\r\n\t\t\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t\t\t\t\t'name':\tuserId,\r\n\t\t\t\t\t\t\t\t\t'what':\teSocketWhat,\r\n\t\t\t\t\t\t\t\t\t'cmd':\t'room',\r\n\t\t\t\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t'libAuto':\t\ttrue,\r\n\t\t\t\t\t\t\t\t\t\t'owner':\t\tuserId,\r\n\t\t\t\t\t\t\t\t\t\t'isPublic':\t\tfalse,\r\n\t\t\t\t\t\t\t\t\t\t'isReadOnly':\tfalse\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\t\tsocket.emit('create', data);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\tthis.isFormOpen = false;\r\n\t\t\t\tdialogRef.close();\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Fonction pour afficher un nouveau message, est bindé directement avec la récup de new message\r\n\t */\r\n\tpublic newMessageReceived(data: any)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Message = isocket data\r\n\t\t// ---------------------------------------\r\n\t\tif (data.cmd === 'msg')\r\n\t\t{\r\n\t\t\tif (this.chatData.selectedRoom)\r\n\t\t\t{\r\n\t\t\t\tthis.chatData.selectedRoom.counter = 0;\r\n\t\t\t\tthis.chatData.setCounterByRoom(this.chatData.selectedRoom.id, 0);\r\n\t\t\t\t// création de l'objet message et ajout dans la room correspondante (var message en global)\r\n\t\t\t\tlet arrayKey\t\t= [];\r\n\t\t\t\tlet arrayMessage\t= _.toArray(data.args.messages);\r\n\r\n\t\t\t\t// Tableau de clef pour les selectionner plus simplement par l'indice\r\n\t\t\t\tfor(let key in data.args.messages)\r\n\t\t\t\t{\r\n\t\t\t\t\tarrayKey.push(key);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor(let key in arrayKey)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet values = JSON.parse(arrayMessage[key].val);\r\n\r\n\t\t\t\t\tif (values.name === this.chatData.selectedRoom.users[0].mail || values.name === this.userData.getUserId())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet oMessage = new Message(values.name, values.args.message, arrayMessage[key].dateticks, arrayMessage[key].id);\r\n\t\t\t\t\t\tthis.addMessage(oMessage);\r\n\r\n\r\n\t\t\t\t\t\t// Commentaire à rajouter\r\n\t\t\t\t\t\tif (values.name !== this.userData.getUserId())\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (socket)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t\t\t\t\t\t'cmd':\t'msg.read',\r\n\t\t\t\t\t\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tbucket:\t\t'rooms',\r\n\t\t\t\t\t\t\t\t\t\t\t\tnotifier:\t['*room::' + this.chatData.selectedRoom.id + '::priv'],\r\n\t\t\t\t\t\t\t\t\t\t\t\tkey:\t\tthis.chatData.selectedRoom.id,\r\n\t\t\t\t\t\t\t\t\t\t\t\tsub:\t\t'M',\r\n\t\t\t\t\t\t\t\t\t\t\t\twhen:\t\tarrayMessage[key].id\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\t\t\t\tsocket.emit('update', data);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param {*} piece\r\n\t * @returns\r\n\t *\r\n\t * @memberOf ChatList\r\n\t */\r\n public isPieceSelected(piece: any)\r\n {\r\n }\r\n\r\n\r\n\t/**\r\n\t * est appelé au clic sur une room.\r\n\t * Va envoyer une demande de récup des messages ... à faire que si on a pas de messages sauvegardé et 0 nouveau\r\n\t */\r\n\tpublic openPiece(piece: any)\r\n\t{\r\n\t\tthis.roomService.getMessagesBucket(piece.id);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Une fois les data de la room reçu pour l'ouverture, on les traites et on ouvre la room\r\n\t * TODO : Rajouter un appel de messages supplémentaire si y'en a pas assez\r\n\t */\r\n\tpublic openRoomAfterData(messages: any = null)\r\n\t{\r\n\t\tthis.isRoomSelected = false;\r\n\r\n\t//ici=> revoir formatage\r\n\t\tlet arrayMessage: any[];\r\n\t\tlet isFormated\t= false;\r\n\r\n\t\tif (messages === null && this.chatData.selectedRoom)\r\n\t\t{\r\n\t\t\t// cas par socket, a été stocké dès la reception des infos => puis emit pr déclancher cette fonction\r\n\t\t\tarrayMessage\t\t= this.chatData.getMessagesByRoomId(this.chatData.selectedRoom.id);\r\n\t\t\tthis.selectedRoomId = this.chatData.selectedRoom.id;\r\n\r\n\t\t\tif (arrayMessage)\r\n\t\t\t{\r\n\t\t\t\tarrayMessage.reverse();\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tisFormated\t\t= true;\r\n\t\t\tarrayMessage\t= messages;\r\n\t\t}\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// A partir de la piece selected, récup les infos des users en storage\r\n\t\t// ---------------------------------------\r\n\t\tlet messageList = [];\r\n\t\tif(arrayMessage)\r\n\t\t{\r\n\t\t\tfor (let message of arrayMessage)\r\n\t\t\t{\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\t// On recoit un Esocket data à transformer en Message\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\tlet oMessage\t\t= new Message();\r\n\t\t\t\tlet eScocketMessage;\r\n\t\t\t\tif (!isFormated)\r\n\t\t\t\t{\r\n\t\t\t\t\t// eScocketMessage\t\t= JSON.parse(message._content);\r\n\t\t\t\t\t// eScocketMessage\t\t= JSON.parse(message.message);\r\n\t\t\t\t\toMessage.content\t= message._content;\r\n\t\t\t\t\toMessage.userId\t\t= message._userId;\r\n\t\t\t\t\toMessage.ticks\t\t= message.ticks;\r\n\r\n\t\t\t\t\tlet tempConvert = new Date(message._date).getTime();\r\n\t\t\t\t\t// let delta\t\t= Math.round((+new Date - this.date) / 1000);\r\n\r\n\t\t\t\t\ttempConvert\t\t= Math.round((tempConvert));\r\n\t\t\t\t\tlet dateTest\t= new Date(tempConvert);\r\n\t\t\t\t\toMessage.date\t= dateTest;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\toMessage.content\t= message._content;\r\n\t\t\t\t\toMessage.userId\t\t= message._userId;\r\n\t\t\t\t\toMessage.date\t\t= message._date;\r\n\t\t\t\t\toMessage.ticks\t\t= message.ticks;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// On balance les messages dans un tableau pr les insérer à la room par la suite\r\n\t\t\t\tif (oMessage.content)\r\n\t\t\t\t{\r\n\t\t\t\t\tmessageList.push(oMessage);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (this.chatData.selectedRoom && this.chatData.selectedRoom.lastDate < oMessage.date)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.chatData.selectedRoom.lastId\t= oMessage.ticks;\r\n\t\t\t\t\tthis.chatData.selectedRoom.lastDate = oMessage.date;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\tif (this.chatData.selectedRoom.firstDate > oMessage.date)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.chatData.selectedRoom.firstId\t\t= oMessage.ticks;\r\n\t\t\t\t\t\tthis.chatData.selectedRoom.firstDate\t= oMessage.date;\r\n\t\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(this.chatData.selectedRoom)\r\n\t\t{\r\n\t\t\tthis.chatData.selectedRoom.counter = 0;\r\n\t\t\tthis.chatData.setCounterByRoom(this.chatData.selectedRoom.id, 0);\r\n\t\t}\r\n\r\n\t\t// modification du boolean pour l'affichage de la room selectionnée\r\n\t\tthis.isRoomSelected = true;\r\n\t\tthis.userData.globalEmitter.emit(['notify', 'scrollBottom']);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Construit le JSON pour envoyer le message\r\n\t */\r\n\tpublic sendMessage(psMessage: string)\r\n\t{\r\n\r\n\t\t// récupération du nom et de l'id de la room en cours\r\n\t\t// TODO: Factoriser et stocker tt ça, userData me semble pas mal pour ça\r\n\t\tif (this.chatData.selectedRoom)\r\n\t\t{\r\n\t\t\tconst name\t\t= '*room::' + this.chatData.selectedRoom.id + '::priv';\r\n\t\t\tconst roomId\t= this.socketService.findRoomAGerer(name);\r\n\r\n\t\t\tlet eSocketWhat: SocketWhat.request;\r\n\r\n\t\t\t// Cas d'erreur\r\n\t\t\tif (roomId === -1)\r\n\t\t\t{\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\t// récupération de l'object room, et publication du message\r\n\t\t\tlet oRoom = this.socketService.roomsAGerer[roomId];\r\n\r\n\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t// \"authToken\":\tthis.userToken,\r\n\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd':\t'msg',\r\n\t\t\t\t\t'args': { 'message': psMessage }\r\n\t\t\t\t};\r\n\r\n\t\t\toRoom.channel.publish(data);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * @param {Piece} piece\r\n\t *\r\n\t * @memberOf ChatList\r\n\t */\r\n\tpublic listenPiece(piece: Piece)\r\n\t{\r\n\r\n\t\tthis.displayMessage = true;\r\n\r\n\t\t//Gestion des erreursw\r\n\t\tthis.socket.on('error', function (err: any)\r\n\t\t{\r\n\t\t\tthrow 'Socket error - ' + err;\r\n\t\t});\r\n\r\n\t\t// logout\r\n\t\tthis.socket.on('logout', function (err: any)\r\n\t\t{\r\n\r\n\t\t});\r\n\r\n\r\n\t\t// Une fois connecté\r\n\t\tthis.socket.on('connect', function ()\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.getUserId() + '::' + this.userData.account + '::socketCluster.authToken', this.userToken);\r\n\t\t}.bind(this));\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Vérification de la souscription\r\n\t\t// ---------------------------------------\r\n\t\tconst isSuscribed = this.socket.isSubscribed(piece.id);\r\n\r\n\t\tif (isSuscribed)\r\n\t\t{\r\n\t\t\t// Vérif watcher\r\n\t\t\tconst arrayWatchers = this.socket.watchers(\"*room::\" + piece.id + \"::priv\");\r\n\r\n\t\t\tif (arrayWatchers === undefined || arrayWatchers.length === 0)\r\n\t\t\t{\r\n\t\t\t\tthis.watchPiece(piece.id);\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param roomId \r\n\t */\r\n\tprivate watchPiece(roomId: string)\r\n\t{\r\n\t\tif (this.channels && this.channels[roomId])\r\n\t\t{\r\n\t\t\tthis.channels[roomId].watch((newMessage: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (newMessage.cmd === 'message')\r\n\t\t\t\t{\r\n\t\t\t\t\tconst message = new Message(newMessage.name, newMessage.args.value, new Date());\r\n\t\t\t\t\tthis.addMessage(message);\r\n\t\t\t\t\tthis.messages += message;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic addMessage(pjMessage: any)\r\n\t{\r\n\t\t// Programmation défensive à mettre en place\r\n\t\tif (this.chatData.selectedRoom)\r\n\t\t{\r\n\t\t\tthis.chatData.selectedRoom.addMessage(pjMessage, pjMessage.ticks);\r\n\r\n\t\t\tif (this.chatData.selectedRoom.lastDate < pjMessage.date)\r\n\t\t\t{\r\n\t\t\t\tthis.chatData.selectedRoom.lastId\t= pjMessage.ticks;\r\n\t\t\t\tthis.chatData.selectedRoom.lastDate = pjMessage.date;\r\n\t\t\t}\r\n\r\n\t\t\tif (this.chatData.selectedRoom.firstDate > pjMessage.date)\r\n\t\t\t{\r\n\t\t\t\tthis.chatData.selectedRoom.firstId\t\t= pjMessage.ticks;\r\n\t\t\t\tthis.chatData.selectedRoom.firstDate\t= pjMessage.date;\r\n\t\t\t}\r\n\r\n\t\t\tthis.userData.globalEmitter.emit(['notify', 'scrollBottom']);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic initMessage(pjMessage: any)\r\n\t{\r\n\t}\r\n\r\n\r\n /**\r\n * @param event\r\n *\r\n * @memberOf ChatList\r\n *\r\n */\r\n\tpublic updatePiecesAvailable(event: any)\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Update des pieces\r\n\t\t// ---------------------------------------\r\n\t\tif (event.value)\r\n\t\t{\r\n\t\t\tthis.piecesAvailable.pieces = [];\r\n\t\t\tlet value = JSON.parse(event.value);\r\n\t\t\tfor (let i = 0; i < value.length; i++)\r\n\t\t\t{\r\n\t\t\t\tthis.piecesAvailable.pieces.push(Piece.fromJsonObject(value[i]));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public join(): void\r\n\t{\r\n //\t\tthis.roomService.join(this.room);\r\n }\r\n\r\n\r\n\t/**\r\n\t * Create room, when Create-button is pressed and empty newRoom text input\r\n\t */\r\n\tpublic create(): void\r\n\t{\r\n\r\n\t\t/*\r\n\t\t * Creation d'un new room() (class)\r\n\t\t */\r\n\t\tlet id:\t\t\t\tstring\t= '';\r\n\t\tlet users:\t\t\tany[]\t= [];\r\n\t\tlet messages:\t\tany[]\t= [];\r\n\t\tlet sType:\t\t\tstring\t= '';\r\n\t\tlet name:\t\t\tstring\t= '';\r\n\t\tlet displayName:\tstring\t= '';\r\n\t\tlet description:\tstring\t= '';\r\n\t\tlet state:\t\t\tboolean = false;\r\n\r\n\r\n\t\t/*\r\n\t\t * Si création ok => on ajoute la room a la liste des rooms\r\n\t\t */\r\n\t\tlet newRoom = new Piece(id, users, messages, sType, name,displayName, description, state);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Remove room, when Remove-button is pressed and unset selected room\r\n\t */\r\n\tpublic remove(): void\r\n\t{\r\n\t\t// this.roomService.remove(this.room);\r\n\t\t// this.room = \"\";\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Handle keypress event (for creating a new room)\r\n\t */\r\n\tpublic eventHandler(event: KeyboardEvent): void\r\n\t{\r\n\r\n\t\tif (event.key === \"Enter\")\r\n\t\t{\r\n\t\t\t// this.create();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic ngOnDestroy()\r\n\t{\r\n\r\n\t\tif (!this.firstLoad)\r\n\t\t{\r\n\t\t\t//Ici on a changé de room, permet d'avoir qu'un seul watch en cours !\r\n\t\t}\r\n\t\tthis.listener.unsubscribe();\r\n\r\n\t}\r\n\r\n\r\n\tpublic changeFocus(event: any)\r\n\t{\r\n\t}\r\n\r\n}\r\n\r\n","\r\n\r\n","import { Component, ViewEncapsulation, OnInit }\t\tfrom '@angular/core';\r\n\r\nimport { AppComponent }\tfrom '../../app.component';\r\n\r\nimport { MatDialog }\tfrom '@angular/material';\r\nimport { UserData }\t\tfrom '../../providers/user-data';\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'app-community',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\ttemplateUrl:\t'./community.component.html',\r\n\tstyleUrls:\t\t['./community.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class CommunityComponent implements OnInit\r\n{\r\n\r\n\tpublic panelSelected\t\t\t\t\t= 0;\r\n public isChatPanelSelected = true;\r\n public isForumtPanelSelected = false;\r\n public isNotificationstPanelSelected = false;\r\n public mbLoadState = false;\r\n\t\r\n\t\r\n\tpublic canAccessChat:\t\t\tboolean = true;\r\n\tpublic canAccessForum:\t\t\tboolean = false;\r\n\tpublic canAccessNotification:\tboolean = false;\r\n\t\r\n\r\n /**\r\n * Creates an instance of CommunityPage.\r\n * \r\n * @param {PopoverController} popoverCtrl\r\n * @param {NavController} nav\r\n *\r\n * @memberOf CommunityPage\r\n */\r\n\tconstructor(public appComponent:\tAppComponent,\r\n\t\t\t\tpublic dialog:\t\t\tMatDialog,\r\n\t\t\t\tpublic userData:\t\tUserData,)\r\n\t{\r\n\t\tthis.panelSelected = 0;\r\n//\t\tthis.canAccessChat = this.userData.canAccessChat;\r\n\t\t\r\n\t\t// Vérification des droits pour valider l'accès aux différentes parties\r\n\t\tif (this.userData.canAccessForum === true)\r\n\t\t{\r\n\t\t\tthis.canAccessForum = true;\r\n\t\t}\r\n\t\t\r\n\t\t// Modification du header\r\n\t\tappComponent.setPageTitle('Communauté');\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\t// TODO: voir si c'est tjr d'actualité\r\n\t\tthis.panelSelected = 0;\r\n\t\tthis.refreshTab(0);\r\n//\t\tthis.appComponent.setHeaderColor('#0277bd');\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnChange()\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @memberOf CommunityPage\r\n\t */\r\n\tpublic updateSegment(): void\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n /**\r\n *\r\n */\r\n\tpublic addCommunityItem(nameButton: any)\r\n\t{\r\n\t\tswitch (nameButton)\r\n\t\t{\r\n\t\t\tcase 'newTopic':\r\n\t\t\t\tbreak;\r\n\t\t\t\t\r\n\t\t\tcase 'publicConversation':\r\n\t\t\tcase 'privateGroup':\r\n\t\t\t\tbreak;\r\n\t\t\t\t\r\n\t\t\tdefault:\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\t/**\r\n\t * Retourne true une fois la page chargée\r\n\t *\r\n\t * @returns\r\n\t *\r\n\t * @memberOf WorkspacePage\r\n\t */\r\n\tpublic isLoaded(): boolean\r\n\t{\r\n\t\treturn this.mbLoadState;\r\n\t}\r\n\r\n\r\n /**\r\n * Display message for chat, topic and notifications creation. Display equally error messages\r\n *\r\n * @returns\r\n *\r\n * @memberOf WorkspacePage\r\n */\r\n\tpublic presentToast(message: any)\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Call on every modification of the tab\r\n\t */\r\n\tpublic refreshTab(e: any)\r\n\t{\r\n\r\n\t\t// En fonction de l'index on va choisir quelle section est à afficher\r\n\t\tswitch (e)\r\n\t\t{\r\n\t\t\tcase 0:\r\n\t\t\t\tthis.appComponent.setPageTitle('Communauté - Messagerie');\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 1:\r\n\t\t\t\tthis.appComponent.setPageTitle('Communauté - Forum');\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 2:\r\n\t\t\t\tthis.appComponent.setPageTitle('Communauté - Notification');\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n","\r\n\t\r\n\t
\r\n\t\t
Entrez les premières lettres du nom ou du mail de votre interlocuteur
\r\n\t\t
\r\n\t\t
\r\n\t\t\t \r\n\t\t \r\n\t\t
\r\n\t\t\t\r\n\t\t\t\t{{ user.infos.prenom }} {{ user.infos.nom }}
\r\n\t\t\t\t{{user.mail}}
\r\n\t\t\t \r\n\t\t \r\n\t\t
\r\n\t
\r\n\t\r\n
\r\n","import { Component, OnInit, ViewEncapsulation, Inject } from '@angular/core';\r\n\r\nimport { FormControl } \tfrom '@angular/forms';\r\nimport { MatDialogRef }\tfrom '@angular/material';\r\n\r\nimport { WorkspaceDataService } from '../../../../providers/workspaceData.service';\r\nimport { UserData }\t\t\t\tfrom '../../../../providers/user-data';\r\n\r\nimport * as _ from 'underscore';\r\nimport {MAT_DIALOG_DATA} from '@angular/material';\r\n\r\n\r\n/**\r\n *\r\n */\r\n@Component({\r\n\tselector:\t\t'app-modal-create-chat',\r\n\ttemplateUrl:\t'./modal-create-chat.component.html',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\tstyleUrls:\t\t['./modal-create-chat.component.scss']\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class ModalCreateChatComponent implements OnInit\r\n{\r\n public userSelected: any\t= null;\r\n public user\t\t\t\t\t= '';\r\n\tpublic usersList: any\t\t= [];\r\n\tpublic selectedType: any;\r\n\r\n\t// ---------------------------------------\r\n\t// Controle du formulaier\r\n\t// ---------------------------------------\r\n\tpublic userCtrl: FormControl;\r\n\r\n\t// Les élements filtré pour l'autocompletion\r\n\tpublic filteredUsers: any;\r\n\r\n\r\n\tpublic typesAvailable =\r\n\t[\r\n\t\t{ value: 'public',\tlibelle: 'Conversation publique' },\r\n\t\t{ value: 'group',\tlibelle: 'Conversation de groupe' }\r\n\t];\r\n\r\n\r\n /**\r\n * Creates an instance of PopoverCreateChat.\r\n *\r\n * @param {ViewController} viewCtrl\r\n *\r\n * @memberOf PopoverCreateChat\r\n */\r\n\tconstructor(public dialogRef: MatDialogRef,\r\n\t\t\t\tpublic workData: WorkspaceDataService,\r\n\t\t\t\tpublic userData:UserData,\r\n\t\t\t\t@Inject(MAT_DIALOG_DATA) public data: any)\r\n\t{\r\n\t\tthis.usersList = this.data.userList;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Init des formsControl\r\n\t\t// ---------------------------------------\r\n\t\tthis.userCtrl\t\t= new FormControl();\r\n\r\n\t\t// Raffraichi le filtrage à chaque modification\r\n \tthis.filteredUsers = this.userCtrl.valueChanges.startWith(null).map((name: any) => this.filterMail(name));\r\n\t}\r\n\r\n\r\n /**\r\n * Create a new piece with parameters of the current popup\r\n *\r\n * @memberOf PopoverCreateChat\r\n */\r\n\tpublic createPiece()\r\n\t{\r\n\t\tthis.userData.userForChatInvite = this.userSelected;\r\n\t\tthis.dialogRef.close(true);\r\n\t}\r\n\r\n\r\n /**\r\n * Close the current popup\r\n *\r\n * @memberOf PopoverCreateChat\r\n */\r\n\tpublic close()\r\n\t{\r\n\t\tthis.dialogRef.close(false);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param user \r\n\t */\r\n \tpublic displayUsername(user: any): string\r\n\t{\r\n \treturn user ? user.mail : null;\r\n \t}\r\n\r\n\r\n\t/**\r\n\t Salut à tous,\r\n\t Le 11 mai je vous donne rendez-vous à Serignan pour mon premier combat en boxe anglaise 🥊\r\n\t Je tiens à remercier Jacques Patrac mon matchmaker, ainsi mon coach Daniel Barry pour la prépa au top ainsi que tout les membres du Boxing Club Montpelliérain pour leur accueil.\r\n\t Un gros bisous à mes supporter, ils ne sont pas nombreux mais ils se reconnaitront !\r\n\t Boxe serignan <= tagguer ici l'event\r\n\t *\r\n\t */\r\n\tpublic filterMail(val: any)\r\n\t{\r\n\r\n\t\tlet result\t= this.usersList;\r\n\t\tlet result2 = this.usersList;\r\n\t\tlet result3 = this.usersList;\r\n\t\tlet result4 = this.usersList;\r\n\t\tlet result5 = this.usersList;\r\n\r\n\t\tif (val && typeof val === 'string')\r\n\t\t{\r\n\t\t\tresult\t= this.usersList.filter((user: any) => user.mail.toLowerCase().indexOf(val.toLowerCase())\t\t\t=== 0);\r\n\t\t\tresult2 = this.usersList.filter((user: any) => user.infos.nom.toLowerCase().indexOf(val.toLowerCase())\t\t=== 0);\r\n\t\t\tresult3 = this.usersList.filter((user: any) => user.infos.prenom.toLowerCase().indexOf(val.toLowerCase())\t=== 0);\r\n\r\n\t\t\tresult4 = this.usersList.filter((user: any) =>\r\n\t\t\t{\r\n\t\t\t\tconst str = user.infos.prenom.toLowerCase() + ' ' + user.infos.nom.toLowerCase();\r\n\t\t\t\t\r\n\t\t\t\treturn str.indexOf(val.toLowerCase()) === 0;\r\n\t\t\t});\r\n\r\n\t\t\tresult5 = this.usersList.filter((user: any) =>\r\n\t\t\t{\r\n\t\t\t\tconst str = user.infos.nom.toLowerCase() + ' ' + user.infos.prenom.toLowerCase();\r\n\t\t\t\t\r\n\t\t\t\treturn str.indexOf(val.toLowerCase())\t=== 0;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tconst aReturn = _.union(result, result2, result3, result4, result5);\r\n\r\n\t\treturn aReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic onNoClick(): void\r\n\t{\r\n\t\tthis.dialogRef.close();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic canCreateRoom()\r\n\t{\r\n\t\tlet result = false;\r\n\r\n\t\tif (this.userSelected && this.userSelected.mail)\r\n\t\t{\r\n\t\t\tresult = true;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n}\r\n","","import { Component, OnInit, Input,ViewEncapsulation } from '@angular/core';\r\nimport { ChatData }\t\t\t\tfrom '../../../providers/chat-data';\r\nimport { Router }\t\t\t\tfrom '@angular/router';\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'app-module-chat',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\ttemplateUrl:\t'./module-chat.component.html',\r\n\tstyleUrls:\t\t['./module-chat.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class ModuleChatComponent implements OnInit\r\n{\r\n\t@Input() maHomeRooms:\tany;\r\n\t@Input() contexte:\t\tany;\r\n\t\r\n\r\n\t/**\r\n\t * \r\n\t * @param chatData \r\n\t * @param router \r\n\t */\r\n\tconstructor(public chatData:\tChatData,\r\n\t\t\t\tpublic router:\t\tRouter) \r\n\t{ }\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param id \r\n\t */\r\n\tpublic onClick(id: any)\r\n\t{\r\n\t\tthis.chatData.setSelectedRoomBy(id);\r\n\t\tthis.router.navigate(['/community']);\r\n\t}\r\n\r\n}","import { Component, OnInit, ViewEncapsulation }\tfrom '@angular/core';\r\nimport { UserData }\t\t\t\tfrom '../../../providers/user-data';\r\nimport {\r\n MatSnackBar,\r\n MatSnackBarConfig,\r\n MatSnackBarHorizontalPosition,\r\n MatSnackBarVerticalPosition,\r\n} from '@angular/material';\r\n\r\n\r\n@Component({\r\n\tselector: 'app-notification-modal',\r\n\ttemplateUrl: './notification-modal.component.html',\r\n\tstyleUrls: ['./notification-modal.component.scss'],\r\n\tencapsulation: ViewEncapsulation.None,\r\n\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class NotificationModalComponent implements OnInit\r\n{\r\n\tpoHorizontalPosition: MatSnackBarHorizontalPosition = 'end';\r\n\tpoVerticalPosition: MatSnackBarVerticalPosition\t\t= 'top';\r\n\r\n\r\n\tactionButtonLabel:\tstring\t= '';\r\n\taction:\t\t\t\tboolean = true;\r\n\tsetAutoHide:\t\tboolean = true;\r\n\tautoHide:\t\t\tnumber\t= 5000;\r\n\taddExtraClass:\t\tboolean = true;\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param userData \r\n\t * @param snackBar \r\n\t */\r\n\tconstructor(public userData: UserData, public snackBar: MatSnackBar) { }\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis.userData.notifEmitter.subscribe((value: any[]) => this.control(value[0], value[1]),\r\n\t\t\t(error: Error) => console.log(error),\r\n\t\t\t() => console.log('done'));\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param psMessage \r\n\t * @param psAction \r\n\t */\r\n\tpublic control(psMessage: any, psAction: any)\r\n\t{\r\n\t\tthis.openSnackBar(psMessage, psAction);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param message \r\n\t * @param action \r\n\t */\r\n\tprivate openSnackBar(message: string, action: string)\r\n\t{\r\n\t\tlet config = new MatSnackBarConfig();\r\n\r\n\t\tconfig.verticalPosition\t\t= this.poVerticalPosition;\r\n\t\tconfig.horizontalPosition\t= this.poHorizontalPosition;\r\n\t\tconfig.duration\t\t\t\t= this.setAutoHide ? this.autoHide : 0;\r\n//\t\tconfig.extraClasses\t\t\t= this.addExtraClass ? ['exa_snack'] : undefined;\r\n\r\n\t\tthis.snackBar.open(message, action, config);\r\n\t}\r\n}\r\n","{{content}} \r\n{{content}} ","import { Component, OnInit, Input, OnChanges, DoCheck } from '@angular/core';\r\n\r\n@Component({\r\n\tselector: \t\t'app-date-user-friendly',\r\n\ttemplateUrl: \t'./date-user-friendly.component.html',\r\n\tstyleUrls: \t\t['./date-user-friendly.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class DateUserFriendlyComponent implements OnChanges, DoCheck\r\n{\r\n\r\n\t@Input() date:\t\tany;\r\n\t@Input() log:\t\tboolean = false;\r\n\t@Input() noFuture:\tboolean = false;\r\n\t\r\n\tpublic content:\t\tany;\r\n\tpublic dateClass:\tany;\r\n\tpublic fullDate:\tany;\r\n\t\r\n\tpublic noToolTip = false;\r\n\r\n\tconstructor() { this.content = ''; }\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnChanges()\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngDoCheck()\r\n\t{\r\n\t\tlet oDate;\r\n\r\n\t\tif (!this.date)\r\n\t\t{\r\n\t\t\tthis.content\t= 'Aucune';\r\n\t\t\tthis.dateClass\t= 'futur';\r\n\t\t\tthis.noToolTip\t= true;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tlet delta = Math.round((+Date.now() - this.date) / 1000);\r\n\r\n\t\t\tif (isNaN(delta ))\r\n\t\t\t{\r\n\t\t\t\tdelta = Math.round((+Date.now() - new Date(this.date).getTime()) / 1000);\r\n\t\t\t}\r\n\r\n\t\t\tlet daysName = ['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'];\r\n\r\n\t\t\tlet minute\t= 60,\r\n\t\t\t\thour\t= minute\t* 60,\r\n\t\t\t\tday\t\t= hour\t\t* 24,\r\n\t\t\t\tweek\t= day\t\t* 7,\r\n\t\t\t\tmonth\t= day\t\t* 30;\r\n\r\n\r\n\t\t\tthis.content = '';\r\n\r\n\t\t\tif (this.date instanceof Date)\r\n\t\t\t{\r\n\t\t\t\toDate = this.date;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\toDate = new Date(this.date);\r\n\t\t\t}\r\n\r\n\t\t\tthis.fullDate = oDate.toLocaleString();\r\n\r\n\t\t\tthis.dateClass = 'passe';\r\n\r\n\t\t\t\r\n\t\t\t// Futur\r\n\t\t\tif (delta < 0 && !this.noFuture)\r\n\t\t\t{\r\n\t\t\t\tthis.dateClass = 'futur';\r\n\r\n\t\t\t\tif (delta > -59)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.content = 'A l\\'instant.';\r\n\t\t\t\t}\r\n\t\t\t\telse if (delta > -minute)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.content = \"Dans \" + delta + ' secondes.';\r\n\t\t\t\t}\r\n\t\t\t\telse if (delta > -hour)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.content = \"Dans \" + (Math.round(delta / minute)) * -1 + ' minutes.';\r\n\t\t\t\t}\r\n\t\t\t\telse if (Math.floor(delta / -hour) == 1)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.content = 'Dans une heure'\r\n\t\t\t\t}\r\n\t\t\t\telse if (delta > -day)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.content = 'Dans ' + (Math.round(delta / hour)) * -1 + ' heures.';\r\n\t\t\t\t}\r\n//\t\t\t\telse if (delta > -(day * 2))\r\n//\t\t\t\t{\r\n//\t\t\t\t\tthis.content = 'Demain';\r\n//\t\t\t\t}\r\n\t\t\t\telse if (delta > -week)\r\n\t\t\t\t{\r\n\t\t\t\t\t// Hier\r\n\t\t\t\t\tlet dateNumber = oDate.getDay() - 1;\r\n\t\t\t\t\tif(dateNumber === -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdateNumber = 6;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tthis.content = daysName[dateNumber] + ' prochain';\r\n\t\t\t\t}\r\n\t\t\t\telse if (delta > -month)\r\n\t\t\t\t{\r\n\t\t\t\t\t// Moins d'une semaine => Todo mardi dernier\r\n\t\t\t\t\t// this.content = 'il y à moins d\\'une semaine';\r\n\t\t\t\t\tthis.content = 'Dans ' + (Math.round(delta / day))*-1 + ' jours';\r\n\t\t\t\t}\r\n\t\t\t\telse if (delta > (-month * 12))\r\n\t\t\t\t{\r\n\t\t\t\t\t// Moins de deux mois\r\n\t\t\t\t\tthis.content = 'Dans ' + Math.round(delta / month)*-1 + ' mois';\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t// au delà\r\n\t\t\t\t\tthis.content = 'Dans ' + Math.round(delta / month / 12)*-1 + ' an(s)';\r\n\t\t\t\t}\r\n\r\n\t\t\t} //Passé\r\n\t\t\telse if (delta < 59)\r\n\t\t\t{\r\n\t\t\t\t// Moins de 30 secondes\r\n\t\t\t\tthis.content = 'A l\\'instant.';\r\n\t\t\t}\r\n\t\t\telse if (delta < minute)\r\n\t\t\t{\r\n\t\t\t\t// Moins d1 minute\r\n\t\t\t\tthis.content = \"il y a \" + delta + ' secondes.';\r\n\t\t\t}\r\n\t\t\telse if (delta < 2 * minute)\r\n\t\t\t{\r\n\t\t\t\t// Moins de deux\r\n\t\t\t\tthis.content = 'il y a une minute.'\r\n\t\t\t}\r\n\t\t\telse if (delta < hour)\r\n\t\t\t{\r\n\t\t\t\t// Moins d 1 heure\r\n\t\t\t\tthis.content = \"il y a \" + Math.round(delta / minute) + ' minutes.';\r\n\t\t\t}\r\n\t\t\telse if (Math.round(delta / hour) == 1)\r\n\t\t\t{\r\n\t\t\t\t// une heure\r\n\t\t\t\tthis.content = 'il y a une heure'\r\n\t\t\t}\r\n\t\t\telse if (delta < day)\r\n\t\t\t{\r\n\t\t\t\t// x heures\r\n\t\t\t\tthis.content = 'il y a ' + Math.round(delta / hour) + ' heures.';\r\n\t\t\t}\r\n\t\t\telse if (delta < day * 2)\r\n\t\t\t{\r\n\t\t\t\t// Hier\r\n\t\t\t\tthis.content = 'Hier';\r\n\t\t\t}\r\n\t\t\telse if (delta < week)\r\n\t\t\t{\r\n\t\t\t\t// Hier\r\n\t\t\t\tlet dateNumber = oDate.getDay() - 1;\r\n\t\t\t\tif (dateNumber === -1)\r\n\t\t\t\t{\r\n\t\t\t\t\tdateNumber = 6;\r\n\t\t\t\t}\r\n\t\t\t\tthis.content = daysName[dateNumber] + ' dernier';\r\n\t\t\t}\r\n\t\t\telse if (delta < month)\r\n\t\t\t{\r\n\t\t\t\t// Moins d'une semaine => Todo mardi dernier\r\n\t\t\t\t// this.content = 'il y à moins d\\'une semaine';\r\n\t\t\t\tthis.content = 'Il y a ' + Math.round(delta / day) + ' jours1';\r\n\t\t\t}\r\n\t\t\telse if (delta > month && delta < month * 12)\r\n\t\t\t{\r\n\t\t\t\t// Moins de deux mois\r\n\t\t\t\tthis.content = 'Il y a ' + Math.round(delta / month) + ' mois';\r\n\t\t\t}\r\n\t\t\telse if (delta > month * 12 && delta < month * 2000 )\r\n\t\t\t{\r\n\t\t\t\t// au delà\r\n\t\t\t\tthis.content = 'Il y a ' + Math.round(delta / (month / 12)) + ' an(s)';\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.content\t= 'Aucune';\r\n\t\t\t\tthis.dateClass\t= 'futur';\r\n\t\t\t\tthis.noToolTip\t= true;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n","\r\n","import { Component, OnInit, DoCheck }\tfrom '@angular/core';\r\nimport { ViewEncapsulation }\tfrom '@angular/core';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\nimport { WorkspaceData }\t\t\t\tfrom '../../providers/workspace-data';\r\nimport { Router }\t\t\t\tfrom '@angular/router';\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'footer-component',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\ttemplateUrl:\t'./footer.component.html',\r\n\tstyleUrls:\t\t['./footer.component.scss']\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class FooterComponent implements OnInit, DoCheck\r\n{\r\n\tpublic showMenu:\t\tboolean\t= false;\r\n\tpublic isHomeSelected:\tboolean = false;\r\n\tpublic isWorkSelected:\tboolean = false;\r\n\tpublic isTaskSelected:\tboolean = false;\r\n\tpublic isComuSelected:\tboolean = false;\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(public userData: UserData,\r\n\t\t\t\tpublic router: Router,\r\n\t\t\t\tpublic workspaceData: WorkspaceData,\r\n\t\t\t\t)\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis.isHomeSelected = false;\r\n\t\tthis.isWorkSelected = false;\r\n\t\tthis.isTaskSelected = false;\r\n\t\tthis.isComuSelected = false;\r\n\r\n\t\t// ---------------------------------------\r\n\t\t//\r\n\t\t// ---------------------------------------\r\n\t\tswitch (this.router.url)\r\n\t\t{\r\n\t\t\tcase '/home':\r\n\t\t\t\tthis.isHomeSelected = true;\r\n\t\t\t\tbreak;\r\n\t\t\t\t\r\n\t\t\tcase '/workspace':\r\n\t\t\t\tthis.workspaceData.mbisWorkspaceLoading = false;\r\n\t\t\t\tthis.isWorkSelected = true;\r\n\t\t\t\tbreak;\r\n\t\t\t\t\r\n\t\t\tcase '/task':\r\n\t\t\t\tthis.isTaskSelected = true;\r\n\t\t\t\tbreak;\r\n\t\t\t\t\r\n\t\t\tcase '/community':\r\n\t\t\t\tthis.isComuSelected = true;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tngDoCheck()\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t//\r\n\t\t// ---------------------------------------\r\n\t\tswitch (this.router.url)\r\n\t\t{\r\n\t\t\tcase '/home':\r\n\t\t\t\tthis.isHomeSelected = true;\r\n\t\t\t\tthis.isWorkSelected = false;\r\n\t\t\t\tthis.isTaskSelected = false;\r\n\t\t\t\tthis.isComuSelected = false;\r\n\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase '/workspace':\r\n\t\t\t\tthis.isWorkSelected = true;\r\n\t\t\t\tthis.isHomeSelected = false;\r\n\t\t\t\tthis.isTaskSelected = false;\r\n\t\t\t\tthis.isComuSelected = false;\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase '/task':\r\n\t\t\t\tthis.isTaskSelected = true;\r\n\t\t\t\tthis.isHomeSelected = false;\r\n\t\t\t\tthis.isWorkSelected = false;\r\n\t\t\t\tthis.isComuSelected = false;\r\n\r\n\t\t\t\tbreak;\r\n\t\t\tcase '/community':\r\n\t\t\t\tthis.isComuSelected = true;\r\n\t\t\t\tthis.isHomeSelected = false;\r\n\t\t\t\tthis.isWorkSelected = false;\r\n\t\t\t\tthis.isTaskSelected = false;\r\n\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tthis.isHomeSelected = false;\r\n\t\t\t\tthis.isWorkSelected = false;\r\n\t\t\t\tthis.isTaskSelected = false;\r\n\t\t\t\tthis.isComuSelected = false;\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param psColor \r\n\t */\r\n\tpublic changeBackgroundColor(psColor: any)\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param psName \r\n\t */\r\n\tpublic changeSelected(psName: any)\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// En fonction on va ouvrir le bon formulaire\r\n\t\t// ---------------------------------------\r\n\t\tthis.isHomeSelected = false;\r\n\t\tthis.isWorkSelected = false;\r\n\t\tthis.isTaskSelected = false;\r\n\t\tthis.isComuSelected = false;\r\n\r\n\t\tswitch (psName)\r\n\t\t{\r\n\t\t\tcase 'home':\r\n\t\t\t\tthis.isHomeSelected = true;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'work':\r\n\t\t\t\tthis.isWorkSelected = true;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'task':\r\n\t\t\t\tthis.isTaskSelected = true;\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'comu':\r\n\t\t\t\tthis.isComuSelected = true;\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n","\r\n\t
\r\n\t
\r\n\t\t
\r\n\r\n\r\n\t\t\t
Tableau de bord \r\n\t\t\t\r\n\r\n\r\n\t\t\t\r\n\t\t\r\n\r\n\t\t
\r\n\t\t\t
\r\n\t\t\t\t
0\" >\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t {{ 'home.tasksToValidate' | translate }} ( {{ workspaceData.geTaskHomeAdminToValidLenght() }} )\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t \r\n\t\t\t\t\t \r\n\r\n\t\t\t\t
\r\n\r\n\t\t\t\t
0\" >\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t{{ 'home.tasksEndDate' | translate }} ( {{ workspaceData.getTaskHomeExpiredLength() }} )\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t \r\n\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t \r\n\t\t\t\t\t \r\n\t\t\t\t
\r\n\r\n\r\n\t\t\t
\r\n\t\t\t
0\">\r\n\t\t\t\t
\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t{{ 'home.assignedTasks' | translate }} ( {{ this.workspaceData.getTaskHomeMineLength() }} )\r\n\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t \r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t \r\n\t\t\t\t \r\n\r\n\t\t\t
\r\n\r\n\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
{{ 'home.emptyActivityMessage' | translate }} \r\n\r\n\t\t\t\t\t
Espace de travail \r\n\t\t\t\t
\r\n\t\t\t
\r\n\r\n\t\t\t
\r\n\r\n\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
{{ 'home.emtyToDoListMessage' | translate }} \r\n\t\t\t\t
\r\n\t\t\t
\r\n\r\n\t\t\t
0\">\r\n\r\n\r\n\r\n\r\n\t\t\t\t
\r\n\t\t\t\t\t\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t{{ 'home.epreuvesTitle' | translate }} ( {{ workspaceData.epreuveHomeAdmin.length }} )\r\n\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\r\n\r\n\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t \r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t\t
0\">
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t\t
0\">
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t\t
0\">
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t
\r\n\t\t
\r\n\t
\r\n\t\r\n
\r\n
\r\n","import { Component, OnInit, OnDestroy, AfterViewInit }\tfrom '@angular/core';\r\n\r\nimport { ViewEncapsulation }\tfrom '@angular/core';\r\nimport { Router }\t\t\t\tfrom '@angular/router';\r\nimport { ChatData }\t\t\t\tfrom '../../providers/chat-data';\r\nimport { SavedData }\t\t\tfrom '../../providers/saved-data';\r\nimport { TaskData }\t\t\t\tfrom '../../providers/task-data';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\nimport { WorkspaceData } from '../../providers/workspace-data';\r\nimport { AppComponent }\t\t\tfrom '../../app.component';\r\nimport { SocketService }\t\tfrom '../../services/socket.service';\r\nimport { StatisticsService }\tfrom '../../services/statistics.service';\r\nimport { Task }\t\t\t\t\tfrom '../../classes/task.class';\r\n\r\nimport { ISocketData, SocketWhat }\t\t\t\tfrom '../../models/message.model';\r\n\r\nimport { startOfDay, endOfDay, subDays, addDays, endOfMonth, isSameDay, isSameMonth, addHours } from 'date-fns';\r\n\r\nimport * as _ from 'underscore';\r\n//import Quill from 'quill';\r\n// add image resize module\r\n// add mention module\r\n\r\n\r\nconst colors: any =\r\n\t{\r\n\t\tred:\r\n\t\t{\r\n\t\t\tprimary:\t'#ad2121',\r\n\t\t\tsecondary:\t'#FAE3E3'\r\n\t\t},\r\n\t\tblue:\r\n\t\t{\r\n\t\t\tprimary:\t'#1e90ff',\r\n\t\t\tsecondary:\t'#D1E8FF'\r\n\t\t},\r\n\t\tyellow:\r\n\t\t{\r\n\t\t\tprimary:\t'#e3bc08',\r\n\t\t\tsecondary:\t'#FDF1BA'\r\n\t\t}\r\n\t};\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'page-home',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\tstyleUrls:\t\t['./home.component.scss'],\r\n\ttemplateUrl:\t'home.component.html'\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class HomeComponent implements OnInit, AfterViewInit, OnDestroy\r\n{\r\n\r\n\tpublic localState:\t\t\t\tany;\r\n\tpublic title:\t\t\t\t\tany;\r\n\tpublic someUrl:\t\t\t\t\tstring\t= \"assets/img/marcel.png\";\r\n\tpublic name:\t\t\t\t\tstring\t= 'user';\r\n\tpublic ckeditorContent:\t\t\tstring = 'test';\r\n\tpublic canAccessChat:\t\t\tboolean = true;\r\n\tpublic haveTask:\t\t\t\tboolean = false;\r\n\tpublic haveTaskAdminExp:\t\tboolean = false;\r\n\tpublic haveTaskAdminValidate:\tboolean = false;\r\n\tpublic haveChatData:\t\t\tboolean = false;\r\n\tpublic haveEpreuve:\t\t\t\tboolean = false;\r\n\tpublic canAccessForum:\t\t\tboolean = false;\r\n\tpublic canAccessNotification:\tboolean = false;\r\n\tpublic viewDate\t\t\t\t\t\t\t= subDays(startOfDay(new Date()), 1);\r\n//\tpublic locale\t\t\t\t\t\t\t= 'fr';\r\n\tpublic tooltipAppendToBody\t\t\t\t= false;\r\n\tpublic socket:\t\t\t\t\tany;\r\n\tpublic data:\t\t\t\t\tany;\r\n\r\n\tpublic color\t\t\t= 'secondary';\r\n\tpublic isRoomSetting\t= false;\r\n\r\n\tpublic events = [\r\n\t\t{\r\n\t\t\tstart:\t\tsubDays(startOfDay(new Date()), 1),\r\n\t\t\tend:\t\taddDays(new Date(), 1),\r\n\t\t\ttitle:\t\t'A 3 day event',\r\n\t\t\tcolor:\t\tcolors.red,\r\n\t\t\tactions:\tthis.test()\r\n\t\t},\r\n\t\t{\r\n\t\t\tstart:\t\tstartOfDay(new Date()),\r\n\t\t\ttitle:\t\t'An event with no end date',\r\n\t\t\tcolor:\t\tcolors.yellow,\r\n\t\t\tactions:\tthis.test()\r\n\t\t},\r\n\t\t{\r\n\t\t\tstart:\t\tsubDays(endOfMonth(new Date()), 3),\r\n\t\t\tend:\t\taddDays(endOfMonth(new Date()), 3),\r\n\t\t\ttitle:\t\t'A long event that spans 2 months',\r\n\t\t\tcolor:\t\tcolors.blue\r\n\t\t},\r\n\t\t{\r\n\t\t\tstart:\t\taddHours(startOfDay(new Date()), 2),\r\n\t\t\tend:\t\tnew Date(),\r\n\t\t\ttitle:\t\t'A draggable and resizable event',\r\n\t\t\tcolor:\t\tcolors.yellow,\r\n\t\t\tactions:\tthis.test(),\r\n\t\t\tresizable:\r\n\t\t\t{\r\n\t\t\t\tbeforeStart:\ttrue,\r\n\t\t\t\tafterEnd:\t\ttrue\r\n\t\t\t},\r\n\t\t\tdraggable: true\r\n\t\t}\r\n\t];\r\n\r\n\tpublic moAdminTasks:\tany\t\t= [];\r\n\tpublic moTasks:\t\t\tany\t\t= [];\r\n\tpublic maRooms:\t\t\tany\t\t= [];\r\n\tpublic maHomeRooms:\t\tany\t\t= [];\r\n\tpublic showTask\t\t\t\t\t= true;\r\n\tpublic showAdminTask\t\t\t= true;\r\n\tpublic listner:\t\t\tany;\r\n\r\n\r\n /**\r\n * Creates an instance of HomePage.\r\n *\r\n * @param {NavController} navCtrl\r\n * @param {TranslateService} translate\r\n *\r\n * @memberOf HomePage\r\n */\r\n\tconstructor(\r\n\t\tpublic\tchatData:\t\t\tChatData,\r\n\t\tpublic\tappComponent:\t\tAppComponent,\r\n\t\tpublic\tuserData:\t\t\tUserData,\r\n\t\tpublic\tsavedData:\t\t\tSavedData,\r\n\t\tpublic workspaceData:\t\tWorkspaceData,\r\n\t\tpublic\tsocketService:\t\tSocketService,\r\n\t\tpublic \tstatisticsService:\tStatisticsService,\r\n\t\tpublic\trouter:\t\t\t\tRouter)\r\n\t{\r\n\t\t// Affectation du titre de la page\r\n\t\tappComponent.setPageTitle('Accueil');\r\n\r\n\t\tif (this.userData.canAccessNotification === true)\r\n\t\t{\r\n\t\t\tthis.canAccessNotification = true;\r\n\t\t}\r\n\r\n\t\tthis.data \t\t= {};\r\n\t\tthis.listner \t= appComponent.homeInfosEmitter.subscribe((value: any) => this.switchEmitterValue(value),\r\n\t\t\t\t\t\t\t\t\t\t\t(error: any) => console.log(error),\r\n\t\t\t\t\t\t\t\t\t\t\t() => console.log('done'));\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Récupération de la liste des rooms dispo\r\n\t\t// ---------------------------------------\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic test()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param value\r\n\t */\r\n\tpublic switchEmitterValue(value: any)\r\n\t{\r\n\t\t\tswitch (value)\r\n\t\t{\r\n\t\t\tcase 'homeRoomsOk':\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'homeTasksOk':\r\n\t\t\t\tthis.getHomeTask();\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'homeEpreuveOk':\r\n\t\t\t\tthis.haveEpreuveAdmin();\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic getHomeRooms()\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic getHomeTask()\r\n\t{\r\n\t\tthis.haveTaskData();\r\n\t\tthis.haveTaskDataAdmin();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Clic permettant d'accéder directement à l'interface d'une épreuve\r\n\t * @param epreuve\r\n\t */\r\n\tgoToEpreuve(epreuve: any)\r\n\t{\r\n\t\t//On selectionne les noeuds parents par leurs identifiants\r\n\t\tif (epreuve.parents)\r\n\t\t{\r\n\t\t\tif (epreuve.id)\r\n\t\t\t{\r\n\t\t\t\tthis.workspaceData.selectedMatiere\t= this.workspaceData.getEpreuve(epreuve.id);\r\n\t\t\t}\r\n\t\t\tthis.workspaceData.selectedItems = [];\r\n\r\n\t\t\tfor (let parent of epreuve.parents)\r\n\t\t\t{\r\n\t\t\t\tif (parent.startsWith('*'))\r\n\t\t\t\t{\r\n\t\t\t\t\tlet arrayValue\t= parent.split('::');\r\n\t\t\t\t\tlet key\t\t\t= arrayValue[0];\r\n\t\t\t\t\tlet valueTag\t= arrayValue[1];\r\n\r\n\t\t\t\t\tswitch (key)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcase '*etab':\r\n\t\t\t\t\t\t\tthis.workspaceData.selectedEtablissement\t= this.workspaceData.getEtablissement(valueTag);\r\n\t\t\t\t\t\t\tthis.workspaceData.selectedItems[0]\t\t\t= valueTag;\r\n\r\n\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\tcase '*sess':\r\n\t\t\t\t\t\t\tthis.workspaceData.selectedSession \t= this.workspaceData.getSession(valueTag);\r\n\t\t\t\t\t\t\tthis.workspaceData.selectedItems[1] = valueTag;\r\n\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\tcase '*exam':\r\n\t\t\t\t\t\t\tthis.workspaceData.selectedExamen \t= this.workspaceData.getExamen(valueTag);\r\n\t\t\t\t\t\t\tthis.workspaceData.selectedItems[2] = valueTag;\r\n\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.workspaceData.selectedSujet \t= null;\r\n\r\n\t\t\t\t\tthis.workspaceData.selectedItems[3] = this.workspaceData.selectedMatiere.id;\r\n\t\t\t\t\tthis.workspaceData.selectedSegment\t= 'all';\r\n\t\t\t\t\tthis.savedData.lastGroup \t\t\t= 'epreuve';\r\n\r\n\t\t\t\t\tthis.router.navigate(['/workspace']);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param task\r\n\t */\r\n\tpublic goToSubject(task: Task)\r\n\t{\r\n\t\tlet canAccessTask = this.canAccessTask(task);\r\n\r\n\t\tif (canAccessTask === true)\r\n\t\t{\r\n\t\t\t// ===================================\r\n\t\t\t// Affectation des objets\r\n\t\t\t// ===================================\r\n\t\t\tthis.workspaceData.selectedSujet\t\t\t= this.workspaceData.getSujet(task.idSujet);\r\n\t\t\tthis.workspaceData.selectedMatiere\t\t\t= this.workspaceData.getEpreuve(task.idEpreuve);\r\n\t\t\tthis.workspaceData.selectedExamen\t\t\t= this.workspaceData.getExamen(task.idExamen);\r\n\t\t\tthis.workspaceData.selectedSession\t\t\t= this.workspaceData.getSession(task.idSession);\r\n\t\t\tthis.workspaceData.selectedEtablissement\t= this.workspaceData.getEtablissement(task.idEtablissement);;\r\n\r\n\t\t\tthis.workspaceData.selectedItems = [];\r\n\t\t\tif (this.workspaceData.selectedEtablissement)\r\n\t\t\t{\r\n\t\t\t\tthis.workspaceData.selectedItems[0] = this.workspaceData.selectedEtablissement.id;\r\n\t\t\t}\r\n\t\t\tif (this.workspaceData.selectedSession)\r\n\t\t\t{\r\n\t\t\t\tthis.workspaceData.selectedItems[1] = this.workspaceData.selectedSession.id;\r\n\t\t\t}\r\n\t\t\tif (this.workspaceData.selectedExamen)\r\n\t\t\t{\r\n\t\t\t\tthis.workspaceData.selectedItems[2] = this.workspaceData.selectedExamen.id;\r\n\t\t\t}\r\n\t\t\tif (this.workspaceData.selectedMatiere)\r\n\t\t\t{\r\n\t\t\t\tthis.workspaceData.selectedItems[3] = this.workspaceData.selectedMatiere.id;\r\n\t\t\t}\r\n\r\n\t\t\tthis.workspaceData.selectedTask\t\t= task;\r\n\t\t\tthis.workspaceData.selectedSegment\t= 'all';\r\n\t\t\tthis.workspaceData.goToSubject\t\t= true;\r\n\t\t\tthis.savedData.lastGroup\t\t\t= 'task';\r\n\r\n\r\n\t\t\tif (this.userData.isAdmin() || this.userData.isSuperviseur() === true)\r\n\t\t\t{\r\n\t\t\t\tthis.savedData.lastGroup = 'epreuve';\r\n\t\t\t}\r\n\t\t\tthis.router.navigate(['/workspace']);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.goToSubject\t\t= false;\r\n\t\t\tthis.router.navigate(['/workspace']);\r\n\t\t}\r\n \t}\r\n\r\n\r\n\t /**\r\n\t *\r\n\t * @param task\r\n\t */\r\n\tpublic canAccessTask(task: Task)\r\n\t{\r\n\t\tlet result = true;\r\n\r\n\t\tif ((this.userData.isAdmin() === false && this.userData.isSuperviseur() === false) && task.state === 'done')\r\n\t\t{\r\n\t\t\tresult = false;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic haveTaskData()\r\n\t{\r\n\t\tlet tasks \t= this.workspaceData.taskHomeMine;\r\n\t\tlet nNumber = 0;\r\n\t\tlet bReturn = false;\r\n\r\n\t\tfor (let task in tasks)\r\n\t\t{\r\n\t\t\tnNumber++;\r\n\t\t}\r\n\r\n\t\tif (tasks && nNumber > 0)\r\n\t\t{\r\n\t\t\tthis.haveTask \t= true;\r\n\t\t\tbReturn \t\t= true;\r\n\t\t}\r\n\r\n\t\treturn bReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic haveTaskDataAdmin()\r\n\t{\r\n\t\tlet adminTasks\t\t\t= this.workspaceData.taskHomeAdmin;\r\n\t\tlet adminTasksExpired\t= this.workspaceData.taskHomeAdminExpired;\r\n\t\tlet nNumber\t\t\t\t= 0;\r\n\t\tlet nNumberExp\t\t\t= 0;\r\n\r\n\t\tfor (let task of adminTasks)\r\n\t\t{\r\n\t\t\tif (task.state === 'review')\r\n\t\t\t{\r\n\t\t\t\tnNumber++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (adminTasks && nNumber > 0)\r\n\t\t{\r\n\t\t\tthis.haveTaskAdminValidate = true;\r\n\t\t}\r\n\r\n\t\tfor (let task of adminTasksExpired)\r\n\t\t{\r\n\t\t\tnNumberExp++;\r\n\t\t}\r\n\r\n\t\tif (adminTasksExpired && nNumberExp > 0)\r\n\t\t{\r\n\t\t\tthis.haveTaskAdminExp = true;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic haveEpreuveAdmin()\r\n\t{\r\n\t\tlet epreuves\t= this.workspaceData.epreuveHomeAdmin;\r\n\t\tlet nNumber\t\t= 0;\r\n\r\n\t\tfor (let epreuve of epreuves)\r\n\t\t{\r\n\t\t\tnNumber++;\r\n\t\t}\r\n\r\n\t\tif (epreuves && nNumber > 0)\r\n\t\t{\r\n\t\t\tthis.haveEpreuve = true;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param element\r\n\t */\r\n\tpublic clickDateEvent(element: any)\r\n\t{\r\n\t\tif (element && element instanceof Task)\r\n\t\t{\r\n\t\t\tthis.goToSubject(element);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param event\r\n\t */\r\n\tpublic keyupHandlerFunction(event: any)\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @memberOf HomePage\r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis.getHomeRooms();\r\n\t\tthis.getHomeTask();\r\n\r\n\t\tthis.workspaceData.resetSelectedHomeEtablissement();\r\n\t\tthis.workspaceData.resetSelectedHomeSession();\r\n\t\tthis.workspaceData.resetSelectedHomeExamen();\r\n\t\tthis.workspaceData.resetSelectedHomeMatiere();\r\n\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngAfterViewInit()\r\n\t{\r\n\t\tthis.statisticsService.getEpreuveStats(null, 160);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngOnDestroy()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedEtablissement(event: any)\r\n\t{\r\n\r\n\t\tthis.workspaceData.selectedHomeEtablissement = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\t\t\tthis.workspaceData.resetSelectedHomeSession();\r\n\t\t\tthis.workspaceData.resetSelectedHomeExamen();\r\n\t\t\tthis.workspaceData.resetSelectedHomeMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.resetSelectedHomeEtablissement();\r\n\t\t\tthis.workspaceData.resetSelectedHomeSession();\r\n\t\t\tthis.workspaceData.resetSelectedHomeExamen();\r\n\t\t\tthis.workspaceData.resetSelectedHomeMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t\t}\r\n\r\n\t\tthis.workspaceData.filterHomeTasks('etab', id);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedSession(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedHomeSession = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\r\n\t\t\tthis.workspaceData.resetSelectedHomeExamen();\r\n\t\t\tthis.workspaceData.resetSelectedHomeMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.resetSelectedHomeSession();\r\n\t\t\tthis.workspaceData.resetSelectedHomeExamen();\r\n\t\t\tthis.workspaceData.resetSelectedHomeMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t\t}\r\n\t\tthis.workspaceData.filterHomeTasks('sess', id);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedExamen(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedHomeExamen = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\t\t\tthis.workspaceData.resetSelectedHomeMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\r\n\t\t\tthis.workspaceData.resetSelectedHomeExamen();\r\n\t\t\tthis.workspaceData.resetSelectedHomeMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t\t}\r\n\r\n\t\tthis.workspaceData.filterHomeTasks('exam', id);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedMatiere(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedHomeMatiere = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\t\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.resetSelectedHomeMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedHomeSujet();\r\n\t\t}\r\n\r\n\t\tthis.workspaceData.filterHomeTasks('matiere', id);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedSujet(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedHomeSujet = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.selectedHomeSujet = null;\r\n\t\t}\r\n\r\n\t\tthis.workspaceData.filterHomeTasks('suj', id);\r\n\t}\r\n}\r\n","\r\n\t\r\n\r\n\t
\r\n\t\t
\r\n\t\t\t
\t\t
\r\n\t\t\t
\r\n\t\t\t
{{errorMessage}}
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\t\r\n\t\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t
\r\n\t\t\t\r\n\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t
\r\n\t
\r\n
\r\n","import { Component, OnDestroy, ViewEncapsulation, OnInit, AfterViewInit }\tfrom '@angular/core';\r\nimport { ActivatedRoute, Router }\t\t\t\t\t\t\t\t\t\t\tfrom '@angular/router';\r\n\r\nimport { UserData }\t\t\tfrom '../../providers/user-data';\r\nimport { SavedData }\t\tfrom '../../providers/saved-data';\r\nimport { WorkspaceData }\tfrom '../../providers/workspace-data';\r\nimport { AuthService }\t\tfrom '../../services/auth.service';\r\nimport { SocketService }\tfrom '../../services/socket.service';\r\nimport { UserService }\t\tfrom '../../services/user.service';\r\n\r\nimport { ForgetPasswordModalComponent }\t\t\tfrom '../../modal/forgetPassword/forgetPasswordModal.component';\r\nimport { InfosForgetPasswordModalComponent }\tfrom '../../modal/forgetPassword/infosForgetPasswordModal.component';\r\nimport { ResetPasswordModalComponent }\t\t\tfrom '../../modal/resetPassword/resetPasswordModal.component';\r\n\r\nimport { AppComponent }\t\tfrom '../../app.component';\r\nimport { SCClientSocket }\tfrom 'socketcluster-client';\r\nimport { MatDialog }\t\tfrom '@angular/material';\r\n\r\nimport * as htmlEncode from 'js-htmlencode';\r\n\r\ndeclare var Fingerprint2: any;\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'login-component',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\tstyleUrls:\t\t['./login.component.scss'],\r\n\ttemplateUrl:\t'login.component.html'\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class LoginComponent implements OnInit, OnDestroy, AfterViewInit\r\n{\r\n\tpublic username:\t\tstring = '';\r\n\tpublic password:\t\tstring = '';\r\n\tpublic color:\t\t\tstring\t= 'primary';\r\n\tpublic checked:\t\t\tboolean = false;\r\n\tpublic disabled:\t\tboolean = false;\r\n\tpublic isError:\t\t\tboolean = false;\r\n\tpublic isLoading:\t\tboolean = false;\r\n\tpublic errorMessage:\tstring\t= 'Vos identifiants sont incorrects';\r\n\tpublic dialogRef:\t\tany\t\t= null;\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(\r\n\t\tpublic authService:\t\tAuthService,\r\n\t\tpublic userData:\t\tUserData,\r\n\t\tpublic savedData:\t\tSavedData,\r\n\t\tpublic workspaceData:\tWorkspaceData,\r\n\t\tpublic socketService:\tSocketService,\r\n\t\tpublic userService:\t\tUserService,\r\n\t\tpublic dialog:\t\t\tMatDialog,\r\n\t\tpublic activatedRoute:\tActivatedRoute,\r\n\t\tpublic router:\t\t\tRouter,\r\n\t\tpublic appComponent:\tAppComponent)\r\n {\r\n\t\tappComponent.setPageTitle('Connexion');\r\n\r\n\t\tthis.socketService.on('error', this._handleError.bind(this));\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngAfterViewInit()\r\n\t{\r\n\t\t// On analyse l'url pour le cas d'une réinitialisation de mot de passe\r\n\t\tif (window && window.location && window.location.search)\r\n\t\t{\r\n\t\t\tconst elements = window.location.search.split('?');\r\n\r\n\t\t\tif (elements.length === 2)\r\n\t\t\t{\r\n\t\t\t\tconst strElement = elements[1].split('=');\r\n\t\t\t\tif (strElement.length === 2)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst key\t= strElement[0];\r\n\t\t\t\t\tconst value = strElement[1];\r\n\r\n\t\t\t\t\tif (key === 'resetPassCode' && value)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// On vérifie la validité du code de réinitialisation\r\n\t\t\t\t\t\tsetTimeout(() =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.userService.checkCodePasswordReset(value).then(res =>\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\tif (res && res.result && res.result.codeValid === true)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t// si le code de réinitialisation est valide\r\n\t\t\t\t\t\t\t\t\t// mais qu'il est périmé on affiche une pop up\r\n\t\t\t\t\t\t\t\t\t// d'information\r\n\t\t\t\t\t\t\t\t\tif (res.result.dateValid === false && res.result.mailUser === undefined && res.result.compte === undefined)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tthis.dialog.open(InfosForgetPasswordModalComponent,\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\theight:\t\t\t'30%',\r\n\t\t\t\t\t\t\t\t\t\t\t\twidth:\t\t\t'60%',\r\n\t\t\t\t\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\t\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\t\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tusermail:\t'error',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype:\t\t'errorOutOfDateLink'\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t// Si le code n'est pas périmé alors on affiche la pop up de saisie\r\n\t\t\t\t\t\t\t\t\t\t// du nouveau mot de passe\r\n\t\t\t\t\t\t\t\t\t\tconst dialogRefPasswordReset = this.dialog.open(ResetPasswordModalComponent,\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\theight:\t\t\t'50%',\r\n\t\t\t\t\t\t\t\t\t\t\t\twidth:\t\t\t'60%',\r\n\t\t\t\t\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype:\t\t'resetWithCode',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tresetCode:\tres.codeReset,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tcompteUser: res.result.compte,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tmailUser:\tres.result.mailUser\r\n\t\t\t\t\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t\t\t\t\tdisableClose: true\r\n\t\t\t\t\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t\t\t\t// A la fermeture de la box\r\n\t\t\t\t\t\t\t\t\t\tdialogRefPasswordReset.afterClosed().subscribe((resultReset: any) =>\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tif (resultReset && resultReset === true)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tthis.dialog.open(InfosForgetPasswordModalComponent,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\theight:\t\t\t'30%',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\twidth:\t\t\t'60%',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tusermail:\t'error',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\ttype:\t\t'confirmPasswordUpdated'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (res && res.result && res.result.codeValid === false)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tthis.dialog.open(InfosForgetPasswordModalComponent,\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\theight:\t\t\t'30%',\r\n\t\t\t\t\t\t\t\t\t\t\t\twidth:\t\t\t'60%',\r\n\t\t\t\t\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\t\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\t\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tusermail:\t'error',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\ttype:\t\t'errorInvalidLink'\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}).catch(err =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t}, 1000);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngOnDestroy()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic onFocus()\r\n\t{\r\n\t\tthis.isError = false;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param event\r\n\t */\r\n\tpublic onKeyUp(event: any)\r\n\t{\r\n\t\tthis.username = this.username.toLowerCase();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic login()\r\n\t{\r\n\t\tthis.userData.setStateApplication('application', 'pending');\r\n\t\tlet fResult: any;\r\n\r\n\t\tlet options =\r\n\t\t\t{\r\n\t\t\t\tuserDefinedFonts:\t\t\t\t\t[''],\r\n\t\t\t\texcludeUserAgent :\t\t\t\t\ttrue,\r\n\t\t\t\texcludeLanguage:\t\t\t\t\tfalse,\r\n\t\t\t\texcludeColorDepth:\t\t\t\t\tfalse,\r\n\t\t\t\texcludeAvailableScreenResolution:\tfalse,\r\n\t\t\t\texcludeTimezoneOffset:\t\t\t\tfalse,\r\n\t\t\t\texcludeIndexedDB:\t\t\t\t\tfalse,\r\n\t\t\t\texcludeDeviceMemory:\t\t\t\tfalse,\r\n\t\t\t\texcludeOpenDatabase:\t\t\t\tfalse,\r\n\t\t\t\texcludeCpuClass:\t\t\t\t\tfalse,\r\n\t\t\t\texcludePlatform:\t\t\t\t\tfalse,\r\n\t\t\t\texcludeHardwareConcurrency:\t\t\tfalse,\r\n\t\t\t\texcludeCanvas:\t\t\t\t\t\tfalse,\r\n\t\t\t\texcludeTouchSupport:\t\t\t\tfalse,\r\n\t\t\t\texcludeHasLiedLanguages:\t\t\tfalse,\r\n\t\t\t\texcludeHasLiedResolution:\t\t\tfalse,\r\n\t\t\t\texcludeHasLiedOs:\t\t\t\t\tfalse,\r\n\t\t\t\texcludeHasLiedBrowser:\t\t\t\tfalse,\r\n\t\t\t\texcludeAdBlock:\t\t\t\t\t\ttrue,\r\n\t\t\t\texcludeSessionStorage:\t\t\t\ttrue,\r\n\t\t\t\texcludeWebGL:\t\t\t\t\t\ttrue,\r\n\t\t\t\texcludeAddBehavior:\t\t\t\t\ttrue,\r\n\t\t\t\texcludeJsFonts:\t\t\t\t\t\ttrue,\r\n\t\t\t\texcludeFlashFonts:\t\t\t\t\ttrue,\r\n\t\t\t\texcludePlugins:\t\t\t\t\t\ttrue,\r\n\t\t\t\texcludeIEPlugins:\t\t\t\t\ttrue,\r\n\t\t\t\texcludeDoNotTrack:\t\t\t\t\ttrue,\r\n\t\t\t\texcludePixelRatio:\t\t\t\t\ttrue,\r\n\t\t\t\texcludeScreenResolution:\t\t\ttrue,\r\n\t\t\t\texcludeWebGLVendorAndRenderer:\t\ttrue,\r\n\t\t\t};\r\n\r\n\t\t// test fingerprint pr le moment\r\n\t\tnew Fingerprint2(options).get((result: any, components: any) =>\r\n\t\t{\r\n\t\t\t// this will use all available fingerprinting sources\r\n\t\t\tfResult = result;\r\n\r\n\t\t\t// components is an array of all fingerprinting components used\r\n\t\t\tthis.isLoading = true;\r\n\r\n\t\t\tthis.username = htmlEncode.htmlEncode(this.username);\r\n\t\t\tthis.password = htmlEncode.htmlEncode(this.password);\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// ToComment\r\n\t\t\t// ---------------------------------------\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (!socket || !socket.state || socket.state !== SCClientSocket.OPEN)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.authService.doLogin(this.username, this.password, fResult)\r\n\t\t\t\t\t.subscribe(res =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\tlet body = JSON.parse(res.text());\r\n\r\n\t\t\t\t\t\tlet mailUnique = body.data.user.email;\r\n\t\t\t\t\t\tif (body.err === false && body.data && body.data.token)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// this.nav.setRoot(TabsPage);\r\n\t\t\t\t\t\t\tthis.userData.setFingerPrint(fResult);\r\n\r\n\t\t\t\t\t\t\tthis.isLoading\t\t= false;\r\n\t\t\t\t\t\t\tthis.isError\t\t= false;\r\n\r\n\t\t\t\t\t\t\tthis.userData.login(this.username, body.data.token, mailUnique);\r\n\t\t\t\t\t\t\t//this.router.navigate(['/home']);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}, (err) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t// ToComment\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\tif (socket.authState === SCClientSocket.AUTHENTICATED && this.userData.hasLoggedIn() === true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.userData.setTokenKey(socket.signedAuthToken);\r\n\r\n\t\t\t\t\t\tthis.userData.mustReset\t\t\t\t= false;\r\n\t\t\t\t\t\tthis.userData.otpAuth\t\t\t\t= false;\r\n\t\t\t\t\t\tthis.userData.mustValidateBrowser\t= false;\r\n\r\n\t\t\t\t\t\tthis.isLoading\t= false;\r\n\t\t\t\t\t\tthis.isError\t= false;\r\n\r\n\t\t\t\t\t\tthis.userData.setStateApplication('application', 'online');\r\n\t\t\t\t\t\tthis.userService.checkFingerPrintUser();\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\tlet credentials =\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tusername:\t\tthis.username,\r\n\t\t\t\t\t\t\t\tpassword:\t\tthis.password,\r\n\t\t\t\t\t\t\t\tfingerprint:\tfResult\r\n\t\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\tsocket.emit('login', credentials, (err: any, datas: any) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.userData.setAccountInfo(datas);\r\n\t\t\t\t\t\t\tthis.isLoading = false;\r\n\r\n\t\t\t\t\t\t\tif (datas.logged && datas.logged === true)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tthis.isError = false;\r\n\r\n\t\t\t\t\t\t\t\tif (datas && datas.infosUser)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tthis.userData.setCurrentUser(datas.infosUser);\r\n\r\n\t\t\t\t\t\t\t\t\t/**\r\n\t\t\t\t\t\t\t\t\t * Par défault on initialise les noeuds ouverts précédements\r\n\t\t\t\t\t\t\t\t\t * avec ceux enregistrés dans le localstorage\r\n\t\t\t\t\t\t\t\t\t */\r\n\r\n\t\t\t\t\t\t\t\t\tthis.workspaceData.selectedItems = this.savedData.openedNodes;\r\n\r\n\t\t\t\t\t\t\t\t\tif (datas.infosUser.prefs)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlet preferences = datas.infosUser.prefs;\r\n\r\n\t\t\t\t\t\t\t\t\t\tif (preferences.paramLogiciels)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tfor (let key in preferences.paramLogiciels)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tif (preferences.paramLogiciels[key])\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tswitch (key)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase 'worspaceTaskChecked':\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tlet workspaceChecked = preferences.paramLogiciels[key] === true || preferences.paramLogiciels[key] === 'true';\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.savedData.isWorkspaceTaskChecked = workspaceChecked;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\tif (preferences.lastGroup)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tthis.savedData.lastGroup = preferences.lastGroup;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\tif (preferences.selectedNodes && this.savedData.openedNodes === null)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tlet selectedNodes;\r\n\t\t\t\t\t\t\t\t\t\t\tif (typeof preferences.selectedNodes === 'string')\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tselectedNodes = JSON.parse(preferences.selectedNodes);\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tselectedNodes = typeof preferences.selectedNodes;\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t/**\r\n\t\t\t\t\t\t\t\t\t\t\t * S'il n'y a pas de noeud enregistré dans le localstorage, on les initialise\r\n\t\t\t\t\t\t\t\t\t\t\t * avec ceux enregistrés en base de données\r\n\t\t\t\t\t\t\t\t\t\t\t */\r\n\t\t\t\t\t\t\t\t\t\t\tif (!this.workspaceData.selectedItems || this.workspaceData.selectedItems.length === 0)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tif (selectedNodes && selectedNodes.length > 0)\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis.workspaceData.selectedItems = [];\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tfor (let index = 0; index < selectedNodes.length; index++)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tif (selectedNodes[index])\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tswitch(index)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase 0:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.savedData.lastEtablissementId = selectedNodes[index];\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.workspaceData.selectedItems.push(selectedNodes[index]);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase 1:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.savedData.lastSessionId = selectedNodes[index];\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.workspaceData.selectedItems.push(selectedNodes[index]);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase 2:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.savedData.lastExamenId = selectedNodes[index];\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.workspaceData.selectedItems.push(selectedNodes[index]);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcase 3:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.savedData.lastDisciplineId = selectedNodes[index];\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthis.workspaceData.selectedItems.push(selectedNodes[index]);\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tthis.isError = true;\r\n\r\n\t\t\t\t\t\t\t\tif (err.includes('#LG001') === true) // s'il s'agit d'une erreur d'identification\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t// On affiche un message adapté\r\n\t\t\t\t\t\t\t\t\terr = 'Votre identifiant ou votre mot de passe est incorrect';\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tlet messageError\t= err || 'Erreur de connexion';\r\n\t\t\t\t\t\t\t\tthis.errorMessage\t= messageError;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic launchResetPassword()\r\n\t{\r\n\t\tconst dialogRef = this.dialog.open(ForgetPasswordModalComponent,\r\n\t\t\t{\r\n\t\t\t\theight:\t\t\t'40%',\r\n\t\t\t\twidth:\t\t\t'40%',\r\n\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\tdata:\r\n\t\t\t\t{}\r\n\t\t\t});\r\n\r\n\t\tdialogRef.afterClosed().subscribe((result: any) =>\r\n\t\t{\r\n\t\t\tif (result !== undefined)\r\n\t\t\t{\r\n\t\t\t\tthis.dialog.open(InfosForgetPasswordModalComponent,\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\theight:\t\t\t'30%',\r\n\t\t\t\t\t\twidth:\t\t\t'60%',\r\n\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tusermail:\t result,\r\n\t\t\t\t\t\t\ttype:\t\t'confirmForget'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t// Handle keypress event, for sending chat message\r\n\tpublic eventHandler(event: KeyboardEvent): void\r\n\t{\r\n\t\tif (event.key === \"Enter\")\r\n\t\t{\r\n\t\t\tthis.login();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Vérification de la présence d'un login et d'un password pour activer le bouton\r\n\t */\r\n\tpublic canDoLogin()\r\n\t{\r\n\r\n\t\tlet result = false;\r\n\t\tif (this.password && this.username)\r\n\t\t{\r\n\t\t\tconst filteredLogin\t\t= this.username.replace(/ /gi, '');\r\n\t\t\tconst filteredPassoword\t= this.password.replace(/ /gi, '');\r\n\r\n\t\t\tif (filteredLogin !== '' && filteredPassoword !== '')\r\n\t\t\t{\r\n\t\t\t\tresult = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param data\r\n\t */\r\n\tprivate _handleError(data: any)\r\n\t{\r\n\t\t/**\r\n\t\t * Si on attend une connection on désactive le spinner et on affiche un message d'érreur\r\n\t\t */\r\n\t\tif (this.isLoading)\r\n\t\t{\r\n\t\t\tthis.isLoading\t\t= false;\r\n\r\n\t\t\tthis.userData.setStateApplication('application', 'offline');\r\n\r\n\t\t\tthis.isError\t\t= true;\r\n\t\t\tthis.errorMessage\t= 'Serveur indisponible. Veuillez rééssayer ultérieurement.';\r\n\t\t}\r\n\t}\r\n}\r\n","\r\n\t\r\n\t\r\n\t\t
\r\n\t\t\t
{{ 'state-stats.assignedTo' | translate }}
\r\n\t\t\t
{{ 'state-stats.createdBy' | translate }}
\r\n\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\t
{{ 'disciplineDetail.echeance' | translate }} : \r\n\t\t\t\t\t \r\n\t\t\t
\r\n\t\t
\r\n\t\t
\r\n\t\t\t
{{task.typeLib}}
\r\n\t\t\t
{{task.stateLib}}
\r\n\t\t
\r\n\t
\r\n \r\n","import { Component, OnInit, Input, OnChanges, DoCheck, EventEmitter }\tfrom '@angular/core';\r\nimport { UserData }\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom '../../providers/user-data';\r\nimport { WorkspaceData }\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom '../../providers/workspace-data';\r\nimport { TaskData }\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom '../../providers/task-data';\r\n\r\n\r\n@Component({\r\n\tselector:\t'app-state-stats',\r\n\toutputs:\t['_onClick: onClick'],\r\n\r\n\ttemplateUrl:\t'./state-stats.component.html',\r\n\tstyleUrls:\t\t['./state-stats.component.scss']\r\n})\r\n\r\n\r\nexport class StateStatsComponent implements OnChanges, DoCheck, OnInit\r\n{\r\n\tpublic _onClick: EventEmitter = new EventEmitter();\r\n\r\n\t@Input() task: any;\r\n\r\n\tpublic content:\t\tany;\r\n\tpublic dateClass:\tany;\r\n\tpublic fullDate:\tany;\r\n\tpublic taskId:\t\tany;\r\n\tpublic oSujet:\t\tany;\r\n\t\r\n\tpublic endDate: Date;\r\n\r\n\r\n\tpublic moUserDataSubscription: any;\r\n\r\n\tconstructor(public userData: UserData, public workspaceData: WorkspaceData, public taskData: TaskData)\r\n\t{\r\n\t\tthis.content = '';\r\n\r\n\r\n\t}\r\n\r\n\r\n\tpublic ngOnChanges()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis.taskId \t= this.task.id;\r\n\t\tthis.endDate \t= this.task.endDate;\r\n\t\t//this.task \t= this.taskData.getTaskById(this.taskId);\r\n\t\tconst er \t= this.workspaceData.globalEmitter.subscribe((value: string) =>\r\n\t\t{\r\n\t\t\t//Evènement récupéré lorsqu'un nouveau classeur à été ajouté\r\n\t\t\t//On ajoute donc le dernier elément de la structure dans user data\r\n\t\t\t//dans les classeurs du composant\r\n\t\t\tif (value === 'majStatsEpr')\r\n\t\t\t{\r\n\t\t\t\tlet\tstatsNode2 = this.workspaceData.statsNode2;\r\n\t\t\t\tif(statsNode2)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let statsNode of statsNode2)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (this.taskId === statsNode.idTask)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.endDate = new Date(statsNode.echeance);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.taskData.taskDataEmitter.emit('task::update');\r\n\r\n\t}\r\n\t\r\n\r\n\tpublic ngDoCheck()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\tpublic onClick(test: any)\r\n\t{\r\n\t\tthis._onClick.emit(this.task);\r\n\t}\r\n}\r\n","\r\n","\r\nimport { Component, EventEmitter, ViewEncapsulation, Inject, OnInit, OnDestroy } from '@angular/core';\r\nimport { MatDialogRef, MatDialog }\t\t\t\t\t\t\t from '@angular/material';\r\nimport { MAT_DIALOG_DATA }\t\t\t\t\t\t\t\t\t from '@angular/material';\r\nimport { DataSource, SelectionModel }\t from '@angular/cdk/collections';\r\nimport {Observable} from 'rxjs/Rx';\r\nimport {startWith, map} from 'rxjs/operators';\r\nimport { TranslateService } \t\t\t\t\t\t from '@ngx-translate/core';\r\n\r\nimport { Etablissement }\t\tfrom '../../../../classes/etablissement.class';\r\nimport { Session }\t\t\t\tfrom '../../../../classes/session.class';\r\nimport { Examen }\t\t\t\tfrom '../../../../classes/examen.class';\r\nimport { Matiere }\t\t\t\tfrom '../../../../classes/matiere.class';\r\nimport { Task }\t\t\t\t\tfrom '../../../../classes/task.class';\r\nimport { Sujet }\t\t\t\tfrom '../../../../classes/sujet.class';\r\nimport { File as FileObject }\tfrom '../../../../classes/file.class';\r\n\r\nimport { TaskService }\t\tfrom '../../../../services/task.service';\r\nimport { FileService }\t\tfrom '../../../../services/file.service';\r\nimport { EncryptService } from '../../../../services/encrypt.service';\r\nimport { UserData }\t\t\tfrom '../../../../providers/user-data';\r\nimport { WorkspaceData }\tfrom '../../../../providers/workspace-data';\r\n\r\nimport { WarningUnloggedUserModalComponent }\t\t\t\tfrom '../../modal/warningUnloggedUserModal.component';\r\nimport { FormBuilder, FormGroup, FormControl, Validators } from '@angular/forms';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n/*\r\nexport interface FileItemList {\r\n name: string;\r\n}\r\n*/\r\n\r\nexport class FileItemDataSource extends DataSource\r\n{\r\n public objSubject: any;\r\n\r\n\r\n\tconstructor(objSubject: any)\r\n\t{\r\n\t\tsuper();\r\n this.objSubject = objSubject;\r\n\t}\r\n\r\n\r\n\t/** Connect function called by the table to retrieve one stream containing the data to render. */\r\n\tconnect(): Observable\r\n\t{\r\n\t\treturn Observable.of(this.objSubject.pj);\r\n\t}\r\n\r\n\tdisconnect() { }\r\n}\r\n\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'editor-panel-task',\r\n\ttemplateUrl:\t'./editor-panel-task.component.html',\r\n\tinputs:\t\t\t['task'],\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\toutputs:\t\t['_onSubmit: onSubmit', '_onCancel: onCancel'],\r\n\tstyleUrls:\t\t['./editor-panel-task.component.scss']\r\n})\r\n\r\n\r\nexport class EditorPanelTaskComponent implements OnInit, OnDestroy\r\n{\r\n public startDate = new Date();\r\n\r\n\tpublic oldTask:\t\t\t\tTask;\r\n public initialTask:\t\t\tTask;\r\n public currentTask:\t\t\tTask;\r\n public structureModel:\t\tany[];\r\n public isTaskEdition:\t\tboolean = false;\r\n public titleModal: string;\r\n public itemSelected:\t\tstring;\r\n public subjectsAvailable:\tany[];\r\n public usersAvailable:\t\tany[];\r\n public moFormGroup:\t\t\tFormGroup;\r\n public scenarioList:\t\tany;\r\n\r\n public currentName:\t\t\tstring;\r\n public currentType:\t\t\tnumber;\r\n public currentIdSujet:\t\tstring;\r\n public currentDescription:\tstring;\r\n public currentAssigneduser: any;\r\n\r\n public sendEmail:\t\t\tboolean = false;\r\n\r\n public noAccessFile:\t\t\tboolean = false;\r\n public readOnlyFile:\t\t\tboolean = false;\r\n public canCreateFile:\t\t\tboolean = true;\r\n public majSelected:\t\t\t\tany\t\t= 'false';\r\n public canDeleteFile:\t\t\tboolean = false;\r\n public typeFileAccess: string = 'all';\r\n\r\n public selectedClasseur:\tEtablissement;\r\n public selectedSession:\t\tSession;\r\n public selectedExamen:\t\tExamen;\r\n public selectedMatiere:\t\tMatiere;\r\n public selectedSubject: Sujet;\r\n public dateEcheance:\t\tDate;\r\n\r\n public moFormCtrType:\t\t\tFormControl;\r\n public moFormCtrSubject:\t\tFormControl;\r\n public moFormCtrDescription:\tFormControl;\r\n public moFormCtrEcheance:\t\tFormControl;\r\n public moFormCtrNoAccessFile:\tFormControl;\r\n public moFormCtrCanCreateFile:\tFormControl;\r\n public moFormCtrAssignedUser:\tFormControl;\r\n public moFormCtrSendEmail:\t\tFormControl;\r\n\r\n public filesSubject:\t\t\t\t\tFileItemDataSource;\r\n public moUserDataEmmiterSubscription:\tany;\r\n public selection:\t\t\t\t\t\tSelectionModel\t= new SelectionModel(true, []);\r\n public displayedColumns\t\t\t\t\t\t\t\t\t\t\t\t= ['select', 'name'];\r\n\r\n public unloggedUserSelected: boolean = false;\r\n\r\n public _onSubmit: EventEmitter\t\t= new EventEmitter();\r\n\tpublic _onCancel: EventEmitter\t= new EventEmitter();\r\n\r\n public treeDatas: any = undefined;\r\n public txtValidateButon: any;\r\n\r\n filteredOptions: Observable;\r\n\r\n constructor(public dialogRef:\t\tMatDialogRef,\r\n public taskService:\t\tTaskService,\r\n public fileService:\t\tFileService,\r\n public encryptService:\tEncryptService,\r\n public fb:\t\t\t\tFormBuilder,\r\n public userData:\t\tUserData,\r\n public workspaceData:\tWorkspaceData,\r\n public dialog:\t\t\tMatDialog,\r\n public translate: TranslateService,\r\n @Inject(MAT_DIALOG_DATA) public data: any)\r\n\t{\r\n\r\n\t\tthis.translate.get('editorPanel.titleCreation').subscribe((title: string) =>\r\n\t\t{\r\n\t\t\tthis.titleModal = title;\r\n\t\t});\r\n\r\n\t\tthis.itemSelected = 'informations';\r\n\r\n\t\tthis.translate.get('editorPanel.new').subscribe((value: string) =>\r\n\t\t{\r\n\r\n\t\t\tthis.subjectsAvailable = [\r\n\t\t\t\t{\r\n\t\t\t\t\tvalue:\t\t'new',\r\n\t\t\t\t\tlibelle:\tvalue\r\n\t\t\t\t}\r\n\t\t\t];\r\n\t\t});\r\n\r\n\t\tthis.translate.get('editorPanel.noUser').subscribe((value: string) =>\r\n\t\t{\r\n\t\t\tthis.usersAvailable = [\r\n\t\t\t\t{\r\n\t\t\t\t\tvalue:\t\t'none',\r\n\t\t\t\t\tloggedOnce: true,\r\n\t\t\t\t\tisPrinter:\tfalse,\r\n\t\t\t\t\tlibelle:\tvalue\r\n\t\t\t\t}];\r\n\t\t});\r\n\r\n let allUsers = this.userData.getUsers();\r\n\r\n\t\tif (allUsers)\r\n\t\t{\r\n\t\t\tfor (let key in allUsers)\r\n\t\t\t{\r\n\t\t\t\tif (allUsers[key])\r\n\t\t\t\t{\r\n\t\t\t\t\tlet userInfo;\r\n\t\t\t\t\tlet outputContent = key;\r\n\r\n\t\t\t\t\tif (key)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tuserInfo = this.userData.getUser(key);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (userInfo && userInfo.infos && (userInfo.infos.nom || userInfo.infos.prenom))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\toutputContent = '';\r\n\r\n\t\t\t\t\t\tif (userInfo.infos.prenom)\toutputContent += userInfo.infos.prenom + ' ';\r\n\t\t\t\t\t\tif (userInfo.infos.nom)\t\toutputContent += userInfo.infos.nom;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tlet loggedOnce: boolean = true;\r\n\t\t\t\t\tif (userInfo && userInfo.state && userInfo.state.active)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet dateActive = new Date(userInfo.state.active);\r\n\t\t\t\t\t\tif (dateActive && dateActive.getTime() === 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tloggedOnce = false;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tlet isPrinter: boolean = false;\r\n\t\t\t\t\tif (userInfo && userInfo.publics && userInfo.publics.isPrinter)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tisPrinter = userInfo.publics.isPrinter === 'true';\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.usersAvailable.push(\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvalue:\t\tkey,\r\n\t\t\t\t\t\t\tloggedOnce: loggedOnce,\r\n\t\t\t\t\t\t\tisPrinter:\tisPrinter,\r\n\t\t\t\t\t\t\tlibelle:\toutputContent\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\tif (this.data)\r\n {\r\n /**\r\n * Récupération des éléments de l'arborescence selectionnés\r\n */\r\n if (this.data.selectedItems)\r\n {\r\n if (this.data.selectedItems[0])\r\n\t\t\t\t\tthis.selectedClasseur = this.workspaceData.selectedEtablissement;\r\n\r\n if (this.data.selectedItems[1])\r\n\t\t\t\t\tthis.selectedSession = this.workspaceData.selectedSession;\r\n\r\n if (this.data.selectedItems[2])\r\n\t\t\t\t\tthis.selectedExamen = this.workspaceData.selectedExamen;\r\n\r\n if (this.data.selectedItems[3])\r\n\t\t\t\t\tthis.selectedMatiere = this.workspaceData.selectedMatiere;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tif (this.data.oldTask)\r\n {\r\n\t\t\t\tthis.oldTask = this.data.oldTask;\r\n\t\t\t}\r\n\t\t\tif (this.data.majSelected)\r\n {\r\n\t\t\t\tthis.majSelected = this.data.majSelected;\r\n\t\t\t}\r\n\r\n /**\r\n * lorsqu'une tache est transmise au composant d'édition\r\n * on remplie le formulaire avec les informations existantes\r\n * pour gérer l'édition\r\n *\r\n * On considère lorsqu'une tache est transmise que nous sommes par défaut en mode édition (sauf si le paramètre isEdition est affecté de faux)\r\n *\r\n * Setter\r\n */\r\n if (this.data.task)\r\n {\r\n\t\t\t\tthis.currentTask = this.data.task;\r\n\r\n // ---------------------------------------\r\n\t\t\t\t// récupération du process courant\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\tlet idEpreuve\t= this.currentTask.idEpreuve;\r\n let oEpreuve\t= this.workspaceData.getEpreuve(idEpreuve);\r\n\r\n if (oEpreuve)\r\n {\r\n this.scenarioList = oEpreuve.scenario;\r\n }\r\n\r\n this.currentName\t\t\t= this.currentTask.name;\r\n this.currentType\t\t\t= Number(this.currentTask.type);\r\n this.currentIdSujet\t\t\t= this.currentTask.idSujet;\r\n this.currentDescription\t\t= this.currentTask.description;\r\n this.currentAssigneduser\t= this.currentTask.assigneduser;\r\n this.selectedSubject\t\t= this.workspaceData.getSujet(this.currentIdSujet);\r\n\t\t\t\tconst currentTypeScenario\t= this.getType();\r\n\r\n\t\t\t\t// On détermine si l'imprimeur aura accés ou pas au document de fin de tache\r\n\t\t\t\tthis.currentTask.hasReadRightForPrinter = currentTypeScenario ? currentTypeScenario.isReadablePrinter === true : false;\r\n\r\n this.translate.get('editorPanel.newTaskText').subscribe((value: string) => {\r\n\t\t\t\t\tconst currentTypeName = currentTypeScenario ? currentTypeScenario.name : '';\r\n });\r\n\r\n if (this.selectedSubject)\r\n {\r\n this.fileService.getFiles(this.selectedSubject.id);\r\n }\r\n\r\n if (!this.currentAssigneduser)\r\n {\r\n this.currentAssigneduser\t= this.usersAvailable[0];\r\n this.unloggedUserSelected\t= false;\r\n }\r\n else\r\n {\r\n this.currentAssigneduser = _.find(this.usersAvailable, (user: any) => { return user.value === this.currentAssigneduser; });\r\n\r\n if (this.currentAssigneduser)\r\n {\r\n if (this.currentAssigneduser.loggedOnce === false)\r\n {\r\n this.unloggedUserSelected = true;\r\n }else\r\n {\r\n this.unloggedUserSelected = false;\r\n }\r\n }\r\n }\r\n\r\n this.dateEcheance = this.currentTask.endDate;\r\n this._initTaskParents();\r\n this.isTaskEdition = this.data.isEdition === false ? false : true;\r\n\r\n if (this.data.task.idSujet)\r\n {\r\n let treeStructure = this.workspaceData.getBranchFromId(this.data.task.idSujet);\r\n\r\n this.treeDatas\t\t\t\t\t\t\t= {};\r\n this.treeDatas.selectedEtablissement\t= treeStructure.etablissement;\r\n this.treeDatas.selectedSession\t\t\t= treeStructure.session;\r\n this.treeDatas.selectedExamen\t\t\t= treeStructure.examen;\r\n this.treeDatas.selectedMatiere\t\t\t= treeStructure.matiere;\r\n\r\n if (this.treeDatas.selectedMatiere)\r\n {\r\n for (let sujet of this.treeDatas.selectedMatiere.sujets)\r\n {\r\n\t\t\t\t\t\t\tthis.subjectsAvailable.push(\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tvalue:\t\tsujet.id,\r\n\t\t\t\t\t\t\t\t\tlibelle:\tsujet.name\r\n\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n }\r\n }\r\n\r\n // ---------------------------------------\r\n // S'il ne s'agit pas d'une nouvelle tache que l'on créé\r\n // on initialise l'ensemble des champs\r\n // ---------------------------------------\r\n\t\t\t\tlet jsonValue\t\t= this.currentTask.toJson();\r\n\t\t\t\tthis.initialTask\t= Task.fromJsonObject(jsonValue);\r\n\r\n //initialisation des champs relatifs aux droits\r\n this.noAccessFile\t= this.currentTask.noAccessFile;\r\n this.canCreateFile\t= this.currentTask.canCreateFile;\r\n\r\n if (this.currentTask.noAccessFile === false)\r\n {\r\n this.readOnlyFile\t= this.currentTask.readOnlyFile;\r\n this.canDeleteFile\t= this.currentTask.canDeleteFile;\r\n this.typeFileAccess = this.currentTask.typeFileAccess;\r\n }\r\n else\r\n {\r\n this.readOnlyFile\t= false;\r\n this.canDeleteFile\t= false;\r\n this.typeFileAccess = 'all';\r\n this.selection\t\t= new SelectionModel(true, []);\r\n }\r\n\r\n }\r\n else\r\n {\r\n\r\n // ---------------------------------------\r\n // Si auncune tache n'est renseigné on considère qu'il s'agit d'un\r\n // ajout de tache\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\tconst currentTypeScenario\t= this.getType();\r\n this.currentTask\t\t\t= new Task();\r\n this.currentTask.flags\t\t= ['inprogress'];\r\n\r\n\t\t\t\tif (this.workspaceData.selectedSujet)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.currentIdSujet = this.workspaceData.selectedSujet.id;\r\n\t\t\t\t}\r\n\r\n this.selectedSubject\t= this.workspaceData.getSujet(this.currentIdSujet);\r\n\t\t\t\tthis.scenarioList\t\t= this.workspaceData.selectedMatiere.scenario;\r\n\r\n if (this.workspaceData.selectedMatiere)\r\n {\r\n for (let sujet of this.workspaceData.selectedMatiere.sujets)\r\n {\r\n\t\t\t\t\t\tthis.subjectsAvailable.push(\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvalue:\t\tsujet.id,\r\n\t\t\t\t\t\t\t\tlibelle:\tsujet.name\r\n\t\t\t\t\t\t\t});\r\n }\r\n }\r\n\r\n\t\t\t\tthis.translate.get('editorPanel.formatedText1').subscribe((value1: string) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.translate.get('editorPanel.formatedText2').subscribe((value2: string) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.currentName = '';\r\n\t\t\t\t\t\tthis.currentName += value1;\r\n\t\t\t\t\t\tthis.currentName += currentTypeScenario ? currentTypeScenario.name : '';\r\n\r\n\t\t\t\t\t\tif (this.workspaceData.selectedSujet)\r\n\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\tthis.currentName += value2;\r\n\t\t\t\t\t\t\tthis.currentName += this.workspaceData.selectedSujet.name;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\r\n this.currentAssigneduser = this.usersAvailable[0];\r\n this._initTaskParents();\r\n this.isTaskEdition = false;\r\n\r\n this.selection = new SelectionModel(true, []);\r\n }\r\n\r\n\t\t\tconst hasAdminRight = this.userData.isAdmin() === true || this.userData.isSuperviseur() === true;\r\n\r\n this.moFormCtrType\t\t\t= this.fb.control({value: this.currentType,\t\t\tdisabled: hasAdminRight === false},\t\t\tValidators.required);\r\n this.moFormCtrSubject\t\t= this.fb.control({value: this.currentIdSujet,\t\tdisabled: true},\t\t\t\t\t\t\tValidators.required);\r\n this.moFormCtrDescription\t= this.fb.control({value: this.currentName,\t\t\tdisabled: hasAdminRight === false},\t\t\tValidators.required);\r\n this.moFormCtrEcheance\t\t= this.fb.control({value: this.dateEcheance,\t\tdisabled: hasAdminRight === false},\t\t\tValidators.required);\r\n this.moFormCtrAssignedUser\t= this.fb.control({value: this.currentAssigneduser, disabled: hasAdminRight === false},\t\t\t[Validators.required, this.isAssignedUserValid.bind(this)]);\r\n this.moFormCtrNoAccessFile\t= this.fb.control({value: this.noAccessFile,\t\tdisabled: hasAdminRight === false});\r\n this.moFormCtrCanCreateFile\t= this.fb.control({value: this.canCreateFile,\t\tdisabled: hasAdminRight === false});\r\n this.moFormCtrSendEmail\t\t= this.fb.control({value: this.sendEmail,\t\t\tdisabled: hasAdminRight === false});\r\n\r\n this.moFormGroup = this.fb.group(\r\n\t\t\t\t{\r\n\t\t\t\t\ttype:\t\t\tthis.moFormCtrType,\r\n\t\t\t\t\tsubject:\t\tthis.moFormCtrSubject,\r\n\t\t\t\t\tdescription:\tthis.moFormCtrDescription,\r\n\t\t\t\t\tdateEcheance:\tthis.moFormCtrEcheance,\r\n\t\t\t\t\tassignedUser:\tthis.moFormCtrAssignedUser,\r\n\t\t\t\t\tnoAccessFile:\tthis.moFormCtrNoAccessFile,\r\n canCreateFile:\tthis.moFormCtrCanCreateFile,\r\n sendEmail: this.moFormCtrSendEmail\r\n });\r\n\r\n\t\t\tif (this.isTaskEdition === true)\r\n\t\t\t{\r\n\t\t\t\tthis.translate.get('editorPanel.title').subscribe((value1: string) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.translate.get('common.validate').subscribe((value2: string) =>\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tthis.titleModal\t\t\t= value1;\r\n\t\t\t\t\t\tthis.txtValidateButon\t= value2;\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.translate.get('editorPanel.titleCreation').subscribe((value1: string) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.translate.get('common.add').subscribe((value2: string) =>\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tthis.titleModal\t\t\t= value1;\r\n\t\t\t\t\t\tthis.txtValidateButon\t= value2;\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\r\n\r\n public ngOnInit()\r\n\t{\r\n this.moUserDataEmmiterSubscription = this.userData.globalEmitter.subscribe((value: any) =>\r\n\t\t{\r\n\t\t\tif (value === 'files::get')\r\n\t\t\t{\r\n this.initExistingFiles();\r\n }\r\n\r\n });\r\n\t\tthis.initExistingFiles();\r\n\r\n\t\tthis.filteredOptions = this.moFormCtrAssignedUser.valueChanges.pipe(\r\n\t\t\tstartWith(null),\r\n\t\t\tmap(value => typeof value === 'string' ? value : value ? value.libelle : ''),\r\n\t\t\tmap(name => name ? this.filterUser(name) : this.usersAvailable.slice())\r\n\t\t);\r\n\t}\r\n\r\n\r\n public ngOnDestroy()\r\n\t{\r\n this.moUserDataEmmiterSubscription.unsubscribe();\r\n }\r\n\r\n\r\n\tpublic filterUser(val: any): string[]\r\n\t{\r\n\r\n\t\tlet libelle = val.libelle ? val.libelle : val;\r\n\r\n\t\treturn this.usersAvailable.filter(user => user.libelle.toLowerCase().indexOf(libelle.toLowerCase()) === 0);\r\n\r\n\t}\r\n\r\n\r\n\tpublic displayUser(user?: any): string | undefined\r\n\t{\r\n\t\treturn user ? user.libelle : undefined;\r\n\t}\r\n\r\n\r\n public initExistingFiles()\r\n {\r\n this.filesSubject = new FileItemDataSource(this.selectedSubject);\r\n\r\n //Si des fichiers sont sélectionnés dans la tache courante, on les selectionne dans la liste\r\n if (this.selectedSubject && this.selectedSubject.pj && this.currentTask.fileToAccess)\r\n {\r\n let filesSelected = _.filter(this.selectedSubject.pj, (pj: any) => {\r\n return _.find(this.currentTask.fileToAccess, (fileId: any) => { return fileId == pj.id; }) !== undefined;\r\n });\r\n\r\n this.selection = new SelectionModel(true, filesSelected);\r\n }\r\n }\r\n\r\n\r\n /**\r\n *\r\n */\r\n\tpublic changeSelectedUser()\r\n\t{\r\n\t\tif (this.currentAssigneduser)\r\n\t\t{\r\n\t\t\tif (this.currentAssigneduser.loggedOnce === false)\r\n\t\t\t{\r\n\t\t\t\tthis.unloggedUserSelected = true;\r\n\r\n\t\t\t\tthis.dialog.open(WarningUnloggedUserModalComponent,\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\theight:\t\t\t'auto',\r\n\t\t\t\t\t\twidth:\t\t\t'auto',\r\n\t\t\t\t\t\tdata:\t\t\t{},\r\n\t\t\t\t\t\tdisableClose:\ttrue\r\n\t\t\t\t\t});\r\n\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.unloggedUserSelected = false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic isAssignedUserValid(control: FormControl)\r\n\t{\r\n\t\tlet result: any = { invalid: true };\r\n\t\tif (control && control.value && control.value.value && control.value.libelle)\r\n\t\t{\r\n\t\t\tresult = null;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n public buildInfosTooltipUser(userId: any)\r\n {\r\n let currentObjectUser = this.userData.getUser(userId);\r\n let tooltipCurrentUser: any;\r\n\r\n if (currentObjectUser && currentObjectUser.infos)\r\n {\r\n tooltipCurrentUser = currentObjectUser.infos.nom + ' ' + currentObjectUser.infos.prenom;\r\n tooltipCurrentUser += '\\n' + currentObjectUser.infos.mail;\r\n\r\n let professions: any;\r\n if (typeof currentObjectUser.publics.professions === 'string')\r\n {\r\n professions = JSON.parse(currentObjectUser.publics.professions);\r\n }\r\n else\r\n {\r\n professions = currentObjectUser.publics.professions;\r\n }\r\n\r\n let matieres: any;\r\n if (typeof currentObjectUser.publics.matieres === 'string')\r\n {\r\n matieres = JSON.parse(currentObjectUser.publics.matieres);\r\n }\r\n else\r\n {\r\n matieres = currentObjectUser.publics.matieres;\r\n }\r\n\r\n if(professions && professions.length > 0)\r\n {\r\n this.translate.get('common.jobs').subscribe((value: string) => {\r\n\r\n tooltipCurrentUser += '\\n\\n' + value + ':';\r\n for(let profession of professions)\r\n {\r\n tooltipCurrentUser += '\\n - ' + profession;\r\n }\r\n });\r\n }\r\n\r\n if(matieres && matieres.length > 0)\r\n {\r\n this.translate.get('common.matieres').subscribe((value: string) => {\r\n\r\n tooltipCurrentUser += '\\n\\n' + value + ':';\r\n for(let matiere of matieres)\r\n {\r\n tooltipCurrentUser += '\\n - ' + matiere;\r\n }\r\n });\r\n }\r\n }\r\n\r\n return tooltipCurrentUser;\r\n }\r\n\r\n /**\r\n * Dans la partie droits, retourne vrai si tout les fichiers sont selectionnées dans\r\n * la table de selection des sujets\r\n */\r\n\tisAllSelected()\r\n\t{\r\n\t\tconst numSelected\t= this.selection.selected.length;\r\n\t\tconst numRows\t\t= this.filesSubject.objSubject.pj.length;\r\n\r\n\r\n\t\treturn numSelected === numRows;\r\n\t}\r\n\r\n\r\n /**\r\n * Dans l'interface des droits si on souhaite choisir les fichiers accessibles\r\n * Selectionne tous les fichiers dans le tableau s'ils ne sont pas déja tous selectionné.\r\n * Dans le cas contraire ils sont tous déselectionnés\r\n */\r\n\tmasterToggle()\r\n\t{\r\n\t\tthis.isAllSelected() ? this.selection.clear() : this.filesSubject.objSubject.pj.forEach((pj: any) => this.selection.select(pj));\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public close()\r\n {\r\n this.dialogRef.close(false);\r\n }\r\n\r\n\r\n public allowFilesTaskForAssignedUser()\r\n\t{\r\n if (this.currentTask.assigneduser && this.currentTask.assigneduser !== '')\r\n {\r\n // On récupère les clé aes des fichiers dont on donne les droits et on les ré-encode avec\r\n // la clé publique de l'utilisateur selectionné\r\n let listFile: any[];\r\n\r\n // Liste des fichiers dont on souhaite supprimer les droits d'accès à l'utilisateur concerné\r\n // On affecte cette liste de l'ensemble des fichiers au départ\r\n let listFileToLock = _.map(this.filesSubject.objSubject.pj, (pj: any) => { return pj.id });\r\n\r\n if (this.currentTask.noAccessFile === true)\r\n {\r\n // Si on désactive l'accès aux fichier on supprime les droits aux fichiers dont l'utilisateur à accès jusqu'à présent\r\n for (let fileTolock of listFileToLock)\r\n {\r\n this.encryptService.deleteAesKey(this.currentTask.assigneduser, fileTolock);\r\n }\r\n }\r\n else\r\n {\r\n // Sinon on détermine les fichiers accèssibles et les fichiers qui ne sont plus accèssibles et on met à jour les droits\r\n if (this.filesSubject && this.filesSubject.objSubject && this.currentTask.typeFileAccess === 'all')\r\n {\r\n listFile = _.map(this.filesSubject.objSubject.pj, (pj: any) => { return pj.id });\r\n }\r\n else\r\n {\r\n if (this.currentTask.typeFileAccess === 'list')\r\n {\r\n listFile = _.map(this.selection.selected, (pj: any) => { return pj.id; });\r\n }\r\n }\r\n\r\n\r\n if (listFile)\r\n {\r\n listFileToLock = _.difference(listFileToLock, listFile);\r\n\r\n for (let fileTolock of listFileToLock)\r\n {\r\n this.encryptService.deleteAesKey(this.currentTask.assigneduser, fileTolock);\r\n }\r\n\r\n let currentSubject = this.workspaceData.getSujet(this.currentTask.idSujet);\r\n\r\n this.encryptService.encryptFilesForUSer(listFile, this.currentTask.assigneduser, currentSubject);\r\n }\r\n }\r\n }\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public validate()\r\n {\r\n\t\tconst currentType:\t\tany = this.getType();\r\n\t\tconst currentNameType:\tany = currentType ? currentType.name : '';\r\n\r\n this.currentTask.name\t\t\t= this.currentName;\r\n this.currentTask.type\t\t\t= this.currentType.toString();\r\n this.currentTask.libelleType\t= currentNameType;\r\n this.currentTask.idSujet\t\t= this.currentIdSujet;\r\n this.currentTask.description\t= this.currentDescription;\r\n\r\n if (this.currentAssigneduser && this.currentAssigneduser.value)\r\n {\r\n this.currentTask.assigneduser = this.currentAssigneduser.value === 'none' ? '' : this.currentAssigneduser.value;\r\n }\r\n else\r\n {\r\n this.currentTask.assigneduser = null;\r\n }\r\n\r\n this.currentTask.noAccessFile\t\t= this.noAccessFile;\r\n this.currentTask.canCreateFile\t\t= this.canCreateFile;\r\n\r\n if (this.currentTask.noAccessFile === false)\r\n {\r\n this.currentTask.readOnlyFile\t= this.readOnlyFile;\r\n this.currentTask.canDeleteFile\t= this.canDeleteFile;\r\n this.currentTask.typeFileAccess = this.typeFileAccess;\r\n this.currentTask.fileToAccess\t= _.map(this.selection.selected, (pj: any) => { return pj.id; });\r\n\r\n }\r\n else\r\n {\r\n this.currentTask.readOnlyFile\t= false;\r\n this.currentTask.canDeleteFile\t= false;\r\n this.currentTask.typeFileAccess = 'none';\r\n this.currentTask.fileToAccess\t= [];\r\n }\r\n\r\n if (this.dateEcheance)\r\n {\r\n this.currentTask.endDate = new Date(this.dateEcheance);\r\n\t\t}\r\n\r\n\t\tconst datasEmail: any =\r\n {\r\n\t\t\tnomSujet: this.selectedSubject ? this.selectedSubject.name : '',\r\n\t\t\tnomEtape: this.currentTask.typeLib,\r\n\t\t\tnomExamen: this.workspaceData.selectedExamen.name,\r\n\t\t\tnomEpreuve: this.workspaceData.selectedMatiere.name\r\n\t\t};\r\n\r\n\t\t//Si c'est une édition on met la tache à jour\r\n\t\tif (this.isTaskEdition === true)\r\n\t\t{\r\n\t\t\tlet datasToUpdate: any = this._getDatasToUpdate(this.initialTask, this.currentTask);\r\n\r\n\t\t\tif (datasToUpdate['assigneduser'] && datasToUpdate['assigneduser'] !== '' && this.sendEmail === true)\r\n\t\t\t{\r\n\t\t\t\tthis.initialTask.notifyByMail = true;\r\n\t\t\t\tdatasToUpdate.typeMail = 'newTask';\r\n\t\t\t\tdatasToUpdate.datasEmail = datasEmail;\r\n\t\t\t}\r\n\r\n\t\t\tthis.taskService.updateTask(this.initialTask, datasToUpdate);\r\n\t\t\tthis.allowFilesTaskForAssignedUser();\r\n\t\t}\r\n else\r\n {\r\n if (this.currentTask.assigneduser === 'none')\r\n {\r\n this.currentTask.assigneduser\t= '';\r\n this.currentTask.state\t\t\t= 'new';\r\n }\r\n else\r\n {\r\n this.currentTask.state = 'todo';\r\n }\r\n\r\n\t\t\tlet datasMail: any = {};\r\n if (this.sendEmail === true)\r\n {\r\n\t\t\t\tthis.currentTask.notifyByMail = true;\r\n\r\n\t\t\t\tconst currentExamen\t\t= this.workspaceData.getExamen(this.currentTask.idExamen);\r\n\t\t\t\tconst currentEpreuve\t= this.workspaceData.getEpreuve(this.currentTask.idEpreuve);\r\n\t\t\t\tconst currentSujet\t\t= this.workspaceData.getSujet(this.currentTask.idSujet);\r\n\r\n\t\t\t\tdatasMail =\r\n\t\t\t\t{\r\n\t\t\t\t\tnomEtape:\tthis.getType().name,\r\n\t\t\t\t\tnomExamen:\tcurrentExamen\t? currentExamen.name:\t'',\r\n\t\t\t\t\tnomEpreuve: currentEpreuve\t? currentEpreuve.name:\t'',\r\n\t\t\t\t\tnomSujet:\tcurrentSujet\t? currentSujet.name:\t''\r\n\t\t\t\t};\r\n }\r\n\r\n // Sinon on l'ajoute en BDD\r\n\t\t\tthis.taskService.addTask(this.currentTask, this.sendEmail, datasMail, this.majSelected);\r\n this.allowFilesTaskForAssignedUser();\r\n }\r\n\r\n this.dialogRef.close(true);\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public switch_tab(tabName: any)\r\n\t{\r\n this.itemSelected = tabName;\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n private _initTaskParents()\r\n {\r\n if (this.selectedClasseur)\r\n\t\t{\r\n this.currentTask.idEtablissement = this.selectedClasseur.id;\r\n\t\t}\r\n\r\n if (this.selectedSession)\r\n\t\t{\r\n this.currentTask.idSession = this.selectedSession.id;\r\n\t\t}\r\n\r\n if (this.selectedExamen)\r\n\t\t{\r\n this.currentTask.idExamen = this.selectedExamen.id;\r\n\t\t}\r\n\r\n if (this.selectedMatiere)\r\n\t\t{\r\n this.currentTask.idEpreuve = this.selectedMatiere.id;\r\n\t\t}\r\n }\r\n\r\n\r\n\tgetType()\r\n\t{\r\n let sReturn = null;\r\n if (this.scenarioList)\r\n {\r\n\t\t\tfor (let typeName of this.scenarioList.steps)\r\n {\r\n if (typeName.id === this.currentType)\r\n {\r\n sReturn = typeName;\r\n }\r\n }\r\n }\r\n\t\treturn sReturn;\r\n\t}\r\n\r\n\r\n\tmajTitle()\r\n\t{\r\n\t\tlet sujetId = this.currentIdSujet;\r\n\t\tlet sujetName = '';\r\n\r\n\t\tthis.translate.get('editorPanel.new').subscribe((value1: string) =>\r\n\t\t{\r\n\t\t\tthis.translate.get('editorPanel.formatedText1').subscribe((value2: string) =>\r\n\t\t\t{\r\n\t\t\t\tthis.translate.get('editorPanel.formatedText2').subscribe((value3: string) =>\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tif (sujetId === 'new')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsujetName = value1;\r\n\t\t\t\t\t\tthis.selectedSubject = undefined;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.selectedSubject = this.workspaceData.getSujet(sujetId);\r\n\t\t\t\t\t\tif (this.selectedSubject)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsujetName = this.selectedSubject.name;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tconst currentType = this.getType();\r\n\r\n\t\t\t\t\tthis.currentName = value2;\r\n\t\t\t\t\tthis.currentName += currentType ? currentType.name : '';\r\n\t\t\t\t\tthis.currentName += value3;\r\n\t\t\t\t\tthis.currentName += sujetName;\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n canValidateTask()\r\n {\r\n let result = true;\r\n\r\n\t\tif ((this.userData.isAdmin() === false && this.userData.isSuperviseur() === false) || !this.currentName || this.currentName === undefined || this.currentName === '' || this.currentType === undefined)\r\n {\r\n result = false;\r\n }\r\n\r\n return result;\r\n }\r\n\r\n\r\n\tonChangeAssignedUser(event: any)\r\n\t{\r\n\t\tthis.currentAssigneduser = event;\r\n\r\n\t\t// Si l'utilisateur selectionné est un imprimeur, on modifie les droits pour qu'il ne puisse pas\r\n\t\t// créer de fichier et pour qu'il ne puisse lire que les fichiers flaggés à la tache précédente\r\n\t\t// (à condition que cette dernière soit accéssible aux imprimeur dans le scénario)\r\n\t\tif (this.currentAssigneduser.isPrinter === true)\r\n\t\t{\r\n\t\t\tthis.moFormCtrNoAccessFile.setValue(true);\r\n\t\t\tthis.moFormCtrCanCreateFile.setValue(false);\r\n\r\n\t\t\t// on vérifie que la tache précédente est accéssible pour l'imprimeur\r\n\t\t\tif (this.oldTask && this.oldTask.hasReadRightForPrinter === true)\r\n\t\t\t{\r\n\t\t\t\t// On récupère les fichiers flaggés pour cette dernière tache\r\n\t\t\t\tconst pjsFiltered = _.filter(this.filesSubject.objSubject.pj, (pj: any) =>\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tlet result = false;\r\n\r\n\t\t\t\t\tif (pj.deleted === false)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (const tag of pj.tags)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tconst partTags = tag.split('::');\r\n\t\t\t\t\t\t\tif (partTags[0] === '*task' && partTags[1] === this.oldTask.id)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\treturn result;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif (pjsFiltered && pjsFiltered.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.moFormCtrNoAccessFile.setValue(false);\r\n\t\t\t\t\tthis.moFormCtrCanCreateFile.setValue(true);\r\n\r\n\t\t\t\t\tthis.readOnlyFile\t\t= true;\r\n\t\t\t\t\tthis.canDeleteFile\t\t= false;\r\n\t\t\t\t\tthis.typeFileAccess\t\t= 'list';\r\n\t\t\t\t\tthis.selection\t\t\t= new SelectionModel(true, pjsFiltered);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// sinon par défaut l'utilsiateur peux créer des fichiers et lire tout les fichiers du sujet\r\n\t\t\tthis.moFormCtrNoAccessFile.setValue(false);\r\n\t\t\tthis.moFormCtrCanCreateFile.setValue(true);\r\n\r\n\t\t\tthis.readOnlyFile\t\t= false;\r\n\t\t\tthis.canDeleteFile\t\t= false;\r\n\t\t\tthis.typeFileAccess\t\t= 'all';\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n private _getDatasToUpdate(oldTask: Task, newTask: Task)\r\n {\r\n let datas: any = {};\r\n\r\n // ---------------------------------------\r\n // ToComment\r\n // ---------------------------------------\r\n if (oldTask.description !== newTask.description)\r\n {\r\n datas['description'] = newTask.description;\r\n }\r\n\r\n if (oldTask.name !== newTask.name)\r\n {\r\n datas['name'] = newTask.name;\r\n }\r\n\r\n if (oldTask.type !== newTask.type)\r\n {\r\n datas['type'] = newTask.type;\r\n }\r\n\r\n // ---------------------------------------\r\n // ToComment\r\n // ---------------------------------------\r\n if (oldTask.state !== newTask.state)\r\n {\r\n datas['state'] = newTask.state;\r\n }\r\n\r\n // ---------------------------------------\r\n // ToComment\r\n // ---------------------------------------\r\n\r\n if (oldTask.assigneduser !== newTask.assigneduser)\r\n {\r\n datas['assigneduser'] = newTask.assigneduser;\r\n //si l'utilisateur assigné est supprimé, on met automatiquement\r\n // la tache en non assigné\r\n if (datas['assigneduser'] === '' || datas['assigneduser'] === 'none')\r\n {\r\n datas['assigneduser'] = '';\r\n datas['state'] = 'new';\r\n }\r\n else\r\n {\r\n //Si le nouvel utilisateur assigné est non vide et que le l'état initial\r\n //de la tache est non assigné alors on la met automatiquement à l'état assigné\r\n if (oldTask.state === 'new')\r\n {\r\n datas['state'] = 'todo';\r\n }\r\n }\r\n }\r\n\r\n\t\tlet oldEndDate = oldTask.endDate ? oldTask.endDate.getTime() : null;\r\n\t\tlet newEndDate = newTask.endDate ? newTask.endDate.getTime() : null;\r\n\r\n\t\tif (oldEndDate !== newEndDate)\r\n\t\t{\r\n\t\t\tdatas['enddate'] = newTask.endDate;\r\n\t\t}\r\n\r\n\t\tif (oldTask.noAccessFile !== newTask.noAccessFile)\r\n\t\t{\r\n\t\t\tdatas['noaccessfile'] = newTask.noAccessFile ? '1' : '0';\r\n\t\t}\r\n\r\n\t\tif (oldTask.canCreateFile !== newTask.canCreateFile)\r\n\t\t{\r\n\t\t\tdatas['cancreatefile'] = newTask.canCreateFile ? '1' : '0';\r\n\t\t}\r\n\r\n\t\tif (oldTask.readOnlyFile !== newTask.readOnlyFile)\r\n\t\t{\r\n\t\t\tdatas['readonlyfile'] = newTask.readOnlyFile ? '1' : '0';\r\n\t\t}\r\n\r\n\t\tif (oldTask.canDeleteFile !== newTask.canDeleteFile)\r\n\t\t{\r\n\t\t\tdatas['candeletefile'] = newTask.canDeleteFile ? '1' : '0';\r\n\t\t}\r\n\r\n\t\tif (oldTask.typeFileAccess !== newTask.typeFileAccess)\r\n\t\t{\r\n\t\t\tdatas['typefileaccess'] = newTask.typeFileAccess;\r\n\t\t}\r\n\r\n\t\tlet intersectFiles = _.intersection(oldTask.fileToAccess, newTask.fileToAccess);\r\n\r\n\t\tif (oldTask.fileToAccess.length !== newTask.fileToAccess.length || intersectFiles.length !== oldTask.fileToAccess.length)\r\n\t\t{\r\n\t\t\tdatas['filetoaccess'] = newTask.fileToAccess;\r\n\t\t}\r\n\r\n return datas;\r\n }\r\n}\r\n","\r\n \r\n\r\n \r\n\r\n \r\n\r\n
\r\n\t\t\t \r\n\r\n\t\t\t
\r\n\r\n
\r\n\t\t
\r\n\r\n\t\t\r\n\r\n\t\t\r\n\r\n\t
\r\n \r\n","import { Component, EventEmitter, ViewEncapsulation, Inject, OnInit, OnDestroy } from '@angular/core';\r\n\r\nimport { MatDialogRef, MatDialog }\t\t\t\t\t\t\tfrom '@angular/material';\r\nimport { MAT_DIALOG_DATA }\t\t\t\t\t\t\t\t\tfrom '@angular/material';\r\nimport { DataSource, SelectionModel }\t\t\t\t\t\tfrom '@angular/cdk/collections';\r\nimport {Observable}\t\t\t\t\t\t\t\t\t\t\tfrom 'rxjs/Rx';\r\nimport { TranslateService }\t\t\t\t\t\t\t\t\tfrom '@ngx-translate/core';\r\nimport { FormBuilder, FormGroup, FormControl, Validators }\tfrom '@angular/forms';\r\n\r\nimport { Etablissement }\t\tfrom '../../../../classes/etablissement.class';\r\nimport { Session }\t\t\t\tfrom '../../../../classes/session.class';\r\nimport { Examen }\t\t\t\tfrom '../../../../classes/examen.class';\r\nimport { Matiere }\t\t\t\tfrom '../../../../classes/matiere.class';\r\nimport { Task }\t\t\t\t\tfrom '../../../../classes/task.class';\r\nimport { Sujet }\t\t\t\tfrom '../../../../classes/sujet.class';\r\nimport { File as FileObject }\tfrom '../../../../classes/file.class';\r\n\r\nimport { TaskService }\t\tfrom '../../../../services/task.service';\r\nimport { FileService }\t\tfrom '../../../../services/file.service';\r\nimport { EncryptService } from '../../../../services/encrypt.service';\r\nimport { UserData }\t\t\tfrom '../../../../providers/user-data';\r\nimport { WorkspaceData }\tfrom '../../../../providers/workspace-data';\r\n\r\nimport { WarningUnloggedUserModalComponent } from '../../modal/warningUnloggedUserModal.component';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n/*\r\nexport interface FileItemList {\r\n name: string;\r\n}\r\n*/\r\n\r\n\r\nexport class FileItemDataSource extends DataSource\r\n{\r\n public objSubject: any;\r\n\r\n\tconstructor(objSubject: any)\r\n\t{\r\n\t\tsuper();\r\n this.objSubject = objSubject;\r\n\t}\r\n\r\n\r\n\t/** Connect function called by the table to retrieve one stream containing the data to render. */\r\n\tconnect(): Observable\r\n\t{\r\n\t\treturn Observable.of(this.objSubject.pj);\r\n\t}\r\n\r\n\tdisconnect() { }\r\n}\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'editor-panel',\r\n\ttemplateUrl:\t'./editor-panel.component.html',\r\n\tinputs:\t\t\t['task'],\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\toutputs:\t\t['_onSubmit: onSubmit', '_onCancel: onCancel'],\r\n\tstyleUrls:\t\t['./editor-panel.component.scss']\r\n})\r\n\r\n\r\nexport class EditorPanelComponent implements OnInit, OnDestroy\r\n{\r\n public startDate = new Date();\r\n\r\n public initialTask:\t\t\tTask;\r\n public currentTask:\t\t\tTask;\r\n public structureModel:\t\tany[];\r\n public isTaskEdition:\t\tboolean = false;\r\n public itemSelected:\t\tstring;\r\n public subjectsAvailable:\tany[];\r\n public usersAvailable:\t\tany[];\r\n public moFormGroup:\t\t\tFormGroup;\r\n public scenarioList:\t\tany;\r\n\r\n public currentName:\t\t\tstring;\r\n public currentType:\t\t\tnumber;\r\n public currentIdSujet:\t\tstring;\r\n public currentDescription:\tstring;\r\n public currentAssigneduser: string;\r\n\r\n public noAccessFile:\t\t\tboolean = false;\r\n public readOnlyFile:\t\t\tboolean = false;\r\n public canCreateFile:\t\t\tboolean = false;\r\n public canDeleteFile:\t\t\tboolean = false;\r\n public typeFileAccess: string = 'all';\r\n\r\n public selectedClasseur:\tEtablissement;\r\n public selectedSession:\t\tSession;\r\n public selectedExamen:\t\tExamen;\r\n public selectedMatiere:\t\tMatiere;\r\n public selectedSubject: Sujet;\r\n public dateEcheance:\t\tDate;\r\n\r\n public moFormCtrlName:\t\t\t\t\tFormControl;\r\n public moFormCtrType:\t\t\t\t\tFormControl;\r\n public moFormCtrSubject:\t\t\t\tFormControl;\r\n public moFormCtrDescription:\t\t\tFormControl;\r\n public moFormCtrEcheance:\t\t\t\tFormControl;\r\n public moFormCtrNoAccessFile:\t\t\tFormControl;\r\n public moFormCtrCanCreateFile:\t\t\tFormControl;\r\n public moFormCtrAssignedUser:\t\t\tFormControl;\r\n\r\n\r\n public filesSubject:\t\tFileItemDataSource;\r\n public selection:\t\t\tSelectionModel = new SelectionModel(true, []);\r\n\t\r\n public displayedColumns = ['select', 'name'];\r\n public moUserDataEmmiterSubscription: any;\r\n\r\n public unloggedUserSelected: boolean = false;\r\n\r\n public _onSubmit: EventEmitter\t\t= new EventEmitter();\r\n\tpublic _onCancel: EventEmitter\t= new EventEmitter();\r\n\r\n public treeDatas: any = undefined;\r\n\r\n\r\n constructor(public dialogRef:\t\tMatDialogRef,\r\n public taskService:\t\tTaskService,\r\n public fileService:\t\tFileService,\r\n public encryptService:\tEncryptService,\r\n public fb:\t\t\t\tFormBuilder,\r\n public userData:\t\tUserData,\r\n public workspaceData:\tWorkspaceData,\r\n public dialog:\t\t\tMatDialog,\r\n public translate:\t\tTranslateService,\r\n @Inject(MAT_DIALOG_DATA) public data: any)\r\n\t{\r\n\t\tthis.itemSelected = 'informations';\r\n\t\tthis.translate.get('editorPanel.new').subscribe((value: string) =>\r\n\t\t{\r\n\t\t\tthis.subjectsAvailable = [\r\n\t\t\t\t{\r\n\t\t\t\t\tvalue:\t\t'new',\r\n\t\t\t\t\tlibelle:\tvalue\r\n\t\t\t\t}\r\n\t\t\t];\r\n\t\t});\r\n\r\n\r\n\t\tthis.translate.get('editorPanel.noUser').subscribe((value: string) =>\r\n\t\t{\r\n\t\t\tthis.usersAvailable = [\r\n\t\t\t\t{\r\n\t\t\t\t\tvalue:\t\t'none',\r\n\t\t\t\t\tloggedOnce: true,\r\n\t\t\t\t\tlibelle:\tvalue\r\n\t\t\t\t}\r\n\t\t\t];\r\n\t\t});\r\n\r\n\t\tlet allUsers = this.userData.getUsers();\r\n\r\n\r\n\t\tif (allUsers)\r\n\t\t{\r\n\t\t\tfor (let key in allUsers)\r\n\t\t\t{\r\n\t\t\t\tif (allUsers[key])\r\n\t\t\t\t{\r\n\t\t\t\t\tlet userInfo;\r\n\t\t\t\t\tlet outputContent = key;\r\n\r\n\t\t\t\t\tif (key)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tuserInfo = this.userData.getUser(key);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (userInfo && userInfo.infos && (userInfo.infos.nom || userInfo.infos.prenom))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\toutputContent = '';\r\n\r\n\t\t\t\t\t\tif (userInfo.infos.prenom)\toutputContent += userInfo.infos.prenom + ' ';\r\n\t\t\t\t\t\tif (userInfo.infos.nom)\t\toutputContent += userInfo.infos.nom;\r\n }\r\n\r\n let loggedOnce: boolean = true;\r\n if (userInfo && userInfo.state && userInfo.state.active)\r\n {\r\n let dateActive = new Date(userInfo.state.active);\r\n if (dateActive && dateActive.getTime() === 0)\r\n {\r\n loggedOnce = false;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.usersAvailable.push(\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvalue:\t\t\tkey,\r\n\t\t\t\t\t\t\tloggedOnce:\t\tloggedOnce,\r\n\t\t\t\t\t\t\tlibelle:\t\toutputContent\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (this.data)\r\n {\r\n /**\r\n * Récupération des éléments de l'arborescence selectionnés\r\n */\r\n if (this.data.selectedItems)\r\n {\r\n if (this.data.selectedItems[0])\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.selectedClasseur = this.workspaceData.selectedEtablissement;\r\n\t\t\t\t}\r\n\r\n if (this.data.selectedItems[1])\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.selectedSession = this.workspaceData.selectedSession;\r\n\t\t\t\t}\r\n\r\n if (this.data.selectedItems[2])\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.selectedExamen = this.workspaceData.selectedExamen;\r\n\t\t\t\t}\r\n\r\n if (this.data.selectedItems[3])\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.selectedMatiere = this.workspaceData.selectedMatiere;\r\n\t\t\t\t}\r\n }\r\n\r\n /**\r\n * lorsqu'une tache est transmise au composant d'édition\r\n * on remplie le formulaire avec les informations existantes\r\n * pour gérer l'édition\r\n * Setter\r\n */\r\n\r\n\r\n\r\n if (this.data.task)\r\n {\r\n this.currentTask = this.data.task;\r\n\r\n // ---------------------------------------\r\n\t\t\t\t// récupération du process courant\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\tlet idEpreuve\t= this.currentTask.idEpreuve;\r\n let oEpreuve\t= this.workspaceData.getEpreuve(idEpreuve);\r\n// this.scenarioList = oEpreuve.scenario;\r\n\r\n this.currentName\t\t\t= this.currentTask.name;\r\n this.currentType\t\t\t= Number(this.currentTask.type);\r\n this.currentIdSujet\t\t\t= this.currentTask.idSujet;\r\n this.currentDescription\t\t= this.currentTask.description;\r\n this.currentAssigneduser\t= this.currentTask.assigneduser;\r\n this.selectedSubject\t\t= this.workspaceData.getSujet(this.currentIdSujet);\r\n\r\n\r\n if (this.selectedSubject)\r\n {\r\n this.fileService.getFiles(this.selectedSubject.id);\r\n }\r\n\r\n if (!this.currentAssigneduser)\r\n {\r\n this.currentAssigneduser\t= 'none';\r\n this.unloggedUserSelected\t= false;\r\n }\r\n else\r\n {\r\n let selectedUser = _.find(this.usersAvailable, (user: any) => { return user.value === this.currentAssigneduser; });\r\n\r\n if (selectedUser)\r\n {\r\n if (selectedUser.loggedOnce === false)\r\n {\r\n this.unloggedUserSelected = true;\r\n }\r\n\t\t\t\t\t\telse\r\n {\r\n this.unloggedUserSelected = false;\r\n }\r\n }\r\n }\r\n\r\n this.dateEcheance = this.currentTask.endDate;\r\n this._initTaskParents();\r\n this.isTaskEdition = true;\r\n\r\n if (this.data.task.idSujet)\r\n {\r\n let treeStructure = this.workspaceData.getBranchFromId(this.data.task.idSujet);\r\n\r\n this.treeDatas\t\t\t\t\t\t\t= {};\r\n this.treeDatas.selectedEtablissement\t= treeStructure.etablissement;\r\n this.treeDatas.selectedSession\t\t\t= treeStructure.session;\r\n this.treeDatas.selectedExamen\t\t\t= treeStructure.examen;\r\n this.treeDatas.selectedMatiere\t\t\t= treeStructure.matiere;\r\n\r\n if (this.treeDatas.selectedMatiere)\r\n {\r\n for (let sujet of this.treeDatas.selectedMatiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.subjectsAvailable.push(\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tvalue:\t\tsujet.id,\r\n\t\t\t\t\t\t\t\t\tlibelle:\tsujet.name\r\n\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n // ---------------------------------------\r\n // S'il ne s'agit pas d'une nouvelle tache que l'on créé\r\n // on initialise l'ensemble des champs\r\n // ---------------------------------------\r\n\t\t\t\tlet jsonValue\t\t= this.currentTask.toJson();\r\n this.initialTask\t= Task.fromJsonObject(jsonValue);\r\n\r\n //initialisation des champs relatifs aux droits\r\n this.noAccessFile\t= this.currentTask.noAccessFile;\r\n this.canCreateFile\t= this.currentTask.canCreateFile;\r\n\r\n if (this.currentTask.noAccessFile === false)\r\n {\r\n this.readOnlyFile\t\t= this.currentTask.readOnlyFile;\r\n this.canDeleteFile\t\t= this.currentTask.canDeleteFile;\r\n this.typeFileAccess\t\t= this.currentTask.typeFileAccess;\r\n }\r\n else\r\n {\r\n this.readOnlyFile\t\t= false;\r\n this.canDeleteFile\t\t= false;\r\n this.typeFileAccess\t\t= 'all';\r\n this.selection\t\t\t= new SelectionModel(true, []);\r\n }\r\n\r\n }\r\n else\r\n {\r\n\r\n // ---------------------------------------\r\n // Si auncune tache n'est renseigné on considère qu'il s'agit d'un\r\n // ajout de tache\r\n // ---------------------------------------\r\n this.currentTask\t\t\t= new Task();\r\n this.currentTask.flags\t\t= ['inprogress'];\r\n\r\n this.currentIdSujet\t\t= this.workspaceData.selectedSujet.id;\r\n this.selectedSubject\t= this.workspaceData.getSujet(this.currentIdSujet);\r\n\t\t\t\tthis.scenarioList\t\t= this.workspaceData.selectedMatiere.scenario;\r\n\r\n\r\n if (this.workspaceData.selectedMatiere)\r\n {\r\n for (let sujet of this.workspaceData.selectedMatiere.sujets)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.subjectsAvailable.push(\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvalue:\t\tsujet.id,\r\n\t\t\t\t\t\t\t\tlibelle:\tsujet.name\r\n\t\t\t\t\t\t\t});\r\n }\r\n }\r\n\r\n\t\t\t\tthis.translate.get('editorPanel.formatedText1').subscribe((value1: string) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.translate.get('editorPanel.formatedText2').subscribe((value2: string) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.currentName = value1 + this.getTypeName() + value2 + this.workspaceData.selectedSujet.name;\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\r\n\r\n this.currentAssigneduser = 'none';\r\n this._initTaskParents();\r\n this.isTaskEdition = false;\r\n\r\n this.selection = new SelectionModel(true, []);\r\n }\r\n\r\n\r\n this.moFormCtrlName\t\t\t\t\t= this.fb.control(this.currentName,\t\t\tValidators.required);\r\n this.moFormCtrType\t\t\t\t\t= this.fb.control(this.currentType,\t\t\tValidators.required);\r\n this.moFormCtrSubject\t\t\t\t= this.fb.control(this.currentIdSujet,\t\tValidators.required);\r\n this.moFormCtrDescription\t\t\t= this.fb.control(this.currentDescription,\tValidators.required);\r\n this.moFormCtrEcheance\t\t\t\t= this.fb.control(this.dateEcheance,\t\tValidators.required);\r\n this.moFormCtrAssignedUser\t\t\t= this.fb.control(this.currentAssigneduser,\tValidators.required);\r\n this.moFormCtrNoAccessFile\t\t\t= this.fb.control(this.noAccessFile,\t Validators.required);\r\n this.moFormCtrCanCreateFile\t\t\t= this.fb.control(this.canCreateFile, Validators.required);\r\n\r\n this.moFormGroup = this.fb.group(\r\n\t\t\t\t{\r\n\t\t\t\t\tname:\t\t\tthis.moFormCtrlName,\r\n\t\t\t\t\ttype:\t\t\tthis.moFormCtrType,\r\n\t\t\t\t\tsubject:\t\tthis.moFormCtrSubject,\r\n\t\t\t\t\tdescription:\tthis.moFormCtrDescription,\r\n\t\t\t\t\tdateEcheance:\tthis.moFormCtrEcheance,\r\n\t\t\t\t\tassignedUser:\tthis.moFormCtrAssignedUser,\r\n\t\t\t\t\tnoAccessFile:\tthis.moFormCtrNoAccessFile,\r\n canCreateFile:\tthis.moFormCtrCanCreateFile\r\n });\r\n }\r\n }\r\n\t\r\n\r\n public ngOnInit()\r\n\t{\r\n this.moUserDataEmmiterSubscription = this.userData.globalEmitter.subscribe((value: string) =>\r\n\t\t{\r\n\t\t\tif (value === 'files::get')\r\n\t\t\t{\r\n this.initExistingFiles();\r\n }\r\n\r\n });\r\n this.initExistingFiles();\r\n }\r\n\r\n\r\n public ngOnDestroy()\r\n\t{\r\n this.moUserDataEmmiterSubscription.unsubscribe();\r\n\t}\r\n\r\n\r\n public initExistingFiles()\r\n {\r\n\r\n }\r\n\r\n\r\n /**\r\n *\r\n */\r\n public changeSelectedUser()\r\n {\r\n let selectedUser = _.find(this.usersAvailable, (user: any) => { return user.value === this.currentAssigneduser; });\r\n\r\n if (selectedUser)\r\n {\r\n if (selectedUser.loggedOnce === false)\r\n {\r\n this.unloggedUserSelected = true;\r\n this.dialog.open(WarningUnloggedUserModalComponent,\r\n\t\t\t\t{\r\n height:\t\t\t'auto',\r\n width:\t\t\t'auto',\r\n data:\t\t\t{},\r\n disableClose:\ttrue\r\n });\r\n\r\n }\r\n\t\t\telse\r\n {\r\n this.unloggedUserSelected = false;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Dans la partie droits, retourne vrai si tout les fichiers sont selectionnées dans\r\n * la table de selection des sujets\r\n */\r\n\tisAllSelected() \r\n\t{\r\n\t\tconst numSelected\t= this.selection.selected.length;\r\n\t\tconst numRows\t\t= this.filesSubject.objSubject.pj.length;\r\n\t\t\r\n\t\treturn numSelected === numRows;\r\n\t}\r\n\t\r\n\r\n /**\r\n * Dans l'interface des droits si on souhaite choisir les fichiers accessibles\r\n * Selectionne tous les fichiers dans le tableau s'ils ne sont pas déja tous selectionné.\r\n * Dans le cas contraire ils sont tous déselectionnés\r\n */\r\n\tmasterToggle()\r\n\t{\r\n\t\tthis.isAllSelected() ? this.selection.clear() : this.filesSubject.objSubject.pj.forEach((pj: any) => this.selection.select(pj));\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public close()\r\n {\r\n this.dialogRef.close();\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic validate()\r\n\t{\r\n\r\n\t\tthis.currentTask.name\t\t\t= this.currentName;\r\n\t\tthis.currentTask.type\t\t\t= this.currentType.toString();\r\n\t\tthis.currentTask.libelleType\t= this.getTypeName();\r\n\r\n\t\tthis.currentTask.idSujet\t\t= this.currentIdSujet;\r\n\t\tthis.currentTask.description\t= this.currentDescription;\r\n\t\tthis.currentTask.assigneduser\t= this.currentAssigneduser;\r\n\r\n\t\tthis.currentTask.noAccessFile\t= this.noAccessFile;\r\n\t\tthis.currentTask.canCreateFile\t= this.canCreateFile;\r\n\r\n\t\tif (this.currentTask.noAccessFile === false)\r\n\t\t{\r\n\t\t\tthis.currentTask.readOnlyFile\t= this.readOnlyFile;\r\n\t\t\tthis.currentTask.canDeleteFile\t= this.canDeleteFile;\r\n\t\t\tthis.currentTask.typeFileAccess = this.typeFileAccess;\r\n\t\t\tthis.currentTask.fileToAccess\t= _.map(this.selection.selected, (pj: any) => { return pj.id; });\r\n\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.currentTask.readOnlyFile\t= false;\r\n\t\t\tthis.currentTask.canDeleteFile\t= false;\r\n\t\t\tthis.currentTask.typeFileAccess\t= 'none';\r\n\t\t\tthis.currentTask.fileToAccess\t= [];\r\n\t\t}\r\n\r\n\r\n\t\tif (this.dateEcheance)\r\n\t\t{\r\n\t\t\tthis.currentTask.endDate = new Date(this.dateEcheance);\r\n\t\t}\r\n\r\n if (this.currentTask.assigneduser === 'none')\r\n {\r\n this.currentTask.assigneduser\t= '';\r\n this.currentTask.state\t\t\t= 'new';\r\n }\r\n else\r\n {\r\n this.currentTask.state = 'todo';\r\n }\r\n\r\n\t\t//Si c'est une édition on met la tache à jour\r\n\t\tif (this.isTaskEdition === true)\r\n\t\t{\r\n\t\t\tlet datasToUpdate = this._getDatasToUpdate(this.initialTask, this.currentTask);\r\n\t\t\tthis.taskService.updateTask(this.initialTask, datasToUpdate);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t//Sinon on l'ajoute en BDD\r\n\t\t\tthis.taskService.addTask(this.currentTask);\r\n\r\n\t\t\t//On récupère les clé aes des fichiers dont on donne les droits et on les ré-encode avec\r\n\t\t\t//la clé publique de l'utilisateur selectionné\r\n\t\t\tlet listFile: any[];\r\n\t\t\tif (this.currentTask.typeFileAccess === 'all')\r\n\t\t\t{\r\n\t\t\t\tlistFile = _.map(this.filesSubject.objSubject.pj, (pj: any) => { return pj.id });\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (this.currentTask.typeFileAccess === 'list')\r\n\t\t\t\t{\r\n\t\t\t\t\tlistFile = _.map(this.selection.selected, (pj: any) => { return pj.id; });\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (listFile && this.currentTask.assigneduser && this.currentTask.assigneduser !== '')\r\n\t\t\t{\r\n\t\t\t\tlet currentSubject = this.workspaceData.getSujet(this.currentTask.idSujet);\r\n\r\n\t\t\t\tthis.encryptService.encryptFilesForUSer(listFile, this.currentTask.assigneduser, currentSubject);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.dialogRef.close();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n public switch_tab(tabName: any)\r\n\t{\r\n this.itemSelected = tabName;\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n private _initTaskParents()\r\n {\r\n if (this.selectedClasseur)\r\n\t\t{\r\n this.currentTask.idEtablissement = this.selectedClasseur.id;\r\n\t\t}\r\n\r\n if (this.selectedSession)\r\n\t\t{\r\n this.currentTask.idSession = this.selectedSession.id;\r\n\t\t}\r\n\r\n if (this.selectedExamen)\r\n\t\t{\r\n this.currentTask.idExamen = this.selectedExamen.id;\r\n\t\t}\r\n\r\n if (this.selectedMatiere)\r\n\t\t{\r\n this.currentTask.idEpreuve = this.selectedMatiere.id;\r\n\t\t}\r\n }\r\n\r\n\r\n\tgetTypeName()\r\n\t{\r\n\t\tlet sReturn = '';\r\n\t\tif (this.scenarioList)\r\n\t\t{\r\n\t\t\tfor (let typeName of this.scenarioList.steps)\r\n\t\t\t{\r\n\t\t\t\tif (typeName.id === this.currentType)\r\n\t\t\t\t{\r\n\t\t\t\t\tsReturn = typeName.name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn sReturn;\r\n\t}\r\n\r\n\r\n\tmajTitle()\r\n\t{\r\n\t\tlet sujetId\t\t= this.currentIdSujet;\r\n\t\tlet sujetName\t= '';\r\n\r\n\t\tif (sujetId === 'new')\r\n\t\t{\r\n\t\t\tsujetName = 'Nouveau';\r\n\t\t\tthis.selectedSubject = undefined;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.selectedSubject\t= this.workspaceData.getSujet(sujetId);\r\n\t\t\tsujetName\t\t\t\t= this.selectedSubject.name;\r\n\t\t}\r\n\r\n\t\tthis.translate.get('editorPanel.formatedText1').subscribe((value1: string) =>\r\n\t\t{\r\n\t\t\tthis.translate.get('editorPanel.formatedText2').subscribe((value2: string) =>\r\n\t\t\t{\r\n\t\t\t\tthis.currentName = value1 + this.getTypeName() + value2 + sujetName;\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tcanValidateTask()\r\n\t{\r\n let result = true;\r\n\r\n if (!this.currentName || this.currentName === undefined || this.currentName === '')\r\n {\r\n result = false;\r\n }\r\n\r\n return result;\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n private _getDatasToUpdate(oldTask: Task, newTask: Task)\r\n {\r\n let datas: any = {};\r\n\r\n // ---------------------------------------\r\n // ToComment\r\n // ---------------------------------------\r\n if (oldTask.description !== newTask.description)\r\n {\r\n datas['description'] = newTask.description;\r\n }\r\n\r\n if (oldTask.name !== newTask.name)\r\n {\r\n datas['name'] = newTask.name;\r\n }\r\n\r\n if (oldTask.type !== newTask.type)\r\n {\r\n datas['type'] = newTask.type;\r\n }\r\n\r\n // ---------------------------------------\r\n // ToComment\r\n // ---------------------------------------\r\n if (oldTask.state !== newTask.state)\r\n {\r\n datas['state'] = newTask.state;\r\n }\r\n\r\n // ---------------------------------------\r\n // ToComment\r\n // ---------------------------------------\r\n if (oldTask.assigneduser !== newTask.assigneduser)\r\n {\r\n datas['assigneduser'] = newTask.assigneduser;\r\n //si l'utilisateur assigné est supprimé, on met automatiquement\r\n // la tache en non assigné\r\n if (datas['assigneduser'] === '')\r\n {\r\n datas['state'] = 'new';\r\n }\r\n else\r\n {\r\n //Si le nouvel utilisateur assigné est non vide et que le l'état initial\r\n //de la tache est non assigné alors on la met automatiquement à l'état assigné\r\n if (oldTask.state === 'new')\r\n {\r\n datas['state'] = 'todo';\r\n }\r\n }\r\n }\r\n\r\n if (oldTask.endDate.getTime() !== newTask.endDate.getTime())\r\n {\r\n datas['enddate'] = newTask.endDate;\r\n }\r\n\r\n if (oldTask.noAccessFile !== newTask.noAccessFile)\r\n {\r\n datas['noaccessfile'] = newTask.noAccessFile ? '1' : '0';\r\n }\r\n\r\n if (oldTask.canCreateFile !== newTask.canCreateFile)\r\n {\r\n datas['cancreatefile'] = newTask.canCreateFile ? '1' : '0';\r\n }\r\n\r\n if (oldTask.readOnlyFile !== newTask.readOnlyFile)\r\n {\r\n datas['readonlyfile'] = newTask.readOnlyFile ? '1' : '0';\r\n }\r\n\r\n if (oldTask.canDeleteFile !== newTask.canDeleteFile)\r\n {\r\n datas['candeletefile'] = newTask.canDeleteFile ? '1' : '0';\r\n }\r\n\r\n if (oldTask.typeFileAccess !== newTask.typeFileAccess)\r\n {\r\n datas['typefileaccess'] = newTask.typeFileAccess;\r\n }\r\n\r\n let intersectFiles = _.intersection(oldTask.fileToAccess, newTask.fileToAccess);\r\n\t\t\r\n if (oldTask.fileToAccess.length !== newTask.fileToAccess.length || intersectFiles.length !== oldTask.fileToAccess.length)\r\n {\r\n datas['filetoaccess'] = newTask.fileToAccess;\r\n }\r\n\r\n return datas;\r\n }\r\n}\r\n","\r\n ","// Angular\r\nimport { Component, OnInit, EventEmitter, Input, ViewEncapsulation } from '@angular/core';\r\n// Neoptec\r\nimport { Task }\t\t\t\tfrom '../../model/task';\r\nimport { TicketComponent }\tfrom '../ticket/ticket.component';\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'lane',\r\n\tinputs:\t\t\t['tasks', 'type', 'laneTitle', 'libelle'],\r\n\toutputs:\t\t['_onTicketEdit: onTicketEdit', '_onAddSubTicket: onAddSubTicket', '_onTicketRemove: onTicketRemove', '_onTicketSelect: onTicketSelect', '_onTicketFocus: onTicketFocus'],\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\thost:\t\t\t{ 'class': 'lane'\t},\r\n\ttemplateUrl:\t'./lane.component.html',\r\n\tstyleUrls:\t\t['./lane.component.css']\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class LaneComponent implements OnInit\r\n{\r\n\t@Input('tasks')\t\t\ttasks:\t\tTask[] = [];\r\n\t@Input() typeTicket: string;\r\n\t@Input('laneTitle')\t\tlaneTitle:\tany;\r\n\r\n\r\n\tpublic _onTicketEdit:\tEventEmitter = new EventEmitter();\r\n\tpublic _onTicketRemove:\tEventEmitter = new EventEmitter();\r\n\tpublic _onTicketSelect:\tEventEmitter = new EventEmitter();\r\n\tpublic _onTicketFocus:\tEventEmitter = new EventEmitter();\r\n\tpublic _onAddSubTicket:\tEventEmitter = new EventEmitter();\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Transmet l'event d'edition\r\n\t */\r\n\tpublic editTicket(task: Task)\r\n\t{\r\n\t\tthis._onTicketEdit.emit(task);\r\n\t}\r\n\r\n\t/**\r\n\t *\r\n\t * @param task\r\n\t */\r\n\tpublic addSubTicket(task: Task)\r\n\t{\r\n\t\tthis._onAddSubTicket.emit(task);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Transmet l'event de suppression\r\n\t */\r\n\tpublic removeTicket(task: Task)\r\n\t{\r\n\t\tthis._onTicketRemove.emit(task);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Transmet l'event de selection pour affichage détaillé\r\n\t */\r\n\tpublic selectTicket(task: Task)\r\n\t{\r\n\t\tthis._onTicketSelect.emit(task);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Focus => pour savoir qui a été Drag and dropé\r\n\t */\r\n\tpublic focusTicket(task: Task)\r\n\t{\r\n\t\tthis._onTicketFocus.emit(task);\r\n\t}\r\n}\r\n","\r\n\t
\r\n\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t
\r\n\r\n\t\t\t\t\t
{{task.nameEtablissement}} - {{task.nameSession}}
\r\n\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t Assigné(e) à
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\tAssigné(e) par
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\tDescription : {{task.name}}\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t
Echéance : \r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\r\n\t\t\t
\r\n\t\t \r\n\t
\r\n\t
\r\n\t\t
\r\n\t\t\t\r\n\t\t\t\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\tCréateur
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\tDate de création : {{task.dateCreation.toLocaleDateString()}} \r\n\t\t\t\t\t
\r\n\r\n\t\t\t\t\t
{{task.nameEpreuve}}
\r\n\t\t\t\t\t
{{task.state}}
\r\n\t\t\t\t
\r\n\r\n\t\t\t
\r\n\t\t \r\n\t
\r\n
\r\n","import { Component, OnInit, EventEmitter, ViewEncapsulation, Input } from '@angular/core';\r\nimport { WorkspaceData }\t\tfrom '../../../../providers/workspace-data';\r\nimport { Task as TaskClass}\tfrom '../../../../classes/task.class';\r\nimport { SavedData }\t\t\tfrom '../../../../providers/saved-data';\r\nimport { TaskData }\t\t\t\tfrom '../../../../providers/task-data';\r\nimport { UserData }\t\t\t\tfrom '../../../../providers/user-data';\r\nimport { Task }\t\t\t\t\tfrom '../../model/task';\r\nimport * as _\t\t\t\t\tfrom 'underscore';\r\nimport { Router }\t\t\t\tfrom '@angular/router';\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'ticket',\r\n\ttemplateUrl:\t'./ticket.component.html',\r\n\tinputs:\t\t\t['task'],\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\toutputs:\t\t['_editTicket: onEdit', '_addTicket: onAdd', '_removeTicket: onRemove', '_displayDetails: onSelect', '_focusTicket: onFocus'],\r\n\tstyleUrls:\t\t['./ticket.component.css']\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class TicketComponent implements OnInit\r\n{\r\n\ttask: Task;\r\n\t@Input()\t\ttypeTicket: string;\r\n\r\n\tpublic _editTicket:\t\t\tEventEmitter = new EventEmitter();\r\n\tpublic _removeTicket:\t\tEventEmitter = new EventEmitter();\r\n\tpublic _displayDetails:\t\tEventEmitter = new EventEmitter();\r\n\tpublic _focusTicket:\t\tEventEmitter = new EventEmitter();\r\n\tpublic _addTicket:\t\t\tEventEmitter = new EventEmitter();\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(\r\n\t\tpublic workspaceData:\tWorkspaceData,\r\n\t\tpublic userData:\t\tUserData,\r\n\t\tpublic savedData:\t\tSavedData,\r\n\t\tpublic router:\t\t\tRouter)\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t *\r\n\t *\r\n\t *\r\n\t */\r\n\tpublic ngOnInit()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic editTicket()\r\n\t{\r\n\t\tthis._editTicket.emit(this.task);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic addTicket()\r\n\t{\r\n\r\n\t\tthis._addTicket.emit(this.task);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic focusTicket()\r\n\t{\r\n\t\tthis._focusTicket.emit(this.task);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic removeTicket()\r\n\t{\r\n\t\tif (confirm(\"Confirmez vous la suppression de \" + this.task.name + ' ?' ))\r\n\t\t{\r\n\t\t\tthis._removeTicket.emit(this.task);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic selectTicket(evt: any)\r\n\t{\r\n\t\tif (evt)\r\n\t\t{\r\n\t\t\tevt.preventDefault();\r\n\t\t}\r\n\t\tthis._displayDetails.emit(this.task);\r\n\t}\r\n\r\n\t/**\r\n\t *\r\n\t * @param task\r\n\t */\r\n\tpublic addSubTask(task: any)\r\n\t{\r\n\t}\r\n\r\n\r\n\tpublic gotoSubject(idSujet: any)\r\n\t{\r\n\t\tthis.workspaceData.constructAutoTreeBySubjectId(idSujet);\r\n\t}\r\n\r\n\r\n\r\n\tpublic goToSubject(task: TaskClass)\r\n\t{\r\n\t\t// ===================================\r\n\t\t// Affectation des objets\r\n\t\t// ===================================\r\n\r\n\t\tthis.workspaceData.selectedSujet\t\t\t= this.workspaceData.getSujet(task.idSujet);\r\n\t\tthis.workspaceData.selectedMatiere\t\t\t= this.workspaceData.getEpreuve(task.idEpreuve);\r\n\t\tthis.workspaceData.selectedExamen\t\t\t= this.workspaceData.getExamen(task.idExamen);\r\n\t\tthis.workspaceData.selectedSession\t\t\t= this.workspaceData.getSession(task.idSession);\r\n\t\tthis.workspaceData.selectedEtablissement\t= this.workspaceData.getEtablissement(task.idEtablissement);;\r\n\r\n\t\tthis.workspaceData.selectedItems\t= [];\r\n\t\tthis.workspaceData.selectedItems[0] = this.workspaceData.selectedEtablissement.id;\r\n\t\tthis.workspaceData.selectedItems[1] = this.workspaceData.selectedSession.id;\r\n\t\tthis.workspaceData.selectedItems[2] = this.workspaceData.selectedExamen.id;\r\n\t\tthis.workspaceData.selectedItems[3] = this.workspaceData.selectedMatiere.id;\r\n\r\n\t\tthis.workspaceData.selectedTask\t\t= task;\r\n\t\tthis.workspaceData.selectedSegment\t= 'subject';\r\n\t\tthis.workspaceData.goToSubject\t\t= true;\r\n\t\tthis.savedData.lastGroup\t\t\t= 'task';\r\n\r\n\r\n\t\tif (this.userData.isAdmin() || this.userData.isSuperviseur() === true)\r\n\t\t{\r\n\t\t\tthis.savedData.lastGroup = 'epreuve';\r\n\t\t}\r\n\r\n\t\tthis.router.navigate(['/workspace']);\r\n \t}\r\n\r\n}\r\n","\r\n \r\n \r\n\r\n
\r\n\r\n
\r\n \r\n\t\t\t\t\t{{ user.libelle }} \r\n \r\n \r\n\r\n\t\t\t
\r\n\r\n\t\t\t
\r\n\t\t\t\t{{ 'selectAssigned.sendMail' | translate }} \r\n\t\t\t
\r\n
\r\n\r\n \r\n
\r\n \r\n","import { Component, ViewEncapsulation, Inject }\t\t\t\tfrom '@angular/core';\r\nimport { FormControl, FormBuilder, FormGroup, Validators }\tfrom '@angular/forms';\r\nimport { MatDialogRef }\t\t\t\t\t\t\t\t\t\tfrom '@angular/material';\r\nimport { MAT_DIALOG_DATA }\t\t\t\t\t\t\t\t\tfrom '@angular/material';\r\n\r\nimport { UserData }\t\t\tfrom '../../../providers/user-data';\r\n\r\n\r\n@Component({\r\n selector:\t\t'select-assigned',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n templateUrl:\t'select-assigned.component.html',\r\n styleUrls:\t\t['./select-assigned.component.scss']\r\n})\r\n\r\n\r\n/**\r\n * Modal permettant l'ajout d'un nouveau commentaire pour un élement donné\r\n */\r\nexport class SelectAssignedComponent\r\n{\r\n //Identifiant de l'élément concerné par le nouveau commentaire\r\n public _idElement: string;\r\n //objet Comment correspondant au commentaire en édition\r\n public _currentComment: Comment;\r\n\r\n public moFormUser:\t\t\tFormGroup;\r\n public moFormCtrlUser:\t\tFormControl;\r\n public moFormCtrlSendEmail:\tFormControl;\r\n public selectedUser:\t\tany;\r\n public sendEmail:\t\t\tboolean = false;\r\n public usersAvailable:\t\tany[] = [];\r\n\r\n\r\n constructor(public dialogRef: MatDialogRef,\r\n public fb: FormBuilder,\r\n public userData: UserData,\r\n @Inject(MAT_DIALOG_DATA) public data: any)\r\n\t{\r\n this.userData.getUsers();\r\n\r\n const allUsers: any = this.userData.getUsers();\r\n\r\n if (allUsers)\r\n {\r\n for (const key in allUsers)\r\n {\r\n if (allUsers[key])\r\n {\r\n let libelle = key;\r\n if (allUsers[key].infos && allUsers[key].infos.nom && allUsers[key].infos.prenom)\r\n {\r\n libelle = allUsers[key].infos.prenom + ' ' + allUsers[key].infos.nom;\r\n }\r\n\r\n\t\t\t\t\tthis.usersAvailable.push(\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvalue:\t\tkey,\r\n\t\t\t\t\t\t\tlibelle:\tlibelle\r\n\t\t\t\t\t\t});\r\n\t\t\t\t}\r\n }\r\n }\r\n\r\n\r\n this.moFormCtrlUser\t\t\t= this.fb.control(this.selectedUser, Validators.required);\r\n this.moFormCtrlSendEmail\t= this.fb.control(this.sendEmail);\r\n\r\n this.moFormUser = this.fb.group(\r\n {\r\n user:\t\tthis.moFormCtrlUser,\r\n sendEmail:\tthis.moFormCtrlSendEmail\r\n });\r\n\r\n\r\n if (data)\r\n {\r\n if (data.sendMailDefaultValue)\r\n {\r\n this.sendEmail = data.sendMailDefaultValue;\r\n }\r\n }\r\n\t}\r\n\r\n\r\n\tpublic cancel()\r\n {\r\n this.dialogRef.close(null);\r\n }\r\n\r\n\r\n public canValidate()\r\n {\r\n let result = false;\r\n\r\n if (this.selectedUser !== undefined && this.selectedUser !== '')\r\n {\r\n result = true;\r\n }\r\n\r\n return result;\r\n }\r\n\r\n\r\n public vadidateUser()\r\n {\r\n const result: any = {};\r\n result.user = this.selectedUser;\r\n\r\n if (this.sendEmail === true)\r\n {\r\n result.typeEmail = 'newTask';\r\n }\r\n\r\n this.dialogRef.close(result);\r\n }\r\n}\r\n","\r\n \r\n \r\n\r\n
\r\n
\r\n\t\t\t\t
{{ 'sendMail.infos' | translate }} \r\n\t\t\t\t
\r\n\r\n
{{ 'sendMail.sendMail' | translate }} \r\n
\r\n
\r\n\r\n \r\n
\r\n \r\n","import { Component, ViewEncapsulation, Inject }\t\t\t\tfrom '@angular/core';\r\nimport { FormControl, FormBuilder, FormGroup, Validators }\tfrom '@angular/forms';\r\nimport { MatDialogRef }\t\t\t\t\t\t\t\t\t\tfrom '@angular/material';\r\nimport { MAT_DIALOG_DATA }\t\t\t\t\t\t\t\t\tfrom '@angular/material';\r\n\r\n\r\n@Component({\r\n selector:\t\t'send-mail-modal',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n templateUrl:\t'sendMailModal.component.html',\r\n styleUrls:\t\t['./sendMailModal.component.scss']\r\n})\r\n\r\nexport class SendMailModalComponent\r\n{\r\n public moFormMail:\t\t\tFormGroup;\r\n public moFormCtrlSendEmail: FormControl;\r\n\r\n public sendEmail: boolean = false;\r\n\r\n constructor(public dialogRef:\tMatDialogRef,\r\n public fb:\t\t\tFormBuilder,\r\n @Inject(MAT_DIALOG_DATA) public data: any)\r\n {\r\n\t\t\r\n this.moFormCtrlSendEmail\t= this.fb.control(this.sendEmail);\r\n this.moFormMail\t\t\t\t= this.fb.group(\r\n {\r\n sendEmail: this.moFormCtrlSendEmail\r\n });\r\n }\r\n\t\r\n\r\n public cancel()\r\n {\r\n this.dialogRef.close(null);\r\n }\r\n\t\r\n\r\n public vadidateMail()\r\n {\r\n const result: any = \r\n\t\t{\r\n sendMail: this.sendEmail\r\n };\r\n\t\t\r\n this.dialogRef.close(result);\r\n }\r\n}\r\n","\r\n\t\r\n\t\r\n\t\t
\r\n\t\t\t{{ 'warningUser.texte1' | translate }} \r\n\t\t\t
\r\n\t\t\t{{ 'warningUser.texte2' | translate }} \r\n\t\t\t
\r\n\t\t \r\n
\r\n\t\r\n ","import { Component, ViewEncapsulation }\tfrom '@angular/core';\r\nimport { MatDialogRef }\t\t\t\t\tfrom '@angular/material';\r\n\r\n@Component({\r\n\tselector:\t\t'warning-unlogged-user-modal',\r\n\ttemplateUrl:\t'warningUnloggedUserModal.component.html',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\tstyleUrls:\t\t['./warningUnloggedUserModal.component.scss']\r\n})\r\n\r\nexport class WarningUnloggedUserModalComponent\r\n{\r\n\t\r\n constructor(public dialogRef: MatDialogRef)\r\n {\r\n\t}\r\n\r\n public validate()\r\n {\r\n this.dialogRef.close();\r\n }\r\n public cancel()\r\n {\r\n this.dialogRef.close();\r\n }\r\n}","export class Task\r\n{\r\n\r\n\tpublic static fromJsonObject(jsonObj: any): Task\r\n {\r\n\t\treturn new Task(0);\r\n\t}\r\n\t\r\n\t\r\n\tconstructor(\r\n\t\tpublic id:\t\t\t\tnumber,\r\n\t\tpublic name:\t\t\tstring = '',\r\n\t\tpublic description:\t\tstring = '',\r\n\t\tpublic status:\t\t\tstring = 'todo',\r\n\t\tpublic priority:\t\tnumber = 2,\r\n\t\tpublic dateCreation:\tstring = '',\r\n\t\tpublic dateUpdate:\t\tstring = '',\r\n\t\tpublic points:\t\t\tnumber = 0\r\n\t) { }\r\n\r\n\r\n\tpublic newTask: boolean;\r\n\r\n\r\n\tpublic toJson()\r\n {\r\n\t}\r\n}\r\n","// Angualr\r\nimport { Pipe, PipeTransform } from '@angular/core';\r\n// Neoptec\r\nimport { Task }\t\tfrom '../../../classes/task.class';\r\n\r\n\r\n@Pipe({\r\n\tname: 'tasksFilter',\r\n\t// Pure make the pipe becomes stateful pipe\r\n\t// By default it's value is true which is stateless, data will be fetch only 1 time\r\n\tpure: false\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class TaskFilterPipe implements PipeTransform\r\n{\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic transform(value: Task[], key: string, val: string): Task[]\r\n\t{\r\n\r\n\t\tif (typeof key === 'undefined' || typeof val === 'undefined')\r\n\t\t{\r\n\t\t\treturn value;\r\n\t\t}\r\n\r\n\t\tif (value)\r\n\t\t{\r\n\t\t\treturn value.filter((task: any) => task[key] == val);\r\n\t\t}\r\n\t}\r\n}\r\n\r\n","// Angular\r\nimport { Injectable }\t\t\t\tfrom '@angular/core';\r\nimport { Http, Headers, Response }\tfrom '@angular/http';\r\nimport {Observable}\t\t\t\t\tfrom 'rxjs/Rx';\r\n// Noeptec\r\nimport { Task }\t\t\t\t\t\tfrom '../model/task';\r\nimport { ISocketData, SocketWhat }\tfrom '../../../models/message.model';\r\nimport { SocketService }\t\t\tfrom '../../../services/socket.service';\r\nimport { UserData }\t\t\t\t\tfrom '../../../providers/user-data';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class TaskService\r\n{\r\n\tpublic tasks:\t\tTask[] = [];\r\n\tpublic urlTask:\t\tstring = 'http://192.168.0.24:3004/tasks';\r\n\tpublic socket:\t\tany;\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(\r\n\t\tpublic socketService: SocketService,\r\n\t\tpublic userData: UserData,\r\n\t\tpublic http: Http\r\n\t)\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * retourne la liste des taches\r\n\t */\r\n\tpublic getTasks()\r\n\t{\r\n\t\treturn new Promise(resolve =>\r\n\t\t{\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// ToComment\r\n\t\t\t// ---------------------------------------\r\n\t\t\tthis.http.get(this.urlTask).map(res => res.json()).subscribe(data =>\r\n\t\t\t{\r\n\t\t\t\tlet task: Task;\r\n\t\t\t\tfor (task of data)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.tasks.push(new Task(task.id, task.name, task.description, task.status, task.priority, task.dateCreation, task.dateUpdate, task.points));\r\n\t\t\t\t}\r\n\t\t\t\tresolve(this.tasks);\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic removeTask(taskId: number)\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// On remove la task du tableau\r\n\t\t// ---------------------------------------\r\n\t\tlet array: Task[]\t= this.tasks.filter(item => { return item.id !== taskId });\r\n\t\tthis.tasks\t\t\t= array;\r\n\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\t// Création de l'url de suppression\r\n\t\tlet url = this.urlTask + '/' + taskId;\r\n\t\t\r\n\t\treturn this.http.delete(url);\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic updateTask(task: Task)\r\n\t{\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\tlet credentials =\r\n\t\t\t{\r\n\t\t\t\t\"id\":\t\t\t\ttask.id,\r\n\t\t\t\t\"name\":\t\t\t\ttask.name,\r\n\t\t\t\t\"description\":\t\ttask.description,\r\n\t\t\t\t\"status\":\t\t\ttask.status,\r\n\t\t\t\t\"dateCreation\":\t\ttask.dateCreation,\r\n\t\t\t\t\"dateUpdate\":\t\ttask.dateUpdate,\r\n\t\t\t\t\"priority\":\t\t\ttask.priority,\r\n\t\t\t\t\"points\":\t\t\ttask.points\r\n\t\t\t};\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Si la tache est nouvelle on l'enregistre, sinon on met à jour\r\n\t\t// ---------------------------------------\r\n\r\n\t\t// ADD\r\n\t\tif (task.newTask)\r\n\t\t{\r\n\t\t\ttask.newTask = false;\r\n\t\t\tthis.tasks.push(task)\r\n\t\t\tlet sUserId = this.userData.getUserId();\r\n\t\t\tlet eSocketWhat: SocketWhat.request;\r\n\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.socket = socket;\r\n\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t\t\t'name':\tsUserId,\r\n\t\t\t\t\t\t\t'what':\teSocketWhat,\r\n\t\t\t\t\t\t\t'cmd':\t'tasks',\r\n\t\t\t\t\t\t\t'args': { tasks: credentials }\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('create', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n//\t\t\treturn this.http.post(this.urlTask, JSON.stringify(credentials), { headers: headers }).map((res: Response) => res.json());\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t// MAJ\r\n\t\t\t// Mise à jours de la liste des taches\r\n\t\t\tfor (let nIndice = 0; nIndice < this.tasks.length; nIndice++)\r\n\t\t\t{\r\n\t\t\t\tif (this.tasks[nIndice].id === task.id)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.tasks[nIndice] = task;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn this.http.put(this.urlTask + '/' + task.id, JSON.stringify(credentials), { headers: headers }).map((res: Response) => res.json());\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic dispatchPromise(callback: any)\r\n\t{\r\n\t\tlet promise = new Promise(function (resolve)\r\n\t\t{\r\n\t\t\tresolve(callback());\r\n\t\t});\r\n\r\n\t\treturn promise;\r\n\t}\r\n}\r\n","\r\n\t
\r\n\t\t\r\n\t\t\t \r\n\t\t \r\n\t
\r\n\r\n\t
\r\n\t\t \r\n\t\t\t\r\n\r\n\t\t\t\r\n\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
{{ 'task.unassigned' | translate }}
\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t \r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t
\r\n\r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
\r\n\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
{{state.libelle}}
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
\r\n\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
{{state.name}}
\r\n\r\n\t\t\t\t\t\t\t\t\t
\r\n\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
\r\n\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
{{user}}
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t\t
\r\n\t\t\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t
\r\n\r\n\r\n\t\t\t\r\n\r\n\t\t \r\n\t \r\n\r\n
\r\n","import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';\r\nimport { Router } from '@angular/router';\r\n\r\nimport { Task } \t\t\t\t\tfrom '../../classes/task.class';\r\n\r\nimport { EtablissementService } \tfrom '../../services/etablissement.service';\r\nimport { SocketService }\t\t\tfrom '../../services/socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../../models/message.model';\r\nimport { TaskService }\t\t\t\tfrom '../../services/task.service';\r\nimport { MessagesService }\t\t\tfrom '../../services/messages.service';\r\nimport { AppComponent }\t\t\t\tfrom '../../app.component';\r\nimport { UserData }\t\t\t\t\tfrom '../../providers/user-data';\r\nimport { AdminData }\t\t\t\tfrom '../../providers/admin-data';\r\nimport { WorkspaceData }\t\t\tfrom '../../providers/workspace-data';\r\nimport { TaskData } \t\t\t\tfrom '../../providers/task-data';\r\nimport { MatDialog }\t\t\t\tfrom '@angular/material';\r\n\r\nimport { EditorPanelTaskComponent }\t\tfrom './components/editor-panel-task/editor-panel-task.component';\r\nimport { EditorPanelComponent }\t\t\tfrom './components/editor-panel/editor-panel.component';\r\nimport { SelectAssignedComponent }\t\tfrom './modal/select-assigned.component';\r\nimport { SendMailModalComponent }\t\tfrom './modal/sendMailModal.component';\r\nimport { ValidateTaskModalComponent }\tfrom '../../pages/workspace/subject/subject-list/modal/validateTaskModal/validateTaskModal.component';\r\n\r\nimport { TranslateService } from '@ngx-translate/core';\r\nimport { DragulaService }\tfrom 'ng2-dragula/ng2-dragula';\r\nimport * as _\t\t\t\tfrom 'underscore';\r\nimport {Observable}\t\t\tfrom 'rxjs/Rx';\r\n\r\n\r\n@Component({\r\n\tselector:\t\t'app-task',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\ttemplateUrl:\t'./task.component.html',\r\n\tstyleUrls:\t\t['./task.component.scss']\r\n})\r\n\r\n\r\nexport class TaskComponent implements OnInit, OnDestroy\r\n{\r\n\tpublic tasksByUser:\t\t\tany\t\t\t= {};\r\n\tpublic tasksByGroup:\t\tany\t\t\t= {};\r\n\tpublic lastTasksByGroup:\tany\t\t\t= {};\r\n\tpublic usersTask:\t\t\tstring[]\t= [];\r\n\tpublic structureSubjects:\tany[]\t\t= [];\r\n\tpublic usersAvailable:\t\tany[]\t\t= [];\r\n\tpublic scenariosAvailable:\tany[]\t\t= [];\r\n\tpublic ticketByWorkflow:\tany[]\t\t= [];\r\n\tpublic showFab:\t\t\t\tboolean\t\t= false;\r\n\tpublic tasksLoaded:\t\t\tboolean\t\t= false;\r\n\tpublic updating:\t\t\tboolean\t\t= false;\r\n\tpublic kanbanTypeSelected:\tstring\t\t= 'state';\r\n\tpublic isLoading:\t\t\tboolean\t\t= false;\r\n\r\n\tpublic selectedTask:\t\t\tTask;\r\n\tpublic editingTask:\t\t\t\tTask;\r\n\tpublic isEditorPanelActive:\t\tboolean;\r\n\tpublic focusedTask:\t\t\t\tTask;\r\n\tpublic dropSubscription:\t\tany;\r\n public titleScenarioSelected:\tany;\r\n public scenarioSelected:\t\tany;\r\n\tpublic moTaskDataSubscription:\tany;\r\n\tselectedEtablissementId:\t\tany;\r\n\r\n\t/**\r\n\t * Types de diagrammes kanban qui seront selectionnables\r\n\t * dans le select en haut à gauche de l'interface des tâches\r\n\t */\r\n\tpublic kanbanTypes: any = [];\r\n\r\n\r\n//\t/**\r\n//\t * Ensemble des états disponibles.\r\n//\t * Correspond aux colonnes du diagramme kanban lorsque le kanban de type\r\n//\t * Etat est selectionné\r\n//\t */\r\n\tpublic statesAvailable: any = [];\r\n\r\n\r\n\t/**\r\n\t * Ensemble des status disponibles.\r\n\t * Correspond aux colonnes du diagramme kanban lorsque le kanban de type\r\n\t * Status est selectionné\r\n\t */\r\n\tpublic typeAvailable = [\r\n\t\t{\r\n\t\t\t/* Correspond à des tâches de rédaction de sujets assignées à un ou plusieurs utilisateurs */\r\n\t\t\tvalue:\t\t'redaction',\r\n\t\t\tlibelle:\t'Rédaction'\r\n\t\t},\r\n\t\t{\r\n\t\t\t/** Correspond à des tâches de tests de sujets en conditions réélles par un ou plusieurs utilisateurs\r\n\t\t\t * assignés\r\n\t\t\t */\r\n\t\t\tvalue:\t\t'test',\r\n\t\t\tlibelle:\t'Test'\r\n\t\t},\r\n\t\t{\r\n\t\t\t/** Correspond à des tâches de validation de sujets assignées à un ou plusieurs membres de jury */\r\n\t\t\tvalue:\t\t'miseEnPage',\r\n\t\t\tlibelle:\t'Mise en page'\r\n\t\t},\r\n\t\t{\r\n\t\t\t/** Correspond à des tâches de validation de sujets assignées à un ou plusieurs membres de jury */\r\n\t\t\tvalue:\t\t'verification',\r\n\t\t\tlibelle:\t'Vérification finale'\r\n\t\t}\r\n\t];\r\n\r\n\r\n\tpublic options: any =\r\n\t{\r\n\t\taccepts: (el: any, target: any, source: any, sibling: any) =>\r\n\t\t{\r\n\t\t\tlet result = true;\r\n\t\t\t// Un simple utilisateur ne peux pas déplacer une tache vers l'état 'non assignées' ou 'Terminées'\r\n\t\t\t// ou qui est déja en état 'non assignées' ou 'Terminées'\r\n\t\t\tif (this.userData.isAdmin() === false && this.userData.isSuperviseur() === false)\r\n\t\t\t{\r\n\t\t\t\tif (target && target.id && source && source.id)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (target.id === 'new' || target.id === 'done' || target.id === 'todo' || source.id === 'new' || source.id === 'done')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult = false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\treturn result;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tconstructor(\r\n\t\tpublic _router:\t\t\t\t\tRouter,\r\n\t\tpublic _taskService:\t\t\tTaskService,\r\n\t\tpublic etablissementService:\tEtablissementService,\r\n\t\tpublic socketService:\t\t\tSocketService,\r\n\t\tpublic messagesService:\t\t\tMessagesService,\r\n\t\tpublic appComponent:\t\t\tAppComponent,\r\n\t\tpublic dragulaService:\t\t\tDragulaService,\r\n\t\tpublic userData:\t\t\t\tUserData,\r\n\t\tpublic taskData:\t\t\t\tTaskData,\r\n\t\tpublic adminData:\t\t\t\tAdminData,\r\n\t\tpublic workspaceData:\t\t\tWorkspaceData,\r\n\t\tpublic dialog:\t\t\t\t\tMatDialog,\r\n\t\tpublic translate: \t\t\t\tTranslateService)\r\n\t{\r\n\t\tthis.translate.get('task.pageTitle').subscribe((value: string) => {\r\n\t\t\tappComponent.setPageTitle(value);\r\n\t\t});\r\n\r\n\t\tthis._initKanbanTypes();\r\n\t\tthis._initStatesAvailable();\r\n\r\n\t\tthis._applyTasksByUser();\r\n\t\tthis._applyTasksByGroup();\r\n\r\n\t\t//usersAvailable\r\n\t\t/**\r\n\t\t * On effectue un appel socket vers le serveur pour récupérer les utilisateurs disponibles\r\n\t\t */\r\n\t\tthis.usersAvailable = this.userData.getUsers();\r\n\t}\r\n\r\n\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis._initTasks();\r\n\t\tthis._initParameters();\r\n\t\tthis.dropSubscription = this.dragulaService.drop.subscribe((el: any) =>\r\n\t\t{\r\n\r\n\t\t\t//Si lors du drop la colonne d'arrivée est la même que la colonne de départ on ne fait rien\r\n\t\t\t//sinon on applique les changements\r\n\t\t\t\r\n\t\t\tif (el[2].id !== el[3].id)\r\n\t\t\t{\r\n\t\t\t\tif(el[3].id === \"done\")\r\n\t\t\t\t{\r\n\t\t\t\t\t/*************************************** \r\n\t\t\t\t\t * Avertissement demandant confirmation de la supression des taches suivante\r\n\t\t\t\t\t***************************************/\r\n\t\t\t\t\t\r\n\r\n\t\t\t\t\t/*************************************** \r\n\t\t\t\t\t * Si oui on supprime les taches suivante\r\n\t\t\t\t\t***************************************/\r\n\r\n\r\n\t\t\t\t\t/*************************************** \r\n\t\t\t\t\t * Si non on remet la tache dans sa colonne\r\n\t\t\t\t\t***************************************/\r\n\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tlet mustChooseAssigned\t\t\t= false;\r\n\t\t\t\t\tlet mustDisplayValidationForm\t= false;\r\n\t\t\t\t\tlet mustShowSendMailModal\t\t= false;\r\n\r\n\t\t\t\t\t// Todo => Rajouter l'update \r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t// Récupération de la lane pour mettre à jour la task en cours\r\n\t\t\t\t\t// el[0] le type de lane\r\n\t\t\t\t\t// el[2] la nouvelle lane\r\n\t\t\t\t\t// el[3] l'ancienne lane \r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\tif (this.focusedTask && !this.updating)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.focusedTask.newTask = false;\r\n\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t// On créer un objet resSubmit contenant dans un premier temps la tâche qui a été déplacée\r\n\t\t\t\t\t\t// par drag and drop\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\tlet resSubmit: any =\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\ttask:\tthis.focusedTask,\r\n\t\t\t\t\t\t\t\tdatas:\tundefined\r\n\t\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t// \tSi on est dans un kanban de type Etat\r\n\t\t\t\t\t\t// on met à jour le le champ state de la tache courante qui à été\r\n\t\t\t\t\t\t// déplacée dans le tableau\r\n\t\t\t\t\t\t// On met à jour l'objet resSubmit avec le nouvel état de la tâche déplacée\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\tif (el[0] === 'state')\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (el[3].id === 'new')\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tmustChooseAssigned = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (el[3].id !== 'done' && (el[2].id === 'done' || el[2].id === 'review'))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tmustDisplayValidationForm = true;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (el[2].id === 'new')\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tmustShowSendMailModal = true;\r\n\t\t\t\t\t\t\t} \r\n\t\t\t\t\t\t\tresSubmit.datas =\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tstate:\t\tel[2].id,\r\n\t\t\t\t\t\t\t\t\toldState:\tel[3].id\r\n\t\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\t\tthis.focusedTask.state = el[2].id;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t// Si on est dans un kanban de type Status\r\n\t\t\t\t\t\t\t// on met à jour le le champ status de la tache courante qui à été\r\n\t\t\t\t\t\t\t// déplacée dans le tableau\r\n\t\t\t\t\t\t\t// On met à jour l'objet resSubmit avec le nouveau status de la tâche déplacée\r\n\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\tif (el[0] === 'status')\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresSubmit.datas =\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\ttype: el[2].id\r\n\t\t\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\t\t\tthis.focusedTask.type = el[2].id;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\t// Si on est dans un kanban de type Utilisateur\r\n\t\t\t\t\t\t\t\t// on met à jour le le champ assigneduser de la\r\n\t\t\t\t\t\t\t\t// tache courante qui à été\r\n\t\t\t\t\t\t\t\t// déplacée dans le tableau\r\n\t\t\t\t\t\t\t\t// On met à jour l'objet resSubmit avec le nouvel\r\n\t\t\t\t\t\t\t\t// utilisateur assigné de la tâche déplacée\r\n\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\tif (el[0] === 'user')\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tresSubmit.datas =\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tassigneduser: el[2].id\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tthis.focusedTask.assigneduser = el[2].id;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t// On appelle la function permettant la mise à jour en bdd de la tâche déplacée.\r\n\t\t\t\t\t\t// Si initialiement la tache était dans l'état 'non assigné' on affiche une modale pour\r\n\t\t\t\t\t\t// sélectionner l'utilisateur assigné\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\tif (mustChooseAssigned === true)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.translate.get('task.textTaskAssigned').subscribe((value1: string) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tthis.translate.get('task.echeance').subscribe((value2: string) =>\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tconst dialogRef = this.dialog.open(SelectAssignedComponent,\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\t\t\theight:\t\t\t'40%',\r\n\t\t\t\t\t\t\t\t\t\twidth:\t\t\t'50%',\r\n\t\t\t\t\t\t\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tsendMailDefaultValue: true\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t\t\tdialogRef.afterClosed().subscribe((result: any) =>\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif (result && result.user)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tresSubmit.datas.assigneduser = result.user;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tif (result.typeEmail)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tconst currentExamen\t\t= this.workspaceData.getExamen(this.focusedTask.idExamen);\r\n\t\t\t\t\t\t\t\t\t\t\t\tconst currentEpreuve\t= this.workspaceData.getEpreuve(this.focusedTask.idEpreuve);\r\n\t\t\t\t\t\t\t\t\t\t\t\tconst currentSujet\t\t= this.workspaceData.getSujet(this.focusedTask.idSujet);\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\tresSubmit.datas.datasEmail =\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnomEtape:\tresSubmit.task.typeLib,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnomExamen:\tcurrentExamen\t\t\t? currentExamen.name\t: '',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnomEpreuve: currentEpreuve\t\t\t? currentEpreuve.name\t: '',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tnomSujet:\tcurrentSujet\t\t\t? currentSujet.name\t\t: ''\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\t\t\t\t\t\t\tresSubmit.datas.typeMail = result.typeEmail;\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tthis.submitTaskChange(resSubmit);\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t//Si aucun utilisateur n'est selectionné\r\n\t\t\t\t\t\t\t\t\t\t\t//on replace la tache a son emplacement initial\r\n\t\t\t\t\t\t\t\t\t\t\tthis.focusedTask.state = el[3].id;\r\n\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (mustDisplayValidationForm === true)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlet heightModal;\r\n\t\t\t\t\t\t\t\tif (el[2].id === 'review')\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\theightModal = '65vh';\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\theightModal = '75vh';\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t//On modifie l'état de la tache pour la modale de validation\r\n\t\t\t\t\t\t\t\tlet oldState;\r\n\t\t\t\t\t\t\t\tif (el[2].id === 'done')\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\toldState = 'review';\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\toldState = 'inprogress';\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\tlet dialogRefValidateTask = this.dialog.open(ValidateTaskModalComponent,\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\theight:\t\t\theightModal,\r\n\t\t\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\t\t\twidth:\t\t\t'650px',\r\n\r\n\t\t\t\t\t\t\t\t\t\tdisableClose: true,\r\n\t\t\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t'task':\t\tresSubmit.task,\r\n\t\t\t\t\t\t\t\t\t\t\t'state':\toldState\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t\t\tdialogRefValidateTask.afterClosed().subscribe((newTask: any) =>\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t/**\r\n\t\t\t\t\t\t\t\t\t\t * Si une nouvelle tache doit être créée après la validation\r\n\t\t\t\t\t\t\t\t\t\t * on ouvre la modale de création de tache\r\n\t\t\t\t\t\t\t\t\t\t */\r\n\t\t\t\t\t\t\t\t\t\tlet selectedItems: any[] =\r\n\t\t\t\t\t\t\t\t\t\t\t[\r\n\t\t\t\t\t\t\t\t\t\t\t\tresSubmit.task.idEtablissement,\r\n\t\t\t\t\t\t\t\t\t\t\t\tresSubmit.task.idSession,\r\n\t\t\t\t\t\t\t\t\t\t\t\tresSubmit.task.idExamen,\r\n\t\t\t\t\t\t\t\t\t\t\t\tresSubmit.task.idEpreuve\r\n\t\t\t\t\t\t\t\t\t\t\t];\r\n\r\n\t\t\t\t\t\t\t\t\t\tif (newTask !== undefined)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tlet dialogRefCreateTask = this.dialog.open(EditorPanelTaskComponent,\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\theight:\t\t\t'80%',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth:\t\t\t'80%',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'selectedItems':\tselectedItems,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'oldTask':\t\t\tresSubmit.task,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'task':\t\t\t\tnewTask,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'isEdition':\t\tfalse\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tdialogRefCreateTask.afterClosed().subscribe((result: any) =>\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t//Si on annule on remet la tache à l'état précédent\r\n\t\t\t\t\t\t\t\t\t\t\tthis.focusedTask.state = el[3].id;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (mustShowSendMailModal === true)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tthis.translate.get('task.textTaskUnassigned1').subscribe((value1: string) => {\r\n\t\t\t\t\t\t\t\t\t\tthis.translate.get('task.textTaskUnassigned2').subscribe((value2: string) => {\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tconst dialogRefSendMail = this.dialog.open(SendMailModalComponent,\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\theight:\t\t\t'30%',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth:\t\t\t'30%',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tdata:\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{}\r\n\t\t\t\t\t\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tdialogRefSendMail.afterClosed().subscribe((result: any) =>\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tif (result)\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (result.sendMail === true)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tconst currentSujet = this.workspaceData.getSujet(this.focusedTask.idSujet);\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresSubmit.datas.typeMail\t= 'unassignedTask';\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresSubmit.datas.datasEmail\t=\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnomSujet: currentSujet ? currentSujet.name : '',\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tnomEtape: resSubmit.task.typeLib\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis.submitTaskChange(resSubmit);\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t//Si aucun utilisateur n'est selectionné\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t//on replace la tache a son emplacement initial\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tthis.focusedTask.state = el[3].id;\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tthis.submitTaskChange(resSubmit);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t});\r\n\r\n\r\n\t\tthis.moTaskDataSubscription = this.taskData.taskDataEmitter.subscribe((values: any) =>\r\n\t\t{\r\n\t\t\tif (values === 'task::update')\r\n\t\t\t{\r\n\t\t\t\tthis._initParameters();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedEtablissement(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedEtablissement = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\r\n\t\t\tthis.workspaceData.resetSelectedSession();\r\n\t\t\tthis.workspaceData.resetSelectedExamen();\r\n\t\t\tthis.workspaceData.resetSelectedMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedSujet();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.resetSelectedEtablissement();\r\n\t\t\tthis.workspaceData.resetSelectedSession();\r\n\t\t\tthis.workspaceData.resetSelectedExamen();\r\n\t\t\tthis.workspaceData.resetSelectedMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedSujet();\r\n\t\t}\r\n\r\n\t\tthis.taskData.filterTasks('etab', id);\r\n\t}\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedSession(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedSession = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\r\n\t\t\tthis.workspaceData.resetSelectedExamen();\r\n\t\t\tthis.workspaceData.resetSelectedMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedSujet();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.resetSelectedSession();\r\n\t\t\tthis.workspaceData.resetSelectedExamen();\r\n\t\t\tthis.workspaceData.resetSelectedMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedSujet();\r\n\t\t}\r\n\r\n\t\tthis.taskData.filterTasks('sess', id);\r\n\r\n\t}\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedExamen(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedExamen = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\t\t\tthis.workspaceData.resetSelectedMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedSujet();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\r\n\t\t\tthis.workspaceData.resetSelectedExamen();\r\n\t\t\tthis.workspaceData.resetSelectedMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedSujet();\r\n\t\t}\r\n\r\n\t\tthis.taskData.filterTasks('exam', id);\r\n\r\n\t}\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedMatiere(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedMatiere = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\t\t\tthis.workspaceData.resetSelectedSujet();\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.resetSelectedMatiere();\r\n\t\t\tthis.workspaceData.resetSelectedSujet();\r\n\t\t}\r\n\r\n\t\tthis.taskData.filterTasks('matiere', id);\r\n\r\n\t}\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic changeSelectedSujet(event: any)\r\n\t{\r\n\t\tthis.workspaceData.selectedSujet = event;\r\n\r\n\t\tlet id = null;\r\n\t\tif (event && event.id)\r\n\t\t{\r\n\t\t\tid = event.id;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.workspaceData.selectedSujet = null;\r\n\t\t}\r\n\r\n\t\tthis.taskData.filterTasks('suj', id);\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic ngOnDestroy()\r\n\t{\r\n\t\t//On désactive la souscription aux evènement de drop lorsque l'on quitte la page\r\n\t\t//Permet de ne pas multiplier les mêmes appels\r\n\t\tif (this.dropSubscription)\r\n\t\t{\r\n\t\t\tthis.dropSubscription.unsubscribe();\r\n\t\t}\r\n\r\n\t\tif (this.moTaskDataSubscription)\r\n\t\t{\r\n\t\t\tthis.moTaskDataSubscription.unsubscribe();\r\n\t\t}\r\n\t}\r\n\r\n\tpublic processRoute()\r\n\t{\r\n\t\tlet routeParams = this.getRouteParams();\r\n\t}\r\n\r\n\tpublic getRouteParams(): any\r\n\t{\r\n\t\treturn null;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic editTicket(task: Task)\r\n\t{\r\n\t\tthis.messagesService.getMessages(task.id, 'tasks');\r\n\t\tthis.taskData.listenTask(task);\r\n\t\tlet dialogRef = this.dialog.open(EditorPanelTaskComponent,\r\n\t\t\t{\r\n\t\t\t\theight:\t\t\t'80%',\r\n\t\t\t\twidth:\t\t\t'80%',\r\n\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\tdata:\r\n\t\t\t\t{\r\n\t\t\t\t\t'task':\t\t\ttask\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t *\r\n\t * @param task\r\n\t */\r\n\tpublic addSubTicket(task: Task)\r\n\t{\r\n\t\tthis.addTicket(task);\r\n//\t\tthis.toggle();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic selectTicket(task: Task)\r\n\t{\r\n\t\tthis.selectedTask = task;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic focusTicket(task: Task)\r\n\t{\r\n\t\tthis.focusedTask = task;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic removeTicket(task: Task)\r\n\t{\r\n\t\tthis._taskService.deleteTask(task).subscribe((res: any) =>\r\n\t\t{\r\n\t\t\tlet arrayTasks: Task[] = this.workspaceData.globalTask.filter((item: any) => { return item.id !== task.id; });\r\n\r\n\t\t\tif (task.taskLocked)\r\n\t\t\t{\r\n\t\t\t\tfor (let t of task.taskLocked)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis._updateTaskDependencies(t.id, task.id, 'lockRules', 'delete');\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// ToComment\r\n\t\t\t// ---------------------------------------\r\n\t\t\tif (task.lockRules)\r\n\t\t\t{\r\n\t\t\t\tfor (let rule of task.lockRules)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let rule of task.lockRules)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis._updateTaskDependencies(rule.id, task.id, 'taskLocked', 'delete');\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.workspaceData.globalTask = arrayTasks;\r\n\t\t\t\tthis._applyTasksByUser();\r\n\t\t\t\tthis._applyTasksByGroup();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic addTicket(parentTicket: Task = null)\r\n\t{\r\n\t\tif (this.editingTask)\r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tlet newTask: Task = new Task();\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tnewTask.newTask = true;\r\n\t\tif (parentTicket)\r\n\t\t{\r\n\t\t\tnewTask.parents = [parentTicket.id];\r\n\t\t}\r\n\t\tthis.editingTask\t\t\t= newTask;\r\n\r\n\t\tthis.isEditorPanelActive\t= true;\r\n\t\tlet dialogRef\t\t\t\t= this.dialog.open(EditorPanelComponent,\r\n\t\t\t{\r\n\t\t\t\theight:\t\t\t'80%',\r\n\t\t\t\tpanelClass:\t\t'responsive_modal',\r\n\t\t\t\twidth:\t\t\t'65%',\r\n\t\t\t\tdisableClose:\ttrue,\r\n\t\t\t\tdata:\r\n\t\t\t\t{\r\n\t\t\t\t\t'task': newTask\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\tthis.toggle();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t* Post de la mise à jours d'une task\r\n\t*/\r\n\tpublic submitTaskChange(datasTask: any)\r\n\t{\r\n\t\tthis.updating = true;\r\n\t\tlet arrayTasks: Task[];\r\n\t\tif (datasTask.task)\r\n\t\t{\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// ToComment\r\n\t\t\t// ---------------------------------------\r\n\t\t\tlet task = datasTask.task;\r\n\r\n\t\t\tlet newTasks: Task[] = [];\r\n\t\t\tnewTasks = newTasks.concat(this.workspaceData.globalTask);\r\n\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// ToComment\r\n\t\t\t// ---------------------------------------\r\n\t\t\tif (task.newTask === false)\r\n\t\t\t{\r\n\t\t\t\tlet newDatas = datasTask.datas;\r\n\t\t\t\t//Si la tache passe en état non assgigné, on supprime l'utilisateur assigné\r\n\t\t\t\t//Si il existe\r\n\t\t\t\tif (newDatas.state && newDatas.state === 'new')\r\n\t\t\t\t{\r\n\t\t\t\t\tif (task.assigneduser)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnewDatas.assigneduser = '';\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//Si un message doit être envoyé par mail on active la notification par mail sur la tache courante\r\n\t\t\t\tif (newDatas.typeMail && newDatas.typeMail !== '')\r\n\t\t\t\t{\r\n\t\t\t\t\ttask.notifyByMail = true;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\ttask.notifyByMail = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis._taskService.updateTask(task, newDatas);\r\n\t\t\t\tthis.updating = false;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\t// ToComment\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\ttask.flags = ['inprogress'];\r\n\t\t\t\tthis._taskService.addTask(task);\r\n\t\t\t\tthis.updating = false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic toggle()\r\n\t{\r\n\t\tthis.showFab = !this.showFab;\r\n\t}\r\n\r\n\r\n\tpublic _initKanbanTypes()\r\n\t{\r\n\t\tthis.translate.get('task.state').subscribe((value1: string) =>\r\n\t\t{\r\n\t\t\tthis.translate.get('task.workflow').subscribe((value2: string) =>\r\n\t\t\t{\r\n\t\t\t\tthis.translate.get('task.user').subscribe((value3: string) =>\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tthis.kanbanTypes = [\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t/*Diagramme permettant de trier les tâches par état*/\r\n\t\t\t\t\t\t\tvalue:\t\t'state',\r\n\t\t\t\t\t\t\tviewValue:\tvalue1\r\n\t\t\t\t\t\t},\r\n//\t\t\t\t\t\t{\r\n//\t\t\t\t\t\t\t/*Diagramme permettant de trier les tâches par statut*/\r\n//\t\t\t\t\t\t\tvalue:\t\t'status',\r\n//\t\t\t\t\t\t\tviewValue:\tvalue2\r\n//\t\t\t\t\t\t},\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t/*Diagramme permettant de trier les tâches par utilisateur*/\r\n\t\t\t\t\t\t\tvalue:\t\t'user',\r\n\t\t\t\t\t\t\tviewValue:\tvalue3\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t];\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic _initStatesAvailable()\r\n\t{\r\n\t\tthis.translate.get('task.assigned').subscribe((value1: string) =>\r\n\t\t{\r\n\t\t\tthis.translate.get('task.inprogress').subscribe((value2: string) =>\r\n\t\t\t{\r\n\t\t\t\tthis.translate.get('task.toValidate').subscribe((value3: string) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.translate.get('task.validated').subscribe((value4: string) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.statesAvailable =\r\n\t\t\t\t\t\t\t[\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t/* La tache est assignée à un utilisateur mais n'est pas encore débutée */\r\n\t\t\t\t\t\t\t\t\tvalue:\t\t'todo',\r\n\t\t\t\t\t\t\t\t\tlibelle:\tvalue1\r\n\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t/* La tache est assignée et elle est en cours */\r\n\t\t\t\t\t\t\t\t\tvalue:\t\t'inprogress',\r\n\t\t\t\t\t\t\t\t\tlibelle:\tvalue2\r\n\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t/* La tache est terminée mais elle doit être validée par un responsable */\r\n\t\t\t\t\t\t\t\t\tvalue:\t\t'review',\r\n\t\t\t\t\t\t\t\t\tlibelle:\tvalue3\r\n\t\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t/* La tache est terminée et elle a été validée par un responsable */\r\n\t\t\t\t\t\t\t\t\tvalue:\t\t'done',\r\n\t\t\t\t\t\t\t\t\tlibelle:\tvalue4\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t];\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\tpublic _initTasks()\r\n\t{\r\n\t\tlet sUserId = this.userData.getUserId();\r\n\t\tlet eSocketWhat: SocketWhat.request;\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\r\n\t\t\t\tif (this.userData.isAdmin() === true || this.userData.isSuperviseur() === true)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': sUserId,\r\n\t\t\t\t\t\t\t'what': eSocketWhat,\r\n\t\t\t\t\t\t\t'cmd': 'tasks.stats',\r\n\t\t\t\t\t\t\t'args': {}\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': sUserId,\r\n\t\t\t\t\t\t\t'what': eSocketWhat,\r\n\t\t\t\t\t\t\t'cmd': 'tasks.assigned',\r\n\t\t\t\t\t\t\t'args': {}\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\r\n\tpublic _applyTasksByUser()\r\n\t{\r\n\t\tthis.tasksByUser\t= _.groupBy(this.workspaceData.globalTask, function(task: any){ return task.assigneduser; });\r\n\t\tthis.usersTask\t\t= _.filter(Object.keys(this.tasksByUser), function(user: any){ return user !== ''; });\r\n\r\n\t}\r\n\r\n\tpublic _applyTasksByGroup()\r\n\t{\r\n\t\tthis.lastTasksByGroup\t= [];\r\n\t\tthis.tasksByGroup\t\t= _.groupBy(this.workspaceData.globalTask, function (task: any)\r\n\t\t{\r\n\t\t\treturn task.idSession + ':' + task.idExamen + ':' + task.idEpreuve + ':' + task.idSujet;\r\n\t\t});\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet tasksDone;\r\n\t\tlet lastTask;\r\n\t\tlet lastIndexState = 0;\r\n\r\n\t\tfor (let key in this.tasksByGroup)\r\n\t\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\t\tif (this.tasksByGroup[key] && this.tasksByGroup[key].length > 0)\r\n\t\t\t{\r\n\t\t\t\ttasksDone = _.sortBy(_.where(this.tasksByGroup[key], {state: 'done'})\r\n\t\t\t\t\t\t\t, function(task: any){ return task.dateModification.getTime(); });\r\n\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\t// ToComment\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\tif (tasksDone && tasksDone.length)\r\n\t\t\t\t{\r\n\t\t\t\t\tlastTask = tasksDone[tasksDone.length - 1];\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tlastTask = this.tasksByGroup[key][0];\r\n\t\t\t\t\tlastIndexState = _.findLastIndex(this.typeAvailable, {value: lastTask.state});\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\t// ToComment\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\tfor (let task of this.tasksByGroup[key])\r\n\t\t\t\t{\r\n\t\t\t\t\tif (task.state !== 'done'\r\n\t\t\t\t\t\t&& _.findLastIndex(this.typeAvailable, {value: task.state}) > lastIndexState)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlastTask = task;\r\n\t\t\t\t\t\tlastIndexState = _.findLastIndex(this.typeAvailable, {value: task.state});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tthis.lastTasksByGroup.push(lastTask);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic _initStructuresModel(datas: any)\r\n\t{\r\n\t\tlet structureModel = [];\r\n\r\n\t\tif (datas && datas.cmd === 'node.info')\r\n\t\t{\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// On récupère la structure renvoyée par socket et on affecte les structures qui pourront\r\n\t\t\t// être sélectionnées dans le formulaire de tâches\r\n\t\t\t// ---------------------------------------\r\n\t\t\tif (datas.args && datas.args.data && datas.args.data.nodes && datas.args.data.nodes.structure)\r\n\t\t\t{\r\n\t\t\t\tfor (let etablissement of datas.args.data.nodes.structure)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let session of etablissement.sessions)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tstructureModel.push(\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlibelle:\tetablissement.name + ' - ' + session.name,\r\n\t\t\t\t\t\t\t\t value:\t\tsession.uuid\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tstructureModel.push(\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tlibelle:\tetablissement.name + ' - ' + session.name + ' - ' + examen.name,\r\n\t\t\t\t\t\t\t\t\tvalue:\t\tsession.uuid + ',' + examen.uuid\r\n\t\t\t\t\t\t\t\t});\r\n\r\n\r\n\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\tfor (let epreuve of examen.epreuves)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tstructureModel.push(\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlibelle:\tetablissement.name + ' - ' + session.name + ' - ' + examen.name + ' - ' + epreuve.name,\r\n\t\t\t\t\t\t\t\t\t\tvalue:\t\tsession.uuid + ',' + examen.uuid + ',' + epreuve.uuid\r\n\t\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.structureSubjects = structureModel;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic _updateTaskDependencies(idTask: string, idField: string, nameField: string, mode: string)\r\n\t{\r\n\t\tlet index;\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tswitch (mode)\r\n\t\t{\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// ToComment\r\n\t\t\t// ---------------------------------------\r\n\t\t\tcase 'add':\r\n\t\t\t\tindex = _.findIndex(this.workspaceData.globalTask, (val: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn val.id === idTask;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tlet indexTask = _.findIndex(this.workspaceData.globalTask, (val: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn val.id === idField;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif (index !== -1 && indexTask !== -1)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet value: any = this.workspaceData.globalTask[index][nameField];\r\n\r\n\t\t\t\t\tlet index2 = _.findIndex(value, (val: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn val.id === idField;\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tif (index2 !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.workspaceData.globalTask[index][nameField][index2] = this.workspaceData.globalTask[indexTask];\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.workspaceData.globalTask[index][nameField].push(this.workspaceData.globalTask[indexTask]);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// ToComment\r\n\t\t\t// ---------------------------------------\r\n\t\t\tcase 'delete':\r\n\t\t\t\tindex = _.findIndex(this.workspaceData.globalTask, (val: any) =>\r\n\t\t\t\t{ \r\n\t\t\t\t\treturn val.id === idTask;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif (index !== -1)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet index2 = _.findIndex(this.workspaceData.globalTask[index][nameField], (val: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn val.id === idField;\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tif (index2 !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.workspaceData.globalTask[index][nameField].splice(index2, 1);\r\n\r\n\t\t\t\t\t\t//We update lock state of task\r\n\t\t\t\t\t\tthis.workspaceData.globalTask[index].locked = this.workspaceData.globalTask[index].lockRules.length > 0;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Cette fonction est appelée lorsque des informations relativres aux\r\n\t * utilisateurs sont transmises par socket\r\n\t * @param datas\r\n\t */\r\n\tpublic _onUsersReturned(datas: any)\r\n\t{\r\n\t\tif (datas.cmd && datas.cmd === 'users')\r\n\t\t{\r\n\t\t\tif (datas && datas.args && datas.args.data && datas.args.data.users)\r\n\t\t\t{\r\n\t\t\t\tthis.usersAvailable = datas.args.data.users;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Cette fonction est appellée lorsque des informations relatives aux tâches\r\n\t * sont transmises par socket\r\n\t * @param datas\r\n\t */\r\n\tpublic _onTasksReturned(datas: any)\r\n\t{\r\n\t\tif (datas.cmd && (datas.cmd === 'tasks.bynode' || datas.cmd === 'tasks.assigned'))\r\n\t\t{\r\n\t\t\tif (datas.args && datas.args.data && datas.args.data.tasks)\r\n\t\t\t{\r\n\t\t\t\tthis.workspaceData.globalTask = _.map(datas.args.data.tasks, (taskJson: any) =>\r\n {\r\n return Task.fromJsonObject(taskJson);\r\n });\r\n\r\n\t\t\t\tthis._applyTasksByUser();\r\n\t\t\t\tthis._applyTasksByGroup();\r\n\r\n\t\t\t\tthis.isLoading\t\t= false;\r\n\t\t\t\tthis.tasksLoaded\t= true;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic changeScenarioSelected(event: any)\r\n\t{\r\n\t\tthis.titleScenarioSelected = event;\r\n\t\tthis.adminData.scenarioSelected = _.find(this.adminData.scenariosAvailable, (scenario: any) => { return scenario.title === this.titleScenarioSelected; });\r\n\r\n\t\tthis.taskData.getEpreuveByWorkflow(this.adminData.scenarioSelected.title);\r\n\t}\r\n\r\n\r\n\r\n private _initParameters()\r\n {\r\n\t\t//Initialisation des paramètres généraux\r\n\t\t//Initialisation des scénarios\r\n\t\tif (this.adminData.scenariosAvailable && this.adminData.scenariosAvailable.length > 0)\r\n\t\t{\r\n\t\t\tthis.adminData.scenarioSelected = this.adminData.scenariosAvailable[0];\r\n\t\t\tthis.titleScenarioSelected = this.adminData.scenarioSelected.title;\r\n\r\n\t\t\tthis.taskData.getEpreuveByWorkflow(this.adminData.scenarioSelected.title);\r\n\t\t}\r\n\r\n\r\n\t\tlet filterName\t= '';\r\n\t\tlet filterId\t= '';\r\n\t\tif (this.workspaceData.selectedSujet)\r\n\t\t{\r\n\t\t\tfilterName\t= 'suj';\r\n\t\t\tfilterId\t= this.workspaceData.selectedSujet.id;\r\n\t\t}\r\n\t\telse if (this.workspaceData.selectedMatiere)\r\n\t\t{\r\n\t\t\tfilterName\t= 'matiere';\r\n\t\t\tfilterId\t= this.workspaceData.selectedMatiere.id;\r\n\t\t}\r\n\t\telse if (this.workspaceData.selectedExamen)\r\n\t\t{\r\n\t\t\tfilterName\t= 'exam';\r\n\t\t\tfilterId\t= this.workspaceData.selectedExamen.id;\r\n\t\t}\r\n\t\telse if (this.workspaceData.selectedSession)\r\n\t\t{\r\n\t\t\tfilterName\t= 'sess';\r\n\t\t\tfilterId\t= this.workspaceData.selectedSession.id;\r\n\t\t}\r\n\t\telse if (this.workspaceData.selectedEtablissement)\r\n\t\t{\r\n\t\t\tfilterName\t= 'etab';\r\n\t\t\tfilterId\t= this.workspaceData.selectedEtablissement.id;\r\n\t\t}\r\n\t\tthis.taskData.filterTasks(filterName, filterId);\r\n\t}\r\n\r\n\r\n\tpublic onDrag(args: any)\r\n\t{\r\n\t\tlet [e, el] = args;\r\n\t}\r\n\r\n\tpublic onDrop(args: any)\r\n\t{\r\n\t\tlet [e, el] = args;\r\n\t}\r\n\r\n\tpublic onOver(args: any)\r\n\t{\r\n\t\tlet [e, el, container] = args;\r\n\t}\r\n\r\n\tpublic onOut(args: any)\r\n\t{\r\n\t\tlet [e, el, container] = args;\r\n\t}\r\n}\r\n","\r\n\t\r\n\t\r\n\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\t
Résultat
\r\n\t\t\t
\r\n\t\t
\r\n\t\t
\r\n\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t De niveau: établissement 1, .... \r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\tDans le groupe \r\n\t\t\t\t\r\n\t\t\t\t\tgroupe1 \r\n\t\t\t\t\tgroupe2 \r\n\t\t\t\t\tgroupe3 \r\n\t\t\t\t\tgroupe4 \r\n\t\t\t\t \r\n\t\t\t\t+ \r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\tpersonnes présentes\r\n\t\t\t
\r\n\t\t
\r\n\t\t
\r\n
\r\n\t\r\n \r\n","import { Component, OnInit, ViewEncapsulation } from '@angular/core';\r\nimport { MatDialogRef }\t\t\t\t\t\t\tfrom '@angular/material';\r\n\r\n@Component({\r\n\tselector:\t\t'app-user-add-form',\r\n\ttemplateUrl:\t'./user-add-form.component.html',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n\tstyleUrls:\t\t['./user-add-form.component.scss']\r\n})\r\n\r\nexport class UserAddFormComponent implements OnInit\r\n{\r\n\r\n\tconstructor(\r\n\t\tpublic dialogRef: MatDialogRef\r\n\t) \r\n\t{ }\r\n\r\n\tpublic ngOnInit()\r\n\t{\r\n\t}\r\n\r\n}\r\n","\r\n\t
{{outputContent}} \r\n\r\n\r\n\t
\r\n\t\t
\r\n\t\t\t{{oUser.infos.nom}} {{oUser.infos.prenom}}\r\n\t\t
\r\n\t\t
\r\n\t\t\t{{userMail}}\r\n\t\t
\r\n\t\t
\r\n\t\t
\r\n\t\t\t{{oUser.mail}}\r\n\t\t
\r\n\t
\r\n\t
\r\n\r\n
","import { Component, OnInit, Input } from '@angular/core';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\nimport { ChatData }\t\t\t\tfrom '../../providers/chat-data';\r\nimport { User }\t\t\t\tfrom '../../classes/user.class';\r\nimport { UserInfoComponent } from '../user-info/user-info.component';\r\nimport { ViewEncapsulation }\t\t\tfrom '@angular/core';\r\nimport { Router }\t\t\t\tfrom '@angular/router';\r\n\r\n\r\n@Component({\r\n\tselector: 'app-user-name',\r\n\tencapsulation: ViewEncapsulation.None,\r\n\ttemplateUrl: './user-name.component.html',\r\n\tstyleUrls: ['./user-name.component.scss']\r\n})\r\n\r\nexport class UserNameComponent implements OnInit\r\n{\r\n\r\n\t@Input() userMail: string;\r\n\t@Input() showBubble: boolean = true;\r\n\tpublic outputContent: string;\r\n\tpublic oUser: any;\r\n\tpublic showMail = false;\r\n\r\n\tconstructor(\r\n\t\tpublic router: Router,\r\n\t\tpublic userData: UserData,\r\n\t\tpublic chatData: ChatData\r\n\t\t\t) { }\r\n\r\n\r\n\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tthis.outputContent = this.userMail;\r\n\r\n\t\tif (this.userMail)\r\n\t\t{\r\n\t\t\tthis.oUser = this.userData.getUser(this.userMail);\r\n\t\t}\r\n\r\n\r\n\t\tif (this.oUser && this.oUser.infos && (this.oUser.infos.nom || this.oUser.infos.prenom))\r\n\t\t{\r\n\t\t\tthis.outputContent = '';\r\n\r\n\t\t\tif (this.oUser.infos.prenom) this.outputContent += this.oUser.infos.prenom + ' ';\r\n\t\t\tif (this.oUser.infos.nom) this.outputContent += this.oUser.infos.nom;\r\n\t\t}\r\n\t\telse if(this.oUser && this.oUser.infos )\r\n\t\t{\r\n\t\t\tthis.showMail = true;\r\n\t\t}\r\n\r\n\r\n\t\telse if (this.userMail === this.userData.getUserId())\r\n\t\t{\r\n\t\t\tthis.outputContent = this.userData.getUsername();\r\n\t\t}\r\n\r\n\t}\r\n\t\r\n\tpublic onClick(event: any)\r\n\t{\r\n\t\tthis.chatData.setSelectedRoomByMail(this.userMail);\r\n\t\tthis.router.navigate(['/community']);\r\n\r\n\t}\r\n}\r\n","\r\n\t
\r\n\t\t
\r\n\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t{{ name }}\r\n\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t
\r\n\t\t\t\t\t{{ status }}\r\n\t\t\t\t
\r\n\t\t\t
\r\n\t\t\t
\r\n\t\t
\r\n\t\t
\r\n\t
\r\n\t\r\n\t
\r\n
\r\n","import { Component, Input, OnInit, OnChanges }\t\tfrom '@angular/core';\r\nimport { ViewEncapsulation }\tfrom '@angular/core';\r\nimport { UserData }\t\t\t\t\tfrom '../../providers/user-data';\r\n\r\n\r\n@Component({\r\n\tselector: 'app-user',\r\n\tencapsulation: ViewEncapsulation.None,\r\n\ttemplateUrl: './user.component.html',\r\n\tstyleUrls: ['./user.component.scss']\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class UserComponent implements OnInit, OnChanges\r\n{\r\n\t@Input() public _id: number;\r\n @Input() public _name: string = 'Non assigné';\r\n @Input() public _lastName: string;\r\n @Input() public _etablissement:\t string;\r\n @Input() public _session: string;\r\n @Input() public _examen: string;\r\n @Input() public _status: string;\r\n @Input() public _icone: string;\r\n @Input() public _state: string;\r\n @Input() public _color: string = '';\r\n @Input() public displayType: string;\r\n\r\n\tpublic firstLetterIcone:\tstring;\r\n private linkToRoute:\t\tstring = '/community';\r\n\r\n constructor(public userData:UserData)\r\n\t{\r\n\r\n }\r\n\r\n\r\n\tpublic ngOnChanges()\r\n\t{\r\n\t\tif (this.name)\r\n\t\t{\r\n\t\t\tthis.firstLetterIcone = this.name.charAt(0);\r\n\t\t\tif (this.lastName)\r\n\t\t\t{\r\n\t\t\t\tthis.firstLetterIcone += this.lastName.charAt(0);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.firstLetterIcone += this.name.charAt(1);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t\r\n\tpublic ngOnInit()\r\n\t{\r\n\t\tif (this.name)\r\n\t\t{\r\n\t\t\tthis.firstLetterIcone = this.name.charAt(0);\r\n\t\t\tif (this.lastName)\r\n\t\t\t{\r\n\t\t\t\tthis.firstLetterIcone += this.lastName.charAt(0);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.firstLetterIcone += this.name.charAt(1);\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.firstLetterIcone = this.status.charAt(0);\r\n\t\t\tthis.firstLetterIcone += this.status.charAt(1);\r\n\t\t}\r\n\t\t\r\n\r\n\t\tif (this.color === '' || this.color === undefined)\r\n\t\t{\r\n\t\t\tthis.color = '#ffffff';\r\n\t\t}\r\n }\r\n\r\n\r\n\tpublic setIcon()\r\n\t{\r\n\t\tif (this.name)\r\n\t\t{\r\n\t\t\tthis.firstLetterIcone = this.name.charAt(0);\r\n\t\t\tthis.firstLetterIcone += this.name.charAt(1);\r\n\t\t}\r\n\t}\r\n\r\n\r\n get id(): number { return this._id; }\r\n get name(): string { return this._name; }\r\n get lastName(): string { return this._lastName; }\r\n get etablissement(): string { return this._etablissement; }\r\n get session(): string { return this._session; }\r\n get examen(): string { return this._examen; }\r\n get status(): string { return this._status; }\r\n get icone(): string { return this._icone; }\r\n get color(): string { return this._color; }\r\n get state(): string { return this._state; }\r\n\r\n set id(id) { this._id = id; }\r\n set name(name) { this._name = name; }\r\n set lastName(lastName) { this._lastName = lastName; }\r\n set etablissement(etablissement) { this._etablissement = etablissement; }\r\n set session(session) { this._session = session; }\r\n set examen(examen) { this._examen = examen; }\r\n set icone(icone) \t{ this._icone = icone; }\r\n set status(status) { this._status = status; }\r\n set color(color)\t\t\t\t\t{ this._color\t\t\t= color; }\r\n set state(state) \t{ this._state = state; }\r\n\r\n\r\n\t@Input()\r\n\tset link(link: string) \r\n\t{\r\n\r\n\t\tif (link === undefined || link === 'none')\r\n\t\t{\r\n\t\t\tthis.linkToRoute = undefined;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.linkToRoute = link;\r\n\t\t}\r\n\t}\r\n}\r\n","\r\n \r\n \r\n\r\n
\r\n\r\n\t\t\t
\r\n\r\n\t\t\t\t
{{ 'validateTask.optionTitle' | translate }}
\r\n\r\n\t\t\t\t
\r\n\t\t\t\t\t{{ 'validateTask.optionAction1' | translate }} ({{nameNextStep}}) \r\n\t\t\t\t\t{{ 'validateTask.optionAction2' | translate }} \r\n\t\t\t\t\t{{ 'validateTask.optionAction3' | translate }} ({{namePreviousStep}}) \r\n\t\t\t\t\t\r\n\t\t\t\t\t\t{{ 'validateTask.optionAction4' | translate }} \r\n\t\t\t\t\t\t{{ 'validateTask.optionAction5' | translate }} \r\n\t\t\t\t\t \r\n\t\t\t\t \r\n\t\t\t
\r\n\r\n
\r\n\t\t\t\t \r\n\t\t\t \r\n\t\t\t
\r\n\r\n\t\t\t
\r\n\t\t\t\t{{ 'validateTask.sendMail' | translate }} \r\n\t\t\t
\r\n
\r\n\r\n \r\n
\r\n \r\n","import { Component, ViewEncapsulation, Inject }\t\t\t\tfrom '@angular/core';\r\nimport { FormControl, FormBuilder, FormGroup, Validators }\tfrom '@angular/forms';\r\nimport { MatDialogRef }\t\t\t\t\t\t\t\t\t\tfrom '@angular/material';\r\nimport { MAT_DIALOG_DATA }\t\t\t\t\t\t\t\t\tfrom '@angular/material';\r\nimport { TranslateService } \t\t\t\t\t\t from '@ngx-translate/core';\r\n\r\nimport { Comment }\t\t\tfrom '../../../../../../classes/comment.class';\r\nimport { Task }\t\t\t\tfrom '../../../../../../classes/task.class';\r\nimport { Matiere }\t\t\t\tfrom '../../../../../../classes/matiere.class';\r\nimport { UserData }\t\t\tfrom '../../../../../../providers/user-data';\r\nimport { WorkspaceData }\tfrom '../../../../../../providers/workspace-data';\r\nimport { TaskService }\t\tfrom '../../../../../../services/task.service';\r\nimport { MessagesService }\tfrom '../../../../../../services/messages.service';\r\n\r\n@Component({\r\n selector:\t\t'validate-task-modal',\r\n\tencapsulation:\tViewEncapsulation.None,\r\n templateUrl:\t'validateTaskModal.component.html',\r\n styleUrls:\t\t['./validateTaskModal.component.scss']\r\n})\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class ValidateTaskModalComponent\r\n{\r\n public currentComment:\tComment;\r\n public moFormGroup:\t\tFormGroup;\r\n public currentTask:\t\tTask;\r\n\r\n public nextAction: string = '1';\r\n\r\n public numberCurrentStep: any;\r\n public nameCurrentStep: any;\r\n public nameNextStep: any;\r\n public namePreviousStep: any;\r\n\r\n public textHeader:\t\t\t\tstring;\r\n public textValidationButton:\tstring;\r\n\r\n public sendEmail: boolean = false;\r\n\r\n public currentState: string;\r\n\tpublic cancelComment: any;\r\n\r\n moFormCtrlMessage:\t\tFormControl;\r\n moFormCtrlSendEmail:\tFormControl;\r\n\r\n\r\n /**\r\n *\r\n * @param dialogRef\r\n * @param fb\r\n * @param userData\r\n * @param workspaceData\r\n * @param taskService\r\n * @param messagesService\r\n * @param translate\r\n * @param data\r\n */\r\n constructor(public dialogRef:\t\t\tMatDialogRef,\r\n public fb:\t\t\t\t\tFormBuilder,\r\n public userData:\t\t\tUserData,\r\n public workspaceData:\t\tWorkspaceData,\r\n public taskService:\t\t\tTaskService,\r\n public messagesService:\t\tMessagesService,\r\n public translate: TranslateService,\r\n\t\t\t\t@Inject(MAT_DIALOG_DATA)\tpublic data: any)\r\n {\r\n this.currentComment = new Comment();\r\n\r\n if (this.data && this.data.task)\r\n\t\t{\r\n this.currentTask = this.data.task;\r\n\r\n if (this.data.state)\r\n {\r\n this.currentState = this.data.state;\r\n }\r\n else\r\n {\r\n this.currentState = this.currentTask.state;\r\n }\r\n\r\n\r\n this.moFormCtrlMessage\t\t= this.fb.control(this.currentComment.message, Validators.required);\r\n this.moFormCtrlSendEmail\t= this.fb.control(this.sendEmail);\r\n\r\n this.moFormGroup =\tthis.fb.group({\r\n message:\t\tthis.moFormCtrlMessage,\r\n sendEmail:\t\tthis.moFormCtrlSendEmail\r\n });\r\n\r\n\t\t\tif (this.currentState === 'review')\r\n\t\t\t{\r\n\t\t\t\tthis.sendEmail = true;\r\n\t\t\t\tthis.translate.get('validateTask.validationButton1').subscribe((value: string) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.textValidationButton = value;\r\n\t\t\t\t});\r\n\r\n this.nameCurrentStep = '';\r\n\r\n\t\t\t\tlet oEpreuve = this.workspaceData.getEpreuve(this.currentTask.idEpreuve);\r\n\r\n if (this.currentTask.type && oEpreuve.scenario.steps)\r\n {\r\n this.numberCurrentStep = Number(this.currentTask.type);\r\n\r\n if (oEpreuve.scenario.steps[this.numberCurrentStep])\r\n {\r\n this.nameCurrentStep = oEpreuve.scenario.steps[this.numberCurrentStep].name;\r\n }\r\n\r\n //On récupère le nom de la prochaine étape (si l'étape courante n'est pas déja la dernière)\r\n if (this.numberCurrentStep < oEpreuve.scenario.steps.length - 1 && oEpreuve.scenario.steps[this.numberCurrentStep + 1])\r\n {\r\n this.nameNextStep = oEpreuve.scenario.steps[this.numberCurrentStep + 1].name;\r\n }\r\n\r\n //On récupère le nom de l'étape précédente (si l'étape courante n'est pas déja la première)\r\n if (this.numberCurrentStep > 0 && oEpreuve.scenario.steps[this.numberCurrentStep - 1])\r\n {\r\n this.namePreviousStep = oEpreuve.scenario.steps[this.numberCurrentStep - 1].name;\r\n }\r\n }\r\n this.translate.get('validateTask.headerText1').subscribe((value: string) =>\r\n {\r\n this.textHeader = value + this.nameCurrentStep;\r\n });\r\n }\r\n else\r\n {\r\n this.translate.get('validateTask.validationButton2').subscribe((value1: string) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.translate.get('validateTask.headerText2').subscribe((value2: string) =>\r\n\t\t\t\t\t{\r\n this.textValidationButton\t= value1;\r\n this.textHeader\t\t\t\t= value2;\r\n });\r\n });\r\n }\r\n }\r\n }\r\n\r\n\r\n /**\r\n * On ajoute le commentaire à la tache concernée\r\n * et on la passe au status \"à valider\"\r\n */\r\n public validate()\r\n {\r\n /**\r\n * Si le commentaire est saisie on l'enregistre en base de données pour la tache concernée\r\n */\r\n if (this.currentComment && this.currentComment.message && this.currentComment.message !== '')\r\n {\r\n\t\t\tconst baseChannelSubject = '*soft::' + this.userData.account + '::creation::suj::';\r\n\t\t\tconst datasComment: any =\r\n\t\t\t{\r\n\t\t\t\taction:\t\t'create',\r\n\t\t\t\tcomment:\tthis.currentComment.message,\r\n\t\t\t\tuser:\t\tthis.userData.mail\r\n\t\t\t};\r\n\r\n\r\n\t\t\t// ce if a été mis là pour éviter une erreur, mais je pense que c'est un pb\r\n\t\t\tif (this.workspaceData.selectedSujet)\r\n\t\t\t{\r\n\t\t\t\tconst notifiers: any[] = [baseChannelSubject + this.workspaceData.selectedSujet.id];\r\n\t\t\t\tthis.messagesService.sendMessage('tasks', this.currentTask.id, 'C', datasComment, notifiers);\r\n\t\t\t\tthis.messagesService.sendMessage('subjects', this.workspaceData.selectedSujet.id, 'C', datasComment, notifiers);\r\n\t\t\t}\r\n\t\t\telse if (this.currentTask.idSujet)\r\n\t\t\t{\r\n\t\t\t\tconst notifiers: any[] = [baseChannelSubject + this.currentTask.idSujet];\r\n\t\t\t\tthis.messagesService.sendMessage('tasks', this.currentTask.id, 'C', datasComment, notifiers);\r\n\t\t\t\tthis.messagesService.sendMessage('subjects', this.currentTask.idSujet, 'C', datasComment, notifiers);\r\n\t\t\t}\r\n }\r\n\r\n const newDatas: any = {};\r\n\t\tlet newTask;\r\n\r\n\t\tconst currentSujet = this.workspaceData.getSujet(this.currentTask.idSujet);\r\n\r\n const datasEmail: any =\r\n {\r\n\t\t\tnomSujet: currentSujet ? currentSujet.name : '',\r\n\t\t\tnomEtape: this.currentTask.typeLib\r\n\t\t};\r\n\r\n if (this.currentState === 'review')\r\n {\r\n\t\t\tif ((this.nextAction === '1' || this.nextAction === '3' || this.nextAction === '4') && this.sendEmail === true)\r\n \t{\r\n\t\t\t\tthis.currentTask.notifyByMail = true;\r\n\t\t\t\tnewDatas.typeMail = 'validatedTask';\r\n\t\t\t\tnewDatas.datasEmail = datasEmail;\r\n\t\t\t}\r\n\r\n switch(this.nextAction)\r\n {\r\n case '1':\r\n // On met la tache courante en 'done' et on créé une nouvelle tache avec\r\n // l'étape suivante\r\n newDatas.state = 'done';\r\n this.taskService.updateTask(this.currentTask, newDatas);\r\n newTask = this._initialiseNewTask('next');\r\n break;\r\n\r\n\r\n case '2':\r\n // On met la tache courante en 'inprogress'\r\n newDatas.state = 'inprogress';\r\n this.taskService.updateTask(this.currentTask, newDatas);\r\n break;\r\n\r\n\r\n case '3':\r\n //On met la tache courante en 'done' et on créé une nouvelle tache avec\r\n //l'étape précédente\r\n newDatas.state = 'done';\r\n this.taskService.updateTask(this.currentTask, newDatas);\r\n newTask = this._initialiseNewTask('previous');\r\n break;\r\n\r\n\r\n case '4':\r\n //On met uniquement la tache courante en 'done'\r\n newDatas.state = 'done';\r\n this.taskService.updateTask(this.currentTask, newDatas);\r\n break;\r\n\r\n\r\n default:\r\n break;\r\n\t\t\t}\r\n }\r\n else\r\n {\r\n\t\t\tif (this.sendEmail === true)\r\n \t{\r\n\t\t\t\tthis.currentTask.notifyByMail = true;\r\n\t\t\t\tnewDatas.typeMail = 'terminatedTask';\r\n\t\t\t\tnewDatas.datasEmail = datasEmail;\r\n\t\t\t}\r\n\r\n\t\t\tnewDatas.state = 'review';\r\n\r\n this.taskService.updateTask(this.currentTask, newDatas);\r\n }\r\n this.dialogRef.close(newTask);\r\n }\r\n\r\n\r\n /**\r\n *\r\n */\r\n public cancel()\r\n {\r\n this.dialogRef.close();\r\n }\r\n\r\n\r\n /**\r\n *\r\n * @param event\r\n */\r\n public onChangeAction(event: any)\r\n {\r\n this.nextAction = event.toString();\r\n\r\n if (this.nextAction === '1' || this.nextAction === '3')\r\n\t\t{\r\n\t\t\tthis.translate.get('validateTask.validationButton1').subscribe((value3: string) =>\r\n\t\t\t{\r\n\t\t\t\tthis.textValidationButton = value3;\r\n\r\n\t\t\t});\r\n }\r\n else\r\n {\r\n\t\t\tthis.translate.get('validateTask.validationButton3').subscribe((value3: string) =>\r\n\t\t\t{\r\n\t\t\t\tthis.textValidationButton = value3;\r\n\t\t\t});\r\n\t\t}\r\n }\r\n\r\n\r\n /**\r\n *\r\n */\r\n public canSendMail()\r\n {\r\n let result = false;\r\n\r\n if (this.currentState === 'review')\r\n {\r\n result = true;\r\n }\r\n else\r\n {\r\n if (this.userData.mail !== this.currentTask.assigneduser)\r\n {\r\n result = true;\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n\r\n /**\r\n *\r\n * @param nature\r\n */\r\n private _initialiseNewTask(nature: string)\r\n {\r\n let newTask:\t\tTask;\r\n let libelleNewStep: string = '';\r\n\r\n\t\tlet oEpreuve = this.workspaceData.getEpreuve(this.currentTask.idEpreuve);\r\n\r\n if (oEpreuve.scenario.steps)\r\n {\r\n if (nature === 'next' && oEpreuve.scenario.steps[this.numberCurrentStep + 1])\r\n {\r\n newTask = new Task();\r\n\r\n let newStep\t\t= this.numberCurrentStep + 1;\r\n let strNewStep\t= newStep.toString();\r\n newTask.type\t= strNewStep;\r\n libelleNewStep\t= oEpreuve.scenario.steps[this.numberCurrentStep + 1].name;\r\n }\r\n else\r\n {\r\n if (nature === 'previous' && oEpreuve.scenario.steps[this.numberCurrentStep - 1])\r\n {\r\n newTask = new Task();\r\n\r\n let newStep\t\t= this.numberCurrentStep - 1;\r\n let strNewStep\t= newStep.toString();\r\n newTask.type\t= strNewStep;\r\n libelleNewStep\t= oEpreuve.scenario.steps[this.numberCurrentStep - 1].name;\r\n }\r\n }\r\n\r\n if (newTask)\r\n {\r\n newTask.idEpreuve\t\t= this.currentTask.idEpreuve;\r\n newTask.canCreateFile\t= true;\r\n\r\n this.translate.get('validateTask.taskName1').subscribe((value1: string) => {\r\n this.translate.get('validateTask.taskName2').subscribe((value2: string) => {\r\n\r\n let newTaskName = '';\r\n newTaskName\t\t+= value1;\r\n newTaskName\t\t+= libelleNewStep;\r\n\r\n\t\t\t\t\t\tconst currentSujet = this.workspaceData.getSujet(this.currentTask.idSujet);\r\n\r\n if (this.workspaceData.selectedSujet)\r\n {\r\n newTaskName += value2;\r\n newTaskName += currentSujet ? currentSujet.name : '';\r\n }\r\n\r\n newTask.name\t= newTaskName;\r\n });\r\n });\r\n newTask.idSujet = this.currentTask.idSujet;\r\n }\r\n }\r\n return newTask;\r\n }\r\n}\r\n\r\n\r\n","\r\nimport { Pipe, PipeTransform }\tfrom '@angular/core';\r\n\r\n@Pipe({\r\n\tname: 'otherUsersFilter'\r\n})\r\nexport class OtherUsersFilter implements PipeTransform\r\n{\r\n\r\n\tpublic transform(users: any[], mailCurrentUser: string): any[]\r\n\t{\r\n\t\tif (users)\r\n\t\t{\r\n return users.filter((user) => user.mail !== mailCurrentUser);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn users;\r\n\t\t}\r\n\t}\r\n}","import { Injectable, EventEmitter, OnDestroy } from '@angular/core';\r\nimport * as _ from 'underscore';\r\n\r\n\r\n@Injectable()\r\nexport class AdminData implements OnDestroy\r\n{\r\n\r\n\tprivate _generalParameters: \tany = {};\r\n\tprivate _mailsTemplates: \t\tany[] = [];\r\n\tprivate _scenariosAvailable: \tany[] = [];\r\n\tprivate _scenarioSelected: \t\tany;\r\n\r\n\tpublic adminEmitter: EventEmitter = new EventEmitter();\r\n\r\n\r\n /**\r\n\t *\r\n\t */\r\n\tconstructor()\r\n\t{\r\n\r\n\t}\r\n\r\n\tngOnDestroy()\r\n\t{\r\n\t\tthis.adminEmitter.unsubscribe();\r\n\r\n\t}\r\n\r\n\tget generalParameters():\tany\t\t{ return this._generalParameters; }\r\n\tget scenariosAvailable():\tany[]\t{ return this._scenariosAvailable; }\r\n\tget mailsTemplates():\t\tany[]\t{ return this._mailsTemplates; }\r\n\r\n\tget scenarioSelected(): any\r\n\t{\r\n\r\n\t\tlet indice = 0;\r\n\t\tif (this._scenarioSelected)\r\n\t\t{\r\n\t\t\tfor (let steps of this._scenarioSelected.steps)\r\n\t\t\t{\r\n\r\n\t\t\t\tsteps.id = indice;\r\n\t\t\t\tindice++;\r\n\t\t\t}\r\n\t\t\treturn this._scenarioSelected;\r\n\t\t}\r\n\t}\r\n\r\n\tset generalParameters(generalParameters: any)\t\t{ this._generalParameters\t= generalParameters; }\r\n\tset scenariosAvailable(scenariosAvailable: any[])\t{ this._scenariosAvailable\t= scenariosAvailable; }\r\n\tset mailsTemplates(mailsTemplates: any[])\t\t\t{ this._mailsTemplates \t\t= mailsTemplates; }\r\n\r\n\tset scenarioSelected(scenarioSelected: any)\r\n\t{\r\n\r\n\t\tlet indice = 0;\r\n\r\n\t\tfor (const steps of scenarioSelected.steps)\r\n\t\t{\r\n\r\n\t\t\tsteps.id = indice;\r\n\t\t\tindice++;\r\n\t\t}\r\n\t\tthis._scenarioSelected = scenarioSelected;\r\n\t}\r\n\r\n\r\n\tpublic isNumericEnabled()\r\n\t{\r\n\t\tlet result = false;\r\n\r\n\t\tif (this._generalParameters && this._generalParameters['numericEnabled'])\r\n\t\t{\r\n\t\t\tresult = Number(this._generalParameters['numericEnabled']) === 1;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\tpublic isSpecialTimeEnabled()\r\n\t{\r\n\t\tlet result = false;\r\n\r\n\t\tif (this._generalParameters && this._generalParameters['specialTimeEnabled'])\r\n\t\t{\r\n\t\t\tresult = Number(this._generalParameters['specialTimeEnabled']) === 1;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\tpublic isSpecialTimeArray()\r\n\t{\r\n\t\tlet result = false;\r\n\r\n\t\tif (this._generalParameters && this._generalParameters['specialTimeArray'])\r\n\t\t{\r\n\t\t\tresult = this._generalParameters['specialTimeAarray'];\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n}\r\n","import { Injectable, EventEmitter, OnDestroy } from '@angular/core';\r\n\r\nimport { WorkspaceData } from './workspace-data';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n\r\n\r\n@Injectable()\r\nexport class BaremeData implements OnDestroy\r\n{\r\n\r\n\r\n public masTypeList:\t\t\t\tany[]\t= ['Strict', 'Par réponse', 'Concordance', 'Relatif'];\r\n\r\n\tprivate _majBaremeList: any\t\t= [];\r\n\tprivate _mnLastNumber: number\t= 0;\r\n\r\n\r\n\r\n\tconstructor(public workspaceDate: WorkspaceData)\r\n\t{\r\n\r\n\t}\r\n\r\n\tngOnDestroy()\r\n\t{\r\n }\r\n\r\n\r\n\tget majBaremeList()\r\n\t{\r\n\r\n\t\tlet aReturn = [];\r\n\r\n\t\tfor (let sIndex in this._majBaremeList)\r\n\t\t{\r\n\t\t\taReturn.push(this._majBaremeList[sIndex]);\r\n\t\t}\r\n\r\n\t\treturn aReturn;\r\n\t}\r\n\r\n\r\n\tgetBaremeByPassation(psPassation:string)\r\n\t{\r\n\t\tconst aReturn = [];\r\n\r\n\t\tfor (const sIndex in this._majBaremeList)\r\n\t\t{\r\n\t\t\tif (this._majBaremeList[sIndex].datas.idPassation && this._majBaremeList[sIndex].datas.idPassation === psPassation)\r\n\t\t\t{\r\n\t\t\t\taReturn.push(this._majBaremeList[sIndex]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn aReturn;\r\n\t}\r\n\r\n\r\n\tset majBaremeList(pajBaremeList)\r\n\t{\r\n\t\tthis._majBaremeList = pajBaremeList;\r\n\t}\r\n\r\n\tsetBaremeById(psId: any, pjData: any)\r\n\t{\r\n\t\tthis._majBaremeList[psId] = pjData;\r\n\t}\r\n\r\n\r\n\tgetBaremeById(psId: any)\r\n\t{\r\n\t\treturn this._majBaremeList[psId];\r\n\t}\r\n\tgetBaremeNameById(psId: any)\r\n\t{\r\n\t\tlet sReturn = '';\r\n\t\tif (psId)\r\n\t\t{\r\n\t\t\tsReturn = this._majBaremeList[psId].datas.name + '-' + this._majBaremeList[psId].datas.number;\r\n\t\t}\r\n\t\treturn sReturn;\r\n\t}\r\n\r\n\r\n\tupdateBaremeDatasById(psId: any, paoDatasToUpdate: any)\r\n\t{\r\n\t\tif (this._majBaremeList[psId])\r\n\t\t{\r\n\t\t\tfor (const sKey in paoDatasToUpdate)\r\n\t\t\t{\r\n\t\t\t\tif (paoDatasToUpdate[sKey])\r\n\t\t\t\t{\r\n\t\t\t\t\tthis._majBaremeList[psId][sKey] = paoDatasToUpdate[sKey];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\taddBareme(pjBareme: any)\r\n\t{\r\n\r\n\t\tlet baremeData\t\t\t= JSON.parse(pjBareme.datas.data);\r\n\t\tpjBareme.datas.data\t\t= baremeData;\r\n\r\n\t\tif (pjBareme.datas.number && pjBareme.datas.number > this._mnLastNumber)\r\n\t\t{\r\n\t\t\tthis._mnLastNumber = +pjBareme.datas.number;\r\n\t\t}\r\n\r\n\t\tthis._majBaremeList[pjBareme.id] = pjBareme;\r\n\t}\r\n\r\n\r\n\taddBaremes(pajBareme: any)\r\n\t{\r\n\t\tfor (let jBareme of pajBareme)\r\n\t\t{\r\n\t\t\tthis.addBareme(jBareme);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic getLastId():number\r\n\t{\r\n\t\tthis._mnLastNumber++;\r\n\r\n\t\treturn this._mnLastNumber;\r\n\t}\r\n}\r\n","import { Injectable, EventEmitter } from '@angular/core';\r\nimport { GenericData }\t\t\t\tfrom './generic-data';\r\nimport { UserData }\t\t\t\t\tfrom './user-data';\r\nimport { Piece }\t\t\t\t\tfrom '../classes/piece.class';\r\nimport { User}\t\t\t\t\t\tfrom '../classes/user.class';\r\nimport { Message }\t\t\t\t\tfrom '../classes/message.class';\r\nimport { SocketService }\t\t\tfrom '../services/socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * Class UserData\r\n */\r\nexport class ChatData extends GenericData\r\n{\r\n\tprivate _idNewRoom:\t\t\tstring\t= '';\r\n\tprivate _rooms:\t\t\t\tPiece[]\t= [];\r\n\tprivate _selectedRoom:\t\tPiece\t= null;\r\n\tprivate _users:\t\t\t\tUser[]\t= [];\r\n\tprivate _userByRoom:\t\tany[][]\t= [];\r\n\tprivate _messagesByRoom:\tany[]\t= [];\r\n\tprivate _haveChatData:\t\tboolean\t= false;\r\n public socket:\t\t\t\tany;\r\n\r\n\tprivate _isRoomOk:\t\tboolean\t= false;\r\n\tprivate _isRoomInfoOk:\tboolean\t= false;\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(\t\tpublic\tuserData:\t\tUserData , \t\tpublic socketService:\t\t\tSocketService)\r\n\t{\r\n\t\tsuper();\r\n\t}\r\n\r\n\r\n\t// ---------------------------------------\r\n\t// Getters\r\n\t// ---------------------------------------\r\n\tget idNewRoom():\t\t\t\tstring\t{ return this._idNewRoom; }\r\n\tget users():\t\t\t\t\tUser[]\t{ return this._users; }\r\n\tget selectedRoom():\t\t\t\tPiece\t{ return this._selectedRoom; }\r\n\tget userByRoom():\t\t\t\tany[]\t{ return this._userByRoom; }\r\n\tget messagesByRoom():\t\t\tany[]\t{ return this._messagesByRoom; }\r\n\tget haveChatData():\t\t\t\tboolean\t{ return this._haveChatData; }\r\n\tget isRoomOk():\t\t\t\t\tboolean\t{ return this._isRoomOk; }\r\n\tget isRoomInfoOk():\t\t\t\tboolean\t{ return this._isRoomInfoOk; }\r\n\r\n\r\n\t/**\r\n\t * Petit truc spécial, on enregistre avec l'id en clef pour manipuler plus facilement\r\n\t * mais on push à la bourrin le retour pour faciliter l'utilisation dans les templates\r\n\t */\r\n\tget rooms(): Piece[]\r\n\t{\r\n\r\n\t\tlet buffRoom: Piece[]\t= [];\r\n\t\tlet numberOfRoom\t\t= 0;\r\n\r\n\r\n\t\tfor (let idRoom in this._rooms)\r\n\t\t{\r\n\t\t\tbuffRoom.push(this._rooms[idRoom]);\r\n\t\t\tnumberOfRoom++;\r\n\t\t}\r\n\r\n\r\n\t\t// Si y'a des rooms on l'indique;\r\n\t\tif (numberOfRoom > 0)\r\n\t\t{\r\n\t\t\tthis.haveChatData = true;\r\n\t\t}\r\n\r\n\t\treturn buffRoom;\r\n\t}\r\n\r\n\r\n\tpublic getMessagesByRoomId(idRoom: any): any[]\r\n\t{\r\n\t\tif (this._rooms[idRoom] && this._rooms[idRoom].messages)\r\n\t\t{\r\n\t\t\treturn this._rooms[idRoom].messages;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic getUser(idUser: any) { return this._users[idUser]; }\r\n\r\n\r\n\r\n\tpublic getUserIcon(idUser: any)\r\n\t{\r\n\t\tlet user = this._users[idUser];\r\n\t\tlet sName: string = '';\r\n\r\n\t\tif (user)\r\n\t\t{\r\n\t\t\tsName = user.nom.charAt(0);\r\n\t\t\tsName += user.prenom.charAt(0);\r\n\t\t}\r\n\t\treturn sName;\r\n\r\n\t}\r\n\r\n\r\n\tpublic setUserState(value: any, key: any)\r\n\t{\r\n\t\tif (this._users[key])\r\n\t\t{\r\n\t\t\tif (value === 'online')\r\n\t\t\t{\r\n\t\t\t\tthis._users[key].status = true;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis._users[key].status = false;\r\n\t\t\t}\r\n\t\t\tthis._users[key].lastDateCo = Date.now().toString();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic getUserState(userList: any)\r\n\t{\r\n\t\tlet me\t\t= this.userData.getUserId();\r\n\t\tlet sReturn = false;\r\n\t\tlet oReturn = null;\r\n\r\n\t\tif (userList && userList.length > 0)\r\n\t\tfor (let item of userList)\r\n\t\t\t{\r\n\t\t\t\tif (item.mail !== me)\r\n\t\t\t\t{\r\n\t\t\t\t\toReturn = this.getUser(item.mail);\r\n\t\t\t\t\tif (oReturn)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsReturn = oReturn.status;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\treturn sReturn;\r\n\t}\r\n\r\n\r\n\tpublic getUserColor(userList: any)\r\n\t{\r\n\r\n\t\tlet me\t\t= this.userData.getUserId();\r\n\t\tlet sReturn = '#ffffff';\r\n\t\tlet oReturn = null;\r\n\r\n\t\tif (userList && userList.length > 0)\r\n\t\t{\r\n\t\t\tfor (let item of userList)\r\n\t\t\t{\r\n\t\t\t\tif (item.mail !== me)\r\n\t\t\t\t{\r\n\t\t\t\t\toReturn = this.getUser(item.mail);\r\n\t\t\t\t\tif (oReturn)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsReturn = oReturn.color;\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn sReturn;\r\n\t}\r\n\r\n\r\n\tpublic getLastname(userList: any)\r\n\t{\r\n\t\tlet me\t\t= this.userData.getUserId();\r\n\t\tlet sReturn = '';\r\n\t\tlet oReturn = null;\r\n\r\n\t\tif (userList && userList.length > 0)\r\n\t\t{\r\n\t\t\tfor (let item of userList)\r\n\t\t\t{\r\n\t\t\t\tif (item.mail !== me)\r\n\t\t\t\t{\r\n\t\t\t\t\toReturn = this.getUser(item.mail);\r\n\t\t\t\t\tif (oReturn)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsReturn = oReturn.prenom;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\treturn sReturn;\r\n\t}\r\n\r\n\r\n\t// ------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n\t// Setters\r\n\t// ------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n\tset idNewRoom(idNewRoom)\t\t{ this._idNewRoom\t\t= idNewRoom; }\r\n\tset rooms(rooms)\t\t\t\t{ this._rooms\t\t\t= rooms; }\r\n\tset selectedRoom(selectedRoom)\t{ this._selectedRoom\t= selectedRoom; }\r\n\tset users(users)\t\t\t\t{ this._users\t\t\t= users; }\r\n\tset userByRoom(userByRoom)\t\t{ this._userByRoom\t\t= userByRoom; }\r\n\tset messagesByRoom(userByRoom)\t{ this._messagesByRoom\t= userByRoom; }\r\n\tset haveChatData(haveChatData)\t{ this._haveChatData\t= haveChatData; }\r\n\r\n\t/**\r\n\t * Quand on a les data, si les 2 sont ok on precess, a la fin du process haveDatachat = true;\r\n\t */\r\n\tset isRoomOk(isRoomOk)\r\n\t{\r\n\t\tthis._isRoomOk = isRoomOk;\r\n\t\tif (this._isRoomOk && this._isRoomInfoOk)\r\n\t\t{\r\n\t\t\tthis.processChat();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Quand on a les data, si les 2 sont ok on precess, a la fin du process haveDatachat = true;\r\n\t */\r\n\tset isRoomInfoOk(isRoomInfoOk)\r\n\t{\r\n\t\tthis._isRoomInfoOk = isRoomInfoOk;\r\n\t\tif (this._isRoomOk && this._isRoomInfoOk)\r\n\t\t{\r\n\t\t\tthis.processChat();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t// ---------------------------------------\r\n\t// Spécial\r\n\t// ---------------------------------------\r\n\t/**\r\n\t * Affecte une room via l'id\r\n\t */\r\n\tpublic setRoom(idRoom: number, room: Piece) { this._rooms[idRoom] = room; }\r\n\r\n\tpublic deleteRoom(idRoom: number)\r\n\t{\r\n\t\tif (this._rooms[idRoom])\r\n\t\t{\r\n\t\t\tdelete this._rooms[idRoom];\r\n\r\n\t\t\tif (this._selectedRoom && this._selectedRoom.id === idRoom.toString())\r\n\t\t\t{\r\n\t\t\t\tthis._selectedRoom = undefined;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tpublic setUser(idUser: any, user: any)\r\n\t{\r\n\t\tthis._users[idUser] = User.fromJsonObject(user);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Pour une room donnée on va ajouter un utilisateur (apellée a la reception des messages lus par room)\r\n\t */\r\n\tpublic setUserByRoom(idRoom: any, userId: any)\r\n\t{\r\n\t\tif (typeof this._userByRoom[idRoom] === undefined || typeof this._userByRoom[idRoom] === 'undefined')\r\n\t\t{\r\n\t\t\tthis._userByRoom[idRoom] = [];\r\n\t\t\tthis._userByRoom[idRoom].push(userId);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis._userByRoom[idRoom].push(userId);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * TODO meme qu'en haut .. voir laquelle est utilisée pr delet l'autre\r\n\t */\r\n\tpublic setUserByRoom2(idRoom: any, userId: any)\r\n\t{\r\n\r\n\t\tif (userId && userId !== this.userData.getUserId())\r\n\t\t{\r\n\t\t\tlet userInfo = this.userData.getUser(userId);\r\n\t\t\tthis._rooms[idRoom].description = userId;\r\n\t\t\tif (userInfo && userInfo.infos && userInfo.infos.nom)\r\n\t\t\t{\r\n\r\n\t\t\t\tthis._rooms[idRoom].displayName = userInfo.infos.nom + ' ' + userInfo.infos.prenom;\r\n\t\t\t\tthis._rooms[idRoom].users.push(userInfo);\r\n\t\t\t}\r\n\t\t\telse if (userInfo)\r\n\t\t\t{\r\n\t\t\t\tthis._rooms[idRoom].users.push(userInfo);\r\n\t\t\t\tthis._rooms[idRoom].displayName = userId;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis._rooms[idRoom].displayName = userId;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\t/**\r\n\t * Voir si elle est utile\r\n\t */\r\n\tpublic setLastMessageIdByRoom(idRoom: any, idMessage: any)\r\n\t{\r\n\t\t\tthis._rooms[idRoom].lastId = idMessage;\r\n\r\n\t}\r\n\tpublic setLastMessageReadedByMeByRoom(roomId: any, messageTicks: any)\r\n\t{\r\n\t\tthis._rooms[roomId].lastIdReadedByMe = messageTicks;\r\n\t}\r\n\tpublic setLastMessageReadedByHimByRoom(roomId: any, messageTicks: any)\r\n\t{\r\n\t\tthis._rooms[roomId].lastIdReadedByHim = messageTicks;\r\n\t}\r\n\r\n\r\n\tpublic setLastMessageReceivedByMeByRoom(roomId: any, messageTicks: any)\r\n\t{\r\n\t\tthis._rooms[roomId].lastIdReceivedByMe = messageTicks;\r\n\t}\r\n\tpublic setLastMessageReceivedByHimByRoom(roomId: any, messageTicks: any)\r\n\t{\r\n\t\tthis._rooms[roomId].lastIdReceivedByHim = messageTicks;\r\n\t}\r\n\r\n\tpublic setFirstMessageByRoom(roomId: any, messageTicks: any)\r\n\t{\r\n\t\t\tthis._rooms[roomId].firstId = messageTicks;\r\n\t}\r\n\r\n\r\n\tgetTotalCounter()\r\n\t{\r\n\t\tlet totalReturn = 0;\r\n\r\n\t\tlet arrayOfKey = [];\r\n\r\n\t\tfor (let key in this._rooms)\r\n\t\t{\r\n\t\t\tarrayOfKey.push(key);\r\n\t\t}\r\n\t\tlet key2: any;\r\n\t\tfor (key2 of arrayOfKey)\r\n\t\t{\r\n\t\t\ttotalReturn += this._rooms[key2].counter;\r\n\t\t}\r\n\t\treturn totalReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * bon hein, les compteurs quoi !\r\n\t */\r\n\tpublic incrementCounterByRoom(idRoom: any)\r\n\t{\r\n\t\tthis._rooms[idRoom].counter += 1;\r\n\r\n\t}\r\n\tpublic setCounterByRoom(idRoom: any, counter: any)\r\n\t{\r\n\t\t// moins 1 car il y a le message systeme au début ........\r\n\t\tthis._rooms[idRoom].counter = counter;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * est apellé quand on ouvre une room, permet également d'envoyer la notif de la lecture du message\r\n\t */\r\n\tpublic setMessagesByRoom(idRoom: any, messages: any)\r\n\t{\r\n\t\tlet arrayMessage = _.toArray(messages);\r\n\t\tlet indice = 0;\r\n\r\n\r\n\t\tlet arrayId = [];\r\n\r\n\t\tfor(let id in messages)\r\n\t\t{\r\n\t\t\tarrayId.push(id);\r\n\t\t}\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Reconstruction d'un tableau template friendly\r\n\t\t// ---------------------------------------\r\n\t\tfor (let key in messages)\r\n\t\t{\r\n\t\t\tarrayMessage[indice].key\t= new Date(messages[key].dateticks);\r\n\t\t\tarrayMessage[indice].id\t\t= arrayId[indice];\r\n\t\t\tindice++;\r\n\t\t}\r\n\r\n\t\tlet nIndice = 0;\r\n\r\n\t\tfor (let keyDate of arrayMessage)\r\n\t\t{\r\n\t\t\tlet globalDate = keyDate.key;\r\n\r\n\t\t\t// Pour éviter les message systemes\r\n\t\t\tif (keyDate.val && keyDate.sub !== 'SYS')\r\n\t\t\t{\r\n\t\t\t\tlet values = JSON.parse(keyDate.val);\r\n\r\n\t\t\t\tlet eScocketMessage;\r\n\t\t\t\tlet oMessage = new Message();\r\n\r\n\t\t\t\t// eScocketMessage = JSON.parse(values.message);\r\n\t\t\t\toMessage.ticks\t\t= keyDate.id;\r\n\t\t\t\toMessage.content\t= values.args.message;\r\n\t\t\t\toMessage.userId\t\t= values.name;\r\n\t\t\t\toMessage.date\t\t= keyDate.dateticks;\r\n\r\n\t\t\t\tif (this._rooms && this._rooms[idRoom])\r\n\t\t\t\t{\r\n\t\t\t\t\tif (oMessage)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis._rooms[idRoom].setMessageById(oMessage, keyDate.id);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (nIndice === 0 && this._rooms[idRoom].lastDate < keyDate.dateticks)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis._rooms[idRoom].lastId\t\t= keyDate.id;\r\n\t\t\t\t\t\tthis._rooms[idRoom].lastDate\t= keyDate.dateticks;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (this._rooms[idRoom].firstDate > keyDate.dateticks || !this._rooms[idRoom].firstId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis._rooms[idRoom].firstId\t\t= keyDate.id;\r\n\t\t\t\t\t\tthis._rooms[idRoom].firstDate\t= keyDate.dateticks;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tnIndice++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (this._rooms[idRoom] && this._rooms[idRoom].lastId && this._rooms[idRoom].lastIdReadedByMe && this._rooms[idRoom].lastId !== this._rooms[idRoom].lastIdReadedByMe)\r\n\t\t{\r\n\t\t\tthis._rooms[idRoom].lastIdReadedByMe = this._rooms[idRoom].lastId;\r\n\r\n\t\t\t// Ici on est dans le cas de message non lu, on envoie donc un readed avec l'id en question\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t\t'cmd': 'msg.read',\r\n\t\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tbucket:\t\t'rooms',\r\n\t\t\t\t\t\t\t\tnotifier:\t['*room::' + idRoom + '::priv'],\r\n\t\t\t\t\t\t\t\tkey:\t\tidRoom,\r\n\t\t\t\t\t\t\t\tsub:\t\t'M',\r\n\t\t\t\t\t\t\t\twhen:\t\tthis._rooms[idRoom].lastIdReadedByMe\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('update', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t\tthis.selectedRoom = null;\r\n\t\tthis.selectedRoom = this._rooms[idRoom];\r\n\r\n\t}\r\n\r\n\r\n\tpublic addRooms(value: any, key: any)\r\n\t{\r\n\t\tthis._rooms[key] = value;\r\n\t}\r\n\r\n\r\n\tpublic setSelectedRoomBy(id: any)\r\n\t{\r\n\t\tthis._selectedRoom = this._rooms[id];\r\n\t}\r\n\r\n\r\n\tpublic getUserByRoom(idRoom: any) { return this._userByRoom[idRoom];}\r\n\r\n\r\n\t/**\r\n\t * Comme d'un coté on récup les rooms et les messages lus (et les compteurs..) une fois qu'on a toute les infos\r\n\t * cette fonction se charge de tt mettre en ordre pr la suite\r\n\t */\r\n\tpublic processChat()\r\n\t{\r\n\t\tfor (let key in this._rooms)\r\n\t\t{\r\n\r\n\t\t\tlet usersRoom = this.getUserByRoom(key);\r\n\r\n\t\t\tfor (let user of usersRoom)\r\n\t\t\t{\r\n\t\t\t\tif (user !== this.userData.getUserId() && user)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet userInfo \t\t\t\t\t= this.userData.getUser(user);\r\n\t\t\t\t\tthis._rooms[key].description\t= user;\r\n\r\n\t\t\t\t\tif (userInfo.infos.nom)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis._rooms[key].displayName = userInfo.infos.nom + ' ' + userInfo.infos.prenom;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis._rooms[key].displayName = user;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\t// on et les booleans pr ne pas repasser ds la fonction\r\n\t\tthis._isRoomOk\t\t= false;\r\n\t\tthis._isRoomInfoOk\t= false;\r\n\t\tthis._haveChatData\t= true;\r\n\t}\r\n\r\n\r\n\tsetSelectedRoomByMail(mail: any)\r\n\t{\r\n\t\tlet found = false;\r\n\r\n\r\n\t\tlet arrayId = [];\r\n\r\n\r\n\t\tfor (let key in this._rooms)\r\n\t\t{\r\n\t\t\tarrayId.push(key);\r\n\t\t}\r\n\r\n\t\tlet key2: any;\r\n\t\tfor (key2 of arrayId)\r\n\t\t{\r\n\t\t\tfor (let user of this._rooms[key2].users)\r\n\t\t\t{\r\n\t\t\t\tif (user.mail === mail)\r\n\t\t\t\t{\r\n\t\t\t\t\tfound = true;\r\n\t\t\t\t\tthis.setSelectedRoomBy(key2);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\tlet userId = this.userData.getUserId();\r\n\r\n\t\tif (!found && mail !== userId)\r\n\t\t{\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// Ici il va falloir créer une room ...\r\n\t\t\t// ---------------------------------------\r\n\t\t\tthis.userData.userForChatInvite = this.userData.getUser(mail);\r\n\t\t\tlet eSocketWhat: SocketWhat.request;\r\n\r\n\t\t\t// Lib auto permet d'avoir un nom automatique en fonction de la personne avec qui on communique.\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.socket = socket;\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': userId,\r\n\t\t\t\t\t\t\t'what': eSocketWhat,\r\n\t\t\t\t\t\t\t'cmd': 'room',\r\n\t\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t'libAuto': \t\ttrue,\r\n\t\t\t\t\t\t\t\t'owner': \t\tuserId,\r\n\t\t\t\t\t\t\t\t'isPublic': \tfalse,\r\n\t\t\t\t\t\t\t\t'isReadOnly': \tfalse\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\tsocket.emit('create', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic canGetChatData()\r\n\t{\r\n\t\treturn this._haveChatData;\r\n\t}\r\n\r\n\r\n}\r\n\r\n","import { Injectable }\t\tfrom '@angular/core';\r\nimport { GenericData }\t\tfrom './generic-data';\r\nimport { WorkspaceData }\tfrom './workspace-data';\r\nimport { TaskData }\t\t\tfrom './task-data';\r\nimport { UserData }\t\t\tfrom './user-data';\r\n\r\nimport { File as EFile }\tfrom '../classes/file.class';\r\nimport * as _\t\t\t\tfrom 'underscore';\r\n\r\n// import { Storage } from '@ionic/storage';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * Class UserData\r\n */\r\nexport class FileData extends GenericData\r\n{\r\n\r\n\t// Selection user\r\n\r\n\t// Les datas\r\n\r\n\tpublic currentSortName\t= '';\r\n\tpublic currentAsc\t\t= '';\r\n\t/**\r\n\t * Stockage des taches récupérées dans l'appli\r\n\t */\r\n\tprivate _filterList:\t\tany\t= [];\r\n\tprivate _taskList:\t\t\tany = [];\r\n\tprivate _haveData:\t\t\tboolean = true;\r\n\tprivate _arrayFiles:\t\tEFile[];\r\n\tprivate _sorterList:\t\tany[];\r\n\tprivate _sorterSelected:\tany;\r\n\tprivate _taskListSelected:\tany;\r\n\tprivate _filterSelected:\tany;\r\n\r\n\tpublic listTypesDocument = [\r\n\t\t{\r\n\t\t\tlabel: 'Sujet',\r\n\t\t\tvalue: 'sujet'\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'Document Réponse',\r\n\t\t\tvalue: 'docRep'\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'Document Annexe',\r\n\t\t\tvalue: 'docAnn'\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'Barème',\r\n\t\t\tvalue: 'bareme'\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'Correction',\r\n\t\t\tvalue: 'correction'\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'Document de test',\r\n\t\t\tvalue: 'docTest'\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'Source',\r\n\t\t\tvalue: 'source'\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'Mémo de correction',\r\n\t\t\tvalue: 'memo'\r\n\t\t},\r\n\t\t{\r\n\t\t\tlabel: 'Bon A Tirer (BAT)',\r\n\t\t\tvalue: 'bat'\r\n\t\t}];\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(public workspaceData:\tWorkspaceData,\r\n\t\t\t\tpublic taskData:\t\tTaskData,\r\n\t\t\t\tpublic userData:\t\tUserData)\r\n\t{\r\n\t\tsuper();\r\n\t}\r\n\r\n\r\n\tget arrayFiles()\t\t{ return this._arrayFiles; }\r\n\t\r\n\tget filterList()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key of this._filterList)\r\n\t\t{\r\n\t\t\toReturn.push(key);\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\tget taskList()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let item of this._taskList)\r\n\t\t{\r\n\t\t\toReturn.push(item);\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t }\r\n\r\n\r\n\tget sorterList()\t\t{ return this._sorterList; }\r\n\tget sorterSelected()\t{ return this._sorterSelected; }\r\n\tget filterSelected()\t{ return this._filterSelected; }\r\n\tget taskListSelected()\t{ return this._taskListSelected; }\r\n\tget haveData()\t\t\t{ return this._haveData; }\r\n\r\n\r\n\tset haveData(haveData)\t\t\t\t\t{ this._haveData\t\t\t= haveData; }\r\n\tset arrayFiles(arrayFiles)\t\t\t\t{ this._arrayFiles\t\t\t= arrayFiles; }\r\n\tset taskList(taskList)\t\t\t\t\t{ this._taskList\t\t\t= taskList; }\r\n\tset filterList(filterList)\t\t\t\t{ this._filterList\t\t\t= filterList; }\r\n\tset sorterList(sorterList)\t\t\t\t{ this._sorterList\t\t\t= sorterList; }\r\n\tset sorterSelected(sorterSelected)\t\t{ this._sorterSelected\t\t= sorterSelected; }\r\n\tset filterSelected(filterSelected)\t\t{ this._filterSelected\t\t= filterSelected; }\r\n\tset taskListSelected(taskListSelected)\t{ this._taskListSelected\t= taskListSelected; }\r\n\r\n\r\n\r\n\t/**\r\n\t * TODO tableau de conversion à prévoir pour voir les bons nom.\r\n\t * Renommer filter en sort et filter2 en filter\r\n\t */\r\n\tpublic synchronize()\r\n\t{\r\n\t\t\r\n\t\tlet taskArray = this.taskData.globalTaskDatas;\r\n\r\n\t\tthis.arrayFiles = this.workspaceData.selectedSujet.pj;\r\n\r\n\t\tif (this._arrayFiles.length > 0)\r\n\t\t{\r\n\t\t\tthis.haveData = true;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.haveData = false;\r\n\t\t}\r\n\r\n//\t\tthis._filterList['tous'] = 1;\r\n//\t\tthis._filterList['aucun'] = 1;\r\n\r\n\t\tlet filterTemp \t\t= [];\r\n\t\tlet filterId1: any \t= {};\r\n\t\tfilterId1.num\t\t= 1;\r\n\t\tfilterId1.id\t\t= 'tous';\r\n\t\tfilterId1.name\t\t= 'Tous';\r\n\t\tfilterTemp.push(filterId1);\r\n\r\n\t\tlet filterId2: any\t\t= {};\r\n\t\tfilterId2.num\t\t\t= 1;\r\n\t\tfilterId2.id\t\t\t= 'aucun';\r\n\t\tfilterId2.name\t\t\t= 'Sans type';\r\n\t\tfilterTemp.push(filterId2);\r\n\r\n\t\tlet filterId3: any\t\t= {};\r\n\t\tfilterId3.num\t\t\t= 1;\r\n\t\tfilterId3.id\t\t\t= 'corbeille';\r\n\t\tfilterId3.name\t\t\t= 'Corbeille';\r\n\t\tfilterTemp.push(filterId3);\r\n\r\n\t\tlet taskTemp:\tany\t= [];\r\n\t\tlet taskId:\t\tany = {};\r\n\t\t\r\n\t\ttaskId.num\t= 1;\r\n\t\ttaskId.id\t= 'toutes';\r\n\t\ttaskId.name = 'Toutes';\r\n\r\n\t\ttaskTemp.push(taskId);\r\n\r\n\r\n\t\tlet taskId2: any\t= {};\r\n\t\ttaskId2.num\t\t\t= 1;\r\n\t\ttaskId2.id\t\t\t= 'aucune';\r\n\t\ttaskId2.name\t\t= 'Aucune';\r\n\t\ttaskTemp.push(taskId2);\r\n\r\n\r\n\t\t// Récupération des types de documents\r\n\t\tfor (let document of this.arrayFiles)\r\n\t\t{\r\n\t\t\tif (document.typeDocument)\r\n\t\t\t{\r\n\t\t\t\tlet filterId4: any \t= {};\r\n\t\t\t\tfilterId4.num\t\t= 1;\r\n\t\t\t\tfilterId4.id\t\t= document.typeDocument;\r\n\r\n\t\t\t\t// Récupération du vrai nom\r\n\t\t\t\tfor (let typeDoc of this.listTypesDocument)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (typeDoc.value === document.typeDocument)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfilterId4.name = typeDoc.label;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tfilterTemp.push(filterId4);\r\n\t\t\t}\r\n\r\n\t\t\tif (document.taskId)\r\n\t\t\t{\r\n\t\t\t\tlet currentTask = this.taskData.getTaskById(document.taskId);\r\n\t\t\t\tif (currentTask && currentTask.typeLib)\r\n\t\t\t\t{\r\n\t\t\t\t\tdocument.currentStep = currentTask.typeLib;\r\n\t\t\t\t\tlet taskId3: any = {};\r\n\t\t\t\t\ttaskId3.num\t\t= 1;\r\n\t\t\t\t\ttaskId3.id\t\t= currentTask.type;\r\n\t\t\t\t\ttaskId3.name\t= currentTask.typeLib;\r\n\t\t\r\n\t\t\t\t\ttaskTemp.push(taskId3);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tthis._taskList\t\t= _.uniq(taskTemp,\t\tfalse, 'id');\r\n\t\tthis._filterList\t= _.uniq(filterTemp,\tfalse, 'id');\r\n\t\t\r\n\t\t\r\n\t\t// récupération des taches rattaché au document\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Remet à l'origine les fichier (efface le tri)\r\n\t */\r\n\tpublic raz()\r\n\t{\r\n\t\tthis.arrayFiles = this.workspaceData.selectedSujet.pj;\r\n\t\tif (this._arrayFiles.length > 0)\r\n\t\t{\r\n\t\t\tthis.haveData = true;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis.haveData = false;\r\n\t\t}\r\n\t\tthis.sorterSelected = '';\r\n\t\tthis.filterSelected = '';\r\n\t}\r\n\r\n\r\n\r\n\t/**\r\n\t * Tri la liste des fichier\r\n\t */\r\n\tpublic sortList(nameFilter: any, orderAsc: any)\r\n\t{\r\n\t\tthis.currentSortName\t= nameFilter;\r\n\t\tthis.currentAsc\t\t\t= orderAsc;\r\n\r\n\t\tthis._arrayFiles.sort(function (a, b)\r\n\t\t{\r\n\t\t\tlet nameA: any;\r\n\t\t\tlet nameB: any;\r\n\r\n\t\t\t// en fonction du choix user on applique le tri en quesiton\r\n\t\t\tswitch (nameFilter)\r\n\t\t\t{\r\n\t\t\t\tcase 'name':\r\n\t\t\t\t\t nameA = a.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t nameB = b.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'type':\r\n\t\t\t\t\t nameA = a.typeDocument;\r\n\t\t\t\t\t nameB = b.typeDocument;\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'date':\r\n\t\t\t\t\t nameA = a.dateCreation\r\n\t\t\t\t\t nameB = b.dateCreation;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tif (orderAsc)\r\n\t\t\t{\r\n\t\t\t\tif (nameA < nameB)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tif (nameA > nameB)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn 1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tif (nameA > nameB)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\tif (nameA < nameB)\r\n\t\t\t\t{\r\n\t\t\t\t\treturn 1;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// names must be equal\r\n\t\t\treturn 0;\r\n\t\t});\r\n\r\n\t}\r\n\r\n\r\n\tpublic filter(typeDoc: any, typeState: any, searchValue: any = undefined)\r\n\t{\r\n\t\t\r\n\t\tthis.synchronize();\r\n\t\tlet aResult\t\t\t= [];\r\n\t\tlet aResultState\t= [];\r\n\t\tlet aResultSearch\t= [];\r\n\r\n\t\tlet taskArray = this.taskData.globalTaskDatas;\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Partie type super\r\n\t\t// ---------------------------------------\r\n\t\tif (typeDoc === 'tous')\r\n\t\t{\r\n\t\t\tfor (let doc of this.arrayFiles)\r\n\t\t\t{\r\n\t\t\t\tif (doc.deleted === false)\r\n\t\t\t\t{\r\n\t\t\t\t\taResult.push(doc);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis._arrayFiles = aResult;\r\n\t\t}\r\n\t\telse if (typeDoc === 'aucun')\r\n\t\t{\r\n\t\t\tfor (let doc of this.arrayFiles)\r\n\t\t\t{\r\n\t\t\t\tif (doc.typeDocument === '' && doc.deleted === false)\r\n\t\t\t\t{\r\n\t\t\t\t\taResult.push(doc);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis._arrayFiles = aResult;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (typeDoc === 'corbeille')\r\n\t\t\t{\r\n\t\t\t\tfor (let doc of this.arrayFiles)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (doc.deleted === true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\taResult.push(doc);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tthis._arrayFiles = aResult;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tfor (let doc of this.arrayFiles)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (doc.typeDocument === typeDoc && doc.deleted === false)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\taResult.push(doc);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tthis._arrayFiles = aResult;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Partie type de tache\r\n\t\t// ---------------------------------------\r\n\t\tif (typeState === 'toutes')\r\n\t\t{\r\n\t\t}\r\n\t\telse if (typeState === 'aucune')\r\n\t\t{\r\n\t\t\tfor (let doc of this.arrayFiles)\r\n\t\t\t{\r\n\t\t\t\tif (doc.taskId === '')\r\n\t\t\t\t{\r\n\t\t\t\t\taResultState.push(doc);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis._arrayFiles = aResultState;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t\r\n\t\t\tfor (let document of this.arrayFiles)\r\n\t\t\t{\r\n\t\t\t\tif (document.taskId)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let task of taskArray)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (task.id === document.taskId && task.type === typeState)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\taResultState.push(document);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\r\n\t\t\tthis._arrayFiles = aResultState;\r\n\t\t}\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Partie recherche\r\n\t\t// ---------------------------------------\r\n\t\tif (searchValue)\r\n\t\t{\r\n\t\t\tlet searchValueWithoutSpaces = searchValue.replace(/\\s/g, '');\r\n\r\n\t\t\tif (searchValueWithoutSpaces !== '')\r\n\t\t\t{\r\n\t\t\t\tlet containsString;\r\n\t\t\t\tlet searchLowerCase\t\t= searchValue.toLowerCase();\r\n\t\t\t\tlet searchWithoutAccent = searchLowerCase.normalize('NFD').replace(/[\\u0300-\\u036f]/g, \"\");\r\n\r\n\t\t\t\tfor (let document of this.arrayFiles)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet nameLowerCase\t\t= document.name.toLowerCase();\r\n\t\t\t\t\tlet nameWithoutAccent\t= nameLowerCase.normalize('NFD').replace(/[\\u0300-\\u036f]/g, \"\");\r\n\r\n\t\t\t\t\tif (document.name)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcontainsString = nameWithoutAccent.indexOf(searchWithoutAccent) !== -1;\r\n\t\t\t\t\t\tif (containsString === true)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\taResultSearch.push(document);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t\tthis._arrayFiles = aResultSearch;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.sortList(this.currentSortName, this.currentAsc);\r\n\t}\r\n\r\n\r\n\r\n\r\n}\r\n","import { Injectable, EventEmitter } from '@angular/core';\r\n\r\n// import { Storage } from '@ionic/storage';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * Class UserData\r\n */\r\nexport class GenericData\r\n{\r\n\r\n\r\n\tpublic globalEmitter: EventEmitter = new EventEmitter();\r\n\tpublic globalEmitter2: EventEmitter = new EventEmitter();\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor()\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic getStorage(key: any)\r\n\t{\r\n\t\tlet value = localStorage.getItem(key);\r\n\r\n\t\tif (!value) { return; }\r\n\r\n\t\t// assume it is an object that has been stringified\r\n\t\tif (value[0] === \"{\" || value[0] === \"[\")\r\n\t\t{\r\n\t\t\tvalue = JSON.parse(value);\r\n\t\t}\r\n\r\n\t\treturn value;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic removeStorage(key: any)\r\n\t{\r\n\t\tlocalStorage.removeItem(key);\r\n\t}\r\n\t\r\n\t\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic store(key: any, data: any)\r\n\t{\r\n//\t\tif (!key || !data) { return; }\r\n\r\n\t\tif(typeof(data) === \"object\")\r\n\t\t{\r\n\t\t\tdata = JSON.stringify(data);\r\n\t\t}\r\n\r\n\t\tlocalStorage.setItem(key, data);\r\n\t}\r\n\r\n\r\n\r\n}\r\n\r\n","import { Injectable } from '@angular/core';\r\nimport { UserData }\tfrom './user-data';\r\nimport { GenericData } from './generic-data';\r\n\r\n@Injectable()\r\n/**\r\n *\r\n * @export\r\n * @class User\r\n */\r\nexport class SavedData extends GenericData\r\n{\r\n\t\tprivate _id:\t\t\t\t\t\tstring\t= '';\r\n\t\tprivate _lastSubjectId:\t\t\t\tany\t\t= null;\r\n\t\tprivate _lastDisciplineId:\t\t\tany\t\t= null;\r\n\t\tprivate _lastEtablissementId:\t\tany\t\t= null;\r\n\t\tprivate _lastSessionId:\t\t\t\tany\t\t= null;\r\n\t\tprivate _lastExamenId:\t\t\t\tany\t\t= null;\r\n\t\tprivate _lastTaskId:\t\t\t\tany\t\t= null;\r\n\t\tprivate _lastPath:\t\t\t\t\tany\t\t= null;\r\n\t\tprivate _lastGroup:\t\t\t\t\tany\t\t= null;\r\n\t\tprivate _openedNodes:\t\t\t\tany\t\t= null;\r\n\t\tprivate _paramsLog:\t\t\t\t\tany\t\t= null;\r\n\t\tprivate _isWorkspaceTaskChecked:\tany\t\t= '';\r\n\r\n\r\n /**\r\n * @memberOf User\r\n */\r\n\tconstructor(public userData: UserData)\r\n\t{\r\n\t\tsuper();\r\n\t\t// Une fois n'est pas coutume on va construire tt le bordel dans le constructeur à partir des infos dans le localStorage\r\n\t}\r\n\r\n\r\n\tget id(): string { return this._id; }\r\n\r\n\tget lastSubjectId()\r\n\t{\r\n\t\tlet oReturn = this._lastSubjectId;\r\n\r\n\t\tif (this._lastSubjectId === '')\r\n\t\t{\r\n\t\t\toReturn \t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::lastSubjectId');\r\n\t\t\tthis._lastSubjectId = oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tget lastDisciplineId()\r\n\t{\r\n\t\tlet oReturn = this._lastDisciplineId;\r\n\t\tif (this._lastDisciplineId === '')\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::lastDisciplineId');\r\n\t\t\tthis._lastDisciplineId = oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tget lastEtablissementId()\r\n\t{\r\n\t\tlet oReturn = this._lastEtablissementId;\r\n\t\tif (this._lastEtablissementId === '')\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::lastEtablissementId');\r\n\t\t\tthis._lastEtablissementId = oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\tget lastSessionId()\r\n\t{\r\n\t\tlet oReturn = this._lastSessionId;\r\n\t\tif (this._lastSessionId === '')\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::lastSessionId');\r\n\t\t\tthis._lastSessionId = oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tget openedNodes()\r\n\t{\r\n\t\tlet oReturn = this._openedNodes;\r\n\t\tif (this._openedNodes === null)\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::openedNodes');\r\n\r\n\t\t\tif (oReturn !== null)\r\n\t\t\t{\r\n\t\t\t\toReturn = JSON.parse(oReturn);\r\n\t\t\t}\r\n\r\n\t\t\tthis._openedNodes = oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tget lastGroup()\r\n\t{\r\n\r\n\t\tlet oReturn = this._lastGroup;\r\n\t\tif (this._lastGroup === null)\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::lastGroup');\r\n\t\t\tthis._lastGroup = oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\tget lastExamenId()\r\n\t{\r\n\t\tlet oReturn = this._lastExamenId;\r\n\t\tif (this._lastExamenId === '')\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::lastExamenId');\r\n\t\t\tthis._lastExamenId = oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\tget lastTaskId()\r\n\t{\r\n\t\tlet oReturn = this._lastTaskId;\r\n\t\tif (this._lastTaskId === '')\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::lastTaskId');\r\n\t\t\tthis._lastTaskId = oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\tget lastPath()\r\n\t{\r\n\t\tlet oReturn = this._lastPath;\r\n\t\tif (this._lastPath === null)\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::lastPath');\r\n\t\t}\r\n\r\n\t\tif (oReturn !== null && oReturn !== undefined && oReturn !== 'undefined')\r\n\t\t{\r\n\t\t\toReturn = JSON.parse(oReturn);\r\n\t\t\tthis._lastPath = oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\tget isWorkspaceTaskChecked()\r\n\t{\r\n\t\tlet oReturn = this._isWorkspaceTaskChecked;\r\n\t\tif (this._isWorkspaceTaskChecked === '')\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::isWorkspaceTaskChecked');\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\t/**\r\n\t * Récupération des paramètres de l'appli (options selectionnées, etc...)\r\n\t */\r\n\tget paramsLog()\r\n\t{\r\n\t\tlet oReturn = this._paramsLog;\r\n\r\n\t\tif (this._paramsLog === '')\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::paramsLog');\r\n\t\t\t\r\n\t\t\tif (oReturn !== null && oReturn !== undefined && oReturn !== 'undefined')\r\n\t\t\t{\r\n\t\t\t\toReturn = JSON.parse(oReturn);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\r\n\tset id(id) { this._id = id; }\r\n\r\n\r\n\tset lastSubjectId(lastSubjectId)\r\n\t{\r\n\t\tif (lastSubjectId)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::lastSubjectId', lastSubjectId);\r\n\t\t}\r\n\t\tthis._lastSubjectId = lastSubjectId;\r\n\t}\r\n\tset lastDisciplineId(lastDisciplineId)\r\n\t{\r\n\t\tif (lastDisciplineId)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::lastDisciplineId', lastDisciplineId);\r\n\t\t}\r\n\t\tthis._lastSubjectId = lastDisciplineId;\r\n\t}\r\n\tset lastEtablissementId(lastEtablissementId)\r\n\t{\r\n\t\tif (lastEtablissementId)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::lastEtablissementId', lastEtablissementId);\r\n\t\t}\r\n\t\tthis._lastEtablissementId = lastEtablissementId;\r\n\t}\r\n\tset lastSessionId(lastSessionId)\r\n\t{\r\n\t\tif (lastSessionId)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::lastSessionId', lastSessionId);\r\n\t\t}\r\n\t\tthis._lastSessionId = lastSessionId;\r\n\t}\r\n\tset lastExamenId(lastExamenId)\r\n\t{\r\n\t\tif (lastExamenId)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::lastExamenId', lastExamenId);\r\n\t\t}\r\n\t\tthis._lastExamenId = lastExamenId;\r\n\t}\r\n\tset lastTaskId(lastTaskId)\r\n\t{\r\n\t\tif (lastTaskId)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::lastTaskId', lastTaskId);\r\n\t\t}\r\n\t\tthis._lastTaskId = lastTaskId;\r\n\t}\r\n\r\n\r\n\tset lastPath(lastPath)\r\n\t{\r\n\t\tif (lastPath)\r\n\t\t{\r\n\t\t\tconst data = JSON.stringify(lastPath);\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::lastPath', data);\r\n\t\t}\r\n\t\tthis._lastPath = lastPath;\r\n\t}\r\n\r\n\r\n\tset lastGroup(lastGroup)\r\n\t{\r\n\t\tif (lastGroup)\r\n\t\t{\r\n\t\t\tconst data = JSON.stringify(lastGroup);\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::lastGroup', data);\r\n\t\t}\r\n\t\tthis._lastGroup = lastGroup;\r\n\t}\r\n\r\n\r\n\tset openedNodes(nodes)\r\n\t{\r\n\t\tif (nodes)\r\n\t\t{\r\n\t\t\tconst data = JSON.stringify(nodes);\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::openedNodes', data);\r\n\t\t}\r\n\t\tthis._openedNodes = nodes;\r\n\t}\r\n\r\n\tset isWorkspaceTaskChecked(isWorkspaceTaskChecked)\r\n\t{\r\n\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::isWorkspaceTaskChecked', isWorkspaceTaskChecked);\r\n\t\tthis._isWorkspaceTaskChecked = isWorkspaceTaskChecked;\r\n\r\n\t\t// On enregistre également l'information dans l'ensemble des paramètres logiciels\r\n\t\t// (utilisé lors de l'enregistrement en base de données)\r\n\t\tlet paramsLogs = this._paramsLog;\r\n\r\n\t\tif (paramsLogs === null)\r\n\t\t{\r\n\t\t\tparamsLogs = this.getStorage(this.userData.mail + '::' + this.userData.account + '::paramsLog');\r\n\r\n\t\t\tif (paramsLogs !== null && paramsLogs !== undefined && paramsLogs !== 'undefined')\r\n\t\t\t{\r\n\t\t\t\tparamsLogs = JSON.parse(paramsLogs);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tparamsLogs = {};\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tparamsLogs['worspaceTaskChecked'] = isWorkspaceTaskChecked;\r\n\t\tthis._paramsLog \t= paramsLogs;\r\n\t\tlet strParamsLogs \t= JSON.stringify(paramsLogs);\r\n\r\n\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::paramsLog', strParamsLogs);\r\n\t}\r\n\r\n\t\r\n\tset paramsLog(params)\r\n\t{\r\n\t\tif (params)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::paramsLog', params);\r\n\t\t}\r\n\t\tthis._paramsLog = params;\r\n\t}\r\n\r\n\r\n\tpublic getStorage(key: any)\r\n\t{\r\n\t\tlet oReturn;\r\n\t\toReturn = localStorage.getItem(key);\r\n\t\treturn oReturn;\r\n\t}\r\n\tpublic removeStorage(key: any)\r\n\t{\r\n\t\tlocalStorage.removeItem(key);\r\n\t}\r\n\tpublic store(key: any, data: any)\r\n\t{\r\n\t\tlocalStorage.setItem(key, data);\r\n\t}\r\n\r\n\tpublic logout()\r\n\t{\r\n\t\tthis._lastGroup \t\t\t= null;\r\n\t\tthis._openedNodes\t\t\t= null;\r\n\t\tthis._paramsLog\t\t\t\t= null;\r\n\t\tthis._lastPath \t\t\t\t= null;\r\n\t\tthis._lastSubjectId \t\t= null;\r\n\t\tthis._lastDisciplineId \t\t= null;\r\n\t\tthis._lastEtablissementId \t= null;\r\n\t\tthis._lastSessionId \t\t= null;\r\n\t\tthis._lastExamenId \t\t\t= null;\r\n\t\tthis._lastTaskId \t\t\t= null;\r\n\t\tthis._lastExamenId \t\t\t= null;\r\n\t\tthis._lastExamenId \t\t\t= null;\r\n\r\n\t}\r\n\r\n}\r\n\r\n","import { Injectable, EventEmitter, OnDestroy } from '@angular/core';\r\nimport { GenericData }\t\t\t\tfrom './generic-data';\r\nimport { WorkspaceData }\t\t\tfrom './workspace-data';\r\nimport { UserData }\t\t\t\t\tfrom './user-data';\r\nimport { Matiere }\t\t\t\t\tfrom '../classes/matiere.class';\r\nimport { Task }\t\t\t\t\t\tfrom '../classes/task.class';\r\nimport { SocketService }\t\t\tfrom '../services/socket.service';\r\n\r\n// import { Storage } from '@ionic/storage';\r\nimport * as _ from 'underscore';\r\n\r\n@Injectable()\r\n/**\r\n * Class UserData\r\n */\r\nexport class TaskData extends GenericData implements OnDestroy\r\n{\r\n\r\n\t/**\r\n\t * Stockage des taches récupérées dans l'appli\r\n\t */\r\n\tprivate _taskDatas:\t\t\t\t\tTask[]\t\t= [];\r\n\tprivate _globalTaskDatas:\t\t\tTask[]\t\t= [];\r\n\tprivate _epreuveByWorkflowSelected: Matiere[]\t= [];\r\n\r\n\tpublic taskDataEmitter: EventEmitter = new EventEmitter();\r\n\tpublic taskDataEmitter2: EventEmitter = new EventEmitter();\r\n\r\n\r\n\tget epreuveByWorkflowSelected()\t{ return this._epreuveByWorkflowSelected; }\r\n\tget taskDatas()\t\t\t\t\t{ return this._taskDatas; }\r\n\tget globalTaskDatas()\t\t\t{ return this._globalTaskDatas; }\r\n\r\n\tset taskDatas(taskDatas)\t\t\t\t{ this._taskDatas\t\t\t\t\t= taskDatas; }\r\n\tset globalTaskDatas(globalTaskDatas)\t{ this._globalTaskDatas\t\t\t\t= globalTaskDatas; }\r\n\tset epreuveByWorkflowSelected(psParam)\t{ this._epreuveByWorkflowSelected\t= psParam; }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(public workspaceData: WorkspaceData,\r\n\t\t\t\tpublic userData: UserData,\r\n\t\t\t\tpublic socketService: SocketService)\r\n\t{\r\n\t\tsuper();\r\n\t\tthis.workspaceData.setTaskData(this);\r\n\t}\r\n\r\n\r\n\tngOnDestroy()\r\n\t{\r\n\t\tthis.taskDataEmitter.unsubscribe();\r\n\t}\r\n\r\n\r\n\tpublic initTasks()\r\n\t{\r\n\t\tthis._taskDatas \t\t= [];\r\n\t\tthis._globalTaskDatas \t= [];\r\n\t}\r\n\r\n\r\n\tpublic majSubjectName(psIdSujet: any)\r\n\t{\r\n\r\n\t\tfor (const task of this._globalTaskDatas)\r\n\t\t{\r\n\t\t\tif (task.idSujet === psIdSujet)\r\n\t\t\t{\r\n\t\t\t\tconst oSujet = this.workspaceData.getSujet(psIdSujet);\r\n\t\t\t\ttask.nameSujet = oSujet.name;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\r\n\r\n\tpublic buildTask(oTask: any)\r\n\t{\r\n\t\tif (oTask)\r\n\t\t{\r\n\t\t\tconst epreuve\t\t\t= this.workspaceData.getEpreuve(oTask.idEpreuve);\r\n\t\t\tconst sujet\t\t\t\t= this.workspaceData.getSujet(oTask.idSujet);\r\n\t\t\tconst session\t\t\t= this.workspaceData.getSession(oTask.idSession);\r\n\t\t\tconst etablissement\t\t= this.workspaceData.getEtablissement(oTask.idEtablissement);\r\n\t\t\tconst examen\t\t\t= this.workspaceData.getExamen(oTask.idExamen);\r\n\r\n\t\t\toTask.nameSession\t\t= session\t\t? session.name\t\t\t: ' Non autorisé ';\r\n\t\t\toTask.nameEtablissement = etablissement\t? etablissement.name\t: ' Non autorisé ';\r\n\t\t\toTask.nameEpreuve\t\t= epreuve\t\t? epreuve.name\t\t\t: ' Non autorisé ';\r\n\t\t\toTask.nameSujet\t\t\t= sujet\t\t\t? sujet.name\t\t\t: ' Non autorisé ';\r\n\t\t\toTask.nameExamen\t\t= examen\t\t? examen.name\t\t\t: ' Non autorisé ';\r\n\r\n\t\t\toTask.stateLib = 'En cours';\r\n\r\n\t\t\t// récupération du nom de l'état de la tache\r\n\t\t\tfor (const item of oTask.statesAvailable)\r\n\t\t\t{\r\n\t\t\t\tif (item.value === oTask.state)\r\n\t\t\t\t{\r\n\t\t\t\t\toTask.stateLib = item.libelle;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Nom du type de tache\r\n\t\t\tif (epreuve && epreuve.scenario && epreuve.scenario.steps)\r\n\t\t\t{\r\n\t\t\t\tfor (const key in epreuve.scenario.steps)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (key === oTask.type)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\toTask.typeLib = epreuve.scenario.steps[key].name;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn oTask;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * sauvegarde de la liste des taches\r\n\t */\r\n\tpublic addTasks(data: any, pbMajSelected = false)\r\n\t{\r\n\r\n\t\tfor (const task of data)\r\n\t\t{\r\n\t\t\tlet oTask = Task.fromJsonObject(task);\r\n\t\t\toTask = this.buildTask(oTask);\r\n\r\n\t\t\tconst indexInTaskDatas = _.findIndex(this._taskDatas, (taskObj: any) => { return taskObj.id === oTask.id; });\r\n\r\n\t\t\tif (indexInTaskDatas === -1)\r\n\t\t\t{\r\n\t\t\t\tthis._taskDatas.push(oTask);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis._taskDatas[indexInTaskDatas] = this.buildTask(this._taskDatas[indexInTaskDatas]);\r\n\t\t\t}\r\n\r\n\t\t\t//On vérifie que la tache à ajouter n'est pas déja présente dans l'ensemble des\r\n\t\t\t//taches déja récupérées\r\n\t\t\tconst indexInGlobalTasks = _.findIndex(this._globalTaskDatas, (taskObj: any) => { return taskObj.id === oTask.id; });\r\n\r\n\t\t\tif (indexInGlobalTasks === -1)\r\n\t\t\t{\r\n\t\t\t\tthis._globalTaskDatas.push(oTask);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// On met à jour les infos de la tache existante\r\n\t\t\t\tthis._globalTaskDatas[indexInGlobalTasks] = this.buildTask(this._globalTaskDatas[indexInGlobalTasks]);\r\n\t\t\t}\r\n\r\n\t\t\tif (pbMajSelected)\r\n\t\t\t{\r\n\t\t\t\tthis.workspaceData.selectedTask = oTask;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tsetGlobalTask(taskId: any, task: Task)\r\n\t{\r\n\t\tconst indexInGlobalTasks = _.findIndex(this._globalTaskDatas, (taskObj: any) => { return taskObj.id === taskId; });\r\n\r\n\t\tif (indexInGlobalTasks !== -1)\r\n\t\t{\r\n\t\t\tthis._globalTaskDatas[indexInGlobalTasks] = task;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis._globalTaskDatas.push(task);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\r\n\t/**\r\n\t * Récupération d'une tache par son identifiant\r\n\t * @param idTask\r\n\t */\r\n\tpublic getTaskById(idTask: any)\r\n\t{\r\n\t\tconst result = _.find(this._globalTaskDatas, (task: any) => { return task.id === idTask; });;\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic listenTask(task: any)\r\n\t{\r\n\t\t// Construction du channel que l'on va écouter\r\n\t\tconst channel = '*soft::' + this.userData.account + '::creation::task::' + task.id;\r\n\t\t/**\r\n\t\t * On vérifie si on écoute pas déja sur le channe!\r\n\t\t * Si ce n'est pas le cas on ajoute une room pour écouter sur ce channel\r\n\t\t * en transmettant une fonction pour gérer les evènements\r\n\t\t */\r\n\t\tlet value = this.socketService.findRoomAGerer(channel);\r\n\r\n\t\tif (value < 0)\r\n\t\t{\r\n\t\t\tthis.socketService.roomsAGerer.push(\r\n\t\t\t\t{\r\n\t\t\t\t\tname:\t\tchannel,\r\n\t\t\t\t\tstate:\t\t'nosub',\r\n\t\t\t\t\twatch:\t\ttrue,\r\n\t\t\t\t\tfct:\t\tthis._handleTaskEvent.bind(this),\r\n\t\t\t\t\tchannel:\tundefined\r\n\t\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Permet la récupération des épreuves en fonction d'un workflow donné\r\n\t */\r\n\tpublic getEpreuveByWorkflow(workflowId: any)\r\n\t{\r\n\t\tlet arrayReturn = [];\r\n\t\tlet etablissements = this.workspaceData.etablissements;\r\n\r\n\t\tfor (let etablissement of etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of etablissement.sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let exam of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let matiere of exam.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (matiere.scenario)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// Récupérer l'étape de la derniere tache ! pour savoir ou en est l'épreuve\r\n\t\t\t\t\t\t\tif (matiere.scenario.title === workflowId)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\t// Fuck à partir d'ici il va falloir récupérer les taches par sujets\r\n\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\tlet maxStep= \"0\";\r\n\r\n\t\t\t\t\t\t\t\tfor (let task of this._globalTaskDatas)\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\tif (task.idEpreuve === matiere.id)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlet typeTask = task.type;\r\n\r\n\t\t\t\t\t\t\t\t\t\tlet indiceOfTask;\r\n\t\t\t\t\t\t\t\t\t\tlet indiceOfStep;\r\n\r\n\t\t\t\t\t\t\t\t\t\t// Si la tache correspond l'indice max des taches rattaché à ce sujet pour avoir l'avancement\r\n\r\n\t\t\t\t\t\t\t\t\t\t// Nom du type de tache\r\n\t\t\t\t\t\t\t\t\t\tfor (let step in matiere.scenario.steps)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\t\t\tif (parseInt(step) === parseInt(typeTask))\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tindiceOfStep = step;\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t\tif (parseInt(indiceOfStep) > parseInt(maxStep))\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tmaxStep = indiceOfStep;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tmatiere.maxStep = maxStep;\r\n\r\n\t\t\t\t\t\t\t\tarrayReturn.push(matiere);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._epreuveByWorkflowSelected = arrayReturn;\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Fonction apellé lorsque un tri par noeud est demandé\r\n\t */\r\n\tpublic filterTasks(typeOfFilter: any, id: any = null)\r\n\t{\r\n\r\n\t\tlet resultDatas: any[] = [];\r\n\t\tif (id)\r\n\t\t{\r\n\t\t\t// Raz des data, si on veut trier sur étab2 et que seulement les etab1 sont dispo ça va pas le faire\r\n\t\t\tresultDatas = this.globalTaskDatas;\r\n\r\n\t\t\tswitch (typeOfFilter)\r\n\t\t\t{\r\n\r\n\t\t\t\tcase 'etab':\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (step: any) =>\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tif (step.idEtablissement)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn step.idEtablissement === id;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// du code supplémentaire est nécéssaire car certaine tache ont été enregistré sans idEtablissement, du coup on va le chercher dans les sessions\r\n\t\t\t\t\t\t\tlet oEtablissements = this.workspaceData.etablissements;\r\n\r\n\t\t\t\t\t\t\tlet idEtabFinded;\r\n\t\t\t\t\t\t\tfor (let etab of oEtablissements)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tfor (let session of etab.sessions)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (session.id === step.idSession)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tidEtabFinded = etab.id;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\treturn idEtabFinded === id;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'sess':\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (task: any) => { return task.idSession == id; });\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'exam':\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (step: any) => { return step.idExamen === id; });\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'matiere':\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (step: any) => { return step.idEpreuve === id; });\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'suj':\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (step: any) => { return step.idSujet === id; });\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tresultDatas = this.globalTaskDatas;\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// Cas aucun => on filtre l'étape d'avant si elle est selectionnée\r\n\t\t\t// ---------------------------------------\r\n\t\t\tresultDatas = this.globalTaskDatas;\r\n\t\t\tlet filterId: any;\r\n\r\n\t\t\tswitch (typeOfFilter)\r\n\t\t\t{\r\n\r\n\t\t\t\tcase 'etab':\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'sess':\r\n\r\n\t\t\t\t\tfilterId\t= this.workspaceData.selectedEtablissement.id;\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (task: any) => { return task.idEtablissement == filterId; });\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'exam':\r\n\t\t\t\t\tfilterId\t= this.workspaceData.selectedSession.id;\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (task: any) => { return task.idSession == filterId; });\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'matiere':\r\n\t\t\t\t\tfilterId\t= this.workspaceData.selectedExamen.id;\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (task: any) => { return task.idExamen == filterId; });\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'suj':\r\n\t\t\t\t\tfilterId\t= this.workspaceData.selectedMatiere.id;\r\n\t\t\t\t\tresultDatas = _.filter(resultDatas, (task: any) => { return task.idEpreuve == filterId; });\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis.taskDatas = resultDatas;\r\n\t}\r\n\r\n\r\n\tpublic getTaskDatas()\r\n\t{\r\n\t\tlet aoReturn = [];\r\n\r\n\t\tfor (let key in this._globalTaskDatas)\r\n\t\t{\r\n\t\t\taoReturn.push(this._globalTaskDatas[key]);\r\n\t\t}\r\n\r\n\t\treturn aoReturn;\r\n\t}\r\n\r\n\r\n\tprivate _handleTaskEvent(datas: any)\r\n\t{\r\n\t\tif (datas.cmd === 'messages.set')\r\n\t\t{\r\n\t\t\tif (datas.args && datas.args.message)\r\n\t\t\t{\r\n\t\t\t\tlet messageAdded = this.workspaceData.parseHistoric(datas.args.message);\r\n\r\n\t\t\t\tthis.workspaceData.addHistoricToElement(datas.args.message.key, messageAdded);\r\n\t\t\t\tthis.workspaceData.globalEmitter.emit(['messages::get', datas.args.message.key]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n}\r\n\r\n","import { Injectable, EventEmitter, OnDestroy } from '@angular/core';\r\nimport * as _ from 'underscore';\r\n// import { Storage } from '@ionic/storage';\r\nimport { User } from '../classes/user.class';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * Class UserData\r\n */\r\nexport class UserData implements OnDestroy\r\n{\r\n\tpublic _favorites: any \t= [];\r\n\tpublic HAS_LOGGED_IN \t= 'hasLoggedIn';\r\n\tpublic TOKEN_KEY \t\t= 'tokenKey';\r\n\r\n\tpublic userDatas: any = null;\r\n\tpublic bddAccountConnected: string = null;\r\n\r\n\tpublic states: any =\r\n\t\t{\r\n\t\t\tapplication:\t'offline',\r\n\t\t\tchat:\t\t\t'offline',\r\n\t\t\tuserchat:\t\t'offline'\r\n\t\t};\r\n\r\n\r\n\tpublic static STATUS_ADMIN\t\t\t= 'admin';\r\n\tpublic static STATUS_RESPONSABLE\t= 'responsable';\r\n\tpublic static STATUS_SUPERVISEUR\t= 'superviseur';\r\n\tpublic static STATUS_USER\t\t\t= 'user';\r\n\r\n\r\n\tpublic static CONST_CHAT_ACTION_NEWMESSAGE\t\t= 'chat::newMessage';\r\n\tpublic static CONST_CHAT_ACTION_NEWROOM\t\t\t= 'chat::newRoom';\r\n\tpublic static CONST_CHAT_ACTION_NEWUSER\t\t\t= 'chat::newUser';\r\n\tpublic static CONST_CHAT_ACTION_USERCONNECTED\t= 'chat::userConnected';\r\n\tpublic static CONST_CHAT_ACTION_GETUSERLIST\t\t= 'chat::getUserList';\r\n\r\n\r\n\tprotected _setAccountInfo:\t\t\tany;\r\n\r\n\tprotected _canAccessChat:\t\t\tboolean = false;\r\n\tprotected _canAccessForum:\t\t\tboolean = false;\r\n\tprotected _canAccessNotification:\tboolean = false;\r\n\r\n\tprotected _canRead:\t\tboolean = false;\r\n\tprotected _canCreate:\tboolean = false;\r\n\tprotected _canUpdate:\tboolean = false;\r\n\tprotected _canDelete:\tboolean = false;\r\n\r\n\tprivate _id:\t\t\tstring\t= '';\r\n\tprivate _fingerPrint:\tstring\t= '';\r\n\tprivate _dateCreation:\tstring\t= '';\r\n\r\n\t// Partie du chat\r\n\tprivate _idNewRoom:\t\t\tstring\t= '';\r\n\tprivate _rooms:\t\t\t\tany[]\t= [];\r\n\tprivate _users:\t\t\t\tUser[]\t= [];\r\n\tprivate _userByRoomId:\t\tany[]\t= [];\r\n\tprivate _messagesByRoomId:\tany[]\t= [];\r\n\tprivate _firstLetterIcone\t\t\t= '';\r\n\tprivate _color\t\t\t= '';\r\n\r\n\t// Status de l'user conencté, par défaut il possède le status de simple utilisateur\r\n\tprivate _status:\t\t\tstring\t= UserData.STATUS_USER;\r\n\tprivate _isServer:\t\t\tboolean = false;\r\n\tprivate _mail:\t\t\t\tstring\t= '';\r\n\tprivate _username:\t\t\tstring\t= '';\r\n\tprivate _accounts:\t\t\tany[]\t= [];\r\n\tprivate _account:\t\t\tstring\t= '';\r\n\tprivate _isAccountSelected:\tboolean = false;\r\n\tprivate _right:\t\t\t\tstring\t= '';\r\n\tprivate _role:\t\t\t\tstring\t= '';\r\n\tprivate _firstName:\t\t\tstring\t= '';\r\n\tprivate _lastName:\t\t\tstring\t= '';\r\n\tprivate _userId:\t\t\tstring\t= '';\r\n\tprivate _deleted:\t\t\tboolean = false;\r\n\tprivate _userForChatInvite:\tany\t\t= null;\r\n\r\n\tprivate _connected:\t\t\tboolean = false;\r\n\tprivate _otpAuth:\t\t\tboolean\t= false;\r\n\tprivate _methodAuth:\t\tany\t\t= 1;\r\n\tprivate _mustReset:\t\t\tboolean = false;\r\n\tprivate _mustValidateBrowser:boolean = false;\r\n\r\n\r\n\tpublic mbIsPrinter: boolean = false;\r\n\r\n\tprivate _dialogRefModalConnection: any = null;\r\n\r\n\t/**\r\n\t * Stockage des évènements du calendrier\r\n\t */\r\n\tprivate _calendarDatas:\tany = {};\r\n\r\n\t/**\r\n\t * Stockage des taches récupérées dans l'appli\r\n\t */\r\n\tprivate _taskDatas:\t\tany = {};\r\n\r\n\tpublic globalEmitter: \tEventEmitter = new EventEmitter();\r\n\tpublic notifEmitter: \tEventEmitter = new EventEmitter();\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor()\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\tngOnDestroy()\r\n\t{\r\n\t\tthis.globalEmitter.unsubscribe();\r\n\t\tthis.notifEmitter.unsubscribe();\r\n\t}\r\n\r\n\r\n\tpublic getStorage(key: any)\r\n\t{\r\n\t\tlet value = localStorage.getItem(key);\r\n\r\n\t\tif (!value) { return; }\r\n\r\n\t\t// assume it is an object that has been stringified\r\n\t\tif (value[0] === \"{\" || value[0] === \"[\")\r\n\t\t{\r\n\t\t\tvalue = JSON.parse(value);\r\n\t\t}\r\n\r\n\t\treturn value;\r\n\t}\r\n\r\n\r\n\r\n\tpublic removeStorage(key: any)\r\n\t{\r\n\t\tlocalStorage.removeItem(key);\r\n\t}\r\n\r\n\tpublic store(key: any, data: any)\r\n\t{\r\n//\t\tif (!key || !data) { return; }\r\n\r\n\t\tif(typeof(data) === \"object\")\r\n\t\t{\r\n\t\t\tdata = JSON.stringify(data);\r\n\t\t}\r\n\t\tlocalStorage.setItem(key, data);\r\n\t}\r\n\r\n\r\n\r\n\r\n\tget id():\t\t\t\t\t\tstring\t{ return this._id; }\r\n\tget fingerPrint():\t\t\t\tstring\t{ return this._fingerPrint; }\r\n\tget dateCreation():\t\t\t\tstring\t{ return this._dateCreation; }\r\n\tget isServer():\t\t\t\t\tboolean { return this._isServer; }\r\n\tget mail():\t\t\t\t\t\tstring\t{ return this._mail; }\r\n\tget username():\t\t\t\t\tstring\t{ return this._username; }\r\n\tget accounts():\t\t\t\t\tany[]\t{ return this._accounts; }\r\n\tget account():\t\t\t\t\tstring\t{ return this._account; }\r\n\tget isAccountSelected():\t\tboolean\t{ return this._isAccountSelected; }\r\n\tget right():\t\t\t\t\tstring\t{ return this._right; }\r\n\tget role():\t\t\t\t\t\tstring\t{ return this._role; }\r\n\tget firstName():\t\t\t\tstring\t{ return this._firstName; }\r\n\tget firstLetterIcone():\t\t\tstring\t{ return this._firstLetterIcone; }\r\n\tget color():\t\t\tstring\t{ return this._color; }\r\n\tget lastName():\t\t\t\t\tstring\t{ return this._lastName; }\r\n\tget deleted():\t\t\t\t\tboolean { return this._deleted; }\r\n\tget status():\t\t\t\t\tstring\t{ return this._status; }\r\n\tget idNewRoom():\t\t\t\tstring\t{ return this._idNewRoom; }\r\n\tget canAccessChat():\t\t\tboolean { return this._canAccessChat; }\r\n\tget canAccessForum():\t\t\tboolean { return this._canAccessForum; }\r\n\tget canAccessNotification():\tboolean { return this._canAccessNotification; }\r\n\tget canRead():\t\t\t\t\tboolean { return this._canRead; }\r\n\tget canCreate():\t\t\t\tboolean { return this._canCreate; }\r\n\tget canUpdate():\t\t\t\tboolean { return this._canUpdate; }\r\n\tget canDelete():\t\t\t\tboolean { return this._canDelete; }\r\n\tget userForChatInvite():\t\tany\t\t{ return this._userForChatInvite; }\r\n\tget rooms():\t\t\t\t\tany[]\t{ return this._rooms; }\r\n\tget users(): any[]\r\n\t{\r\n\t\tlet objUsers = [];\r\n\r\n\t\tfor (let key in this._users)\r\n\t\t{\r\n\t\t\tobjUsers.push(this._users[key]);\r\n\r\n\t\t}\r\n\t\treturn objUsers;\r\n\t}\r\n\tget userByRoomId():\t\t\t\tany[]\t{ return this._userByRoomId; }\r\n\tget messagesByRoomId():\t\t\tany[]\t{ return this._messagesByRoomId; }\r\n\tget connected():\t\t\t\tboolean { return this._connected; }\r\n\tget otpAuth():\t\t\t\t\tboolean { return this._otpAuth; }\r\n\tget methodAuth():\t\t\t\tany\t\t{ return this._methodAuth; }\r\n\tget mustReset():\t\t\t\tboolean\t{ return this._mustReset; }\r\n\tget mustValidateBrowser(): \tboolean\t{ return this._mustValidateBrowser; }\r\n\tget dialogRefModalConnection():\tany { return this._dialogRefModalConnection; }\r\n\r\n\r\n\tset id(id)\t\t\t\t\t\t\t\t\t\t\t{ this._id\t\t\t\t\t\t= id; }\r\n\tset fingerPrint(fingerPrint)\t\t\t\t\t\t{ this._fingerPrint\t\t\t\t= fingerPrint; }\r\n\tset dateCreation(dateCreation)\t\t\t\t\t\t{ this._dateCreation\t\t\t= dateCreation; }\r\n\tset isServer(isServer)\t\t\t\t\t\t\t\t{ this._isServer\t\t\t\t= isServer; }\r\n\tset mail(mail)\t\t\t\t\t\t\t\t\t\t{ this._mail\t\t\t\t\t= mail; }\r\n\tset username(username)\t\t\t\t\t\t\t\t{ this._username\t\t\t\t= username; }\r\n\tset accounts(accounts)\t\t\t\t\t\t\t\t{ this._accounts\t\t\t\t= accounts; }\r\n\tset account(account)\t\t\t\t\t\t\t\t{ this._account\t\t\t\t\t= account; }\r\n\tset isAccountSelected(isAccountSelected)\t\t\t{ this._isAccountSelected\t\t= isAccountSelected; }\r\n\tset right(right)\t\t\t\t\t\t\t\t\t{ this._right\t\t\t\t\t= right; }\r\n\tset role(role)\t\t\t\t\t\t\t\t\t\t{ this._role\t\t\t\t\t= role; }\r\n\tset firstName(firstName)\t\t\t\t\t\t\t{ this._firstName\t\t\t\t= firstName; }\r\n\tset color(color)\t\t\t\t\t\t\t\t\t{ this._color\t\t\t\t= color; }\r\n\tset firstLetterIcone(firstLetterIcone)\t\t\t\t{ this._firstLetterIcone\t\t\t\t= firstLetterIcone; }\r\n\tset lastName(lastName)\t\t\t\t\t\t\t\t{ this._lastName\t\t\t\t= lastName; }\r\n\tset deleted(deleted)\t\t\t\t\t\t\t\t{ this._deleted\t\t\t\t\t= deleted; }\r\n\tset status(status)\t\t\t\t\t\t\t\t\t{ this._status\t\t\t\t\t= status; }\r\n\tset idNewRoom(idNewRoom)\t\t\t\t\t\t\t{ this._idNewRoom\t\t\t\t= idNewRoom; }\r\n\tset canAccessChat(canAccessChat)\t\t\t\t\t{ this._canAccessChat\t\t\t= canAccessChat; }\r\n\tset canAccessForum(canAccessForum)\t\t\t\t\t{ this._canAccessForum\t\t\t= canAccessForum; }\r\n\tset canAccessNotification(canAccessNotification)\t{ this._canAccessNotification\t= canAccessNotification; }\r\n\tset canRead(canRead)\t\t\t\t\t\t\t\t{ this._canRead\t\t\t\t\t= canRead; }\r\n\tset canCreate(canCreate)\t\t\t\t\t\t\t{ this._canCreate\t\t\t\t= canCreate; }\r\n\tset canUpdate(canUpdate)\t\t\t\t\t\t\t{ this._canUpdate\t\t\t\t= canUpdate; }\r\n\tset canDelete(canDelete)\t\t\t\t\t\t\t{ this._canDelete\t\t\t\t= canDelete; }\r\n\tset userForChatInvite(userForChatInvite)\t\t\t{ this._userForChatInvite\t\t= userForChatInvite; }\r\n\tset rooms(rooms)\t\t\t\t\t\t\t\t\t{ this._rooms\t\t\t\t\t= rooms; }\r\n\tset users(users)\t\t\t\t\t\t\t\t\t{ this._users\t\t\t\t\t= users; }\r\n\tset userByRoomId(userByRoomId)\t\t\t\t\t\t{ this._userByRoomId\t\t\t= userByRoomId; }\r\n\tset messagesByRoomId(userByRoomId)\t\t\t\t\t{ this._messagesByRoomId\t\t= userByRoomId; }\r\n\tset connected(connected)\t\t\t\t\t\t\t{ this._connected\t\t\t\t= connected; }\r\n\tset otpAuth(otpAuth)\t\t\t\t\t\t\t\t{ this._otpAuth\t\t\t\t\t= otpAuth; }\r\n\tset methodAuth(methodAuth)\t\t\t\t\t\t\t{ this._methodAuth\t\t\t\t= methodAuth; }\r\n\tset mustReset(mustReset)\t\t\t\t\t\t\t{ this._mustReset\t\t\t\t= mustReset; }\r\n\tset mustValidateBrowser(mustValidateBrowser)\t\t{ this._mustValidateBrowser\t\t= mustValidateBrowser; }\r\n\tset dialogRefModalConnection(dialogRef)\t\t\t\t{ this._dialogRefModalConnection= dialogRef; }\r\n\r\n\t/**\r\n\t * Retourne true si l'user courant est un administrateur\r\n\t */\r\n\tpublic isAdmin()\r\n\t{\r\n\t\treturn this.status === UserData.STATUS_ADMIN;\r\n\t}\r\n\r\n\t/**\r\n\t * Retourne true si l'user courant est un responsable\r\n\t */\r\n\tpublic isResponsable()\r\n\t{\r\n\t\treturn this.status === UserData.STATUS_RESPONSABLE;\r\n\t}\r\n\r\n\t/**\r\n\t * Retourne true si l'user courant est un superviseur\r\n\t */\r\n\tpublic isSuperviseur()\r\n\t{\r\n\t\treturn this.status === UserData.STATUS_SUPERVISEUR;\r\n\t}\r\n\r\n\t/**\r\n\t * Retourne true si l'user courant est un simple utilisateur\r\n\t */\r\n\tpublic isSimpleUser()\r\n\t{\r\n\t\treturn this.status === UserData.STATUS_USER;\r\n\t}\r\n\r\n\tpublic parseBoolean(psString: any)\r\n\t{\r\n\t\tlet bReturn = null;\r\n\r\n\t\tif(psString === \"true\")\r\n\t\t{\r\n\t\t\tbReturn = true;\r\n\t\t}\r\n\t\telse if (psString === \"false\")\r\n\t\t{\r\n\t\t\tbReturn = false;\r\n\t\t}\r\n\r\n\t\treturn bReturn;\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Fonction qui permet de définir les droits globaux\r\n\t */\r\n\tpublic setCurrentUser(poUserData: any)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Récupération des infos de base\r\n\t\t// ---------------------------------------\r\n\t\tif (poUserData)\r\n\t\t{\r\n\t\t\tif (poUserData.infos)\r\n\t\t\t{\r\n\t\t\t\tthis.firstName\t= poUserData.infos.prenom;\r\n\t\t\t\tthis.lastName\t= poUserData.infos.nom;\r\n\t\t\t\tthis.mail\t\t= poUserData.infos.mail;\r\n\t\t\t}\r\n\r\n\t\t\tif (poUserData.privates)\r\n\t\t\t{\r\n\t\t\t\tthis.account\t= poUserData.privates.account;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tthis.mbIsPrinter = this.parseBoolean(poUserData.publics.bIsPrinter);\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// Gestion des droits sur le chat\r\n\t\t\t// ---------------------------------------\r\n\t\t\tif (poUserData.droitsLogiciel)\r\n\t\t\t{\r\n\t\t\t\tlet aRight = poUserData.droitsLogiciel.creation;\r\n\t\t\t\tif (aRight)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (aRight.indexOf('chat') !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.canAccessChat = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (aRight.indexOf('forum') !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.canAccessForum = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (aRight.indexOf('notification') !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.canAccessNotification = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t// Droits CRUD\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\tif (aRight.indexOf('create') !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.canCreate = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (aRight.indexOf('read') !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.canRead = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (aRight.indexOf('update') !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.canUpdate = true;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (aRight.indexOf('delete') !== -1)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.canDelete = true;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic hasFavorite(sessionName: any)\r\n\t{\r\n\t\tlet oReturn = this._favorites.indexOf(sessionName) > -1;\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic addFavorite(sessionName: any)\r\n\t{\r\n\t\tthis._favorites.push(sessionName);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic removeFavorite(sessionName: any)\r\n\t{\r\n\t\tlet index = this._favorites.indexOf(sessionName);\r\n\t\tif (index > -1)\r\n\t\t{\r\n\t\t\tthis._favorites.splice(index, 1);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic login(username: string, token: string, idUnique: string)\r\n\t{\r\n\t\tif (!username || !idUnique ||\r\n\t\t\tusername.length === 0 || idUnique.length === 0)\r\n\t\t{\r\n\t\t\treturn false;\r\n\t\t}\r\n\r\n\t\tthis.store(this.HAS_LOGGED_IN, 'true');\r\n\t\tthis.setUsername(username);\r\n\t\tthis.setUserId(idUnique);\r\n\t\tif (token)\r\n\t\t{\r\n\t\t\tthis.setTokenKey(token);\r\n\t\t}\r\n\r\n\t\t// this.events.publish('user:login');\r\n\t\t// TODO => voir si il à pas un status ne pas déranger en cours lors de la dernière connexion\r\n\t\tthis.states.application = 'online';\r\n\t\tthis.states.chat\t\t= 'online';\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic signup(username: any)\r\n\t{\r\n\t\t//\t\tthis.storage.set(this.HAS_LOGGED_IN, true);\r\n\t\tthis.setUsername(username);\r\n\t\t//\t\tthis.events.publish('user:signup');\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic logout()\r\n\t{\r\n\t\tthis.removeStorage(\"username\");\r\n\t\tthis.removeStorage(\"userid\");\r\n\t\tthis.removeStorage(\"calendarDatas\");\r\n\r\n\t\tthis.store(this.HAS_LOGGED_IN, 'false');\r\n\t\tthis.removeStorage(this.getUserId() + '::' + this.account + '::socketCluster.authToken');\r\n\t\tthis.states.application = 'offline';\r\n\r\n\t\tfor (let keyUser in this._users)\r\n\t\t{\r\n\t\t\tthis.removeStorage('usersDatas::' + this.account + '::' + keyUser);\r\n\t\t}\r\n\t\tthis._users = [];\r\n\t\tthis._otpAuth = false;\r\n\t\tthis.connected = false;\r\n\r\n\t\tthis.setTasksHomeForMe({});\r\n\t\tthis.setTasksHomeImAdmin({});\r\n\t\tthis.setCalendarDatas({});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic setUsername(username: any)\r\n\t{\r\n\t\tthis.store('username', username);\r\n\t\t// this.router.navigate(['/home']);\r\n\t\t// this.storage.set('username', username);\r\n\t}\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic setUserId(userid: any)\r\n\t{\r\n\t\t// this.router.navigate(['/home']);\r\n\t\t// this.storage.set('username', username);\r\n\t\tthis._userId = userid;\r\n\t}\r\n\r\n\r\n\tpublic setStateApplication(key: string, value: any)\r\n\t{\r\n\t\tthis.states[key] = value;\r\n\t\t// this.store(this.HAS_LOGGED_IN, 'true');\r\n\t}\r\n\r\n\tpublic setFingerPrint(value: any)\r\n\t{\r\n\t\tthis.store(this.getUserId() + '::' + this.account + '::fingerprint', value);\r\n\t}\r\n\r\n\r\n\tpublic setAccountInfo(value: any)\r\n\t{\r\n\t\tthis.store('accountInfo', value);\r\n\t}\r\n\r\n\r\n\t// ------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n\t//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tPartie Chat\r\n\t// ------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n\tpublic addUser(value: any, key: any)\r\n\t{\r\n\t\tthis._users[key] = value;\r\n\t\tthis.store('usersDatas::' + this.account + '::' + key, value);\r\n\t}\r\n\r\n\tpublic removeUser(key: any)\r\n\t{\r\n\t\tdelete this._users[key];\r\n\t\tthis.removeStorage('usersDatas::' + this.account + '::' + key);\r\n\t}\r\n\r\n\tpublic setUserState(value: any, key: any)\r\n\t{\r\n\t\tif(value === 'online')\r\n\t\t{\r\n\t\t\tthis._users[key].status = true;\r\n\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\r\n\t\t\tthis._users[key].status = false;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic getUser(key: any)\r\n\t{\r\n\t\tlet oReturn: any;\r\n\r\n\t\tif (!this._users[key])\r\n\t\t{\r\n\t\t\toReturn = this.getStorage('usersDatas::' + this.account + '::' + key);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\toReturn = this._users[key];\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\tpublic getUsers()\r\n\t{\r\n\t\treturn this._users;\r\n\t}\r\n\r\n\tpublic getUsers2()\r\n\t{\r\n\t\tlet test: any = this._users;\r\n\t\tlet returnArray = [];\r\n\r\n\t\tfor (let user in this._users)\r\n\t\t{\r\n\t\t\treturnArray.push(this.getUser(user));\r\n\t\t}\r\n\t\treturn returnArray;\r\n\t}\r\n\r\n\tpublic getUsersList()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage(this.account + '::usersList');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t// ------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n\t//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tPartie autre\r\n\t// ------------------------------------------------------------------------------------------------------------------------------------------------------------\r\n\r\n\tpublic setTasksHomeForMe(value: any)\r\n\t{\r\n\t\tthis.store(this.account + '::tasksHomeForMe', value);\r\n\t}\r\n\r\n\tpublic addTaskHomeForMe(value: any)\r\n\t{\r\n\t\tconst tasks: any = this.getStorage(this.account + '::tasksHomeForMe');\r\n\r\n\t\tconst index = _.findIndex(tasks, (val: any) => {\r\n\t\t\treturn val.uuid === value.uuid;\r\n\t\t});\r\n\r\n\t\tif (index !== -1)\r\n\t\t{\r\n\t\t\ttasks[index] = value;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ttasks.push(value);\r\n\t\t}\r\n\t\tthis.store(this.account + '::tasksHomeForMe', tasks);\r\n\t}\r\n\r\n\tpublic setUsersList(value: any)\r\n\t{\r\n\t\tthis.store(this.account + '::usersList', value);\r\n\t}\r\n\r\n\r\n\tpublic setTasksHomeImAdmin(value: any)\r\n\t{\r\n\t\tthis.store(this.account + '::tasksHomeImAdmin', value);\r\n\t}\r\n\r\n\tpublic addTasksHomeImAdmin(value: any)\r\n\t{\r\n\t\tconst tasks: any = this.getStorage(this.account + '::tasksHomeImAdmin');\r\n\r\n\t\tconst index = _.findIndex(tasks, (val: any) => {\r\n\t\t\treturn val.uuid === value.uuid;\r\n\t\t});\r\n\r\n\t\tif (index !== -1)\r\n\t\t{\r\n\t\t\ttasks[index] = value;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\ttasks.push(value);\r\n\t\t}\r\n\t\tthis.store(this.account + '::tasksHomeImAdmin', tasks);\r\n\r\n\t}\r\n\r\n\r\n\tpublic setUserDatas(datas: any)\r\n\t{\r\n\t\tthis.userDatas = datas;\r\n//\t\t('setCurrentUSer', datas);\r\n\r\n\t\t// parser des éléments pour les membres de classe\r\n\t\tthis.setCurrentUser(datas);\r\n\r\n\t\tthis.store('userDatas', datas);\r\n\t}\r\n\r\n\tpublic setRessources(datas: any)\r\n\t{\r\n\t\tthis.store('ressources', datas);\r\n\t}\r\n\r\n\tpublic setUsersDatas(datas: any, key: any)\r\n\t{\r\n\t\tthis.userDatas = datas;\r\n\t\t//\t\ts('setCurrentUSer', datas);\r\n\r\n\t\t// parser des éléments pour les membres de classe\r\n\r\n\t\tthis.store('usersDatas::' + this.account + '::' + key, datas);\r\n\t}\r\n\r\n\tpublic getUsersDatas(key: any)\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage('usersDatas::' + this.account + '::' + key);\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\r\n\r\n\t/**\r\n\t * Récupère un évènement en fonction de son identifiant dans le localstorage\r\n\t * @param idElement\r\n\t */\r\n\tpublic getCalendarElement(idElement: string)\r\n\t{\r\n\t\tlet result;\r\n\r\n\t\tif (!this._calendarDatas)\r\n\t\t{\r\n\t\t\tthis._calendarDatas = this.getStorage(this.getUserId() + '::' + this.account + '::calendarDatas');\r\n\t\t}\r\n\r\n\t\tresult = this._calendarDatas[idElement];\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Ajout d'un evènement dans le localstorage en fonction de son identifiant\r\n\t * @param idData\r\n\t * @param data\r\n\t */\r\n\tpublic addCalendarElement(idData: string, data: any)\r\n\t{\r\n\r\n\t\tif (!this._calendarDatas)\r\n\t\t{\r\n\t\t\tthis._calendarDatas = this.getStorage(this.getUserId() + '::' + this.account + '::calendarDatas');\r\n\t\t}\r\n\r\n\t\tlet type = data.type;\r\n\r\n\t\tif (!this._calendarDatas[idData])\r\n\t\t{\r\n\t\t\tthis._calendarDatas[idData] = {};\r\n\t\t}\r\n\t\tthis._calendarDatas[idData][type] = data;\r\n\r\n\t\tthis.store(this.getUserId() + '::' + this.account + '::calendarDatas', this._calendarDatas);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t * @param dateId \r\n\t */\r\n\tpublic removeCalendarElement(dateId: any)\r\n\t{\r\n\t\tif (!this._calendarDatas)\r\n\t\t{\r\n\t\t\tthis._calendarDatas = this.getStorage(this.getUserId() + '::' + this.account + '::calendarDatas');\r\n\t\t}\r\n\r\n\t\tif (this._calendarDatas[dateId])\r\n\t\t{\r\n\t\t\tdelete this._calendarDatas[dateId];\r\n\t\t\tthis.store(this.getUserId() + '::' + this.account + '::calendarDatas', this._calendarDatas);\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Affectation d'un ensemble de dates dans le localstorage\r\n\t * @param datas\r\n\t */\r\n\tpublic setCalendarDatas(datas: any)\r\n\t{\r\n\t\tthis._calendarDatas = datas;\r\n\t\tthis.store(this.getUserId() + '::' + this.account + '::calendarDatas', datas);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Récupération des évènements dans le localstorage\r\n\t */\r\n\tpublic getCalendarDatas()\r\n\t{\r\n\t\tlet oReturn: any = {};\r\n\r\n\t\tif (this._calendarDatas)\r\n\t\t{\r\n\t\t\toReturn = this._calendarDatas;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis._calendarDatas = this.getStorage(this.getUserId() + '::' + this.account + '::calendarDatas');\r\n\t\t\toReturn \t\t\t= this._calendarDatas;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Récupération d'une tache dans le localstorage en fonction de son identifiant\r\n\t * @param idData\r\n\t * @param data\r\n\t */\r\n\tpublic addTaskData(idData: string, data: any)\r\n\t{\r\n\t\tif (!this._taskDatas)\r\n\t\t{\r\n\t\t\tthis._taskDatas = this.getStorage('taskDatas');\r\n\t\t}\r\n\r\n\t\tif (!this._taskDatas)\r\n\t\t{\r\n\t\t\tthis._taskDatas = {};\r\n\t\t}\r\n\r\n\t\tthis._taskDatas[idData] = data;\r\n\t\tthis.store('taskDatas', this._taskDatas);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Ajout de la structure de nodes dans le locastorage\r\n\t * @param datas\r\n\t */\r\n\tpublic setTaskDatas(datas: any)\r\n\t{\r\n\t\tthis._taskDatas = datas;\r\n\t\tthis.store('taskDatas', datas);\r\n\t}\r\n\r\n\tpublic getAccountInfo()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage('accountInfo');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic getUsername()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage('username');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tpublic getUserId()\r\n\t{\r\n\t\treturn this._userId;\r\n\t}\r\n\r\n\r\n\tpublic getUserObject()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage('userid');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tpublic getFingerPrint()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage(this.getUserId() + '::' + this.account + '::fingerprint');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\r\n\tpublic getTasksHomeForMe()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage(this.account + '::tasksHomeForMe');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\tpublic getTasksHomeForMeById(idTask: string)\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\tconst tasks = this.getStorage(this.account + '::tasksHomeForMe');\r\n\r\n\t\tconst index = _.findIndex(tasks, (val: any) => \r\n\t\t{\r\n\t\t\treturn val.uuid === idTask;\r\n\t\t});\r\n\r\n\t\tif (index !== -1)\r\n\t\t{\r\n\t\t\toReturn = tasks[index];\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tpublic getTasksHomeImAdmin()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage(this.account + '::tasksHomeImAdmin');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tpublic isUserAdmin(userId: any)\r\n\t{\r\n\t\tconst user \t= this.getUser(userId);\r\n\t\tlet isAdmin = false;\r\n\r\n\t\tif (user.publics && (user.publics.isAdmin === true || user.publics.isAdmin === 'true'))\r\n\t\t{\r\n\t\t\tisAdmin = true;\r\n\t\t}\r\n\r\n\t\treturn isAdmin;\r\n\t}\r\n\r\n\r\n\tpublic isUserSuperviseur(userId: any)\r\n\t{\r\n\t\tconst user \t\t= this.getUser(userId);\r\n\t\tlet isSuperUser = false;\r\n\r\n\t\tif (user.publics && (user.publics.isSuperUser === true || user.publics.isSuperUser === 'true'))\r\n\t\t{\r\n\t\t\tisSuperUser = true;\r\n\t\t}\r\n\r\n\t\treturn isSuperUser;\r\n\t}\r\n\r\n\r\n\tpublic getReadedMessages()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage('readedMessages');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tpublic getRessources()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage('ressources');\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Récupération de l'ensemble des tâches disponibles dans le localstorage\r\n\t */\r\n\tpublic getTaskDatas()\r\n\t{\r\n\t\tlet oReturn: any = {};\r\n\r\n\t\tif (this._taskDatas)\r\n\t\t{\r\n\t\t\toReturn = this._taskDatas;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis._taskDatas = this.getStorage('taskDatas');\r\n\t\t\toReturn \t\t= this._taskDatas;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tpublic getUserDatas()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\tif (this.userDatas !== null)\r\n\t\t{\r\n\t\t\toReturn = this.userDatas;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\toReturn = this.getStorage('userDatas');\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tpublic getStateApplication()\r\n\t{\r\n\t\treturn this.states;\r\n\t}\r\n\r\n\t/**\r\n\t * return a promise\r\n\t */\r\n\tpublic hasLoggedIn()\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\toReturn = this.getStorage(this.HAS_LOGGED_IN) === 'true';\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic setTokenKey(token: string)\r\n\t{\r\n\t\tthis.store(this.getUserId() + '::' + this.account + '::socketCluster.authToken', token);\r\n\t}\r\n\r\n\tpublic setRSAPrivate(rsaKey: any)\r\n\t{\r\n\t\tthis.store(this.getUserId() + '::' + this.account + '::rsa-private', rsaKey);\r\n\t}\r\n\r\n\r\n\tpublic getRSAPrivate()\r\n\t{\r\n\t\tlet rsa = this.getStorage(this.getUserId() + '::' + this.account + '::rsa-private');\r\n\r\n\t\treturn rsa;\r\n\t}\r\n\r\n\tpublic hasRSAprivate()\r\n\t{\r\n\t\tlet result = false;\r\n\r\n\t\tif (this.getStorage(this.getUserId() + '::' + this.account + '::rsa-private') !== undefined)\r\n\t\t{\r\n\t\t\tresult = true;\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\tpublic deleteRSAPrivate()\r\n\t{\r\n\t\tthis.removeStorage(this.getUserId() + '::' + this.account + '::rsa-private');\r\n\t}\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic delTokenKey()\r\n\t{\r\n\t\tthis.removeStorage(this.getUserId() + '::' + this.account + '::socketCluster.authToken');\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic getTokenKey()\r\n\t{\r\n\t\tlet token = this.getStorage(this.getUserId() + '::' + this.account + '::socketCluster.authToken');\r\n\r\n\t\tif (token)\r\n\t\t{\r\n\t\t\ttoken = token.replace(/\"/g, '');\r\n\t\t}\r\n\t\treturn token;\r\n\t}\r\n\r\n\r\n\tpublic storeRooms(paRooms: any)\r\n\t{\r\n\t\tthis.store('avaibleRooms', paRooms);\r\n\t}\r\n\r\n\r\n\tgetTextColor(color: any)\r\n\t{\r\n\t\tif (color === '#fff')\r\n\t\t{\r\n\t\t\tcolor = \"#ffffff\";\r\n\t\t}\r\n\t\tlet value;\r\n\r\n\t\tlet colorReturn = \"#000000\";\r\n\r\n\t\tif (color)\r\n\t\t{\r\n\t\t\tcolor = color.replace('#', '');\r\n\r\n\t\t\tvar arrBuff = new ArrayBuffer(4);\r\n\t\t\tvar vw\t\t= new DataView(arrBuff);\r\n\t\t\tvw.setUint32(0, parseInt(color, 16), false);\r\n\t\t\tvar arrByte = new Uint8Array(arrBuff);\r\n\r\n\t\t\t//\t\treturn arrByte[1] + \",\" + arrByte[2] + \",\" + arrByte[3];\r\n\r\n\t\t\tvalue = (arrByte[1] * 299 + arrByte[2] * 587 + arrByte[3] * 114) / 1000;\r\n\r\n\t\t\tif (value < 128)\r\n\t\t\t{\r\n\t\t\t\tcolorReturn = \"#ffffff\";\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn colorReturn;\r\n\t}\r\n}\r\n\r\n","import { Injectable, EventEmitter, OnDestroy } from '@angular/core';\r\n\r\nimport { WorkspaceData } from './workspace-data';\r\nimport { CandidatService }\t\tfrom '../services/candidat.service';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n\r\n\r\n@Injectable()\r\nexport class VaultData implements OnDestroy\r\n{\r\n\r\n public vaultEmitter: EventEmitter = new EventEmitter();\r\n\r\n public static rootParentId = 'b1bcd800-1dc9-11b2-8080-808080808080';\r\n\r\n private _concours:\t\t\t\tany[]\t= [];\r\n private _nodesById:\t\t\t\tany\t\t= {};\r\n private _candidatsByElement:\tany\t\t= {};\r\n private _candidats:\t\t\t\tany\t\t= {\r\n all: [],\r\n groups: null\r\n\t}\r\n\r\n\tconstructor(public workspaceDate: WorkspaceData, public candidatService: CandidatService)\r\n\t{\r\n\r\n\t}\r\n\r\n\tngOnDestroy()\r\n\t{\r\n\t\tthis.vaultEmitter.unsubscribe();\r\n }\r\n\r\n\tget concours(): any[]\r\n\t{\r\n\t\treturn this._concours;\r\n\t}\r\n\r\n\r\n\tgetConcourByid(psId: string): any[]\r\n\t{\r\n\r\n\t\tlet aReturn;\r\n\t\tfor (const concour of this._concours)\r\n\t\t{\r\n\t\t\tif (concour.id === psId)\r\n\t\t\t{\r\n\t\t\t\taReturn = concour;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn aReturn;\r\n\t}\r\n\r\n\r\n get candidats():\t\t\tany[] { return this._candidats; }\r\n get candidatsByElement():\tany[] { return this._candidatsByElement; }\r\n\r\n\r\n\r\n\tpublic addConcours(concours: any)\r\n\t{\r\n\t\tif (concours && concours.id && this._nodesById[concours.id] === undefined)\r\n\t\t{\r\n\t\t\tconcours.epreuve\t\t= undefined;\r\n\t\t\tconst epreuveAffected\t= this.workspaceDate.getEpreuve(concours.idEpreuve);\r\n\r\n\t\t\tif (epreuveAffected)\r\n\t\t\t{\r\n\t\t\t\tconcours.epreuve = epreuveAffected;\r\n\t\t\t}\r\n\t\t\tif (!concours.datas)\r\n\t\t\t{\r\n\t\t\t\tconcours.datas = {};\r\n\t\t\t}\r\n\t\t\tif (concours.datas.candidats)\r\n\t\t\t{\r\n\t\t\t\ttry{\r\n\t\t\t\t\tconcours.datas.candidats = JSON.parse(concours.datas.candidats);\r\n\t\t\t\t}\r\n\t\t\t\tcatch(e)\r\n\t\t\t\t{}\r\n\t\t\t}\r\n\t\t\tif (concours.datas.specialTime)\r\n\t\t\t{\r\n\t\t\t\ttry{\r\n\t\t\t\t\tconcours.datas.specialTime = JSON.parse(concours.datas.specialTime);\r\n\t\t\t\t}\r\n\t\t\t\tcatch(e)\r\n\t\t\t\t{}\r\n\t\t\t}\r\n\t\t\telse if (!concours.datas || !concours.datas.candidats)\r\n\t\t\t{\r\n\t\t\t\tconcours.datas.candidats = [];\r\n\t\t\t}\r\n\r\n\t\t\tthis._nodesById[concours.id] = concours;\r\n\r\n\t\t\tif (concours.datas && concours.datas.datePassationSend)\r\n\t\t\t{\r\n\t\t\t\tconcours.passationSend = true;\r\n\r\n\t\t\t\tif (concours.datas.mustUpdate && (concours.datas.mustUpdate === true || concours.datas.mustUpdate === 'true'))\r\n\t\t\t\t{\r\n\t\t\t\t\tconcours.mustUpdate = true;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tconcours.mustUpdate = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tthis._concours.push(concours);\r\n\t\t\tthis._concours = _.sortBy(this._concours, 'creationDate');\r\n\t\t\tthis._concours = this.concours.reverse();\r\n\t\t}\r\n\r\n\t}\r\n\r\n\r\n\tpublic getNodeById(id: string)\r\n\t{\r\n\t\tlet result = [];\r\n\r\n\t\tif (this._nodesById[id])\r\n\t\t{\r\n\t\t\tresult = this._nodesById[id];\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\t\r\n\tpublic updateNode(nodeId: string, datasUpdated: any)\r\n\t{\r\n\t\tif (this._nodesById && this._nodesById[nodeId])\r\n\t\t{\r\n\r\n\t\t\tfor (const key in datasUpdated)\r\n\t\t\t{\r\n\t\t\t\tswitch (key)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase 'libelle':\r\n\t\t\t\t\t\tthis._nodesById[nodeId].libelle = datasUpdated[key];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'passationSend':\r\n\t\t\t\t\t\tthis._nodesById[nodeId].passationSend = datasUpdated[key];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'mustUpdate':\r\n\t\t\t\t\t\tthis._nodesById[nodeId].mustUpdate = datasUpdated[key];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'passwordSubjects':\r\n\t\t\t\t\t\tthis._nodesById[nodeId].passwordSubjects = datasUpdated[key];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'datePassationSend':\r\n\t\t\t\t\t\tthis._nodesById[nodeId].datas.datePassationSend = datasUpdated[key];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'update_date':\r\n\t\t\t\t\t\tthis._nodesById[nodeId].updateDate = datasUpdated[key];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'idEpreuve':\r\n\t\t\t\t\t\tthis._nodesById[nodeId].idEpreuve = datasUpdated[key];\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'datas':\r\n\t\t\t\t\t\tthis._nodesById[nodeId].datas = datasUpdated[key];\r\n\t\t\t\t\tcase '+datas':\r\n\t\t\t\t\t\tfor (let keyData in datasUpdated[key])\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (datasUpdated[key][keyData])\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (keyData === 'baremesMain' || keyData === 'baremesSec')\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (typeof datasUpdated[key][keyData] === 'string')\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tthis._nodesById[nodeId].datas[keyData] = datasUpdated[key][keyData];\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tthis._nodesById[nodeId].datas[keyData] = JSON.stringify(datasUpdated[key][keyData]);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (keyData === 'mustUpdate')\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tthis._nodesById[nodeId].mustUpdate = datasUpdated[key][keyData];\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tthis._nodesById[nodeId].datas[keyData] = datasUpdated[key][keyData];\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic logout()\r\n\t{\r\n\t\tthis._concours \t\t\t\t= [];\r\n\t\tthis._nodesById \t\t\t= {};\r\n\t\tthis._candidatsByElement \t= {};\r\n\t\tthis._candidats \t\t\t=\r\n\t\t{\r\n\t\t\tall: \t[],\r\n\t\t\tgroups: null\r\n\t\t};\r\n\t}\r\n}\r\n","import { Injectable, EventEmitter } from '@angular/core';\r\nimport { GenericData }\t\tfrom './generic-data';\r\n\r\nimport { ChatData }\tfrom './chat-data';\r\nimport { UserData }\tfrom './user-data';\r\n\r\nimport { Router }\tfrom '@angular/router';\r\n\r\nimport { Etablissement }\tfrom '../classes/etablissement.class';\r\nimport { Session }\t\t\tfrom '../classes/session.class';\r\nimport { Examen }\t\t\tfrom '../classes/examen.class';\r\nimport { Matiere }\t\t\tfrom '../classes/matiere.class';\r\nimport { Sujet }\t\t\tfrom '../classes/sujet.class';\r\nimport { Task }\t\t\t\tfrom '../classes/task.class';\r\nimport { File as EFile }\tfrom '../classes/file.class';\r\nimport * as _\t\t\t\tfrom 'underscore';\r\n\r\n// import { Storage } from '@ionic/storage';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * Class UserData\r\n */\r\nexport class WorkspaceData extends GenericData\r\n{\r\n\r\n\t// Selection user\r\n\tprivate _selectedEtablissement:\tEtablissement\t= null;\r\n\tprivate _selectedSession:\t\tSession\t\t\t= null;\r\n\tprivate _selectedExamen:\t\tExamen\t\t\t= null;\r\n\tprivate _selectedMatiere:\t\tMatiere\t\t\t= null;\r\n\tprivate _selectedSujet:\t\t\tSujet\t\t\t= null;\r\n\r\n\r\n\tprivate _selectedHomeEtablissement:\tEtablissement\t= null;\r\n\tprivate _selectedHomeSession:\t\tSession\t\t\t= null;\r\n\tprivate _selectedHomeExamen:\t\tExamen\t\t\t= null;\r\n\tprivate _selectedHomeMatiere:\t\tMatiere\t\t\t= null;\r\n\tprivate _selectedHomeSujet:\t\t\tSujet\t\t\t= null;\r\n\r\n\r\n\tprivate _selectedTask:\t\t\tTask\t\t\t= null;\r\n\tprivate _selectedElement:\t\tany\t\t\t\t= null;\r\n\r\n\t// Les datas\r\n\tprivate _etablissements:\t\t\tEtablissement[] = [];\r\n\tprivate _selectedSegment:\t\t\tstring\t\t\t= null;\r\n\tprivate _epreuveByWorkflowSelected:\tany[]\t\t\t= [];\r\n\r\n\r\n\t/**\r\n\t * Stockage des taches récupérées dans l'appli\r\n\t */\r\n\tprivate _taskDatas:\t\t\t\t\tany\t\t= {};\r\n\tprivate _taskHomeAdmin:\t\t\t\tTask[]\t= [];\r\n\tprivate _taskHomeAdminSave:\t\t\tTask[]\t= [];\r\n\tprivate _taskHomeAdminToValid:\t\tTask[]\t= [];\r\n\tprivate _taskHomeAdminToValidSave:\tTask[]\t= [];\r\n\tprivate _taskHomeAdminExpired:\t\tTask[]\t= [];\r\n\tprivate _taskHomeAdminExpiredSave:\tTask[]\t= [];\r\n\tprivate _epreuveHomeAdmin:\t\t\tany[]\t= [];\r\n\tprivate _epreuveHomeAdminSave:\t\tany[]\t= [];\r\n\tprivate _taskHomeMine:\t\t\t\tTask[]\t= [];\r\n\tprivate _taskHomeMineSave:\t\t\tTask[]\t= [];\r\n\tprivate _globalTask:\t\t\t\tTask[]\t= [];\r\n\r\n\tprivate _historicFromElement: any = {};\r\n\r\n\tprivate _isInfoTaskMineOk:\tboolean\t= false;\r\n\tprivate _isInfoTaskAdminOk:\tboolean\t= false;\r\n\tprivate _isInfoNodeOk:\t\tboolean\t= false;\r\n\tprivate _isInfoSubjectOk:\tboolean\t= false;\r\n\tprivate _isHomeEpreuveOk:\tboolean\t= false;\r\n\tpublic selectedItems:\t\tany[]\t= [];\r\n\r\n\tpublic goToSubject:\t\t\tboolean\t= false;\r\n\r\n\tprivate _statsNode:\t\tany;\r\n\tprivate _statsNode2:\tany;\r\n\tprivate _statsNodeEpr:\tany;\r\n\r\n\tprivate _openedItemsBySearch: any[] = [];\r\n\r\n\tprivate _sujetKey:\tany;\r\n\r\n\tpublic workspaceEmitter: EventEmitter = new EventEmitter();\r\n\r\n\tprivate _fileForEdit: any;\r\n\r\n\tpublic urlCreator = window.URL;\r\n\tpublic taskData: any;\r\n\r\n\tpublic mbisWorkspaceLoading: boolean = false;\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(\r\n\t\t\t\tpublic chatData:\tChatData,\r\n\t\t\t\tpublic router:\t\tRouter,\r\n\t\t\t\tpublic userData:\tUserData\r\n\t\t\t\t)\r\n\t{\r\n\t\tsuper();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param taskData\r\n\t */\r\n\tsetTaskData(taskData: any)\r\n\t{\r\n\t\tthis.taskData = taskData;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget fileForEdit() { return this._fileForEdit; }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedEtablissement(): Etablissement\r\n\t{\r\n\t\tlet oReturn = this._selectedEtablissement;\r\n\t\tif (this._selectedEtablissement === null)\r\n\t\t{\r\n\t\t\tlet etablissementId\t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedEtablissementId');\r\n\t\t\toReturn\t\t\t\t\t\t= this.getEtablissement(etablissementId);\r\n\t\t\tthis._selectedEtablissement = oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedSession():\t\t\tSession\r\n\t{\r\n\t\tlet oReturn = this._selectedSession;\r\n\t\tif (this._selectedSession === null)\r\n\t\t{\r\n\t\t\tlet sessionId \t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedSessionId');\r\n\t\t\toReturn \t\t\t\t= this.getSession(sessionId);\r\n\t\t\tthis._selectedSession \t= oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedExamen():\t\t\tExamen\r\n\t{\r\n\t\tlet oReturn = this._selectedExamen;\r\n\t\tif (this._selectedExamen === null)\r\n\t\t{\r\n\t\t\tlet examenId \t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedExamenId');\r\n\t\t\toReturn \t\t\t\t= this.getExamen(examenId);\r\n\t\t\tthis._selectedExamen \t= oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedMatiere():\t\t\tMatiere\r\n\t{\r\n\t\tlet oReturn = this._selectedMatiere;\r\n\t\tif (this._selectedMatiere === null)\r\n\t\t{\r\n\t\t\tlet matiereId \t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedMatiereId');\r\n\t\t\toReturn \t\t\t\t= this.getEpreuve(matiereId);\r\n\t\t\tthis._selectedMatiere \t= oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedSujet():\t\t\tSujet\r\n\t{\r\n\t\tlet oReturn = this._selectedSujet;\r\n\t\tif (this._selectedSujet === null)\r\n\t\t{\r\n\t\t\tlet subjectId \t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedSubjectId');\r\n\t\t\toReturn \t\t\t= this.getSujet(subjectId);\r\n\t\t\tthis._selectedSujet = oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedTask():\t\t\t Task\r\n\t{\r\n\t\tlet oReturn = this._selectedTask;\r\n\t\tif (this._selectedTask === null)\r\n\t\t{\r\n\t\t\tlet taskId \t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedTaskId');\r\n\t\t\toReturn \t\t\t= this.taskData.getTaskById(taskId);\r\n\t\t\tthis._selectedTask \t= oReturn;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedElement():\t\t\tany\r\n\t{\r\n\t\tlet oReturn = this._selectedElement;\r\n\t\tif (this._selectedElement === null)\r\n\t\t{\r\n\t\t\tlet elementId \t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedElementId');\r\n\t\t\toReturn \t\t\t\t= this.getTreeElement(elementId);\r\n\t\t\tthis._selectedElement \t= oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedSegment():\t\t\tstring\t\t\t{ return this._selectedSegment; }\r\n\tget taskDatas()\t\t\t\t\t\t\t\t\t{ return this._taskDatas; }\r\n\r\n\tget sujetKey()\r\n\t{\r\n\t\tlet oReturn = this._sujetKey;\r\n\t\tif (this._sujetKey === null)\r\n\t\t{\r\n\t\t\toReturn = this.getStorage(this.userData.mail + '::' + this.userData.account + '::sujetKey');\r\n\t\t\tthis._sujetKey = oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tget epreuveByWorkflowSelected()\t\t\t{ return this._epreuveByWorkflowSelected; }\r\n\tget isHomeEpreuveOk()\t\t\t\t\t{ return this._isHomeEpreuveOk; }\r\n\tset isHomeEpreuveOk(isHomeEpreuveOk)\t{ this._isHomeEpreuveOk = isHomeEpreuveOk; }\r\n\r\n\r\n\tget statsNode()\r\n\t{\r\n\t\treturn this._statsNode;\r\n\t}\r\n\r\n\tget statsNodeEpr()\r\n\t{\r\n\t\treturn this._statsNodeEpr;\r\n\t}\r\n\r\n\tget statsNode2()\r\n\t{\r\n\t\treturn this._statsNode2;\r\n\t}\r\n\r\n\tsetEpr(statsNode: any)\r\n\t{\r\n\t\tthis._statsNode = [];\r\n\t\tfor (let key in statsNode)\r\n\t\t{\r\n\t\t\tthis._statsNode.push(statsNode[key]);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tset statsNodeEpr(statsNode)\r\n\t{\r\n\t\tthis._statsNodeEpr = [];\r\n\r\n\t\tfor (let key in statsNode)\r\n\t\t{\r\n\t\t\tlet formatedStatNode: any = {};\r\n\r\n\t\t\t//On récupère les propriétés existantes\r\n\t\t\tfor (let keyStat in statsNode[key])\r\n\t\t\t{\r\n\t\t\t\tformatedStatNode[keyStat] = statsNode[key][keyStat];\r\n\t\t\t}\r\n\r\n\t\t\tformatedStatNode.nomeEpreuve\t= '';\r\n\t\t\tformatedStatNode.nomExamen\t\t= '';\r\n\t\t\tformatedStatNode.nomUser\t\t= '';\r\n\t\t\tformatedStatNode.sCount\t\t\t= '';\r\n\t\t\tformatedStatNode.echeanceLib\t= '';\r\n\t\t\tformatedStatNode.isPrincipal\t= false;\r\n\t\t\tformatedStatNode.isSecondary\t= false;\r\n\t\t\tformatedStatNode.isAccepted\t\t= false;\r\n\r\n\r\n\t\t\tformatedStatNode.sujetLib\t= '';\r\n\r\n\t\t\tlet oEpreuve;\r\n\t\t\t// Récupération du nom de l'épreuve\r\n\t\t\tif (statsNode[key].idEpreuve !== '')\r\n\t\t\t{\r\n\t\t\t\toEpreuve = this.getEpreuve(statsNode[key].idEpreuve);\r\n\r\n\t\t\t\tif (oEpreuve)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomEpreuve = oEpreuve.name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(statsNode[key].status)\r\n\t\t\t{\r\n\t\t\t\tswitch (statsNode[key].status)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase 'new':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Non assigné';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'todo':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Assigné';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'inprogress':\r\n\t\t\t\t\t\tformatedStatNode.status = 'En cours';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'review':\r\n\t\t\t\t\t\tformatedStatNode.status = 'A valider';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'done':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Terminé';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t\tif (statsNode[key].nomUser === \"undefined\")\r\n\t\t\t{\r\n\t\t\t\tformatedStatNode.nomUser = ' - ';\r\n\t\t\t}\r\n\r\n\t\t\t// Nom de l'examen\r\n\t\t\tif (statsNode[key].idExamen !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oExamen = this.getExamen(statsNode[key].idExamen);\r\n\t\t\t\tif (oExamen !== null)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomExamen = oExamen.name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Nom de l'examen\r\n\t\t\tif (statsNode[key].echeance !== '')\r\n\t\t\t{\r\n\t\t\t\tlet date = new Date(statsNode[key].echeance);\r\n\t\t\t\tformatedStatNode.echeanceLib = date.toLocaleDateString();\r\n\t\t\t}\r\n\r\n\t\t\t// Mise en forme des infos utilisateur\r\n\t\t\tif (statsNode[key].assigned_to !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oUser = this.chatData.getUser(statsNode[key].assigned_to);\r\n\t\t\t\tif (oUser)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (oUser.nom !== '' && oUser.nom !== undefined)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.nom + ' ';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (oUser.prenom !== '' && oUser.prenom !== undefined)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.prenom + ' ';\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// Si on a rien on met le mail\r\n\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomUser = 'utilisateur inconnu';\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (oUser)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (statsNode[key].nomUser === '')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.id;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomUser = 'utilisateur inconnu';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlet oTask;\r\n\t\t\t// Mise en forme info des taches\r\n\r\n\r\n\t\t\tif (statsNode[key].idTask !== '')\r\n\t\t\t{\r\n\t\t\t\toTask = this._globalTask[statsNode[key].idTask];\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif (statsNode[key].count !== '')\r\n\t\t\t{\r\n\t\t\t\tlet sCount = [];\r\n\t\t\t\tlet isFind = false;\r\n\r\n\t\t\t\tfor (let key2 in statsNode[key].count)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (key2 === statsNode[key].typeT)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tisFind \t\t\t= true;\r\n\t\t\t\t\t\tlet txtEtape \t= key2;\r\n\r\n\t\t\t\t\t\tif (oEpreuve && oEpreuve.scenario && oEpreuve.scenario.steps)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet step = _.find(oEpreuve.scenario.steps, (step: any) => { return step.id.toString() === key2; });\r\n\r\n\t\t\t\t\t\t\tif (step)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\ttxtEtape = step.name;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (Number(statsNode[key].count[key2]) < 2)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsCount.push(txtEtape);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsCount.push( txtEtape + '(' + statsNode[key].count[key2] + ')');\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif(!isFind)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet txtEtape \t= 'Création terminée';\r\n\t\t\t\t\tsCount \t\t\t= [];\r\n\r\n\t\t\t\t\tsCount.push(txtEtape);\r\n\t\t\t\t}\r\n\t\t\t\tformatedStatNode.sCount = sCount;\r\n\t\t\t}\r\n\r\n\t\t\tif(statsNode[key].idSujet !== '')\r\n\t\t\t{\r\n\r\n\t\t\t\tlet oSujet = this.getSujet(statsNode[key].idSujet);\r\n\t\t\t\tif (oSujet)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.sujetLib = oSujet.name;\r\n\t\t\t\t\tif (oSujet.datas && oSujet.datas.etat && !formatedStatNode.ps)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.ps = oSujet.datas.etat;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tthis._statsNodeEpr.push(formatedStatNode);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\r\n\r\n\t/**\r\n\t * LEs node sauf epreuve\r\n\t */\r\n\tset statsNode(statsNode)\r\n\t{\r\n\t\tthis._statsNode = [];\r\n\t\tfor (let key in statsNode)\r\n\t\t{\r\n\t\t\tlet formatedStatNode: any = {};\r\n\r\n\t\t\t//On récupère les propriétés existantes\r\n\t\t\tfor (let keyStat in statsNode[key])\r\n\t\t\t{\r\n\t\t\t\tformatedStatNode[keyStat] = statsNode[key][keyStat];\r\n\t\t\t}\r\n\r\n\t\t\tformatedStatNode.nomeEpreuve\t= '';\r\n\t\t\tformatedStatNode.nomExamen\t\t= '';\r\n\t\t\tformatedStatNode.nomEtab\t\t= '';\r\n\t\t\tformatedStatNode.nomSession\t\t= '';\r\n\t\t\tformatedStatNode.nomUser\t\t= '';\r\n\t\t\tformatedStatNode.sCount\t\t\t= '';\r\n\t\t\tformatedStatNode.echeanceLib\t= '';\r\n\t\t\tformatedStatNode.isPrincipal\t= false;\r\n\t\t\tformatedStatNode.isSecondary\t= false;\r\n\t\t\tformatedStatNode.isAccepted\t\t= false;\r\n\t\t\tformatedStatNode.sujetLib\t\t= '';\r\n\r\n\t\t\tlet oEpreuve: Matiere;\r\n\r\n\t\t\t// Mise en forme du status\r\n\t\t\tif(statsNode[key].status)\r\n\t\t\t{\r\n\t\t\t\tswitch (statsNode[key].status)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase 'new':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Non assigné';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'todo':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Assigné';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'inprogress':\r\n\t\t\t\t\t\tformatedStatNode.status = 'En cours';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'review':\r\n\t\t\t\t\t\tformatedStatNode.status = 'A valider';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase 'done':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Terminé';\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// nom de l'user\r\n\t\t\tif (statsNode[key].nomUser === \"undefined\")\r\n\t\t\t{\r\n\t\t\t\tformatedStatNode.nomUser = ' - ';\r\n\t\t\t}\r\n\r\n\t\t\tlet oEpr = this.getEpreuve(key);\r\n\t\t\tif (oEpr)\r\n\t\t\t{\r\n\t\t\t\tformatedStatNode.nomEpreuve = oEpr.name;\r\n\t\t\t}\r\n\r\n\t\t\tfor (let key2 of statsNode[key].parents)\r\n\t\t\t{\r\n\t\t\t\tlet keyArray = key2.split('::');\r\n\r\n\t\t\t\tswitch (keyArray[0])\r\n\t\t\t\t{\r\n\t\t\t\t\tcase '*etab':\r\n\t\t\t\t\t\tlet oEtab = this.getEtablissement(keyArray[1]);\r\n\t\t\t\t\t\tif (oEtab)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tformatedStatNode.nomEtab = oEtab.name;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase '*exam':\r\n\t\t\t\t\t\tlet oExam = this.getExamen(keyArray[1]);\r\n\t\t\t\t\t\tif (oExam)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tformatedStatNode.nomExamen = oExam.name;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase '*epr':\r\n\t\t\t\t\t\tlet oEpr = this.getEpreuve(key);\r\n\t\t\t\t\t\tif (oEpr)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tformatedStatNode.nomEpreuve = oEpr.name;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase '*sess':\r\n\t\t\t\t\t\tlet oSess = this.getSession(keyArray[1]);\r\n\t\t\t\t\t\tif (oSess)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tformatedStatNode.nomSession = oSess.name;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tdefault:\r\n\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Mise en forme des infos utilisateur\r\n\t\t\tif (statsNode[key].assigned_to !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oUser = this.chatData.getUser(statsNode[key].assigned_to);\r\n\t\t\t\tif (oUser)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (oUser.nom !== '' && oUser.nom !== undefined)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.nom + ' ';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (oUser.prenom !== '' && oUser.prenom !== undefined)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.prenom + ' ';\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// Si on a rien on met le mail\r\n\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomUser = 'utilisateur inconnu';\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (oUser)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tif (statsNode[key].nomUser === '')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.id;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomUser = 'utilisateur inconnu';\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\r\n\t\t\tlet oTask;\r\n\t\t\t// Mise en forme info des taches\r\n\t\t\tif (statsNode[key].idTask !== '')\r\n\t\t\t{\r\n\t\t\t\toTask = this._globalTask[statsNode[key].idTask];\r\n\t\t\t}\r\n\r\n\t\t\tif (statsNode[key].count !== '')\r\n\t\t\t{\r\n\t\t\t\tlet sCount = [];\r\n\t\t\t\tfor (let key2 in statsNode[key].count)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (key2 === statsNode[key].typeT)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet txtEtape = key2;\r\n\r\n\t\t\t\t\t\tif (oEpreuve && oEpreuve.scenario && oEpreuve.scenario.steps)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet step = _.find(oEpreuve.scenario.steps, (step: any) => { return step.id.toString() === key2; });\r\n\r\n\t\t\t\t\t\t\tif (step)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\ttxtEtape = step.name;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif (Number(statsNode[key].count[key2]) < 2)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsCount.push(txtEtape);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsCount.push( txtEtape + '(' + statsNode[key].count[key2] + ')');\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tformatedStatNode.sCount = sCount;\r\n\t\t\t}\r\n\r\n\t\t\tif(statsNode[key].idSujet !== '')\r\n\t\t\t{\r\n\r\n\t\t\t\tlet oSujet = this.getSujet(statsNode[key].idSujet);\r\n\t\t\t\tif (oSujet)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.sujetLib = oSujet.name;\r\n\t\t\t\t\tif (oSujet.datas && oSujet.datas.etat && !formatedStatNode.ps)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.ps = oSujet.datas.etat;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tthis._statsNode.push(formatedStatNode);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tset statsNode2(statsNode)\r\n\t{\r\n\r\n\t\tthis._statsNode2 = [];\r\n\t\tfor (let key in statsNode)\r\n\t\t{\r\n\t\t\tlet formatedStatNode: any = {};\r\n\r\n\t\t\t//On récupère les propriétés existantes\r\n\t\t\tfor (let keyStat in statsNode[key])\r\n\t\t\t{\r\n\t\t\t\tformatedStatNode[keyStat] = statsNode[key][keyStat];\r\n\t\t\t}\r\n\r\n\t\t\tformatedStatNode.nomeEpreuve\t= '';\r\n\t\t\tformatedStatNode.nomExamen\t\t= '';\r\n\t\t\tformatedStatNode.nomSession\t\t= '';\r\n\t\t\tformatedStatNode.nomEtab\t\t= '';\r\n\t\t\tformatedStatNode.nomUser\t\t= '';\r\n\t\t\tformatedStatNode.sCount\t\t\t= '';\r\n\t\t\tformatedStatNode.echeanceLib\t= '';\r\n\t\t\tformatedStatNode.isPrincipal\t= false;\r\n\t\t\tformatedStatNode.isSecondary\t= false;\r\n\t\t\tformatedStatNode.isAccepted\t\t= false;\r\n\r\n\r\n\t\t\tformatedStatNode.sujetLib\t= '';\r\n\r\n\t\t\tlet oEpreuve;\r\n\t\t\t// Récupération du nom de l'épreuve\r\n\t\t\tif (statsNode[key].idEpreuve !== '')\r\n\t\t\t{\r\n\t\t\t\toEpreuve = this.getEpreuve(statsNode[key].idEpreuve);\r\n\r\n\t\t\t\tif (oEpreuve)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomEpreuve = oEpreuve.name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Nom de l'examen\r\n\t\t\tif (statsNode[key].idExamen !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oExamen = this.getExamen(statsNode[key].idExamen);\r\n\r\n\t\t\t\tif (oExamen)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomExamen = oExamen.name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Nom de l'examen\r\n\t\t\tif (statsNode[key].idSession !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oSession = this.getSession(statsNode[key].idSession);\r\n\r\n\t\t\t\tif (oSession)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomSession = oSession.name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Nom de l'examen\r\n\t\t\tif (statsNode[key].idEtablissement !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oEtab = this.getExamen(statsNode[key].idEtablissement);\r\n\r\n\t\t\t\tif (oEtab)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.nomEtab = oEtab.name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// Nom de l'examen\r\n\t\t\tif (statsNode[key].echeance !== '')\r\n\t\t\t{\r\n\t\t\t\tlet date = new Date(statsNode[key].echeance);\r\n\t\t\t\tformatedStatNode.echeanceLib = date.toLocaleDateString();\r\n\t\t\t}\r\n\t\t\tif (statsNode[key].status)\r\n\t\t\t{\r\n\t\t\t\tswitch (statsNode[key].status)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase 'new':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Non assignée';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'todo':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Assignée';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'inprogress':\r\n\t\t\t\t\t\tformatedStatNode.status = 'En cours';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'review':\r\n\t\t\t\t\t\tformatedStatNode.status = 'A valider';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'done':\r\n\t\t\t\t\t\tformatedStatNode.status = 'Terminé';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif (statsNode[key].nomUser === \"undefined\")\r\n\t\t\t{\r\n\t\t\t\tformatedStatNode.nomUser = ' - ';\r\n\t\t\t}\r\n\r\n\t\t\t// Mise en forme des infos utilisateur\r\n\t\t\tif (statsNode[key].assigned_to !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oUser = this.chatData.getUser(statsNode[key].assigned_to);\r\n\r\n\t\t\t\tif (oUser)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (oUser.nom !== '' && oUser.nom !== undefined)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.nom + ' ';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (oUser.prenom !== '' && oUser.prenom !== undefined)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.prenom + ' ';\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t// Si on a rien on met le mail\r\n\t\t\t\t\tif (statsNode[key].nomUser === '')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tformatedStatNode.nomUser += oUser.id;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t\t// Mise en forme info des taches\r\n\t\t\tif (statsNode[key].idTask !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oTask = this._globalTask[statsNode[key].idTask];\r\n\t\t\t}\r\n\r\n\t\t\tif (statsNode[key].count !== '')\r\n\t\t\t{\r\n\t\t\t\tlet sCount = [];\r\n\t\t\t\tfor (let key2 in statsNode[key].count)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (key2 === statsNode[key].typeT)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet name \t\t= '';\r\n\t\t\t\t\t\tlet txtEtape \t= key2;\r\n\r\n\t\t\t\t\t\tif (oEpreuve && oEpreuve.scenario && oEpreuve.scenario.steps)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet step = _.find(oEpreuve.scenario.steps, (step: any) => { return step.id.toString() === key2; });\r\n\r\n\t\t\t\t\t\t\tif (step)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\ttxtEtape = step.name;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tif(statsNode[key].count[key2] > 1)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsCount.push( txtEtape + '(' + statsNode[key].count[key2] + ')');\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsCount.push(txtEtape);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tformatedStatNode.sCount = sCount;\r\n\t\t\t}\r\n\r\n\t\t\tif(statsNode[key].idSujet !== '')\r\n\t\t\t{\r\n\t\t\t\tlet oSujet = this.getSujet(statsNode[key].idSujet);\r\n\t\t\t\tif (oSujet)\r\n\t\t\t\t{\r\n\t\t\t\t\tformatedStatNode.sujetLib = oSujet.name;\r\n\t\t\t\t\tif (oSujet.datas && oSujet.datas.etat)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tformatedStatNode.ps = oSujet.datas.etat;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tthis._statsNode2.push(formatedStatNode);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tset fileForEdit(fileForEdit) { this._fileForEdit = fileForEdit;}\r\n\r\n\r\n\tset selectedEtablissement(selectedEtablissement)\r\n\t{\r\n\t\tif (selectedEtablissement)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedEtablissementId', selectedEtablissement.id);\r\n\t\t}\r\n\t\tthis._selectedEtablissement\t= selectedEtablissement;\r\n\t}\r\n\r\n\r\n\tset selectedSession(selectedSession)\r\n\t{\r\n\t\tif (selectedSession)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedSessionId', selectedSession.id);\r\n\t\t}\r\n\t\tthis._selectedSession = selectedSession;\r\n\t}\r\n\r\n\r\n\tset selectedExamen(selectedExamen)\r\n\t{\r\n\t\tif (selectedExamen)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedExamenId', selectedExamen.id);\r\n\t\t}\r\n\t\tthis._selectedExamen = selectedExamen;\r\n\t}\r\n\r\n\r\n\tset selectedMatiere(selectedMatiere)\r\n\t{\r\n\t\tif (selectedMatiere)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedMatiereId', selectedMatiere.id);\r\n\t\t}\r\n\t\tthis._selectedMatiere = selectedMatiere;\r\n\t}\r\n\r\n\r\n\tset selectedSujet(selectedSujet)\r\n\t{\r\n\t\tif (selectedSujet)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedSubjectId', selectedSujet.id);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedSubjectId');\r\n\t\t}\r\n\t\tthis._selectedSujet\t= selectedSujet;\r\n\t}\r\n\r\n\r\n\tset selectedTask(selectedTask)\r\n\t{\r\n\t\tif (selectedTask)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedTaskId', selectedTask.id);\r\n\t\t}\r\n\t\tthis._selectedTask = selectedTask;\r\n\t}\r\n\r\n\r\n\tset sujetKey(sujetKey)\r\n\t{\r\n\t\tif (sujetKey)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::sujetKey', sujetKey);\r\n\t\t}\r\n\t\tthis._sujetKey = sujetKey;\r\n\t}\r\n\r\n\r\n\tset selectedElement(selectedElement)\r\n\t{\r\n\t\tif (selectedElement)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedElementId', selectedElement.id);\r\n\t\t}\r\n\t\tthis._selectedElement = selectedElement;\r\n\t}\r\n\r\n\r\n\tset etablissements(etablissements)\r\n\t{\r\n\t\tthis._etablissements = etablissements;\r\n\t}\r\n\r\n\r\n\tresetSelectedEtablissement()\r\n\t{\r\n\t\tthis._selectedEtablissement = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedEtablissementId');\r\n\t}\r\n\r\n\r\n\tresetSelectedSession()\r\n\t{\r\n\t\tthis._selectedSession = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedSessionId');\r\n\t}\r\n\r\n\r\n\tresetSelectedExamen()\r\n\t{\r\n\t\tthis._selectedExamen = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedExamenId');\r\n\t}\r\n\r\n\r\n\tresetSelectedMatiere()\r\n\t{\r\n\t\tthis._selectedMatiere = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedMatiereId');\r\n\t}\r\n\r\n\r\n\tresetSelectedSujet()\r\n\t{\r\n\t\tthis._selectedSujet = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedSubjectId');\r\n\t}\r\n\r\n\r\n\tset selectedSegment(selectedSegment)\t\t\t\t{ this._selectedSegment\t\t\t= selectedSegment;}\r\n\tset taskDatas(taskDatas)\t\t\t\t\t\t\t{ this._taskDatas\t\t\t\t= taskDatas; }\r\n\tset taskHomeAdmin(taskHomeAdmin)\t\t\t\t\t{ this._taskHomeAdmin\t\t\t= taskHomeAdmin; }\r\n\tset taskHomeAdminToValid(taskHomeAdminToValid: any)\t{ this._taskHomeAdminToValid\t= taskHomeAdminToValid; }\r\n\tset taskHomeAdminExpired(taskHomeAdminExpired)\t\t{ this._taskHomeAdminExpired\t= taskHomeAdminExpired; }\r\n\tset taskHomeMine(taskHomeMine)\t\t\t\t\t\t{ this._taskHomeMine\t\t\t= taskHomeMine; }\r\n\tset epreuveHomeAdmin(epreuveHomeAdmin)\t\t\t\t{ this._epreuveHomeAdmin\t\t= epreuveHomeAdmin; }\r\n\tset globalTask(globalTask)\t\t\t\t\t\t\t{ this._globalTask\t\t\t\t= globalTask; }\r\n\r\n\r\n\t/**\r\n\t * Quand on a les data, si les 2 sont ok on precess, a la fin du process haveDatachat = true;\r\n\t */\r\n\tset isInfoTaskMineOk(isOk: any)\r\n\t{\r\n\t\tthis._isInfoTaskMineOk = isOk;\r\n\t\tif ((this._isInfoTaskMineOk === true || this._isInfoTaskAdminOk === true) && this._isInfoNodeOk === true && this._isInfoSubjectOk === true)\r\n\t\t{\r\n\t\t\tthis.processData();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Quand on a les data, si les 2 sont ok on precess, a la fin du process haveDatachat = true;\r\n\t */\r\n\tset isInfoTaskAdminOk(isOk: any)\r\n\t{\r\n\t\tthis._isInfoTaskAdminOk = isOk;\r\n\t\tif ((this._isInfoTaskMineOk === true || this._isInfoTaskAdminOk === true) && this._isInfoNodeOk === true && this._isInfoSubjectOk === true)\r\n\t\t{\r\n\t\t\tthis.processData();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Quand on a les data, si les 2 sont ok on precess, a la fin du process haveDatachat = true;\r\n\t */\r\n\tset isInfoNodeOk(isOk: any)\r\n\t{\r\n\t\tthis._isInfoNodeOk = isOk;\r\n\t\tif ((this._isInfoTaskMineOk === true || this._isInfoTaskAdminOk === true) && this._isInfoNodeOk === true && this._isInfoSubjectOk === true)\r\n\t\t{\r\n\t\t\tthis.processData();\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * Quand les sujets sont chargés on peux mettre à jour les informations des taches\r\n\t * avec les infos des sujets\r\n\t */\r\n\tset isInfoSubjectOk(isOk: any)\r\n\t{\r\n\t\tthis._isInfoSubjectOk = isOk;\r\n\t\tif ((this._isInfoTaskMineOk === true || this._isInfoTaskAdminOk === true) && this._isInfoNodeOk === true && this._isInfoSubjectOk === true)\r\n\t\t{\r\n\t\t\tthis.processData();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tset historic(historic)\r\n\t{\r\n\t\tthis._historicFromElement = historic;\r\n\t}\r\n\r\n\r\n\tget globalTask(): any\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._globalTask)\r\n\t\t{\r\n\t\t\t// On retourne sous cette forme pour que ça soit plus simple de parser coté html\r\n\t\t\toReturn.push(this._globalTask[key]);\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tget historic()\r\n\t{\r\n\t\treturn this._historicFromElement;\r\n\t}\r\n\r\n\r\n\t// ---------------------------------------------------------------------------------------------------------------------\r\n\t// Spécifique\r\n\t// ---------------------------------------------------------------------------------------------------------------------\r\n\tpublic setTaskHomeAdmin(id: any, data: any)\r\n\t{\r\n\t\tthis._taskHomeAdmin[id] = data;\r\n\t}\r\n\r\n\tpublic setTaskHomeExpired(id: any, data: any)\r\n\t{\r\n\t\tthis._taskHomeAdminExpired[id] = data;\r\n\t}\r\n\r\n\r\n\tpublic setTaskHomeAdminToValid(id: any, data: any)\r\n\t{\r\n\t\tthis._taskHomeAdminToValid[id] = data;\r\n\t}\r\n\r\n\r\n\tpublic setTaskHomeAdminExpired(id: any, data: any)\r\n\t{\r\n\t\tthis._taskHomeAdminExpired[id] = data;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t * @param data\r\n\t */\r\n\tpublic setEpreuveHomeAdmin(id: any, data: any)\r\n\t{\r\n\t\tlet epName\t\t\t= '';\r\n\t\tlet ariane\t\t\t= '';\r\n\t\tlet etabName\t\t= '';\r\n\t\tlet sessName\t\t= '';\r\n\t\tlet examName\t\t= '';\r\n\r\n\t\tlet oEpreuve\t= this.getEpreuve( data.id);\r\n\t\tif (oEpreuve)\r\n\t\t{\r\n\t\t\tdata.name = oEpreuve.name;\r\n\t\t}\r\n\r\n\t\tfor (let key of data.parents)\r\n\t\t{\r\n\t\t\tlet keyArray = key.split('::');\r\n\r\n\t\t\tswitch (keyArray[0])\r\n\t\t\t{\r\n\t\t\t\tcase '*etab':\r\n\t\t\t\t\tlet oEtab = this.getEtablissement(keyArray[1]);\r\n\t\t\t\t\tif (oEtab)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tetabName = oEtab.name;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase '*exam':\r\n\t\t\t\t\tlet oExam = this.getExamen(keyArray[1]);\r\n\t\t\t\t\tif (oExam)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\texamName = oExam.name;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase '*sess':\r\n\t\t\t\t\tlet oSess = this.getSession(keyArray[1]);\r\n\t\t\t\t\tif (oSess)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsessName = oSess.name;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tariane\t\t= etabName + '/' + sessName + '/' + examName;\r\n\t\tdata.ariane = ariane;\r\n\r\n\t\tthis._epreuveHomeAdmin[id]\t\t= data;\r\n\t\tthis._epreuveHomeAdminSave[id]\t= data;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param pnIndice\r\n\t */\r\n\tremoveTaskToValid(pnIndice: any)\r\n\t{\r\n\t\tlet aArray:any[]\t\t\t= [];\r\n\t\tlet nIndice\t\t\t\t\t= 0;\r\n//\t\tthis._taskHomeAdminExpired\t= [];\r\n\r\n\t\tfor (let key in this._taskHomeAdminToValid)\r\n\t\t{\r\n\t\t\tif (nIndice !== pnIndice)\r\n\t\t\t{\r\n\t\t\t\taArray[key] = this._taskHomeAdminToValid[key];\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._taskHomeAdminToValid = aArray;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param pnIndice\r\n\t */\r\n\tremoveTaskExpired(pnIndice: any)\r\n\t{\r\n\r\n\t\tlet aArray:any[]\t\t\t= [];\r\n\t\tlet nIndice\t\t\t\t\t= 0;\r\n//\t\tthis._taskHomeAdminExpired\t= [];\r\n\r\n\t\tfor (let key in this._taskHomeAdminExpired)\r\n\t\t{\r\n\t\t\tif (nIndice !== pnIndice)\r\n\t\t\t{\r\n\t\t\t\taArray[key] = this._taskHomeAdminExpired[key];\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._taskHomeAdminExpired = aArray;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param pnIndice\r\n\t */\r\n\tremoveTaskToMine(pnIndice: any)\r\n\t{\r\n\r\n\t\tlet aArray: any[] = [];\r\n\t\t//\t\tthis._taskHomeMine\t= [];\r\n\t\tlet nIndice = 0;\r\n\r\n\t\tfor (let key in this._taskHomeMine)\r\n\t\t{\r\n\t\t\tif (nIndice !== pnIndice)\r\n\t\t\t{\r\n\t\t\t\taArray[key] = this._taskHomeMine[key];\r\n\t\t\t}\r\n\t\t\tnIndice++;\r\n\t\t}\r\n\r\n\t\tthis._taskHomeMine = aArray;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t * @param data\r\n\t */\r\n\tpublic setTaskHomeMine(id: any, data: any)\r\n\t{\r\n\t\tthis._taskHomeMine[id] = data;\r\n//\t\tthis.processData();\r\n\t}\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t * @param data\r\n\t */\r\n\tpublic cleanTaskHomeMine()\r\n\t{\r\n\t\tthis._taskHomeMine = [];\r\n//\t\tthis.processData();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param idTask\r\n\t * @param task\r\n\t */\r\n\tpublic setGlobalTask(idTask: any, task: any)\r\n\t{\r\n\t\tlet indexTask = _.findIndex(this._globalTask, (t: any) =>\r\n\t\t{\r\n\t\t\treturn t.id === idTask;\r\n\t\t});\r\n\r\n\t\tif (indexTask === - 1)\r\n\t\t{\r\n\t\t\tthis._globalTask.push(task);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis._globalTask[indexTask] = task;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param idTask\r\n\t */\r\n\tpublic getGlobalTaskById(idTask: any)\r\n\t{\r\n\t\tlet result = undefined;\r\n\r\n\t\tlet indexTask = _.findIndex(this._globalTask, (t: any) =>\r\n\t\t{\r\n\t\t\treturn t.id === idTask;\r\n\t\t});\r\n\r\n\t\tif (indexTask !== -1)\r\n\t\t{\r\n\t\t\tresult = this._globalTask[indexTask];\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\tpublic getEtablissement(id: any): Etablissement { return this._etablissements[id]; }\r\n\tpublic addEtablissement(id: any, data: Etablissement)\r\n\t{\r\n\t\tthis._etablissements[id] \t= data;\r\n\t\t//this._selectedEtablissement = data;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Retourne la liste des établissements\r\n\t */\r\n\tget etablissements(): Etablissement[]\r\n\t{\r\n\t\tlet etabReturn = [];\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\t// On retourne sous cette forme pour que ça soit plus simple de parser coté html\r\n\t\t\tetabReturn.push(this._etablissements[key]);\r\n\t\t}\r\n\t\tetabReturn.sort(function (a, b)\r\n\t\t{\r\n\t\t\tvar nameA = a.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\tvar nameB = b.name.toUpperCase(); // ignore upper and lowercase\r\n\r\n\t\t\tif (nameA < nameB)\r\n\t\t\t{\r\n\t\t\t\treturn -1;\r\n\t\t\t}\r\n\t\t\tif (nameA > nameB)\r\n\t\t\t{\r\n\t\t\t\treturn 1;\r\n\t\t\t}\r\n\r\n\t\t\t// names must be equal\r\n\t\t\treturn 0;\r\n\t\t});\r\n\t\treturn etabReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Maj d'un établissement\r\n\t */\r\n\tpublic majEtablissement(id: any, data: any)\r\n\t{\r\n\t\t// Msie à jours des éléments en mode GROS bourrin !\r\n\t\t// La maj c'est spécial\r\n\t\tif (data && this._etablissements)\r\n\t\t{\r\n\t\t\tif (this._etablissements[data.id])\r\n\t\t\t{\r\n\t\t\t\tthis._etablissements[data.id].name\t\t\t\t= data.name;\r\n\t\t\t\tthis._etablissements[data.id].description\t\t= data.description;\r\n\t\t\t\tthis._etablissements[data.id].dateModification\t= data.dateModification;\r\n\t\t\t\tthis._etablissements[data.id].dateCreation\t\t= data.dateCreation;\r\n\t\t\t\tthis._etablissements[data.id].author\t\t\t= data.author;\r\n\r\n\r\n\t\t\t\tif (this._selectedEtablissement && data.id === this._selectedEtablissement.id)\r\n\t\t\t\t{\r\n\t\t\t\t\t// Mise à jours des éléments selectionné\r\n\t\t\t\t\tthis._selectedEtablissement.name\t\t\t\t= data.name;\r\n\t\t\t\t\tthis._selectedEtablissement.description\t\t\t= data.description;\r\n\t\t\t\t\tthis._selectedEtablissement.dateModification\t= data.dateModification;\r\n\t\t\t\t\tthis._selectedEtablissement.dateCreation\t\t= data.dateCreation;\r\n\t\t\t\t\tthis._selectedEtablissement.author\t\t\t\t= data.author;\r\n\r\n\r\n\t\t\t\t\tif (this._selectedElement && data.id === this._selectedElement.id)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis._selectedElement.name\t\t\t\t\t= data.name;\r\n\t\t\t\t\t\tthis._selectedElement.description\t\t\t= data.description;\r\n\t\t\t\t\t\tthis._selectedElement.dateModification\t\t= data.dateModification;\r\n\t\t\t\t\t\tthis._selectedElement.dateCreation\t\t\t= data.dateCreation;\r\n\t\t\t\t\t\tthis._selectedElement.author\t\t\t\t= data.author;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis._etablissements[data.id]\t= data;\r\n\t//\t\t\tthis._selectedEtablissement\t\t= data;\r\n\t//\t\t\tthis._selectedElement\t\t\t= data;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Ajoute ou MAJ une session\r\n\t */\r\n\tpublic setSession(id: string, data: Session, idParent: any)\r\n\t{\r\n\t\tlet isFind = false;\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tif (session.id === id)\r\n\t\t\t\t{\r\n\t\t\t\t\tisFind\t\t\t\t\t= true;\r\n\t\t\t\t\tsession.name\t\t\t= data.name;\r\n\t\t\t\t\tsession.description\t\t= data.description;\r\n\t\t\t\t\tsession.dateCreation\t= data.dateCreation;\r\n\r\n\t\t\t\t\tthis._etablissements[key].sessions.sort(function (a, b)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar nameA = a.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\tvar nameB = b.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\tif (nameA < nameB)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn -1;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (nameA > nameB)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn 1;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// names must be equal\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Cas ou la session est à ajouter\r\n\t\tif (!isFind)\r\n\t\t{\r\n\t\t\tfor (let key in this._etablissements)\r\n\t\t\t{\r\n\t\t\t\tif (this._etablissements[key].id === idParent)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis._etablissements[key].sessions.push(data);\r\n\t\t\t\t\tthis._etablissements[key].sessions.sort(function (a, b)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tvar nameA = a.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\tvar nameB = b.name.toUpperCase(); // ignore upper and lowercase\r\n\r\n\t\t\t\t\t\tif (nameA < nameB)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn -1;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (nameA > nameB)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn 1;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// names must be equal\r\n\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic resetSelect()\r\n\t{\r\n\t\tthis._selectedEtablissement = null;\r\n\t\tthis._selectedSession\t\t= null;\r\n\t\tthis._selectedExamen\t\t= null;\r\n\t\tthis._selectedMatiere\t\t= null;\r\n\t\tthis._selectedSujet\t\t\t= null;\r\n\t\tthis._selectedElement\t\t= null;\r\n\t\tthis._sujetKey\t\t\t\t= null;\r\n\t\tthis.selectedItems\t\t\t= [];\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic resetHomeSelect()\r\n\t{\r\n\t\tthis._selectedHomeEtablissement = null;\r\n\t\tthis._selectedHomeSession\t\t= null;\r\n\t\tthis._selectedHomeExamen\t\t= null;\r\n\t\tthis._selectedHomeMatiere\t\t= null;\r\n\t\tthis._selectedHomeSujet\t\t\t= null;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * ajoute ou MAJ un examen\r\n\t */\r\n\tpublic setExamen(id: string, data: Examen, idParent: any)\r\n\t{\r\n\t\tlet isFind = false;\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (examen.id === id)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tisFind \t\t\t\t= true;\r\n\t\t\t\t\t\texamen.name \t\t= data.name;\r\n\t\t\t\t\t\texamen.description \t= data.description;\r\n\r\n\t\t\t\t\t\tsession.examens.sort(function (a, b)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvar nameA = a.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\t\tvar nameB = b.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\t\tif (nameA < nameB)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn -1;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (nameA > nameB)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn 1;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t// names must be equal\r\n\t\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\t// Cas ou la session est à ajouter\r\n\t\tif (!isFind)\r\n\t\t{\r\n\t\t\tfor (let key in this._etablissements)\r\n\t\t\t{\r\n\t\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (session.id === idParent)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsession.examens.push(data);\r\n\t\t\t\t\t\tsession.examens.sort(function (a, b)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvar nameA = a.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\t\tvar nameB = b.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\t\tif (nameA < nameB)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn -1;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tif (nameA > nameB)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn 1;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t// names must be equal\r\n\t\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * ajoute ou MAJ une matière\r\n\t */\r\n\tpublic setMatiere(id: string, data: Matiere, idParent: any)\r\n\t{\r\n\t\tlet isFind = false;\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (matiere.id === id)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tisFind\t\t\t\t\t= true;\r\n\t\t\t\t\t\t\tmatiere.name\t\t\t= data.name;\r\n\t\t\t\t\t\t\tmatiere.description\t\t= data.description;\r\n\t\t\t\t\t\t\tmatiere.dateCreation\t= data.dateCreation;\r\n\t\t\t\t\t\t\tmatiere.typeEpreuve\t\t= data.typeEpreuve;\r\n\r\n\t\t\t\t\t\t\texamen.matieres.sort(function (a, b)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvar nameA = a.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\t\t\tvar nameB = b.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\t\t\tif (nameA < nameB)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn -1;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tif (nameA > nameB)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn 1;\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t// names must be equal\r\n\t\t\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Cas ou la session est à ajouter\r\n\t\tif (!isFind)\r\n\t\t{\r\n\t\t\tfor (let key in this._etablissements)\r\n\t\t\t{\r\n\t\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (examen.id === idParent)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\texamen.matieres.push(data);\r\n\t\t\t\t\t\t\texamen.matieres.sort(function (a, b)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvar nameA = a.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\t\t\tvar nameB = b.name.toUpperCase(); // ignore upper and lowercase\r\n\t\t\t\t\t\t\t\tif (nameA < nameB)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn -1;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tif (nameA > nameB)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn 1;\r\n\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t// names must be equal\r\n\t\t\t\t\t\t\t\treturn 0;\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Retourne vrai si un element possède des élément enfants, retourne faux sinon\r\n\t */\r\n\tpublic hasElementChilds(element: any)\r\n\t{\r\n\t\tlet result: boolean = false;\r\n\r\n\t\tif (element instanceof Etablissement)\r\n\t\t{\r\n\t\t\tif (element.sessions.length > 0)\r\n\t\t\t{\r\n\t\t\t\tresult = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (element instanceof Session)\r\n\t\t{\r\n\t\t\tif (element.examens.length > 0)\r\n\t\t\t{\r\n\t\t\t\tresult = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (element instanceof Examen)\r\n\t\t{\r\n\t\t\tif (element.matieres.length > 0)\r\n\t\t\t{\r\n\t\t\t\tresult = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (element instanceof Matiere)\r\n\t\t{\r\n\t\t\tif (element.sujets.length > 0)\r\n\t\t\t{\r\n\t\t\t\tresult = true;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Mise à jours d'une matière après insert d'un sujet\r\n\t */\r\n\tpublic addFile(idSujet: string, data: EFile, ras = false)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (sujet.id === idSujet)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlet indexPj = _.findIndex(sujet.pj, {id:data.id});\r\n\r\n\t\t\t\t\t\t\t\tif (indexPj === -1)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tsujet.pj.push(data);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t//Sinon on la met à jour\r\n\t\t\t\t\t\t\t\t\t//On concernve les thumbnails et les clé aes du fichier courant\r\n\t\t\t\t\t\t\t\t\t//si ces données sont présentes\r\n\t\t\t\t\t\t\t\t\t//Si le thumbnail et les clé AES sont également présent dans la\r\n\t\t\t\t\t\t\t\t\t//nouvelle version du fichier, on prend ces donénes en priorité\r\n\t\t\t\t\t\t\t\t\tif (sujet.pj[indexPj].thumbs.length > 0)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif (data.thumbs.length === 0)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tdata.thumbs = sujet.pj[indexPj].thumbs;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\tif (sujet.pj[indexPj].encryptedAesKeys.length > 0)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif (data.encryptedAesKeys.length === 0)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tdata.encryptedAesKeys = sujet.pj[indexPj].encryptedAesKeys;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\tsujet.pj[indexPj] = data;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Mise à jours d'une matière après insert d'un sujet\r\n\t */\r\n\tpublic razFile(idSujet: string)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (sujet.id === idSujet)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsujet.pj = [];\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t// Mise à jour des élements selected\r\n\t\t\t\t\t\t\tif (sujet.id === this.selectedSujet.id)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tthis.selectedSujet.pj = [];\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param idSujet\r\n\t */\r\n\tpublic selectSujetById(idSujet: any)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (sujet.id === idSujet)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tthis.selectedSujet = sujet;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param jsonSujets\r\n\t */\r\n\tpublic _updateSubjectFromJSON(jsonSujets: any[])\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Gestion des sujets transmis par socket et enregistrement de ces sujets dans la structure user-data\r\n\t * @param jsonSujets\r\n\t */\r\n\tpublic _addSubjectFromJSON(jsonSujets: any[])\r\n\t{\r\n\t\tconst subjectsAdded: any[] = [];\r\n\t\t//pour chaque sujet récupéré\r\n\t\tfor (let subject of jsonSujets)\r\n\t\t{\r\n\t\t\tlet subjectToAdd : Sujet = Sujet.fromJsonObject(subject);\r\n\r\n\t\t\tif (subjectToAdd.datas.scenario)\r\n\t\t\t{\r\n\t\t\t\tsubjectToAdd.datas.scenario2 = JSON.parse(subjectToAdd.datas.scenario);\r\n\r\n\t\t\t\tfor (let key of subjectToAdd.datas.scenario2.steps)\r\n\t\t\t\t{\r\n\t\t\t\t\t//Si une tache existe on l'affecte sinon il s'agit d'une tache \"fantome\"\r\n\t\t\t\t\tlet existingTask = _.find(this.taskData.globalTaskDatas, (task: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn task.idSujet === subjectToAdd.id && Number(task.type) === Number(key.id);\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tif (existingTask)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\texistingTask.nameSujet = subjectToAdd.name;\r\n\t\t\t\t\t\tsubjectToAdd.fake[key.id] = existingTask;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsubjectToAdd.fake[key.id] = key;\r\n\t\t\t\t\t\tsubjectToAdd.fake[key.id].realTask = false;\r\n\t\t\t\t\t}\r\n\t//\t\t\t\tsubjectToAdd.fake[key.id] = subjectToAdd.datas.scenario2.steps;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//On récupère l'épreuve correspondante\r\n\t\t\tlet epreuve = this.getEpreuve(subjectToAdd.idMatiere);\r\n\r\n\t\t\tif (epreuve)\r\n\t\t\t{\r\n\t\t\t\t//On regarde si le sujet n'éxiste pas déja dans l'épreuve\r\n\t\t\t\tlet indexSujet = _.findIndex(epreuve.sujets, (sujet: any) => { return sujet.id === subjectToAdd.id; });\r\n\t\t\t\tif (indexSujet !== -1)\r\n\t\t\t\t{\r\n\t\t\t\t\t//Si c'est le cas on remplace le sujet\r\n\t\t\t\t\tepreuve.sujets[indexSujet] = subjectToAdd;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t//Sinon on l'ajoute\r\n\t\t\t\t\tepreuve.sujets.push(subjectToAdd);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tsubjectsAdded.push(subjectToAdd);\r\n\r\n\t\t\t\t//S'il s'agit du sujet courant on le met à jour\r\n\t\t\t\tif (this.selectedSujet && this.selectedSujet.id === subjectToAdd.id)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.selectedSujet = subjectToAdd;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//On met à jour le nom du sujet dans les tache concernée de l'épreuve\r\n\t\t\t\tlet taskEpr = _.find(epreuve.tasks, (task: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn task.idSujet === subjectToAdd.id;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif (taskEpr)\r\n\t\t\t\t{\r\n\t\t\t\t\ttaskEpr.nameSujet = subjectToAdd.name;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn subjectsAdded;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t */\r\n\tpublic getTreeElementForComment(id: any)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n//\t\t\tif (key === id) { return this._etablissements[key]; }\r\n\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tif (session.id === id) { return session; }\r\n\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (examen.id === id) { return examen; }\r\n\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (matiere.id === id) { return matiere; }\r\n\r\n\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (sujet.id === id) { return sujet; }\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t */\r\n\tpublic getBranchFromId(id: any)\r\n\t{\r\n\t\tlet result: any = {};\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tif (key === id)\r\n\t\t\t{\r\n\t\t\t\tresult.etablissement = this._etablissements[key];\r\n\r\n\t\t\t\treturn result;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (session.id === id)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresult.etablissement \t= this._etablissements[key];\r\n\t\t\t\t\t\tresult.session \t\t\t= session;\r\n\r\n\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (examen.id === id)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresult.etablissement \t= this._etablissements[key];\r\n\t\t\t\t\t\t\t\tresult.session \t\t\t= session;\r\n\t\t\t\t\t\t\t\tresult.examen \t\t\t= examen;\r\n\r\n\t\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (matiere.id === id)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tresult.etablissement \t= this._etablissements[key];\r\n\t\t\t\t\t\t\t\t\t\tresult.session \t\t\t= session;\r\n\t\t\t\t\t\t\t\t\t\tresult.examen \t\t\t= examen;\r\n\t\t\t\t\t\t\t\t\t\tresult.matiere \t\t\t= matiere;\r\n\r\n\t\t\t\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tif (sujet.id === id)\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tresult.etablissement \t= this._etablissements[key];\r\n\t\t\t\t\t\t\t\t\t\t\t\tresult.session \t\t\t= session;\r\n\t\t\t\t\t\t\t\t\t\t\t\tresult.examen \t\t\t= examen;\r\n\t\t\t\t\t\t\t\t\t\t\t\tresult.matiere \t\t\t= matiere;\r\n\t\t\t\t\t\t\t\t\t\t\t\tresult.sujet \t\t\t= sujet;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\tfor (let pj of sujet.pj)\r\n\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tif (pj.id === id)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult.etablissement \t= this._etablissements[key];\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult.session \t\t\t= session;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult.examen \t\t\t= examen;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult.matiere \t\t\t= matiere;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult.sujet \t\t\t= sujet;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tresult.pj \t\t\t\t= pj;\r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\treturn result;\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t// désolé\r\n\t\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param data\r\n\t * @param replace\r\n\t */\r\n\tpublic setTasksBySubject(data: any, replace = false)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\t//\t\t\tif (key === id) { return this._etablissements[key]; }\r\n\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfor (let task of data)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (sujet.id === task.idsujet)\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\tlet oTask \t= Task.fromJsonObject(task);\r\n\t\t\t\t\t\t\t\t\toTask \t\t= this.taskData.buildTask(oTask);\r\n\r\n\t\t\t\t\t\t\t\t\tlet idSaouled \t\t\t= parseInt(oTask.type);\r\n\t\t\t\t\t\t\t\t\tsujet.fake[idSaouled] \t= oTask;\r\n\r\n\t\t\t\t\t\t\t\t\tlet indexInSubjectTasks = _.findIndex(sujet.tasks, (taskObj: any) => { return taskObj.id === oTask.id; });\r\n\t\t\t\t\t\t\t\t\tif (indexInSubjectTasks === -1)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tsujet.tasks.push(oTask);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tif (replace === true)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tsujet.tasks[indexInSubjectTasks] = oTask;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\t\t// Gestion des scénario ...\r\n\t\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t */\r\n\tpublic getTreeElement(id: any)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tif (key === id) { return this._etablissements[key]; }\r\n\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tif (session.id === id) { return session; }\r\n\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (examen.id === id) { return examen; }\r\n\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (matiere.id === id) { return matiere; }\r\n\r\n\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (sujet.id === id) { return sujet; }\r\n\t\t\t\t\t\t\tfor (let pj of sujet.pj)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (pj.id === id) { return pj; }\r\n\t\t\t\t\t\t\t\t// désolé\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t */\r\n\tpublic getSession(id: any)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tif (session.id === id) { return session; }\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t */\r\n\tpublic getExamen(id: any)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (examen.id === id) { return examen; }\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t */\r\n\tpublic getEpreuve(id: any)\r\n\t{\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (matiere.id === id) { return matiere; }\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param idNode\r\n\t * @param type\r\n\t * @param parents\r\n\t */\r\n\tpublic removeNode(idNode: any, type: string, parents: any[])\r\n\t{\r\n\t\tlet structParents: any = {};\r\n\r\n\t\tfor (let parent of parents)\r\n\t\t{\r\n\t\t\tif (parent.indexOf('*etab::') >= 0)\r\n\t\t\t{\r\n\t\t\t\tstructParents.etab = parent.split('::').pop();\r\n\t\t\t}\r\n\r\n\t\t\tif (parent.indexOf('*sess::') >= 0)\r\n\t\t\t{\r\n\t\t\t\tstructParents.session = parent.split('::').pop();\r\n\t\t\t}\r\n\r\n\t\t\tif (parent.indexOf('*exam::') >= 0)\r\n\t\t\t{\r\n\t\t\t\tstructParents.examen = parent.split('::').pop();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tswitch (type)\r\n\t\t{\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t\tcase 'etablissement':\r\n\r\n\t\t\t\tif (this._etablissements[idNode])\r\n\t\t\t\t{\r\n\t\t\t\t\tdelete this._etablissements[idNode];\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'session':\r\n\t\t\t\tif (parents.length === 2)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (structParents.etab\r\n\t\t\t\t\t\t&& this._etablissements[structParents.etab])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet etab = this._etablissements[structParents.etab];\r\n\r\n\t\t\t\t\t\tlet index = _.findIndex(etab.sessions, (session: any) => {\r\n\t\t\t\t\t\t\treturn session.id === idNode;\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\tif (index !== -1)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tetab.sessions.splice(index, 1);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'examen':\r\n\t\t\t\tif (parents.length === 3)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (structParents.etab && structParents.session && this._etablissements[structParents.etab])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet etab = this._etablissements[structParents.etab];\r\n\t\t\t\t\t\tlet indexSession = _.findIndex(etab.sessions, (session: any) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn session.id === structParents.session;\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\tif (indexSession !== -1)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet session = etab.sessions[indexSession];\r\n\t\t\t\t\t\t\tlet index = _.findIndex(session.examens, (examen: any) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn examen.id === idNode;\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\tif (index !== -1)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsession.examens.splice(index, 1);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'epreuve':\r\n\t\t\t\tif (parents.length === 4)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (structParents.etab && structParents.session && structParents.examen && this._etablissements[structParents.etab])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet etab = this._etablissements[structParents.etab];\r\n\r\n\t\t\t\t\t\tlet indexSession = _.findIndex(etab.sessions, (session: any) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn session.id === structParents.session;\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\tif (indexSession !== -1)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet session = etab.sessions[indexSession];\r\n\t\t\t\t\t\t\tlet indexExamen = _.findIndex(session.examens, (examen: any) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn examen.id === structParents.examen;\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\tif (indexExamen !== -1)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlet examen = session.examens[indexExamen];\r\n\r\n\t\t\t\t\t\t\t\tlet index = _.findIndex(examen.matieres, (matiere: any) =>\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn matiere.id === idNode;\r\n\t\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t\t\texamen.matieres.splice(index, 1);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\treturn structParents;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t */\r\n\tpublic getSujet(id: any)\r\n\t{\r\n\t\tfor (const key in this._etablissements)\r\n\t\t{\r\n\t\t\tfor (const session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (const examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (const matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (const sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (sujet.id === id) { return sujet; }\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param resultSearch\r\n\t * @param visible\r\n\t * @param textSearch\r\n\t */\r\n\tchangeTreeVisibility(resultSearch: any, visible: boolean, textSearch: string)\r\n\t{\r\n\t\tlet found;\r\n\r\n\t\tfor (let item of this._openedItemsBySearch)\r\n\t\t{\r\n\t\t\titem.show = false;\r\n\t\t}\r\n\r\n\t\tthis._openedItemsBySearch = [];\r\n\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\tif (this._etablissements[key])\r\n\t\t\t{\r\n\t\t\t\tif (resultSearch)\r\n\t\t\t\t{\r\n\t\t\t\t\tfound = _.findWhere(resultSearch, {idEtab: this._etablissements[key].id});\r\n\t\t\t\t\tthis._etablissements[key].visible = (found !== undefined);\r\n\r\n\t\t\t\t\tif (found && textSearch)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif(this._etablissements[key].name.toLowerCase().indexOf(textSearch) === -1)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis._etablissements[key].show = true;\r\n\t\t\t\t\t\t\tthis._openedItemsBySearch.push(this._etablissements[key]);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tthis._etablissements[key].visible = visible;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (resultSearch)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfound \t\t\t= _.findWhere(resultSearch, {idSession: session.id});\r\n\t\t\t\t\t\tsession.visible = (found !== undefined);\r\n\r\n\t\t\t\t\t\tif (found && textSearch)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif(session.name.toLowerCase().indexOf(textSearch) === -1)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsession.show = true;\r\n\t\t\t\t\t\t\t\tthis._openedItemsBySearch.push(session);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsession.visible = visible;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (resultSearch)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfound \t\t\t= _.findWhere(resultSearch, {idExamen: examen.id});\r\n\t\t\t\t\t\t\texamen.visible \t= (found !== undefined);\r\n\r\n\t\t\t\t\t\t\tif (found && textSearch)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif(examen.name.toLowerCase().indexOf(textSearch) === -1)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\texamen.show = true;\r\n\t\t\t\t\t\t\t\t\tthis._openedItemsBySearch.push(examen);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\texamen.visible = visible;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (resultSearch)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tfound = _.findWhere(resultSearch, {idMatiere: matiere.id});\r\n\t\t\t\t\t\t\t\tmatiere.visible = (found !== undefined);\r\n\r\n\t\t\t\t\t\t\t\tif (found && textSearch)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif(matiere.name.toLowerCase().indexOf(textSearch) === -1)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tmatiere.show = true;\r\n\t\t\t\t\t\t\t\t\t\tthis._openedItemsBySearch.push(matiere);\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tmatiere.visible = visible;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param idElement\r\n\t * @param values\r\n\t */\r\n\tpublic setHistoric(idElement: any, values: any[])\r\n\t{\r\n\t\tthis._historicFromElement[idElement] = { comments: values };\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param idElement\r\n\t */\r\n\tpublic getHistoric(idElement: any)\r\n\t{\r\n\t\tlet result;\r\n\r\n\t\tif (this._historicFromElement && this._historicFromElement[idElement])\r\n\t\t{\r\n\t\t\tresult = this._historicFromElement[idElement];\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Ajout d'un historic ou un commentaire à un élement donné\r\n\t * @param idElement\r\n\t * @param values\r\n\t */\r\n\tpublic addHistoricToElement(idElement: any, values: any[])\r\n\t{\r\n\t\tif (this._historicFromElement && this._historicFromElement[idElement])\r\n\t\t{\r\n\t\t\tfor (let value of values)\r\n\t\t\t{\r\n\t\t\t\t//On vérifie si le message n'est pas déja présent: vérification sur l'auteur et le dateticks\r\n\t\t\t\tlet existingMessage = _.find(this._historicFromElement[idElement].comments, (message: any) => {\r\n\r\n\t\t\t\t\treturn (\t//filtrage sur les commentaires déja existants\r\n\t\t\t\t\t\t\t\tvalue.idUser && value.dateticks && message.idUser === value.idUser && message.dateticks === value.dateticks\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t(\t//filtrage sur les historiques déja existants\r\n\t\t\t\t\t\t\t\tvalue.path && value.type && message.path === value.path && message.type === value.type\r\n\t\t\t\t\t\t\t)\r\n\t\t\t\t\t\t\t||\r\n\t\t\t\t\t\t\t(\r\n\t\t\t\t\t\t\t\tvalue.soustitre && value.dateticks && message.soustitre === value.soustitre && message.dateticks === value.dateticks\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif (!existingMessage)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis._historicFromElement[idElement].comments.push(value);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tthis._historicFromElement[idElement] = { comments: values };\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Parse un ensemble d'element de type historique ou de type message\r\n\t * @param data\r\n\t */\r\n\tpublic parseHistoric(data: any)\r\n\t{\r\n\t\tlet result: any[] = [];\r\n\t\tif (data.bucket)\r\n\t\t{\r\n\t\t\tswitch (data.bucket)\r\n\t\t\t{\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'session':\r\n\t\t\t\tcase 'examen':\r\n\t\t\t\tcase 'matiere':\r\n\t\t\t\tcase 'subjects':\r\n\t\t\t\tcase 'files':\r\n\t\t\t\tcase 'tasks':\r\n\t\t\t\t\tlet fileObj: any = this.getTreeElement(data.key);\r\n\r\n\t\t\t\t\tlet versionNum = 1;\r\n\t\t\t\t\tlet arrayHisto = _.toArray(data.messages);\r\n\r\n\t\t\t\t\tlet indice = 0;\r\n\r\n\t\t\t\t\tfor (let key in data.messages)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (data.messages[key] && data.messages[key])\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tarrayHisto[indice].key\t\t\t= new Date(data.messages[key].dateticks);\r\n\t\t\t\t\t\t\tarrayHisto[indice].dateticks\t= data.messages[key].dateticks;\r\n\t\t\t\t\t\t\tindice++;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tfor (let keyDate of arrayHisto)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tlet globalDate = keyDate.key;\r\n\r\n\t\t\t\t\t\tif (keyDate)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (keyDate.val && keyDate.who !== null)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlet dataHistoric: any\t= {};\r\n\t\t\t\t\t\t\t\tlet values\t\t\t\t= JSON.parse(keyDate.val);\r\n\t\t\t\t\t\t\t\tlet sub\t\t\t\t\t= keyDate.sub;\r\n\r\n\t\t\t\t\t\t\t\tdataHistoric.idUser\t\t\t= keyDate.who;\r\n\t\t\t\t\t\t\t\tdataHistoric.creationDate\t= keyDate.key;\r\n\t\t\t\t\t\t\t\tdataHistoric.dateticks\t\t= keyDate.dateticks;\r\n\r\n\t\t\t\t\t\t\t\tif (sub === 'H')\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tdataHistoric = this.parseHistoricItem(values, dataHistoric);\r\n\t\t\t\t\t\t\t\t\tif (dataHistoric)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdataHistoric.version = versionNum;\r\n\t\t\t\t\t\t\t\t\t\tversionNum++;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tif (sub === 'C')\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tdataHistoric.typeName = 'Message';\r\n\t\t\t\t\t\t\t\t\t\tif (values.comment)\r\n\t\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\t\tdataHistoric.content = values.comment;\r\n\t\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tif (dataHistoric)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tresult.push(dataHistoric);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tresult = result.reverse();\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Parse un élément de type historique\r\n\t */\r\n\tpublic parseHistoricItem(value: any, objectResult: any)\r\n\t{\r\n\t\tswitch (value.action)\r\n\t\t{\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'update':\r\n\t\t\t\tobjectResult.type\t\t= 'update';\r\n\t\t\t\tobjectResult.typeName\t= 'Mise à jour';\r\n\r\n\t\t\t\tif (value.data && value.data.libelle)\r\n\t\t\t\t{\r\n\t\t\t\t\tobjectResult.soustitre\t= 'à modifié : ';\r\n\t\t\t\t\tobjectResult.content\t= 'Libelle : ' + value.data.libelle;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t//Si il s'agit d'une nouvelle version d'un fichier\r\n\t\t\t\t\tif (value.path)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobjectResult.typeName\t\t= 'Edition';\r\n\t\t\t\t\t\tobjectResult.soustitrePath\t= 'A édité : ';\r\n\t\t\t\t\t\tobjectResult.path\t\t\t= value.path;\r\n\t\t\t\t\t\tobjectResult.nameFile\t\t= value.name;\r\n\t\t\t\t\t\tobjectResult.typeFile\t\t= value.type;\r\n\t\t\t\t\t\tobjectResult.idFile\t\t\t= value.idFile;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (value.data && value.data.state)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//objectResult.soustitre = 'à modifié la tache: ';\r\n\t\t\t\t\t\t\tobjectResult.soustitre = '';\r\n\t\t\t\t\t\t\tif (value.data.name)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tobjectResult.soustitre += value.data.name;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tswitch (value.data.state)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcase 'new':\r\n\t\t\t\t\t\t\t\t\tobjectResult.content = \"Etat : 'Non assignée'\";\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tcase 'todo':\r\n\t\t\t\t\t\t\t\t\tobjectResult.content = \"Etat : 'Assignée'\";\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tcase 'inprogress':\r\n\t\t\t\t\t\t\t\t\tobjectResult.content = \"Etat : 'En cours'\";\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tcase 'review':\r\n\t\t\t\t\t\t\t\t\tobjectResult.content = \"Etat : 'A valider'\";\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tcase 'done':\r\n\t\t\t\t\t\t\t\t\tobjectResult.content = \"Etat : 'Terminé'\";\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// objectResult.content = \"à mis une nouvelle version du fichier\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'create':\r\n\r\n\t\t\t\tobjectResult.type \t\t= 'create';\r\n\t\t\t\tobjectResult.typeName \t= 'Création';\r\n\t\t\t\tobjectResult.version \t= 1;\r\n\r\n\t\t\t\tif (value.path)\r\n\t\t\t\t{\r\n\t\t\t\t\tobjectResult.soustitrePath\t= 'A créé : ';\r\n\t\t\t\t\tobjectResult.path\t\t\t= value.path;\r\n\t\t\t\t\tobjectResult.nameFile\t\t= value.name;\r\n\t\t\t\t\tobjectResult.typeFile\t\t= value.type;\r\n\t\t\t\t\tobjectResult.idFile\t\t\t= value.idFile;\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tif (value.name)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobjectResult.soustitre = 'A créé : ' + value.name;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (value.what && value.id)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet name;\r\n\t\t\t\t\t\t\tswitch(value.what)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tcase 'etablissement':\r\n\t\t\t\t\t\t\t\t\tif (value.libelle)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tname = value.libelle;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlet etab \t= this.getEtablissement(value.id);\r\n\t\t\t\t\t\t\t\t\t\tname\t\t= etab ? etab.name : '';\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\tobjectResult.soustitre = 'A créé le classeur : ' + name;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\tcase 'session':\r\n\t\t\t\t\t\t\t\t\tif (value.libelle)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tname = value.libelle;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlet session = this.getSession(value.id);\r\n\t\t\t\t\t\t\t\t\t\tname \t\t= session ? session.name : '';\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\tobjectResult.soustitre = 'A créé la session : ' + name;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\tcase 'examen':\r\n\t\t\t\t\t\t\t\t\tif (value.libelle)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tname = value.libelle;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlet examen \t= this.getExamen(value.id);\r\n\t\t\t\t\t\t\t\t\t\tname \t\t= examen ? examen.name : '';\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\tobjectResult.soustitre = \"A créé l'examen : \" + name;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\tcase 'matiere':\r\n\t\t\t\t\t\t\t\t\tif (value.libelle)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tname = value.libelle;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlet matiere = this.getEpreuve(value.id);\r\n\t\t\t\t\t\t\t\t\t\tname \t\t= matiere ? matiere.name : '';\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\tobjectResult.soustitre = \"A créé l'épreuve : \" + name;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\tcase 'subjects':\r\n\t\t\t\t\t\t\t\t\tif (value.libelle)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tname = value.libelle;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlet sujet \t= this.getSujet(value.id);\r\n\t\t\t\t\t\t\t\t\t\tname \t\t= sujet ? sujet.name : '';\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\tobjectResult.soustitre = 'A créé le sujet : ' + name;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\tcase 'task':\r\n\t\t\t\t\t\t\t\t\tif (value.libelle)\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tname = value.libelle;\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tlet task \t= this.taskData.getTaskById(value.id);\r\n\t\t\t\t\t\t\t\t\t\tname \t\t= task ? task.name : '';\r\n\t\t\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\t\t\tobjectResult.soustitre = \"A créé l'étape : \" + name;\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tobjectResult = undefined;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\treturn objectResult;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Est call une fois que tt les datas sont là pour les merger\r\n\t */\r\n\tpublic processData()\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Là tu vas aller chercher tes infos du node pour les insérer dans l'objet Task\r\n\t\t// ---------------------------------------\r\n\t\tfor(let key in this._taskHomeMine)\r\n\t\t{\r\n\t\t\tif (this._taskHomeMine[key])\r\n\t\t\t{\r\n\t\t\t\tlet etablissement \t= this.getEtablissement(this._taskHomeMine[key].idEtablissement);\r\n\t\t\t\tlet session \t\t= this.getSession(this._taskHomeMine[key].idSession);\r\n\t\t\t\tlet examen \t\t\t= this.getExamen(this._taskHomeMine[key].idExamen);\r\n\t\t\t\tlet epreuve\t\t\t= this.getEpreuve(this._taskHomeMine[key].idEpreuve);\r\n\t\t\t\tlet sujet\t\t\t= this.getSujet(this._taskHomeMine[key].idSujet);\r\n\r\n\t\t\t\tthis._taskHomeMine[key].nameEtablissement \t= etablissement ? etablissement.name \t: '';\r\n\t\t\t\tthis._taskHomeMine[key].nameSession \t\t= session\t\t? session.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeMine[key].nameExamen \t\t\t= examen\t\t? examen.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeMine[key].nameEpreuve \t\t= epreuve\t\t? epreuve.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeMine[key].nameSujet \t\t\t= sujet\t\t\t? sujet.name \t\t\t: '';\r\n\r\n\t\t\t\tthis._taskHomeMineSave[key]\t\t\t\t\t= this._taskHomeMine[key];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor(let key in this._taskHomeAdmin)\r\n\t\t{\r\n\t\t\tif (this._taskHomeAdmin[key])\r\n\t\t\t{\r\n\t\t\t\tlet etablissement \t= this.getEtablissement(this._taskHomeAdmin[key].idEtablissement);\r\n\t\t\t\tlet session \t\t= this.getSession(this._taskHomeAdmin[key].idSession);\r\n\t\t\t\tlet examen \t\t\t= this.getExamen(this._taskHomeAdmin[key].idExamen);\r\n\t\t\t\tlet epreuve \t\t= this.getEpreuve(this._taskHomeAdmin[key].idEpreuve);\r\n\t\t\t\tlet sujet \t\t\t= this.getSujet(this._taskHomeAdmin[key].idSujet);\r\n\r\n\t\t\t\tthis._taskHomeAdmin[key].nameEtablissement \t= etablissement ? etablissement.name \t: '';\r\n\t\t\t\tthis._taskHomeAdmin[key].nameSession \t\t= session\t\t? session.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdmin[key].nameExamen \t\t= examen\t\t? examen.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdmin[key].nameEpreuve\t\t= epreuve\t\t? epreuve.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdmin[key].nameSujet\t\t\t= sujet\t\t\t? sujet.name \t\t\t: '';\r\n\r\n\t\t\t\tthis._taskHomeAdminSave[key] = this._taskHomeAdmin[key];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (let key in this._taskHomeAdminToValid)\r\n\t\t{\r\n\t\t\tif (this._taskHomeAdminToValid[key])\r\n\t\t\t{\r\n\t\t\t\tlet etablissement \t= this.getEtablissement(this._taskHomeAdminToValid[key].idEtablissement);\r\n\t\t\t\tlet session \t\t= this.getSession(this._taskHomeAdminToValid[key].idSession);\r\n\t\t\t\tlet examen \t\t\t= this.getExamen(this._taskHomeAdminToValid[key].idExamen);\r\n\t\t\t\tlet epreuve \t\t= this.getEpreuve(this._taskHomeAdminToValid[key].idEpreuve);\r\n\t\t\t\tlet sujet \t\t\t= this.getSujet(this._taskHomeAdminToValid[key].idSujet);\r\n\r\n\t\t\t\tthis._taskHomeAdminToValid[key].nameEtablissement \t= etablissement ? etablissement.name \t: '';\r\n\t\t\t\tthis._taskHomeAdminToValid[key].nameSession \t\t= session\t\t? session.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdminToValid[key].nameExamen\t\t\t= examen\t\t? examen.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdminToValid[key].nameEpreuve\t\t\t= epreuve\t\t? epreuve.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdminToValid[key].nameSujet\t\t\t= sujet\t\t\t? sujet.name \t\t\t: '';\r\n\r\n\t\t\t\tthis._taskHomeAdminToValidSave[key] = this._taskHomeAdminToValid[key];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tfor (let key in this._taskHomeAdminExpired)\r\n\t\t{\r\n\t\t\tif (this._taskHomeAdminExpired[key])\r\n\t\t\t{\r\n\t\t\t\tlet etablissement \t= this.getEtablissement(this._taskHomeAdminExpired[key].idEtablissement);\r\n\t\t\t\tlet session \t\t= this.getSession(this._taskHomeAdminExpired[key].idSession);\r\n\t\t\t\tlet examen \t\t\t= this.getExamen(this._taskHomeAdminExpired[key].idExamen);\r\n\t\t\t\tlet epreuve \t\t= this.getEpreuve(this._taskHomeAdminExpired[key].idEpreuve);\r\n\t\t\t\tlet sujet \t\t\t= this.getSujet(this._taskHomeAdminExpired[key].idSujet);\r\n\r\n\t\t\t\tthis._taskHomeAdminExpired[key].nameEtablissement \t= etablissement ? etablissement.name \t: '';\r\n\t\t\t\tthis._taskHomeAdminExpired[key].nameSession \t\t= session\t\t? session.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdminExpired[key].nameExamen \t\t\t= examen\t\t? examen.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdminExpired[key].nameEpreuve\t\t\t= epreuve\t\t? epreuve.name \t\t\t: '';\r\n\t\t\t\tthis._taskHomeAdminExpired[key].nameSujet\t\t\t= sujet\t\t\t? sujet.name \t\t\t: '';\r\n\r\n\t\t\t\tthis._taskHomeAdminExpiredSave[key]\t\t\t\t\t= this._taskHomeAdminExpired[key];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis._globalTask = [];\r\n\t\tthis._globalTask = this._globalTask.concat(this.taskHomeMine);\r\n\t\tthis._globalTask = this._globalTask.concat(this.taskHomeAdmin);\r\n\t\tthis._globalTask = this._globalTask.concat(this.taskHomeAdminExpired);\r\n\t}\r\n\r\n\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic logout()\r\n\t{\r\n\t\tthis._taskHomeAdmin\t\t\t= [];\r\n\t\tthis._taskHomeMine\t\t\t= [];\r\n\t\tthis._taskHomeAdminExpired\t= [];\r\n\t\tthis._taskHomeAdminToValid\t= [];\r\n\t\tthis.epreuveHomeAdmin\t\t= [];\r\n\t\tthis._globalTask\t\t\t= [];\r\n\t\tthis._etablissements\t\t= [];\r\n\t\tthis.selectedItems\t\t\t= [];\r\n\t\tthis._historicFromElement\t= {};\r\n\r\n\t\tthis.resetSelect();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param id\r\n\t */\r\n\tpublic getTaskName(id: any)\r\n\t{\r\n\t\tlet name = '';\r\n\r\n\t\tfor (let task of this._globalTask)\r\n\t\t{\r\n\t\t\tif (task.id === id)\r\n\t\t\t{\r\n\t\t\t\tswitch (task.type)\r\n\t\t\t\t{\r\n\t\t\t\t\tcase 'redaction':\r\n\t\t\t\t\t\tname = 'Rédaction';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'test':\r\n\t\t\t\t\t\tname = 'Test';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'miseEnPage':\r\n\t\t\t\t\t\tname = 'Mise en page';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase 'verification':\r\n\t\t\t\t\t\tname = 'Vérification finale';\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tdefault:\r\n\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn name;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param sujetId\r\n\t */\r\n\tpublic constructTreeBySubjectId(sujetId: any)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t//\r\n\t\t// ---------------------------------------\r\n\t\tlet tempEtab:\t\tEtablissement;\r\n\t\tlet tempSession:\tSession;\r\n\t\tlet tempExam:\t\tExamen;\r\n\t\tlet tempMatiere:\tMatiere;\r\n\t\tlet tree = [];\r\n\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\ttempEtab = this._etablissements[key];\r\n\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\ttempSession = session;\r\n\r\n\t\t\t\tfor (let exam of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\ttempExam = exam;\r\n\r\n\t\t\t\t\tfor (let matiere of exam.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempMatiere = matiere;\r\n\r\n\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (sujet.id === sujetId)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\ttree[0] = tempMatiere.id;\r\n\t\t\t\t\t\t\t\ttree[1] = tempExam.id;\r\n\t\t\t\t\t\t\t\ttree[2] = tempSession.id;\r\n\t\t\t\t\t\t\t\ttree[3] = tempEtab.id;\r\n\t\t\t\t\t\t\t\ttree[4] = sujet.id;\r\n\r\n\t\t\t\t\t\t\t\treturn tree;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param sujetId\r\n\t */\r\n\tpublic constructAutoTreeBySubjectId(sujetId: any)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t//\r\n\t\t// ---------------------------------------\r\n\t\tlet tempEtab:\t\tEtablissement;\r\n\t\tlet tempSession:\tSession;\r\n\t\tlet tempExam:\t\tExamen;\r\n\t\tlet tempMatiere:\tMatiere;\r\n\t\tlet tree = [];\r\n\r\n\t\tfor (let key in this._etablissements)\r\n\t\t{\r\n\t\t\ttempEtab = this._etablissements[key];\r\n\r\n\t\t\tfor (let session of this._etablissements[key].sessions)\r\n\t\t\t{\r\n\t\t\t\ttempSession = session;\r\n\r\n\t\t\t\tfor (let exam of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\ttempExam = exam;\r\n\r\n\t\t\t\t\tfor (let matiere of exam.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempMatiere = matiere;\r\n\r\n\t\t\t\t\t\tfor (let sujet of matiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (sujet.id === sujetId)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tthis.goToSubject\t\t\t= true;\r\n\t\t\t\t\t\t\t\tthis._selectedMatiere\t\t= tempMatiere;\r\n\t\t\t\t\t\t\t\tthis._selectedElement\t\t= tempMatiere;\r\n\t\t\t\t\t\t\t\tthis._selectedExamen\t\t= tempExam;\r\n\t\t\t\t\t\t\t\tthis._selectedSession\t\t= tempSession;\r\n\t\t\t\t\t\t\t\tthis._selectedEtablissement = tempEtab;\r\n\t\t\t\t\t\t\t\tthis._selectedSujet\t\t\t= sujet;\r\n\r\n\t\t\t\t\t\t\t\tthis.router.navigate(['/workspace']);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Vérifie si le nom est dispo avec un nom à check et un type\r\n\t */\r\n\tpublic isNameFree(psName: string, psType: any)\r\n\t{\r\n\t\tlet xReturn: any = null;\r\n\t\tlet indexFinal = false;\r\n\t\tif (psName)\r\n\t\t{\r\n\t\t\tpsName = psName.toLowerCase();\r\n\r\n\r\n\t\t\tswitch (psType)\r\n\t\t\t{\r\n\t\t\t\tcase 'etablissement':\r\n\r\n\t\t\t\t\tfor (let indice in this._etablissements)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (this._etablissements[indice])\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet nameToTest: string = this._etablissements[indice].name;\r\n\t\t\t\t\t\t\tif (nameToTest)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnameToTest = nameToTest.toLowerCase();\r\n\t\t\t\t\t\t\t\tif (nameToTest === psName)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tindexFinal = true;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\r\n\t\t\t\tcase 'session':\r\n\r\n\t\t\t\t\tif (this.selectedEtablissement)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let session of this.selectedEtablissement.sessions)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet nameToTest: string = session.name;\r\n\t\t\t\t\t\t\tif (nameToTest)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnameToTest = nameToTest.toLowerCase();\r\n\t\t\t\t\t\t\t\tif (nameToTest === psName)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tindexFinal = true;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'examen':\r\n\t\t\t\t\tif (this.selectedSession)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let examen of this.selectedSession.examens)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet nameToTest: string = examen.name;\r\n\t\t\t\t\t\t\tif (nameToTest)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnameToTest = nameToTest.toLowerCase();\r\n\t\t\t\t\t\t\t\tif (nameToTest === psName)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tindexFinal = true;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'matiere':\r\n\t\t\t\t\tif (this.selectedExamen)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let matiere of this.selectedExamen.matieres)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet nameToTest: string = matiere.name;\r\n\t\t\t\t\t\t\tif (nameToTest)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnameToTest = nameToTest.toLowerCase();\r\n\t\t\t\t\t\t\t\tif (nameToTest === psName)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tindexFinal = true;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'sujet':\r\n\t\t\t\t\tif (this.selectedMatiere)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let sujet of this.selectedMatiere.sujets)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet nameToTest: string = sujet.name;\r\n\t\t\t\t\t\t\tif (nameToTest)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnameToTest = nameToTest.toLowerCase();\r\n\t\t\t\t\t\t\t\tif (nameToTest === psName)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tindexFinal = true;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'pj':\r\n\t\t\t\t\tif (this.selectedSujet)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let pj of this.selectedSujet.pj)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet nameToTest: string = pj.name;\r\n\t\t\t\t\t\t\tif (nameToTest)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnameToTest = nameToTest.toLowerCase();\r\n\t\t\t\t\t\t\t\tif (nameToTest === psName)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tindexFinal = true;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\tif (indexFinal)\r\n\t\t\t{\r\n\t\t\t\txReturn = { invalid: true };\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn xReturn;\r\n\t}\r\n\r\n\r\n\t// ---------------------------------------------------------------------------------------------------------------------------------------------------------\r\n\t// Home\r\n\t// ---------------------------------------------------------------------------------------------------------------------------------------------------------\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param paArray\r\n\t * @param psId\r\n\t * @param psType\r\n\t */\r\n\tpublic findItem(paArray: any[], psId: string, psType ='etab')\r\n\t{\r\n\t\t// Partie à valider\r\n\t\tlet tempObj1 = [];\r\n\t\tlet paReturn = [];\r\n\t\tfor (let key in paArray)\r\n\t\t{\r\n\t\t\tswitch (psType)\r\n\t\t\t{\r\n\t\t\t\tcase 'etab':\r\n\t\t\t\t\tif (paArray[key].idEtablissement === psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'sess':\r\n\t\t\t\t\tif (paArray[key].idSession === psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'exam':\r\n\t\t\t\t\tif (paArray[key].idExamen === psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'matiere':\r\n\t\t\t\t\tif (paArray[key].idEpreuve === psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'suj':\r\n\t\t\t\t\tif (paArray[key].idSujet === psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\tpaReturn = tempObj1;\r\n\r\n\t\treturn paReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param paArray\r\n\t * @param psId\r\n\t * @param psType\r\n\t */\r\n\tpublic findItemEpreuve(paArray: any[], psId: string, psType ='etab')\r\n\t{\r\n\t\t// Partie à valider\r\n\t\tlet tempObj1 = [];\r\n\t\tlet paReturn = [];\r\n\r\n\r\n\t\tfor (let key in paArray)\r\n\t\t{\r\n\r\n\t\t\tswitch (psType)\r\n\t\t\t{\r\n\t\t\t\tcase 'etab':\r\n\t\t\t\t\tif (paArray[key].parents[0] === \"*etab::\"+psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'sess':\r\n\t\t\t\t\tif (paArray[key].parents[3] === \"*sess::\"+psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'exam':\r\n\t\t\t\t\tif (paArray[key].parents[1] === \"*exam::\"+psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'matiere':\r\n\t\t\t\t\tif (paArray[key].id === psId)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttempObj1.push(paArray[key]);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t\tpaReturn = tempObj1;\r\n\r\n\t\treturn paReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Trie des éléments sur la home\r\n\t */\r\n\tpublic filterHomeTasks(typeOfFilter: any, id: any = null)\r\n\t{\r\n\t\tlet resultDatasAdminToValid:\tany[] = [];\r\n\t\tlet resultDatasAdmin:\t\t\tany[] = [];\r\n\t\tlet resultDatasAdminExpired:\tany[] = [];\r\n\t\tlet resultDatasMine:\t\t\tany[] = [];\r\n\t\tlet resultDatasEpreuve:\t\t\tany[] = [];\r\n\r\n\t\tif (id)\r\n\t\t{\r\n\t\t\t// Raz des data, si on veut trier sur étab2 et que seulement les etab1 sont dispo ça va pas le faire\r\n\t\t\tresultDatasAdminToValid\t\t= this._taskHomeAdminToValidSave;\r\n\t\t\tresultDatasAdmin\t\t\t= this._taskHomeAdminSave;\r\n\t\t\tresultDatasAdminExpired\t\t= this._taskHomeAdminExpiredSave;\r\n\t\t\tresultDatasMine\t\t\t\t= this._taskHomeMineSave;\r\n\t\t\tresultDatasEpreuve\t\t\t= this._epreuveHomeAdminSave;\r\n\r\n\t\t\tswitch (typeOfFilter)\r\n\t\t\t{\r\n\t\t\t\tcase 'etab':\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdmin,\t\t\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tid, typeOfFilter);\r\n\r\n\t\t\t\t\tresultDatasEpreuve = this.findItemEpreuve(resultDatasEpreuve, id, typeOfFilter);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'sess':\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdmin,\t\t\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tid, typeOfFilter);\r\n\r\n\t\t\t\t\tresultDatasEpreuve = this.findItemEpreuve(resultDatasEpreuve, id, typeOfFilter);\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'exam':\r\n//\t\t\t\t\tresultDatasAdminToValid = _.filter(resultDatasAdminToValid, (step: any) => { return step.idExamen === id; });\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdmin,\t\t\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tid, typeOfFilter);\r\n\r\n\t\t\t\t\tresultDatasEpreuve = this.findItemEpreuve(resultDatasEpreuve, id, typeOfFilter);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'matiere':\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdminToValid,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tid, typeOfFilter);\r\n\r\n\t\t\t\t\tresultDatasEpreuve\t\t= this.findItemEpreuve(resultDatasEpreuve,\t\t\tid, typeOfFilter);\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase 'suj':\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdmin,\t\t\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tid, typeOfFilter);\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tid, typeOfFilter);\r\n\r\n\r\n\t\t\t\t\tlet sujet = this.getSujet(id);\r\n\t\t\t\t\tresultDatasEpreuve = this.findItemEpreuve(resultDatasEpreuve, sujet.idMatiere, 'matiere');\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tresultDatasAdminToValid = this._taskHomeAdminToValidSave;\r\n\t\t\t\t\tresultDatasAdmin\t\t= this._taskHomeAdminSave;\r\n\t\t\t\t\tresultDatasAdminExpired = this._taskHomeAdminExpiredSave;\r\n\t\t\t\t\tresultDatasMine\t\t\t= this._taskHomeMineSave;\r\n\t\t\t\t\tresultDatasEpreuve\t\t= this._epreuveHomeAdminSave;\r\n\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// Cas aucun => on filtre l'étape d'avant si elle est selectionnée\r\n\t\t\t// ---------------------------------------\r\n\t\t\tresultDatasAdminToValid\t\t= this._taskHomeAdminToValidSave;\r\n\t\t\tresultDatasAdmin\t\t\t= this._taskHomeAdminSave;\r\n\t\t\tresultDatasAdminExpired\t\t= this._taskHomeAdminExpiredSave;\r\n\t\t\tresultDatasMine\t\t\t\t= this._taskHomeMineSave;\r\n\t\t\tresultDatasEpreuve\t\t\t= this._epreuveHomeAdminSave;\r\n\r\n\t\t\tlet filterId: any;\r\n\r\n\t\t\tswitch (typeOfFilter)\r\n\t\t\t{\r\n\t\t\t\tcase 'etab':\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'sess':\r\n\t\t\t\t\tfilterId = this.selectedHomeEtablissement.id;\r\n\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tfilterId, 'etab');\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdmin,\t\t\tfilterId, 'etab');\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tfilterId, 'etab');\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tfilterId, 'etab');\r\n\r\n\t\t\t\t\tresultDatasEpreuve = this.findItemEpreuve(resultDatasEpreuve, filterId, 'etab');\r\n\t\t\t\tbreak;\r\n\r\n\r\n\t\t\t\tcase 'exam':\r\n\t\t\t\t\tfilterId = this.selectedHomeSession.id;\r\n\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tfilterId, 'sess');\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdmin,\t\t\tfilterId, 'sess');\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tfilterId, 'sess');\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tfilterId, 'sess');\r\n\r\n\t\t\t\t\tresultDatasEpreuve = this.findItemEpreuve(resultDatasEpreuve, filterId, 'sess');\r\n\t\t\t\tbreak;\r\n\r\n\r\n\t\t\t\tcase 'matiere':\r\n\t\t\t\t\tfilterId = this.selectedHomeExamen.id;\r\n\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tfilterId, 'exam');\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdmin,\t\t\tfilterId, 'exam');\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tfilterId, 'exam');\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tfilterId, 'exam');\r\n\r\n\t\t\t\t\tresultDatasEpreuve = this.findItemEpreuve(resultDatasEpreuve, filterId, 'exam');\r\n\t\t\t\tbreak;\r\n\r\n\r\n\t\t\t\tcase 'suj':\r\n\t\t\t\t\tfilterId = this.selectedHomeMatiere.id;\r\n\r\n\t\t\t\t\tresultDatasAdminToValid = this.findItem(resultDatasAdminToValid,\tfilterId, 'matiere');\r\n\t\t\t\t\tresultDatasAdmin\t\t= this.findItem(resultDatasAdmin,\t\t\tfilterId, 'matiere');\r\n\t\t\t\t\tresultDatasAdminExpired = this.findItem(resultDatasAdminExpired,\tfilterId, 'matiere');\r\n\t\t\t\t\tresultDatasMine\t\t\t= this.findItem(resultDatasMine,\t\t\tfilterId, 'matiere');\r\n\r\n\t\t\t\t\tresultDatasEpreuve = this.findItemEpreuve(resultDatasEpreuve, filterId, 'matiere');\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tthis._taskHomeAdminToValid\t= resultDatasAdminToValid;\r\n\t\tthis._taskHomeAdmin\t\t\t= resultDatasAdmin;\r\n\t\tthis._taskHomeAdminExpired\t= resultDatasAdminExpired;\r\n\t\tthis._taskHomeMine\t\t\t= resultDatasMine;\r\n\t\tthis._epreuveHomeAdmin\t\t= resultDatasEpreuve;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedHomeEtablissement(): Etablissement\r\n\t{\r\n\t\tlet oReturn = this._selectedHomeEtablissement;\r\n\t\tif (this._selectedHomeEtablissement === null)\r\n\t\t{\r\n\t\t\tlet etablissementId\t\t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedHomeEtablissementId');\r\n\t\t\toReturn\t\t\t\t\t\t\t= this.getEtablissement(etablissementId);\r\n\t\t\tthis._selectedHomeEtablissement = oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedHomeSession():\t\t\tSession\r\n\t{\r\n\t\tlet oReturn = this._selectedHomeSession;\r\n\r\n\t\tif (this._selectedHomeSession === null)\r\n\t\t{\r\n\t\t\tlet sessionId\t\t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedHomeSessionId');\r\n\t\t\toReturn\t\t\t\t\t\t= this.getSession(sessionId);\r\n\t\t\tthis._selectedHomeSession\t= oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedHomeExamen():\t\t\tExamen\r\n\t{\r\n\t\tlet oReturn = this._selectedHomeExamen;\r\n\r\n\t\tif (this._selectedHomeExamen === null)\r\n\t\t{\r\n\t\t\tlet examenId\t\t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedHomeExamenId');\r\n\t\t\toReturn\t\t\t\t\t\t= this.getExamen(examenId);\r\n\t\t\tthis._selectedHomeExamen\t= oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedHomeMatiere():\t\t\tMatiere\r\n\t{\r\n\t\tlet oReturn = this._selectedHomeMatiere;\r\n\r\n\t\tif (this._selectedHomeMatiere === null)\r\n\t\t{\r\n\t\t\tlet matiereId\t\t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedHomeMatiereId');\r\n\t\t\toReturn\t\t\t\t\t\t= this.getEpreuve(matiereId);\r\n\t\t\tthis._selectedHomeMatiere\t= oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tget selectedHomeSujet():\t\t\tSujet\r\n\t{\r\n\t\tlet oReturn = this._selectedHomeSujet;\r\n\t\tif (this._selectedHomeSujet === null)\r\n\t\t{\r\n\t\t\tlet subjectId\t\t\t= this.getStorage(this.userData.mail + '::' + this.userData.account + '::selectedHomeSubjectId');\r\n\t\t\toReturn\t\t\t\t\t= this.getSujet(subjectId);\r\n\t\t\tthis._selectedHomeSujet = oReturn;\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tset selectedHomeEtablissement(selectedEtablissement)\r\n\t{\r\n\t\tif (selectedEtablissement)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeEtablissementId', selectedEtablissement.id);\r\n\t\t}\r\n\t\tthis._selectedHomeEtablissement\t= selectedEtablissement;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tset selectedHomeSession(selectedSession)\r\n\t{\r\n\t\tif (selectedSession)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeSessionId', selectedSession.id);\r\n\t\t}\r\n\t\tthis._selectedHomeSession = selectedSession;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tset selectedHomeExamen(selectedExamen)\r\n\t{\r\n\t\tif (selectedExamen)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeExamenId', selectedExamen.id);\r\n\t\t}\r\n\t\tthis._selectedHomeExamen = selectedExamen;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tset selectedHomeMatiere(selectedMatiere)\r\n\t{\r\n\t\tif (selectedMatiere)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeMatiereId', selectedMatiere.id);\r\n\t\t}\r\n\t\tthis._selectedHomeMatiere = selectedMatiere;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tset selectedHomeSujet(selectedSujet)\r\n\t{\r\n\t\tif (selectedSujet)\r\n\t\t{\r\n\t\t\tlocalStorage.setItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeSubjectId', selectedSujet.id);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeSubjectId');\r\n\t\t}\r\n\t\tthis._selectedHomeSujet\t= selectedSujet;\r\n\t}\r\n\r\n\r\n\tresetSelectedHomeEtablissement()\r\n\t{\r\n\t\tthis._selectedHomeEtablissement = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeEtablissementId');\r\n\t}\r\n\r\n\r\n\tresetSelectedHomeSession()\r\n\t{\r\n\t\tthis._selectedHomeSession = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeSessionId');\r\n\t}\r\n\r\n\r\n\tresetSelectedHomeExamen()\r\n\t{\r\n\t\tthis._selectedHomeExamen = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeExamenId');\r\n\t}\r\n\r\n\r\n\tresetSelectedHomeMatiere()\r\n\t{\r\n\t\tthis._selectedHomeMatiere = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeMatiereId');\r\n\t}\r\n\r\n\r\n\tresetSelectedHomeSujet()\r\n\t{\r\n\t\tthis._selectedHomeSujet = null;\r\n\t\tlocalStorage.removeItem(this.userData.mail + '::' + this.userData.account + '::selectedHomeSubjectId');\r\n\t}\r\n\r\n\r\n\tget epreuveHomeAdmin()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._epreuveHomeAdmin)\r\n\t\t{\r\n\t\t\t// On retourne sous cette forme pour que ça soit plus simple de parser coté html\r\n\t\t\toReturn.push(this._epreuveHomeAdmin[key]);\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tget taskHomeAdmin()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._taskHomeAdmin)\r\n\t\t{\r\n\t\t\toReturn.push(this._taskHomeAdmin[key]);\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tget taskHomeAdminToValid()\r\n\t{\r\n\t\treturn this._taskHomeAdminToValid;\r\n\t}\r\n\r\n\r\n\tgeTaskHomeAdminToValid()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._taskHomeAdminToValid)\r\n\t\t{\r\n\t\t\toReturn.push(this._taskHomeAdminToValid[key]);\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tgetTaskHomeMine()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._taskHomeMine)\r\n\t\t{\r\n\t\t\tif (this._taskHomeMine[key].name)\r\n\t\t\t{\r\n\t\t\t\toReturn.push(this._taskHomeMine[key]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tgetTaskHomeAdminExpired()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._taskHomeAdminExpired)\r\n\t\t{\r\n\t\t\t// On retourne sous cette forme pour que ça soit plus simple de parser coté html\r\n\t\t\toReturn.push(this._taskHomeAdminExpired[key]);\r\n\t\t}\r\n\r\n\r\n\t\treturn oReturn;\r\n\t}\r\n\r\n\r\n\tgetTaskHomeMineLength()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._taskHomeMine)\r\n\t\t{\r\n\t\t\tif (this._taskHomeMine[key].name)\r\n\t\t\t{\r\n\t\t\t\toReturn.push(this._taskHomeMine[key]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn oReturn.length;\r\n\t}\r\n\r\n\tgetTaskHomeExpiredLength()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._taskHomeAdminExpired)\r\n\t\t{\r\n\t\t\toReturn.push(this._taskHomeAdminExpired[key]);\r\n\t\t}\r\n\r\n\t\treturn oReturn.length;\r\n\t}\r\n\r\n\r\n\tgeTaskHomeAdminToValidLenght()\r\n\t{\r\n\t\tlet oReturn = [];\r\n\t\tfor (let key in this._taskHomeAdminToValid)\r\n\t\t{\r\n\t\t\toReturn.push(this._taskHomeAdminToValid[key]);\r\n\t\t}\r\n\r\n\t\treturn oReturn.length;\r\n\t}\r\n\r\n\r\n\tget taskHomeAdminExpired()\r\n\t{\r\n\t\treturn this._taskHomeAdminExpired;\r\n\t}\r\n\r\n\r\n\tget taskHomeMine()\r\n\t{\r\n\t\treturn this._taskHomeMine;\r\n\t}\r\n\r\n\r\n\tpublic deleteTaskNodeById(psId: string)\r\n\t{\r\n\r\n\t\tfor (let etablissement of this.etablissements)\r\n\t\t{\r\n\t\t\tfor (let session of etablissement.sessions)\r\n\t\t\t{\r\n\t\t\t\tfor (let examen of session.examens)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let matiere of examen.matieres)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (matiere.tasks)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet nIndice \t= 0;\r\n\t\t\t\t\t\t\tlet arrayTask \t= [];\r\n\r\n\t\t\t\t\t\t\tfor (let task of matiere.tasks)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// On a la meme id de tache mais pas pour la meme personne, on l'enlève donc\r\n\t\t\t\t\t\t\t\tif (psId !== task.id)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tarrayTask.push(task);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tnIndice++;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tmatiere.tasks = arrayTask;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic deleteStatsNodeByIndice(pnIndice: number)\r\n\t{\r\n\r\n\t\tthis.statsNode2 = undefined;\r\n\r\n\t}\r\n}\r\n","// Angular\r\nimport { Injectable }\tfrom '@angular/core';\r\nimport { Http }\t\t\tfrom '@angular/http';\r\nimport {Observable} from 'rxjs/Rx';\r\n// Other\r\nimport { UserData }\t\tfrom './user-data';\r\nimport { EtablissementService } from '../services/etablissement.service';\r\nimport { SujetService } from '../services/sujet.service';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * Manage the datas for the workspace component\r\n */\r\nexport class WorkspaceDataService\r\n{\r\n\t_data: any;\r\n _dataReturn: any;\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(public http: Http, public user: UserData,\r\n\t\t\t\tpublic etablissementService: EtablissementService,\r\n\t\t\t\tpublic sujetService: SujetService)\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\tpublic get data()\r\n\t{\r\n\t\treturn this._dataReturn;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n processSujet(data: any = null, sujet: any = null)\r\n {\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n filterSujet(sujet: any, queryWords: any, excludeTracks: any, segment: any)\r\n {\r\n\r\n }\r\n\r\n}","import { Injectable }\t\tfrom '@angular/core';\r\nimport { SocketService } from './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } from '../providers/user-data';\r\n\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\n\r\n@Injectable()\r\nexport class AdminService\r\n{\r\n\r\n constructor(private socketService: SocketService,\r\n private userData: UserData)\r\n {\r\n\r\n }\r\n\r\n /**\r\n * Récupération de l'ensemble des paramètres d'administration\r\n */\r\n public getAllAdminParameters()\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'adminParameters',\r\n\t\t\t\t\t'args': {}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n }\r\n\r\n /**\r\n * Mise à jour des paramètres principaux dans l'interface d'administration\r\n * @param datasParameters\r\n */\r\n public updateAdminParameters(datasParameters: any)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'adminParameters',\r\n\t\t\t\t\t'args': {\r\n\t\t\t\t\t\t'datas': datasParameters\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Mise à jour des midèles de mails dans l'administration\r\n\t */\r\n\tpublic updateAdminMailsTemplates(mailsTemplates: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'adminMailsTemplates',\r\n\t\t\t\t\t'args': {\r\n\t\t\t\t\t\t'datas': mailsTemplates\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic deleteScenario(idScenario: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'deleteScenario',\r\n\t\t\t\t\t'args': {\r\n\t\t\t\t\t\t'idScenario': idScenario\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('delete', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n}\r\n","import { Injectable }\t\tfrom '@angular/core';\r\nimport { AuthHttpService }\tfrom './http/authHttp.service';\r\nimport { SocketService }\tfrom './socket.service';\r\nimport { UserData }\t\t\tfrom '../providers/user-data';\r\n\r\nimport { SCClientSocket, SCChannel } from 'socketcluster-client';\r\n\r\nimport {Observable} from 'rxjs/Rx';\r\nimport { ChatService } from './chat.service';\r\n\r\n//declare var SCSocket: any;\r\n@Injectable()\r\n\r\n//\r\n/**\r\n *\r\n */\r\nexport class AuthService\r\n{\r\n\r\n\tprivate static autoRefreshInterval: any = undefined;\r\n\tprivate static nextPing\t\t\t\t\t= 0;\r\n\tprivate static pingInterval\t\t\t\t= 0;\r\n\tprivate static currentSocket: \t\tany;\r\n\tprivate static roomsAvailable: \t\tany;\r\n\r\n\tprivate static mainRooms = \r\n\t[\r\n\t\t'*user::mailuser',\r\n\t\t'*soft::all::creation'\r\n\t];\r\n\r\n\tpublic userToken: string;\r\n\tpublic currentUser: any;\r\n\r\n\t/**\r\n\t * Arret du service de gestion des rooms\r\n\t * Cette fonction est appelé lorsqu'on se déconnecte de l'application\r\n\t */\r\n\tpublic static stopGestionRooms()\r\n\t{\r\n\t\tif (AuthService.autoRefreshInterval)\r\n\t\t{\r\n\t\t\tclearInterval(AuthService.autoRefreshInterval);\r\n\t\t\tAuthService.autoRefreshInterval = undefined;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(private authHttpService: \tAuthHttpService,\r\n\t\t\t\tprivate userData: \t\t\tUserData,\r\n\t\t\t\tprivate socketService: \t\tSocketService\r\n\t)\r\n\t{\r\n\r\n\t}\r\n\r\n\t/**\r\n\t * Get un socket et verifie si le token est valide (par http si besoin)\r\n\t */\r\n\tpublic checkTokenWsHttp(): Observable\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tif (!AuthService.autoRefreshInterval)\r\n\t\t{\r\n\t\t\tAuthService.autoRefreshInterval = setInterval(() => { this.gestionSockets(); }, 200);\r\n\t\t}\r\n\r\n\t\tlet observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\t// get du socket\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t\t{\r\n\t\t\t\tAuthService.currentSocket = socket;\r\n\r\n\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\t// ToComment\r\n\t\t\t\t// ---------------------------------------\r\n\t\t\t\tif (!this.isCurrentSocketValid())\r\n\t\t\t\t{\r\n\t\t\t\t\tlet token = this.userData.getTokenKey();\r\n\t\t\t\t\t//si token\r\n\t\t\t\t\tif (token)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet base64js = this.getTokenJSON(token);\r\n\r\n\t\t\t\t\t\tif (base64js && base64js.exp)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//token expiré\r\n\t\t\t\t\t\t\tif (base64js.exp < Date.now())\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tobserver.next(false);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t// on le checke en htttp\r\n\t\t\t\t\t\tthis.refreshToken(token).subscribe(res =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet body = JSON.parse(res.text());\r\n\t\t\t\t\t\t\tif (body.err === false && body.data && body.data.token)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\tthis.userData.setTokenKey(body.data.token);\r\n\t\t\t\t\t\t\t\t// je peux ajouter mes canaux utilisateurs si pas déjà fait\r\n\t\t\t\t\t\t\t\tthis.addRoomForToken(this.getTokenJSON(token));\r\n\t\t\t\t\t\t\t\tobserver.next(true);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t\t\tobserver.next(false);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\t// ToComment\r\n\t\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t\tobserver.next(false);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t// ToComment\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\tif (socket.authState === SCClientSocket.AUTHENTICATED)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// je peux ajouter mes canaux utilisateurs si pas déjà fait depuis authToken du socket\r\n\t\t\t\t\t\tif (this.socketService.roomsAGerer)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.addRoomForToken(socket.authToken);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tobserver.next(true);\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobserver.next(false);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\tprivate addRoomForToken(tokenJS: any)\r\n\t{\r\n\t\tif (tokenJS)\r\n\t\t{\r\n\t\t\tif (this.socketService.roomsAGerer)\r\n\t\t\t{\r\n\t\t\t\t// Canal spécifique à l'user (multimachine)\r\n\t\t\t\tif (tokenJS.idUser)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet room = '*user::' + tokenJS.idUser;\r\n\t\t\t\t\tlet value = this.socketService.findRoomAGerer(room);\r\n\t\t\t\t\tif (value < 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.socketService.roomsAGerer.push({ name: room, state: 'nosub', watch: true, fct: this.socketService.watchUser.bind(this.socketService), channel: undefined })\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t\t// Canal pour la machine\r\n\t\t\t\tif (tokenJS.fp)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet room = '*machine::' + tokenJS.fp;\r\n\t\t\t\t\tlet value = this.socketService.findRoomAGerer(room);\r\n\t\t\t\t\tif (value < 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.socketService.roomsAGerer.push({ name: room, state: 'nosub', watch: true, fct: this.socketService.watchMachine.bind(this.socketService), channel: undefined })\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t\t// Canal pour le compte + soft/compte\r\n\t\t\t\tif (tokenJS.acc)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet room = '*cpt::' + tokenJS.acc;\r\n\t\t\t\t\tlet value = this.socketService.findRoomAGerer(room);\r\n\t\t\t\t\tif (value < 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.socketService.roomsAGerer.push({ name: room, state: 'nosub', watch: true, fct: this.socketService.watchAccount.bind(this.socketService), channel: undefined })\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (tokenJS.idUser)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet room2 = '*soft::' + tokenJS.acc + '::creation';\r\n\t\t\t\t\t\tvalue = this.socketService.findRoomAGerer(room2);\r\n\t\t\t\t\t\tif (value < 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.socketService.roomsAGerer.push({ name: room2, state: 'nosub', watch: true, fct: this.socketService.watchAccountUpdates.bind(this.socketService), channel: undefined })\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tprivate getTokenJSON(token: any): any\r\n\t{\r\n\t\tif (token)\r\n\t\t{\r\n\t\t\t//decodage token\r\n\t\t\tlet splitToken: string[] = token.split('.');\r\n\t\t\tif (splitToken.length > 2)\r\n\t\t\t{\r\n\t\t\t\treturn JSON.parse(window.atob(splitToken[1]));\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn undefined;\r\n\t}\r\n\r\n\t/**\r\n\t *\r\n\r\n\t */\r\n\tpublic doLogin(username: any, password: any, fingerprint: any = '')\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\treturn this.authHttpService.doLogin(username, password, fingerprint).share();\r\n\t}\r\n\r\n\t/**\r\n\t *\r\n\t * @param token\r\n\t */\r\n\tpublic refreshToken(token: any)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\treturn this.authHttpService.refreshToken(token).share();\r\n\t}\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic doLoginWithToken(token: any)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\treturn this.authHttpService.doLoginWithToken(token).share();\r\n\t}\r\n\r\n\t/**\r\n\t * Check if current socket is in a valid state\r\n\t * SI c'est IS => ça retourne true ou false, là c'est un get\r\n\t */\r\n\tprivate isCurrentSocketValid()\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\treturn AuthService.currentSocket && AuthService.currentSocket.state && AuthService.currentSocket.state === SCClientSocket.OPEN;\r\n\t}\r\n\r\n\r\n\tprivate isCurrentSocketAuth()\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\treturn AuthService.currentSocket && AuthService.currentSocket.authState && AuthService.currentSocket.authState == SCClientSocket.AUTHENTICATED;\r\n\t}\r\n\r\n\tprivate ping(token: any)\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tthis.refreshToken(token).subscribe(res =>\r\n\t\t{\r\n\t\t\tlet body = JSON.parse(res.text());\r\n\t\t\tif (body.err === false && body.data && body.data.token)\r\n\t\t\t{\r\n\t\t\t\tthis.userData.setTokenKey(body.data.token);\r\n\t\t\t\tAuthService.nextPing = Date.now() + AuthService.pingInterval;;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tAuthService.nextPing = 0;\r\n\t\t\t\tthis.userData.delTokenKey();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Intervalle pour vérifier les connexions et les relancer si elles sont tombées\r\n\t */\r\n\tprivate gestionSockets()\r\n\t{\r\n\t\t//si connection socket valide\r\n\t\tif (!this.isCurrentSocketValid())\r\n\t\t{\r\n\t\t\t//sinon on verifie si on a un token et la variable nextping\r\n\t\t\tlet token = this.userData.getTokenKey();\r\n\r\n\t\t\tif (token)\r\n\t\t\t{\r\n\t\t\t\t//si nextping =0, on lui affecte now+ 20 *1000\r\n\t\t\t\tif (AuthService.nextPing === 0)\r\n\t\t\t\t{\r\n\t\t\t\t\t//decodage token\r\n\t\t\t\t\tlet splitToken: string[] = token.split('.');\r\n\t\t\t\t\tif (splitToken.length > 2)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet base64js = JSON.parse(window.atob(splitToken[1]));\r\n\r\n\t\t\t\t\t\tif (base64js.iat && base64js.exp)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//si token deja expiré on le supprime\r\n\t\t\t\t\t\t\tif (base64js.exp < (Date.now() / 1000))\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tthis.userData.delTokenKey();\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlet msec = (base64js.exp - base64js.iat) / 0.003;\r\n\t\t\t\t\t\t\t\t//calcul du prochain ping\r\n\t\t\t\t\t\t\t\tif (msec < 5000)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tAuthService.pingInterval = 5 * 1000;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tAuthService.pingInterval = msec;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tAuthService.nextPing = Date.now() + AuthService.pingInterval;\r\n\t\t\t\t\t\t\t\tlet mSec = base64js.exp * 1000;\r\n\t\t\t\t\t\t\t\t// si deja (presque) expiré\r\n\t\t\t\t\t\t\t\tif (AuthService.nextPing > mSec)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tAuthService.nextPing = mSec;\r\n\t\t\t\t\t\t\t\t\tthis.ping(token);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tAuthService.nextPing = Date.now() + (20 * 1000);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tAuthService.nextPing = Date.now() + (20 * 1000);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t//si now > nextping, on reaffecte nextping + appel refresh (ping)\r\n\t\t\t\t\tif (AuthService.nextPing < Date.now())\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tAuthService.nextPing = Date.now() + (5 * 1000);\r\n\t\t\t\t\t\tthis.ping(token);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t\treturn;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t//Soket valide\r\n\t\t\tif(this.isCurrentSocketAuth())\r\n\t\t\t{\r\n\t\t\t\tthis.socketService.GererRoom();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { SocketService } from './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } \t\t\t\tfrom '../providers/user-data';\r\n\r\n@Injectable()\r\n\r\n/**\r\n *\r\n */\r\nexport class BaremeService\r\n{\r\n constructor(private socketService: SocketService,\r\n private userData: UserData)\r\n {\r\n\r\n }\r\n\r\n\r\n public createBareme(pjDatas: any)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'bareme',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdatas:\t\t\tpjDatas\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic getBaremes()\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'allBaremes',\r\n\t\t\t\t\t'args': { }\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n }\r\n\r\n\r\n\r\n\t/**\r\n\t * Update epreuve in database from Matiere object given in parameter\r\n\t * @param dataEpreuve\r\n\t */\r\n\tpublic editBareme(psId: string, dataEpreuve: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'bareme',\r\n\t\t\t\t\t'args': {\r\n\t\t\t\t\t\tdatasToUpdate: {\r\n\t\t\t\t\t\t\tdatas: dataEpreuve\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\tbaremeId: psId\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\r\n\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n//\t/**\r\n//\t * Update epreuve in database from Matiere object given in parameter\r\n//\t * @param dataEpreuve\r\n//\t */\r\n//\tpublic associateBareme(psBaremeId: string, psEpreuveId: string, psActivePart: string, psActiveQuestion: string, psSubjectType: string)\r\n//\t{\r\n//\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n//\t\t{\r\n//\t\t\tif (socket)\r\n//\t\t\t{\r\n//\t\t\t\tlet data: ISocketData =\r\n//\t\t\t\t\t{\r\n//\t\t\t\t\t\t'iam': 'c-c',\r\n//\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n//\t\t\t\t\t\t'what': SocketWhat.info,\r\n//\t\t\t\t\t\t'cmd': 'baremeToQuestion',\r\n//\t\t\t\t\t\t'args':\r\n//\t\t\t\t\t\t{\r\n//\t\t\t\t\t\t\tdatasToUpdate:\r\n//\t\t\t\t\t\t\t{\r\n//\t\t\t\t\t\t\t\tepreuveId:\t\tpsEpreuveId,\r\n//\t\t\t\t\t\t\t\tactivePart:\t\tpsActivePart,\r\n//\t\t\t\t\t\t\t\tactiveQuestion: psActiveQuestion,\r\n//\t\t\t\t\t\t\t\tsubjectType: psSubjectType,\r\n//\t\t\t\t\t\t\t},\r\n//\t\t\t\t\t\t\tbaremeId: psBaremeId\r\n//\t\t\t\t\t\t}\r\n//\t\t\t\t\t};\r\n//\t\t\t\tsocket.emit('create', data);\r\n//\t\t\t}\r\n//\t\t});\r\n//\t}\r\n\r\n}\r\n\r\n","\r\nimport { Injectable } \t\t\t\tfrom '@angular/core';\r\nimport { SocketService } \t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } \t\t\t\tfrom '../providers/user-data';\r\n\r\n@Injectable()\r\n/**\r\n *\r\n */\r\nexport class CandidatService\r\n{\r\n constructor(private socketService: \tSocketService,\r\n private userData: \t\tUserData)\r\n {\r\n\r\n }\r\n\r\n\r\n public createCandidats(datas: any)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'candidats',\r\n\t\t\t\t\t'args': datas\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\t\r\n\r\n public getCandidatsByParent(idParent: any)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'candidatByParent',\r\n\t\t\t\t\t'args': { idParent: idParent }\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n }\r\n}\r\n\r\n","// Angular\r\nimport { Injectable } \t\t\t\tfrom '@angular/core';\r\nimport {Observable} \t\t\t\tfrom 'rxjs/Rx';\r\nimport { SocketService } \t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat } \tfrom '../models/message.model';\r\n\r\nimport { File as FileItem } from '../classes/file.class';\r\nimport { Sujet } \t\t\tfrom '../classes/sujet.class';\r\n\r\nimport { WorkspaceData } \tfrom '../providers/workspace-data';\r\nimport { UserData } \t\tfrom '../providers/user-data';\r\ndeclare var require: any;\r\n\r\nlet fileSaver = require('file-saver');\r\n\r\nimport { Buffer } \tfrom 'buffer';\r\nimport * as _ \t\tfrom 'underscore';\r\n\r\n@Injectable()\r\nexport class EncryptService\r\n{\r\n\tconstructor(private userData: \tUserData,\r\n\t\tprivate workspaceData:\t\tWorkspaceData,\r\n\t\tprivate socketService: \t\tSocketService)\r\n\t{\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Encryptage des clés AES associées à un ou plusieurs fichiers donnés avec la clé publique d'un utilisateur\r\n\t * donné en paramètre. Envoie de la clé AES encodée au serveur pour enregistrement en base de données\r\n\t * @param files\r\n\t * @param userId\r\n\t */\r\n\tpublic encryptFilesForUSer(files: any[], userId: string, currentSubject: Sujet)\r\n\t{\r\n\t\tconst user = this.userData.getUser(userId);\r\n\r\n\t\t//On vérifie que l'on possède bien la clé RSA publique de l'utilisateur concerné\r\n\t\tif (user && user.publics && user.publics.rsaPublicKey && user.publics.rsaPublicKey !== '')\r\n\t\t{\r\n\t\t\tconst userRsaPublicKey = user.publics.rsaPublicKey;\r\n\r\n\t\t\tif (currentSubject)\r\n\t\t\t{\r\n\t\t\t\tconst filesObj = _.filter(currentSubject.pj, (pj: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn _.contains(files, pj.id);\r\n\t\t\t\t});\r\n\t\t\t\t//Pour chaque fichier dont on souhaite transmettre les droits, on vérifie que l'on possède\r\n\t\t\t\t//la clé AES et on l'envoie au serveur afin que cette clé soit associée au client\r\n\r\n\t\t\t\tfor (const fileToSend of filesObj)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (fileToSend.encryptedAesKeys && fileToSend.encryptedAesKeys.length > 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tconst aesKeyEncoded = fileToSend.encryptedAesKeys[0];\r\n\r\n\t\t\t\t\t\tif (aesKeyEncoded.val && aesKeyEncoded.val !== '' && aesKeyEncoded.version_min)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t//On décrypte la clé AES avec la clé privée de l'utilisateur courant\r\n\t\t\t\t\t\t\tthis.decryptData(aesKeyEncoded.val).then((aesDecoded: any) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t//On encrypte la clé AES décryptée avec la clé publique de l'utilisateur affecté\r\n\t\t\t\t\t\t\t\tthis.encryptData(aesDecoded, userRsaPublicKey).then((encryptedAes: any) =>\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tthis.sendAesKey(userId, fileToSend.id, encryptedAes, aesKeyEncoded.version_min);\r\n\r\n\t\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t}).catch(error =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t} \r\n\r\n\r\n\t/**\r\n\t * Génération d'une clé RSA publique et d'une clé RSA privée associée\r\n\t */\r\n\tpublic generateRsaKeyPair(): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tlet subtle = this._getSubtleCryptoInstance();\r\n\r\n\t\t\tif (subtle)\r\n\t\t\t{\r\n\t\t\t\tsubtle.generateKey({\r\n\t\t\t\t\tname: \t\t\t\t\"RSA-OAEP\",\r\n\t\t\t\t\tmodulusLength: \t\t4096,\r\n\t\t\t\t\tpublicExponent: \tnew Uint8Array([0x01, 0x00, 0x01]),\r\n\t\t\t\t\thash: \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tname: \"SHA-1\"\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t\t\ttrue,\r\n\t\t\t\t\t[\"encrypt\", \"decrypt\"]\r\n\t\t\t\t).then((key: any) =>\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tlet promises: PromiseLike[] = [];\r\n\t\t\t\t\tpromises.push(subtle.exportKey('spki', key.publicKey));\r\n\t\t\t\t\tpromises.push(subtle.exportKey('pkcs8', key.privateKey));\r\n\r\n\t\t\t\t\tPromise.all(promises).then(rsaResult =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (rsaResult && rsaResult.length === 2)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet publicKeyBuffer\t\t= rsaResult[0];\r\n\t\t\t\t\t\t\tlet privateKeyBuffer\t= rsaResult[1];\r\n\r\n\t\t\t\t\t\t\tlet result: any =\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tpublicKey:\tthis.convertBinaryToPem(publicKeyBuffer, \t'PUBLIC KEY'),\r\n\t\t\t\t\t\t\t\t\tprivateKey: this.convertBinaryToPem(privateKeyBuffer, \t'RSA PRIVATE KEY')\r\n\t\t\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\t\tresolve(result);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treject(null);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treject(null);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Formatage d'une clé RSA\r\n\t * @param binaryData\r\n\t * @param label\r\n\t */\r\n\tpublic convertBinaryToPem(binaryData: any, label: any)\r\n\t{\r\n\r\n\t\tlet base64Cert \t= this.arrayBufferToBase64String(binaryData);\r\n\t\tlet pemCert \t= \"-----BEGIN \" + label + \"-----\\r\\n\";\r\n\t\tlet nextIndex \t= 0;\r\n\r\n\t\tlet lineLength;\r\n\r\n\t\twhile (nextIndex < base64Cert.length)\r\n\t\t{\r\n\t\t\tif (nextIndex + 64 <= base64Cert.length)\r\n\t\t\t{\r\n\t\t\t\tpemCert += base64Cert.substr(nextIndex, 64) + \"\\r\\n\";\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tpemCert += base64Cert.substr(nextIndex) + \"\\r\\n\";\r\n\t\t\t}\r\n\t\t\tnextIndex += 64;\r\n\t\t}\r\n\t\tpemCert += \"-----END \" + label + \"-----\\r\\n\";\r\n\t\treturn pemCert;\r\n\t};\r\n\r\n\r\n\t/**\r\n\t * Conversion d'un ArrayBuffer vers une chaine encodée en base64\r\n\t * @param arrayBuffer\r\n\t */\r\n\tpublic arrayBufferToBase64String(arrayBuffer: any)\r\n\t{\r\n\r\n\t\tlet byteArray\t= new Uint8Array(arrayBuffer)\r\n\t\tlet byteString\t= '';\r\n\r\n\t\tfor (var i = 0; i < byteArray.byteLength; i++)\r\n\t\t{\r\n\t\t\tbyteString += String.fromCharCode(byteArray[i]);\r\n\t\t}\r\n\t\treturn btoa(byteString);\r\n\t}\r\n\r\n\r\n\t/**\r\n * Envoie une ou plusieurs clé aes pour un utilisateur donné\r\n * @param publicKey\r\n */\r\n\tsendAesKey(userId: any, fileId: any, aesKey: string, aesKeyVersionMin: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'userFileKey',\r\n\t\t\t\t\t\targs:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tuserId:\t\t\t\tuserId,\r\n\t\t\t\t\t\t\tfileId:\t\t\t\tfileId,\r\n\t\t\t\t\t\t\taesKey:\t\t\t\taesKey,\r\n\t\t\t\t\t\t\taesKeyVersionMin:\taesKeyVersionMin\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Suppression de la clé fichier pour un utilisateur et un fichier donné\r\n\t * @param userId\r\n\t * @param fileId\r\n\t */\r\n\tdeleteAesKey(userId: any, fileId: any)\r\n\t{\r\n\t\t// On vérifie si l'utilisateur dont on souhaite supprimer des clés de fichiers\r\n\t\t// n'est pas un super utilisateur ou un administrateur\r\n\t\tconst isAdmin = this.userData.isUserAdmin(userId);\r\n\t\tconst isSuper = this.userData.isUserSuperviseur(userId);\r\n\r\n\t\tif (isAdmin === false && isSuper === false)\r\n\t\t{\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t\t'cmd': 'userFileKey',\r\n\t\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tuserId: userId,\r\n\t\t\t\t\t\t\t\tfileId: fileId\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('delete', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\r\n /**\r\n * Envoie la clé publique sur le serveur pour que cette dernière soit enregistrée en base de donnée\r\n * @param publicKey\r\n */\r\n\tsendRsaPublic(publicKey: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'userPublicKey',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpublicKey: publicKey\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tencryptData(datas: any, publicRsaKey: any)\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tlet subtle = this._getSubtleCryptoInstance();\r\n\r\n\t\t\tif (subtle)\r\n\t\t\t{\r\n\t\t\t\tlet algorithmImport =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tname: \"RSA-OAEP\",\r\n\t\t\t\t\t\thash:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tname: \"SHA-1\"\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsubtle.importKey(\"spki\", this.convertPemToBinary(publicRsaKey), algorithmImport, true, ['encrypt']).then((publicCryptoKey: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tlet testBuffer\t\t\t= Buffer.from(datas, 'ascii');\r\n\t\t\t\t\tlet algorithmEncrypt\t=\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tname: 'RSA-OAEP'\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsubtle.encrypt(algorithmEncrypt, publicCryptoKey, testBuffer).then((encrypted: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet hexDataEncrypted = this.bufferToHex(encrypted);\r\n\t\t\t\t\t\tresolve(hexDataEncrypted);\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treject(null);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Decrypt data encrypted using private RSA key\r\n\t * @param datas\r\n\t */\r\n\tdecryptData(datas: any, rsaPRivate: any = undefined): Promise\r\n\t{\r\n\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tlet subtle = this._getSubtleCryptoInstance();\r\n\t\t\tif (subtle)\r\n\t\t\t{\r\n\t\t\t\tlet rsaPrivate = rsaPRivate || this.userData.getRSAPrivate();\r\n\t\t\t\tif (rsaPrivate)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet dataToDecrypt = new Uint8Array(datas.match(/[\\da-f]{2}/gi).map((h: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn parseInt(h, 16);\r\n\t\t\t\t\t}));\r\n\r\n\t\t\t\t\tlet algorithmImport =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tname: \"RSA-OAEP\",\r\n\t\t\t\t\t\t\thash:\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tname: \"SHA-1\"\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsubtle.importKey(\"pkcs8\", this.convertPemToBinary(rsaPrivate), algorithmImport, true, ['decrypt'])\r\n\t\t\t\t\t\t.then((privateCryptoKey: any) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet algorithmDecrypt =\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tname: 'RSA-OAEP',\r\n\t\t\t\t\t\t\t\t\thash:\r\n\t\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t\tname: \"SHA-1\"\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\t\tsubtle.decrypt(algorithmDecrypt, privateCryptoKey, dataToDecrypt).then((decrypted: any) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlet strDecoded = String.fromCharCode.apply(null, new Uint8Array(decrypted));\r\n\t\t\t\t\t\t\t\tresolve(strDecoded);\r\n\r\n\r\n\t\t\t\t\t\t\t}).catch((err: any) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treject(err);\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t}).catch((err: any) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treject(err);\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t} \r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\treject(null);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treject(null);\r\n\t\t\t}\r\n\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Déchiffrement d'un fichier en utilisant une clé et vecteur AES 256\r\n\t */\r\n\tdecryptAesFile(blob: Blob, mimeType: string, sharedkey: string, vectorkey: string): Promise\r\n\t{\r\n\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tconst subtle = this._getSubtleCryptoInstance();\r\n\r\n\t\t\tif (subtle)\r\n\t\t\t{\r\n\t\t\t\tconst reader = new FileReader();\r\n\r\n\t\t\t\t// Attente du chargement du blob\r\n\t\t\t\treader.onload = () =>\r\n\t\t\t\t{\r\n\t\t\t\t\t// Chargment de la clé dans SUBTLE\r\n\t\t\t\t\tsubtle.importKey(\r\n\r\n\t\t\t\t\t\t// hex transformé en Array8\r\n\t\t\t\t\t\t'raw', this.hexStringToByte(sharedkey),\r\n\t\t\t\t\t\t{ // this is the algorithm options\r\n\r\n\t\t\t\t\t\t\tname: 'AES-CBC',\r\n\t\t\t\t\t\t},\r\n\t\t\t\t\t\tfalse,\r\n\t\t\t\t\t\t['encrypt', 'decrypt']\r\n\t\t\t\t\t).then((key: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// Déchiffrement\r\n\t\t\t\t\t\tsubtle.decrypt(\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tname: 'AES-CBC',\r\n\t\t\t\t\t\t\t\tiv: this.hexStringToByte(vectorkey)\r\n\t\t\t\t\t\t\t},\r\n\t\t\t\t\t\t\tkey,\r\n\t\t\t\t\t\t\treader.result // ArrayBuffer\r\n\t\t\t\t\t\t).then((decrypted: ArrayBuffer) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// le blob veut un talbeau et pas un array buffer\r\n\t\t\t\t\t\t\tresolve(new Blob([decrypted],\r\n\t\t\t\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\t\t\t\ttype: mimeType\r\n\t\t\t\t\t\t\t\t}));\r\n\r\n\t\t\t\t\t\t}).catch((error: Error) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treject(null);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}).catch((error: Error) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treject(null);\r\n\t\t\t\t\t});\r\n\t\t\t\t};\r\n\t\t\t\treader.readAsArrayBuffer(blob);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treject(null);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * convertion d'une chaine encodée en base64 vers on tableau d'octets\r\n\t * @param base64\r\n\t */\r\n\tpublic b64ToArray(base64: any)\r\n\t{\r\n\r\n\t\tlet binary_string \t= window.atob(base64);\r\n\t\tlet len \t\t\t= binary_string.length;\r\n\t\tlet bytes \t\t\t= new Uint8Array(len);\r\n\r\n\t\tfor (let i = 0; i < len; i++)\r\n\t\t{\r\n\t\t\tbytes[i] = binary_string.charCodeAt(i);\r\n\t\t}\r\n\r\n\t\treturn bytes.buffer;\r\n\t}\r\n\r\n\r\n\tbufferToHex(buffer: any)\r\n\t{\r\n//\t\tlet sVarTest:any;\r\n\t\treturn Array.prototype.map.call(new Uint8Array(buffer), (sVarTest:any) => ('00' + sVarTest.toString(16)).slice(-2)).join('');\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Retourne une string hex depuis un tableau de byte\r\n\t */\r\n\tbyteToHexString(uint8arr: Uint8Array): string\r\n\t{\r\n\t\tif (!uint8arr)\r\n\t\t{\r\n\t\t\treturn '';\r\n\t\t}\r\n\r\n\t\tvar hexStr = '';\r\n\t\tfor (var i = 0; i < uint8arr.length; i++)\r\n\t\t{\r\n\t\t\tvar hex = (uint8arr[i] & 0xff).toString(16);\r\n\t\t\thex \t= (hex.length === 1) ? '0' + hex : hex;\r\n\t\t\thexStr += hex;\r\n\t\t}\r\n\r\n\t\treturn hexStr.toUpperCase();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Retourne un tableau de byte depuis une chaine hexa\r\n\t */\r\n\tpublic hexStringToByte(str: string): Uint8Array\r\n\t{\r\n\t\tif (!str)\r\n\t\t{\r\n\t\t\treturn new Uint8Array(0);\r\n\t\t}\r\n\r\n\t\tvar a = [];\r\n\t\tfor (var i = 0, len = str.length; i < len; i += 2)\r\n\t\t{\r\n\t\t\ta.push(parseInt(str.substr(i, 2), 16));\r\n\t\t}\r\n\r\n\t\treturn new Uint8Array(a);\r\n\t}\r\n\r\n\r\n\tpublic arrayBufferToBase64(arrayBuffer: any)\r\n\t{\r\n\r\n\t\tlet binary\t= '';\r\n\t\tlet bytes\t= new Uint8Array(arrayBuffer);\r\n\t\tlet len \t= bytes.byteLength;\r\n\r\n\t\tfor (let i = 0; i < len; i++)\r\n\t\t{\r\n\t\t\tbinary += String.fromCharCode(bytes[i]);\r\n\t\t}\r\n\t\treturn window.btoa(binary);\r\n\t}\r\n\r\n\r\n\tpublic stringToArrayBuffer(strDatas: string)\r\n\t{\r\n\t\tlet buf \t= new ArrayBuffer(strDatas.length * 2);\r\n\t\tlet bufView = new Uint8Array(buf);\r\n\r\n\t\tfor (let i = 0, strLen = strDatas.length; i < strLen; i++)\r\n\t\t{\r\n\t\t\tbufView[i] = strDatas.charCodeAt(i);\r\n\t\t}\r\n\t\treturn buf;\r\n\t}\r\n\r\n\t\r\n\t/**\r\n\t * Convertion d'une clé RSA formatée pem en clé RSA binaire\r\n\t * @param pem\r\n\t */\r\n\tpublic convertPemToBinary(pem: any)\r\n\t{\r\n\t\tlet lines = pem.split('\\n');\r\n\t\tlet encoded = '';\r\n\t\tfor (let i = 0; i < lines.length; i++)\r\n\t\t{\r\n\t\t\tif (lines[i].trim().length > 0 &&\r\n\t\t\t\tlines[i].indexOf('-----BEGIN RSA PRIVATE KEY-----') < 0 &&\r\n\t\t\t\tlines[i].indexOf('-----BEGIN RSA PUBLIC KEY-----') < 0 &&\r\n\t\t\t\tlines[i].indexOf('-----BEGIN PUBLIC KEY-----') < 0 &&\r\n\t\t\t\tlines[i].indexOf('-----END PUBLIC KEY-----') < 0 &&\r\n\t\t\t\tlines[i].indexOf('-----BEGIN PRIVATE KEY-----') < 0 &&\r\n\t\t\t\tlines[i].indexOf('-----END PRIVATE KEY-----') < 0 &&\r\n\t\t\t\tlines[i].indexOf('-----END RSA PRIVATE KEY-----') < 0 &&\r\n\t\t\t\tlines[i].indexOf('-----END RSA PUBLIC KEY-----') < 0)\r\n\t\t\t{\r\n\r\n\t\t\t\tencoded += lines[i].trim();\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn this.b64ToArray(encoded);\r\n\t}\r\n\r\n\r\n\tprivate _getSubtleCryptoInstance()\r\n\t{\r\n\t\tlet instance: any;\r\n\t\tif (window.crypto.subtle !== undefined)\r\n\t\t{\r\n\t\t\tinstance = window.crypto.subtle;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (crypto.subtle !== undefined)\r\n\t\t\t{\r\n\t\t\t\tinstance = crypto.subtle;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t//Compatibilité Safari\r\n//\t\t\t\tif (crypto['webkitSubtle'] !== undefined)\r\n//\t\t\t\t{\r\n//\t\t\t\t\tinstance = crypto['webkitSubtle'];\r\n//\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\treturn instance;\r\n\t}\r\n}\r\n","// Angular\r\nimport { Injectable }\t \t\t\tfrom '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n// Other\r\nimport { EpreuveHttpService } \t\tfrom './http/epreuveHttp.service';\r\nimport { Matiere } \t\t\t\t\tfrom '../classes/matiere.class';\r\nimport { Comment }\t\t\t\t\tfrom '../classes/comment.class';\r\nimport { SocketService } \t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } \t\t\t\tfrom '../providers/user-data';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class EpreuveService\r\n{\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n constructor(private epreuveHttpService: EpreuveHttpService,\r\n\t\t\t\tpublic socketService: SocketService,\r\n\t\t\t\tprivate userData: UserData)\r\n {\r\n\r\n }\r\n\r\n\r\n /**\r\n * Add new epreuve in database from Matiere object given in parameter\r\n * Parents ids are given by the parentPath parameter\r\n */\r\n public addEpreuve(epreuve: Matiere, parentPath: any[] = [])\r\n {\r\n\t\tlet datas \t\t= epreuve.toJson();\r\n\t\tdatas.idparents = parentPath;\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\ttype: 'epreuve',\r\n\t\t\t\t\t\t\tnode: datas\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n }\r\n\r\n\r\n\t/**\r\n\t * Update epreuve in database from Matiere object given in parameter\r\n\t * @param dataEpreuve\r\n\t */\r\n\tpublic editEpreuve(dataEpreuve: Matiere)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\ttype: 'epreuve',\r\n\t\t\t\t\t\t\tnode: dataEpreuve.toJson()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Get all epreuves in database relative to user account and parameters given:\r\n *\r\n * -idEpreuve: if this parameter is defined, return the Matiere object corresponding to the value id\r\n * -idExamen: if this parameter is defined (and if the parameter idEpreuve is not), return the Matiere\r\n * objects wich the examen parent matches the value id.\r\n *\r\n * Return a list of Matiere objects\r\n */\r\n\tpublic getEpreuves(idEpreuve: string, idExamen: string): Observable\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.epreuveHttpService.getEpreuves(idEpreuve, idExamen).subscribe(res =>\r\n\t\t\t{\r\n\t\t\t\tlet resJson\t\t\t\t= res.json();\r\n\t\t\t\tlet examens: Matiere[]\t= [];\r\n\r\n\t\t\t\tif (resJson.data && resJson.data.rows)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let row of resJson.data.rows)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (row)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\texamens.push(Matiere.fromJsonObject(row));\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tobserver.next(examens);\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n}\r\n\r\n\r\n","// Angular\r\nimport { Injectable } from '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n// Other\r\nimport { EtablissementHttpService } from './http/etablissementHttp.service';\r\nimport { Etablissement }\t\t\tfrom '../classes/etablissement.class';\r\nimport { SocketService }\t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData }\t\t\t\t\tfrom '../providers/user-data';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class EtablissementService\r\n{\r\n\r\n\r\n\tprivate socket: any = undefined;\r\n\t/**\r\n\t *\r\n\t */\r\n\r\n\r\n\tconstructor(private etablissementHttpService:\tEtablissementHttpService,\r\n\t\t\t\tpublic\tsocketService:\t\t\t\tSocketService,\r\n\t\t\t\tprivate userData:\t\t\t\t\tUserData)\r\n\t{\r\n\t\tthis.socket = socketService.getSocketConnection();\r\n\t}\r\n\r\n\r\n /**\r\n * Add new etablissement in database from Etablissement object given in parameter\r\n */\r\n\tpublic addEtablissement(dataEtab: Etablissement)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\ttype:\t'etablissement',\r\n\t\t\t\t\t\t\tnode:\tdataEtab.toJson()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Update etablissement in database from Etablissement object given in parameter\r\n */\r\n\tpublic editEtablissement(dataEtab: Etablissement)\r\n\t{\r\n\t\treturn this.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t\t'args': \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\ttype: 'etablissement',\r\n\t\t\t\t\t\t\t\tnode: dataEtab.toJson()\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Get all etablissements in database from the user account\r\n * Return a list of Etablissement object\r\n */\r\n\tpublic getEtablissementsAvailable()\r\n\t{\r\n\t\tif (this.userData.isAdmin() === true || this.userData.isSuperviseur() === true)\r\n\t\t{\r\n\t\t\tthis.socketService.on('read', this._onRessourcesReturned.bind(this));\r\n\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd':\t'ressources',\r\n\t\t\t\t\t\t'args': {}\r\n\t\t\t\t\t};\r\n\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tlet tasksAvailable\t= this.userData.getTasksHomeForMe();\r\n\t\t\tlet sUserId\t\t\t= this.userData.getUserId();\r\n\t\t\tlet eSocketWhat: SocketWhat.request;\r\n\t\t\tlet arrayEpreuves = _.map(tasksAvailable, (task: any) => { return task.idepreuve; });\r\n\r\n\t\t\t//On effectue un appel socket pour récupérer l'épreuve associé à la tache\r\n\t\t\t//ainsi que tous ses parents\r\n\t\t\tif (sUserId && arrayEpreuves.length > 0)\r\n\t\t\t{\r\n\t\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tif (socket)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.socket = socket;\r\n\r\n\t\t\t\t\t\tlet data: ISocketData = \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t\t'name': sUserId,\r\n\t\t\t\t\t\t\t\t'what': eSocketWhat,\r\n\t\t\t\t\t\t\t\t'cmd': 'node.info',\r\n\t\t\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tnodeOption:\t'wp',\r\n\t\t\t\t\t\t\t\t\tnodes:\t\tarrayEpreuves\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Suppression d'un noeud du système et de le'ensemble des noeuds enfants, des sujets, des taches et des fichiers\r\n\t * @param element\r\n\t */\r\n\tpublic removeElement(element: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tthis.socket = socket;\r\n\r\n\t\t\t\tlet data: ISocketData = \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tnodeId: element.id\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('delete', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Fonction appelée automatiquement à la récupération de ressources\r\n\t */\r\n\tprivate _onRessourcesReturned(datas: any)\r\n\t{\r\n\r\n\t\tif (datas.cmd && datas.cmd === 'ressources')\r\n\t\t{\r\n\t\t\tif (datas.args && datas.args.data && datas.args.data.ressources)\r\n\t\t\t{\r\n\t\t\t\tlet nodes = _.keys(datas.args.data.ressources);\r\n\t\t\t\tthis.userData.setRessources(nodes);\r\n\r\n\t\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tif (socket)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t\t'cmd': 'node.info',\r\n\t\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnodes:\t\tnodes,\r\n\t\t\t\t\t\t\t\tnodeOption: 'wc',\r\n\t\t\t\t\t\t\t\tdepth:\t\t-1\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n","// Angular\r\nimport { Injectable }\t \t\t\tfrom '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n// Other\r\nimport { EpreuveHttpService } \t\tfrom './http/epreuveHttp.service';\r\nimport { Event }\t\t\t\t\tfrom '../classes/event.class';\r\nimport { SocketService } \t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } \t\t\t\tfrom '../providers/user-data';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class EventService\r\n{\r\n\t\r\n\t/**\r\n\t * \r\n\t */\r\n constructor(private epreuveHttpService: EpreuveHttpService,\r\n\t\t\t\tpublic socketService: SocketService,\r\n\t\t\t\tprivate userData: UserData)\r\n {\r\n\r\n }\r\n\r\n\r\n /**\r\n * Add new epreuve in database from Matiere object given in parameter\r\n * Parents ids are given by the parentPath parameter\r\n */\r\n public addEvent(event: Event)\r\n {\r\n\t\tlet datas = event.toJson();\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'calendar',\r\n\t\t\t\t\t\t'args': \r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tnode: datas\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n }\r\n\r\n\r\n\t/** \r\n\t * Update epreuve in database from Matiere object given in parameter\r\n\t * @param dataEpreuve \r\n\t */\r\n\tpublic editEvent(event: Event)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'calendar',\r\n\t\t\t\t\t'args': \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tnode:\tevent.toJson()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Get all epreuves in database relative to user account and parameters given:\r\n * \r\n * -idEpreuve: if this parameter is defined, return the Matiere object corresponding to the value id\r\n * -idExamen: if this parameter is defined (and if the parameter idEpreuve is not), return the Matiere\r\n * objects wich the examen parent matches the value id.\r\n *\r\n * Return a list of Matiere objects\r\n */\r\n\tpublic getEvents(idNode: string)\r\n\t{\r\n\t\t\t\t\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'calendar',\r\n\t\t\t\t\t'args': \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tnode: idNode\r\n\t\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n}\r\n\r\n\r\n","// Angular\r\nimport { Injectable } from '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n// Other\r\nimport { ExamenHttpService }\t\tfrom './http/examenHttp.service';\r\nimport { Examen }\t\t\t\t\tfrom '../classes/examen.class';\r\nimport { Comment }\t\t\t\t\tfrom '../classes/comment.class';\r\nimport { SocketService } \t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } \t\t\t\tfrom '../providers/user-data';\r\n\r\n@Injectable()\r\nexport class ExamenService\r\n{\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(private examenHttpService: \tExamenHttpService,\r\n\t\t\t\tpublic socketService: \t\tSocketService,\r\n\t\t\t\tprivate userData: \t\t\tUserData)\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n /**\r\n * Add new examen in database from Examen object given in parameter\r\n * Parents ids are given by the parentPath parameter\r\n */\r\n\tpublic addExamen(examen: Examen, parentPath: any[] = [])\r\n\t{\r\n\t\tlet datas \t\t= examen.toJson();\r\n\t\tdatas.idparents = parentPath;\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t\t'args': \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\ttype: 'examen',\r\n\t\t\t\t\t\t\tnode: datas\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n * Update examen in database from Examen object given in parameter\r\n */\r\n\tpublic editExamen(dataExamen: Examen)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t'args': \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttype: 'examen',\r\n\t\t\t\t\t\tnode:\tdataExamen.toJson()\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Get all examens in database relative to user account and parameters given:\r\n *\r\n * -cascade: if false, return only examens objects, if true return Examens object with childs\r\n * (epreuves) in each objects\r\n * -idExamen: if this parameter is defined, return the Examen object corresponding to the value id\r\n * -idSession: if this parameter is defined (and if the parameter idExamen is not), return the Examen\r\n * objects wich the session parent matches the value id.\r\n *\r\n * Return a list of Examen objects\r\n */\r\n\tpublic getExamens(cascade: boolean, idExamen: string, idSession: string, callback: (result: any) => void)\r\n\t{\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'node.info',\r\n\t\t\t\t\t'args': \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnode: \t\tidSession,\r\n\t\t\t\t\t\tnodeOption: 'wc',\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.examenHttpService.getExamens(cascade, idExamen, idSession).subscribe(res =>\r\n\t\t\t\t{\r\n\t\t\t\t\tlet resJson\t\t\t\t= res.json();\r\n\t\t\t\t\tlet examens: Examen[]\t= [];\r\n\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t// ToComment\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\tif (resJson.data && resJson.data.rows)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let row of resJson.data.rows)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (row)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\texamens.push(Examen.fromJsonObject(row));\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcallback(examens);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n}\r\n\r\n\r\n","// Angular\r\nimport { Injectable } from '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\nimport { File } from '../classes/file.class';\r\nimport { Comment } from '../classes/comment.class';\r\nimport { Note } from '../classes/note.class';\r\n\r\nimport { FileHttpService }\t\t\tfrom './http/fileHttp.service';\r\nimport { SocketService }\t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } \t\t\t\tfrom '../providers/user-data';\r\nimport { VaultData }\t\t\t\tfrom '../providers/vault-data';\r\nimport { WorkspaceData } \t\t\tfrom '../providers/workspace-data';\r\n\r\nimport { EncryptService } from '../services/encrypt.service';\r\ndeclare const require: any;\r\n\r\n\r\nlet fileSaver = require('file-saver');\r\nlet JSZip\t\t= require('jszip');\r\n\r\nimport {Buffer}\t\tfrom 'buffer/';\r\nimport * as _\t\tfrom 'underscore';\r\nimport * as crypto\tfrom \"crypto-browserify\";\r\n\r\n//let fileSaver: any;\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class FileService\r\n{\r\n private socket: any = undefined;\r\n\r\n private listExtensionsFileSelector = '.jpeg, .jpg, .gif, .png, .bmp, .tga, .txt, .doc, .docx, .xls, .xlsx, .odt, .pdf, .html, .csv, .json, .zip, .tar, .rar, .7z, .xml, .tex, .ctx, .ltx, .tif, .tiff';\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n constructor(private fileHttpService:\tFileHttpService,\r\n private socketService:\t\tSocketService,\r\n private workspaceData:\t\tWorkspaceData,\r\n private encryptService:\t\tEncryptService,\r\n\t\t\t\tprivate userData:\t\t\tUserData,\r\n\t\t\t\tprivate vaultData:\t\t\tVaultData)\r\n\t{\r\n\t\tthis.socket = socketService.getSocketConnection();\r\n\t}\r\n\r\n\r\n /**\r\n * Add file in database indexed by given id\r\n */\r\n public addFile(file: File)\r\n {\r\n return this.fileHttpService.addFile(file).share();\r\n }\r\n\r\n\r\n /**\r\n * Get all files wich belong to a subject given by his id\r\n *\r\n * @param subjectId\r\n */\r\n\tpublic getFiles(subjectId: string)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd':\t'files',\r\n\t\t\t\t\t\t'args': { idSubject: subjectId }\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Get detailed file from infos in the file object given\r\n *\r\n * @param file\r\n */\r\n\tpublic getDetailsFile(file: File)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'files',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tidSubject:\tfile.idSubject,\r\n\t\t\t\t\t\t\tid:\t\t\tfile.id,\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\r\n\t\t\t\tlet dataHistoric: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'history',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tbucket:\t\t'files',\r\n\t\t\t\t\t\t\tkey:\t\tfile.id,\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', dataHistoric);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Get detailed file from infos in the file object given\r\n *\r\n * @param file\r\n */\r\n\tpublic getHistoricFile(file: File)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\r\n\t\t\t\tlet dataHistoric: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'history',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tbucket:\t'files',\r\n\t\t\t\t\t\t\tkey:\tfile.id,\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', dataHistoric);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Remove file in database indexed by given id\r\n */\r\n public removeFile(file: File)\r\n {\r\n return this.fileHttpService.removeFile(file).share();\r\n }\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic updateFile(fileJson: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'file',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfile: fileJson\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic deleteFile(file: any, definitive: boolean = false)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'file',\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfileId:\t\t\tfile.id,\r\n\t\t\t\t\t\tepreuveId:\t\tfile.idEpreuve,\r\n\t\t\t\t\t\tsubjectId:\t\tfile.idSubject,\r\n\t\t\t\t\t\tdefinitive:\t\tdefinitive\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('delete', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic restoreFile(file: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'restoreFile',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfileId:\t\tfile.id,\r\n\t\t\t\t\t\t\tepreuveId:\tfile.idEpreuve,\r\n\t\t\t\t\t\t\tsubjectId:\tfile.idSubject\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic addFileNote(file: File, note: Note)\r\n\t{\r\n\t\treturn this.fileHttpService.addFileNote(file, note);\r\n\t}\r\n\r\n\r\n\tpublic addFileVersion(file: File)\r\n\t{\r\n\t\treturn this.fileHttpService.addFileVersion(file);\r\n\t}\r\n\r\n\r\n\tpublic downloadContentFile(file: any, typeFile: string = 'file'): Observable\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Récupère le contenu d'un fichier\r\n\t\t// ---------------------------------------\r\n\t\tconst observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.fileHttpService.downloadFile(file, typeFile).subscribe((res) =>\r\n\t\t\t{\r\n\t\t\t\tobserver.next(res);\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic saveForEdit(file: File, mustDecrypt: boolean = true): Observable\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Récupère le contenu d'un fichier et le télécharge\r\n\t\t// sur le navigateur du client\r\n\t\t// ---------------------------------------\r\n\r\n\t\tconst observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.downloadContentFile(file).subscribe((res) =>\r\n\t\t\t{\r\n\t\t\t\tconst body = ( res)._body;\r\n\r\n\t\t\t\tif (body)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst mimeType \t\t= body.type || this._getMimeType(file.extension);\r\n\t\t\t\t\tconst blob: Blob \t= new Blob([body], { type: mimeType });\r\n\t\t\t\t\t// Cas spécifique: l'extension n'est pas ajoutée automatiquement\r\n\t\t\t\t\t// dans le cas d'un fichier tex\r\n\t\t\t\t\tswitch (mimeType)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tcase 'application/x-tex':\r\n\t\t\t\t\t\t\tconst nameExtension: any = file.name.split('.').pop();\r\n\t\t\t\t\t\t\tif (nameExtension !== 'ltx' && nameExtension !== 'tex')\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tfile.name += '.ltx';\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (mustDecrypt === true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.decryptFileWithAES(file, blob, mimeType).then((blobResult) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.workspaceData.fileForEdit = blobResult;\r\n\t\t\t\t\t\t\tobserver.next(true);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.workspaceData.fileForEdit = blob;\r\n\t\t\t\t\t\tobserver.next(true);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic downloadFile(file: File, mustDecrypt: boolean = true): Observable\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Récupère le contenu d'un fichier et le télécharge\r\n\t\t// sur le navigateur du client\r\n\t\t// ---------------------------------------\r\n\r\n\t\t// On réinitialise l'objet global URL au cas ou si ce dernier aurait été écrasé (MacGiver)\r\n\t\twindow.URL = this.workspaceData.urlCreator;\r\n\r\n\t\tlet observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tfile.isDownloading = true;\r\n\r\n\t\t\tthis.downloadContentFile(file).subscribe((res) =>\r\n\t\t\t{\r\n\r\n\t\t\t\tlet body = ( res)._body;\r\n\r\n\t\t\t\tif (body)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet mimeType \t= body.type || this._getMimeType(file.extension);\r\n\t\t\t\t\tlet blob: Blob \t= new Blob([body], { type: mimeType });\r\n\r\n\t\t\t\t\tif (mustDecrypt === true)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.decryptFileWithAES(file, blob, mimeType).then((blobResult) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfileSaver.saveAs(blobResult, file.name);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfileSaver.saveAs(blob, file.name);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tfile.isDownloading = false;\r\n\t\t\t\tobserver.next(true);\r\n\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\tpublic downloadContentFileFromId(id: any): Observable\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Récupère le contenu d'un fichier\r\n\t\t// ---------------------------------------\r\n\t\tlet observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.fileHttpService.downloadFromId(id).subscribe((res) =>\r\n\t\t\t{\r\n\t\t\t\tobserver.next(res);\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n\r\n /**\r\n * Suppression d'un fichier à partir de son identifiant dans le système de stockage\r\n * @param id\r\n */\r\n\tpublic deleteFromId(id: any): Observable\r\n\t{\r\n\t\tlet observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.fileHttpService.deleteFromId(id).subscribe((res) =>\r\n\t\t\t{\r\n\t\t\t\tobserver.next(res);\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\tpublic downloadFromId(path: any, idFile: any, name: string, type: string, mustDecrypt: boolean = true)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// Récupère le contenu d'un fichier et le télécharge\r\n\t\t// sur le navigateur du client\r\n\t\t// ---------------------------------------\r\n\t\twindow.URL = this.workspaceData.urlCreator;\r\n\r\n\t\tif (idFile)\r\n\t\t{\r\n\t\t\tlet file: any = this.workspaceData.getTreeElement(idFile);\r\n\r\n\t\t\tif (file && file['encryptedAesKeys'] && file['encryptedAesKeys'].length > 0)\r\n\t\t\t{\r\n\t\t\t\tthis.fileHttpService.downloadFromId(path).subscribe((res) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tlet body = ( res)._body;\r\n\r\n\t\t\t\t\tif (body)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet blob: Blob = new Blob([body], { type: type });\r\n\r\n\t\t\t\t\t\tif (mustDecrypt === true)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.decryptFileWithAES(file, blob, type).then((blobResult) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tfileSaver.saveAs(blobResult, name);\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfileSaver.saveAs(blob, name);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n /**\r\n * Download in blob objects all thumbnails for a given file\r\n */\r\n\tpublic downloadThumbnail(file: File, mustDecrypt: boolean = true): Observable\r\n\t{\r\n\t\tconst observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.fileHttpService.downloadFile(file, 'thumbnail').subscribe((res) =>\r\n\t\t\t{\r\n\t\t\t\tconst mimeType \t\t\t= 'image/jpeg';\r\n\t\t\t\tconst blobThumb: Blob \t= new Blob([( res)._body], { type: mimeType });\r\n\r\n\t\t\t\tlet thumbDatas: any;\r\n\t\t\t\tconst urlCreator = this.workspaceData.urlCreator;\r\n\r\n\t\t\t\tif (mustDecrypt === true)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.decryptFileWithAES(file, blobThumb, mimeType).then((blobResult) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthumbDatas =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tblob: \tblobResult,\r\n\t\t\t\t\t\t\turl: \turlCreator.createObjectURL(blobResult)\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\t\tobserver.next(thumbDatas);\r\n\t\t\t\t\t}).catch((error) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobserver.next();\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tthumbDatas =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tblob: blobThumb,\r\n\t\t\t\t\t\t\turl: urlCreator.createObjectURL(blobThumb)\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\tobserver.next(thumbDatas);\r\n\t\t\t\t}\r\n\t\t\t}, (err) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tobserver.next();\r\n\t\t\t\t});\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic downloadFiles(files: File[], nameArchive: string, password: string = null): Observable\r\n\t{\r\n\t\twindow.URL = this.workspaceData.urlCreator;\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tconst observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.fileHttpService.downloadFiles(files, password).subscribe((res) =>\r\n\t\t\t{\r\n\t\t\t\tconst mimeType: any\t= this._getMimeType('zip');\r\n\t\t\t\tconst blob: Blob\t= new Blob([( res)._body], { type: mimeType });\r\n\r\n\t\t\t\tfileSaver.saveAs(blob, nameArchive);\r\n\t\t\t\tobserver.next(true);\r\n\t\t\t});\r\n\t\t});\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\tpublic decryptFileWithAES(file: any, blobInput: Blob, type: string): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tthis.getDecryptedAESKey(file).then((aesFileKey =>\r\n\t\t\t{\r\n\t\t\t\tif (aesFileKey)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst objAesKey = JSON.parse(aesFileKey);\r\n\r\n\t\t\t\t\tthis.encryptService.decryptAesFile(blobInput, type, objAesKey.sharedkey, objAesKey.vectorkey).then((blobResult) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresolve(blobResult);\r\n\r\n\t\t\t\t\t}).catch((error) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treject(error);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t})).catch((error) =>\r\n\t\t\t{\r\n\t\t\t\treject(error);\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic createArchivePassation(passationStruct: any, subjectsToAdd: any[]): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tconst subjectsInfos: any[] = [];\r\n\r\n\t\t\tfor (const subject of subjectsToAdd)\r\n\t\t\t{\r\n\t\t\t\tconst newSubject: any \t= {};\r\n\t\t\t\tnewSubject.id \t\t\t= subject.id;\r\n\r\n\t\t\t\tif (subject.datas)\r\n\t\t\t\t{\r\n\t\t\t\t\tnewSubject.type = subject.datas.etat;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tnewSubject.name = subject.name;\r\n\t\t\t\tnewSubject.pj\t= [];\r\n\r\n\t\t\t\tlet nameMainFile;\r\n\r\n\t\t\t\tif (subject.pj)\r\n\t\t\t\t{\r\n\r\n\t\t\t\t\tfor (let pj of subject.pj)\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tconst newPj: any = {};\r\n\r\n\t\t\t\t\t\tnewPj.id\t\t= pj.id;\r\n\t\t\t\t\t\tnewPj.idSubject = pj.idSubject;\r\n\t\t\t\t\t\tnewPj.name\t\t= pj.name;\r\n\r\n\t\t\t\t\t\tconst compoName: any = pj.name.split('.');\r\n\t\t\t\t\t\tif (compoName.length > 1 && compoName[1] === 'json')\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tnameMainFile = pj.name;\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tnewSubject.pj.push(newPj);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tnewSubject.nameMainFile = nameMainFile;\r\n\r\n\t\t\t\tsubjectsInfos.push(newSubject);\r\n\t\t\t}\r\n\r\n\t\t\tconst structIndex: any =\r\n\t\t\t\t{\r\n\t\t\t\t\tidpassation:\t\tpassationStruct.id,\r\n\t\t\t\t\tnomPassation:\t\tpassationStruct.libelle,\r\n\t\t\t\t\tdatePassation:\t\tpassationStruct.datas.date,\r\n\t\t\t\t\tlocationPassation:\tpassationStruct.datas.location,\r\n\t\t\t\t\tsubjects:\t\t\tsubjectsInfos\r\n\t\t\t\t};\r\n\r\n\t\t\tlet candidats = [];\r\n\r\n\t\t\tif (passationStruct.datas.candidats)\r\n\t\t\t{\r\n\t\t\t\tcandidats = passationStruct.datas.candidats;\r\n\t\t\t}\r\n\r\n\t\t\tlet zip = new JSZip();\r\n\r\n\t\t\tzip.file('index.json', JSON.stringify(structIndex));\r\n\t\t\tzip.file('candidats.json', JSON.stringify(candidats));\r\n\r\n\t\t\tconst sujetsFolder = zip.folder('sujets');\r\n\t\t\tlet cptFileToDownload = 0;\r\n\r\n\t\t\tfor (let index = 0; index < subjectsToAdd.length; index++)\r\n\t\t\t{\r\n\r\n\t\t\t\tconst sujet: \tany\t= subjectsToAdd[index];\r\n\t\t\t\tconst name: \tany\t= index === 0 ? 'principal' : 'secondaire';\r\n\r\n\t\t\t\tconst sujetFolder = sujetsFolder.folder(name);\r\n\r\n\t\t\t\tsujetFolder.file('correction.json', '');\r\n\t\t\t\tsujetFolder.file('bareme.json', '');\r\n\r\n\t\t\t\tfor (const file of sujet.pj)\r\n\t\t\t\t{\r\n\t\t\t\t\tcptFileToDownload++;\r\n\r\n\t\t\t\t\tconst pathJson = JSON.parse(file.path);\r\n\r\n\t\t\t\t\tthis.downloadContentFileFromId(pathJson.main).subscribe((res) =>\r\n\t\t\t\t\t{\r\n\r\n\t\t\t\t\t\tsujetFolder.file(file.name, res._body);\r\n\t\t\t\t\t\tcptFileToDownload--;\r\n\r\n\t\t\t\t\t\tif (cptFileToDownload === 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tzip.generateAsync({ type: 'blob' }).then((blob: any) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tresolve(blob);\r\n\r\n\t\t\t\t\t\t\t}).catch((error: any) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treject(error);\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n\t * Retourne si le format du fichier est accépté, retourne faux sinon\r\n\t * @param file\r\n\t */\r\n\tpublic isAcceptedFile(file: any, isNumericEpreuve: boolean = false)\r\n\t{\r\n\t\tlet result = false;\r\n\t\t// ---------------------------------------\r\n\t\t// Todo: Remplacer ce test par un call via BDD\r\n\t\t// ---------------------------------------\r\n\t\tlet supportedFileTypes: string[] =\r\n\t\t[\r\n\t\t\t'text/plain',\r\n\t\t\t'text/html',\r\n\t\t\t'text/csv',\r\n\t\t\t'application/x-abiword',\r\n\t\t\t'application/pdf',\r\n\t\t\t'application/msword',\r\n\t\t\t'application/json',\r\n\t\t\t'application/x-bzip',\r\n\t\t\t'application/x-bzip2',\r\n\t\t\t'application/x-rar-compressed',\r\n\t\t\t'application/x-tar',\r\n\t\t\t'application/x-7z-compressed',\r\n\t\t\t'application/x-zip-compressed',\r\n\t\t\t'application/x-gzip',\r\n\t\t\t'application/zip',\r\n\t\t\t'application/xml',\r\n\t\t\t'application/x-tex',\r\n\t\t\t'application/vnd.oasis.opendocument.text',\r\n\t\t\t'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\r\n\t\t\t'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\r\n\t\t\t'application/vnd.ms-excel',\r\n\t\t\t'image/png',\r\n\t\t\t'image/bmp',\r\n\t\t\t'image/jpeg',\r\n\t\t\t'image/tiff'];\r\n\r\n\r\n\t\tif (isNumericEpreuve === true)\r\n\t\t{\r\n\t\t\tsupportedFileTypes.push('audio/mp3');\r\n\t\t\tsupportedFileTypes.push('video/mp4');\r\n\t\t\tsupportedFileTypes.push('video/avi');\r\n\t\t\tsupportedFileTypes.push('video/x-matroska');\r\n\t\t}\r\n\r\n\t\tif (file && file.type)\r\n\t\t{\r\n\t\t\tresult = _.contains(supportedFileTypes, file.type);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// S'il n'y a pas de mimetype on regarde l'extension\r\n\r\n\t\t\t// On récupère les extentions accéptées\r\n\t\t\tlet arrayExtentions = this.listExtensionsFileSelector.split(',');\r\n\t\t\tarrayExtentions \t= _.map(arrayExtentions, (ext: any) => { return ext.trim(); });\r\n\r\n\t\t\t// On récupère l'extention du fichier\r\n\t\t\tconst fileNameParts = file.name.split('.');\r\n\t\t\tif (fileNameParts.length > 1)\r\n\t\t\t{\r\n\t\t\t\tconst extention = '.' + fileNameParts[1];\r\n\t\t\t\tresult \t\t\t= _.contains(arrayExtentions, extention);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\tpublic getDecryptedAESKey(file: any): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tif (file.encryptedAesKeys && file.encryptedAesKeys.length > 0)\r\n\t\t\t{\r\n\t\t\t\tlet encryptedKey\t= file.encryptedAesKeys[0];\r\n\t\t\t\tencryptedKey\t\t= encryptedKey.val;\r\n\t\t\t\treturn this.encryptService.decryptData(encryptedKey).then(decoded =>\r\n\t\t\t\t{\r\n\t\t\t\t\tresolve(decoded);\r\n\t\t\t\t}).catch(error =>\r\n\t\t\t\t{\r\n\t\t\t\t\treject(null);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treject(null);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tprivate _getMimeType(extension: string)\r\n\t{\r\n\t\tlet oReturn: any;\r\n\t\tswitch (extension)\r\n\t\t{\r\n\t\t\tcase 'jpg':\r\n\t\t\t\toReturn = 'image/jpeg';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'zip':\r\n\t\t\t\toReturn = 'application/zip';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\toReturn = 'application/octet-stream';\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t\treturn oReturn;\r\n\t}\r\n}\r\n","import { CreationHttpService }\tfrom './creationHttp.service';\r\n\r\nimport { Injectable }\t\tfrom '@angular/core';\r\nimport { Http, Headers }\tfrom '@angular/http';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\n@Injectable()\r\n\r\n/**\r\n * Todo: commenter\r\n */\r\nexport class AuthHttpService\r\n{\r\n\r\n\t/**\r\n\t * Todo: commenter\r\n\t */\r\n\tconstructor(private http: Http)\r\n\t{\r\n\t}\r\n\r\n\t/**\r\n\t * Todo: commenter\r\n\t */\r\n\tpublic doLogin(username: string, password: string, fingerprint: string): Observable\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Création d'un post pour demander un login.\r\n\t\t// Todo: mise en place programmation defensive!\r\n\t\t// ---------------------------------------\r\n\t\tlet credentials =\r\n\t\t{\r\n\t\t\tusername:\t\tusername,\r\n\t\t\tpassword:\t\tpassword,\r\n\t\t\tfingerprint:\tfingerprint\r\n\t\t};\r\n\r\n\r\n\t\tlet apiUrl\t\t\t= CreationHttpService.getAPIUrl();\r\n\t\tlet path\t\t\t= CreationHttpService.getPathByWebServiceName('auth');\r\n\t\tlet jSonCredential\t= JSON.stringify(credentials);\r\n\t\tlet absolutePath\t= CreationHttpService.absolute(apiUrl,path);\r\n\r\n\r\n\t\t// Todo : passer en socker\r\n\t\treturn this.http.post(absolutePath, jSonCredential, { headers: headers });\r\n\t}\r\n\r\n\r\n\tpublic refreshToken(token: any): Observable\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + token);\r\n\r\n\t\tlet credentials = {};\r\n\r\n return this.http.post(CreationHttpService.absolute(CreationHttpService.getAPIUrl(),CreationHttpService.getPathByWebServiceName('refresh'))\r\n\t\t\t, JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n\r\n\r\n\tpublic doLoginWithToken(token: any): Observable\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + token);\r\n\r\n\t\tlet credentials =\r\n\t\t\t{\r\n\t\t\t\ttoken: token\r\n\t\t\t};\r\n\r\n\r\n\t\t// Sale\r\n return this.http.post(CreationHttpService.absolute(CreationHttpService.getAPIUrl(), CreationHttpService.getPathByWebServiceName('auth'))\r\n\t\t\t, JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n}\r\n"," import { Injectable }\t from '@angular/core';\r\nimport { Http, Headers, URLSearchParams } from '@angular/http';\r\n\r\nimport { DataHttpService }\t\tfrom './dataHttp.service';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { Piece }\t\t\t\tfrom '../../classes/piece.class';\r\n\r\n\r\n@Injectable()\r\nexport class ChatHttpService extends DataHttpService\r\n{\r\n constructor(public http: Http, public userData: UserData)\r\n\t{\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('chat'));\r\n\t}\r\n\r\n\r\n /**\r\n * Get rooms available for given user\r\n */\r\n\tpublic getUserRooms(userId: any)\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type',\t'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet params: URLSearchParams = new URLSearchParams();\r\n\t\tparams.set('userid', userId);\r\n\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\treturn this.http.get(this.getUrl() + 'getUserRooms', { headers: headers, search: params });\r\n\t}\r\n\r\n\r\n\tpublic setRoom(newRoom: Piece)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet credentials = \r\n\t\t\t{\r\n\t\t\t\tdata:\tnewRoom.toJson()\r\n\t\t\t};\r\n\r\n\t\treturn this.http.post(this.getUrl() + 'addRoom', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n\r\n /**\r\n * Get room by ids\r\n */\r\n public getRooms(roomsIds: any[])\r\n {\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let headers = new Headers();\r\n\t\theaders.append('Content-Type',\t'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n let params: URLSearchParams = new URLSearchParams();\r\n params.set('ids', roomsIds.join());\r\n\r\n return this.http.get(this.getUrl() + 'getRooms', { headers: headers, search: params });\r\n }\r\n\r\n\r\n /**\r\n * Get messages by room id\r\n */\r\n public getMessages(roomId: any)\r\n {\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let headers = new Headers();\r\n\t\theaders.append('Content-Type',\t'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n let params: URLSearchParams = new URLSearchParams();\r\n params.set('roomid', roomId);\r\n\r\n return this.http.get(this.getUrl() + 'getMessages', { headers: headers, search: params });\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { Http }\tfrom '@angular/http';\r\n\r\n\r\n@Injectable()\r\n\r\n\r\nexport class CreationHttpService\r\n{\r\n\r\n\tprivate static useApiUrl:\t\tboolean = undefined; // l'api ce trouve, sur le serveur de connexion, a part si vrai si dessous\r\n\tprivate static useChatUrl:\t\tboolean = undefined; // idem on peut deporter le chat\r\n\tprivate static chatSecure:\t\tboolean = undefined; // http ou https (si pas automatique)\r\n\tprivate static apiBehindProxy:\tboolean = undefined; // proxy = rajouter un chemin\r\n\tprivate static chatBehindProxy: boolean = undefined; // proxy = rajouter un chemin\r\n\tprivate static apiUrl:\t\t\tstring\t= undefined; // http ou https, url de l'api et port si besoin'\r\n\tprivate static apiPath:\t\t\tstring\t= undefined;\r\n\tprivate static chatUrl:\t\t\tstring\t= undefined;\r\n\tprivate static chatPath:\t\tstring\t= undefined;\r\n\tprivate static chatPort:\t\tstring\t= undefined;\r\n\r\n\tpublic static initConfigs(http: Http): Promise\r\n\t{ \r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\t const jsonFile \t= 'assets/configprod.json';\r\n\t\t\t// const jsonFile \t= 'assets/configpreprod.json';\r\n\t\t\t// const jsonFile \t\t= 'assets/configlocal.json';\r\n\t\t\t\r\n\t\t\thttp.get(jsonFile).toPromise().then((res: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (res && res._body)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst configsJson: any = JSON.parse(res._body);\r\n\r\n\t\t\t\t\tCreationHttpService.useApiUrl \t\t= configsJson.useApiUrl \t\t=== 'true' ? true : false;\r\n\t\t\t\t\tCreationHttpService.useChatUrl \t\t= configsJson.useChatUrl \t\t=== 'true' ? true : false;\r\n\t\t\t\t\tCreationHttpService.chatSecure \t\t= configsJson.chatSecure \t\t=== 'true' ? true : false;\r\n\t\t\t\t\tCreationHttpService.apiBehindProxy \t= configsJson.apiBehindProxy \t=== 'true' ? true : false;\r\n\t\t\t\t\tCreationHttpService.chatBehindProxy = configsJson.chatBehindProxy \t=== 'true' ? true : false; \r\n\t\t\t\t\tCreationHttpService.apiUrl \t\t\t= configsJson.apiUrl;\r\n\t\t\t\t\tCreationHttpService.apiPath \t\t= configsJson.apiPath;\r\n\t\t\t\t\tCreationHttpService.chatUrl \t\t= configsJson.chatUrl;\r\n\t\t\t\t\tCreationHttpService.chatPath \t\t= configsJson.chatPath;\r\n\t\t\t\t\tCreationHttpService.chatPort \t\t= configsJson.chatPort;\r\n\r\n\t\t\t\t\tresolve();\r\n\t\t\t\t} \r\n\t\t\t\telse \r\n\t\t\t\t{\r\n\t\t\t\t\treject();\r\n\t\t\t\t} \r\n\r\n\t\t\t}).catch(err =>\r\n\t\t\t{\r\n\t\t\t\treject();\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Retourne l'url de l'api (normalement sur le meme serveur que le serveur http)\r\n\t */\r\n\tpublic static getAPIUrl(): string\r\n\t{\r\n\t\tif (CreationHttpService.useApiUrl)\r\n\t\t{\r\n\t\t\tif (CreationHttpService.apiBehindProxy)\r\n\t\t\t{\r\n\t\t\t\treturn CreationHttpService.absolute(CreationHttpService.apiUrl, CreationHttpService.apiPath);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn CreationHttpService.apiUrl;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (CreationHttpService.apiBehindProxy)\r\n\t\t\t{\r\n\t\t\t\treturn CreationHttpService.absolute(window.location.origin, CreationHttpService.apiPath);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn window.location.origin;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n /**\r\n\t * Retourne l'url du chat (normalement sur le meme serveur que le serveur http)\r\n\t */\r\n\tpublic static getChatUrl(): string\r\n\t{\r\n\t\tif (CreationHttpService.useChatUrl)\r\n\t\t{\r\n\t\t\treturn CreationHttpService.chatUrl;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn window.location.hostname;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic static getChatPort(): string\r\n\t{\r\n\t\tif (CreationHttpService.useChatUrl)\r\n\t\t{\r\n\t\t\treturn CreationHttpService.chatPort;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn window.location.port;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic static getChatSecure(): boolean\r\n\t{\r\n\t\tlet bReturn;\r\n\t\tif (CreationHttpService.useChatUrl)\r\n\t\t{\r\n\t\t\tbReturn = CreationHttpService.chatSecure;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tbReturn = window.location.protocol === 'https:';\r\n\t\t}\r\n\t\treturn bReturn;\r\n\t}\r\n\r\n\r\n\tpublic static getChatPath(): string\r\n\t{\r\n\t\tif (CreationHttpService.chatBehindProxy)\r\n\t\t{\r\n\t\t\treturn CreationHttpService.chatPath;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn undefined;\r\n\t\t}\r\n\t}\r\n\r\n\r\n /**\r\n * Ajoute une url a l'adresse en gérant le /\r\n * @param base\r\n * @param relative\r\n */\r\n\tpublic static absolute(...args: string[]): string\r\n\t{\r\n\t\tlet join = [].slice.call(args, 0).join('/');\r\n\t\treturn CreationHttpService.normalize(join);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Retourne l'url du service dans l'api\r\n\t */\r\n\tpublic static getPathByWebServiceName(name: string)\r\n\t{\r\n\t\tlet sReturn = '';\r\n\r\n\t\t// Si c'est en prod on va avoir besoin du suffixe\r\n\t\t// sReturn = '/creation';\r\n\r\n\t\t// Et encore on pourrait ajouter le \"name\" à la suite sans passer par le switch ... mais au cas ou je laisse\r\n\t\tswitch (name)\r\n\t\t{\r\n\t\t\tcase 'auth':\r\n\t\t\t\tsReturn += '/api/v1/auth/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'refresh':\r\n\t\t\t\tsReturn += '/api/v1/auth/refresh';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'chat':\r\n\t\t\t\tsReturn += '/api/v1/chat/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'epreuve':\r\n\t\t\t\tsReturn += '/api/v1/epreuve/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'etablissement':\r\n\t\t\t\tsReturn += '/api/v1/etablissement/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'examen':\r\n\t\t\t\tsReturn += '/api/v1/examen/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'file':\r\n\t\t\t\tsReturn += '/api/v1/file/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'filesend':\r\n\t\t\t\tsReturn += '/api/v1/file/send/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'filesendforpreview':\r\n\t\t\t\tsReturn += '/api/v1/file/sendForPreview/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'filesendToConvert':\r\n\t\t\t\tsReturn += '/api/v1/file/sendToConvert/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'session':\r\n\t\t\t\tsReturn += '/api/v1/session/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'sujet':\r\n\t\t\t\tsReturn += '/api/v1/sujet/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'task':\r\n\t\t\t\tsReturn += '/api/v1/task/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'user':\r\n\t\t\t\tsReturn += '/api/v1/user/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\treturn sReturn;\r\n\t}\r\n\r\n\r\n /**\r\n * Fonction interne pour normaliser une url\r\n * @param str\r\n * @pzaram searchString\r\n */\r\n\tprivate static startsWith(str: string, searchString: string): boolean\r\n\t{\r\n\t\treturn str.substr(0, searchString.length) === searchString;\r\n\t}\r\n\r\n\r\n /**\r\n * Normalise une url\r\n * @param str\r\n */\r\n\tprivate static normalize(str: string): string\r\n\t{\r\n\r\n\t\tif (CreationHttpService.startsWith(str, 'file://'))\r\n\t\t{\r\n\t\t\t// 3 slash pour file protocol\r\n\t\t\tstr = str.replace(/(\\/{0,3})\\/*/g, '$1');\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// au minimum 2 apres le protocole\r\n\t\t\tstr = str.replace(/:\\//g, '://');\r\n\r\n\t\t\t// enlever les slash en trop\r\n\t\t\tstr = str.replace(/([^:\\s\\%\\3\\A])\\/+/g, '$1/');\r\n\t\t}\r\n\r\n\t\t// enlever les slash de fin avant param\r\n\t\tstr = str.replace(/\\/(\\?|&|#[^!])/g, '$1');\r\n\r\n\t\t// remplace ? par &\r\n\t\tstr = str.replace(/(\\?.+)\\?/g, '$1&');\r\n\r\n\t\treturn str;\r\n\t}\r\n}\r\n","import { CreationHttpService }\t\t\t\tfrom './creationHttp.service';\r\nimport { Injectable }\t\t\t\t\t\tfrom '@angular/core';\r\nimport { Http, Headers, URLSearchParams }\tfrom '@angular/http';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\nimport { Matiere }\tfrom '../../classes/matiere.class';\r\nimport { UserData } from '../../providers/user-data';\r\n\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class DataHttpService\r\n{\r\n\tprotected sUrl:\t\t\t\tstring;\r\n\tprotected sUrlExtention:\tstring;\r\n\tprotected sToken:\t\t\tstring;\r\n\tprotected sParentToken:\t\tstring;\r\n\tprotected jOptionToken: any;\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(protected http: Http, protected userData: UserData, urlExtention: string= '')\r\n\t{\r\n\t\tthis.sUrlExtention\t= urlExtention;\r\n this.sUrl \t\t\t= CreationHttpService.absolute(CreationHttpService.getAPIUrl(), this.sUrlExtention);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tprotected add(pxData: any, path: any[] = [], data: any = undefined): Observable\r\n\t{\r\n\t\tlet jData;\r\n\r\n\t\tif (data)\r\n\t\t{\r\n\t\t\tjData = data;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tjData =\r\n\t\t\t\t{\r\n\t\t\t\t\tname: pxData.name,\r\n\t\t\t\t\tpath: path\r\n\t\t\t\t};\r\n\t\t}\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet credentials =\r\n\t\t\t{\r\n\t\t\t\tdata:\tjData,\r\n\t\t\t\ttoken:\tthis.userData.getTokenKey()\r\n\t\t\t};\r\n\r\n\t\treturn this.http.post(this.getUrl() + 'create', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n\r\n\r\n\tprotected edit(pxData: any, path: any[] = [], data: any = undefined): Observable\r\n\t{\r\n\t\tlet jData;\r\n\r\n\t\tif (data)\r\n\t\t{\r\n\t\t\tjData = data;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tjData = \r\n\t\t\t\t{\r\n\t\t\t\t\tname: pxData.name,\r\n\t\t\t\t\tpath: path\r\n\t\t\t\t};\r\n\t\t}\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tconst headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tconst credentials =\r\n\t\t\t{\r\n\t\t\t\tdata:\tjData,\r\n\t\t\t\ttoken:\tthis.userData.getTokenKey()\r\n\t\t\t};\r\n\r\n\t\treturn this.http.post(this.getUrl() + 'create', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tprotected get(id: string = '', idParent: string = ''): Observable\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tconst headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tconst params: URLSearchParams = new URLSearchParams();\r\n\r\n\t\tif (id && this.sToken)\r\n\t\t{\r\n\t\t\tparams.set(this.sToken, id);\r\n\t\t}\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tif (idParent && this.sParentToken)\r\n\t\t{\r\n\t\t\tparams.set(this.sParentToken, idParent);\r\n\t\t}\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tif (this.jOptionToken)\r\n\t\t{\r\n\t\t\tfor (let key in this.jOptionToken)\r\n\t\t\t{\r\n\t\t\t\tvar value: any = this.jOptionToken[key];\r\n\t\t\t\tparams.set(key, this.jOptionToken[key]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\treturn this.http.get(this.getUrl() + 'get', { headers: headers, search: params });\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tprotected getById(data: any)\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tprotected getByForeignKey(data: any)\r\n\t{\r\n\r\n\t}\r\n\r\n\tprotected getUrl()\r\n\t{\r\n\t\tconst result = CreationHttpService.absolute(CreationHttpService.getAPIUrl(), this.sUrlExtention);\r\n\t\treturn result;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tprotected delet(data: any)\r\n\t{\r\n\r\n\t}\r\n}\r\n","import { Injectable }\tfrom '@angular/core';\r\nimport { Http }\t\t\tfrom '@angular/http';\r\n\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { DataHttpService }\t\tfrom './dataHttp.service';\r\nimport { Matiere }\t\t\t\tfrom '../../classes/matiere.class';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class EpreuveHttpService extends DataHttpService\r\n{\r\n\tprotected sToken:\t\t\tstring = 'idepreuve';\r\n\tprotected sParentToken:\t\tstring = 'idexamen';\r\n\t\r\n\t\r\n\tconstructor(protected http: Http, protected userData: UserData)\r\n\t{\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('epreuve'));\r\n\t}\r\n\r\n\r\n /**\r\n * add new epreuve in database from Matiere object given in parameter\r\n */\r\n\tpublic addEpreuve(epreuve: any, parentPath: any[] = [])\r\n\t{\r\n\t\tepreuve.dateDebut\t= epreuve.redactionStart;\r\n\t\tepreuve.dateFin\t\t= epreuve.redactionEnd;\r\n\t\tepreuve.path\t\t= parentPath;\r\n\r\n\t\treturn this.add(null, parentPath, epreuve);\r\n\t}\r\n\r\n\r\n /**\r\n * Get all epreuves in database relative to user account and parameters given:\r\n * \r\n * -idEpreuve: if this parameter is defined, return the Matiere object corresponding to the value id\r\n * -idExamen: if this parameter is defined (and if the parameter idEpreuve is not), return the Matiere\r\n * objects wich the examen parent matches the value id.\r\n * \r\n * Return a list of Matiere objects\r\n */\r\n\tpublic getEpreuves(idEpreuve: string, idExamen: string)\r\n\t{\r\n\t\treturn this.get(idEpreuve, idExamen);\r\n\t}\r\n}\r\n\r\n","import { Injectable }\tfrom '@angular/core';\r\nimport { Http }\t\t\tfrom '@angular/http';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\nimport { DataHttpService }\tfrom './dataHttp.service';\r\nimport { UserData }\t\t\tfrom '../../providers/user-data';\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { Etablissement } from '../../classes/etablissement.class';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class EtablissementHttpService extends DataHttpService\r\n{\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tconstructor(protected http: Http, protected userData: UserData)\r\n\t{\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('etablissement'));\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic addEtablissement(dataEtab: any): Observable\r\n\t{\r\n\t\tdataEtab.path = [];\r\n\t\treturn this.add(null, [], dataEtab);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic editEtablissement(dataEtab: any): Observable\r\n\t{\r\n\t\treturn this.edit(dataEtab);\r\n\t\t\r\n\t\t\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic getAllEtablissements(): Observable\r\n\t{\r\n\t\tthis.jOptionToken = \r\n\t\t\t{\r\n\t\t\t\tnodes:\tthis.userData.getRessources()\r\n\t\t\t};\r\n\t\treturn this.get();\r\n\t}\r\n\r\n\r\n}\r\n","import { Injectable }\tfrom '@angular/core';\r\nimport { Http }\t\t\tfrom '@angular/http';\r\n\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { DataHttpService }\tfrom './dataHttp.service';\r\nimport { Examen }\t\t\tfrom '../../classes/examen.class';\r\nimport { UserData }\t\t\tfrom '../../providers/user-data';\r\n\r\n\r\n@Injectable()\r\n\r\n\r\nexport class ExamenHttpService extends DataHttpService\r\n{\r\n\tprotected sToken:\t\t\tstring = 'idexamen';\r\n\tprotected sParentToken:\t\tstring = 'idsession';\r\n\t\r\n\t\r\n constructor(protected http: Http, protected userData: UserData)\r\n {\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('examen'));\r\n }\r\n\r\n\r\n /**\r\n * Add new examen in database from Examen object given in parameter\r\n */\r\n public addExamen(examen: any, parentPath: any[] = [])\r\n {\r\n examen.path = parentPath;\r\n return this.add(null, [], examen);\r\n }\r\n\r\n\r\n /**\r\n * Get all examens in database relative to user account and parameters given:\r\n * \r\n * -cascade: if false, return only examens objects, if true return Examens object with childs \r\n * (epreuves) in each objects\r\n * -idExamen: if this parameter is defined, return the Examen object corresponding to the value id\r\n * -idSession: if this parameter is defined (and if the parameter idExamen is not), return the Examen\r\n * objects wich the session parent matches the value id.\r\n *\r\n * Return a list of Examen objects\r\n */\r\n\tpublic getExamens(cascade: boolean, idExamen: string, idSession: string)\r\n\t{\r\n\r\n\t\tlet cascadeStr\t\t= cascade ? (cascade === true ? 'true' : 'false') : 'false';\r\n\t\tthis.jOptionToken\t= { \"cascade\": cascadeStr };\r\n\r\n\t\treturn this.get(idExamen, idSession);\r\n\t}\r\n\r\n}\r\n\r\n\r\n","import { Injectable } from '@angular/core';\r\nimport { Http, Headers, RequestOptions, ResponseContentType, URLSearchParams } from '@angular/http';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\nimport { Comment } \tfrom '../../classes/comment.class';\r\nimport { Note } \tfrom '../../classes/note.class';\r\nimport { File } \tfrom '../../classes/file.class';\r\n\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { DataHttpService }\t\tfrom './dataHttp.service';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\n\r\nimport * as _ from 'underscore';\r\n\r\n@Injectable()\r\n\r\n\r\nexport class FileHttpService extends DataHttpService\r\n{\r\n\r\n /**\r\n\t *\r\n\t */\r\n\tconstructor(protected http: Http, protected userData: UserData)\r\n\t{\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('file'));\r\n\t}\r\n\r\n /**\r\n *\r\n */\r\n public addFile(file: File): Observable\r\n {\r\n\t\tlet data = \r\n\t\t\t{\r\n\t\t\t\tfile: file.toJson()\r\n\t\t\t};\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// Ajouter la vérification de l'extention\r\n\t\t// ---------------------------------------\r\n\t\t// Ajoute la vérif du poids\r\n\t\t// ---------------------------------------\r\n\t\t// Thumbnail\r\n\t\t// ---------------------------------------\r\n\r\n return this.add(undefined, undefined, data);\r\n }\r\n\r\n\r\n /**\r\n *\r\n */\r\n public getFiles(subjectId: string = undefined, fileId: string = undefined): Observable\r\n {\r\n\t\tthis.jOptionToken = \r\n\t\t\t{\r\n\t\t\t\tidsubject:\tsubjectId,\r\n\t\t\t\tidfile:\t\tfileId\r\n\t\t\t};\r\n\r\n return this.get();\r\n }\r\n\r\n /**\r\n *\r\n * @param fileId\r\n */\r\n public removeFile(file: File): Observable\r\n {\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n let params: URLSearchParams = new URLSearchParams();\r\n params.set('files', JSON.stringify(file.toJson()));\r\n\r\n return this.http.get(this.getUrl() + 'delete', { headers: headers, search: params });\r\n }\r\n\r\n\r\n public updateFile(file: File, datas: any)\r\n {\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet data = \r\n\t\t{\r\n file:\tfile.toJson(),\r\n datas:\tdatas\r\n };\r\n\r\n\t\tlet credentials = \r\n\t\t{\r\n\t\t\tdata:\tdata\r\n\t\t};\r\n\r\n return this.http.post(this.getUrl() + 'update', JSON.stringify(credentials), { headers: headers });\r\n }\r\n\r\n\r\n public addFileNote(file: File, note: Note)\r\n {\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet datas = \r\n\t\t{\r\n file: file.toJson(),\r\n note: note.toJson()\r\n };\r\n\r\n\t\tlet credentials = \r\n\t\t{\r\n\t\t\tdata:\tdatas\r\n\t\t};\r\n\r\n return this.http.post(this.getUrl() + 'addNote', JSON.stringify(credentials), { headers: headers });\r\n }\r\n\r\n\r\n public addFileVersion(file: any)\r\n {\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet datas =\r\n\t\t\t{\r\n\t\t\t\tfile: file.toJson()\r\n\t\t\t};\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet credentials =\r\n\t\t\t{\r\n\t\t\t\tdata: datas\r\n\t\t\t};\r\n\r\n return this.http.post(this.getUrl() + 'addVersion', JSON.stringify(credentials), { headers: headers });\r\n }\r\n\r\n\r\n public downloadFile(file: File, typeFile: string = 'file')\r\n {\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n const headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tconst fileJson: any =\r\n\t\t{\r\n\t\t\tidsubject:\tfile.idSubject,\r\n\t\t\tid:\t\t\tfile.id\r\n\t\t};\r\n\r\n const params: URLSearchParams = new URLSearchParams();\r\n params.set('file', JSON.stringify(fileJson));\r\n params.set('type', typeFile);\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n const options = new RequestOptions(\r\n\t\t{\r\n\t\t\tsearch:\t\t\t\tparams,\r\n\t\t\theaders:\t\t\theaders,\r\n\t\t\twithCredentials:\ttrue,\r\n\t\t\tresponseType:\t\tResponseContentType.Blob\r\n\t\t});\r\n\r\n return this.http.get(this.getUrl() + 'download', options);\r\n }\r\n\r\n /**\r\n * Téléchargement d'un fichier à partir de son identifiant dans le système de stockage\r\n * du serveur\r\n * @param path\r\n */\r\n\tpublic downloadFromId(path: any)\r\n\t{\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet params: URLSearchParams = new URLSearchParams();\r\n\t\tparams.set('path', path);\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet options = new RequestOptions({\r\n\t\t\tsearch:\t\t\t\tparams,\r\n\t\t\theaders:\t\t\theaders,\r\n\t\t\twithCredentials:\ttrue,\r\n\t\t\tresponseType:\t\tResponseContentType.Blob\r\n\t\t});\r\n\r\n\t\treturn this.http.get(this.getUrl() + 'downloadFromId', options);\r\n\t}\r\n\r\n /**\r\n * Suppression d'un fichier à partir de son identifiant dans le système de stockage\r\n * du serveur\r\n * @param path\r\n */\r\n\tpublic deleteFromId(path: any)\r\n\t{\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet params: URLSearchParams = new URLSearchParams();\r\n\t\tparams.set('path', path);\r\n\r\n\t\tlet options = new RequestOptions(\r\n\t\t\t{\r\n\t\t\t\tsearch:\t\t\t\tparams,\r\n\t\t\t\theaders:\t\t\theaders,\r\n\t\t\t\twithCredentials:\ttrue,\r\n\t\t\t\tresponseType:\t\tResponseContentType.Blob\r\n\t\t\t});\r\n\r\n\t\treturn this.http.get(this.getUrl() + 'deleteFromId', options);\r\n\t}\r\n\r\n\r\n public downloadFiles(files: File[], password: string = null)\r\n {\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n headers.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet filesJson = _.map(files, function(file: any)\r\n\t\t\t{\r\n\t\t\t\treturn file.toJson();\r\n\t\t\t});\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let params: URLSearchParams = new URLSearchParams();\r\n params.set('files', JSON.stringify(filesJson));\r\n\r\n if (password)\r\n {\r\n params.set('password', password);\r\n }\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n let options = new RequestOptions({search: params, headers: headers, responseType: ResponseContentType.Blob });\r\n\r\n return this.http.get(this.getUrl() + 'downloadFiles', options);\r\n }\r\n}\r\n","import { Injectable }\tfrom '@angular/core';\r\nimport { Http }\t\t\tfrom '@angular/http';\r\n\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { DataHttpService }\t\tfrom './dataHttp.service';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\nimport { Session }\t\t\t\tfrom '../../classes/session.class';\r\n\r\n@Injectable()\r\nexport class SessionHttpService extends DataHttpService\r\n{\r\n\tprotected sToken:\t\tstring = 'idsession';\r\n\tprotected sParentToken:\tstring = 'idetab';\r\n\r\n\tconstructor(protected http: Http, protected userData: UserData)\r\n\t{\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('session'));\r\n\t}\r\n\r\n\r\n /**\r\n * Add new session in database from Session object given in parameter\r\n\t * Parents ids are given by the path parameter\r\n */\r\n\tpublic addSession(session: any, parentPath: any[] = [])\r\n\t{\r\n\t\tsession.path = parentPath;\r\n return this.add(null, [], session);\r\n\t}\r\n\r\n\r\n /**\r\n * Get all sessions in database relative to user account and parameters given:\r\n * \r\n * -cascade: if false, return only Sessions objects, if true return Sessions object with childs \r\n * (examens and epreuves) in each objects\r\n * -idSession: if this parameter is defined, return the Session object corresponding to the value id\r\n * -idEtab: if this parameter is defined (and if the parameter idSession is not), return the Sessions\r\n * objects wich the etablissement parent matches the value id.\r\n * \r\n * Return a list of Session objects\r\n */\r\n\tpublic getSessions(cascade: boolean, idSession: string, idEtab: string)\r\n\t{\r\n\t\tlet cascadeStr\t\t= cascade ? (cascade === true ? 'true' : 'false') : 'false';\r\n\t\tthis.jOptionToken\t= { \"cascade\": cascadeStr };\r\n\r\n\t\treturn this.get(idSession, idEtab);\r\n\t}\r\n\r\n\r\n}\r\n\r\n","import { Sujet }\t\tfrom '../../classes/sujet.class';\r\nimport { Comment } from '../../classes/comment.class';\r\nimport { Injectable }\tfrom '@angular/core';\r\nimport { Http, Headers }from '@angular/http';\r\n\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { DataHttpService }\t\tfrom './dataHttp.service';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\n\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class SujetHttpService extends DataHttpService\r\n{\r\n\tprotected sToken:\t\t\tstring = 'idsubject';\r\n\tprotected sParentToken:\t\tstring = 'idepreuve';\r\n\r\n\tconstructor(protected http: Http, protected userData: UserData)\r\n\t{\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('sujet'));\r\n\r\n\t}\r\n\r\n\r\n /**\r\n * Add new sujet in database from Sujet object given in parameter\r\n */\r\n\tpublic addSujet(sujet: Sujet)\r\n\t{\r\n\t\tlet data =\r\n\t\t\t{\r\n\t\t\t\tname:\t\tsujet.name,\r\n\t\t\t\tidepreuve:\tsujet.idMatiere,\r\n\t\t\t\ttype:\t\tsujet.type,\r\n\t\t\t\tnote:\t\tsujet.note,\r\n\t\t\t\tpath:\t\t['']\r\n\t\t\t};\r\n\r\n\t\treturn this.add(sujet, undefined, data);\r\n\t}\r\n\r\n\r\n /**\r\n * Get all subjects in database relative to user account and parameters given:\r\n *\r\n * -idSujet: if this parameter is defined, return the Sujet object corresponding to the value id\r\n * -idEpreuve: if this parameter is defined (and if the parameter idSujet is not), return the Sujet\r\n * objects wich the epreuve parent matches the value id.\r\n *\r\n * Return a list of Sujet objects\r\n */\r\n\tpublic getSujets(idSujet: string, idEpreuve: string)\r\n\t{\r\n\t\treturn this.get(idSujet, idEpreuve);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Add new comment to subject in database.\r\n\t *\r\n\t * @param sujet: Sujet object in wich the comment will be added\r\n\t * @param comment: Comment object corresponding to the comment to add in database\r\n\t */\r\n\tpublic addCommentToSujet(sujet: Sujet, comment: Comment)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\tlet datas = \r\n\t\t\t{\r\n\t\t\t\tsubject: sujet.toJson(),\r\n\t\t\t\tcomment: comment.toJson()\r\n\t\t\t};\r\n\r\n\t\tlet credentials = \r\n\t\t\t{\r\n\t\t\t\tdata:\tdatas\r\n\t\t\t};\r\n\r\n\t\treturn this.http.post(this.getUrl() + 'addComment', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n\r\n\t/**\r\n\t * Add note to subject in database\r\n\t *\r\n\t * @param sujet: Sujet object in wich the note will be added\r\n\t * @param note: note wich will be added in database to given subject\r\n\t */\r\n\tpublic addNoteToSujet(sujet: Sujet, note: string)\r\n\t{\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet datas = \r\n\t\t\t{\r\n\t\t\t\tsubject:\tsujet.toJson(),\r\n\t\t\t\tnote:\t\tnote\r\n\t\t\t};\r\n\t\tlet credentials = \r\n\t\t\t{\r\n\t\t\t\tdata:\tdatas\r\n\t\t\t};\r\n\r\n\t\treturn this.http.post(this.getUrl() + 'addNote', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { Http, Headers, RequestOptions, ResponseContentType, URLSearchParams } from '@angular/http';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { Task } \t\t\t\tfrom '../../classes/task.class';\r\nimport { Comment } \t\t\t\tfrom '../../classes/comment.class';\r\nimport { DataHttpService }\t\tfrom './dataHttp.service';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\n\r\n@Injectable()\r\nexport class TaskHttpService extends DataHttpService\r\n{\r\n\r\n /**\r\n\t *\r\n\t */\r\n\tconstructor(protected http: Http, protected userData: UserData)\r\n\t{\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('task'));\r\n\t}\r\n\r\n\tpublic getTask(sessionId: string, examenId: string = '', epreuveId: string = '')\r\n\t{\r\n\t\tthis.jOptionToken = \r\n\t\t{\r\n\t\t\tsessionId:\tsessionId,\r\n\t\t\texamenId:\texamenId,\r\n\t\t\tepreuveId:\tepreuveId\r\n\t\t};\r\n\r\n\t\treturn this.get();\r\n\t}\r\n\r\n\r\n\r\n\tpublic addTask(task: Task)\r\n\t{\r\n\t\tlet data = \r\n\t\t{\r\n\t\t\ttask: task.toJson()\r\n\t\t};\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\treturn this.add(undefined, undefined, data);\r\n\t}\r\n\r\n\r\n\tpublic deleteTask(task: Task)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet params: URLSearchParams = new URLSearchParams();\r\n\t\tparams.set('task', JSON.stringify(task.toJson()));\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet options = new RequestOptions({ search: params, headers: headers });\r\n\r\n\t\treturn this.http.get(this.getUrl() + 'delete', options);\r\n\t}\r\n\t\r\n\r\n\tpublic updateTask(task: Task, newDatas: any)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet data = \r\n\t\t{\r\n\t\t\ttask:\ttask.toJson(),\r\n\t\t\tdatas:\tnewDatas\r\n\t\t};\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet credentials = \r\n\t\t{\r\n\t\t\tdata:\tdata\r\n\t\t};\r\n\r\n\t\treturn this.http.post(this.getUrl() + 'update', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n\r\n\tpublic addTaskComment(task: Task, newComment: Comment)\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet data = \r\n\t\t{\r\n\t\t\ttask:\t\ttask.toJson(),\r\n\t\t\tcomment: \tnewComment.toJson()\r\n\t\t};\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\r\n\t\tlet credentials = \r\n\t\t{\r\n\t\t\tdata:\tdata\r\n\t\t};\r\n\r\n\t\treturn this.http.post(this.getUrl() + 'addComment', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n}\r\n","import { Injectable }\t\tfrom '@angular/core';\r\nimport { Http, Headers }\tfrom '@angular/http';\r\n\r\nimport { CreationHttpService }\tfrom './creationHttp.service';\r\nimport { DataHttpService }\t\tfrom './dataHttp.service';\r\nimport { UserData }\t\t\t\tfrom '../../providers/user-data';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class UserHttpService extends DataHttpService\r\n{\r\n\tprotected sToken:\t\t\tstring = 'idsubject';\r\n\tprotected sParentToken:\t\tstring = 'idepreuve';\r\n \r\n\r\n\tconstructor(protected http: Http, protected userData: UserData)\r\n\t{\r\n\t\tsuper(http, userData, CreationHttpService.getPathByWebServiceName('user'));\r\n\t}\r\n\r\n\r\n /**\r\n * Get all users in the creation app server and their rights\r\n */\r\n\tpublic getAllUsers(): Observable\r\n\t{\r\n\t\treturn this.get();\r\n\t}\r\n\r\n\r\n /**\r\n * Update informations and rights for a set of users given\r\n */\r\n\tpublic updateUser(dataUser: any): Observable\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\t\tlet credentials = \r\n\t\t{\r\n\t\t\tdata: dataUser\r\n\t\t};\r\n\t\t// Sale\r\n\t\treturn this.http.post(this.getUrl() + 'update', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Get current user datas from database\r\n\t */\r\n\tpublic getCurrentUser(): Observable\r\n\t{\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\r\n\t\treturn this.http.get(this.getUrl() + 'getCurrent', { headers: headers });\r\n\t}\r\n\r\n /**\r\n * Update informations and rights for a set of users given\r\n */\r\n\tpublic updateCurrentUser(dataUser: any): Observable\r\n\t{\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet headers = new Headers();\r\n\t\theaders.append('Content-Type', 'application/json');\r\n\t\theaders.append('Authorization', 'Bearer ' + this.userData.getTokenKey());\r\n\t\tlet credentials = \r\n\t\t{\r\n\t\t\tdata: dataUser\r\n\t\t};\r\n\t\t// Sale\r\n\t\treturn this.http.post(this.getUrl() + 'updatecurrent', JSON.stringify(credentials), { headers: headers });\r\n\t}\r\n\r\n\r\n}\r\n","\r\nimport { Injectable } from '@angular/core';\r\n\r\n@Injectable()\r\n\r\nexport class VaultHttpService\r\n{\r\n\r\n\r\n/* Local*/\r\n\r\n\r\n/*\r\nprivate static useApiUrl = true; // l'api ce trouve, sur le serveur de connexion, a part si vrai si dessous\r\nprivate static useChatUrl = true; // idem on peut deporter le chat\r\nprivate static chatSecure = false; // http ou https (si pas automatique)\r\nprivate static apiBehindProxy = false; // proxy = rajouter un chemin\r\nprivate static chatBehindProxy = false;\t // proxy = rajouter un chemin\r\nprivate static apiUrl = 'http://192.168.0.21:8002'; // http ou https, url de l'api et port si besoin'\r\nprivate static apiPath = '';\r\nprivate static chatUrl = '192.168.0.21';\r\nprivate static chatPath = '/creation/socketcluster/';\r\nprivate static chatPort = '8002';\r\n*/\r\n//\tprivate static useApiUrl:\t\tboolean = true; // l'api ce trouve, sur le serveur de connexion, a part si vrai si dessous\r\n//\tprivate static useChatUrl:\t\tboolean = true; // idem on peut deporter le chat\r\n//\tprivate static chatSecure:\t\tboolean = true; // http ou https (si pas automatique)\r\n//\tprivate static apiBehindProxy:\tboolean = true; // proxy = rajouter un chemin\r\n//\tprivate static chatBehindProxy: boolean = true;\t // proxy = rajouter un chemin\r\n//\tprivate static apiUrl:\t\t\tstring\t= \"https://vault.viatique.com\"; // http ou https, url de l'api et port si besoin'\r\n//\tprivate static apiPath:\t\t\tstring\t= \"\";\r\n//\tprivate static chatUrl:\t\t\tstring\t= 'vault.viatique.com';\r\n//\tprivate static chatPath:\t\t\tstring\t= \"/socketcluster/\";\r\n// private static chatPort:\t\t\tstring\t= \"443\";\r\n\r\n\r\n\t/* Prod*/\r\n\tprivate static useApiUrl:\t\tboolean = true; // l'api ce trouve, sur le serveur de connexion, a part si vrai si dessous\r\n\tprivate static useChatUrl:\t\tboolean = false; // idem on peut deporter le chat\r\n\tprivate static chatSecure:\t\tboolean = false; // http ou https (si pas automatique)\r\n\tprivate static apiBehindProxy:\tboolean = true; // proxy = rajouter un chemin\r\n\tprivate static chatBehindProxy: boolean = true;\t // proxy = rajouter un chemin\r\n\tprivate static apiUrl:\t\t\tstring\t= \"https://vault.viatique.com\"; // http ou https, url de l'api et port si besoin'\r\n\tprivate static apiPath:\t\t\tstring\t= \"\";\r\n\tprivate static chatUrl:\t\t\tstring\t= 'vault.viatique.com';\r\n\tprivate static chatPath:\t\tstring\t= \"/socketcluster/\";\r\n\tprivate static chatPort:\t\tstring\t= \"443\";\r\n\r\n\t/* Confirugation sur machine isolée*/\r\n\t/*\r\n\tprivate static useApiUrl:\t\tboolean = true; // l'api ce trouve, sur le serveur de connexion, a part si vrai si dessous\r\n\tprivate static useChatUrl:\t\tboolean = false; // idem on peut deporter le chat\r\n\tprivate static chatSecure:\t\tboolean = false; // http ou https (si pas automatique)\r\n\tprivate static apiBehindProxy:\tboolean = true; // proxy = rajouter un chemin\r\n\tprivate static chatBehindProxy: boolean = true;\t // proxy = rajouter un chemin\r\n\tprivate static apiUrl:\t\t\tstring\t= \"http://vault.exatique.lan\"; // http ou https, url de l'api et port si besoin'\r\n\tprivate static apiPath:\t\t\tstring\t= \"\";\r\n\tprivate static chatUrl:\t\t\tstring\t= 'vault.viatique.com';\r\n\tprivate static chatPath:\t\tstring\t= \"/socketcluster/\";\r\n\tprivate static chatPort:\t\tstring\t= \"443\";\r\n\t*/\r\n\r\n /**\r\n\t * Retourne l'url de l'api (normalement sur le meme serveur que le serveur http)\r\n\t */\r\n\tpublic static getAPIUrl(): string\r\n\t{\r\n\t\tif (VaultHttpService.useApiUrl)\r\n\t\t{\r\n\t\t\tif (VaultHttpService.apiBehindProxy)\r\n\t\t\t{\t\t\t\t\r\n\t\t\t\treturn VaultHttpService.absolute(VaultHttpService.apiUrl, VaultHttpService.apiPath);\r\n\t\t\t}\t\t\t\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn VaultHttpService.apiUrl;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (VaultHttpService.apiBehindProxy)\r\n\t\t\t{\r\n\t\t\t\treturn VaultHttpService.absolute(window.location.origin, VaultHttpService.apiPath);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treturn window.location.origin;\r\n\t\t\t}\r\n\t\t}\r\n }\r\n\r\n\r\n /**\r\n\t * Retourne l'url du chat (normalement sur le meme serveur que le serveur http)\r\n\t */\r\n\tpublic static getChatUrl(): string\r\n\t{\r\n\t\tif (VaultHttpService.useChatUrl)\r\n\t\t{\r\n\t\t\treturn VaultHttpService.chatUrl;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn window.location.hostname;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic static getChatPort(): string\r\n\t{\r\n\t\tif (VaultHttpService.useChatUrl)\r\n\t\t{\r\n\t\t\treturn VaultHttpService.chatPort;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn window.location.port;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic static getChatSecure(): boolean\r\n\t{\r\n\t\tlet bReturn;\r\n\t\tif (VaultHttpService.useChatUrl)\r\n\t\t{\r\n\t\t\tbReturn = VaultHttpService.chatSecure;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tbReturn = window.location.protocol === 'https:';\r\n\t\t}\r\n\t\treturn bReturn;\r\n }\r\n\r\n\r\n public static getChatPath(): string\r\n\t{\r\n\t\tif (VaultHttpService.chatBehindProxy)\r\n\t\t{\r\n\t\t\treturn VaultHttpService.chatPath;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn '/socketcluster/';\r\n\t\t}\r\n\t}\r\n\r\n\r\n /**\r\n * Ajoute une url a l'adresse en gérant le /\r\n * @param base\r\n * @param relative\r\n */\r\n\tpublic static absolute(...args: string[]): string\r\n\t{\r\n\t\tlet join = [].slice.call(args, 0).join('/');\r\n\t\treturn VaultHttpService.normalize(join);\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Retourne l'url du service dans l'api\r\n\t */\r\n\tpublic static getPathByWebServiceName(name: string)\r\n\t{\r\n\t\tlet sReturn = '';\r\n\r\n\t\t// Si c'est en prod on va avoir besoin du suffixe\r\n\t\t//sReturn = '/creation';\r\n\r\n\t\t// Et encore on pourrait ajouter le \"name\" à la suite sans passer par le switch ... mais au cas ou je laisse\r\n\t\tswitch (name)\r\n\t\t{\r\n\t\t\tcase 'auth':\r\n\t\t\t\tsReturn += '/api/v1/auth/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'refresh':\r\n\t\t\t\tsReturn += '/api/v1/auth/refresh';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'chat':\r\n\t\t\t\tsReturn += '/api/v1/chat/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'epreuve':\r\n\t\t\t\tsReturn += '/api/v1/epreuve/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'etablissement':\r\n\t\t\t\tsReturn += '/api/v1/etablissement/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'examen':\r\n\t\t\t\tsReturn += '/api/v1/examen/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'file':\r\n\t\t\t\tsReturn += '/api/v1/file/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'filesend':\r\n\t\t\t\tsReturn += '/api/v1/file/send/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'filesendforpreview':\r\n\t\t\t\tsReturn += '/api/v1/file/sendForPreview/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'sendToConvert':\r\n\t\t\t\tsReturn += '/api/v1/file/sendToConvert/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'session':\r\n\t\t\t\tsReturn += '/api/v1/session/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'sujet':\r\n\t\t\t\tsReturn += '/api/v1/sujet/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'task':\r\n\t\t\t\tsReturn += '/api/v1/task/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tcase 'user':\r\n\t\t\t\tsReturn += '/api/v1/user/';\r\n\t\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\treturn sReturn;\r\n }\r\n\r\n /**\r\n * Fonction interne pour normaliser une url\r\n * @param str\r\n * @pzaram searchString\r\n */\r\n\tprivate static startsWith(str: string, searchString: string): boolean\r\n\t{\r\n\t\treturn str.substr(0, searchString.length) === searchString;\r\n\t}\r\n\r\n\r\n /**\r\n * Normalise une url\r\n * @param str\r\n */\r\n\tprivate static normalize(str: string): string\r\n\t{\r\n\r\n\t\tif (VaultHttpService.startsWith(str, 'file://'))\r\n\t\t{\r\n\t\t\t// 3 slash pour file protocol\r\n\t\t\tstr = str.replace(/(\\/{0,3})\\/*/g, '$1');\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// au minimum 2 apres le protocole\r\n\t\t\tstr = str.replace(/:\\//g, '://');\r\n\r\n\t\t\t// enlever les slash en trop\r\n\t\t\tstr = str.replace(/([^:\\s\\%\\3\\A])\\/+/g, '$1/');\r\n\t\t}\r\n\r\n\t\t// enlever les slash de fin avant param\r\n\t\tstr = str.replace(/\\/(\\?|&|#[^!])/g, '$1');\r\n\r\n\t\t// remplace ? par &\r\n\t\tstr = str.replace(/(\\?.+)\\?/g, '$1&');\r\n\r\n\t\treturn str;\r\n\t}\r\n\r\n}\r\n","\r\nimport { Injectable } from '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\nimport { SocketService }\t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData }\t\t\t\t\tfrom '../providers/user-data';\r\n\r\n@Injectable()\r\n/**\r\n *\r\n */\r\nexport class MessagesService\r\n{\r\n private socket: any = undefined;\r\n\r\n\r\n /**\r\n\t *\r\n\t */\r\n constructor(private socketService:\tSocketService,\r\n\t\t\t\tprivate userData:\t\tUserData)\r\n {\r\n this.socket = socketService.getSocketConnection();\r\n }\r\n\r\n\r\n /**\r\n *\r\n * @param idElement\r\n * @param bucket\r\n */\r\n public getMessages(idElement: any, bucket: string)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n {\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'messages',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tkey:\tidElement,\r\n\t\t\t\t\t\t\tbucket: bucket\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Requete permettant dz récupéré les commentaires lus par l'utilisateur\r\n * pour un élément donné (tache, fichier, sujet ou noeud)\r\n * @param idElement\r\n */\r\n\tpublic getReadedMessages(idElement: string, bucket: string)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\tcmd: 'messages.readed',\r\n\t\t\t\t\t\targs:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tkey:\tidElement,\r\n\t\t\t\t\t\t\tbucket: idElement\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Récupère les messages appartenant à un élément non lu\r\n * A utiliser plutôt qu'un count\r\n * @param idElement\r\n * @param bucket\r\n * @param dateMessageFrom\r\n * @param limite\r\n */\r\n public getLastUnread(idElement: string, bucket: string, dateMessageFrom: any, limite: number)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n {\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tiam: 'c-c',\r\n\t\t\t\t\t\tname: this.userData.getUserId(),\r\n\t\t\t\t\t\twhat: SocketWhat.info,\r\n\t\t\t\t\t\tcmd: 'messages',\r\n\t\t\t\t\t\targs:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tkey:\t\tidElement,\r\n\t\t\t\t\t\t\tbucket:\t\tidElement,\r\n\t\t\t\t\t\t\tfromDate:\tdateMessageFrom,\r\n\t\t\t\t\t\t\tlimit:\t\tlimite\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Flague le commentaire comme lu\r\n * @param idElement\r\n * @param bucket\r\n * @param idMessage\r\n * @param typeMessage\r\n * @param notification\r\n */\r\n public setMessageRead(idElement: string, bucket: string, idMessage: string, typeMessage: string, notification: string[])\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n {\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tiam: 'c-c',\r\n\t\t\t\t\t\tname: this.userData.getUserId(),\r\n\t\t\t\t\t\twhat: SocketWhat.info,\r\n\t\t\t\t\t\tcmd: 'messages.read',\r\n\t\t\t\t\t\targs:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tkey:\t\tidElement,\r\n\t\t\t\t\t\t\tbucket:\t\tidElement,\r\n\t\t\t\t\t\t\tsub:\t\ttypeMessage,\r\n\t\t\t\t\t\t\twhen:\t\tidMessage,\r\n\t\t\t\t\t\t\tnotifier:\tnotification\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Flague le commentaire comme recu\r\n * @param idElement\r\n * @param bucket\r\n * @param idMessage\r\n * @param typeMessage\r\n * @param notification\r\n */\r\n public setMessageAck(idElement: string, bucket: string, idMessage: string, typeMessage: string, notification: string[])\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n {\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tiam: 'c-c',\r\n\t\t\t\t\t\tname: this.userData.getUserId(),\r\n\t\t\t\t\t\twhat: SocketWhat.info,\r\n\t\t\t\t\t\tcmd: 'messages.ack',\r\n\t\t\t\t\t\targs:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tkey:\t\tidElement,\r\n\t\t\t\t\t\t\tbucket:\t\tidElement,\r\n\t\t\t\t\t\t\tsub:\t\ttypeMessage,\r\n\t\t\t\t\t\t\twhen:\t\tidMessage,\r\n\t\t\t\t\t\t\tnotifier:\tnotification\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n }\r\n });\r\n\t}\r\n\t\r\n\r\n /**\r\n * Récupère le nombre de messages appartenant à un élémént\r\n * @param idElement\r\n * @param bucket\r\n * @param dateMessageFrom\r\n */\r\n public getMessagesCount(idElement: string, bucket: string, dateMessageFrom: any)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n {\r\n if (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tiam: 'c-c',\r\n\t\t\t\t\t\tname: this.userData.getUserId(),\r\n\t\t\t\t\t\twhat: SocketWhat.info,\r\n\t\t\t\t\t\tcmd: 'messages.count',\r\n\t\t\t\t\t\targs:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tkey:\t\tidElement,\r\n\t\t\t\t\t\t\tbucket:\t\tidElement,\r\n\t\t\t\t\t\t\tfromDate:\tdateMessageFrom,\r\n\t\t\t\t\t\t\tsub:\t\t'C'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n }\r\n });\r\n }\r\n\r\n\t\r\n /**\r\n *\r\n */\r\n public sendMessage(nameBucket: string, key: string, type: string, datas: any, notifiers: string[] = [])\r\n {\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tiam: 'c-c',\r\n\t\t\t\t\t\tname: this.userData.getUserId(),\r\n\t\t\t\t\t\twhat: SocketWhat.info,\r\n\t\t\t\t\t\tcmd: 'messages.set',\r\n\t\t\t\t\t\targs:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tbucket: nameBucket,\r\n\t\t\t\t\t\t\tkey,\r\n\t\t\t\t\t\t\tsub: type,\r\n\t\t\t\t\t\t\tdatas\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tif (notifiers.length > 0)\r\n {\r\n data.args.notifier = notifiers;\r\n }\r\n\r\n socket.emit('create', data);\r\n }\r\n });\r\n }\r\n}\r\n","import { Injectable } from '@angular/core';\r\n\r\nimport { SocketService }\t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData }\t\t\t\t\tfrom '../providers/user-data';\r\nimport { EncryptService }\t\t\tfrom '../services/encrypt.service';\r\n\r\n\r\n@Injectable()\r\n\r\n\r\nexport class PassationService\r\n{\r\n\tconstructor(\r\n\t\tprivate socketService:\tSocketService,\r\n\t\tprivate userData:\t\tUserData,\r\n\t\tprivate encryptService: EncryptService)\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\tpublic createPassation(datas: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd':\t'passation',\r\n\t\t\t\t\t\t'args': datas\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic getPassations()\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'passations',\r\n\t\t\t\t\t\t'args': {}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic getCandidatsPassations(idPassation: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'candidatsPassations',\r\n\t\t\t\t\t\t'args': {\r\n\t\t\t\t\t\t\tidPassation: idPassation\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic updatePassation(idPassation: any, datasToUpdate: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd':\t'passation',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpassationId:\tidPassation,\r\n\t\t\t\t\t\t\tdatasToUpdate:\tdatasToUpdate\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic sendPassation(passation: any, decryptedFiles: any, subjectsToAdd: any, passwordSelected: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'sendPassation',\r\n\t\t\t\t\t'args': \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttoken:\t\t\t\tthis.userData.getTokenKey(),\r\n\t\t\t\t\t\tpassation:\t\t\tpassation,\r\n\t\t\t\t\t\tdecryptedFiles:\t\tdecryptedFiles,\r\n\t\t\t\t\t\tsubjectsToAdd:\t\tsubjectsToAdd,\r\n\t\t\t\t\t\tpasswordSelected:\tpasswordSelected\r\n\t\t\t\t\t} \r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic importResultsPassation(passation: any, moDecryptedFiles: any, needRecalculate: boolean = false)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'importResultsPassations2',\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttoken:\t\t\t\tthis.userData.getTokenKey(),\r\n\t\t\t\t\t\tpassation:\t\t\tpassation,\r\n\t\t\t\t\t\tdecryptedFiles: \tmoDecryptedFiles,\r\n\t\t\t\t\t\tmustRecalculate: \tneedRecalculate\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\tsocket.emit('read', data);\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic importEmargementsPassation(passation: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (passation)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.mail,\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'candidatsEmargement',\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttoken: this.userData.getTokenKey(),\r\n\t\t\t\t\t\tpassation: passation\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic decodePassationFiles(passation: any, subjectsToEncode: any[]): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tconst resultEncoding: \tany \t\t\t= {};\r\n\t\t\tconst promises: \t\tPromise[] \t= [];\r\n\r\n\t\t\tlet idFileMain: any;\r\n\t\t\tlet idFileSec: \tany;\r\n\r\n\t\t\tif (passation && passation.datas && passation.datas.idFileMain)\r\n\t\t\t{\r\n\t\t\t\tidFileMain = passation.datas.idFileMain;\r\n\t\t\t}\r\n\r\n\t\t\tif (passation && passation.datas && passation.datas.idFileSec)\r\n\t\t\t{\r\n\t\t\t\tidFileSec = passation.datas.idFileSec;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tfor (const subject of subjectsToEncode)\r\n\t\t\t{\r\n\t\t\t\tlet qcmFileSubject: any;\r\n\r\n\t\t\t\t// En fonction du type de sujet (principal ou secondaire) on récupère le\r\n\t\t\t\t// fichier qui a été défini comme fichier QCM\r\n\t\t\t\tif (idFileMain)\r\n\t\t\t\t{\r\n\t\t\t\t\tqcmFileSubject = subject.pj.find((pj: any) => pj.id === idFileMain);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (qcmFileSubject === undefined && idFileSec)\r\n\t\t\t\t{\r\n\t\t\t\t\tqcmFileSubject = subject.pj.find((pj: any) => pj.id === idFileSec);\r\n\t\t\t\t}\r\n\r\n\t\t\t\t// Si le fichier n'est pas trouvé en on prend par défaut le premier fichier avec une extension JSON\r\n\t\t\t\tif (qcmFileSubject === undefined)\r\n\t\t\t\t{\r\n\t\t\t\t\tqcmFileSubject = subject.pj.find((pj: any) => pj.extension === 'json');\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (qcmFileSubject)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet filesToInclude: any[] = [];\r\n\t\t\t\t\tfilesToInclude.push(qcmFileSubject);\r\n\r\n\t\t\t\t\tif (qcmFileSubject.path && qcmFileSubject.path !== '')\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tconst jsonPath = JSON.parse(qcmFileSubject.path);\r\n\t\t\t\t\t\tconst attachedFileQcmIds = jsonPath.attachedFiles;\r\n\r\n\t\t\t\t\t\tif (attachedFileQcmIds)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tconst attachedFileQcm = subject.pj.filter((pj: any) => attachedFileQcmIds.includes(pj.id));\r\n\t\t\t\t\t\t\tfilesToInclude = filesToInclude.concat(attachedFileQcm);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tresultEncoding[subject.id] =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tidFile:\t\t\t[],\r\n\t\t\t\t\t\tdecryptedAes:\t[]\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\t\tfor (const pj of filesToInclude)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t// On ne décrypte que les fichiers que ne sont pas en corbeille\r\n\t\t\t\t\t\tif (pj.deleted === false)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpromises.push(this._decryptAesKeysForEpreuve(pj));\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tPromise.all(promises).then(result =>\r\n\t\t\t{\r\n\t\t\t\tfor (const res of result)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (res.idSubject && res.idFile)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tresultEncoding[res.idSubject].idFile.push(res.idFile);\r\n\t\t\t\t\t\tresultEncoding[res.idSubject].decryptedAes.push(res.decryptedAes);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tresolve(resultEncoding);\r\n\r\n\t\t\t}).catch((error) =>\r\n\t\t\t{\r\n\t\t\t\treject(error);\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tprivate _decryptAesKeysForEpreuve(pj: any): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tif (pj.encryptedAesKeys && pj.encryptedAesKeys.length > 0)\r\n\t\t\t{\r\n\t\t\t\tthis.encryptService.decryptData(pj.encryptedAesKeys[0].val).then((aesDecoded: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tlet result: any =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tidSubject:\t\tpj.idSubject,\r\n\t\t\t\t\t\t\tidFile:\t\t\tpj.id,\r\n\t\t\t\t\t\t\tdecryptedAes:\taesDecoded\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\tresolve(result);\r\n\r\n\t\t\t\t}).catch(error =>\r\n\t\t\t\t{\r\n\t\t\t\t\treject();\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\treject();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport { SocketService } from './socket.service';\r\nimport { ISocketData, SocketWhat } from '../models/message.model';\r\nimport { UserData } from '../providers/user-data';\r\n\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n * \r\n */\r\nexport class RoomService\r\n{\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tconstructor(public socketService: SocketService,\r\n\t\tprivate userData: UserData)\t\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n\tpublic getMessages(roomId: any)\r\n\t{\r\n\t\t//return this.etablissementHttpService.addEtablissement(dataEtab.toJson()).share();\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\t\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'msg',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// Todo faire un truc moins honteux que ça\r\n\t\t\t\t\t\t\tkey: roomId,\r\n\t\t\t\t\t\t\tbucket: 'rooms',\r\n\t\t\t\t\t\t\tlimit: 100\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\t\r\n\t\r\n\tpublic getMessagesBucket(roomId: any, ticks = '', limit = 100, isMore = 'false')\r\n\t{\r\n\t\t\r\n\t\t\r\n\t\tlet args = \r\n\t\t{\r\n\t\t\t// Todo faire un truc moins honteux que ça\r\n\t\t\ttoDate:\t\tticks,\r\n\t\t\tkey:\t\troomId,\r\n\t\t\tbucket:\t\t'rooms',\r\n\t\t\tlimit:\t\tlimit,\r\n\t\t};\r\n\t\t\r\n\r\n\t\t\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam':\t\t'c-c',\r\n\t\t\t\t\t\t'name':\t\tthis.userData.getUserId(),\r\n\t\t\t\t\t\t'what':\t\tSocketWhat.info,\r\n\t\t\t\t\t\t'cmd':\t\t'msg',\r\n\t\t\t\t\t\t'idc':\t\tisMore,\r\n\t\t\t\t\t\t'args':\t\targs\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * \r\n\t */\r\n\tpublic getNomberOfUnreadedMessage(roomId: any)\r\n\t{\r\n\t\t//return this.etablissementHttpService.addEtablissement(dataEtab.toJson()).share();\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\t\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'msg.unread',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t// Todo faire un truc moins honteux que ça\r\n\t\t\t\t\t\t\tchan: '*room::' + roomId + '::priv'\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n}\r\n","// Angular\r\nimport { Injectable } from '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n// Other\r\nimport { SessionHttpService }\t\tfrom './http/sessionHttp.service';\r\nimport { Session }\t\t\t\t\tfrom '../classes/session.class';\r\nimport { Comment }\t\t\t\t\tfrom '../classes/comment.class';\r\nimport { SocketService } \t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } \t\t\t\tfrom '../providers/user-data';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class SessionService\r\n{\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(private sessionHttpService: SessionHttpService,\r\n\t\t\t public socketService: SocketService,\r\n\t\t\t\tprivate userData: UserData)\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n /**\r\n * Add new session in database from Session object given in parameter\r\n\t * Parents ids are given by the parentPath parameter\r\n */\r\n\tpublic addSession(dataSession: Session, parentPath: any[] = [])\r\n\t{\r\n\t\tlet datas \t\t= dataSession.toJson();\r\n\t\tdatas.idparents = parentPath;\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t\t'args': \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\ttype: 'session',\r\n\t\t\t\t\t\t\tnode: datas\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Update session in database from Session object given in parameter\r\n\t * @param dataSession\r\n\t */\r\n\tpublic editSession(dataSession: Session)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'node',\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttype: \t'session',\r\n\t\t\t\t\t\tnode:\tdataSession.toJson()\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Get all sessions in database relative to user account and parameters given:\r\n *\r\n * -cascade: if false, return only Sessions objects, if true return Sessions object with childs\r\n * (examens and epreuves) in each objects\r\n * -idSession: if this parameter is defined, return the Session object corresponding to the value id\r\n * -idEtab: if this parameter is defined (and if the parameter idSession is not), return the Sessions\r\n * objects wich the etablissement parent matches the value id.\r\n *\r\n * Return a list of Session objects\r\n */\r\n\tpublic getSessions(cascade: boolean, idSession: string, idEtab: string, callback: (result: any) => void)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'node.info',\r\n\t\t\t\t\t'args': \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnode: \t\tidEtab,\r\n\t\t\t\t\t\tnodeOption: 'wc',\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.sessionHttpService.getSessions(cascade, idSession, idEtab).subscribe(res =>\r\n\t\t\t\t{\r\n\t\t\t\t\tlet resJson\t\t\t\t= res.json();\r\n\t\t\t\t\tlet sessions: Session[] = [];\r\n\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\t// ToComment\r\n\t\t\t\t\t// ---------------------------------------\r\n\t\t\t\t\tif (resJson.data && resJson.data.rows)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let row of resJson.data.rows)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (row)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tsessions.push(Session.fromJsonObject(row));\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tcallback(sessions);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n}\r\n\r\n\r\n","import { Injectable } from '@angular/core';\r\n\r\nimport { CreationHttpService } from './http/creationHttp.service';\r\nimport { ISocketData, SocketWhat } from '../models/message.model';\r\nimport { SCClientSocket } from 'socketcluster-client';\r\nimport { SCChannel } from 'sc-channel';\r\nimport { EventEmitter } from 'events';\r\nimport {Observable} from 'rxjs/Rx';\r\nimport { MatDialog }\t\t\t\t\t\t\t\tfrom '@angular/material';\r\n\r\ndeclare const require: any;\r\n\r\nlet socketCluster = require('socketcluster-client')\r\n\r\n\r\ninterface ISocketEvents\r\n{\r\n\t// Canaux par defaut hors room\r\n\ton(event: 'genericUpdates', listener: (data: any) => void): this; // Pour action globale\r\n\ton(event: 'accountUpdates', listener: (data: any) => void): this; // Action sur le compte\r\n\ton(event: 'user',\t\t\tlistener: (data: any) => void): this; // Action mail user (si 10machines, send sur les 10)\r\n\ton(event: 'machine',\t\tlistener: (data: any) => void): this; // Cible une seule machine en cours (multi onglet par contre)\r\n\ton(event: 'account',\t\tlistener: (data: any) => void): this; // Le compte (Etablissement)\r\n\r\n\t// Ecouteur générique\r\n\ton(event: 'create', listener: (data: any) => void): this;\r\n\ton(event: 'read',\tlistener: (data: any) => void): this;\r\n\ton(event: 'update', listener: (data: any) => void): this;\r\n\ton(event: 'delete', listener: (data: any) => void): this;\r\n\r\n\t// Ecouteur spécifique\r\n\ton(event: 'error',\t\t\t\tlistener: (data: any)\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'debug',\t\t\t\tlistener: (data: any)\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'authenticate',\t\tlistener: (data: any)\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'authStateChange',\tlistener: (old: any, news: any, signed: any)\t=> void): this;\r\n\ton(event: 'deauthenticate',\t\tlistener: ()\t\t\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'authTokenChange',\tlistener: (newtoken: any)\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'connect',\t\t\tlistener: ()\t\t\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'disconnect',\t\t\tlistener: ()\t\t\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'message_creation',\tlistener: (data: any)\t\t\t\t\t\t\t=> void): this;\r\n\r\n\ton(event: string, listener: (data: any) => void): this;\r\n}\r\n\r\n\r\n@Injectable()\r\n\r\n\r\nexport class SocketService extends EventEmitter implements ISocketEvents\r\n{\r\n\r\n\tpublic\troomsAGerer: any = undefined;\r\n\r\n\tprivate socket: any;\r\n//\tprivate processing: any\t\t= false;\r\n\tprivate timeOutSocket: any\t= undefined;\r\n//\tprivate roomsGet: boolean\t= false;\r\n\r\n\r\n\tconstructor(public dialog: MatDialog)\r\n\t{\r\n\t\tsuper();\r\n\t\tthis.init();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Initialisation du service socket\r\n\t */\r\n\tpublic init()\r\n\t{\r\n\t\tthis.roomsAGerer =\r\n\t\t\t[\r\n\t\t\t\t{\r\n\t\t\t\t\tname: '*soft::all::creation', state: 'nosub', watch: true,\r\n\t\t\t\t\tfct: this.watchGenericUpdates.bind(this), channel: undefined\r\n\t\t\t\t}\r\n\t\t\t];\r\n\t}\r\n\r\n\tpublic offMachine()\r\n\t{\r\n\t\tthis.socket.off('marchine');\r\n\t}\r\n\r\n\t/**\r\n\t * Cree le socket authentifie ou pas , pas d'http\r\n\t */\r\n\tpublic getSocketConnection(): Observable\r\n\t{\r\n\t\tconst observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tif (this.socket)\r\n\t\t\t{\r\n\t\t\t\tif (this.socket.state)\r\n\t\t\t\t{\r\n\t\t\t\t\t//retourne le socket s'il est ouvert (peut etre non auth)\r\n\t\t\t\t\tif (this.socket.state === SCClientSocket.OPEN)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobserver.next(this.socket);\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// en cours de connexion\r\n\t\t\t\t\tif (this.socket.state === SCClientSocket.CONNECTING)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tobserver.next(undefined);\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// ou deco\r\n\t\t\t\t\tif (this.socket.state === SCClientSocket.CLOSED)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.socket.connect();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\r\n\t\t\t\tconst chatUrl \t\t= CreationHttpService.getChatUrl();\r\n\t\t\t\tconst chatSecure \t= CreationHttpService.getChatSecure();\r\n\t\t\t\tconst chatPath \t\t= CreationHttpService.getChatPath();\r\n\t\t\t\tconst chatPort \t\t= CreationHttpService.getChatPort();\r\n\r\n\t\t\t\tif (chatUrl !== undefined && chatSecure !== undefined && chatPath !== undefined && chatPort !== undefined)\r\n\t\t\t\t{\r\n\t\t\t\t\t// Pas de socket, on cree un\r\n\t\t\t\t\tthis.socket = socketCluster.connect({\r\n\t\t\t\t\t\thostname:\t\tchatUrl,\r\n\t\t\t\t\t\tsecure:\t\t\tchatSecure,\r\n\t\t\t\t\t\tpath:\t\t\tchatPath,\r\n\t\t\t\t\t\tautoreconnect:\ttrue,\r\n\t\t\t\t\t\tport:\t\t\tchatPort\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tobserver.next(this.socket);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tobserver.next(undefined);\r\n\t\t\t\t\treturn;\r\n\t\t\t\t}\r\n\r\n\t\t\t}\r\n\r\n\t\t\tthis.socket.off('authenticate');\r\n\t\t\tthis.socket.off('authStateChange');\r\n\t\t\tthis.socket.off('deauthenticate');\r\n\t\t\tthis.socket.off('authTokenChange');\r\n\t\t\tthis.socket.off('error');\r\n\t\t\tthis.socket.off('debug');\r\n\t\t\tthis.socket.off('connect');\r\n\t\t\tthis.socket.off('message_creation');\r\n\r\n\t\t\tthis.socket.off('create');\r\n\t\t\tthis.socket.off('read');\r\n\t\t\tthis.socket.off('update');\r\n\t\t\tthis.socket.off('delete');\r\n\t\t\tthis.socket.off('marchine');\r\n\t\t\tthis.socket.off();\r\n\r\n\t\t\tif (this.timeOutSocket)\r\n\t\t\t{\r\n\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t}\r\n\r\n\t\t\tthis.socket.on('authenticate', (old: any, news: any, signed: any) =>\r\n\t\t\t{\r\n\t\t\t\tthis.emit('authenticate', old, news, signed);\r\n\t\t\t});\r\n\r\n\r\n\t\t\tthis.socket.on('authStateChange', (old: any, news: any, signed: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (old && old.newState && old.newState === 'unauthenticated')\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.emit('deauthenticate');\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.emit('authStateChange', old, news, signed);\r\n\t\t\t});\r\n\r\n\r\n\t\t\tthis.socket.on('deauthenticate', () =>\r\n\t\t\t{\r\n\t\t\t\tthis.emit('deauthenticate');\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('authTokenChange', (newToken: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (!newToken)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.emit('deauthenticate');\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.emit('authTokenChange', newToken);\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('error', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t{\r\n\t\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t\t\tobserver.next(undefined);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (this.emit('error', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'error', data);\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('debug', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('debug', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'debug', data);\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('create', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('create', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'create', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.socket.on('read', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('read', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'read', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.socket.on('update', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('update', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'update', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.socket.on('delete', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('delete', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'delete', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.socket.on('connect', () =>\r\n\t\t\t{\r\n\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t{\r\n\t\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t\t}\r\n\t\t\t\tif (this.emit('connect') === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'connect');\r\n\t\t\t\t}\r\n\t\t\t\tobserver.next(this.socket);\r\n\t\t\t});\r\n\t\t\tthis.socket.on('message_creation', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t{\r\n\t\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t\t}\r\n\t\t\t\tif (this.emit('message_creation', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'message_creation');\r\n\t\t\t\t}\r\n\t\t\t\tobserver.next(this.socket);\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('disconnect', () =>\r\n\t\t\t{\r\n\t\t\t\tconsole.log(\"this.socket.on('disconnect', (data: any) =>this.socket.on('disconnect', (data: any) =>this.socket.on('disconnect', (data: any) =>\");\r\n\r\n\t\t\t\t//this.dialog.closeAll();\r\n\r\n\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t{\r\n\t\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t\t}\r\n\t\t\t\tif (this.emit('disconnect') === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'disconnect');\r\n\t\t\t\t}\r\n\t\t\t\tobserver.next(undefined);\r\n\t\t\t});\r\n\r\n\r\n\t\t\tthis.timeOutSocket = setTimeout(() =>\r\n\t\t\t{\r\n\t\t\t\t// this.dialog.closeAll();\r\n\r\n\t\t\t\tconsole.log('************Trop long on deco volontairement!');\r\n\t\t\t\tobserver.next(undefined);\r\n\t\t\t\tthis.logout();\r\n\t\t\t}, 10000);\r\n\r\n\t\t});\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t */\r\n\tpublic logout()\r\n\t{\r\n\t\tconsole.log('logout');\r\n\t\tif (this.socket && this.socket.state && this.socket.state === SCClientSocket.OPEN)\r\n\t\t{\r\n\t\t\tif (this.roomsAGerer)\r\n\t\t\t{\r\n\t\t\t\tfor (let room of this.roomsAGerer)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (room.channel)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\troom.channel.unwatch();\r\n\t\t\t\t\t\troom.channel.off();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// On enlève les écouteurs\r\n\t\t\t// ---------------------------------------\r\n\t\t\tthis.socket.off('authenticate');\r\n\t\t\tthis.socket.off('authStateChange');\r\n\t\t\tthis.socket.off('deauthenticate');\r\n\t\t\tthis.socket.off('authTokenChange');\r\n\t\t\tthis.socket.off('error');\r\n\t\t\tthis.socket.off('connect');\r\n\t\t\tthis.socket.off('message_creation');\r\n\r\n\t\t\tthis.socket.off('create');\r\n\t\t\tthis.socket.off('read');\r\n\t\t\tthis.socket.off('update');\r\n\t\t\tthis.socket.off('delete');\r\n\t\t\tthis.socket.off('machine');\r\n\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// Déconnexion et désauthentification\r\n\t\t\t// ---------------------------------------\r\n\t\t\tthis.socket.deauthenticate();\r\n\t\t\tthis.socket.disconnect();\r\n\t\t\tthis.socket.off();\r\n\t\t\tthis.roomsAGerer = null;\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic watchGenericUpdates(data: any)\r\n\t{\r\n\t\tif (super.emit('genericUpdates', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'genericUpdates', data);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic watchAccountUpdates(data: any)\r\n\t{\r\n\t\tif (super.emit('accountUpdates', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'accountUpdates', data);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic watchUser(data: any)\r\n\t{\r\n\t\tif (super.emit('user', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'user', data);\r\n\t\t}\r\n\t}\r\n\tpublic watchMachine(data: any)\r\n\t{\r\n\t\tif (super.emit('machine', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'machine', data);\r\n\t\t}\r\n\t}\r\n\tpublic watchAccount(data: any)\r\n\t{\r\n\t\tif (super.emit('account', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'account', data);\r\n\t\t}\r\n\t}\r\n\r\n\tpublic findRoomAGerer(name: string):any\r\n\t{\r\n\t\tif (this.roomsAGerer)\r\n\t\t{\r\n\t\t\tfor (let i = 0; i < this.roomsAGerer.length; i++)\r\n\t\t\t{\r\n\t\t\t\tif (this.roomsAGerer[i].name == name)\r\n\t\t\t\t\treturn i;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn -1;\r\n\t}\r\n\r\n\r\n\r\n\tpublic RoomLost()\r\n\t{\r\n\t\tlet time = Date.now() / 1000;\r\n\t\tif (this.roomsAGerer)\r\n\t\t{\r\n\t\t\t// on parcours toutes les rooms\r\n\t\t\tlet nb = 3;\r\n\t\t\tfor (let i = 0; i < this.roomsAGerer.length; i++)\r\n\t\t\t{\r\n\t\t\t\t// on passe a eta cnx perdue\r\n\t\t\t\tthis.roomsAGerer[i].state = 'lost';\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tpublic GererRoom()\r\n\t{\r\n\t\tlet time = Date.now() / 1000;\r\n\r\n\t\tif (this.roomsAGerer)\r\n\t\t{\r\n\t\t\t// on parcours toutes les rooms\r\n\t\t\tlet nb = 5;\r\n\t\t\tfor (let i = 0; i < this.roomsAGerer.length; i++)\r\n\t\t\t{\r\n\t\t\t\t// si on en trouve une non subscrite on lance le sub, et on sort\r\n\t\t\t\tif (this.roomsAGerer[i].state === 'nosub')\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.subscribe(this.socket, i);\r\n\t\t\t\t\t// nb a la fois\r\n\t\t\t\t\tif (nb < 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tnb--;\r\n\t\t\t\t}\r\n\t\t\t\t//pour les socket a l'etat lost (deco && a surveiller)\r\n\t\t\t\tif (this.roomsAGerer[i].state === 'lost')\r\n\t\t\t\t{\r\n\t\t\t\t\tlet channel = this.roomsAGerer[i].channel;\r\n\t\t\t\t\tthis.roomsAGerer[i].state = 'pending';\r\n\r\n\t\t\t\t\tif (channel.state === SCChannel.UNSUBSCRIBED)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tchannel.subscribe();\r\n\t\t\t\t\t\t// nb a la fois\r\n\t\t\t\t\t\tif (nb < 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tnb--;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t\t// si tout ca est ok\r\n\t\t\t// toutes les 10s (modulo sur date)\r\n\t\t\tif (time % 10)\r\n\t\t\t{\r\n\t\t\t\tif (this.roomsAGerer)\r\n\t\t\t\t{\r\n\t\t\t\t\t// on parcours toutes les rooms\r\n\t\t\t\t\tfor (let i = 0; i < this.roomsAGerer.length; i++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet value = this.roomsAGerer[i];\r\n\t\t\t\t\t\t//si le canal est connecté\r\n\t\t\t\t\t\tif (value.channel && value.channel.state === SCChannel.SUBSCRIBED)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet watchers = value.channel.watchers();\r\n\t\t\t\t\t\t\t// si pas de watcher on l'ajoute\r\n\t\t\t\t\t\t\tif (!watchers || watchers.length == 0)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvalue.channel.watch((data: any) => { value.fct(data); });\r\n\t\t\t\t\t\t\t\tvalue.state = 'watching';\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tprivate subscribe(socket: any, idx: number)\r\n\t{\r\n\t\tlet value = this.roomsAGerer[idx];\r\n\t\tif (!value)\r\n\t\t{\r\n\t\t\tconsole.log(idx, 'must be in table before subsribe');\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tvalue.state = 'pending';\r\n\r\n\t\tvalue.channel = socket.subscribe(value.name);\r\n\t\tvalue.channel.on('subscribe', () =>\r\n\t\t{\r\n\t\t\tconsole.log('Subscribre to', value.name);\r\n\t\t\tif (value.fct)\r\n\t\t\t{\r\n\t\t\t\tvalue.channel.watch((data: any) => { value.fct(data); });\r\n\t\t\t\tvalue.state = 'watching';\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tvalue.state = 'noWatcher';\r\n\t\t\t}\r\n\t\t\t// TODO: recuperee etat messages lus\r\n\t\t});\r\n\r\n\r\n\t\tvalue.channel.on('unsubscribe', () =>\r\n\t\t{\r\n\t\t\tconsole.log('unsubscribe to', value.name);\r\n\t\t\tif (value.watch)\r\n\t\t\t{\r\n\t\t\t\tvalue.state = 'lost';\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tdelete this.roomsAGerer[idx];\r\n\t\t\t}\r\n\t\t});\r\n\r\n\r\n\t\tvalue.channel.on('subscribeFail', () =>\r\n\t\t{\r\n\t\t\tconsole.log('subscribeFail', value.name);\r\n\t\t\tif (value.watch)\r\n\t\t\t{\r\n\t\t\t\tvalue.state = 'lost';\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tvalue.state = 'fail';\r\n\t\t\t}\r\n\t\t});\r\n\r\n\r\n\t}\r\n\r\n}\r\n","import { Injectable } from '@angular/core';\r\n\r\nimport { VaultHttpService } from './http/vaultHttp.service';\r\nimport { ISocketData, SocketWhat } from '../models/message.model';\r\nimport { SCClientSocket } from 'socketcluster-client';\r\nimport { SCChannel } from 'sc-channel';\r\nimport { EventEmitter } from 'events';\r\nimport {Observable} from 'rxjs/Rx';\r\ndeclare const require: any;\r\n\r\nlet socketCluster = require('socketcluster-client');\r\n\r\ninterface ISocketEvents\r\n{\r\n\t// Canaux par defaut hors room\r\n\ton(event: 'genericUpdates',\tlistener: (data: any) => void): this; // Pour action globale\r\n\ton(event: 'accountUpdates',\tlistener: (data: any) => void): this; // Action sur le compte\r\n\ton(event: 'user',\t\t\tlistener: (data: any) => void): this; // Action mail user (si 10machines, send sur les 10)\r\n\ton(event: 'machine',\t\tlistener: (data: any) => void): this; // Cible une seule machine en cours (multi onglet par contre)\r\n\ton(event: 'account',\t\tlistener: (data: any) => void): this; // Le compte (Etablissement)\r\n\r\n\t// Ecouteur générique\r\n\ton(event: 'create', listener: (data: any) => void): this;\r\n\ton(event: 'read',\tlistener: (data: any) => void): this;\r\n\ton(event: 'update', listener: (data: any) => void): this;\r\n\ton(event: 'delete', listener: (data: any) => void): this;\r\n\r\n\t// Ecouteur spécifique\r\n\ton(event: 'error',\t\t\t\tlistener: (data: any)\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'debug',\t\t\t\tlistener: (data: any)\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'authenticate',\t\tlistener: (data: any)\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'authStateChange',\tlistener: (old: any, news: any, signed: any)\t=> void): this;\r\n\ton(event: 'deauthenticate',\t\tlistener: ()\t\t\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'authTokenChange',\tlistener: (newtoken: any)\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'connect',\t\t\tlistener: ()\t\t\t\t\t\t\t\t\t=> void): this;\r\n\ton(event: 'disconnect',\t\t\tlistener: ()\t\t\t\t\t\t\t\t\t=> void): this;\r\n\r\n\ton(event: string, listener: (data: any) => void): this;\r\n}\r\n\r\n\r\n@Injectable()\r\nexport class SocketVaultService extends EventEmitter implements ISocketEvents\r\n{\r\n public\troomsAGerer: any = undefined;\r\n\r\n\tprivate socket:\t\t\tany;\r\n\tprivate processing:\t\tboolean\t= false;\r\n\tprivate timeOutSocket:\tany\t\t= undefined;\r\n private roomsGet:\t\tboolean\t= false;\r\n\r\n constructor()\r\n\t{\r\n\t\tsuper();\r\n\t\tthis.init();\r\n }\r\n\r\n /**\r\n\t * Initialisation du service socket\r\n\t */\r\n\tpublic init()\r\n\t{\r\n\t\tthis.roomsAGerer =\r\n [\r\n {\r\n name: '*soft::all::creation', state: 'nosub', watch: true,\r\n fct: this.watchGenericUpdates.bind(this), channel: undefined\r\n }\r\n ];\r\n }\r\n\r\n /**\r\n\t * Cree le socket authentifie ou pas , pas d'http\r\n\t */\r\n\tpublic getSocketConnection(): Observable\r\n\t{\r\n\t\tlet observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tif (this.socket)\r\n\t\t\t{\r\n\t\t\t\tif (this.socket.state)\r\n\t\t\t\t{\r\n\t\t\t\t\t//retourne le socket s'il est ouvert (peut etre non auth)\r\n\t\t\t\t\tif (this.socket.state === SCClientSocket.OPEN)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tobserver.next(this.socket);\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// en cours de connexion\r\n\t\t\t\t\tif (this.socket.state === SCClientSocket.CONNECTING)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tobserver.next(undefined);\r\n\t\t\t\t\t\t\treturn;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\t// ou deco\r\n\t\t\t\t\tif (this.socket.state === SCClientSocket.CLOSED)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.socket.connect();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t//Pas de socket, on cree un\r\n\t\t\t\tthis.socket = socketCluster.connect({\r\n\t\t\t\t\thostname:\t\tVaultHttpService.getChatUrl(),\r\n\t\t\t\t\tsecure:\t\t\tVaultHttpService.getChatSecure(),\r\n\t\t\t\t\tpath:\t\t\tVaultHttpService.getChatPath(),\r\n\t\t\t\t\tautoreconnect:\ttrue,\r\n\t\t\t\t\tport:\t\t\tVaultHttpService.getChatPort()\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tthis.socket.off('authenticate');\r\n\t\t\tthis.socket.off('authStateChange');\r\n\t\t\tthis.socket.off('deauthenticate');\r\n\t\t\tthis.socket.off('authTokenChange');\r\n\t\t\tthis.socket.off('error');\r\n\t\t\tthis.socket.off('debug');\r\n\t\t\tthis.socket.off('connect');\r\n\t\t\tthis.socket.off('create');\r\n\t\t\tthis.socket.off('read');\r\n\t\t\tthis.socket.off('update');\r\n\t\t\tthis.socket.off('delete');\r\n\t\t\tthis.socket.off();\r\n\r\n\t\t\tif (this.timeOutSocket)\r\n\t\t\t{\r\n\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t}\r\n\r\n\t\t\tthis.socket.on('authenticate', (old: any, news: any, signed: any) =>\r\n\t\t\t{\r\n\t\t\t\tthis.emit('authenticate', old, news, signed);\r\n\t\t\t});\r\n\r\n\r\n\t\t\tthis.socket.on('authStateChange', (old: any, news: any, signed: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (old && old.newState && old.newState === 'unauthenticated')\r\n\t\t\t\t\tthis.emit('deauthenticate');\r\n\r\n\t\t\t\tthis.emit('authStateChange', old, news, signed);\r\n\t\t\t});\r\n\r\n\r\n\t\t\tthis.socket.on('deauthenticate', () =>\r\n\t\t\t{\r\n\t\t\t\tthis.emit('deauthenticate');\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('authTokenChange', (newToken: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (!newToken)\r\n\t\t\t\t\tthis.emit('deauthenticate');\r\n\r\n\t\t\t\tthis.emit('authTokenChange', newToken);\r\n\t\t\t});\r\n\r\n\r\n\t\t\tthis.socket.on('error', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t{\r\n\t\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t\t\tobserver.next(undefined);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (this.emit('error', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'error', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('debug', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('debug', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'debug', data);\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('create', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('create', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'create', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.socket.on('read', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('read', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'read', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.socket.on('update', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('update', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'update', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.socket.on('delete', (data: any) =>\r\n\t\t\t{\r\n\t\t\t\tif (this.emit('delete', data) === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'delete', data);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis.socket.on('connect', () =>\r\n\t\t\t{\r\n\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t\tif (this.emit('connect') === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'connect');\r\n\t\t\t\t}\r\n\t\t\t\tobserver.next(this.socket);\r\n\t\t\t});\r\n\r\n\t\t\tthis.socket.on('disconnect', () =>\r\n\t\t\t{\r\n\t\t\t\tif (this.timeOutSocket)\r\n\t\t\t\t\tclearTimeout(this.timeOutSocket);\r\n\t\t\t\tif (this.emit('disconnect') === false)\r\n\t\t\t\t{\r\n\t\t\t\t\tconsole.log('Hey no listener for', 'disconnect');\r\n\t\t\t\t}\r\n\t\t\t\tobserver.next(undefined);\r\n\t\t\t});\r\n\r\n\r\n\t\t\tthis.timeOutSocket = setTimeout(() =>\r\n\t\t\t{\r\n\t\t\t\tconsole.log('************Trop long on deco volontairement!');\r\n\t\t\t\tobserver.next(undefined);\r\n\t\t\t\tthis.logout();\r\n\t\t\t}, 10000);\r\n\r\n\t\t});\r\n\t\treturn observable;\r\n }\r\n\r\n\r\n /**\r\n\t *\r\n\t */\r\n\tpublic logout()\r\n\t{\r\n\t\tif (this.socket && this.socket.state && this.socket.state === SCClientSocket.OPEN)\r\n\t\t{\r\n\t\t\tif (this.roomsAGerer)\r\n\t\t\t{\r\n\t\t\t\tfor (let room of this.roomsAGerer)\r\n\t\t\t\t{\r\n\t\t\t\t\tif (room.channel)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\troom.channel.unwatch();\r\n\t\t\t\t\t\troom.channel.off();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// On enlève les écouteurs\r\n\t\t\t// ---------------------------------------\r\n\t\t\tthis.socket.off('authenticate');\r\n\t\t\tthis.socket.off('authStateChange');\r\n\t\t\tthis.socket.off('deauthenticate');\r\n\t\t\tthis.socket.off('authTokenChange');\r\n\t\t\tthis.socket.off('error');\r\n\t\t\tthis.socket.off('connect');\r\n\r\n\t\t\tthis.socket.off('create');\r\n\t\t\tthis.socket.off('read');\r\n\t\t\tthis.socket.off('update');\r\n\t\t\tthis.socket.off('delete');\r\n\r\n\r\n\t\t\t// ---------------------------------------\r\n\t\t\t// Déconnexion et désauthentification\r\n\t\t\t// ---------------------------------------\r\n\t\t\tthis.socket.deauthenticate();\r\n\t\t\tthis.socket.disconnect();\r\n\t\t\tthis.socket.off(); \r\n\r\n\t\t}\r\n }\r\n\r\n\r\n public watchGenericUpdates(data: any)\r\n\t{ \r\n\t\tif (super.emit('genericUpdates', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'genericUpdates', data);\r\n\t\t}\r\n\t} \r\n\r\n\r\n\tpublic watchAccountUpdates(data: any)\r\n\t{\r\n\t\tif (super.emit('accountUpdates', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'accountUpdates', data);\r\n\t\t}\r\n\t} \r\n\r\n\r\n\tpublic watchUser(data: any)\r\n\t{\r\n\t\tif (super.emit('user', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'user', data);\r\n\t\t}\r\n\t}\r\n\r\n\tpublic watchMachine(data: any)\r\n\t{\r\n\t\tif (super.emit('machine', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'machine', data);\r\n\t\t}\r\n\t}\r\n\tpublic watchAccount(data: any)\r\n\t{\r\n\t\tif (super.emit('account', data) === false)\r\n\t\t{\r\n\t\t\tconsole.log('Hey no listener for', 'account', data);\r\n\t\t}\r\n\t}\r\n\r\n\tpublic findRoomAGerer(name: string):any\r\n\t{\r\n\t\tif (this.roomsAGerer)\r\n\t\t{\r\n\t\t\tfor (let i = 0; i < this.roomsAGerer.length; i++)\r\n\t\t\t{\r\n\t\t\t\tif (this.roomsAGerer[i].name == name)\r\n\t\t\t\t\treturn i;\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn -1;\r\n\t}\r\n\r\n\r\n\r\n\tpublic RoomLost()\r\n\t{\r\n\t\tlet time = Date.now() / 1000;\r\n\t\t\r\n\t\tif (this.roomsAGerer)\r\n\t\t{\r\n\t\t\t// on parcours toutes les rooms \r\n\t\t\tlet nb = 3;\r\n\t\t\tfor (let i = 0; i < this.roomsAGerer.length; i++)\r\n\t\t\t{\r\n\t\t\t\t// on passe a eta cnx perdue\r\n\t\t\t\tthis.roomsAGerer[i].state = 'lost';\r\n\t\t\t}\r\n\t\t}\r\n } \r\n\r\n\r\n public GererRoom()\r\n\t{\r\n\t\tlet time = Date.now() / 1000;\r\n\r\n\t\tif (this.roomsAGerer)\r\n\t\t{\r\n\t\t\t// on parcours toutes les rooms\r\n\t\t\tlet nb = 5;\r\n\t\t\tfor (let i = 0; i < this.roomsAGerer.length; i++)\r\n\t\t\t{\r\n\t\t\t\t// si on en trouve une non subscrite on lance le sub, et on sort\r\n\t\t\t\tif (this.roomsAGerer[i].state === 'nosub')\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.subscribe(this.socket, i);\r\n\t\t\t\t\t// nb a la fois\r\n\t\t\t\t\tif (nb < 0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tnb--;\r\n\t\t\t\t}\r\n\t\t\t\t//pour les socket a l'etat lost (deco && a surveiller)\r\n\t\t\t\tif (this.roomsAGerer[i].state === 'lost')\r\n\t\t\t\t{\r\n\t\t\t\t\tlet channel = this.roomsAGerer[i].channel;\r\n\t\t\t\t\tthis.roomsAGerer[i].state = 'pending';\r\n\r\n\t\t\t\t\tif (channel.state === SCChannel.UNSUBSCRIBED)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tchannel.subscribe();\r\n\t\t\t\t\t\t// nb a la fois\r\n\t\t\t\t\t\tif (nb < 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tnb--;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t\t// si tout ca est ok\r\n\t\t\t// toutes les 10s (modulo sur date)\r\n\t\t\tif (time % 10)\r\n\t\t\t{\r\n\t\t\t\tif (this.roomsAGerer)\r\n\t\t\t\t{\r\n\t\t\t\t\t// on parcours toutes les rooms\r\n\t\t\t\t\tfor (let i = 0; i < this.roomsAGerer.length; i++)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet value = this.roomsAGerer[i];\r\n\t\t\t\t\t\t//si le canal est connecté\r\n\t\t\t\t\t\tif (value.channel && value.channel.state === SCChannel.SUBSCRIBED)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tlet watchers = value.channel.watchers();\r\n\t\t\t\t\t\t\t// si pas de watcher on l'ajoute\r\n\t\t\t\t\t\t\tif (!watchers || watchers.length == 0)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvalue.channel.watch((data: any) => { value.fct(data); });\r\n\t\t\t\t\t\t\t\tvalue.state = 'watching';\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tprivate subscribe(socket: any, idx: number)\r\n\t{\r\n\t\tlet value = this.roomsAGerer[idx];\r\n\t\tif (!value)\r\n\t\t{\r\n\t\t\tconsole.log(idx, 'must be in table before subsribe');\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tvalue.state = 'pending';\r\n\r\n\t\tvalue.channel = socket.subscribe(value.name);\r\n\t\tvalue.channel.on('subscribe', () =>\r\n\t\t{\r\n\t\t\tconsole.log('Subscribre to', value.name);\r\n\t\t\tif (value.fct)\r\n\t\t\t{\r\n\t\t\t\tvalue.channel.watch((data: any) => { value.fct(data); });\r\n\t\t\t\tvalue.state = 'watching';\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tvalue.state = 'noWatcher';\r\n\t\t\t}\r\n\t\t\t// TODO: recuperee etat messages lus\r\n\t\t});\r\n\r\n\r\n\t\tvalue.channel.on('unsubscribe', () =>\r\n\t\t{\r\n\t\t\tconsole.log('unsubscribe to', value.name);\r\n\t\t\tif (value.watch)\r\n\t\t\t{\r\n\t\t\t\tvalue.state = 'lost';\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tdelete this.roomsAGerer[idx];\r\n\t\t\t}\r\n\t\t});\r\n\r\n\r\n\t\tvalue.channel.on('subscribeFail', () =>\r\n\t\t{\r\n\t\t\tconsole.log('subscribeFail', value.name);\r\n\t\t\tif (value.watch)\r\n\t\t\t{\r\n\t\t\t\tvalue.state = 'lost';\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tvalue.state = 'fail';\r\n\t\t\t}\r\n\t\t});\r\n\r\n\r\n\t}\r\n}\r\n","import { Injectable } from '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\nimport { SocketService } from './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData } \t\t\t\tfrom '../providers/user-data';\r\n\r\n@Injectable()\r\n\r\nexport class StatisticsService\r\n{\r\n private socket: any = undefined;\r\n\r\n /**\r\n\t *\r\n\t */\r\n constructor(private socketService:\tSocketService,\r\n\t\t\t\tprivate userData:\t\tUserData)\r\n {\r\n this.socket = socketService.getSocketConnection();\r\n }\r\n\r\n public getEpreuveStats(nodeParentIds: any[] = [], limit: number = 0)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'epreuve.stats',\r\n\t\t\t\t\t\t'args': {\r\n\t\t\t\t\t\t\tparentNodes: nodeParentIds,\r\n\t\t\t\t\t\t\tlimit: limit\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tthis.socket = socket;\r\n\r\n\t\t\t\tif (this.userData.isAdmin() === true || this.userData.isSuperviseur() === true)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t\t'cmd': 'tasks.stats',\r\n\t\t\t\t\t\t\t'args': {}\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t\t'cmd': 'tasks.assigned',\r\n\t\t\t\t\t\t\t'args': {}\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n}\r\n\r\n","// Angular\r\nimport { Injectable } from '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\n// Other\r\nimport { SujetHttpService }\t\t\tfrom './http/sujetHttp.service';\r\nimport { Sujet }\t\t\t\t\tfrom '../classes/sujet.class';\r\nimport { File as FileSubject }\t\tfrom '../classes/file.class';\r\nimport { Comment }\t\t\t\t\tfrom '../classes/comment.class';\r\nimport { SocketService }\t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\n\r\nimport { UserData } \t\tfrom '../providers/user-data';\r\nimport { WorkspaceData } \tfrom '../providers/workspace-data';\r\nimport { TaskData }\t\t\tfrom '../providers/task-data';\r\n\r\nimport { FileService } from '../services/file.service';\r\n\r\n\r\nimport * as _ from 'underscore';\r\n\r\n@Injectable()\r\n\r\n\r\n/**\r\n *\r\n */\r\nexport class SujetService\r\n{\r\n\t/**\r\n\t *\r\n\t */\r\n\tconstructor(private sujetHttpService:\tSujetHttpService,\r\n\t\t\t\tprivate socketService:\t\tSocketService,\r\n\t\t\t\tprivate workspaceData:\t\tWorkspaceData,\r\n\t\t\t\tprivate taskData:\t\t\tTaskData,\r\n\t\t\t\tprivate fileService:\t\tFileService,\r\n\t\t\t\tprivate userData:\t\t\tUserData)\r\n\t{\r\n\r\n\t}\r\n\r\n\r\n /**\r\n * Add new sujet in database from Sujet object given in parameter\r\n */\r\n\tpublic addSujet(sujet: Sujet, parentPath: any, datasMail: any = '', idc: any = '')\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'subject',\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsubject:\tsujet.toJson(),\r\n\t\t\t\t\t\tparentPath: parentPath,\r\n\t\t\t\t\t\tdatasMail:\tdatasMail\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n *\r\n */\r\n\tpublic editFlag(psId: string, psEtat: string, idMatiere: any)\r\n\t{\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'subject',\r\n\t\t\t\t\t'args': {\r\n\t\t\t\t\t\tsubject:\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tidsujet:\tpsId,\r\n\t\t\t\t\t\t\tidepreuve:\tidMatiere,\r\n\t\t\t\t\t\t\tdata:\t\t{ etat: psEtat }\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n /**\r\n * Get all subjects in database relative to user account and parameters given:\r\n *\r\n * -idSujet: if this parameter is defined, return the Sujet object corresponding to the value id\r\n * -idEpreuve: if this parameter is defined (and if the parameter idSujet is not), return the Sujet\r\n * objects wich the epreuve parent matches the value id.\r\n *\r\n */\r\n\tpublic getSujets(idEpreuve: string = undefined, idSujet: string = '')\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'subjects',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tidMatiere: idEpreuve,\r\n\t\t\t\t\t\t\tidSubject: idSujet\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic getSubjectHistoric(idSubject: any)\r\n {\r\n this.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n let dataHistoric: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'history',\r\n\t\t\t\t\t'args': {\r\n\t\t\t\t\t\tbucket: 'subjects',\r\n\t\t\t\t\t\tkey: idSubject,\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', dataHistoric);\r\n\t\t\t}\r\n });\r\n }\r\n\r\n\r\n\t/**\r\n\t * Mise à jour coté serveur du sujet donné en paramètre\r\n\t * @param subject\r\n\t */\r\n\tpublic updateSubject(subject: Sujet)\r\n\t{\r\n\t\tconst jsonSubject: any = subject.toJson();\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'subject',\r\n\t\t\t\t\t'args': \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tsubject: jsonSubject\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Vérification à partir des taches du sujet donné si l'utilisateur donné à le droit d'ajouter des fichiers\r\n\t * -Il peut ajouter des fichiers s'il est admin\r\n\t * -Il peut ajouter des fichiers si une des taches du sujet dans lesquelles il est affecté\r\n\t * contient le droit d'ajout de fichier\r\n\t */\r\n\tpublic getAuthCreateFileInSubject(idUser: any, subject: Sujet)\r\n\t{\r\n\t\tlet result = false;\r\n\r\n\t\tif (this.userData.isAdmin() === true || this.userData.isSuperviseur() === true)\r\n\t\t{\r\n\t\t\tresult = true;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (subject && subject.tasks)\r\n\t\t\t{\r\n\t\t\t\t// On recherche dans les taches du sujet, la premiere ayant la propriete canCreateFile a vrai\r\n\t\t\t\t// s'il n'y en a aucune alors l'utilisateur courant ne peut pas ajouter de fichier dans le sujet\r\n\t\t\t\tconst indexTaskWithUploadRight = _.find(subject.tasks, (task: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\treturn task.canCreateFile === true && task.state !== 'done' && task.state !== 'review' && task.assigneduser === idUser; \r\n\t\t\t\t});\r\n\r\n\t\t\t\tif (indexTaskWithUploadRight !== undefined)\r\n\t\t\t\t{\r\n\t\t\t\t\tresult = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n /**\r\n\t * Add note to subject in database\r\n\t *\r\n\t * @param sujet: Sujet object in wich the note will be added\r\n\t * @param note: note wich will be added in database to given subject\r\n\t */\r\n\tpublic addNoteToSujet(sujet: Sujet, note: string)\r\n\t{\r\n\t\treturn this.sujetHttpService.addNoteToSujet(sujet, note);\r\n\t}\r\n\r\n\r\n\tpublic deleteSubject(sujet: Sujet)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'deleteSubject',\r\n\t\t\t\t\t'args': \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tidSubject: sujet.id,\r\n\t\t\t\t\t\tidEpreuve: sujet.idMatiere\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('delete', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Ecoute le channel socket d'un sujet donnée si on ne l'écoute pas déja.\r\n\t * @param task\r\n\t */\r\n\tpublic listenSubjectChannel(subject: Sujet)\r\n\t{\r\n\t\t// Construction du channel que l'on va écouter\r\n\t\tconst channel = '*soft::' + this.userData.account + '::creation::suj::' + subject.id;\r\n\t\t/**\r\n\t\t * On vérifie si on écoute pas déja sur le channe!\r\n\t\t * Si ce n'est pas le cas on ajoute une room pour écouter sur ce channel\r\n\t\t * en transmettant une fonction pour gérer les evènements\r\n\t\t */\r\n\t\tconst value = this.socketService.findRoomAGerer(channel);\r\n\r\n\t\tif (value < 0)\r\n\t\t{\r\n\t\t\tthis.socketService.roomsAGerer.push(\r\n\t\t\t\t{\r\n\t\t\t\t\tname:\t\tchannel,\r\n\t\t\t\t\tstate:\t\t'nosub',\r\n\t\t\t\t\twatch:\t\ttrue,\r\n\t\t\t\t\tfct:\t\tthis._handleSubjectEvent.bind(this),\r\n\t\t\t\t\tchannel:\tundefined\r\n\t\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tprivate _handleSubjectEvent(datas: any)\r\n\t{\r\n\t\tif (datas.cmd === 'update')\r\n\t\t{\r\n\t\t\tif (datas.args.data)\r\n\t\t\t{\r\n\r\n\t\t\t\tthis.workspaceData._updateSubjectFromJSON([datas.args.data]);\r\n//\t\t\t\tthis.workspaceData._addSubjectFromJSON([datas.args.data]);\r\n\t\t\t\tthis.taskData.majSubjectName(datas.args.data.idsujet);\r\n\r\n\t\t\t\tif (datas.args.data.idsujet && datas.args.data.data)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst sujet = this.taskData.workspaceData.getSujet(datas.args.data.idsujet);\r\n\r\n\t\t\t\t\tfor (const key in datas.args.data.data)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (sujet.datas[key])\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tsujet.datas[key] = datas.args.data.data[key];\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tconst sujet2 = this.taskData.workspaceData.getSujet(datas.args.data.idsujet);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\tif (datas.cmd === 'updatefile')\r\n\t\t{\r\n\t\t\tif (datas.args.file)\r\n\t\t\t{\r\n\t\t\t\tconst fileToReplace: FileSubject = FileSubject.fromJsonObject(datas.args.file);\r\n\r\n\t\t\t\tif (datas.args.definitive === true)\r\n\r\n\t\t\t\t{\r\n\t\t\t\t\tif (this.workspaceData.selectedSujet)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.workspaceData.selectedSujet.pj = _.filter(this.workspaceData.selectedSujet.pj, (pj: any) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn pj.id !== fileToReplace.id;\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.workspaceData.globalEmitter2.emit(fileToReplace.idSubject);\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\tif (this.workspaceData.selectedSujet)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tconst index = _.findIndex(this.workspaceData.selectedSujet.pj, (pj: any) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturn pj.id === fileToReplace.id;\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t// On vérifie si les donnnées de fichier récupéré contiennent des thumbnails\r\n\t\t\t\t\t\tif (index !== -1)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfileToReplace.encryptedAesKeys = this.workspaceData.selectedSujet.pj[index].encryptedAesKeys;\r\n\t\t\t\t\t\t\tfileToReplace.thumbs = this.workspaceData.selectedSujet.pj[index].thumbs;\r\n\r\n\t\t\t\t\t\t\tif (fileToReplace.tags)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (_.indexOf(fileToReplace.tags, 'corbeille') === -1)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tfileToReplace.deleted = false;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tfileToReplace.deleted = true;\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\tthis.workspaceData.selectedSujet.pj[index] = fileToReplace;\r\n\t\t\t\t\t\t\tthis.workspaceData.globalEmitter2.emit(fileToReplace.idSubject);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (datas.cmd === 'messages.set')\r\n\t\t{\r\n\t\t\tif (datas.args && datas.args.message)\r\n\t\t\t{\r\n\t\t\t\tconst messageAdded = this.workspaceData.parseHistoric(datas.args.message);\r\n\t\t\t\tthis.workspaceData.addHistoricToElement(datas.args.message.key, messageAdded);\r\n\t\t\t\tthis.workspaceData.globalEmitter.emit(['messages::get', datas.args.message.key]);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t/**\r\n\t\t * Onrécupère un évènement concernant un fichier\r\n\t\t */\r\n\t\tif (datas.cmd === 'file')\r\n\t\t{\r\n\t\t\tif (datas.args\r\n\t\t\t\t&& datas.args.action\r\n\t\t\t\t&& datas.args.subjectId\r\n\t\t\t\t&& (datas.args.action === 'update'\r\n\t\t\t\t|| datas.args.action === 'create'\r\n\t\t\t\t|| datas.args.action === 'delete'))\r\n\t\t\t{\r\n\t\t\t\tlet newHistoricItem: any = {};\r\n\t\t\t\tnewHistoricItem.idUser\t\t\t= datas.args.idUser;\r\n\t\t\t\tnewHistoricItem.creationDate\t= new Date(datas.args.creationDate);\r\n\r\n\t\t\t\tnewHistoricItem = this.workspaceData.parseHistoricItem(datas.args, newHistoricItem);\r\n\t\t\t\tif (newHistoricItem)\r\n\t\t\t\t{\r\n\t\t\t\t\t//On ajoute l'historique au sujet courant\r\n\t\t\t\t\tthis.workspaceData.addHistoricToElement(datas.args.subjectId, [newHistoricItem]);\r\n\t\t\t\t\tthis.workspaceData.globalEmitter.emit(['messages::get', datas.args.subjectId]);\r\n\r\n\t\t\t\t\tif (datas.args.idFile)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t//On ajoute l'historique au fichier courant\r\n\t\t\t\t\t\tthis.workspaceData.addHistoricToElement(datas.args.idFile, [newHistoricItem]);\r\n\t\t\t\t\t\tthis.workspaceData.globalEmitter.emit(['messages::get', datas.args.idFile]);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (datas.cmd === 'thumbnails')\r\n\t\t{\r\n\t\t\tif (datas && datas.args && datas.args.file)\r\n\t\t\t{\r\n\t\t\t\t// On recherche le fichier créé à mettre à jour suite à la génération d'un thumbnail\r\n\t\t\t\tconst fileAdded: FileSubject\t\t= FileSubject.fromJsonObject(datas.args.file);\r\n\t\t\t\tlet oldUuid: any;\r\n\r\n\t\t\t\tif (datas.args.file.oldUuid)\r\n\t\t\t\t{\r\n\t\t\t\t\toldUuid = datas.args.file.oldUuid;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif (this.workspaceData.selectedSujet && this.workspaceData.selectedSujet.pj)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst fileToUpdate: FileSubject = _.find(this.workspaceData.selectedSujet.pj, (pj: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn pj.id === fileAdded.id || (oldUuid && oldUuid === pj.id);\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\t// On vérifie si les donnnées de fichier récupéré contiennent des thumbnails\r\n\t\t\t\t\tif (fileToUpdate)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (datas.args.error === false)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfileToUpdate.id \t\t= fileAdded.id;\r\n\t\t\t\t\t\t\tfileToUpdate.idSubject \t= fileAdded.idSubject;\r\n\t\t\t\t\t\t\tfileToUpdate.pathThumbs = fileAdded.pathThumbs;\r\n\t\t\t\t\t\t\tfileToUpdate.thumbs \t= [];\r\n\r\n\t\t\t\t\t\t\t// On télécharge le thumbnail à partir de son identifiant unique et on le stocke\r\n\t\t\t\t\t\t\tthis.fileService.downloadThumbnail(fileToUpdate).subscribe((res) =>\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (res && res.url)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tfileToUpdate.errorThumb = false;\r\n\t\t\t\t\t\t\t\t\tfileToUpdate.thumbs.push(res);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\tthis.workspaceData.globalEmitter2.emit(this.workspaceData.selectedSujet.id);\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfileToUpdate.errorThumb = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif (datas.cmd === 'pdf')\r\n\t\t{\r\n\t\t\tif (datas && datas.args && datas.args.file)\r\n\t\t\t{\r\n\t\t\t\tconst fileAdded: FileSubject\t\t= FileSubject.fromJsonObject(datas.args.file);\r\n\r\n\t\t\t\tif (this.workspaceData.selectedSujet && this.workspaceData.selectedSujet.pj)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst fileToUpdate: FileSubject = _.find(this.workspaceData.selectedSujet.pj, (pj: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\treturn pj.id === fileAdded.id;\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\t// On met à jour la référence du pdf\r\n\t\t\t\t\tif (fileToUpdate)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (datas.args.error === undefined || datas.args.error === false)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfileToUpdate.errorPdf \t= false;\r\n\t\t\t\t\t\t\tfileToUpdate.pathPdf \t= fileAdded.pathPdf;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfileToUpdate.errorPdf = true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\r\n\t\tif (datas.cmd === 'deleteSubject')\r\n\t\t{\r\n\t\t\tif (datas && datas.args && datas.args.idEpreuve && datas.args.idSubject && datas.args.tasksToRemove)\r\n\t\t\t{\r\n\t\t\t\tthis.workspaceData.selectedMatiere.sujets = _.filter(this.workspaceData.selectedMatiere.sujets, (sujet: any) => { return sujet.id !== datas.args.idSubject });\r\n\r\n\t\t\t\t// On supprime les taches concernées par le sujet\r\n\t\t\t\tconst tasksToRemove: any[] = datas.args.tasksToRemove;\r\n\r\n\t\t\t\tif (tasksToRemove.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tthis.taskData.globalTaskDatas = this.taskData.globalTaskDatas.filter(task => \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let taskToRemove of tasksToRemove)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (taskToRemove !== task.id)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn true\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t//return tasksToRemove.includes(task.id);\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tthis.taskData.taskDatas = this.taskData.taskDatas.filter(task => \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let taskToRemove of tasksToRemove)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (taskToRemove !== task.id)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturn true\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t//return tasksToRemove.includes(task.id);\r\n\t\t\t\t\t});\r\n\r\n\r\n\r\n\r\n\r\n\t\t\t\t\tlet nIndiceMine = 0;\r\n\t\t\t\t\t\r\n\t\t\t\tfor (let taskMineIndice in this.workspaceData.taskHomeMine)\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (let taskToRemove of tasksToRemove)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (taskToRemove === this.workspaceData.taskHomeMine[taskMineIndice].id)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tthis.workspaceData.removeTaskToMine(nIndiceMine);\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tnIndiceMine++;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t\t/*\r\n\t\t\t\t\tthis.workspaceData.taskHomeMine = this.workspaceData.taskHomeMine.filter(task => \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfor (let taskToRemove of tasksToRemove)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (taskToRemove !== task.id)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn true\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t*/\r\n\t\t\t\t\t\tlet nIndiceExpired = 0;\r\n\t\t\t\t\t\t\r\n\t\t\t\t\tfor (let taskExpiredIndice in this.workspaceData.taskHomeAdminExpired)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tfor (let taskToRemove of tasksToRemove)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (taskToRemove === this.workspaceData.taskHomeAdminExpired[taskExpiredIndice].id)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tthis.workspaceData.removeTaskExpired(nIndiceExpired);\r\n\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tnIndiceExpired++;\r\n\r\n\t\t\t\t\t}\r\n/*\r\n\r\n\t\t\t\t\tthis.workspaceData.taskHomeMine = taskExpired.filter(task => \r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tfor (let taskToRemove of tasksToRemove)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (taskToRemove !== task.id)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturn true\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});*/\r\n\t\t\t\t}\r\n\t\t\t\tthis.userData.globalEmitter.emit(['subject::delete', datas.args.idSubject]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"," // Angular\r\nimport { Injectable } from '@angular/core';\r\nimport {Observable} from 'rxjs/Rx';\r\nimport 'rxjs/add/operator/share'\r\n\r\n\r\nimport { Task }\t\t\t\tfrom '../classes/task.class';\r\nimport { Sujet }\t\t\tfrom '../classes/sujet.class';\r\nimport { Comment }\t\t\tfrom '../classes/comment.class';\r\nimport { Etablissement }\tfrom '../classes/etablissement.class';\r\nimport { Session }\t\t\tfrom '../classes/session.class';\r\nimport { Examen }\t\t\tfrom '../classes/examen.class';\r\nimport { Matiere }\t\t\tfrom '../classes/matiere.class';\r\nimport { TaskHttpService }\tfrom './http/taskHttp.service';\r\n\r\nimport { SocketService }\t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData }\t\t\t\t\tfrom '../providers/user-data';\r\nimport { WorkspaceData }\t\t\tfrom '../providers/workspace-data';\r\n\r\nimport { EncryptService } from '../services/encrypt.service';\r\nimport { FileService } \tfrom '../services/file.service';\r\n\r\n\r\nimport * as _ from 'underscore';\r\n\r\n@Injectable()\r\n/**\r\n *\r\n */\r\nexport class TaskService\r\n{\r\n\r\n /**\r\n\t *\r\n\t */\r\n\tconstructor(private taskHttpService:\tTaskHttpService,\r\n\t\t\t\tpublic\tsocketService:\t\tSocketService,\r\n\t\t\t\tprivate userData:\t\t\tUserData,\r\n\t\t\t\tprivate workspaceData:\t\tWorkspaceData,\r\n\t\t\t\tprivate encryptService:\t\tEncryptService,\r\n\t\t\t\tprivate fileService:\t\tFileService)\r\n\t{\r\n\r\n\t}\r\n\r\n\t/**\r\n\t * Get tasks available considering the ressources for current user\r\n\t */\r\n\tpublic getTasksAvailable()\r\n\t{\r\n\t\tthis.socketService.on('read', this._onRessourcesReturned.bind(this));\r\n\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'ressources',\r\n\t\t\t\t\t'args': {}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic addTask(task: Task, sendMail: boolean = false, datasMail: any = null, pbMajSelected = 'false')\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'task',\r\n\t\t\t\t\tidc:\tString(pbMajSelected),\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttask:\t\ttask.toJson(),\r\n\t\t\t\t\t\tdatasMail: datasMail\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic deleteTask(task: Task)\r\n\t{\r\n\t\treturn this.taskHttpService.deleteTask(task).share();\r\n\t}\r\n\r\n\r\n\tpublic updateTask(task: Task, newDatas: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'task',\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttask: task.toJson(),\r\n\t\t\t\t\t\tdatasTask: newDatas\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif (newDatas.assigneduser)\r\n\t\t{\r\n\t\t\ttask.assigneduser = newDatas.assigneduser;\r\n\t\t}\r\n\r\n\t\tif (newDatas.state && newDatas.oldState && task.assigneduser)\r\n\t\t{\r\n\t\t\tconst currentSubject = this.workspaceData.getSujet(task.idSujet);\r\n\t\t\tthis.fileService.getFiles(currentSubject.id);\r\n\r\n\t\t\tconst userDataEmmiterSubscription = this.userData.globalEmitter.subscribe((value: string) =>\r\n\t\t\t{\r\n\t\t\t\tif (value === 'files::get')\r\n\t\t\t\t{\r\n\t\t\t\t\tthis._updateFilesAccessFromNewState(newDatas.state, newDatas.oldState, task, currentSubject);\r\n\t\t\t\t\tuserDataEmmiterSubscription.unsubscribe();\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tprivate _updateFilesAccessFromNewState(newState: string, oldState: string, task: Task, currentSubject: Sujet)\r\n\t{\r\n\t\tif (newState && task)\r\n\t\t{\r\n\t\t\tif (currentSubject)\r\n\t\t\t{\r\n\t\t\t\t//L'état est mis à jour\r\n\t\t\t\t//si le nouvel état est review on supprime les accès aux fichiers\r\n\t\t\t\t//concernés\r\n\t\t\t\tif (newState === 'done' || newState === 'new')\r\n\t\t\t\t{\r\n\t\t\t\t\tfor (const file of currentSubject.pj)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.encryptService.deleteAesKey(task.assigneduser, file.id);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\t//sinon si l'ancien état est review on réatribue les droits\r\n\t\t\t\t\tif ((oldState === 'done' || oldState === 'new') && (newState === 'todo' || newState === 'inprogress'))\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (task.noAccessFile === false)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (task.typeFileAccess === 'all')\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlet listFile = _.map(currentSubject.pj, (pj: any) => { return pj.id });\r\n\t\t\t\t\t\t\t\tthis.encryptService.encryptFilesForUSer(listFile, task.assigneduser, currentSubject);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tif (task.fileToAccess && task.fileToAccess.length > 0)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\tthis.encryptService.encryptFilesForUSer(task.fileToAccess, task.assigneduser, currentSubject);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tpublic addTaskComment(task: Task, newComment: Comment)\r\n\t{\r\n\t\treturn this.taskHttpService.addTaskComment(task, newComment).share();\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Fonction appelée automatiquement à la récupération de ressources\r\n\t */\r\n\tprivate _onRessourcesReturned(datas: any)\r\n\t{\r\n\t\tif (datas.cmd && datas.cmd === 'ressources')\r\n\t\t{\r\n\t\t\tif (this.userData.isAdmin() === true || this.userData.isSuperviseur() === true)\r\n\t\t\t{\r\n\t\t\t\tif (datas.args && datas.args.data && datas.args.data.ressources)\r\n\t\t\t\t{\r\n\t\t\t\t\tlet parentNodes = _.keys(datas.args.data.ressources);\r\n\t\t\t\t\tthis.userData.setRessources(parentNodes);\r\n\r\n\t\t\t\t\tfor (let parentNode of parentNodes)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tif (socket)\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t\t\t\t'cmd': 'tasks.bynode',\r\n\t\t\t\t\t\t\t\t\t'args': {\r\n\t\t\t\t\t\t\t\t\t\tparentNode: parentNode\r\n\t\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\t};\r\n\t\t\t\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tif (socket)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t\t'cmd': 'tasks.assigned',\r\n\t\t\t\t\t\t\t'args': {}\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\t\tsocket.emit('read', data);\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n","import { Injectable }\t\tfrom '@angular/core';\r\nimport { UserHttpService }\tfrom './http/userHttp.service';\r\n\r\nimport { SocketService }\t\t\tfrom './socket.service';\r\nimport { ISocketData, SocketWhat }\tfrom '../models/message.model';\r\nimport { UserData }\t\t\t\t\tfrom '../providers/user-data';\r\n\r\nimport {Observable} from 'rxjs/Rx';\r\n\r\ndeclare var Fingerprint2: any;\r\n\r\n@Injectable()\r\n\r\n\r\nexport class UserService\r\n{\r\n constructor(private userHttpService:\tUserHttpService,\r\n\t\t\t\tpublic\tsocketService:\t\tSocketService,\r\n\t\t\t\tprivate userData:\t\t\tUserData)\r\n {\r\n\r\n }\r\n\r\n\r\n /**\r\n * Get all users informations and their rights.\r\n */\r\n\tpublic getAllUsers(): Observable\r\n\t{\r\n\r\n\t\t// ---------------------------------------\r\n\t\t// ToComment\r\n\t\t// ---------------------------------------\r\n\t\tlet observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.userHttpService.getAllUsers().subscribe(res =>\r\n\t\t\t{\r\n\t\t\t\tobserver.next(res);\r\n\t\t\t});\r\n\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\tpublic createNewUser(userJson: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'user',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'user': { userJson },\r\n\t\t\t\t\t\t\t'token': this.userData.getTokenKey()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic deleteUser(userMail: string)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket:any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'user',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'userMail': userMail,\r\n\t\t\t\t\t\t\t'token': this.userData.getTokenKey()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('delete', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Génération du code OTP permettant la génération d'un QR code pour la double authentification\r\n\t * @param mailUser\r\n\t */\r\n\tpublic createUserOTPCode(mailUser: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'createOTP',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'mail': mailUser,\r\n\t\t\t\t\t\t\t'token': this.userData.getTokenKey()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Validation d'un code généré périodiquement à partir de l'appli smartphone\r\n\t * Permet de finaliser le passage d'un compte en double authentification\r\n\t * @param mailUser\r\n\t * @param otpValidationCode\r\n\t */\r\n\tvalidateUserOTPCode(mailUser: any, otpValidationCode: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'validateOtp',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'mail':\t\tmailUser,\r\n\t\t\t\t\t\t\t'otpCode': \totpValidationCode,\r\n\t\t\t\t\t\t\t'token': \tthis.userData.getTokenKey()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t/**\r\n\t * Mise a jour de la methode d'authentification\r\n\t */\r\n\tchangeOtpMethod(mailUser: any, otpMethod: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'changeOtpMethod',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'mail': \t\tmailUser,\r\n\t\t\t\t\t\t\t'otpMethod': \totpMethod,\r\n\t\t\t\t\t\t\t'token': \t\tthis.userData.getTokenKey()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Vérification à la connection d'un code OTP généré périodiquement au saisie par l'utilisateur\r\n\t * à la connexion\r\n\t * @param mailUser\r\n\t * @param otpValidationCode\r\n\t */\r\n\tcheckUserOTPCode(otpValidationCode: any, callback: (err: any, data: any) => any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet credentials = \r\n\t\t\t\t{\r\n\t\t\t\t\totpCode: \totpValidationCode,\r\n\t\t\t\t\ttoken: \t\tthis.userData.getTokenKey()\r\n\t\t\t\t};\r\n\r\n\t\t\t\tsocket.emit('login2nd', credentials, (err: any, datas: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tcallback(err, datas);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t *\r\n\t * @param code\r\n\t * @param fingerPrint\r\n\t * @param callback\r\n\t */\r\n\tcheckMachineCode(code: any, fingerPrint: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'checkCodeNewMachine',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'code': \t\tcode,\r\n\t\t\t\t\t\t\t'fingerprint': \tfingerPrint,\r\n\t\t\t\t\t\t\t'token': \t\tthis.userData.getTokenKey()\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n /**\r\n * update informations and right for a set of users\r\n */\r\n\tpublic updateUser(userId: any, dataUser: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'user',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'idUser': \t\t\tuserId,\r\n\t\t\t\t\t\t\t'datasToUpdate': \tdataUser,\r\n\t\t\t\t\t\t\t'token': \t\t\tthis.userData.getTokenKey()\r\n\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Get infos from current user logged\r\n\t */\r\n\tpublic getCurrentUser(): Observable\r\n\t{\r\n\t\tconst observable = Observable.create((observer: any) =>\r\n\t\t{\r\n\t\t\tthis.userHttpService.getCurrentUser().subscribe(res =>\r\n\t\t\t{\r\n\t\t\t\tobserver.next(res);\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\treturn observable;\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Génère coté serveur un password aléatoire dont la longueur est donnée en paramètre\r\n\t * @param passwordLength\r\n\t */\r\n\tpublic generateNewPassword(passwordLength: number)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'password',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'lengthPassword': passwordLength\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('create', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic updateUserPassword(jsonUser: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket: any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'updateUserPassword',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'datasuser': \tjsonUser,\r\n\t\t\t\t\t\t\t'token': \t\tthis.userData.getTokenKey()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/** */\r\n\tpublic checkFingerPrintUser()\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket:any) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\r\n\t\t\t\tlet options:any = \r\n\t\t\t\t{\r\n\t\t\t\t\tuserDefinedFonts:\t\t\t\t\t[],\r\n\t\t\t\t\texcludeUserAgent:\t\t\t\t\tfalse,\r\n\t\t\t\t\texcludeLanguage:\t\t\t\t\tfalse,\r\n\t\t\t\t\texcludeColorDepth:\t\t\t\t\tfalse,\r\n\t\t\t\t\texcludeScreenResolution:\t\t\ttrue,\r\n\t\t\t\t\texcludeAvailableScreenResolution:\tfalse,\r\n\t\t\t\t\texcludeTimezoneOffset:\t\t\t\tfalse,\r\n\t\t\t\t\texcludeSessionStorage:\t\t\t\tfalse,\r\n\t\t\t\t\texcludeIndexedDB:\t\t\t\t\tfalse,\r\n\t\t\t\t\texcludeAddBehavior:\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludeOpenDatabase:\t\t\t\tfalse,\r\n\t\t\t\t\texcludeCpuClass:\t\t\t\t\tfalse,\r\n\t\t\t\t\texcludePlatform:\t\t\t\t\tfalse,\r\n\t\t\t\t\texcludeDoNotTrack:\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludeCanvas:\t\t\t\t\t\tfalse,\r\n\t\t\t\t\texcludeWebGL:\t\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludeAdBlock:\t\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludeHasLiedLanguages:\t\t\tfalse,\r\n\t\t\t\t\texcludeHasLiedResolution:\t\t\tfalse,\r\n\t\t\t\t\texcludeHasLiedOs:\t\t\t\t\tfalse,\r\n\t\t\t\t\texcludeHasLiedBrowser:\t\t\t\tfalse,\r\n\t\t\t\t\texcludeJsFonts:\t\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludeFlashFonts:\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludePlugins:\t\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludeIEPlugins:\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludeTouchSupport:\t\t\t\tfalse,\r\n\t\t\t\t\texcludePixelRatio:\t\t\t\t\ttrue,\r\n\t\t\t\t\texcludeHardwareConcurrency:\t\t\tfalse,\r\n\t\t\t\t\texcludeWebGLVendorAndRenderer:\t\tfalse,\r\n\t\t\t\t\texcludeDeviceMemory:\t\t\t\tfalse\r\n\t\t\t\t};\r\n\t\t\t\tnew Fingerprint2(options).get((result: any, components: any) =>\r\n\t\t\t\t{\r\n\t\t\t\t\tlet fResult = result;\r\n\t\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam':\t'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd':\t'checkUserFingerprint',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'fingerprint': \tfResult,\r\n\t\t\t\t\t\t\t'token': \t\tthis.userData.getTokenKey()\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\t\tsocket.emit('create', data);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Demande au serveur la regeneration d'ue code machine à 4 chiffres et l'envoie par mail\r\n\t */\r\n\tpublic regenerateCodeMachine()\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tconst data: ISocketData =\r\n\t\t\t{\r\n\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t'cmd': 'generateNewCodeMachine',\r\n\t\t\t\t'args': {}\r\n\t\t\t};\r\n\t\t\tsocket.emit('create', data);\r\n\t\t});\r\n\t}\r\n\r\n\r\n\t/**\r\n\t * Décode coté serveur avec la clé RSA publique la signature donnée qui est encodée avec\r\n\t * la clé RSA privée, renvoie la confirmation de la signature\r\n\t * @param encryptedSignature\r\n\t */\r\n\tpublic encryptDatasForValidation(datas: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'encryptDatasForValidation',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'data': datas\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic toggleEnabledUser(mailUser: string, enable: boolean)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tlet data: ISocketData =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t\t'cmd': 'userAccess',\r\n\t\t\t\t\t\t'args':\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t'idUser': mailUser,\r\n\t\t\t\t\t\t\t'enable': enable\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t};\r\n\t\t\t\tsocket.emit('update', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tpublic resetRsaKeyUSer(mailUser: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'deleteRsaKeyUser',\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'idUser': mailUser\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('delete', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic getAesKeysFromUser(mailUser: any)\r\n\t{\r\n\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t{\r\n\t\t\tif (socket)\r\n\t\t\t{\r\n\t\t\t\tconst data: ISocketData =\r\n\t\t\t\t{\r\n\t\t\t\t\t'iam': 'c-c',\r\n\t\t\t\t\t'name': this.userData.getUserId(),\r\n\t\t\t\t\t'what': SocketWhat.info,\r\n\t\t\t\t\t'cmd': 'getAesKeysFromUser',\r\n\t\t\t\t\t'args':\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\t'idUser': mailUser\r\n\t\t\t\t\t}\r\n\t\t\t\t};\r\n\t\t\t\tsocket.emit('read', data);\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic sendPasswordReset(emailUser: any): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst credentials =\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\temailUser: emailUser\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('sendPasswordReset', credentials, (err: any, datas: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (err)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treject();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresolve();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t};\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic checkCodePasswordReset(codeReset: any): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst credentials = \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcodeReset: codeReset\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('checkCodePasswordReset', credentials, (err: any, datas: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (err)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treject(err);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresolve(datas);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t};\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic updatePasswordUserWithCode(compteUser: any, mailUser: any, codeReset: any, newPassword: any): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst credentials = \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcompteUser: \tcompteUser,\r\n\t\t\t\t\t\tmailUser: \t\tmailUser,\r\n\t\t\t\t\t\tcodeReset: \t\tcodeReset,\r\n\t\t\t\t\t\tnewPassword: \tnewPassword\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('updatePasswordUserWithCode', credentials, (err: any, datas: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (err)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treject(err);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresolve(datas);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t};\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tpublic initKeyspaceAndUser(compteUser: any, mailUser: any, token: any): Promise\r\n\t{\r\n\t\treturn new Promise((resolve, reject) =>\r\n\t\t{\r\n\t\t\tthis.socketService.getSocketConnection().subscribe((socket) =>\r\n\t\t\t{\r\n\t\t\t\tif (socket)\r\n\t\t\t\t{\r\n\t\t\t\t\tconst credentials = \r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tcompteUser: compteUser,\r\n\t\t\t\t\t\tmailUser: \tmailUser,\r\n\t\t\t\t\t\ttoken: \t\ttoken\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\t\tsocket.emit('initKeyspaceAndUser', credentials, (err: any, datas: any) =>\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif (datas.user)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tconst accountInfos \t\t= this.userData.getAccountInfo();\r\n\t\t\t\t\t\t\taccountInfos.infosUser \t= datas.user;\r\n\t\t\t\t\t\t\tthis.userData.setAccountInfo(accountInfos);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tif (err)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treject(err);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tresolve(datas);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t\telse\r\n\t\t\t\t{\r\n\t\t\t\t\treject();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n}\r\n","import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';\r\nimport { AppModule } from './app/app.module';\r\n\r\nplatformBrowserDynamic().bootstrapModule(AppModule);","/* (ignored) */","/* (ignored) */","/* (ignored) */","/* (ignored) */","/* (ignored) */"],"sourceRoot":""}