Merge branch 'main' into vue-documentation

This commit is contained in:
Priyatham Sai Chand 2024-03-08 12:49:59 -08:00 committed by GitHub
commit f72f64bab8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 489 additions and 5 deletions

View File

@ -4,11 +4,14 @@
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> <link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tauri + Vue + TS</title> <title>Tauri + Vue + TS</title>
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>
</body> </body>
</html> </html>

23
package-lock.json generated
View File

@ -9,7 +9,9 @@
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.4.0", "@tauri-apps/api": "^1.4.0",
"vue": "^3.2.45" "vue": "^3.2.45",
"vue-router": "^4.3.0"
}, },
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "^1.4.0", "@tauri-apps/cli": "^1.4.0",
@ -2052,6 +2054,11 @@
"dev": true, "dev": true,
"peer": true "peer": true
}, },
"node_modules/@vue/devtools-api": {
"version": "6.6.1",
"resolved": "https://registry.npmjs.org/@vue/devtools-api/-/devtools-api-6.6.1.tgz",
"integrity": "sha512-LgPscpE3Vs0x96PzSSB4IGVSZXZBZHpfxs+ZA1d+VEPwHdOXowy/Y2CsvCAIFrf+ssVU1pD1jidj505EpUnfbA=="
},
"node_modules/@vue/reactivity": { "node_modules/@vue/reactivity": {
"version": "3.4.18", "version": "3.4.18",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.18.tgz", "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.4.18.tgz",
@ -14297,6 +14304,20 @@
"url": "https://github.com/chalk/chalk?sponsor=1" "url": "https://github.com/chalk/chalk?sponsor=1"
} }
}, },
"node_modules/vue-router": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.3.0.tgz",
"integrity": "sha512-dqUcs8tUeG+ssgWhcPbjHvazML16Oga5w34uCUmsk7i0BcnskoLGwjpa15fqMr2Fa5JgVBrdL2MEgqz6XZ/6IQ==",
"dependencies": {
"@vue/devtools-api": "^6.5.1"
},
"funding": {
"url": "https://github.com/sponsors/posva"
},
"peerDependencies": {
"vue": "^3.2.0"
}
},
"node_modules/vue-style-loader": { "node_modules/vue-style-loader": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.3.tgz", "resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.3.tgz",

View File

@ -12,7 +12,8 @@
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.4.0", "@tauri-apps/api": "^1.4.0",
"vue": "^3.2.45" "vue": "^3.2.45",
"vue-router": "^4.3.0"
}, },
"devDependencies": { "devDependencies": {
"@tauri-apps/cli": "^1.4.0", "@tauri-apps/cli": "^1.4.0",

View File

@ -11,6 +11,9 @@ dependencies:
vue: vue:
specifier: ^3.2.45 specifier: ^3.2.45
version: 3.2.45 version: 3.2.45
vue-router:
specifier: ^4.3.0
version: 4.3.0(vue@3.2.45)
devDependencies: devDependencies:
'@tauri-apps/cli': '@tauri-apps/cli':
@ -1320,6 +1323,10 @@ packages:
- whiskers - whiskers
dev: true dev: true
/@vue/devtools-api@6.6.1:
resolution: {integrity: sha512-LgPscpE3Vs0x96PzSSB4IGVSZXZBZHpfxs+ZA1d+VEPwHdOXowy/Y2CsvCAIFrf+ssVU1pD1jidj505EpUnfbA==}
dev: false
/@vue/reactivity-transform@3.2.45: /@vue/reactivity-transform@3.2.45:
resolution: {integrity: sha512-BHVmzYAvM7vcU5WmuYqXpwaBHjsS8T63jlKGWVtHxAHIoMIlmaMyurUSEs1Zcg46M4AYT5MtB1U274/2aNzjJQ==} resolution: {integrity: sha512-BHVmzYAvM7vcU5WmuYqXpwaBHjsS8T63jlKGWVtHxAHIoMIlmaMyurUSEs1Zcg46M4AYT5MtB1U274/2aNzjJQ==}
dependencies: dependencies:
@ -8899,6 +8906,14 @@ packages:
webpack: 5.90.1 webpack: 5.90.1
dev: true dev: true
/vue-router@4.3.0(vue@3.2.45):
resolution: {integrity: sha512-dqUcs8tUeG+ssgWhcPbjHvazML16Oga5w34uCUmsk7i0BcnskoLGwjpa15fqMr2Fa5JgVBrdL2MEgqz6XZ/6IQ==}
peerDependencies:
vue: ^3.2.0
dependencies:
'@vue/devtools-api': 6.6.1
vue: 3.2.45
dev: false
/vue-style-loader@4.1.3: /vue-style-loader@4.1.3:
resolution: {integrity: sha512-sFuh0xfbtpRlKfm39ss/ikqs9AbKCoXZBpHeVZ8Tx650o0k0q/YCM7FRvigtxpACezfq6af+a7JeqVTWvncqDg==} resolution: {integrity: sha512-sFuh0xfbtpRlKfm39ss/ikqs9AbKCoXZBpHeVZ8Tx650o0k0q/YCM7FRvigtxpACezfq6af+a7JeqVTWvncqDg==}
dependencies: dependencies:

View File

@ -1,11 +1,18 @@
<script setup lang="ts"> <script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs // This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup // Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
// import Greet from "./components/Greet.vue"; import Greet from "./components/Greet.vue";
import Navbar from "./components/Navbar.vue";
import Camera from "./components/Camera.vue";
import { RouterView } from "vue-router";
</script> </script>
<template> <template>
<div class="container"> <div>
<Navbar/>
</div>
<RouterView/>
<!-- <div class="container">
<h1>Welcome to Tauri!</h1> <h1>Welcome to Tauri!</h1>
<div class="row"> <div class="row">
<a href="https://vitejs.dev" target="_blank"> <a href="https://vitejs.dev" target="_blank">
@ -36,7 +43,8 @@
> >
</p> </p>
</div>
</div> -->
</template> </template>
<style scoped> <style scoped>
@ -47,4 +55,11 @@
.logo.vue:hover { .logo.vue:hover {
filter: drop-shadow(0 0 2em #249b73); filter: drop-shadow(0 0 2em #249b73);
} }
.grid {
display: grid;
grid-template-columns: repeat(2, 1fr); /* 2 columns */
grid-template-rows: repeat(2, 46vh); /* 2 rows */
max-width: 100vw; /* Limit width to viewport width */
max-height: 100vh; /* Limit height to viewport height */
}
</style> </style>

14
src/assets/NGCP.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

141
src/components/Battery.vue Normal file
View File

@ -0,0 +1,141 @@
<template>
<div class="outer_div">
<div class="battery_container">
<!-- <div :class="percentageCSS" :style="{ width: this.percentage + '%' }"></div> -->
<div :class="percentageCSS" :style="[percentage > 15 ? { width: percentage + '%' } : { width: '15%'}]"></div>
</div>
<div class="battery_widget"></div>
<img class="lightingSymbol" :class="batteryStatus" src="..\assets\lightning-icon-png-5.png" >
</div>
</template>
<script lang="ts">
export default {
data() {
return {};
},
props: {
percentage: { required: true, type: Number},
charging: { required: true, type: Boolean},
},
computed: {
percentageCSS() {
if (this.percentage <= 0) {
return 'zeroPercent'
} else if ((this.percentage > 0) && (this.percentage <= 15)) {
return 'tenPercent'
} else if ((this.percentage > 15) && (this.percentage <= 30)) {
return 'twentyFivePercent'
} else if ((this.percentage > 30) && (this.percentage <= 50)) {
return 'fiftyPercent'
} else {
return 'normalPercent'
}
},
batteryStatus() {
if (this.charging == true) {
return 'charging'
} else if (this.percentage <= 0) {
return 'dead'
}
}
},
};
</script>
<style scoped>
.outer_div {
display: flex;
position: relative;
/* height: 110px;
width: 225px; */
height: 12%;
width: 12%;
}
.battery_widget {
position: relative;
height: 50%;
width: 10%;
background-color:black;
top: 30%;
left: 1%;
/* top: 30%; */
/* border-radius: 0 12px 12px 0; */
border-radius: 0 25% 25% 0;
}
/* .battery_icon {
position: absolute;
width: 40%;
left: 30%;
top: 15%;
animation: blinker 1s linear infinite;
visibility: hidden;
} */
.lightingSymbol {
position: absolute;
width: 40%;
left: 30%;
top: 15%;
visibility: hidden;
}
.dead {
visibility: visible;
animation: blinker 1s linear infinite;
}
.charging {
visibility: visible;
}
@keyframes blinker {
50% {
opacity: 0;
}
}
.battery_container {
position: relative;
display: flex;
border: 0.1em solid black;
height: 100%;
width: 100%;
border-radius: 12%;
background-color: white;
}
#battery_progress {
background-color: rgb(116, 194, 92);
border-radius: 12%;
height:100%;
width: 100%;
}
.zeroPercent {
width: 0%;
}
.tenPercent {
background-color: red;
border-radius: 12%;
height:100%;
}
.twentyFivePercent {
background-color: rgb(116, 115, 109);
border-radius: 12%;
height:100%;
}
.fiftyPercent {
background-color: rgb(245, 225, 44);
border-radius: 12%;
height:100%;
}
.normalPercent {
background-color: rgb(116, 194, 92);
border-radius: 12%;
}
</style>

63
src/components/Camera.vue Normal file
View File

@ -0,0 +1,63 @@
<script>
export default {
props: ['cameraNumber'],
data() {
return {
localIp: 'http://192.168.1.173', //maybe change accordingly
port: '5000', //maybe change accordingly
cameraUrls: {
1: 'video_feed', //cam url here
2: 'video_feed2',
}
};
},
mounted() {
// this.initCam();
},
methods: {
// async initCam() {
// try {
// const constraints = { video: true };
// const stream = await navigator.mediaDevices.getUserMedia(constraints);
// this.streams.push(stream);
// } catch (error) {
// console.error('Error accessing camera:', error);
// }
// },
getCameraImageUrl(cameraNumber) {
return `${this.localIp}:${this.port}/${this.cameraUrls[cameraNumber]}`;
}
}
};
</script>
<template>
<div class="box video-section">
<img :src="getCameraImageUrl(cameraNumber)" class="video-image">
</div>
</template>
<style scoped>
/* .app {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
} */
.video-section {
width: 100%;
height: 100%;
box-sizing: border-box;
border: 2px solid #ccc;
}
.video-image {
width: 100%;
height: 100%;
/* object-fit: contain; */
}
.box{
border: 2px solid #030303;
}
</style>

83
src/components/Navbar.vue Normal file
View File

@ -0,0 +1,83 @@
<script>
export default {
data() {
return {
isNavbarOpen: false,
misson_one_status: "Done",
misson_two_status: "In Progress",
misson_three_status: "initiated",
};
},
methods: {
toggleNavbar() {
this.isNavbarOpen = !this.isNavbarOpen;
}
}
};
</script>
<template>
<nav style="background-color: #011949; padding: 10px;">
<div style="display: flex; align-items: center;">
<router-link to="/" style="text-decoration: none;">
<img src="../assets/NGCP.svg" alt="" width="40" height="24">
<span style="font-weight: bold; font-size: 1.2rem; margin-left: 10px;">NG</span>
<span style="font-weight: bold; font-size: 1.2rem; color: white">CP</span>
</router-link>
<div style="width: 12rem; height:4rem;border: 2px solid rgb(52, 49, 49); background-color: rgb(255, 255, 255); margin-left: auto; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;">
<div>
<span style="font-weight: bold; font-size: 1.2rem; color: rgb(0, 0, 0);">Mission 1</span>
<button style="border: 2px solid rgb(0, 0, 0); margin-left: 1.2rem; color: rgb(0, 0, 0); padding: 3px 6px; font-size: 0.8rem;" type="button" @click="">
<router-link to="/1" class="router-link">
<span style="font-weight: bold; font-size: 0.8rem;">OPEN</span>
</router-link>
</button>
</div>
<div>
<span style="font-weight: bold; font-size: 1.2rem; color: rgb(0, 0, 0);">Status: {{ misson_one_status }}</span>
</div>
</div>
<div style="width: 12rem; height:4rem;border: 2px solid rgb(52, 49, 49); background-color: rgb(255, 255, 255); margin-left: auto; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;">
<div>
<span style="font-weight: bold; font-size: 1.2rem; color: rgb(0, 0, 0);">Mission 2</span>
<button style="border: 2px solid rgb(0, 0, 0); margin-left: 1.2rem; color: rgb(0, 0, 0); padding: 3px 6px; font-size: 0.8rem;" type="button" @click="">
<router-link to="/2" class="router-link">
<span style="font-weight: bold; font-size: 0.8rem;">OPEN</span>
</router-link>
</button>
</div>
<div>
<span style="font-weight: bold; font-size: 1.2rem; color: rgb(0, 0, 0);">Status: {{ misson_two_status }}</span>
</div>
</div>
<div style="width: 12rem; height:4rem;border: 2px solid rgb(52, 49, 49); background-color: rgb(255, 255, 255); margin-left: auto; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;">
<div>
<span style="font-weight: bold; font-size: 1.2rem; color: rgb(0, 0, 0);">Mission 3</span>
<button style="border: 2px solid rgb(0, 0, 0); margin-left: 1.2rem; color: rgb(0, 0, 0); padding: 3px 6px; font-size: 0.8rem;" type="button" @click="">
<span style="font-weight: bold; font-size: 0.8rem;">OPEN</span>
</button>
</div>
<div>
<span style="font-weight: bold; font-size: 1.2rem; color: rgb(0, 0, 0);">Status: {{ misson_three_status }}</span>
</div>
</div>
<button style="border: 2px solid rgb(255, 0, 0); background-color: rgba(255, 0, 0); margin-left: auto; color: rgb(255, 255, 255);" type="button" @click="">
<span style="font-size: 18px;">STOP ALL</span>
</button>
<button style="border: 2px solid rgb(52, 49, 49); background-color: rgba(38, 36, 36, 0.25); margin-left: auto; color: rgb(52, 49, 49);" type="button" @click="toggleNavbar">
<span style="font-size: 18px;">&#9776;</span>
</button>
</div>
<div v-if="isNavbarOpen" style="margin-top: 10px;">
<ul style="list-style-type: none; padding-left: 0;">
<!-- Insert your menu items here -->
<li><a href="#" style="text-decoration: none;">Home</a></li>
<li><a href="#" style="text-decoration: none;">Link</a></li>
<li><router-link to="/test" style="text-decoration: none;">Disabled</router-link></li>
</ul>
</div>
</nav>
</template>

22
src/router/index.js Normal file
View File

@ -0,0 +1,22 @@
import { createRouter, createWebHashHistory } from "vue-router"
import fourCam from "../views/fourCam.vue";
import Cam1Focus from "../views/Cam1Focus.vue";
import Cam2Focus from "../views/Cam2Focus.vue";
import test from "../views/test.vue";
const routes = [
{ path: '/', component: fourCam },
{ path: '/1', component: Cam1Focus },
{ path: '/2', component: Cam2Focus },
{ path: '/test', component: test },
]
const router = createRouter({
// 4. Provide the history implementation to use. We
// are using the hash history for simplicity here.
history: createWebHashHistory(),
routes, // short for `routes: routes`
})
export default router

View File

@ -0,0 +1,31 @@
<script setup>
import Battery from './components/Battery.vue';
</script>
<template>
<h2>Below is the Connection component</h2>
<!-- <div class="bruh">
<Connection :latency=20 />
</div> -->
<h2>Below is the Battery component</h2>
<div class="border_div">
<Battery :percentage=10 :charging="false"/>
</div>
</template>
<style scoped>
.border_div {
/* display: flex; */
border: 0.4em solid black;
height: 200px;
width: 400px;
/* height: 100px;
width: 200px; */
}
</style>

20
src/views/Cam1Focus.vue Normal file
View File

@ -0,0 +1,20 @@
<script setup lang="ts">
import Camera from "../components/Camera.vue";
</script>
<template>
<div class="camera-container">
<Camera :cameraNumber="1" />
</div>
</template>
<style scoped>
.camera-container {
height: 90vh; /* Set the height of the container to 100% of the viewport height */
width: 75%;
display: flex; /* Use flexbox to align items vertically */
justify-content: center; /* Center the child element horizontally */
align-items: center; /* Center the child element vertically */
}
</style>

20
src/views/Cam2Focus.vue Normal file
View File

@ -0,0 +1,20 @@
<script setup lang="ts">
import Camera from "../components/Camera.vue";
</script>
<template>
<div class="camera-container">
<Camera :cameraNumber="2" />
</div>
</template>
<style scoped>
.camera-container {
height: 90vh; /* Set the height of the container to 100% of the viewport height */
width: 75%;
display: flex; /* Use flexbox to align items vertically */
justify-content: center; /* Center the child element horizontally */
align-items: center; /* Center the child element vertically */
}
</style>

21
src/views/fourCam.vue Normal file
View File

@ -0,0 +1,21 @@
<script setup lang="ts">
import Camera from "../components/Camera.vue";
</script>
<template>
<div class="grid">
<div>
<Camera :cameraNumber="1"/>
</div>
<div>
<Camera :cameraNumber="2"/>
</div>
<div>
<Camera :cameraNumber="2"/>
</div>
<div>
<Camera :cameraNumber="1"/>
</div>
</div>
</template>

14
src/views/test.vue Normal file
View File

@ -0,0 +1,14 @@
<script setup lang="ts">
</script>
<template>
<div class="grid">
<div>
<h1>
TESTESTES
</h1>
</div>
</div>
</template>