From 2adbfd418a7e335f115a20b65a05f997893277e4 Mon Sep 17 00:00:00 2001 From: eliaspue Date: Thu, 27 Jun 2024 10:38:47 +0200 Subject: [PATCH 1/7] Adding basic --- .../dialog-add-grid.component.ts | 4 +- .../dialog-export-pages.component.ts | 4 +- .../dialog-model-grid.component.ts | 4 +- .../dialog-reset-grid.component.ts | 2 +- .../components/edition/edition.component.html | 15 +-- .../components/edition/edition.component.ts | 121 +++++++++++++----- src/app/components/event/event.component.html | 38 ++++-- src/app/components/event/event.component.ts | 52 ++++++++ src/app/components/export/export.component.ts | 8 +- .../generator-grid.component.ts | 45 ++++--- .../import-user/import-user.component.ts | 6 +- src/app/components/import/import.component.ts | 9 +- .../information-edition-page.component.html | 14 +- .../life-companion2aug.component.ts | 7 +- .../components/spb2aug/spb2aug.component.ts | 8 +- src/app/components/tile/tile.component.ts | 44 +++++-- src/app/services/board.service.ts | 14 +- src/app/services/edition.service.ts | 7 +- src/app/services/functions.service.ts | 1 + src/app/services/proloquoParser.ts | 4 +- src/app/services/speakForYourselfParser.ts | 5 +- src/app/types.ts | 15 ++- src/assets/multilinguism.json | 7 +- 23 files changed, 319 insertions(+), 115 deletions(-) diff --git a/src/app/components/dialog-add-grid/dialog-add-grid.component.ts b/src/app/components/dialog-add-grid/dialog-add-grid.component.ts index cf0514933..43f7de16c 100644 --- a/src/app/components/dialog-add-grid/dialog-add-grid.component.ts +++ b/src/app/components/dialog-add-grid/dialog-add-grid.component.ts @@ -27,7 +27,7 @@ export class DialogAddGridComponent implements OnInit { } /** - * Creates a new grid corresponding to selected options (name and type). + * Creates a new grid corresponding to selected options (name and type). * If a grid already exists with the same name, not grid will be created and an error will be shown. * @param newGrid Grid to be checked if already exists */ @@ -45,7 +45,7 @@ export class DialogAddGridComponent implements OnInit { page.ElementIDsList = []; page.NumberOfCols = 0; page.NumberOfRows = 0; - this.boardService.board = new Grid(this.nameGrid, 'Grid', 6, 6, [], [], [page]); + this.boardService.board = new Grid(this.nameGrid, 'Grid', 6, 6, [], [], [page], []); } this.boardService.board.software = 'Augcom'; this.boardService.board.ID = this.nameGrid; diff --git a/src/app/components/dialog-export-pages/dialog-export-pages.component.ts b/src/app/components/dialog-export-pages/dialog-export-pages.component.ts index e9ad3843d..e6a5e93a8 100644 --- a/src/app/components/dialog-export-pages/dialog-export-pages.component.ts +++ b/src/app/components/dialog-export-pages/dialog-export-pages.component.ts @@ -43,10 +43,10 @@ export class DialogExportPagesComponent implements OnInit { }) let exportedGrid: Grid; if (this.pageToExport.NumberOfRows !== undefined && this.pageToExport.NumberOfCols !== undefined) { - exportedGrid = new Grid('exportedPage', 'Grid', Number(this.pageToExport.NumberOfCols), Number(this.pageToExport.NumberOfRows), this.gridElementOfPage, this.imageListOfPage, [this.pageToExport]); + exportedGrid = new Grid('exportedPage', 'Grid', Number(this.pageToExport.NumberOfCols), Number(this.pageToExport.NumberOfRows), this.gridElementOfPage, this.imageListOfPage, [this.pageToExport], []); } else { - exportedGrid = new Grid('exportedPage', 'Grid', 10, 10, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList); + exportedGrid = new Grid('exportedPage', 'Grid', 10, 10, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList, []); } this.downloadFile(JSON.stringify(exportedGrid)); } diff --git a/src/app/components/dialog-model-grid/dialog-model-grid.component.ts b/src/app/components/dialog-model-grid/dialog-model-grid.component.ts index 9a87b93ec..e1940ea30 100644 --- a/src/app/components/dialog-model-grid/dialog-model-grid.component.ts +++ b/src/app/components/dialog-model-grid/dialog-model-grid.component.ts @@ -25,11 +25,11 @@ export class DialogModelGridComponent implements OnInit { if (this.boardService.gridModel === 'default') { this.indexDbAccessService.loadDefaultGrid(); } else if (this.boardService.gridModel === 'empty') { - let page = new Page(); + const page = new Page(); page.ID = '#HOME'; page.Name = 'Accueil'; page.ElementIDsList = []; - this.boardService.board = new Grid('newGrid', 'Grid', 6, 6, [], [], [page]); + this.boardService.board = new Grid('newGrid', 'Grid', 6, 6, [], [], [page], []); } this.boardService.updateElementList(); } diff --git a/src/app/components/dialog-reset-grid/dialog-reset-grid.component.ts b/src/app/components/dialog-reset-grid/dialog-reset-grid.component.ts index 8ca703f2e..1d55015ac 100644 --- a/src/app/components/dialog-reset-grid/dialog-reset-grid.component.ts +++ b/src/app/components/dialog-reset-grid/dialog-reset-grid.component.ts @@ -28,7 +28,7 @@ export class DialogResetGridComponent implements OnInit { homePage.NumberOfCols = 3; homePage.NumberOfRows = 3; homePage.GapSize = 6; - this.boardService.board = new Grid('nothing', 'Grid', 0, 0, [], [], [homePage]); + this.boardService.board = new Grid('nothing', 'Grid', 0, 0, [], [], [homePage],[]); this.boardService.updateElementList(); } diff --git a/src/app/components/edition/edition.component.html b/src/app/components/edition/edition.component.html index 008c2d35f..df7af4e11 100644 --- a/src/app/components/edition/edition.component.html +++ b/src/app/components/edition/edition.component.html @@ -11,14 +11,13 @@ 'border-style': 'solid', 'border-color': this.editionService.curentBorderColor}">
+ [style.background-image]="this.sanitizer.bypassSecurityTrustStyle('url(\'' +this.editionService.imageURL+'\')')">
- {{this.editionService.name}} + {{ this.editionService.name }}
-
@@ -27,9 +26,9 @@
@@ -40,11 +39,11 @@
- {{this.multilinguism.translate("save")}} + {{ this.multilinguism.translate("save") }}

