Skip to content

Commit

Permalink
[Merge] merge from dev into main (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
FacerAin committed Aug 10, 2023
2 parents 8a78429 + 9f8ae1c commit 00a5cd0
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
88 changes: 88 additions & 0 deletions src/components/dashboard/MainBottom.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<script setup>
import axios from 'axios';
import { ref } from 'vue';
let btnData = ref('upload');
let btnLoader = ref(false);
let btnType = ref('');
let btnMsg = ref('');
const showModal = ref(false);
const OnClick = () => {
btnLoader.value = true;
if (btnData.value == 'upload') {
axios
.post('/s3/upload')
.then((res) => {
btnData.value = 'download';
btnType.value = 'success';
btnMsg.value = 's3 업로드 완료';
btnLoader.value = false;
showModal.value = true;
})
.catch((err) => {
btnMsg.value = 's3 업로드 실패';
btnType.value = 'warning';
btnLoader.value = false;
showModal.value = true;
console.error(err);
});
} else if (btnData.value == 'download') {
axios
.get('/s3/download', { responseType: 'blob' })
.then((res) => {
btnData.value = 'upload';
btnType.value = 'success';
btnMsg.value = 's3 다운로드 완료';
btnLoader.value = false;
showModal.value = true;
const url = window.URL.createObjectURL(new Blob([res.data]), {
type: 'application/zip',
});
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'tf.zip');
document.body.appendChild(link);
link.click();
})
.catch((err) => {
btnMsg.value = 's3 다운로드 실패';
btnType.value = 'warning';
btnLoader.value = false;
showModal.value = true;
console.error(err);
});
}
};
</script>
<template>
<div>
<v-btn :loading="btnLoader" class="upload-btn" @click="OnClick">{{
btnData
}}</v-btn>
</div>
<template>
<v-dialog v-model="showModal" content-class="align-center">
<v-alert
variant="outlined"
:type="btnType"
prominent
border="top"
width="300"
>
{{ btnMsg }}
</v-alert>
</v-dialog>
</template>
</template>

<style>
.upload-btn {
margin-top: 10px;
margin-left: auto;
height: 2rem;
background-color: #228be6;
color: white;
font-weight: bold;
}
</style>
4 changes: 4 additions & 0 deletions src/views/dashboard/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
<v-row class="row-vueflow">
<v-col><NodePlane @nodeClicked="handleRightDrawer" /></v-col>
</v-row>
<v-row>
<v-col><MainBottom /></v-col>
</v-row>
</v-container>
</v-main>
</template>

<script setup>
import NodePlane from '@/components/node/NodePlane';
import DrawerInput from '@/components/aws/DrawerInput.vue';
import MainBottom from '@/components/dashboard/MainBottom.vue';
import { ref } from 'vue';
import store from '@/store';
Expand Down

0 comments on commit 00a5cd0

Please sign in to comment.