Skip to content

Commit

Permalink
Remove unused message param from spin(), fix #157
Browse files Browse the repository at this point in the history
  • Loading branch information
arildm committed Mar 25, 2024
1 parent a63754d commit 2ff7414
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 126 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ As this project is a user-facing application, the places in the semantic version
### Changed

- Group export files by folder [#95](https://github.com/spraakbanken/mink-frontend/issues/95)
- Removed unused `message` param from `spin()` [#157](https://github.com/spraakbanken/mink-frontend/issues/157)

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ It is a [Vue 3](https://v3.vuejs.org/) app using [Vite](https://vitejs.dev/).
- Visualization of API calls:
1. Wrap async calls in [`spin`](src/spin/spin.composable.js):
```js
spin(loadCorpora(), "Loading corpora", "corpora");
spin(loadCorpora(), "corpora");
```
2. For markup that might change after the call, wrap it in [`<PendingContent>`](src/spin/PendingContent.vue) to apply animation:
```html
Expand Down
85 changes: 19 additions & 66 deletions src/api/backend.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,34 @@ export default function useMinkBackend() {
const { spin } = useSpin();
const { t } = useI18n();

const loadCorpusIds = () =>
spin(api.listCorpora(), t("corpus.list.loading"), "corpora");
const loadCorpusIds = () => spin(api.listCorpora(), "corpora");

const createCorpus = () =>
spin(api.createCorpus(), t("corpus.creating"), "create");
const createCorpus = () => spin(api.createCorpus(), "create");

const createMetadata = (publicId: string) =>
spin(api.createMetadata(publicId), null, "create");
spin(api.createMetadata(publicId), "create");

const deleteCorpus = (corpusId: string) =>
spin(
api.removeCorpus(corpusId),
t("corpus.deleting"),
`corpus/${corpusId}`,
);
spin(api.removeCorpus(corpusId), `corpus/${corpusId}`);

const deleteMetadata = (resourceId: string) =>
spin(api.removeMetadata(resourceId), null, `resource/${resourceId}`);
spin(api.removeMetadata(resourceId), `resource/${resourceId}`);

const loadConfig = (corpusId: string) =>
spin(
api.downloadConfig(corpusId),
t("config.loading"),
`corpus/${corpusId}/config`,
);
spin(api.downloadConfig(corpusId), `corpus/${corpusId}/config`);

const saveConfig = (corpusId: string, configYaml: string) =>
spin(
api.uploadConfig(corpusId, configYaml),
t("corpus.configuring"),
`corpus/${corpusId}/config`,
);
spin(api.uploadConfig(corpusId, configYaml), `corpus/${corpusId}/config`);

const downloadSource = (corpusId: string, filename: string, binary = false) =>
spin(
api.downloadSources(corpusId, filename, binary),
t("source.downloading"),
`corpus/${corpusId}/sources/${filename}`,
);

const downloadPlaintext = (corpusId: string, filename: string) =>
spin(
api.downloadSourceText(corpusId, filename),
t("source.downloading_plain"),
`corpus/${corpusId}/sources/${filename}/plain`,
);

Expand All @@ -62,89 +46,58 @@ export default function useMinkBackend() {
) =>
spin(
api.uploadSources(corpusId, files, onProgress),
t("source.uploading", files.length),
`corpus/${corpusId}/sources`,
);

const deleteSource = (corpusId: string, filename: string) =>
spin(
api.removeSource(corpusId, filename),
t("source.deleting"),
`corpus/${corpusId}/sources`,
);
spin(api.removeSource(corpusId, filename), `corpus/${corpusId}/sources`);

const uploadMetadata = (resourceId: string, yaml: string) =>
spin(
api.uploadMetadataYaml(resourceId, yaml),
null,
`resource/${resourceId}/metadata`,
);

const downloadMetadata = (resourceId: string) =>
spin(
api.downloadMetaataYaml(resourceId),
null,
`resource/${resourceId}/metadata`,
);

const resourceInfoAll = () =>
spin(api.resourceInfoAll(), t("resource.loading"), "corpora");
const resourceInfoAll = () => spin(api.resourceInfoAll(), "corpora");

const resourceInfoOne = (corpusId: string) =>
spin(
api.resourceInfoOne(corpusId),
t("resource.loading"),
`corpus/${corpusId}/job`,
);
spin(api.resourceInfoOne(corpusId), `corpus/${corpusId}/job`);

const runJob = (corpusId: string) =>
spin(api.runSparv(corpusId), t("job.starting"), `corpus/${corpusId}/job`);
spin(api.runSparv(corpusId), `corpus/${corpusId}/job`);

const installKorp = (corpusId: string) =>
spin(
api.installKorp(corpusId),
t("job.installing"),
`corpus/${corpusId}/job`,
);
spin(api.installKorp(corpusId), `corpus/${corpusId}/job`);

const installStrix = (corpusId: string) =>
spin(
api.installStrix(corpusId),
t("job.installing"),
`corpus/${corpusId}/job`,
);
spin(api.installStrix(corpusId), `corpus/${corpusId}/job`);

const abortJob = (corpusId: string) =>
spin(api.abortJob(corpusId), t("job.aborting"), `corpus/${corpusId}/job`);
spin(api.abortJob(corpusId), `corpus/${corpusId}/job`);

const loadExports = (corpusId: string) =>
spin(
api.listExports(corpusId),
t("exports.loading"),
`corpus/${corpusId}/exports`,
);
spin(api.listExports(corpusId), `corpus/${corpusId}/exports`);

const downloadExports = (corpusId: string) =>
spin(
api.downloadExports(corpusId),
t("exports.downloading"),
`corpus/${corpusId}/exports`,
);
spin(api.downloadExports(corpusId), `corpus/${corpusId}/exports`);

const downloadExportFiles = (corpusId: string, filename: string) =>
spin(
api.downloadExportFile(corpusId, filename),
t("exports.downloading"),
`corpus/${corpusId}/exports`,
);

const checkAdminMode = () => spin(api.adminModeStatus(), null, "admin-mode");
const checkAdminMode = () => spin(api.adminModeStatus(), "admin-mode");

const enableAdminMode = () =>
spin(api.adminModeOn(), "Enabling admin mode", "admin-mode");
const enableAdminMode = () => spin(api.adminModeOn(), "admin-mode");

const disableAdminMode = () =>
spin(api.adminModeOff(), "Disabling admin mode", "admin-mode");
const disableAdminMode = () => spin(api.adminModeOff(), "admin-mode");

return {
loadCorpusIds,
Expand Down
3 changes: 1 addition & 2 deletions src/auth/auth.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ export function useAuth() {
}
}
// Reuse current JWT request or make a new one.
jwtPromise =
jwtPromise || spin(fetchAndStoreJwt(), t("jwt.refreshing"), "jwt");
jwtPromise = jwtPromise || spin(fetchAndStoreJwt(), "jwt");
await jwtPromise;
// Free the slot for subsequent refreshes.
jwtPromise = undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/corpus/CreateCorpus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function submit(fields: Form) {
fields.format,
fields.textAnnotation,
);
await spin(createPromise, null, "create");
await spin(createPromise, "create");
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/corpus/deleteCorpus.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function useDeleteCorpus() {
*/
async function deleteCorpus(corpusId: string) {
// Wrap deletion as well as refreshing in spin, for visual feedback.
return spin(doDeleteCorpus(corpusId), null, `corpus/${corpusId}`);
return spin(doDeleteCorpus(corpusId), `corpus/${corpusId}`);
}

return { deleteCorpus };
Expand Down
16 changes: 0 additions & 16 deletions src/i18n/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ library.help.corpora: These are the corpora that you have created. Only you can
library.help.corpora.none: Mink provides automatic linguistic analysis for your data. Start by creating a corpus; use the "@:{'new_corpus'}" button or drop text files into the upload field below.
library.help.metadata: A metadata record holds information describing an arbitrary resource. Mink will not process any data for this resource, but you can export the metadata to a repository.
corpus.create.help: The corpus will be accessible by you only. You can always change these values later.
corpus.creating: Creating corpus
corpus.configuring: Configuring corpus
corpus.delete: Delete corpus
corpus.deleting: Deleting corpus
corpus.list.loading: Listing corpora
corpus.state.unknown: Unknown
corpus.state.empty: No files
corpus.state.needing_config: Configuration needed
Expand All @@ -54,20 +50,15 @@ metadata.new: New metadata
metadata.public_id.help: In Mink, all resources have fixed, unmodifiable identifiers. The public identifier is what this resource will get once it is exported to a repository. Try to make it recognizable and descriptive, but not too long. It must only contain lowercase letters, numbers and dashes, and start with your assigned organization prefix.
metadata.public_id.error.format: The public identifier must only contain lowercase letters (a-z), numbers (0-9) and dashes (-). It must not start or end with a dash.
metadata.delete: Delete metadata
resource.loading: Loading resource
resource.delete.ask: Are you sure you want to delete this resource?
config.metadata.help: Metadata is information about the data, meant for assessment by interested users (if you release the data), and for categorization in data repositories.
config.configuration.help: These settings are information for the automatic analysis; they will affect the parsing or annotation.
corpus.config.parse.error: The config of this corpus could not be parsed. Try editing the settings or metadata again. If you need help, please contact sb-info{'@'}svenska.gu.se
config.loading: Loading metadata
config.saving: Saving metadata
job.run: Run annotation
job.rerun: Re-run annotation
job.rerun.overwrite: Previous results will be overwritten
job.abort: Abort
job.aborting: Aborting annotation job
job.starting: Queueing annotation job
job.installing: Installing to Korp
job.status: Status
job.priority: Place in queue
job.last_run_started: Last run started
Expand All @@ -76,26 +67,20 @@ job.time_taken: Time taken
job.process.sparv: Annotation
job.process.korp: Installation to Korp
job.process.strix: Installation to Strix
source.deleting: Deleting text
source.downloading: Downloading text
source.downloading_plain: Downloading extracted text
source.limit.file.recommended: Recommended max file size
source.limit.file.max: Maximum file size
source.limit.upload.max: Maximum batch upload size
source.limit.corpus.recommended: Recommended max corpus size
source.limit.corpus.max: Maximum corpus size
source.notfound: This source file was not found
source.uploading: Uploading text file | Uploading text files
source.list.loading: Listing source texts
source.content: Content
upload.label.single: Add file
upload.label.multiple: Add files
upload.dnd.single: Drag and drop file here, or click here to choose
upload.dnd.multiple: Drag and drop files here, or click here to choose
upload.drop.empty: No file was dropped. Drag-and-drop may not be supported on your system.
jwt.refreshing: Refreshing account
tools: Explore
exports.loading: Listing result files
exports.tools.help: Use this data in Språkbanken's corpus tools. Your data will be available to you only, in a special Mink mode.
exports.tools.help.korp: Korp offers concordance search, detailed queries, frequency statistics and more.
exports.tools.help.korp.manual.url: https://spraakbanken.gu.se/en/tools/korp/user-manual
Expand All @@ -105,7 +90,6 @@ exports.tools.install: Install
exports.tools.reinstall: Reinstall
exports.tools.view: View
exports.download.help: Results can be downloaded as machine-readable files for processing in scripts or other specialized software.
exports.downloading: Downloading results
exports.help: The annotation process yields export files for each input file. You can download each single export file or all of them in a bundle. The exact structure of the files depends on the input files as well as the configuration. They are stored on the server indefinitely, but re-running the annotation will replace them with new ones.
exports.help.more.label: Read more about export files in the user manual
user.settings: Settings
Expand Down
16 changes: 0 additions & 16 deletions src/i18n/locales/sv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ library.help.corpora.none: >-
Mink erbjuder automatisk språkvetenskaplig analys av din data. Börja med att skapa en korpus: använd knappen "@:{'new_corpus'}" eller dra textfiler till uppladdningsrutan nedan.
library.help.metadata: Ett metadataobjekt har information som beskriver en godtycklig resurs. Mink bearbetar ingen data för dessa objekt, men de kan exporteras till en datakatalog.
corpus.create.help: Korpusen kommer bara att vara synlig för dig. Du kan alltid uppdatera de här uppgifterna senare.
corpus.creating: Skapar korpus
corpus.configuring: Konfigurerar korpus
corpus.delete: Radera korpus
corpus.deleting: Raderar korpus
corpus.list.loading: Hämtar korpusar
corpus.state.unknown: Okänt
corpus.state.empty: Inga filer
corpus.state.needing_config: Behöver konfigureras
Expand All @@ -55,20 +51,15 @@ metadata.new: Ny metadata
metadata.public_id.help: Varje resurs i Mink har en förutbestämd identifierare. Den publika identifieraren är vad denna resurs kommer at få när den exporteras till en datakatalog. Välj gärna något unikt och beskrivande, men inte för långt. Den får endast innehålla små bokstäver, siffror och bindestreck, och måste börja med ditt tilldelade organisationsprefix.
metadata.public_id.error.format: Den publika identifieraren får endast innehålla små bokstäver (a-z), siffror (0-9) och bindestreck (-). Den får inte börja eller sluta med bindestreck.
metadata.delete: Radera metadata
resource.loading: Laddar resurs
resource.delete.ask: Är du säker på att du vill ta bort den här resursen?
config.metadata.help: Metadata är information om datan, och fungerar som underlag för potentiellt intresserade användare (om du publicerar datan) samt underlättar katalogiseringen i datarepositorier.
config.configuration.help: Dessa inställningar blir instruktioner till den automatiska analysen.
corpus.config.parse.error: Korpusens config kunde inte läsas. Prova att redigera inställningarna eller metadatan igen. Om du behöver hjälp kan du kontakta sb-info{'@'}svenska.gu.se
config.loading: Hämtar metadata
config.saving: Sparar metadata
job.run: Starta annotering
job.rerun: Starta om annotering
job.rerun.overwrite: Tidigare resultat kommer att skrivas över
job.abort: Avbryt
job.aborting: Avbryter annotering
job.starting: Lägger annotering i kö
job.installing: Installerar i Korp
job.status: Status
job.priority: Plats i kön
job.last_run_started: Senast startad
Expand All @@ -77,26 +68,20 @@ job.time_taken: Tidsåtgång
job.process.sparv: Annotering
job.process.korp: Installation i Korp
job.process.strix: Installation i Strix
source.deleting: Raderar text
source.downloading: Laddar ner text
source.downloading_plain: Laddar ner extraherad text
source.limit.file.recommended: Rekommenderad filstorlek
source.limit.file.max: Högsta tillåtna filstorlek
source.limit.upload.max: Största tillåtna uppladdning
source.limit.corpus.recommended: Rekommenderad korpusstorlek
source.limit.corpus.max: Största tillåtna korpus
source.notfound: Denna källfil kunde inte hittas
source.uploading: Laddar upp källfil | Laddar upp källfiler
source.list.loading: Hämtar textlista
source.content: Innehåll
upload.label.single: Lägg till fil
upload.label.multiple: Lägg till filer
upload.dnd.single: Dra och släpp en fil hit, eller klicka här för att välja
upload.dnd.multiple: Dra och släpp filer hit, eller klicka här för att välja
upload.drop.empty: Ingen fil släpptes. Dra-och-släpp kanske inte stöds på ditt system.
jwt.refreshing: Uppdaterar konto
tools: Utforska
exports.loading: Hämtar resultatlista
exports.tools.help: Använd den här datan i Språkbankens korpusverktyg. Din data visas bara för dig, i ett särskilt Mink-läge.
exports.tools.help.korp: I Korp finns konkordanssökning, detaljerade sökfrågor, frekvensstatistik med mera.
exports.tools.help.korp.manual.url: https://spraakbanken.gu.se/verktyg/korp/anvandarhandledning
Expand All @@ -106,7 +91,6 @@ exports.tools.install: Installera
exports.tools.reinstall: Installera om
exports.tools.view: Visa
exports.download.help: Resultatet kan laddas ner som maskinläsbara filer för bearbetning i script eller speciella program.
exports.downloading: Laddar ner analysresultat
exports.help: Annoteringsprocessen skapar exportfiler för varje källfil, och de kan laddas ner enskilt eller som arkiv. Filernas struktur beror både på källfilerna och konfigurationen. De lagras på servern tillsvidare, men ersätts med nya om du kör om annoteringen på nytt.
exports.help.more.label: Läs mer om exportfiler i användarhandledningen
user.settings: Inställningar
Expand Down
2 changes: 1 addition & 1 deletion src/library/CorpusButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { corpusName } = useConfig(props.id);
const corpus = resourceStore.corpora[props.id];
spin(loadCorpus(), null, "corpora");
spin(loadCorpus(), "corpora");
</script>

<template>
Expand Down
2 changes: 1 addition & 1 deletion src/library/LibraryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ requireAuthentication(() => {
});
async function createCorpusFromFiles(files: FileList) {
await spin(createFromUpload(files), null, "create");
await spin(createFromUpload(files), "create");
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/metadata/deleteMetadata.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function useDeleteMetadata() {
*/
async function deleteMetadata(resourceId: string) {
// Wrap deletion as well as refreshing in spin, for visual feedback.
return spin(doDeleteMetadata(resourceId), null, `resource/${resourceId}`);
return spin(doDeleteMetadata(resourceId), `resource/${resourceId}`);
}

return { deleteMetadata };
Expand Down
Loading

0 comments on commit 2ff7414

Please sign in to comment.