#5 Fix monaco editor for explain crontab tool #6

Merged
stuzer05 merged 1 commits from stuzer05/random-web-tools#5 into master 2024-03-09 16:13:12 +02:00

@ -4,38 +4,48 @@
<div class="input-group"> <div class="input-group">
<label for="data">Data</label> <label for="data">Data</label>
<input id="data" class="input" v-model="toolData.data" placeholder="* * * * *" type="text"> <input id="data" class="input" v-model="toolData.data" v-on:keyup="result" placeholder="* * * * *" type="text">
</div> </div>
<hr class="mt-5 mb-5"> <hr class="mt-5 mb-5">
<div class="input-group"> <div class="input-group">
<label for="result">Result</label> <label for="result">Result</label>
<textarea id="result" v-model="toolResult"></textarea> <MonacoEditor name="result" language="json" :value="toolResult"></MonacoEditor>
</div> </div>
</template> </template>
<script> <script>
import cronstrue from 'cronstrue'; import cronstrue from 'cronstrue';
import { unproxy } from "@/utils/unproxy"; import MonacoEditor from "@/components/MonacoEditor.vue";
export default { export default {
components: {
MonacoEditor
},
data() { data() {
return { return {
toolData: { toolData: {
data: '* * * * *', data: '* * * * *',
}, },
toolResult: '',
}; };
}, },
computed: { mounted() {
toolResult() { this.toolResult = cronstrue.toString(this.toolData.data, {
use24HourTimeFormat: true,
verbose: true,
});
},
methods: {
result() {
try { try {
return cronstrue.toString(this.toolData.data, { this.toolResult = cronstrue.toString(this.toolData.data, {
use24HourTimeFormat: true, use24HourTimeFormat: true,
verbose: true, verbose: true,
}); });
} catch (e) { } catch (e) {
return 'invalid syntax'; this.toolResult = 'invalid syntax';
} }
}, },
}, },