Skip to content

Commit 6f74ff5

Browse files
committed
finish remaining parts
1 parent 8f6e676 commit 6f74ff5

15 files changed

+639
-11
lines changed

package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
},
1111
"dependencies": {
1212
"axios": "^1.6.2",
13+
"chart.js": "^4.4.1",
1314
"flowbite": "^2.2.1",
1415
"js-cookie": "^3.0.5",
1516
"vue": "^3.3.11",
17+
"vue-chartjs": "^5.3.0",
1618
"vue-router": "^4.2.5"
1719
},
1820
"devDependencies": {

src/App.vue

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
<template>
2+
<nav v-if="!isLogged">
3+
<LogoutNavBar/>
4+
<div class="m-3">
5+
<router-view/>
6+
</div>
7+
</nav>
8+
<div class="sm:flex">
9+
<nav v-if="isLogged">
10+
<LoggedNavBar v-if="isLogged" />
11+
</nav>
12+
<div class="sm:flex-1 p-3 sm:ml-32 mt-8 sm:mt-0">
13+
<router-view />
14+
</div>
15+
</div>
16+
</template>
17+
18+
<!--
119
<template>
220
<nav v-if="!isLogged">
321
<LogoutNavBar/>
@@ -6,12 +24,13 @@
624
</div>
725
</nav>
826
<nav v-if="isLogged" class="sm:flex">
9-
<LoggedNavBar v-if="isLogged" class="sm:flex-none" />
27+
<LoggedNavBar v-if="isLogged" class="flex-no-wrap fixed relative top-0 sm:flex-none" />
1028
<div class="sm:flex-1 m-3">
1129
<router-view class="w-full" />
1230
</div>
1331
</nav>
1432
</template>
33+
-->
1534

1635
<script>
1736

src/components/LoggedNavBar.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template>
2-
<div ref="dashboard-menu" id="dashboard-menu" class="hidden sm:flex sm:w-1/3 md:w-1/6 flex-col justify-between bg-[#575757] w-1/4 text-gray-300 h-screen text-center">
2+
<div ref="dashboard-menu" id="dashboard-menu" class="hidden sm:flex w-[100px] flex-col justify-between bg-[#575757] w-1/4 text-gray-300 h-screen text-center fixed top-0 left-0 bottom-0">
33
<div>
44
<div class="px-2 pt-2 pb-3 space-y-1">
55
<ul>
66
<li><a href="/">NYCU-ME</a></li>
77
<li><hr/></li>
88
<li><a href="/dashboard">儀表板</a></li>
9-
<li><a href="/manage">DNS 管理</a></li>
9+
<li><a href="/domains">DNS 管理</a></li>
1010
<li><a href="/profile">個人資料</a></li>
1111
</ul>
1212
</div>
@@ -26,7 +26,7 @@
2626
</div>
2727
</div>
2828

29-
<nav ref="navbar" class="sm:hidden bg-[#575757]">
29+
<nav ref="navbar" class="sm:hidden w-screen bg-[#575757]">
3030
<div class="max-w-7xl mx-auto px-2 sm:px-6 lg:px-8">
3131
<div class="flex items-center justify-between h-16">
3232
<div class="flex-1 flex items-center justify-start sm:items-stretch">
@@ -46,10 +46,11 @@
4646
</div>
4747
</nav>
4848

49-
<div ref="dashboard-menu" id="dashboard-menu" class="overlay-element bg-[#363B3F] w-screen text-gray-300" v-show="isMenuOpen">
49+
<div ref="dashboard-menu" id="dashboard-menu" class="sm:hidden overlay-element bg-[#363B3F] w-screen text-gray-300" v-show="isMenuOpen">
5050
<div class="flex flex-col items-center px-2 pt-2 pb-3 space-y-1">
5151
<ul class="w-full text-center">
5252
<li><a href="/dashboard" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">儀表板</a></li>
53+
<li><a href="/domains" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">DNS 管理</a></li>
5354
<li><a href="/profile" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">個人資料</a></li>
5455
<li><hr class="w-full"/></li>
5556
<li><a href="/about-us" class="text-gray-300 hover:bg-gray-700 hover:text-white px-3 py-2 rounded-md text-sm font-medium">關於我們</a></li>

src/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createApp } from 'vue'
22
import './index.css'
33
import App from './App.vue'
4-
import 'flowbite';
4+
import { Bar } from 'vue-chartjs'
55
import router from './router';
66

77
createApp(App)

src/router/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@ import HomePage from '../views/HomePage.vue';
44
import LoginPage from '../views/LoginPage.vue';
55
import AboutUs from '../views/AboutUs.vue';
66
import MyDomains from '../views/MyDomains.vue';
7+
import DomainPanel from '../views/DomainPanel.vue';
8+
import StatisticBoard from '../views/StatisticBoard.vue';
9+
import MyProfile from '../views/MyProfile.vue';
10+
import DashboardPage from '../views/DashboardPage.vue';
11+
import ContactUs from '../views/ContactUs.vue';
12+
import UsageRules from '../views/UsageRules.vue';
713

