Implemented most of logic behind REST Mock Services

Added dev.sh script to run r11-tools in dev-mode with hot-reload for frontend
This commit is contained in:
2023-06-19 15:31:15 +02:00
parent c0fcd53d35
commit 3a3073d236
9 changed files with 177 additions and 48 deletions

View File

@@ -0,0 +1,45 @@
<script setup lang="ts">
import { ref } from 'vue';
import MockedMessageToastComponent from './MockedMessageToastComponent.vue';
const props = defineProps(
{
messageData : {type: Object, required:true}
}
)
const message = ref('');
const visible = ref('hidden');
const fetchLink = window.location.protocol + "//" + window.location.hostname + "/mock/api/mock"
function prepareAndSendData(){
if (props.messageData != null|| props.messageData != undefined ){
fetch(fetchLink, { method: "put", body:JSON.stringify(props.messageData), headers: { "Content-Type" : "application/json" }})
.then( response => response.text() )
.then( data => {message.value = data} )
.catch(exception => {message.value = exception})
showToast();
}
}
function showToast(){
visible.value = "visible";
}
function hideToast(){
visible.value = "hidden";
}
</script>
<template>
<button @click="prepareAndSendData()" class="w-2/12 tool-button">Save</button>
<div class="fixed bottom-5 right-12">
<MockedMessageToastComponent @closed:toast_closed="hideToast()" v-bind:visible="visible" v-bind:message="message"/>
</div>
</template>