Skip to content

Commit

Permalink
fix frontend linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
akash5100 committed Nov 1, 2023
1 parent 1988531 commit c9ccae9
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>

<div class="captions-tab-section">
<div class="title my-4 px-4" >
<div class="my-4 px-4 title">
<ContentNodeIcon
v-if="node && node.kind"
:kind="node.kind"
Expand All @@ -12,11 +12,11 @@
class="headline mx-2 notranslate"
data-test="title"
>
{{ $tr('header', { fileName: node.title}) }}
{{ $tr('header', { fileName: node.title }) }}
</h2>
</div>

<div v-if="!isGeneratingCaptions" class="mb-2 mt-2 px-4" >
<div v-if="!isGeneratingCaptions" class="mb-2 mt-2 px-4">
<p class="my-2">
{{ $tr('captionGenerationHelpText') }}
</p>
Expand All @@ -30,19 +30,19 @@
/>

<VBtn
v-if="selectedLanguage && !isGeneratingCaptions"
flat
color="primary"
class="font-weight-bold ml-0"
@click="addCaption"
>
{{ $tr('generateBtn') }}
v-if="selectedLanguage && !isGeneratingCaptions"
flat
color="primary"
class="font-weight-bold ml-0"
@click="addCaption"
>
{{ $tr('generateBtn') }}
</VBtn>
</div>
<!-- TODO -->
<!-- est. time, time elapsed can be good -->
<p v-if="isGeneratingCaptions">
{{ $tr('generating', { fileName: node.title}) }}
{{ $tr('generating', { fileName: node.title }) }}
<LoadingText />
<br>
</p>
Expand All @@ -53,12 +53,12 @@

<script>
import { mapState, mapActions, mapGetters } from 'vuex';
import { CaptionFile, uuid4 } from 'shared/data/resources';
import { notSupportedCaptionLanguages } from 'shared/leUtils/TranscriptionLanguages';
import ContentNodeIcon from 'shared/views/ContentNodeIcon';
import LoadingText from 'shared/views/LoadingText';
import LanguageDropdown from 'shared/views/LanguageDropdown';
import { mapActions, mapGetters } from 'vuex';
import { CaptionFile, uuid4 } from 'shared/data/resources';
import { notSupportedCaptionLanguages } from 'shared/leUtils/TranscriptionLanguages';
import ContentNodeIcon from 'shared/views/ContentNodeIcon';
import LoadingText from 'shared/views/LoadingText';
import LanguageDropdown from 'shared/views/LanguageDropdown';
export default {
name: 'CaptionsTab',
Expand All @@ -79,10 +79,10 @@ import LanguageDropdown from 'shared/views/LanguageDropdown';
};
},
computed: {
...mapState('caption', ['captionFilesMap', 'captionCuesMap']),
...mapGetters('contentNode', ['getContentNode']),
...mapGetters('caption', ['isGeneratingGetter']),
...mapGetters('file', ['getContentNodeFiles']),
// ...mapState('caption', ['captionFilesMap', 'captionCuesMap']),
node() {
return this.getContentNode(this.nodeId);
},
Expand All @@ -92,7 +92,7 @@ import LanguageDropdown from 'shared/views/LanguageDropdown';
},
isGeneratingCaptions() {
return this.isGeneratingGetter(this.nodeId);
}
},
},
methods: {
...mapActions('caption', ['addCaptionFile']),
Expand All @@ -114,10 +114,10 @@ import LanguageDropdown from 'shared/views/LanguageDropdown';
});
},
getLongestDurationFileId() {
let files = this.getContentNodeFiles(this.nodeId);
let { id } = files.reduce((max, file) => (
file.duration > max.duration ? file : max
), { duration: 0 });
const files = this.getContentNodeFiles(this.nodeId);
const { id } = files.reduce((max, file) => (file.duration > max.duration ? file : max), {
duration: 0,
});
return id;
},
},
Expand All @@ -133,14 +133,16 @@ import LanguageDropdown from 'shared/views/LanguageDropdown';
</script>

<style lang="less" scoped>
.captions-tab-section {
vertical-align: text-top;
height: 80vh;
vertical-align: text-top;
}
.title {
display: inline-flex;
align-items: center;
justify-content: flex-start;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function addCaptionFile({ state, commit }, { id, file_id, language,
file_id: file_id,
language: language,
};
// The file_id and language should be unique together in the vuex state.
// The file_id and language should be unique together in the vuex state.
// This check avoids duplicating existing caption data already loaded into vuex.
const alreadyExists = state.captionFilesMap[nodeId]
? Object.values(state.captionFilesMap[nodeId]).find(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { GENERATING } from 'shared/data/constants';

export function isGeneratingGetter(state) {
return (contentnode_id) => {
const captionFileIds = Object.keys(state.captionFilesMap[contentnode_id] || {});
let isAnyGenerating = false;
for (const id of captionFileIds) {
if (state.captionFilesMap[contentnode_id][id][GENERATING] === true) {
isAnyGenerating = true;
break; // Exit loop if a generating flag is found
}
}
return isAnyGenerating;
return contentnode_id => {
const captionFileIds = Object.keys(state.captionFilesMap[contentnode_id] || {});
let isAnyGenerating = false;
for (const id of captionFileIds) {
if (state.captionFilesMap[contentnode_id][id][GENERATING] === true) {
isAnyGenerating = true;
break; // Exit loop if a generating flag is found
}
}
return isAnyGenerating;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function ADD_CUE(state, { cue, nodeId }) {
}

export function ADD_CAPTIONCUES(state, { cues, nodeId }) {
if(Array.isArray(cues)) {
if (Array.isArray(cues)) {
cues.forEach(cue => {
ADD_CUE(state, { cue, nodeId });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,16 +1031,16 @@ export const CaptionFile = new Resource({
ContentNode.table
.where({ channel_id: id })
.and(node => node.has_children == true)
.modify({ changed: true })
.modify({ changed: true });
});
},

_add: Resource.prototype.add,
add(obj) {
return this._add(obj).then(id => {
return this._add(obj).then(() => { // id
const contentnodeId = this.getChannelId();
return this.updateContentNodeChanged(contentnodeId);
})
});
},

waitForCaptionCueGeneration(id) {
Expand Down Expand Up @@ -1082,7 +1082,7 @@ export const CaptionCues = new Resource({
.toArray();
},
collectionUrl(caption_file_id) {
return this.getUrlFunction('list')(caption_file_id)
return this.getUrlFunction('list')(caption_file_id);
},
fetchCollection({ caption_file_id }) {
const now = Date.now();
Expand Down Expand Up @@ -1120,7 +1120,7 @@ export const CaptionCues = new Resource({
promise,
};
return promise;
}
},
});

export const Channel = new Resource({
Expand Down
Loading

0 comments on commit c9ccae9

Please sign in to comment.