Skip to content

Conversation

mnocon
Copy link
Contributor

@mnocon mnocon commented Feb 19, 2025

Target: 4.6. master

@github-actions
Copy link

Preview of modified Markdown: no Markdown change to preview.

@mnocon mnocon changed the title Updated message when fixing CS Updated message when fixing CS & fixed JS formatting Feb 19, 2025
@github-actions
Copy link

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/ai_actions/assets/js/transcribe.audio.js

docs/ai_actions/extend_ai_actions.md@353:``` js
docs/ai_actions/extend_ai_actions.md@354:[[= include_file('code_samples/ai_actions/assets/js/transcribe.audio.js') =]]
docs/ai_actions/extend_ai_actions.md@355:```

001⫶import BaseAIComponent from '../../vendor/ibexa/connector-ai/src/bundle/Resources/public/js/core/base.ai.component';
002⫶
003⫶export default class TranscribeAudio extends BaseAIComponent {
004⫶ constructor(mainElement, config) {
005⫶ super(mainElement, config);
006⫶
007⫶ this.requestHeaders = {
008⫶ Accept: 'application/vnd.ibexa.api.ai.AudioText+json',
009⫶ 'Content-Type': 'application/vnd.ibexa.api.ai.TranscribeAudio+json',
010⫶ };
011⫶ }
012⫶
013⫶ getAudioInBase64() {
014⫶ const request = new XMLHttpRequest();
015⫶ request.open('GET', this.inputElement.href, false);
016⫶ request.overrideMimeType('text/plain; charset=x-user-defined');
017⫶ request.send();
018⫶
019⫶ if (request.status === 200) {
020⫶ return this.convertToBase64(request.responseText);

code_samples/ai_actions/assets/js/transcribe.audio.js

docs/ai_actions/extend_ai_actions.md@353:``` js
docs/ai_actions/extend_ai_actions.md@354:[[= include_file('code_samples/ai_actions/assets/js/transcribe.audio.js') =]]
docs/ai_actions/extend_ai_actions.md@355:```

001⫶import BaseAIComponent from '../../vendor/ibexa/connector-ai/src/bundle/Resources/public/js/core/base.ai.component';
002⫶
003⫶export default class TranscribeAudio extends BaseAIComponent {
004⫶ constructor(mainElement, config) {
005⫶ super(mainElement, config);
006⫶
007⫶ this.requestHeaders = {
008⫶ Accept: 'application/vnd.ibexa.api.ai.AudioText+json',
009⫶ 'Content-Type': 'application/vnd.ibexa.api.ai.TranscribeAudio+json',
010⫶ };
011⫶ }
012⫶
013⫶ getAudioInBase64() {
014⫶ const request = new XMLHttpRequest();
015⫶ request.open('GET', this.inputElement.href, false);
016⫶ request.overrideMimeType('text/plain; charset=x-user-defined');
017⫶ request.send();
018⫶
019⫶ if (request.status === 200) {
020⫶ return this.convertToBase64(request.responseText);
021⫶        }
022⫶ else {
023⫶ this.processError('Error occured when decoding the file.');
024⫶ }
025⫶ }
026⫶
027⫶ getRequestBody() {
028⫶ const body = {
029⫶ TranscribeAudio: {
030⫶ Audio: {
031⫶ base64: this.getAudioInBase64(),
032⫶ },
033⫶ RuntimeContext: {},
034⫶ },
035⫶ };
036⫶
037⫶ if (this.languageCode) {
038⫶ body.TranscribeAudio.RuntimeContext.languageCode = this.languageCode;
039⫶ }
040⫶
041⫶ return JSON.stringify(body);
042⫶ }
043⫶
044⫶ afterFetchData(response) {
045⫶ super.afterFetchData();
046⫶
047⫶ if (response) {
048⫶ this.outputElement.value = response.AudioText.Text.text[0];
049⫶ }
050⫶ }
051⫶
052⫶ toggle(forceEnabled) {
053⫶ super.toggle(forceEnabled);
054⫶
055⫶ this.outputElement.disabled = !forceEnabled || !this.outputElement.disabled;
056⫶ }
057⫶
058⫶ convertToBase64(data) {
059⫶ let binary = '';
060⫶
061⫶ for (let i = 0; i < data.length; i++) {
062⫶ binary += String.fromCharCode(data.charCodeAt(i) & 0xff);
063⫶ }
064⫶
065⫶ return btoa(binary);
066⫶ }
067⫶}
021⫶        } else {
022⫶ this.processError('Error occured when decoding the file.');
023⫶ }
024⫶ }
025⫶
026⫶ getRequestBody() {
027⫶ const body = {
028⫶ TranscribeAudio: {
029⫶ Audio: {
030⫶ base64: this.getAudioInBase64(),
031⫶ },
032⫶ RuntimeContext: {},
033⫶ },
034⫶ };
035⫶
036⫶ if (this.languageCode) {
037⫶ body.TranscribeAudio.RuntimeContext.languageCode = this.languageCode;
038⫶ }
039⫶
040⫶ return JSON.stringify(body);
041⫶ }
042⫶
043⫶ afterFetchData(response) {
044⫶ super.afterFetchData();
045⫶
046⫶ if (response) {
047⫶ this.outputElement.value = response.AudioText.Text.text[0];
048⫶ }
049⫶ }
050⫶
051⫶ toggle(forceEnabled) {
052⫶ super.toggle(forceEnabled);
053⫶
054⫶ this.outputElement.disabled = !forceEnabled || !this.outputElement.disabled;
055⫶ }
056⫶
057⫶ convertToBase64(data) {
058⫶ let binary = '';
059⫶
060⫶ for (let i = 0; i < data.length; i++) {
061⫶ binary += String.fromCharCode(data.charCodeAt(i) & 0xff);
062⫶ }
063⫶
064⫶ return btoa(binary);
065⫶ }
066⫶}


Download colorized diff

@mnocon mnocon marked this pull request as ready for review February 19, 2025 14:45
@mnocon mnocon requested a review from adriendupuis February 19, 2025 14:45
@mnocon mnocon merged commit a93ee18 into master Feb 19, 2025
4 of 7 checks passed
@mnocon mnocon deleted the test-prettier branch February 19, 2025 14:52
mnocon added a commit that referenced this pull request Feb 19, 2025
* Updated message when fixing CS

* PHP & JS CS Fixes

* Rebuild

* Fixed typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants