Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Reload Timer and fixed minor bugs #141

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion Taipei-City-Dashboard-FE/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Testing: Jack Huang (Data Scientist), Ian Huang (Data Analysis Intern)
<!-- Department of Information Technology, Taipei City Government -->

<script setup>
import { onBeforeMount, onMounted } from "vue";
import { onBeforeMount, onMounted, onBeforeUnmount, ref, computed } from "vue";
import { useAuthStore } from "./store/authStore";
import { useDialogStore } from "./store/dialogStore";
import { useContentStore } from "./store/contentStore";

import NavBar from "./components/utilities/bars/NavBar.vue";
import SideBar from "./components/utilities/bars/SideBar.vue";
Expand All @@ -24,6 +25,29 @@ import LogIn from "./components/dialogs/LogIn.vue";

const authStore = useAuthStore();
const dialogStore = useDialogStore();
const contentStore = useContentStore();

const timeToUpdate = ref(600);

const formattedTimeToUpdate = computed(() => {
const minutes = Math.floor(timeToUpdate.value / 60);
const seconds = timeToUpdate.value % 60;
return `${minutes}:${seconds < 10 ? "0" : ""}${seconds}`;
});

function reloadChartData() {
if (!["dashboard", "mapview"].includes(authStore.currentPath)) return;
contentStore.setCurrentDashboardChartData();
timeToUpdate.value = 600;
}
function updateTimeToUpdate() {
if (!["dashboard", "mapview"].includes(authStore.currentPath)) return;
if (timeToUpdate.value <= 0) {
timeToUpdate.value = 0;
return;
}
timeToUpdate.value -= 5;
}

onBeforeMount(() => {
authStore.initialChecks();
Expand All @@ -41,6 +65,13 @@ onMounted(() => {
if (!showInitialWarning) {
dialogStore.showDialog("initialWarning");
}

setInterval(reloadChartData, 1000 * 600);
setInterval(updateTimeToUpdate, 1000 * 5);
});
onBeforeUnmount(() => {
clearInterval(reloadChartData);
clearInterval(updateTimeToUpdate);
});
</script>

Expand Down Expand Up @@ -84,6 +115,16 @@ onMounted(() => {
</div>
<InitialWarning />
<LogIn />
<div
class="app-update"
v-if="
['dashboard', 'mapview'].includes(authStore.currentPath) &&
!authStore.isMobile &&
!authStore.isNarrowDevice
"
>
<p>下次更新:{{ formattedTimeToUpdate }}</p>
</div>
</div>
</template>

Expand All @@ -108,5 +149,23 @@ onMounted(() => {
flex-direction: column;
}
}

&-update {
position: fixed;
bottom: 0;
right: 20px;
color: white;
opacity: 0.3;
transition: opacity 0.3s;
user-select: none;

p {
color: var(--color-complement-text);
}

&:hover {
opacity: 1;
}
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ const chartOptions = ref({
grid: {
show: false,
},
labels: {
datetimeUTC: false,
},
legend: {
show: true,
markers: {
Expand Down Expand Up @@ -104,6 +101,9 @@ const chartOptions = ref({
color: "var(--color-complement-text)",
},
},
labels: {
datetimeUTC: false,
},
tooltip: {
enabled: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const chartOptions = ref({
grid: {
show: false,
},
labels: {
datetimeUTC: false,
},
legend: {
show: props.series.length > 1 ? true : false,
},
Expand Down Expand Up @@ -70,6 +67,9 @@ const chartOptions = ref({
crosshairs: {
show: false,
},
labels: {
datetimeUTC: false,
},
tooltip: {
enabled: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ const chartOptions = ref({
grid: {
show: false,
},
labels: {
datetimeUTC: false,
},
legend: {
show: props.series.length > 1 ? true : false,
},
Expand Down Expand Up @@ -71,6 +68,9 @@ const chartOptions = ref({
crosshairs: {
show: false,
},
labels: {
datetimeUTC: false,
},
tooltip: {
enabled: false,
},
Expand Down
2 changes: 1 addition & 1 deletion Taipei-City-Dashboard-FE/src/views/DashboardView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function handleOpenSettings() {
<button
@click="handleOpenSettings"
class="hide-if-mobile"
v-if="contentStore.currentDashboard.index !== 'favorites'"
v-if="contentStore.currentDashboard.icon !== 'favorite'"
>
加入您的第一個組件
</button>
Expand Down
2 changes: 1 addition & 1 deletion Taipei-City-Dashboard-FE/src/views/MapView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function handleOpenSettings() {
<button
@click="handleOpenSettings"
class="hide-if-mobile"
v-if="contentStore.currentDashboard.index !== 'favorites'"
v-if="contentStore.currentDashboard.icon !== 'favorite'"
>
加入您的第一個組件
</button>
Expand Down
Loading