814
const routes = [
915
{ path: '/', component: HomePage },
1016
{ path: '/login', component: LoginPage },
1117
{ path: '/about-us', component: AboutUs },
12-
{ path: '/manage', component: MyDomains },
18+
{ path: '/domains', component: MyDomains },
19+
{ path: '/domain', component: DomainPanel },
20+
{ path: '/statistic', component: StatisticBoard },
21+
{ path: '/profile', component: MyProfile },
22+
{ path: '/dashboard', component: DashboardPage },
23+
{ path: '/contact-us', component: ContactUs },
24+
{ path: '/rules', component: UsageRules },
1325
];
1426

1527
const router = createRouter({

src/views/AboutUs.vue

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,54 @@
3232
</div>
3333
<hr/>
3434
</div>
35+
<hr/>
36+
<div class="p-16">
37+
<div class="flex justify-center ">
38+
感謝以下貢獻者:
39+
</div>
40+
<div class="m-16">
41+
{{contributors}}
42+
</div>
43+
</div>
3544
</template>
3645

46+
47+
<script>
48+
import axios from 'axios';
49+
50+
export default {
51+
data() {
52+
return {
53+
contributor_list: [],
54+
contributors: "",
55+
}
56+
},
57+
created() {
58+
this.getContributors();
59+
},
60+
methods: {
61+
async getContributors() {
62+
try {
63+
const apiServerResponse = await axios.get('https://api.github.com/repos/NYCU-ME/backend-flask-server/pulls?state=closed');
64+
const backendResponse = await axios.get('https://api.github.com/repos/NYCU-ME/backend/pulls?state=closed');
65+
const frontendResponse = await axios.get('https://api.github.com/repos/NYCU-ME/frontend/pulls?state=closed');
66+
const contributorsResponse = await axios.get('https://api.github.com/repos/NYCU-ME/contributors/pulls?state=closed');
67+
68+
69+
// Concatenate contributors from all sources
70+
const contributor_list = apiServerResponse['data'].concat(backendResponse['data']).concat(frontendResponse['data']).concat(contributorsResponse['data']);
71+
72+
for(let i = 0; i < contributor_list.length; i++) {
73+
if(contributor_list[i]['merged_at'] != null)
74+
this.contributor_list.push(contributor_list[i]['user']['login'])
75+
}
76+
const unique = arr => [...new Set(arr)];
77+
this.contributors = unique(this.contributor_list).join(", ")
78+
} catch (error) {
79+
console.error('Error fetching contributors:', error);
80+
}
81+
},
82+
}
83+
}
84+
</script>
85+

src/views/ContactUs.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<template>
2+
本專案目前由 Lin Lee 維護,若有任何問題,請至 <a href="https://github.com/NYCU-ME/">GitHub</a> 發 Issues,或是寄信給 lin.cs09[a]nycu.edu.tw。
3+
</template>
4+

src/views/DashboardPage.vue

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<template>
2+
<div class="overflow-x-auto">
3+
<table class="min-w-full bg-white">
4+
<thead class="bg-gray-800 text-white">
5+
<tr>
6+
<th class="text-left py-3 px-4 uppercase font-semibold text-sm">網域名稱</th>
7+
<th class="text-left py-3 px-4 uppercase font-semibold text-sm">有效日期</th>
8+
</tr>
9+
</thead>
10+
<tbody class="text-gray-700">
11+
<tr v-for="(user_domain, index) in this.domains" :key="index">
12+
<td class="text-left py-3 px-4">{{ user_domain.domain }}</td>
13+
<td class="text-left py-3 px-4">{{ user_domain.expDate }}</td>
14+
</tr>
15+
</tbody>
16+
</table>
17+
</div>
18+
</template>
19+
20+
<script>
21+
import axios from 'axios';
22+
import Cookies from 'js-cookie';
23+
24+
const baseUrl = import.meta.env.VITE_API_BASE_URL;
25+
26+
export default {
27+
data() {
28+
return {
29+
isRegistering: false,
30+
domain: "",
31+
domains: [],
32+
}
33+
},
34+
mounted() {
35+
const token = Cookies.get('token');
36+
if (!token) {
37+
alert("還並未登入。");
38+
window.location.href = '/';
39+
} else {
40+
this.getDomains(token);
41+
}
42+
},
43+
methods: {
44+
async getDomains(token) {
45+
try {
46+
const response = await axios.get(`${baseUrl}/domains`, {headers: `Authorization: Bearer ${token}`});
47+
const data = response.data;
48+
this.domains = data.data;
49+
console.log(this.domains)
50+
} catch(e){
51+
console.log(e)
52+
if(e.response.status == 401) {
53+
Cookies.remove('token');
54+
alert("您尚未登入!");
55+
window.location.href = '/login'
56+
}
57+
if(e.response.status == 403) {
58+
alert("暫時不開放給非管理員使用。")
59+
window.location.href = '/'
60+
}
61+
}
62+
}
63+
}
64+
}
65+
</script>

0 commit comments

Comments
 (0)