Skip to content

Commit

Permalink
Minor: Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Jan 10, 2025
1 parent ba7a75f commit af44d26
Show file tree
Hide file tree
Showing 239 changed files with 4,488 additions and 3,296 deletions.
2 changes: 1 addition & 1 deletion assets/vue/AppInstaller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<h1
v-else-if="'update' === installerData.installType"
v-t="{
path: 'Update from Chamilo ' + installerData.upgradeFromVersion.join(' | ')
path: 'Update from Chamilo ' + installerData.upgradeFromVersion.join(' | '),
}"
class="mb-4"
/>
Expand Down
70 changes: 35 additions & 35 deletions assets/vue/components/ActionCell.vue
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
<template>
<!-- auto-width-->
<q-td slot="body-cell-action" >
<!-- auto-width-->
<q-td slot="body-cell-action">
<div class="p-4 flex flex-row gap-1">
<q-btn
v-if="handleShow"
no-caps
dense
color="secondary"
@click="handleShow"
label="Show"
v-if="handleShow"
color="secondary"
dense
label="Show"
no-caps
@click="handleShow"
/>
<q-btn
v-if="handleEdit"
no-caps
dense
color="secondary"
@click="handleEdit"
label="Edit"
v-if="handleEdit"
color="secondary"
dense
label="Edit"
no-caps
@click="handleEdit"
/>
<q-btn
v-if="handleDelete"
no-caps
label="Delete"
dense
color="red"
@click="confirmDeleteClick = true"
v-if="handleDelete"
color="red"
dense
label="Delete"
no-caps
@click="confirmDeleteClick = true"
/>
<ConfirmDelete
v-if="handleDelete"
:show="confirmDeleteClick"
:handle-delete="handleDelete"
:handle-cancel="() => (confirmDeleteClick = false)"
v-if="handleDelete"
:handle-cancel="() => (confirmDeleteClick = false)"
:handle-delete="handleDelete"
:show="confirmDeleteClick"
/>
</div>
</q-td>
</template>

<script>
import ConfirmDelete from './ConfirmDelete.vue';
import ConfirmDelete from "./ConfirmDelete.vue"
export default {
name: 'ActionCell',
name: "ActionCell",
components: {
ConfirmDelete
ConfirmDelete,
},
data() {
return {
confirmDeleteClick: false
};
confirmDeleteClick: false,
}
},
props: {
handleShow: {
type: Function,
required: false
required: false,
},
handleEdit: {
type: Function,
required: false
required: false,
},
handleDelete: {
type: Function,
required: false
}
}
};
required: false,
},
},
}
</script>
137 changes: 78 additions & 59 deletions assets/vue/components/AudioRecorder.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<template>
<div v-if="!microphoneError">
<div class="flex flex-row">
<div v-if="recorderState.isRecording" class="flex rounded-md mr-2 mb-2 py-2 px-3 border border-error">
<BaseIcon class="self-center mr-2 text-error motion-safe:animate-pulse" icon="microphone"/>
<div
v-if="recorderState.isRecording"
class="flex rounded-md mr-2 mb-2 py-2 px-3 border border-error"
>
<BaseIcon
class="self-center mr-2 text-error motion-safe:animate-pulse"
icon="microphone"
/>
<p class="self-center font-semibold text-error">
{{ recordedTime }}
</p>
Expand All @@ -27,9 +33,16 @@
</div>

<div v-if="showRecordedAudios">
<div v-for="(audio, index) in recorderState.audioList" :key="index" class="py-2">
<audio class="max-w-full" controls>
<source :src="window.URL.createObjectURL(audio)"/>
<div
v-for="(audio, index) in recorderState.audioList"
:key="index"
class="py-2"
>
<audio
class="max-w-full"
controls
>
<source :src="window.URL.createObjectURL(audio)" />
</audio>

<BaseButton
Expand All @@ -44,20 +57,20 @@
</div>
</div>
<div v-else>
<p>
{{ microphoneError }}
</p>
<p>
{{ microphoneError }}
</p>
</div>
</template>