- {{this.multilinguism.translate("nameEmpty")}} + {{ this.multilinguism.translate("nameEmpty") }}
@@ -67,4 +66,4 @@ -{{this.configuration.VERSION}} \ No newline at end of file +{{ this.configuration.VERSION }} diff --git a/src/app/components/edition/edition.component.ts b/src/app/components/edition/edition.component.ts index ab1e19f4c..055792e7c 100644 --- a/src/app/components/edition/edition.component.ts +++ b/src/app/components/edition/edition.component.ts @@ -1,23 +1,23 @@ -import { Component, OnInit } from '@angular/core'; -import { DbnaryService } from '../../services/dbnary.service'; -import { BoardService } from '../../services/board.service'; -import { GeticonService } from '../../services/geticon.service'; -import { DomSanitizer } from '@angular/platform-browser'; -import { FolderGoTo, GridElement, Interaction, Page } from '../../types'; -import { IndexeddbaccessService } from '../../services/indexeddbaccess.service'; -import { Router } from '@angular/router'; -import { PaletteService } from '../../services/palette.service'; -import { EditionService } from '../../services/edition.service'; -import { Ng2ImgMaxService } from 'ng2-img-max'; -import { HttpClient } from '@angular/common/http'; -import { MultilinguismService } from '../../services/multilinguism.service'; -import { FunctionsService } from '../../services/functions.service'; -import { GridElementService } from '../../services/grid-element.service'; -import { LayoutService } from "../../services/layout.service"; -import { ConfigurationService } from "../../services/configuration.service"; - -import { ComponentCanDeactivate } from 'src/app/services/pending-changes-guard.service'; -import { Observable } from 'rxjs'; +import {Component, OnInit} from '@angular/core'; +import {DbnaryService} from '../../services/dbnary.service'; +import {BoardService} from '../../services/board.service'; +import {GeticonService} from '../../services/geticon.service'; +import {DomSanitizer} from '@angular/platform-browser'; +import {FolderGoTo, GridElement, Interaction, Page} from '../../types'; +import {IndexeddbaccessService} from '../../services/indexeddbaccess.service'; +import {Router} from '@angular/router'; +import {PaletteService} from '../../services/palette.service'; +import {EditionService} from '../../services/edition.service'; +import {Ng2ImgMaxService} from 'ng2-img-max'; +import {HttpClient} from '@angular/common/http'; +import {MultilinguismService} from '../../services/multilinguism.service'; +import {FunctionsService} from '../../services/functions.service'; +import {GridElementService} from '../../services/grid-element.service'; +import {LayoutService} from "../../services/layout.service"; +import {ConfigurationService} from "../../services/configuration.service"; + +import {ComponentCanDeactivate} from 'src/app/services/pending-changes-guard.service'; +import {Observable} from 'rxjs'; @Component({ selector: 'app-edition', @@ -26,6 +26,7 @@ import { Observable } from 'rxjs'; providers: [Ng2ImgMaxService, HttpClient] }) export class EditionComponent implements OnInit, ComponentCanDeactivate { + /** * Guard that checks before the user leaves the page, if any unsaved modification has been made * @returns true if (no modification has been made) or if (modifications have been made and the user confirmed his wish to quit), false elsewise @@ -42,18 +43,18 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { } - nameEmpty = false; - initialEditionState; initialdbnaryState; + initialEditionState; + initialdbnaryState; popstateFired = false; constructor(public editionService: EditionService, public paletteService: PaletteService, - public router: Router, public multilinguism: MultilinguismService, - public indexedDBacess: IndexeddbaccessService, public functionsService: FunctionsService, - public sanitizer: DomSanitizer, public getIconService: GeticonService, - public dbnaryService: DbnaryService, public boardService: BoardService, - public gridElementService: GridElementService, public layoutService: LayoutService, - public configuration: ConfigurationService) { + public router: Router, public multilinguism: MultilinguismService, + public indexedDBacess: IndexeddbaccessService, public functionsService: FunctionsService, + public sanitizer: DomSanitizer, public getIconService: GeticonService, + public dbnaryService: DbnaryService, public boardService: BoardService, + public gridElementService: GridElementService, public layoutService: LayoutService, + public configuration: ConfigurationService) { } @@ -115,11 +116,15 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { * Saves the modified or new element, updates the indexedDB database with it and closes the edition panel */ async save() { + console.log("1"); if (this.editionService.name !== '') { + console.log("2"); if (this.editionService.newPage === '') { + console.log("3"); this.editionService.newPage = this.editionService.name; } if (this.editionService.add) { + console.log("4"); this.createNewButton(); } else if (this.editionService.selectedElements.length === 1) { this.modifyButton(); @@ -168,8 +173,9 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { { DisplayedText: this.editionService.name, VoiceText: this.editionService.name, - LexicInfos: [{ default: true }], - ImageID: elt.ElementFormsList[0].ImageID + LexicInfos: [{default: true}], + ImageID: elt.ElementFormsList[0].ImageID, + AudioID: elt.ElementFormsList[0].AudioID } ); } @@ -211,6 +217,10 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { } else { return new FolderGoTo(this.editionService.pageLink); } + } else if (this.editionService.radioTypeFormat === 'sound') { + return 'sound'; + } else if (this.editionService.radioTypeFormat === 'video') { + return 'video'; } else { return 'button'; } @@ -254,11 +264,25 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { this.boardService.board.ImageList = this.boardService.board.ImageList.filter( img => img.ID !== this.editionService.getDefaultForm(element.ElementFormsList).ImageID); + this.boardService.board.AudioList = this.boardService.board.AudioList.filter( + img => img.ID !== this.editionService.getDefaultForm(element.ElementFormsList).AudioID); + this.boardService.board.ImageList.push({ ID: this.editionService.getDefaultForm(element.ElementFormsList).ImageID, OriginalName: this.editionService.name, Path: this.editionService.imageURL }); + + + this.boardService.board.AudioList.push( + { + ID: this.editionService.audioURL, + OriginalName: this.editionService.name, + Path: this.editionService.audioURL + } + ); + + } } @@ -277,8 +301,9 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { { DisplayedText: this.editionService.name, VoiceText: this.editionService.name, - LexicInfos: [{ default: true }], - ImageID: tempId + LexicInfos: [{default: true}], + ImageID: tempId, + AudioID: tempId } ); @@ -312,6 +337,15 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { Path: this.editionService.imageURL }); + this.boardService.board.AudioList.push( + { + ID: tempId, + OriginalName: this.editionService.name, + Path: this.editionService.audioURL + } + ); + + const currentPage: Page = this.getCurrentPage(); currentPage.ElementIDsList.push(tempId); } @@ -357,7 +391,15 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { this.editionService.name = this.editionService.getDefaultForm(elementToModif.ElementFormsList).DisplayedText; this.editionService.curentColor = this.gridElementService.getStyle(elementToModif).BackgroundColor; this.editionService.curentBorderColor = this.gridElementService.getStyle(elementToModif).BorderColor; - this.editionService.radioTypeFormat = elementToModif.Type === 'button' ? 'button' : 'folder'; + if (elementToModif.Type === 'button') { + this.editionService.radioTypeFormat = 'button'; + } else if (elementToModif.Type === 'sound') { + this.editionService.radioTypeFormat = 'sound'; + } else if (elementToModif.Type === 'video') { + this.editionService.radioTypeFormat = 'video'; + } else { + this.editionService.radioTypeFormat = 'folder'; + } this.editionService.pageLink = elementToModif.Type === 'button' ? '@' : (elementToModif.Type as FolderGoTo).GoTo; const imageToModif = this.boardService.board.ImageList.find(x => x.ID === elementToModif.ElementFormsList[0].ImageID); if (imageToModif != null && imageToModif !== undefined) { @@ -366,6 +408,18 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { this.editionService.imageURL = ''; } + // Mise à jour de l'URL de l'audio + if (elementToModif.Type === 'sound') { + const audioToModif = this.boardService.board.AudioList.find(x => x.ID === elementToModif.ElementFormsList[0].AudioID); + if (audioToModif != null && audioToModif !== undefined) { + this.editionService.audioURL = audioToModif.Path; + } else { + this.editionService.audioURL = ''; + } + } else { + this.editionService.audioURL = ''; + } + if (elementToModif.ElementFormsList != null && elementToModif.ElementFormsList !== undefined) { this.editionService.variantList = Object.assign([], elementToModif.ElementFormsList); } else { @@ -411,6 +465,7 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { && this.initialEditionState.pageLink == this.editionService.pageLink && this.initialEditionState.curentBorderColor == this.editionService.curentBorderColor && this.initialEditionState.imageURL == this.editionService.imageURL + && this.initialEditionState.audioURL == this.editionService.audioURL && this.initialEditionState.variantList == this.editionService.variantList && this.initialdbnaryState.wordList == this.dbnaryService.wordList && this.initialdbnaryState.typeList == this.dbnaryService.typeList); diff --git a/src/app/components/event/event.component.html b/src/app/components/event/event.component.html index 969e34141..eae52ca94 100644 --- a/src/app/components/event/event.component.html +++ b/src/app/components/event/event.component.html @@ -2,7 +2,7 @@
- {{this.multilinguism.translate("modifyInteractions")}}: + {{ this.multilinguism.translate("modifyInteractions") }}:
@@ -10,38 +10,56 @@
- {{this.multilinguism.translate(this.getLabel(inter.ID))}} + {{ this.multilinguism.translate(this.getLabel(inter.ID)) }}
- +
- + + (click)="inter.ActionList = removeFrom(action,inter.ActionList)">
+ + +
+

{{ multilinguism.translate("addSoundByFile") }}

+

{{ multilinguism.translate("addVideoByFile") }}

+
+ +
+ + +
+ +
- \ No newline at end of file + diff --git a/src/app/components/event/event.component.ts b/src/app/components/event/event.component.ts index a2c4b04a7..48f3eebd0 100644 --- a/src/app/components/event/event.component.ts +++ b/src/app/components/event/event.component.ts @@ -128,4 +128,56 @@ export class EventComponent implements OnInit, OnDestroy { interaction.plus = false; }); } + + AddAudioByFile(file) { + if (file.length === 0) { + return; + } + const mimeType = file[0].type; + if (mimeType.match(/audio\/*/) == null) { + return; + } + const reader = new FileReader(); + + // Lecture du fichier audio en tant que Data URL + reader.readAsDataURL(file[0]); + + reader.onload = () => { + this.editionService.audioURL = reader.result; + + }; + + // Gestion des erreurs de lecture + reader.onerror = (error) => { + console.error('Erreur lors de la lecture du fichier audio:', error); + }; + } + + AddVideoByFile(file) { + if (file.length === 0) { + return; + } + const mimeType = file[0].type; + if (mimeType.match(/video\/*/) == null) { + return; + } + const reader = new FileReader(); + + // Lecture du fichier audio en tant que Data URL + reader.readAsDataURL(file[0]); + + reader.onload = () => { + this.editionService.videoURL = reader.result; + + }; + + // Gestion des erreurs de lecture + reader.onerror = (error) => { + console.error('Erreur lors de la lecture du fichier video:', error); + }; + } + + printAudio(){ + console.log("URL de l'audio : " + this.editionService.audioURL); + } } diff --git a/src/app/components/export/export.component.ts b/src/app/components/export/export.component.ts index 65831e1e4..c23a2b53e 100644 --- a/src/app/components/export/export.component.ts +++ b/src/app/components/export/export.component.ts @@ -111,9 +111,9 @@ export class ExportComponent implements OnInit { this.pageToExportList.push(this.pageToExport); let exportedGrid: Grid; if (this.pageToExport.NumberOfRows !== undefined && this.pageToExport.NumberOfCols !== undefined) { - exportedGrid = new Grid('exportedPage', 'Grid', Number(this.pageToExport.NumberOfCols), Number(this.pageToExport.NumberOfRows), this.gridElementOfPage, this.imageListOfPage, [this.pageToExport]); + exportedGrid = new Grid('exportedPage', 'Grid', Number(this.pageToExport.NumberOfCols), Number(this.pageToExport.NumberOfRows), this.gridElementOfPage, this.imageListOfPage, [this.pageToExport], []); } else { - exportedGrid = new Grid('exportedPage', 'Grid', 10, 10, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList); + exportedGrid = new Grid('exportedPage', 'Grid', 10, 10, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[]); } this.downloadFile(JSON.stringify(exportedGrid)); } @@ -135,9 +135,9 @@ export class ExportComponent implements OnInit { }); let exportedGrid: Grid; if (newPageHomeRow !== undefined && newPageHomeCol !== undefined) { - exportedGrid = new Grid('exportedPage', 'Grid', newPageHomeCol, newPageHomeRow, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList); + exportedGrid = new Grid('exportedPage', 'Grid', newPageHomeCol, newPageHomeRow, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[]); } else { - exportedGrid = new Grid('exportedPage', 'Grid', this.boardService.board.NumberOfCols, this.boardService.board.NumberOfRows, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList); + exportedGrid = new Grid('exportedPage', 'Grid', this.boardService.board.NumberOfCols, this.boardService.board.NumberOfRows, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[]); } this.downloadFile(JSON.stringify(exportedGrid)); } diff --git a/src/app/components/generator-grid/generator-grid.component.ts b/src/app/components/generator-grid/generator-grid.component.ts index 990db25d1..ffc46ffd9 100644 --- a/src/app/components/generator-grid/generator-grid.component.ts +++ b/src/app/components/generator-grid/generator-grid.component.ts @@ -41,15 +41,15 @@ export class GeneratorGridComponent implements OnInit { errorType = ''; constructor(public configuration: ConfigurationService, - public boardService: BoardService, - public editionService: EditionService, - public functionsService: FunctionsService, - public dbnaryService: DbnaryService, - public router: Router, - public multilinguism: MultilinguismService, - public indexedDBacess: IndexeddbaccessService, - public layoutService: LayoutService, - public voiceRecognition: VoiceRecognitionService) { + public boardService: BoardService, + public editionService: EditionService, + public functionsService: FunctionsService, + public dbnaryService: DbnaryService, + public router: Router, + public multilinguism: MultilinguismService, + public indexedDBacess: IndexeddbaccessService, + public layoutService: LayoutService, + public voiceRecognition: VoiceRecognitionService) { } ngOnInit(): void { @@ -64,7 +64,7 @@ export class GeneratorGridComponent implements OnInit { generatedPage.NumberOfCols = Number(this.nbCols); generatedPage.NumberOfRows = Number(this.nbRows); generatedPage.GapSize = 6; - this.boardService.board = new Grid('nothing', 'Grid', Number(this.nbCols), Number(this.nbRows), [], [], [generatedPage]); + this.boardService.board = new Grid('nothing', 'Grid', Number(this.nbCols), Number(this.nbRows), [], [], [generatedPage], []); this.boardService.board.NumberOfCols = Number(this.nbCols); this.boardService.board.NumberOfRows = Number(this.nbRows); this.boardService.updateElementList(); @@ -114,7 +114,7 @@ export class GeneratorGridComponent implements OnInit { (arasaacJson as unknown as ArasaacObject)[0].wordList.forEach(word => { if (text !== null && text !== '' && word.toLowerCase() === text.toLocaleLowerCase() && !this.addOnlyOneImage) { this.addOnlyOneImage = true; - this.imageList.push({ lib: 'arasaacNB', word: this.cleanString(word) }); + this.imageList.push({lib: 'arasaacNB', word: this.cleanString(word)}); return; } }, this); @@ -122,7 +122,7 @@ export class GeneratorGridComponent implements OnInit { (arasaacColoredJson as unknown as ArasaacObject)[0].wordList.forEach(word => { if (text !== null && text !== '' && word.toLowerCase() === text.toLocaleLowerCase() && !this.addOnlyOneImage) { this.addOnlyOneImage = true; - this.imageList.push({ lib: 'arasaacColor', word: this.cleanString(word) }); + this.imageList.push({lib: 'arasaacColor', word: this.cleanString(word)}); } }, this); } @@ -132,7 +132,7 @@ export class GeneratorGridComponent implements OnInit { if (text !== null && text !== '' && value.symbol.toLowerCase() === text.toLocaleLowerCase() && !this.addOnlyOneImage) { this.addOnlyOneImage = true; const url = value.symbol; - this.imageList.push({ lib: 'mulberry', word: this.cleanString(url) }); + this.imageList.push({lib: 'mulberry', word: this.cleanString(url)}); return; } }, this); @@ -148,7 +148,7 @@ export class GeneratorGridComponent implements OnInit { (arasaacJson as unknown as ArasaacObject)[0].wordList.forEach(word => { if (text !== null && text !== '' && word.toLowerCase().includes(text.toLocaleLowerCase()) && !this.addOnlyOneImage) { this.addOnlyOneImage = true; - this.imageList.push({ lib: 'arasaacNB', word: this.cleanString(word) }); + this.imageList.push({lib: 'arasaacNB', word: this.cleanString(word)}); return; } }, this); @@ -156,7 +156,7 @@ export class GeneratorGridComponent implements OnInit { (arasaacColoredJson as unknown as ArasaacObject)[0].wordList.forEach(word => { if (text !== null && text !== '' && word.toLowerCase().includes(text.toLocaleLowerCase()) && !this.addOnlyOneImage) { this.addOnlyOneImage = true; - this.imageList.push({ lib: 'arasaacColor', word: this.cleanString(word) }); + this.imageList.push({lib: 'arasaacColor', word: this.cleanString(word)}); } }, this); } @@ -165,7 +165,7 @@ export class GeneratorGridComponent implements OnInit { if (text !== null && text !== '' && value.symbol.toLowerCase().includes(text.toLocaleLowerCase()) && !this.addOnlyOneImage) { this.addOnlyOneImage = true; const url = value.symbol; - this.imageList.push({ lib: 'mulberry', word: this.cleanString(url) }); + this.imageList.push({lib: 'mulberry', word: this.cleanString(url)}); return; } }, this); @@ -236,8 +236,9 @@ export class GeneratorGridComponent implements OnInit { { DisplayedText: name, VoiceText: name, - LexicInfos: [{ default: true }], - ImageID: tempId + LexicInfos: [{default: true}], + ImageID: tempId, + AudioID: tempId } ); @@ -247,8 +248,8 @@ export class GeneratorGridComponent implements OnInit { this.editionService.interractionList.push({ ID: 'click', ActionList: [ - { ID: 'display', Options: [] }, - { ID: 'say', Options: [] } + {ID: 'display', Options: []}, + {ID: 'say', Options: []} ] }); @@ -295,6 +296,10 @@ export class GeneratorGridComponent implements OnInit { } else { return new FolderGoTo(this.editionService.pageLink); } + } else if (this.editionService.radioTypeFormat === 'sound') { + return 'sound'; + } else if (this.editionService.radioTypeFormat === 'video') { + return 'video'; } else { return 'button'; } diff --git a/src/app/components/import-user/import-user.component.ts b/src/app/components/import-user/import-user.component.ts index 1491765bf..0b73d2536 100644 --- a/src/app/components/import-user/import-user.component.ts +++ b/src/app/components/import-user/import-user.component.ts @@ -66,7 +66,8 @@ export class ImportUserComponent implements OnInit { DisplayedText: element.ElementFormsList[0].DisplayedText, VoiceText: element.ElementFormsList[0].VoiceText, LexicInfos: [{ default: true }], - ImageID: element.ElementFormsList[0].ImageID + ImageID: element.ElementFormsList[0].ImageID, + AudioID: element.ElementFormsList[0].AudioID }); } else { console.log('DEFAULT FORM NOT FOUND FOR ' + element.ID); @@ -74,7 +75,8 @@ export class ImportUserComponent implements OnInit { DisplayedText: element.ID, VoiceText: element.ID, LexicInfos: [{ default: true }], - ImageID: element.ID + ImageID: element.ID, + AudioID: element.ID }); } } diff --git a/src/app/components/import/import.component.ts b/src/app/components/import/import.component.ts index d2f008557..dd266956f 100644 --- a/src/app/components/import/import.component.ts +++ b/src/app/components/import/import.component.ts @@ -211,6 +211,7 @@ export class ImportComponent implements OnInit { VoiceText: name, LexicInfos: [{ default: true }], ImageID: theID, + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }] }]) ); @@ -278,7 +279,8 @@ export class ImportComponent implements OnInit { DisplayedText: element.ElementFormsList[0].DisplayedText, VoiceText: element.ElementFormsList[0].VoiceText, LexicInfos: [{ default: true }], - ImageID: element.ElementFormsList[0].ImageID + ImageID: element.ElementFormsList[0].ImageID, + AudioID: element.ElementFormsList[0].AudioID }); } else { console.log('DEFAULT FORM NOT FOUND FOR ' + element.ID); @@ -286,14 +288,15 @@ export class ImportComponent implements OnInit { DisplayedText: element.ID, VoiceText: element.ID, LexicInfos: [{ default: true }], - ImageID: element.ID + ImageID: element.ID, + AudioID: element.ID }); } } } importPages(zip) { - let importedGrid: Grid = new Grid('newGrid', 'Grid', 0, 0, [], [], []); + let importedGrid: Grid = new Grid('newGrid', 'Grid', 0, 0, [], [], [],[]); const zipFolder: JSZip = new JSZip(); let tempBoard; zipFolder.loadAsync(zip[0]).then((zipFiles) => { diff --git a/src/app/components/information-edition-page/information-edition-page.component.html b/src/app/components/information-edition-page/information-edition-page.component.html index cfb4ca437..8e3a6f6fd 100644 --- a/src/app/components/information-edition-page/information-edition-page.component.html +++ b/src/app/components/information-edition-page/information-edition-page.component.html @@ -15,6 +15,16 @@

{{ multilinguism.translate("buttonDescription") }}

+ + +

{{ multilinguism.translate("soundbuttonDescription") }}

+ + + +

{{ multilinguism.translate("videobuttonDescription") }}

+ @@ -27,7 +37,7 @@ - + - \ No newline at end of file + diff --git a/src/app/components/life-companion2aug/life-companion2aug.component.ts b/src/app/components/life-companion2aug/life-companion2aug.component.ts index 46fc58163..a814fe0ad 100644 --- a/src/app/components/life-companion2aug/life-companion2aug.component.ts +++ b/src/app/components/life-companion2aug/life-companion2aug.component.ts @@ -145,7 +145,7 @@ export class LifeCompanion2augComponent implements OnInit { // get grid information from fileJson and set it in the new grid private newGrid(metadata: any) { - this.grid = new Grid('importedGrid', 'Grid', 6, 6, [], [], []); + this.grid = new Grid('importedGrid', 'Grid', 6, 6, [], [], [], []); let date: Date; const lastDate: Date = new Date(parseInt(metadata.ConfigurationDescription.attr.lastDate)); try { @@ -310,6 +310,7 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: element.attr.textContent, LexicInfos: [{ default: true }], ImageID: element.attr.imageId2 ? element.attr.imageId2 : '', + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); } else { @@ -325,6 +326,7 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: element.attr.textContent, LexicInfos: [{ default: true }], ImageID: element.attr.imageId2 ? element.attr.imageId2 : '', + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); } @@ -680,6 +682,7 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: treeKeyListElement.attr.text, LexicInfos: [{ default: true }], ImageID: treeKeyListElement.attr.imageId2 ? treeKeyListElement.attr.imageId2 : '', + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); } else { @@ -695,6 +698,7 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: treeKeyListElement.attr.text, LexicInfos: [{ default: true }], ImageID: treeKeyListElement.attr.imageId2 ? treeKeyListElement.attr.imageId2 : '', + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); } @@ -747,6 +751,7 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: '', LexicInfos: [{ default: true }], ImageID: '', + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); this.grid.ElementList.push(buttonNextPage); diff --git a/src/app/components/spb2aug/spb2aug.component.ts b/src/app/components/spb2aug/spb2aug.component.ts index df43069a2..51140d1b2 100644 --- a/src/app/components/spb2aug/spb2aug.component.ts +++ b/src/app/components/spb2aug/spb2aug.component.ts @@ -43,7 +43,7 @@ export class Spb2augComponent implements OnInit { } ngOnInit(): void { - this.newGrid = new Grid('newGrid', 'Grid', 0, 0, [], [], []); + this.newGrid = new Grid('newGrid', 'Grid', 0, 0, [], [], [],[]); this.newGrid.software = 'Snap Core first' this.page = new Page(); this.page.ID = '#HOME'; @@ -178,6 +178,7 @@ export class Spb2augComponent implements OnInit { VoiceText: (message) !== null ? message : label, LexicInfos: [{ default: true }], ImageID: (label) !== null ? label : message, + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) const pageUniqueIdFromButtonFolder = buttonsFolder.getAsObject().PageUniqueId; @@ -202,6 +203,7 @@ export class Spb2augComponent implements OnInit { VoiceText: (message) !== null ? message : label, LexicInfos: [{ default: true }], ImageID: (label) !== null ? label : message, + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) const pageUniqueIdFromButtonFolder = buttonsFolder.getAsObject().PageUniqueId; @@ -227,6 +229,7 @@ export class Spb2augComponent implements OnInit { VoiceText: (message) !== null ? message : label, LexicInfos: [{ default: true }], ImageID: (label) !== null ? label : message, + AudioID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) } @@ -442,6 +445,7 @@ export class Spb2augComponent implements OnInit { VoiceText: '', LexicInfos: [{ default: true }], ImageID: '', + AudioID:'' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) this.gridElement.cols = 1; @@ -474,6 +478,7 @@ export class Spb2augComponent implements OnInit { VoiceText: '', LexicInfos: [{ default: true }], ImageID: '', + AudioID:'' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) this.gridElement.cols = 1; @@ -517,6 +522,7 @@ export class Spb2augComponent implements OnInit { VoiceText: label, LexicInfos: [{ default: true }], ImageID: label, + AudioID: label } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) this.gridElement.x = Number(tabResPos[0]); diff --git a/src/app/components/tile/tile.component.ts b/src/app/components/tile/tile.component.ts index 974f67143..922efc429 100644 --- a/src/app/components/tile/tile.component.ts +++ b/src/app/components/tile/tile.component.ts @@ -1,16 +1,16 @@ -import { Component, Input, OnDestroy, OnInit, } from '@angular/core'; -import { HistoricService } from '../../services/historic.service'; -import { EditionService } from '../../services/edition.service'; -import { BoardService } from '../../services/board.service'; -import { ElementForm, FolderGoTo, GridElement, Vignette } from '../../types'; -import { GeticonService } from '../../services/geticon.service'; -import { UsertoolbarService } from '../../services/usertoolbar.service'; -import { Router } from '@angular/router'; -import { SearchService } from '../../services/search.service'; -import { LayoutService } from '../../services/layout.service'; -import { GridElementService } from '../../services/grid-element.service'; -import { DwellCursorService } from '../../services/dwell-cursor.service'; -import { ConfigurationService } from '../../services/configuration.service'; +import {Component, Input, OnDestroy, OnInit,} from '@angular/core'; +import {HistoricService} from '../../services/historic.service'; +import {EditionService} from '../../services/edition.service'; +import {BoardService} from '../../services/board.service'; +import {ElementForm, FolderGoTo, GridElement, Vignette} from '../../types'; +import {GeticonService} from '../../services/geticon.service'; +import {UsertoolbarService} from '../../services/usertoolbar.service'; +import {Router} from '@angular/router'; +import {SearchService} from '../../services/search.service'; +import {LayoutService} from '../../services/layout.service'; +import {GridElementService} from '../../services/grid-element.service'; +import {DwellCursorService} from '../../services/dwell-cursor.service'; +import {ConfigurationService} from '../../services/configuration.service'; @Component({ selector: 'app-tile', @@ -208,6 +208,22 @@ export class TileComponent implements OnInit, OnDestroy { } // for folder + } else if (element.Type === 'sound') { + if (this.editionService.audioURL) { + // Création d'un nouvel élément audio + const audio = new Audio(this.editionService.audioURL); + + // Lecture de l'audio + audio.play().then(() => { + console.log('Audio is playing'); + }).catch(error => { + console.error('Error playing audio:', error); + }); + } else { + console.error('No audio URL found in editionService'); + } + } else if (element.Type === 'video') { + } else if ((element.Type as FolderGoTo).GoTo !== undefined) { let pathTab = this.boardService.currentPath.split('.'); if (pathTab.length >= 2) { @@ -344,7 +360,7 @@ export class TileComponent implements OnInit, OnDestroy { '0px ' + (isFolder ? '-2px ' : '0px ') + (this.gridElementService.getStyle(element).BackgroundColor === undefined - || this.gridElementService.getStyle(element).BackgroundColor == null + || this.gridElementService.getStyle(element).BackgroundColor == null ? '#d3d3d3' : this.gridElementService.getStyle(element).BackgroundColor); diff --git a/src/app/services/board.service.ts b/src/app/services/board.service.ts index 0a6356cca..f868a44a7 100644 --- a/src/app/services/board.service.ts +++ b/src/app/services/board.service.ts @@ -228,6 +228,7 @@ export class BoardService { /*delete the element that is sentenced to death*/ executer() { const imageTemp = []; + const audioTemp = []; // TODO // this.board.ElementList = this.board.ElementList.filter(x => { @@ -251,6 +252,12 @@ export class BoardService { }); this.board.ElementList.forEach((elt) => { + const resaud = this.board.AudioList.find( + (audio) => audio.ID === elt.ElementFormsList[0].AudioID + ); + if (resaud !== null && resaud !== undefined) { + audioTemp.push(resaud); + } const res = this.board.ImageList.find( (img) => img.ID === elt.ElementFormsList[0].ImageID ); @@ -273,6 +280,7 @@ export class BoardService { this.board.ImageList = imageTemp; + this.board.AudioList = audioTemp; this.editionService.sentencedToBeDeletedElement = []; this.updateElementList(); } @@ -435,7 +443,8 @@ export class BoardService { DisplayedText: eltform.DisplayedText, VoiceText: eltform.VoiceText, LexicInfos: eltform.LexicInfos, - ImageID: '' + eltform.ImageID + ImageID: '' + eltform.ImageID, + AudioID: '' + eltform.AudioID }], compElt.InteractionsList.slice() ); @@ -456,7 +465,8 @@ export class BoardService { DisplayedText: 'back', VoiceText: 'back', LexicInfos: [], - ImageID: '#back' + ImageID: '#back', + AudioID: '' }]; diff --git a/src/app/services/edition.service.ts b/src/app/services/edition.service.ts index 3f47d9f5e..85b7d88cd 100644 --- a/src/app/services/edition.service.ts +++ b/src/app/services/edition.service.ts @@ -54,12 +54,15 @@ export class EditionService { */ imageURL: any = ''; + audioURL: any = ''; + + videoURL: any = ''; + /** * the type of the current element (button by default) */ radioTypeFormat = 'button'; - menu: string[] = ['information', 'appearance'/*, 'grammar'*/, 'otherForms', 'interactions']; currentEditPage = 'information'; @@ -113,6 +116,8 @@ export class EditionService { this.interractionList = []; this.variantList = []; this.imageURL = ''; + this.audioURL = ''; + this.videoURL = ''; this.radioTypeFormat = 'button'; this.currentEditPage = 'information'; this.curentColor = '#d3d3d3'; diff --git a/src/app/services/functions.service.ts b/src/app/services/functions.service.ts index 815101f3d..22eb00cd6 100644 --- a/src/app/services/functions.service.ts +++ b/src/app/services/functions.service.ts @@ -39,6 +39,7 @@ export class FunctionsService { 'otherforms', 'back', 'backHome', + 'sound' ) } diff --git a/src/app/services/proloquoParser.ts b/src/app/services/proloquoParser.ts index ceb6a020a..4933c4a56 100644 --- a/src/app/services/proloquoParser.ts +++ b/src/app/services/proloquoParser.ts @@ -238,7 +238,8 @@ export class ProloquoParser { DisplayedText: word.mot, VoiceText: word.mot, LexicInfos: [{ default: true }], - ImageID: word.wordID + ImageID: word.wordID, + AudioID: '' } ], interList @@ -279,6 +280,7 @@ export class ProloquoParser { GapSize: 5, ElementList: tempElement, ImageList: [], + AudioList: [], PageList: tempPage }; } diff --git a/src/app/services/speakForYourselfParser.ts b/src/app/services/speakForYourselfParser.ts index 9a557b9b7..1ee9806a2 100644 --- a/src/app/services/speakForYourselfParser.ts +++ b/src/app/services/speakForYourselfParser.ts @@ -30,7 +30,7 @@ export class SpeakForYourselfParser { } createGrid() { - const grille: Grid = new Grid('speak4yourself', 'Grid', 12, 12, [], [], []); + const grille: Grid = new Grid('speak4yourself', 'Grid', 12, 12, [], [], [], []); this.speak4Yourself.forEach(element => { if (element.page === 'HOME') { @@ -73,7 +73,8 @@ export class SpeakForYourselfParser { DisplayedText: element.mot, VoiceText: element.mot, LexicInfos: [{ default: true }], - ImageID: '' + ImageID: '', + AudioID: '' }], [{ ID: 'click', diff --git a/src/app/types.ts b/src/app/types.ts index d45a67b63..30a51401b 100644 --- a/src/app/types.ts +++ b/src/app/types.ts @@ -22,19 +22,21 @@ export class Grid { ElementList: GridElement[]; ImageList: Image[]; + AudioList: Audio[]; PageList: Page[]; BackgroundColor: string; - constructor(gridId, gridType, gridCol, gridRow, elemList, imageList, pageList) { + constructor(gridId, gridType, gridCol, gridRow, elemList, imageList, pageList,AudioList) { this.ID = gridId; this.Type = gridType; this.NumberOfCols = Number(gridCol); this.NumberOfRows = Number(gridRow); this.ElementList = elemList; this.ImageList = imageList; + this.AudioList = AudioList; this.PageList = pageList; } @@ -53,7 +55,7 @@ export class FolderGoTo { */ export class GridElement { ID: string; - Type: 'empty' | 'button' | FolderGoTo; + Type: 'empty' | 'button' | 'sound' | 'video' | FolderGoTo; PartOfSpeech: '-nom-' | '-nom-pr-' | 'nom de famille' | '-adv-' | 'prénom' | '-adj-' | 'variante typographique' | '-verb' | 'pronom' | 'locution-phrase' | 'interjection' | 'onomatopée' | 'pronom démonstratif' | 'adjectif indéfini' | 'pronom indéfini' | 'pronom personnel' | 'conjonction' | 'adjectif numéral' | 'préposition' | 'article partitif' | 'adverbe interrogatif' | 'conjonction de coordination' | 'pronom interrogatif' | 'pronom relatif' | 'pronom possessif' | 'erreur' | 'locution phrase' | 'proverbe' | 'adverbe relatif' | 'nom scientifique' | 'adjectif exclamatif' | 'adjectif interrogatif' | 'adjectif possessif' | 'adjectif démonstratif' | 'patronyme' | 'article défini' | 'interj' | 'locution' | 'article indéfini' | string; VisibilityLevel: number; x: number; @@ -92,7 +94,7 @@ export class GridElement { */ export class GridElementGenerated { ID: string; - Type: 'empty' | 'button' | FolderGoTo; + Type: 'empty' | 'button' | 'sound' | 'video' | FolderGoTo; PartOfSpeech: '-nom-' | '-nom-pr-' | 'nom de famille' | '-adv-' | 'prénom' | '-adj-' | 'variante typographique' | '-verb' | 'pronom' | 'locution-phrase' | 'interjection' | 'onomatopée' | 'pronom démonstratif' | 'adjectif indéfini' | 'pronom indéfini' | 'pronom personnel' | 'conjonction' | 'adjectif numéral' | 'préposition' | 'article partitif' | 'adverbe interrogatif' | 'conjonction de coordination' | 'pronom interrogatif' | 'pronom relatif' | 'pronom possessif' | 'erreur' | 'locution phrase' | 'proverbe' | 'adverbe relatif' | 'nom scientifique' | 'adjectif exclamatif' | 'adjectif interrogatif' | 'adjectif possessif' | 'adjectif démonstratif' | 'patronyme' | 'article défini' | 'interj' | 'locution' | 'article indéfini' | string; VisibilityLevel: number; x: number; @@ -145,6 +147,12 @@ export class Image { Path: string; } +export class Audio { + ID: string; + OriginalName: string; + Path: string; +} + export class Interaction { ID: string; // 'click' | 'longPress' | 'doubleClick'; ActionList: Action[]; @@ -166,6 +174,7 @@ export class ElementForm { VoiceText: string; LexicInfos: any[]; ImageID: string; + AudioID: string; } export class Page { diff --git a/src/assets/multilinguism.json b/src/assets/multilinguism.json index fedeedc77..45058eb0f 100644 --- a/src/assets/multilinguism.json +++ b/src/assets/multilinguism.json @@ -367,6 +367,12 @@ { "id" : "deactivateDwell", "FR": "Désactiver la sélection par fixation", "EN": "Disable selection by focus"}, { "id" : "buttonDescription", "FR": "L'élément créé sera un simple bouton", "EN": "The element will be a simple button"}, { "id" : "folderDescription", "FR": "L'élément créé sera un dossier pouvant contenir d'autres boutons", "EN": "The element will be a folder that can contain other buttons"}, + { "id" : "soundbuttonDescription", "FR": "L'élément créé sera un bouton qui lancera un bruit quand il sera utilisé", "EN": "The element will be a button that does a sound when used"}, + { "id" : "videobuttonDescription", "FR": "L'élément créé sera un bouton qui lancera une vidéo quand il sera utilisé", "EN": "The element will be a button that launch a video when used"}, + { "id" : "soundButton", "FR": "Bouton son", "EN": "Sound button"}, + { "id" : "videoButton", "FR": "Bouton vidéo", "EN": "Video button"}, + { "id" : "addSoundByFile", "FR": "Ajouter le son depuis un fichier de votre ordinateur", "EN": "Add the sound by a File from your computer"}, + { "id" : "addVideoByFile", "FR": "Ajouter la vidéo depuis un fichier de votre ordinateur", "EN": "Add the video by a File from your computer"}, { "id" : "warningQuit", "FR": "Voulez vous vraiment quitter ? Les modifications non sauvegardées seront perdues", "EN": "Are you sure you want to quit ? Unsaved changes will be lost"}, { "id" : "export", "FR": "Export", "EN": "Export"}, { "id" : "exportStyle", "FR": "Mise en page", "EN" : "Export style"}, @@ -374,6 +380,5 @@ { "id" : "WordNameFile", "FR": "ClavierAugCom", "EN": "GridFileAugcom"}, { "id" : "WordTitle", "FR": "Clavier Augcom", "EN": "AugCom main grid"}, { "id" : "WordFolder", "FR": "Sous Dossier", "EN": "Folder"} - ] } From 25c18de455f4c8f424f310ef437e6df79e7f18a9 Mon Sep 17 00:00:00 2001 From: eliaspue Date: Thu, 27 Jun 2024 16:48:18 +0200 Subject: [PATCH 2/7] Adding video button w/o final interaction --- src/app/app.module.ts | 23 ++-- .../alternative-forms.component.ts | 5 +- .../dialog-add-grid.component.ts | 2 +- .../dialog-export-pages.component.ts | 4 +- .../dialog-model-grid.component.ts | 2 +- .../dialog-reset-grid.component.ts | 2 +- .../components/edition/edition.component.ts | 45 ++++++-- src/app/components/event/event.component.html | 2 - src/app/components/event/event.component.ts | 3 - src/app/components/export/export.component.ts | 8 +- .../generator-grid.component.ts | 7 +- .../import-user/import-user.component.ts | 6 +- src/app/components/import/import.component.ts | 12 +- .../life-companion2aug.component.ts | 17 ++- .../components/spb2aug/spb2aug.component.ts | 20 ++-- src/app/components/tile/tile.component.ts | 108 +++++++++++++++--- src/app/services/board.service.ts | 22 +++- src/app/services/functions.service.ts | 3 +- src/app/services/proloquoParser.ts | 4 +- src/app/services/speakForYourselfParser.ts | 5 +- src/app/types.ts | 11 +- src/assets/defaultsave.json | 14 +++ src/assets/multilinguism.json | 4 +- 23 files changed, 251 insertions(+), 78 deletions(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7d7543e7e..93b13e5f5 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,6 +1,5 @@ import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; - import { AppComponent } from './app.component'; import { UsertoolbarComponent } from './components/usertoolbar/usertoolbar.component'; import { EditionComponent } from './components/edition/edition.component'; @@ -41,28 +40,28 @@ import { GridFormatManagementComponent } from './components/grid-format-manageme import { PictogramStyleComponent } from './components/pictogram-style/pictogram-style.component'; import { DwellCursorComponent } from './components/dwell-cursor/dwell-cursor.component'; import { MainComponent } from './components/main/main.component'; -import { MatAutocompleteModule } from "@angular/material/autocomplete"; +import { MatAutocompleteModule } from '@angular/material/autocomplete'; import { UserPageComponent } from './components/user-page/user-page.component'; -import { MatCardModule } from "@angular/material/card"; -import { MatGridListModule } from "@angular/material/grid-list"; +import { MatCardModule } from '@angular/material/card'; +import { MatGridListModule } from '@angular/material/grid-list'; import { DialogDeleteUserComponent } from './components/dialog-delete-user/dialog-delete-user.component'; import { DialogChangeUserComponent } from './components/dialog-change-user/dialog-change-user.component'; import { DialogAddUserComponent } from './components/dialog-add-user/dialog-add-user.component'; import { DialogTextComponent } from './components/dialog-text/dialog-text.component'; -import { MatInputModule } from "@angular/material/input"; +import { MatInputModule } from '@angular/material/input'; import { MentionComponent } from './components/mention/mention.component'; import { DeletePageComponent } from './components/delete-page/delete-page.component'; import { MatListModule } from '@angular/material/list'; import { DialogDeletePageComponent } from './components/dialog-delete-page/dialog-delete-page.component'; import { MatButtonModule } from '@angular/material/button'; -import { MatDialogModule } from "@angular/material/dialog"; -import { MatMenuModule } from "@angular/material/menu"; -import { MatFormFieldModule } from "@angular/material/form-field"; -import { MatSelectModule } from "@angular/material/select"; -import { MatCheckboxModule } from "@angular/material/checkbox"; +import { MatDialogModule } from '@angular/material/dialog'; +import { MatMenuModule } from '@angular/material/menu'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatSelectModule } from '@angular/material/select'; +import { MatCheckboxModule } from '@angular/material/checkbox'; import { Spb2augComponent } from './components/spb2aug/spb2aug.component'; import { DialogHelpComponent } from './components/dialog-help/dialog-help.component'; -import { MatIconModule } from "@angular/material/icon"; +import { MatIconModule } from '@angular/material/icon'; import { ResetConfigurationComponent } from './components/reset-configuration/reset-configuration.component'; import { ResetGridComponent } from './components/reset-grid/reset-grid.component'; import { DialogResetGridComponent } from './components/dialog-reset-grid/dialog-reset-grid.component'; @@ -76,7 +75,7 @@ import { DialogLinkAFSRComponent } from './components/dialog-link-afsr/dialog-li import { DialogLinkInteraactionboxComponent } from './components/dialog-link-interaactionbox/dialog-link-interaactionbox.component'; import { LoadingUserComponent } from './components/loading-user/loading-user.component'; import { DialogResetSettingsComponent } from './components/dialog-reset-settings/dialog-reset-settings.component'; -import { LifeCompanion2augComponent } from "./components/life-companion2aug/life-companion2aug.component"; +import { LifeCompanion2augComponent } from './components/life-companion2aug/life-companion2aug.component'; import { ModelGridComponent } from './components/model-grid/model-grid.component'; import { DialogModelGridComponent } from './components/dialog-model-grid/dialog-model-grid.component'; import { DialogExportPagesComponent } from './components/dialog-export-pages/dialog-export-pages.component'; diff --git a/src/app/components/alternative-forms/alternative-forms.component.ts b/src/app/components/alternative-forms/alternative-forms.component.ts index 05842ff6d..69614c008 100644 --- a/src/app/components/alternative-forms/alternative-forms.component.ts +++ b/src/app/components/alternative-forms/alternative-forms.component.ts @@ -35,6 +35,7 @@ export class AlternativeFormsComponent implements OnInit { } imageList = []; + AudioList = []; elementFormNameImageURL: any = ''; elementFormDisplayedWordField = ''; elementFormPronouncedWordField = ''; @@ -289,7 +290,7 @@ export class AlternativeFormsComponent implements OnInit { } /** - * Shows the image corresponding to a combination of selected library (mulberry or arasaac) and searched word (any) + * Shows the image corresponding to a combination of selected library (mulberry or arasaac) and searched word (any) * @param elt library to be used and word to be searched */ previewLibrary(elt: { lib, word }) { @@ -313,7 +314,7 @@ export class AlternativeFormsComponent implements OnInit { } /** - * + * * @param elt library to be used and word to be searched * @returns an url corresponding to the searched image's name in the selected library */ diff --git a/src/app/components/dialog-add-grid/dialog-add-grid.component.ts b/src/app/components/dialog-add-grid/dialog-add-grid.component.ts index 43f7de16c..b937aded4 100644 --- a/src/app/components/dialog-add-grid/dialog-add-grid.component.ts +++ b/src/app/components/dialog-add-grid/dialog-add-grid.component.ts @@ -45,7 +45,7 @@ export class DialogAddGridComponent implements OnInit { page.ElementIDsList = []; page.NumberOfCols = 0; page.NumberOfRows = 0; - this.boardService.board = new Grid(this.nameGrid, 'Grid', 6, 6, [], [], [page], []); + this.boardService.board = new Grid(this.nameGrid, 'Grid', 6, 6, [], [], [page], [], []); } this.boardService.board.software = 'Augcom'; this.boardService.board.ID = this.nameGrid; diff --git a/src/app/components/dialog-export-pages/dialog-export-pages.component.ts b/src/app/components/dialog-export-pages/dialog-export-pages.component.ts index e6a5e93a8..ca833f0ff 100644 --- a/src/app/components/dialog-export-pages/dialog-export-pages.component.ts +++ b/src/app/components/dialog-export-pages/dialog-export-pages.component.ts @@ -43,10 +43,10 @@ export class DialogExportPagesComponent implements OnInit { }) let exportedGrid: Grid; if (this.pageToExport.NumberOfRows !== undefined && this.pageToExport.NumberOfCols !== undefined) { - exportedGrid = new Grid('exportedPage', 'Grid', Number(this.pageToExport.NumberOfCols), Number(this.pageToExport.NumberOfRows), this.gridElementOfPage, this.imageListOfPage, [this.pageToExport], []); + exportedGrid = new Grid('exportedPage', 'Grid', Number(this.pageToExport.NumberOfCols), Number(this.pageToExport.NumberOfRows), this.gridElementOfPage, this.imageListOfPage, [this.pageToExport], [], []); } else { - exportedGrid = new Grid('exportedPage', 'Grid', 10, 10, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList, []); + exportedGrid = new Grid('exportedPage', 'Grid', 10, 10, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList, [],[]); } this.downloadFile(JSON.stringify(exportedGrid)); } diff --git a/src/app/components/dialog-model-grid/dialog-model-grid.component.ts b/src/app/components/dialog-model-grid/dialog-model-grid.component.ts index e1940ea30..70bb9e3dc 100644 --- a/src/app/components/dialog-model-grid/dialog-model-grid.component.ts +++ b/src/app/components/dialog-model-grid/dialog-model-grid.component.ts @@ -29,7 +29,7 @@ export class DialogModelGridComponent implements OnInit { page.ID = '#HOME'; page.Name = 'Accueil'; page.ElementIDsList = []; - this.boardService.board = new Grid('newGrid', 'Grid', 6, 6, [], [], [page], []); + this.boardService.board = new Grid('newGrid', 'Grid', 6, 6, [], [], [page], [], []); } this.boardService.updateElementList(); } diff --git a/src/app/components/dialog-reset-grid/dialog-reset-grid.component.ts b/src/app/components/dialog-reset-grid/dialog-reset-grid.component.ts index 1d55015ac..fcde1b557 100644 --- a/src/app/components/dialog-reset-grid/dialog-reset-grid.component.ts +++ b/src/app/components/dialog-reset-grid/dialog-reset-grid.component.ts @@ -28,7 +28,7 @@ export class DialogResetGridComponent implements OnInit { homePage.NumberOfCols = 3; homePage.NumberOfRows = 3; homePage.GapSize = 6; - this.boardService.board = new Grid('nothing', 'Grid', 0, 0, [], [], [homePage],[]); + this.boardService.board = new Grid('nothing', 'Grid', 0, 0, [], [], [homePage],[], []); this.boardService.updateElementList(); } diff --git a/src/app/components/edition/edition.component.ts b/src/app/components/edition/edition.component.ts index 055792e7c..29b2ea4c2 100644 --- a/src/app/components/edition/edition.component.ts +++ b/src/app/components/edition/edition.component.ts @@ -175,7 +175,8 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { VoiceText: this.editionService.name, LexicInfos: [{default: true}], ImageID: elt.ElementFormsList[0].ImageID, - AudioID: elt.ElementFormsList[0].AudioID + AudioID: elt.ElementFormsList[0].AudioID, + videoID: elt.ElementFormsList[0].VideoID } ); } @@ -276,12 +277,19 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { this.boardService.board.AudioList.push( { - ID: this.editionService.audioURL, + ID: this.editionService.getDefaultForm(element.ElementFormsList).AudioID, OriginalName: this.editionService.name, Path: this.editionService.audioURL } ); + this.boardService.board.VideoList.push( + { + ID: this.editionService.getDefaultForm(element.ElementFormsList).VideoID, + OriginalName: this.editionService.name, + Path: this.editionService.videoURL + } + ); } } @@ -303,7 +311,8 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { VoiceText: this.editionService.name, LexicInfos: [{default: true}], ImageID: tempId, - AudioID: tempId + AudioID: tempId, + VideoID: tempId } ); @@ -345,6 +354,14 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { } ); + this.boardService.board.VideoList.push( + { + ID: tempId, + OriginalName: this.editionService.name, + Path: this.editionService.videoURL + } + ); + const currentPage: Page = this.getCurrentPage(); currentPage.ElementIDsList.push(tempId); @@ -402,7 +419,7 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { } this.editionService.pageLink = elementToModif.Type === 'button' ? '@' : (elementToModif.Type as FolderGoTo).GoTo; const imageToModif = this.boardService.board.ImageList.find(x => x.ID === elementToModif.ElementFormsList[0].ImageID); - if (imageToModif != null && imageToModif !== undefined) { + if (imageToModif != null) { this.editionService.imageURL = imageToModif.Path; } else { this.editionService.imageURL = ''; @@ -410,8 +427,20 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { // Mise à jour de l'URL de l'audio if (elementToModif.Type === 'sound') { - const audioToModif = this.boardService.board.AudioList.find(x => x.ID === elementToModif.ElementFormsList[0].AudioID); - if (audioToModif != null && audioToModif !== undefined) { + const videoToModif = this.boardService.board.VideoList.find(x => x.ID === elementToModif.ElementFormsList[0].AudioID); + if (videoToModif != null) { + this.editionService.videoURL = audioToModif.Path; + } else { + this.editionService.videoURL = ''; + } + } else { + this.editionService.videoURL = ''; + } + + // Mise à jour de l'URL de la video + if (elementToModif.Type === 'video') { + const audioToModif = this.boardService.board.VideoList.find(x => x.ID === elementToModif.ElementFormsList[0].AudioID); + if (audioToModif != null) { this.editionService.audioURL = audioToModif.Path; } else { this.editionService.audioURL = ''; @@ -420,14 +449,14 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { this.editionService.audioURL = ''; } - if (elementToModif.ElementFormsList != null && elementToModif.ElementFormsList !== undefined) { + if (elementToModif.ElementFormsList != null) { this.editionService.variantList = Object.assign([], elementToModif.ElementFormsList); } else { this.editionService.variantList = []; } - if (elementToModif.InteractionsList != null && elementToModif.InteractionsList !== undefined) { + if (elementToModif.InteractionsList != null) { this.editionService.interractionList = Object.assign([], elementToModif.InteractionsList); } else { this.editionService.interractionList = []; diff --git a/src/app/components/event/event.component.html b/src/app/components/event/event.component.html index eae52ca94..3b87df27e 100644 --- a/src/app/components/event/event.component.html +++ b/src/app/components/event/event.component.html @@ -56,8 +56,6 @@ type="file"> - - diff --git a/src/app/components/event/event.component.ts b/src/app/components/event/event.component.ts index 48f3eebd0..0f8319791 100644 --- a/src/app/components/event/event.component.ts +++ b/src/app/components/event/event.component.ts @@ -177,7 +177,4 @@ export class EventComponent implements OnInit, OnDestroy { }; } - printAudio(){ - console.log("URL de l'audio : " + this.editionService.audioURL); - } } diff --git a/src/app/components/export/export.component.ts b/src/app/components/export/export.component.ts index c23a2b53e..bfb0db5d6 100644 --- a/src/app/components/export/export.component.ts +++ b/src/app/components/export/export.component.ts @@ -111,9 +111,9 @@ export class ExportComponent implements OnInit { this.pageToExportList.push(this.pageToExport); let exportedGrid: Grid; if (this.pageToExport.NumberOfRows !== undefined && this.pageToExport.NumberOfCols !== undefined) { - exportedGrid = new Grid('exportedPage', 'Grid', Number(this.pageToExport.NumberOfCols), Number(this.pageToExport.NumberOfRows), this.gridElementOfPage, this.imageListOfPage, [this.pageToExport], []); + exportedGrid = new Grid('exportedPage', 'Grid', Number(this.pageToExport.NumberOfCols), Number(this.pageToExport.NumberOfRows), this.gridElementOfPage, this.imageListOfPage, [this.pageToExport], [], []); } else { - exportedGrid = new Grid('exportedPage', 'Grid', 10, 10, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[]); + exportedGrid = new Grid('exportedPage', 'Grid', 10, 10, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[],[]); } this.downloadFile(JSON.stringify(exportedGrid)); } @@ -135,9 +135,9 @@ export class ExportComponent implements OnInit { }); let exportedGrid: Grid; if (newPageHomeRow !== undefined && newPageHomeCol !== undefined) { - exportedGrid = new Grid('exportedPage', 'Grid', newPageHomeCol, newPageHomeRow, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[]); + exportedGrid = new Grid('exportedPage', 'Grid', newPageHomeCol, newPageHomeRow, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[],[]); } else { - exportedGrid = new Grid('exportedPage', 'Grid', this.boardService.board.NumberOfCols, this.boardService.board.NumberOfRows, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[]); + exportedGrid = new Grid('exportedPage', 'Grid', this.boardService.board.NumberOfCols, this.boardService.board.NumberOfRows, this.gridElementOfPage, this.imageListOfPage, this.pageToExportList,[],[]); } this.downloadFile(JSON.stringify(exportedGrid)); } diff --git a/src/app/components/generator-grid/generator-grid.component.ts b/src/app/components/generator-grid/generator-grid.component.ts index ffc46ffd9..b6cdac79b 100644 --- a/src/app/components/generator-grid/generator-grid.component.ts +++ b/src/app/components/generator-grid/generator-grid.component.ts @@ -33,6 +33,8 @@ export class GeneratorGridComponent implements OnInit { libToUse = 'arasaacNB'; imageList = []; + audioList = []; + videoList = []; imageUrlList = []; addOnlyOneImage; @@ -64,7 +66,7 @@ export class GeneratorGridComponent implements OnInit { generatedPage.NumberOfCols = Number(this.nbCols); generatedPage.NumberOfRows = Number(this.nbRows); generatedPage.GapSize = 6; - this.boardService.board = new Grid('nothing', 'Grid', Number(this.nbCols), Number(this.nbRows), [], [], [generatedPage], []); + this.boardService.board = new Grid('nothing', 'Grid', Number(this.nbCols), Number(this.nbRows), [], [], [generatedPage], [],[]); this.boardService.board.NumberOfCols = Number(this.nbCols); this.boardService.board.NumberOfRows = Number(this.nbRows); this.boardService.updateElementList(); @@ -238,7 +240,8 @@ export class GeneratorGridComponent implements OnInit { VoiceText: name, LexicInfos: [{default: true}], ImageID: tempId, - AudioID: tempId + AudioID: tempId, + VideoID: tempid } ); diff --git a/src/app/components/import-user/import-user.component.ts b/src/app/components/import-user/import-user.component.ts index 0b73d2536..0e2d476ea 100644 --- a/src/app/components/import-user/import-user.component.ts +++ b/src/app/components/import-user/import-user.component.ts @@ -67,7 +67,8 @@ export class ImportUserComponent implements OnInit { VoiceText: element.ElementFormsList[0].VoiceText, LexicInfos: [{ default: true }], ImageID: element.ElementFormsList[0].ImageID, - AudioID: element.ElementFormsList[0].AudioID + AudioID: element.ElementFormsList[0].AudioID, + VideoID: element.ElementFormsList[0].VideoID }); } else { console.log('DEFAULT FORM NOT FOUND FOR ' + element.ID); @@ -76,7 +77,8 @@ export class ImportUserComponent implements OnInit { VoiceText: element.ID, LexicInfos: [{ default: true }], ImageID: element.ID, - AudioID: element.ID + AudioID: element.ID, + VideoID: element.ID }); } } diff --git a/src/app/components/import/import.component.ts b/src/app/components/import/import.component.ts index dd266956f..818f152d5 100644 --- a/src/app/components/import/import.component.ts +++ b/src/app/components/import/import.component.ts @@ -90,6 +90,7 @@ export class ImportComponent implements OnInit { this.boardService.board.PageList = []; this.boardService.board.ElementList = []; this.boardService.board.ImageList = []; + this.boardService.board.AudioList = []; zipFiles.forEach((fileName) => { if (fileName[fileName.length - 1] !== '/') { zipFolder @@ -211,7 +212,8 @@ export class ImportComponent implements OnInit { VoiceText: name, LexicInfos: [{ default: true }], ImageID: theID, - AudioID: '' + AudioID: '', + videoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }] }]) ); @@ -280,7 +282,8 @@ export class ImportComponent implements OnInit { VoiceText: element.ElementFormsList[0].VoiceText, LexicInfos: [{ default: true }], ImageID: element.ElementFormsList[0].ImageID, - AudioID: element.ElementFormsList[0].AudioID + AudioID: element.ElementFormsList[0].AudioID, + VideoID: element.ElementFormsList[0].VideoID }); } else { console.log('DEFAULT FORM NOT FOUND FOR ' + element.ID); @@ -289,14 +292,15 @@ export class ImportComponent implements OnInit { VoiceText: element.ID, LexicInfos: [{ default: true }], ImageID: element.ID, - AudioID: element.ID + AudioID: element.ID, + VideoID: element.ID }); } } } importPages(zip) { - let importedGrid: Grid = new Grid('newGrid', 'Grid', 0, 0, [], [], [],[]); + let importedGrid: Grid = new Grid('newGrid', 'Grid', 0, 0, [], [], [],[],[]); const zipFolder: JSZip = new JSZip(); let tempBoard; zipFolder.loadAsync(zip[0]).then((zipFiles) => { diff --git a/src/app/components/life-companion2aug/life-companion2aug.component.ts b/src/app/components/life-companion2aug/life-companion2aug.component.ts index a814fe0ad..3762d9875 100644 --- a/src/app/components/life-companion2aug/life-companion2aug.component.ts +++ b/src/app/components/life-companion2aug/life-companion2aug.component.ts @@ -145,7 +145,7 @@ export class LifeCompanion2augComponent implements OnInit { // get grid information from fileJson and set it in the new grid private newGrid(metadata: any) { - this.grid = new Grid('importedGrid', 'Grid', 6, 6, [], [], [], []); + this.grid = new Grid('importedGrid', 'Grid', 6, 6, [], [], [], [],[]); let date: Date; const lastDate: Date = new Date(parseInt(metadata.ConfigurationDescription.attr.lastDate)); try { @@ -310,7 +310,8 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: element.attr.textContent, LexicInfos: [{ default: true }], ImageID: element.attr.imageId2 ? element.attr.imageId2 : '', - AudioID: '' + AudioID: '', + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); } else { @@ -326,7 +327,8 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: element.attr.textContent, LexicInfos: [{ default: true }], ImageID: element.attr.imageId2 ? element.attr.imageId2 : '', - AudioID: '' + AudioID: '', + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); } @@ -682,7 +684,8 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: treeKeyListElement.attr.text, LexicInfos: [{ default: true }], ImageID: treeKeyListElement.attr.imageId2 ? treeKeyListElement.attr.imageId2 : '', - AudioID: '' + AudioID: '', + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); } else { @@ -698,7 +701,8 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: treeKeyListElement.attr.text, LexicInfos: [{ default: true }], ImageID: treeKeyListElement.attr.imageId2 ? treeKeyListElement.attr.imageId2 : '', - AudioID: '' + AudioID: '', + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); } @@ -751,7 +755,8 @@ export class LifeCompanion2augComponent implements OnInit { VoiceText: '', LexicInfos: [{ default: true }], ImageID: '', - AudioID: '' + AudioID: '', + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]); this.grid.ElementList.push(buttonNextPage); diff --git a/src/app/components/spb2aug/spb2aug.component.ts b/src/app/components/spb2aug/spb2aug.component.ts index 51140d1b2..bb213ee67 100644 --- a/src/app/components/spb2aug/spb2aug.component.ts +++ b/src/app/components/spb2aug/spb2aug.component.ts @@ -43,7 +43,7 @@ export class Spb2augComponent implements OnInit { } ngOnInit(): void { - this.newGrid = new Grid('newGrid', 'Grid', 0, 0, [], [], [],[]); + this.newGrid = new Grid('newGrid', 'Grid', 0, 0, [], [], [],[], []); this.newGrid.software = 'Snap Core first' this.page = new Page(); this.page.ID = '#HOME'; @@ -178,7 +178,8 @@ export class Spb2augComponent implements OnInit { VoiceText: (message) !== null ? message : label, LexicInfos: [{ default: true }], ImageID: (label) !== null ? label : message, - AudioID: '' + AudioID: '', + videoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) const pageUniqueIdFromButtonFolder = buttonsFolder.getAsObject().PageUniqueId; @@ -203,7 +204,8 @@ export class Spb2augComponent implements OnInit { VoiceText: (message) !== null ? message : label, LexicInfos: [{ default: true }], ImageID: (label) !== null ? label : message, - AudioID: '' + AudioID: '', + videoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) const pageUniqueIdFromButtonFolder = buttonsFolder.getAsObject().PageUniqueId; @@ -229,7 +231,8 @@ export class Spb2augComponent implements OnInit { VoiceText: (message) !== null ? message : label, LexicInfos: [{ default: true }], ImageID: (label) !== null ? label : message, - AudioID: '' + AudioID: '', + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) } @@ -445,7 +448,8 @@ export class Spb2augComponent implements OnInit { VoiceText: '', LexicInfos: [{ default: true }], ImageID: '', - AudioID:'' + AudioID: '', + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) this.gridElement.cols = 1; @@ -478,7 +482,8 @@ export class Spb2augComponent implements OnInit { VoiceText: '', LexicInfos: [{ default: true }], ImageID: '', - AudioID:'' + AudioID: '', + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) this.gridElement.cols = 1; @@ -522,7 +527,8 @@ export class Spb2augComponent implements OnInit { VoiceText: label, LexicInfos: [{ default: true }], ImageID: label, - AudioID: label + AudioID: label, + VideoID: label } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) this.gridElement.x = Number(tabResPos[0]); diff --git a/src/app/components/tile/tile.component.ts b/src/app/components/tile/tile.component.ts index 922efc429..c66849c1c 100644 --- a/src/app/components/tile/tile.component.ts +++ b/src/app/components/tile/tile.component.ts @@ -209,21 +209,103 @@ export class TileComponent implements OnInit, OnDestroy { // for folder } else if (element.Type === 'sound') { - if (this.editionService.audioURL) { - // Création d'un nouvel élément audio - const audio = new Audio(this.editionService.audioURL); - - // Lecture de l'audio - audio.play().then(() => { - console.log('Audio is playing'); - }).catch(error => { - console.error('Error playing audio:', error); - }); - } else { - console.error('No audio URL found in editionService'); - } + const prononcedText = this.boardService.getLabel(element); + const color = this.gridElementService.getStyle(element).BackgroundColor; + const borderColor = this.gridElementService.getStyle(element).BorderColor; + const imgUrl = this.boardService.getImgUrl(element); + const vignette: Vignette = { + Label: prononcedText, + ImagePath: imgUrl, + Color: color, + BorderColor: borderColor, + }; + let otherFormsDisplayed = false; + element.InteractionsList.forEach((inter) => { + if (inter.ID === interaction) { + inter.ActionList.forEach((action) => { + if (action.ID === 'pronomChangeInfo') { + this.changePronomInfo(element.ElementFormsList[0]); + } else if (action.ID === 'display') { + this.historicService.push(vignette); + } else if (action.ID === 'say') { + this.historicService.say('' + prononcedText); + } else if (action.ID === 'otherforms' && element.ElementFormsList.length > 1) { + otherFormsDisplayed = true; + this.boardService.activatedElement = this.boardService + .getNormalTempList() + .indexOf(element); + this.boardService.activatedElementTempList(); + this.pressedElement = null; + } else if (action.ID === 'backFromVariant' && !otherFormsDisplayed) { + this.boardService.activatedElement = -1; + } else if (action.ID === 'back') { + this.boardService.backToPreviousFolder(); + } else if (action.ID === 'backHome') { + this.boardService.backHome(); + } else if (action.ID ==='sound'){ + const AudioURL = this.boardService.getAudioUrl(element); + console.log(element); + if (AudioURL) { + console.log(AudioURL); + // Création d'un nouvel élément audioAudioURL + const audio = new Audio(AudioURL); + + // Lecture de l'audio + audio.play().then(() => { + console.log('Audio is playing'); + }).catch(error => { + console.error('Error playing audio:', error); + }); + } else { + console.log(this.editionService); + console.error('No audio URL found in editionService'); + } + } + }); + } + }); } else if (element.Type === 'video') { + const prononcedText = this.boardService.getLabel(element); + const color = this.gridElementService.getStyle(element).BackgroundColor; + const borderColor = this.gridElementService.getStyle(element).BorderColor; + const imgUrl = this.boardService.getImgUrl(element); + const vignette: Vignette = { + Label: prononcedText, + ImagePath: imgUrl, + Color: color, + BorderColor: borderColor, + }; + let otherFormsDisplayed = false; + element.InteractionsList.forEach((inter) => { + if (inter.ID === interaction) { + inter.ActionList.forEach((action) => { + if (action.ID === 'pronomChangeInfo') { + this.changePronomInfo(element.ElementFormsList[0]); + } else if (action.ID === 'display') { + this.historicService.push(vignette); + } else if (action.ID === 'say') { + this.historicService.say('' + prononcedText); + } else if (action.ID === 'otherforms' && element.ElementFormsList.length > 1) { + otherFormsDisplayed = true; + this.boardService.activatedElement = this.boardService + .getNormalTempList() + .indexOf(element); + this.boardService.activatedElementTempList(); + this.pressedElement = null; + } else if (action.ID === 'backFromVariant' && !otherFormsDisplayed) { + this.boardService.activatedElement = -1; + } else if (action.ID === 'back') { + this.boardService.backToPreviousFolder(); + } else if (action.ID === 'backHome') { + this.boardService.backHome(); + } else if (action.ID === 'sound'){ + console.log('erreur'); + } else if (action.ID === 'video'){ + } + }); + } + }); } else if ((element.Type as FolderGoTo).GoTo !== undefined) { let pathTab = this.boardService.currentPath.split('.'); if (pathTab.length >= 2) { diff --git a/src/app/services/board.service.ts b/src/app/services/board.service.ts index f868a44a7..4ab30baf6 100644 --- a/src/app/services/board.service.ts +++ b/src/app/services/board.service.ts @@ -307,6 +307,22 @@ export class BoardService { } } + /*get sanitized image URL of an element*/ + getAudioUrl(element: GridElement) { + if (this.board.AudioList != null) { + console.log(this.board.AudioList); + console.log(element.ElementFormsList[0].AudioID); + const path = this.board.AudioList.find(x => x.ID === element.ElementFormsList[0].AudioID); + if (path !== null && path !== undefined) { + return path.Path ; + } else { + return ''; + } + } else { + return ''; + } + } + /*get normal image URL of an element (with no sanitizing)*/ getSimpleImgUrl(element: GridElement) { if (this.board.ImageList != null) { @@ -444,7 +460,8 @@ export class BoardService { VoiceText: eltform.VoiceText, LexicInfos: eltform.LexicInfos, ImageID: '' + eltform.ImageID, - AudioID: '' + eltform.AudioID + AudioID: '' + eltform.AudioID, + VideoID: '' + eltform.VideoID, }], compElt.InteractionsList.slice() ); @@ -466,7 +483,8 @@ export class BoardService { VoiceText: 'back', LexicInfos: [], ImageID: '#back', - AudioID: '' + AudioID: '', + VideoID: '', }]; diff --git a/src/app/services/functions.service.ts b/src/app/services/functions.service.ts index 22eb00cd6..d9140be47 100644 --- a/src/app/services/functions.service.ts +++ b/src/app/services/functions.service.ts @@ -39,7 +39,8 @@ export class FunctionsService { 'otherforms', 'back', 'backHome', - 'sound' + 'sound', + 'video' ) } diff --git a/src/app/services/proloquoParser.ts b/src/app/services/proloquoParser.ts index 4933c4a56..66096d967 100644 --- a/src/app/services/proloquoParser.ts +++ b/src/app/services/proloquoParser.ts @@ -239,7 +239,8 @@ export class ProloquoParser { VoiceText: word.mot, LexicInfos: [{ default: true }], ImageID: word.wordID, - AudioID: '' + AudioID: '', + videoID: '' } ], interList @@ -281,6 +282,7 @@ export class ProloquoParser { ElementList: tempElement, ImageList: [], AudioList: [], + VideoList: [], PageList: tempPage }; } diff --git a/src/app/services/speakForYourselfParser.ts b/src/app/services/speakForYourselfParser.ts index 1ee9806a2..8690014cc 100644 --- a/src/app/services/speakForYourselfParser.ts +++ b/src/app/services/speakForYourselfParser.ts @@ -30,7 +30,7 @@ export class SpeakForYourselfParser { } createGrid() { - const grille: Grid = new Grid('speak4yourself', 'Grid', 12, 12, [], [], [], []); + const grille: Grid = new Grid('speak4yourself', 'Grid', 12, 12, [], [], [], [], []); this.speak4Yourself.forEach(element => { if (element.page === 'HOME') { @@ -74,7 +74,8 @@ export class SpeakForYourselfParser { VoiceText: element.mot, LexicInfos: [{ default: true }], ImageID: '', - AudioID: '' + AudioID: '', + videoID: '' }], [{ ID: 'click', diff --git a/src/app/types.ts b/src/app/types.ts index 30a51401b..1c6c1f85e 100644 --- a/src/app/types.ts +++ b/src/app/types.ts @@ -23,13 +23,14 @@ export class Grid { ElementList: GridElement[]; ImageList: Image[]; AudioList: Audio[]; + VideoList: Video[]; PageList: Page[]; BackgroundColor: string; - constructor(gridId, gridType, gridCol, gridRow, elemList, imageList, pageList,AudioList) { + constructor(gridId, gridType, gridCol, gridRow, elemList, imageList, pageList,AudioList,videoList) { this.ID = gridId; this.Type = gridType; this.NumberOfCols = Number(gridCol); @@ -37,6 +38,7 @@ export class Grid { this.ElementList = elemList; this.ImageList = imageList; this.AudioList = AudioList; + this.VideoList = videoList; this.PageList = pageList; } @@ -153,6 +155,12 @@ export class Audio { Path: string; } +export class Video { + ID: string; + OriginalName: string; + Path: string; +} + export class Interaction { ID: string; // 'click' | 'longPress' | 'doubleClick'; ActionList: Action[]; @@ -175,6 +183,7 @@ export class ElementForm { LexicInfos: any[]; ImageID: string; AudioID: string; + VideoID: string; } export class Page { diff --git a/src/assets/defaultsave.json b/src/assets/defaultsave.json index 56cdfc784..62070eb26 100644 --- a/src/assets/defaultsave.json +++ b/src/assets/defaultsave.json @@ -802,6 +802,20 @@ "Path": "assets/libs/mulberry-symbols/EN-symbols/grandmother.svg" } ], + "AudioList": [ + { + "ID": "vide", + "OriginalName": "vide", + "Path": "vide" + } + ], + "VideoList": [ + { + "ID": "vide", + "OriginalName": "vide", + "Path": "vide" + } +], "PageList": [ { "ID": "#HOME", diff --git a/src/assets/multilinguism.json b/src/assets/multilinguism.json index 45058eb0f..9ac826a43 100644 --- a/src/assets/multilinguism.json +++ b/src/assets/multilinguism.json @@ -379,6 +379,8 @@ { "id" : "focusSelection", "FR": "Sélection par fixation", "EN": "Selection by focus"}, { "id" : "WordNameFile", "FR": "ClavierAugCom", "EN": "GridFileAugcom"}, { "id" : "WordTitle", "FR": "Clavier Augcom", "EN": "AugCom main grid"}, - { "id" : "WordFolder", "FR": "Sous Dossier", "EN": "Folder"} + { "id" : "WordFolder", "FR": "Sous Dossier", "EN": "Folder"}, + { "id" : "sound", "FR": "Faire jouer un son", "EN": "Play a sound"}, + { "id" : "video", "FR": "Faire jouer une vidéo", "EN": "Play a video"} ] } From 28a61b9df20706a2eec7387eeb2380ed3968c1ba Mon Sep 17 00:00:00 2001 From: eliaspue Date: Thu, 27 Jun 2024 17:02:30 +0200 Subject: [PATCH 3/7] Adding video button w/o final interaction --- .../components/edition/edition.component.ts | 8 ++---- .../generator-grid.component.ts | 2 +- src/app/components/import/import.component.ts | 2 +- .../components/spb2aug/spb2aug.component.ts | 4 +-- src/app/services/board.service.ts | 27 +++++++++++++++++++ src/app/services/proloquoParser.ts | 2 +- src/app/services/speakForYourselfParser.ts | 2 +- 7 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/app/components/edition/edition.component.ts b/src/app/components/edition/edition.component.ts index 29b2ea4c2..2c7d39ba8 100644 --- a/src/app/components/edition/edition.component.ts +++ b/src/app/components/edition/edition.component.ts @@ -90,7 +90,7 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { * Resets all the informations of the edition panel to their initial value */ clear() { - this.editionService.imageTextField = ""; + this.editionService.imageTextField = ''; this.editionService.borderCheck = false; this.editionService.insideCheck = false; this.editionService.name = ''; @@ -116,15 +116,11 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { * Saves the modified or new element, updates the indexedDB database with it and closes the edition panel */ async save() { - console.log("1"); if (this.editionService.name !== '') { - console.log("2"); if (this.editionService.newPage === '') { - console.log("3"); this.editionService.newPage = this.editionService.name; } if (this.editionService.add) { - console.log("4"); this.createNewButton(); } else if (this.editionService.selectedElements.length === 1) { this.modifyButton(); @@ -429,7 +425,7 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { if (elementToModif.Type === 'sound') { const videoToModif = this.boardService.board.VideoList.find(x => x.ID === elementToModif.ElementFormsList[0].AudioID); if (videoToModif != null) { - this.editionService.videoURL = audioToModif.Path; + this.editionService.videoURL = videoToModif.Path; } else { this.editionService.videoURL = ''; } diff --git a/src/app/components/generator-grid/generator-grid.component.ts b/src/app/components/generator-grid/generator-grid.component.ts index b6cdac79b..7a010a408 100644 --- a/src/app/components/generator-grid/generator-grid.component.ts +++ b/src/app/components/generator-grid/generator-grid.component.ts @@ -241,7 +241,7 @@ export class GeneratorGridComponent implements OnInit { LexicInfos: [{default: true}], ImageID: tempId, AudioID: tempId, - VideoID: tempid + VideoID: tempId } ); diff --git a/src/app/components/import/import.component.ts b/src/app/components/import/import.component.ts index 818f152d5..1664db72c 100644 --- a/src/app/components/import/import.component.ts +++ b/src/app/components/import/import.component.ts @@ -213,7 +213,7 @@ export class ImportComponent implements OnInit { LexicInfos: [{ default: true }], ImageID: theID, AudioID: '', - videoID: '' + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }] }]) ); diff --git a/src/app/components/spb2aug/spb2aug.component.ts b/src/app/components/spb2aug/spb2aug.component.ts index bb213ee67..a99480457 100644 --- a/src/app/components/spb2aug/spb2aug.component.ts +++ b/src/app/components/spb2aug/spb2aug.component.ts @@ -179,7 +179,7 @@ export class Spb2augComponent implements OnInit { LexicInfos: [{ default: true }], ImageID: (label) !== null ? label : message, AudioID: '', - videoID: '' + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) const pageUniqueIdFromButtonFolder = buttonsFolder.getAsObject().PageUniqueId; @@ -205,7 +205,7 @@ export class Spb2augComponent implements OnInit { LexicInfos: [{ default: true }], ImageID: (label) !== null ? label : message, AudioID: '', - videoID: '' + VideoID: '' } ], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }, { ID: 'say', Options: [] }] }]) const pageUniqueIdFromButtonFolder = buttonsFolder.getAsObject().PageUniqueId; diff --git a/src/app/services/board.service.ts b/src/app/services/board.service.ts index 4ab30baf6..e9c859722 100644 --- a/src/app/services/board.service.ts +++ b/src/app/services/board.service.ts @@ -229,6 +229,7 @@ export class BoardService { executer() { const imageTemp = []; const audioTemp = []; + const videoTemp = []; // TODO // this.board.ElementList = this.board.ElementList.filter(x => { @@ -252,12 +253,21 @@ export class BoardService { }); this.board.ElementList.forEach((elt) => { + const resvid = this.board.VideoList.find( + (video) => video.ID === elt.ElementFormsList[0].VideoID + ); + if (resvid !== null && resvid !== undefined) { + videoTemp.push(resvid); + } + + const resaud = this.board.AudioList.find( (audio) => audio.ID === elt.ElementFormsList[0].AudioID ); if (resaud !== null && resaud !== undefined) { audioTemp.push(resaud); } + const res = this.board.ImageList.find( (img) => img.ID === elt.ElementFormsList[0].ImageID ); @@ -323,6 +333,23 @@ export class BoardService { } } + /*get sanitized image URL of an element*/ + getVideoUrl(element: GridElement) { + if (this.board.VideoList != null) { + console.log(this.board.VideoList); + console.log(element.ElementFormsList[0].VideoID); + const path = this.board.VideoList.find(x => x.ID === element.ElementFormsList[0].VideoID); + if (path !== null && path !== undefined) { + return path.Path ; + } else { + return ''; + } + } else { + return ''; + } + } + + /*get normal image URL of an element (with no sanitizing)*/ getSimpleImgUrl(element: GridElement) { if (this.board.ImageList != null) { diff --git a/src/app/services/proloquoParser.ts b/src/app/services/proloquoParser.ts index 66096d967..61c5ba129 100644 --- a/src/app/services/proloquoParser.ts +++ b/src/app/services/proloquoParser.ts @@ -240,7 +240,7 @@ export class ProloquoParser { LexicInfos: [{ default: true }], ImageID: word.wordID, AudioID: '', - videoID: '' + VideoID: '' } ], interList diff --git a/src/app/services/speakForYourselfParser.ts b/src/app/services/speakForYourselfParser.ts index 8690014cc..b2115f751 100644 --- a/src/app/services/speakForYourselfParser.ts +++ b/src/app/services/speakForYourselfParser.ts @@ -75,7 +75,7 @@ export class SpeakForYourselfParser { LexicInfos: [{ default: true }], ImageID: '', AudioID: '', - videoID: '' + VideoID: '' }], [{ ID: 'click', From 511f28c7866d71d272319d37e54fd1e3e287b847 Mon Sep 17 00:00:00 2001 From: eliaspue Date: Thu, 27 Jun 2024 17:03:26 +0200 Subject: [PATCH 4/7] MinorFix --- src/app/components/edition/edition.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/edition/edition.component.ts b/src/app/components/edition/edition.component.ts index 2c7d39ba8..8ab36ceaf 100644 --- a/src/app/components/edition/edition.component.ts +++ b/src/app/components/edition/edition.component.ts @@ -172,7 +172,7 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { LexicInfos: [{default: true}], ImageID: elt.ElementFormsList[0].ImageID, AudioID: elt.ElementFormsList[0].AudioID, - videoID: elt.ElementFormsList[0].VideoID + VideoID: elt.ElementFormsList[0].VideoID } ); } From 072316df8d9cc44f65552918400d1c8a56c93ac9 Mon Sep 17 00:00:00 2001 From: eliaspue Date: Fri, 28 Jun 2024 12:59:00 +0200 Subject: [PATCH 5/7] Adding video button --- .../components/edition/edition.component.ts | 26 +-- src/app/components/event/event.component.html | 1 + src/app/components/event/event.component.ts | 3 +- src/app/components/tile/tile.component.css | 35 ++++ src/app/components/tile/tile.component.html | 9 + src/app/components/tile/tile.component.ts | 159 ++++++++++-------- 6 files changed, 147 insertions(+), 86 deletions(-) diff --git a/src/app/components/edition/edition.component.ts b/src/app/components/edition/edition.component.ts index 8ab36ceaf..1c3d761c4 100644 --- a/src/app/components/edition/edition.component.ts +++ b/src/app/components/edition/edition.component.ts @@ -13,8 +13,8 @@ import {HttpClient} from '@angular/common/http'; import {MultilinguismService} from '../../services/multilinguism.service'; import {FunctionsService} from '../../services/functions.service'; import {GridElementService} from '../../services/grid-element.service'; -import {LayoutService} from "../../services/layout.service"; -import {ConfigurationService} from "../../services/configuration.service"; +import {LayoutService} from '../../services/layout.service'; +import {ConfigurationService} from '../../services/configuration.service'; import {ComponentCanDeactivate} from 'src/app/services/pending-changes-guard.service'; import {Observable} from 'rxjs'; @@ -262,7 +262,10 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { img => img.ID !== this.editionService.getDefaultForm(element.ElementFormsList).ImageID); this.boardService.board.AudioList = this.boardService.board.AudioList.filter( - img => img.ID !== this.editionService.getDefaultForm(element.ElementFormsList).AudioID); + aud => aud.ID !== this.editionService.getDefaultForm(element.ElementFormsList).AudioID); + + this.boardService.board.VideoList = this.boardService.board.VideoList.filter( + vid => vid.ID !== this.editionService.getDefaultForm(element.ElementFormsList).VideoID); this.boardService.board.ImageList.push({ ID: this.editionService.getDefaultForm(element.ElementFormsList).ImageID, @@ -423,11 +426,11 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { // Mise à jour de l'URL de l'audio if (elementToModif.Type === 'sound') { - const videoToModif = this.boardService.board.VideoList.find(x => x.ID === elementToModif.ElementFormsList[0].AudioID); - if (videoToModif != null) { - this.editionService.videoURL = videoToModif.Path; + const audioToModif = this.boardService.board.AudioList.find(x => x.ID === elementToModif.ElementFormsList[0].AudioID); + if (audioToModif != null) { + this.editionService.audioURL = audioToModif.Path; } else { - this.editionService.videoURL = ''; + this.editionService.audioURL = ''; } } else { this.editionService.videoURL = ''; @@ -435,11 +438,11 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { // Mise à jour de l'URL de la video if (elementToModif.Type === 'video') { - const audioToModif = this.boardService.board.VideoList.find(x => x.ID === elementToModif.ElementFormsList[0].AudioID); - if (audioToModif != null) { - this.editionService.audioURL = audioToModif.Path; + const videoToModif = this.boardService.board.VideoList.find(x => x.ID === elementToModif.ElementFormsList[0].VideoID); + if (videoToModif != null) { + this.editionService.videoURL = videoToModif.Path; } else { - this.editionService.audioURL = ''; + this.editionService.videoURL = ''; } } else { this.editionService.audioURL = ''; @@ -491,6 +494,7 @@ export class EditionComponent implements OnInit, ComponentCanDeactivate { && this.initialEditionState.curentBorderColor == this.editionService.curentBorderColor && this.initialEditionState.imageURL == this.editionService.imageURL && this.initialEditionState.audioURL == this.editionService.audioURL + && this.initialEditionState.videoURL == this.editionService.videoURL && this.initialEditionState.variantList == this.editionService.variantList && this.initialdbnaryState.wordList == this.dbnaryService.wordList && this.initialdbnaryState.typeList == this.dbnaryService.typeList); diff --git a/src/app/components/event/event.component.html b/src/app/components/event/event.component.html index 3b87df27e..59da005e3 100644 --- a/src/app/components/event/event.component.html +++ b/src/app/components/event/event.component.html @@ -52,6 +52,7 @@ class="input" type="file"> diff --git a/src/app/components/event/event.component.ts b/src/app/components/event/event.component.ts index 0f8319791..fe4397b21 100644 --- a/src/app/components/event/event.component.ts +++ b/src/app/components/event/event.component.ts @@ -163,12 +163,11 @@ export class EventComponent implements OnInit, OnDestroy { } const reader = new FileReader(); - // Lecture du fichier audio en tant que Data URL + // Lecture du fichier video en tant que Data URL reader.readAsDataURL(file[0]); reader.onload = () => { this.editionService.videoURL = reader.result; - }; // Gestion des erreurs de lecture diff --git a/src/app/components/tile/tile.component.css b/src/app/components/tile/tile.component.css index 0629fd3fe..6ec424420 100644 --- a/src/app/components/tile/tile.component.css +++ b/src/app/components/tile/tile.component.css @@ -1,3 +1,38 @@ +.video-popup { + display: flex; + justify-content: center; + align-items: center; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.7); + z-index: 1000; +} + +.video-popup-content { + background-color: #fff; + padding: 20px; + border-radius: 5px; + max-width: 80%; + max-height: 80%; +} + +.close { + position: absolute; + top: 10px; + right: 20px; + font-size: 50px; + font-weight: bold; + cursor: pointer; +} + +video { + width: 100%; + height: auto; +} + .elementContainer { min-height: 1cm; min-width: 1cm; diff --git a/src/app/components/tile/tile.component.html b/src/app/components/tile/tile.component.html index 796df91e3..28bef3977 100644 --- a/src/app/components/tile/tile.component.html +++ b/src/app/components/tile/tile.component.html @@ -34,6 +34,15 @@ {{this.boardService.getLabel(element)}} +
+
+ × + +
+
+ diff --git a/src/app/components/tile/tile.component.ts b/src/app/components/tile/tile.component.ts index c66849c1c..d8676e089 100644 --- a/src/app/components/tile/tile.component.ts +++ b/src/app/components/tile/tile.component.ts @@ -1,4 +1,4 @@ -import {Component, Input, OnDestroy, OnInit,} from '@angular/core'; +import {Component, Input, OnDestroy, OnInit, ViewChild, ElementRef} from '@angular/core'; import {HistoricService} from '../../services/historic.service'; import {EditionService} from '../../services/edition.service'; import {BoardService} from '../../services/board.service'; @@ -26,6 +26,11 @@ export class TileComponent implements OnInit, OnDestroy { dwellTimer; dblClickTimer; + //for videos buttons + @ViewChild('videoPlayer') videoPlayer: ElementRef | undefined; + videoURL = ''; + show = false; + /** * element currently pressed */ @@ -242,22 +247,18 @@ export class TileComponent implements OnInit, OnDestroy { this.boardService.backToPreviousFolder(); } else if (action.ID === 'backHome') { this.boardService.backHome(); - } else if (action.ID ==='sound'){ + } else if (action.ID === 'sound') { const AudioURL = this.boardService.getAudioUrl(element); - console.log(element); if (AudioURL) { - console.log(AudioURL); // Création d'un nouvel élément audioAudioURL const audio = new Audio(AudioURL); // Lecture de l'audio audio.play().then(() => { - console.log('Audio is playing'); }).catch(error => { console.error('Error playing audio:', error); }); } else { - console.log(this.editionService); console.error('No audio URL found in editionService'); } } @@ -265,47 +266,51 @@ export class TileComponent implements OnInit, OnDestroy { } }); } else if (element.Type === 'video') { - const prononcedText = this.boardService.getLabel(element); - const color = this.gridElementService.getStyle(element).BackgroundColor; - const borderColor = this.gridElementService.getStyle(element).BorderColor; - const imgUrl = this.boardService.getImgUrl(element); - const vignette: Vignette = { - Label: prononcedText, - ImagePath: imgUrl, - Color: color, - BorderColor: borderColor, - }; - let otherFormsDisplayed = false; - element.InteractionsList.forEach((inter) => { - if (inter.ID === interaction) { - inter.ActionList.forEach((action) => { - if (action.ID === 'pronomChangeInfo') { - this.changePronomInfo(element.ElementFormsList[0]); - } else if (action.ID === 'display') { - this.historicService.push(vignette); - } else if (action.ID === 'say') { - this.historicService.say('' + prononcedText); - } else if (action.ID === 'otherforms' && element.ElementFormsList.length > 1) { - otherFormsDisplayed = true; - this.boardService.activatedElement = this.boardService - .getNormalTempList() - .indexOf(element); - this.boardService.activatedElementTempList(); - this.pressedElement = null; - } else if (action.ID === 'backFromVariant' && !otherFormsDisplayed) { - this.boardService.activatedElement = -1; - } else if (action.ID === 'back') { - this.boardService.backToPreviousFolder(); - } else if (action.ID === 'backHome') { - this.boardService.backHome(); - } else if (action.ID === 'sound'){ - console.log('erreur'); - } else if (action.ID === 'video'){ - - } - }); - } - }); + const prononcedText = this.boardService.getLabel(element); + const color = this.gridElementService.getStyle(element).BackgroundColor; + const borderColor = this.gridElementService.getStyle(element).BorderColor; + const imgUrl = this.boardService.getImgUrl(element); + const vignette: Vignette = { + Label: prononcedText, + ImagePath: imgUrl, + Color: color, + BorderColor: borderColor, + }; + let otherFormsDisplayed = false; + element.InteractionsList.forEach((inter) => { + if (inter.ID === interaction) { + inter.ActionList.forEach((action) => { + if (action.ID === 'pronomChangeInfo') { + this.changePronomInfo(element.ElementFormsList[0]); + } else if (action.ID === 'display') { + this.historicService.push(vignette); + } else if (action.ID === 'say') { + this.historicService.say('' + prononcedText); + } else if (action.ID === 'otherforms' && element.ElementFormsList.length > 1) { + otherFormsDisplayed = true; + this.boardService.activatedElement = this.boardService + .getNormalTempList() + .indexOf(element); + this.boardService.activatedElementTempList(); + this.pressedElement = null; + } else if (action.ID === 'backFromVariant' && !otherFormsDisplayed) { + this.boardService.activatedElement = -1; + } else if (action.ID === 'back') { + this.boardService.backToPreviousFolder(); + } else if (action.ID === 'backHome') { + this.boardService.backHome(); + } else if (action.ID === 'sound') { + } else if (action.ID === 'video') { + this.videoURL = this.boardService.getVideoUrl(element); + if (this.videoURL !== '') { + this.show = true; + } else { + console.error('No video was found for this button'); + } + } + }); + } + }); } else if ((element.Type as FolderGoTo).GoTo !== undefined) { let pathTab = this.boardService.currentPath.split('.'); if (pathTab.length >= 2) { @@ -340,6 +345,12 @@ export class TileComponent implements OnInit, OnDestroy { this.boardService.updateElementList(); } + // To allow the pop up of the video to be closed + closePopup(): void { + this.show = false; + this.videoURL = ''; + } + /** * Return true if the element is part of the search result * @@ -390,32 +401,34 @@ export class TileComponent implements OnInit, OnDestroy { * @param num, number of the event triggering the action */ pointerUp(element: GridElement, num) { - this.release[num] = false; - this.release[(num + 1) % 2] = false; - this.press[num] = true; - if ( - !this.userToolBarService.edit && - this.press[num] && - !this.press[(num + 1) % 2] - ) { - window.clearTimeout(this.pressTimer); - window.clearTimeout(this.dblClickTimer); - if (this.down === 1) { - if (this.pressedElement === element) { - this.setClickTimer(element); - } else { - this.down = 0; - this.pressedElement = null; - } - } else if (this.down > 1) { - if (this.pressedElement === element) { - this.action(element, 'doubleClick'); - this.pressedElement = null; - this.down = 0; - } else if (this.pressedElement != null) { - this.down = 1; - this.pressedElement = element; - this.setClickTimer(element); + if(!this.show){ + this.release[num] = false; + this.release[(num + 1) % 2] = false; + this.press[num] = true; + if ( + !this.userToolBarService.edit && + this.press[num] && + !this.press[(num + 1) % 2] + ) { + window.clearTimeout(this.pressTimer); + window.clearTimeout(this.dblClickTimer); + if (this.down === 1) { + if (this.pressedElement === element) { + this.setClickTimer(element); + } else { + this.down = 0; + this.pressedElement = null; + } + } else if (this.down > 1) { + if (this.pressedElement === element) { + this.action(element, 'doubleClick'); + this.pressedElement = null; + this.down = 0; + } else if (this.pressedElement != null) { + this.down = 1; + this.pressedElement = element; + this.setClickTimer(element); + } } } } From 0b42e1e2781a8684508942cfc36408b64791a623 Mon Sep 17 00:00:00 2001 From: eliaspue Date: Fri, 28 Jun 2024 14:05:21 +0200 Subject: [PATCH 6/7] Fix spec.ts --- .../alternative-forms.component.spec.ts | 4 +- .../edition/edition.component.spec.ts | 48 +++++++++++-------- .../components/tile/tile.component.spec.ts | 4 +- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/app/components/alternative-forms/alternative-forms.component.spec.ts b/src/app/components/alternative-forms/alternative-forms.component.spec.ts index d0dbcd7ee..cf4263fc1 100644 --- a/src/app/components/alternative-forms/alternative-forms.component.spec.ts +++ b/src/app/components/alternative-forms/alternative-forms.component.spec.ts @@ -27,7 +27,9 @@ function createElement(component: any, id: any, numberOfElementForms: number) { DisplayedText: id + i, VoiceText: id + i, LexicInfos: [], - ImageID: id + i + ImageID: id + i, + AudioID: id + i, + VideoID: id + i }); } component.editionService.selectedElements.push( diff --git a/src/app/components/edition/edition.component.spec.ts b/src/app/components/edition/edition.component.spec.ts index 972a774cf..9798b5af4 100644 --- a/src/app/components/edition/edition.component.spec.ts +++ b/src/app/components/edition/edition.component.spec.ts @@ -1,12 +1,12 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import {async, ComponentFixture, TestBed} from '@angular/core/testing'; -import { EditionComponent } from './edition.component'; -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { Ng2ImgMaxModule } from 'ng2-img-max'; -import { HttpClientModule } from '@angular/common/http'; -import { Router } from '@angular/router'; -import { Grid, GridElement } from '../../types'; +import {EditionComponent} from './edition.component'; +import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core'; +import {FormsModule} from '@angular/forms'; +import {Ng2ImgMaxModule} from 'ng2-img-max'; +import {HttpClientModule} from '@angular/common/http'; +import {Router} from '@angular/router'; +import {Grid, GridElement} from '../../types'; function newBoard(component: any) { component.boardService.board = new Grid( @@ -24,11 +24,15 @@ function newBoard(component: any) { [{ DisplayedText: 'testBeforeModif', VoiceText: 'testBeforeModif', - LexicInfos: [{ default: true }], - ImageID: '' + LexicInfos: [{default: true}], + ImageID: '', + AudioID: '', + VideoID: '' }], [])], [], + [], + [], [] ); } @@ -45,8 +49,10 @@ function addElementToBoard(component: any) { [{ DisplayedText: 'test2BeforeModif', VoiceText: 'test2BeforeModif', - LexicInfos: [{ default: true }], - ImageID: '' + LexicInfos: [{default: true}], + ImageID: '', + AudioID: '', + VideoID: '' }], [])); } @@ -95,7 +101,7 @@ describe('EditionComponent', () => { fixture = TestBed.createComponent(EditionComponent); component = fixture.componentInstance; fixture.detectChanges(); - component.boardService.board = new Grid('gridId', 'grid', 2, 2, [], [], []); + component.boardService.board = new Grid('gridId', 'grid', 2, 2, [], [], [],[],[]); component.indexedDBacess.loadUsersList(); }); @@ -269,30 +275,30 @@ describe('EditionComponent', () => { component.editionService.colorPicked = 'inside'; component.editionService.selectedPalette = '22 magic colors'; fixture.detectChanges(); - + compiled.querySelector('.color').click(); fixture.detectChanges(); - + compiled.querySelector('.close').click(); fixture.detectChanges(); - + expect(component.editionService.curentColor).toEqual('#800000') }); - - + + it('should change the bordercolor value when a bordercolor is selected', () => { const compiled = fixture.debugElement.nativeElement; clickElementOf(compiled, fixture, '.menu-item-title-container', 'Apparence'); component.editionService.colorPicked = 'border'; component.editionService.selectedPalette = '22 magic colors'; fixture.detectChanges(); - + compiled.querySelector('.color').click(); fixture.detectChanges(); - + compiled.querySelector('.close').click(); fixture.detectChanges(); - + expect(component.editionService.curentBorderColor).toEqual('#800000') }); */ diff --git a/src/app/components/tile/tile.component.spec.ts b/src/app/components/tile/tile.component.spec.ts index 9e0c05d13..5d881e549 100644 --- a/src/app/components/tile/tile.component.spec.ts +++ b/src/app/components/tile/tile.component.spec.ts @@ -41,7 +41,9 @@ describe('TileComponent', () => { DisplayedText: 'testBeforeModif', VoiceText: 'testBeforeModif', LexicInfos: [{ default: true }], - ImageID: '' + ImageID: '', + AudioID: '', + VideoID: '' }], [{ ID: 'click', ActionList: [{ ID: 'display', Options: [] }] }]); fixture.detectChanges(); From afd8075017452dbf3fd40edd5fca864b33b27c13 Mon Sep 17 00:00:00 2001 From: eliaspue Date: Fri, 28 Jun 2024 16:47:19 +0200 Subject: [PATCH 7/7] Fix recursive function export word --- src/app/components/export/export.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/export/export.component.ts b/src/app/components/export/export.component.ts index bfb0db5d6..59e06285d 100644 --- a/src/app/components/export/export.component.ts +++ b/src/app/components/export/export.component.ts @@ -327,7 +327,7 @@ export class ExportComponent implements OnInit { if (this.checkIfIsFolder(elem)) { if (!this.listPageAlreadyVisited.includes(this.goToValue)) { this.listPageAlreadyVisited.push(this.goToValue); - await this.goInFolderExcell(this.goToValue, index + 1); // await the recursive call + await this.goInFolderWord(this.goToValue, index + 1); // await the recursive call } } }