Skip to content

Commit

Permalink
fix: #382
Browse files Browse the repository at this point in the history
  • Loading branch information
khansadaoudi committed Jul 23, 2024
1 parent 0be1e7e commit dcaae9a
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 24 deletions.
99 changes: 79 additions & 20 deletions src/components/project/UploadDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,66 @@
<q-input outlined v-model="sampleName" :label="$t('uploadSample.sampleName')" />
</q-tab-panel>
</q-tab-panels>
<div class="row q-px-md">
<q-input
class="col"
outlined
v-model="customUserId"
:label="$t('uploadSample.customUsername')"
:rules="[
(val) => reservedUserId !== val.toLowerCase() || `${val} ` + $t('uploadSample.reservedUsernameError'),
(val) => (val && val.length > 0) || $t('uploadSample.emptyUsernameError'),
]"
/>
<q-separator />
<div class="q-px-md">
<div class="text-h6">
{{ $t('uploadSample.userIdConfig') }}
</div>
<q-list>
<q-item>
<q-item-section avatar>
<q-radio v-model="userId" val="username" />
</q-item-section>
<q-item-section>
<q-item-label>
{{ $t('uploadSample.userIdOptions[0]') }}
</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section avatar>
<q-radio v-model="userId" val="validated" />
</q-item-section>
<q-item-section>
<q-item-label>
{{ $t('uploadSample.userIdOptions[1]') }}
</q-item-label>
</q-item-section>
</q-item>
<q-item v-if="blindAnnotationMode">
<q-item-section avatar>
<q-radio v-model="userId" val="base_tree" />
</q-item-section>
<q-item-section>
<q-item-label>
{{ $t('uploadSample.userIdOptions[2]') }}
</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section avatar>
<q-radio v-model="userId" class="row" val="other" />
</q-item-section>
<q-item-section>
<q-item-label>
{{ $t('uploadSample.userIdOptions[3]') }}
</q-item-label>
</q-item-section>
</q-item>
</q-list>
</div>
<q-input
v-if="userId === 'other'"
class="col"
outlined
v-model="customUserId"
:label="$t('uploadSample.customUsername')"
:rules="[
(val) => !reservedUserIds.includes(val.toLowerCase()) || `${val} ` + $t('uploadSample.reservedUsernameError'),
(val) => (val && val.length > 0) || $t('uploadSample.emptyUsernameError'),
]"
/>
<q-separator />
<q-item>
<q-item-section side top>
<q-checkbox v-model="rtl" />
Expand All @@ -82,7 +130,7 @@
icon="cloud_upload"
label="Upload sample"
:loading="uploadSample.submitting"
:disable="disableUploadBtn || customUserId === ''"
:disable="disableUploadBtn"
@click="uploadSamples()"
>
<q-tooltip v-if="uploadSample.attachment.file.length == 0" content-class="text-white bg-primary">
Expand Down Expand Up @@ -167,12 +215,12 @@ export default defineComponent({
generateNewSentIds: false,
samplesWithoutSentIds,
rtl: false,
userId: 'username',
};
},
computed: {
...mapState(useUserStore, { userid: 'id' }),
...mapState(useUserStore, ['username', 'reservedUserId']),
...mapState(useUserStore, ['username', 'reservedUserIds']),
...mapState(useProjectStore, ['blindAnnotationMode']),
disableTokenizeBtn() {
if (this.option.value == 'plainText') {
Expand All @@ -185,15 +233,15 @@ export default defineComponent({
let disable = true;
if (this.samplesWithoutSentIds.length > 0) {
disable = !this.generateNewSentIds;
} else if (this.uploadSample.attachment.file.length > 0) {
} else if (this.uploadSample.attachment.file.length > 0 && this.userId !== 'other') {
disable = false;
}
else if (this.uploadSample.attachment.file.length > 0 && this.userId === 'other' && this.customUserId !== '') {
disable = false;
}
return disable;
},
},
mounted() {
this.customUserId = this.username;
},
methods: {
async preprocess() {
this.warningMessage = '';
Expand Down Expand Up @@ -265,7 +313,7 @@ export default defineComponent({
for (const file of this.uploadSample.attachment.file) {
form.append('files', file);
}
form.append('userId', this.customUserId);
form.append('userId', this.selectedUserId());
form.append('rtl', JSON.stringify(this.rtl))
if (this.generateNewSentIds) {
form.append('samplesWithoutSentIds', JSON.stringify(this.samplesWithoutSentIds));
Expand All @@ -291,7 +339,7 @@ export default defineComponent({
},
tokenizeSample() {
const data = {
username: this.customUserId,
username: this.selectedUserId(),
text: this.text.normalize('NFC'),
option: this.option.value,
lang: this.lang.value,
Expand All @@ -309,6 +357,17 @@ export default defineComponent({
notifyError({ error: 'Invalid request' });
});
},
selectedUserId() {
if (this.userId === 'username') {
return this.username;
}
else if (this.userId === 'other') {
return this.customUserId;
}
else {
return this.userId;
}
},
closeDialog() {
this.uploadDialModel = false;
this.uploadSample.attachment.file = [];
Expand Down
9 changes: 8 additions & 1 deletion src/i18n/en-us/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,21 @@ export default {
sampleName: 'Sample Name',
horizontalHint: 'Each sentence on a separate line, the tokens are separated by spaces.',
verticalHint: 'Each token on a separate line, with an empty line indicating the end of sentence.',
customUsername: "Custom UserId By default it's your username",
customUsername: "Custom UserId",
text: 'text',
tokenizeBtn: 'Tokenize',
selectFiles: 'Select one or multiple conll files',
uploadFileLabel: 'Pick or drop files',
uploadFileTooltip: 'Select file to upload',
reservedUsernameError: 'is reserved username for ArboratorGrew',
emptyUsernameError: 'You can not upload file without userId please type something',
userIdConfig: 'User Id configuration',
userIdOptions: [
'Import your trees under your username',
'Import your trees as validated trees',
'Import your trees as base_tree',
'Import your trees using custom username'
],
},
advancedFilter: {
textFilter: 'Text filter',
Expand Down
9 changes: 8 additions & 1 deletion src/i18n/fr-fra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,21 @@ export default {
sampleName: "Le nom d'échantillon",
horizontalHint: 'Chaque phrase se trouve sur une ligne séparée, les tokens sont séparés par des espaces..',
verticalHint: 'Chaque token est écrit sur une ligne séparée, une ligne vide indiquant la fin de la phrase.',
customUsername: "UserId personnalisé par défaut il s'agit de votre username",
customUsername: "UserId personnalisé",
text: 'texte',
tokenizeBtn: 'Tokéniser',
selectFiles: 'Sélectionnez un ou plusieurs fichiers CONLL',
uploadFileLabel: 'Choisir ou déposer des fichiers',
uploadFileTooltip: 'sélectionnez un fichier',
reservedUsernameError: 'est un nom réservé pour ArboratorGrew',
emptyUsernameError: 'Vous ne pouvez pas télécharger de fichier sans userId, veuillez saisir quelque chose.',
userIdConfig: 'Configuration du UserId',
userIdOptions: [
"Importez vos arbres sous votre nom d'utilisateurs",
'Importez vos arbres comme des arbres validated',
'Importez vos arbres comme des arbres base_tree',
"Importez vos arbres en utilisant un nom d'utilisateur personalisé",
],
},
advancedFilter: {
textFilter: 'Filtre du texte',
Expand Down
4 changes: 2 additions & 2 deletions src/pinia/modules/user/defaultState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface UserStateInterface {
query_class: string | null;
super_admin: boolean;
username: string;
reservedUserId: string;
reservedUserIds: string[];
}

// default user state
Expand Down Expand Up @@ -55,6 +55,6 @@ export default function defaultState(): UserStateInterface {
query_class: null,
super_admin: false,
username: '',
reservedUserId: 'base_tree',
reservedUserIds: ['base_tree', 'validated'],
};
}

0 comments on commit dcaae9a

Please sign in to comment.