Changeset 35718


Ignore:
Timestamp:
2021-11-01T21:31:59+13:00 (5 weeks ago)
Author:
cstephen
Message:

Implement download support

Location:
main/trunk/model-interfaces-dev/atea/macron-restoration/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/DirectInput.vue

    r35716 r35718  
    66        {{ output }}
    77    </div>
     8
     9    <button class="btn-primary right-column" :disabled="!canDownload" @click="downloadAsText">Download</button>
    810</div>
    911</template>
     
    1315    display: grid;
    1416    grid-template-columns: 1fr 1fr;
     17    grid-template-rows: auto auto;
    1518    gap: 1em;
    1619}
     
    2124    overflow: hidden;
    2225}
     26
     27.right-column {
     28    grid-column: 2;
     29}
    2330</style>
    2431
    2532<script>
    2633import { mapState } from "vuex";
     34import { saveAs } from "file-saver"
    2735import MacronRestorationModule from "../js/MacronRestorationModule"
    2836
     
    3543            input: "",
    3644            output: "",
    37             transcribeTimeout: null
     45            transcribeTimeout: null,
     46            waitingOnTranscribe: false
    3847        }
    3948    },
    4049    computed: {
     50        canDownload() {
     51            return this.output.length > 0 && !this.waitingOnTranscribe;
     52        },
    4153        ...mapState({
    4254            translations: state => state.translations
     
    4557    watch: {
    4658        input() {
     59            this.waitingOnTranscribe = true;
     60
    4761            if (this.transcribeTimeout !== null) {
    4862                clearTimeout(this.transcribeTimeout);
     
    6175        },
    6276        async updateMacronisedText() {
     77            // TODO: Handle error
    6378            const response = await macroniser.directMacronisation(this.input);
    6479            this.output = response.fragment2;
     80            this.waitingOnTranscribe = false;
     81        },
     82        downloadAsText() {
     83            const blob = new Blob([ this.output ], { type: "text/plain;charset=utf-8" });
     84            saveAs(blob, "output.txt");
    6585        }
    6686    }
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/styles/_material.scss

    r35715 r35718  
    7171    display: flex;
    7272    align-items: center;
    73     text-align: left;
     73    justify-content: center;
    7474
    7575    background-color: var(--bg-color);
Note: See TracChangeset for help on using the changeset viewer.