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:
45
Frontend/src/components/mock/SaveComponent.vue
Normal file
45
Frontend/src/components/mock/SaveComponent.vue
Normal 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>
|
||||
Reference in New Issue
Block a user