Skip to content

Commit e60bbbb

Browse files
committed
[fix] 알림, 대시보드 갱신 기능
알림은 시연을 위한 기능
1 parent 3c3d357 commit e60bbbb

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/views/Dashboard.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import PieGraph from "@/views/components/PieGraph.vue"
1616
import LineGraph from "@/views/components/LineGraph.vue";
1717
import GaugeGraph from "@/views/components/GaugeGraph.vue";
1818
import store from "@/store";
19-
import { useToast } from 'vue-toastification'; // vue-toastification 라이브러리에서 useToast 함수를 가져옵니다.
19+
import { useToast } from 'vue-toastification';
20+
import {defaultInstance} from "@/axios/axios-instance"; // vue-toastification 라이브러리에서 useToast 함수를 가져옵니다.
2021
2122
export default {
2223
components: {
@@ -30,7 +31,12 @@ export default {
3031
return store.getters.projectId;
3132
}
3233
},
33-
mounted() {
34+
async mounted() {
35+
try {
36+
defaultInstance.get(`/graphs/refresh`); // 프로젝트 ID를 이용해 프로젝트 정보를 가져옵니다.
37+
} catch (error) {
38+
toast.error("데이터를 불러오는 중 오류가 발생했습니다."); // 데이터를 불러오는 중 오류가 발생한 경우 토스트 메시지를 표시합니다.
39+
}
3440
const toast = useToast(); // 토스트 메시지를 사용할 수 있는 toast 객체를 생성합니다.
3541
if (!this.projectId) {
3642
toast.warning("표시할 데이터가 없습니다."); // projectId가 없는 경우 토스트 메시지를 표시합니다.

src/views/Notifications.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
<i class="material-icons text-white me-2">notifications</i>
1313
<h6 class="text-white text-capitalize mb-0">알림</h6>
1414
</div>
15+
<div class="d-flex align-items-center">
16+
<button
17+
class="btn btn-link text-white text-decoration-none"
18+
@click="sendNotifications"
19+
>
20+
<i class="material-icons text-white">refresh</i> 새로고침
21+
</button>
22+
</div>
1523
</div>
1624
</div>
1725
<!-- 카드 본문 -->
@@ -156,6 +164,15 @@ const fetchNotifications = async () => {
156164
// stopPolling: null,
157165
// });
158166
167+
// 알림 생성 메소드 (임시)
168+
const sendNotifications = async () => {
169+
try {
170+
await defaultInstance.get(`/notifications/send/${store.getters.projectId}`);
171+
} catch (error) {
172+
toast.error(`알림을 보내는 중 오류 발생: ${error.message}`);
173+
}
174+
};
175+
159176
onMounted(async () => {
160177
store.dispatch("notifications/resetNotification");
161178
await fetchNotifications();

0 commit comments

Comments
 (0)