<script setup>
import BaseButton from "./basecomponents/BaseButton.vue";
import { computed, reactive, ref, onMounted } from "vue";
import { RecordRTCPromisesHandler, StereoAudioRecorder } from "recordrtc";
import { useI18n } from "vue-i18n";
import BaseIcon from "./basecomponents/BaseIcon.vue";
import BaseButton from "./basecomponents/BaseButton.vue"
import { computed, onMounted, reactive, ref } from "vue"
import { RecordRTCPromisesHandler, StereoAudioRecorder } from "recordrtc"
import { useI18n } from "vue-i18n"
import BaseIcon from "./basecomponents/BaseIcon.vue"
const { t } = useI18n();
const { t } = useI18n()
const props = defineProps({
multiple: {
Expand All @@ -72,25 +85,25 @@ const props = defineProps({
showRecordedAudios: {
type: Boolean,
default: true,
}
});
},
})
const emit = defineEmits(["attach-audio", "recorded-audio"]);
const emit = defineEmits(["attach-audio", "recorded-audio"])
defineExpose({
record,
stop,
});
})
const recorderState = reactive({
isRecording: false,
audioList: [],
seconds: 0,
minutes: 0,
hours: 0,
});
})
const microphoneError = ref('');
const microphoneError = ref("")
const recordedTime = computed(() => {
let hours = timeComponentToString(recorderState.hours)
Expand All @@ -100,81 +113,87 @@ const recordedTime = computed(() => {
})
onMounted(() => {
let isMediaDevicesSupported = navigator.mediaDevices
&& navigator.mediaDevices.getUserMedia
let isMediaDevicesSupported = navigator.mediaDevices && navigator.mediaDevices.getUserMedia
if (!isMediaDevicesSupported) {
console.warn('Either your browser does not support microphone or your are serving your site from not secure ' +
'context, check https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia for more information');
microphoneError.value = t('We\'re sorry, your browser does not support using a microphone');
console.warn(
"Either your browser does not support microphone or your are serving your site from not secure " +
"context, check https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia for more information",
)
microphoneError.value = t("We're sorry, your browser does not support using a microphone")
}
});
})
let recorder = null;
let recorder = null
async function record() {
if (microphoneError.value) {
return;
return
}
try {
let stream = await navigator.mediaDevices.getUserMedia({ video: false, audio: true });
let stream = await navigator.mediaDevices.getUserMedia({ video: false, audio: true })
recorder = new RecordRTCPromisesHandler(stream, {
recorderType: StereoAudioRecorder,
type: "audio",
mimeType: "audio/wav",
numberOfAudioChannels: 2,
});
recorder.startRecording();
})
recorder.startRecording()
startTimer()
recorderState.isRecording = true;
recorderState.isRecording = true
} catch (error) {
console.warn('Either the user denied permission or microphone is not available, ' +
'check https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia');
if (error.name === 'NotAllowedError') {
microphoneError.value = t('Permission to use the microphone is not enabled, please enable it in your browser to record audio');
console.warn(
"Either the user denied permission or microphone is not available, " +
"check https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia",
)
if (error.name === "NotAllowedError") {
microphoneError.value = t(
"Permission to use the microphone is not enabled, please enable it in your browser to record audio",
)
} else {
microphoneError.value = t('We\'re sorry, your browser does not support using a microphone');
microphoneError.value = t("We're sorry, your browser does not support using a microphone")
}
}
}
async function stop() {
if (!recorder) {
return;
return
}
if (false === props.multiple && recorderState.audioList.length > 0) {
recorderState.audioList.shift();
recorderState.audioList.shift()
}
await recorder.stopRecording();
await recorder.stopRecording()
const audioBlob = await recorder.getBlob();
const audioBlob = await recorder.getBlob()
recorderState.audioList.push(audioBlob);
emit('recorded-audio', audioBlob);
recorderState.audioList.push(audioBlob)
emit("recorded-audio", audioBlob)
recorderState.isRecording = false;
stopTimer();
recorderState.isRecording = false
stopTimer()
}
function attachAudio(audio) {
emit("attach-audio", audio);
emit("attach-audio", audio)
const index = recorderState.audioList.indexOf(audio);
const index = recorderState.audioList.indexOf(audio)
if (index >= 0) {
recorderState.audioList.splice(index, 1);
recorderState.audioList.splice(index, 1)
}
}
let timer = null;
let timer = null
function startTimer() {
recorderState.seconds = 0;
recorderState.minutes = 0;
recorderState.hours = 0;
recorderState.seconds = 0
recorderState.minutes = 0
recorderState.hours = 0
timer = setInterval(() => {
recorderState.seconds = recorderState.seconds + 1
Expand All @@ -186,19 +205,19 @@ function startTimer() {
recorderState.hours = recorderState.hours + 1
recorderState.minutes = 0
}
}, 1000);
}, 1000)
}
function stopTimer() {
recorderState.seconds = 0;
recorderState.minutes = 0;
recorderState.hours = 0;
recorderState.seconds = 0
recorderState.minutes = 0
recorderState.hours = 0
clearInterval(timer);
timer = null;
clearInterval(timer)
timer = null
}
function timeComponentToString(value) {
return value.toString().padStart(2, '0');
return value.toString().padStart(2, "0")
}
</script>
2 changes: 1 addition & 1 deletion assets/vue/components/Breadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ watchEffect(() => {
const parts = route.path.split("/").filter(Boolean)
parts.forEach((part, index) => {
const path = `/${parts.slice(0, index + 1).join("/")}`
const matchedRoute = router.getRoutes().find(r => r.path === path)
const matchedRoute = router.getRoutes().find((r) => r.path === path)
if (matchedRoute) {
const label = matchedRoute.meta?.breadcrumb || t(part.charAt(0).toUpperCase() + part.slice(1))
itemList.value.push({
Expand Down
Loading

0 comments on commit af44d26

Please sign in to comment.