Skip to content

Commit

Permalink
Merge pull request #155 from catenax-ng/release/v2.0.0-qr-code-scanner
Browse files Browse the repository at this point in the history
[2°] - Release/v2.0.0 qr code scanner: Fixes some issus regarding a qr code scanner
  • Loading branch information
saudkhan116 authored Dec 22, 2023
2 parents c799856 + dd47ab1 commit 8274105
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 80 deletions.
17 changes: 9 additions & 8 deletions src/assets/styles/components/general/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* SPDX-License-Identifier: Apache-2.0
*/


.footer-content {
position: absolute;
bottom: 0;
Expand Down Expand Up @@ -80,8 +79,10 @@
}
}

@media (max-width: 893px) {
@media (max-width: 1020px) {
.footer-content {
position: relative;
margin: 0;
flex-direction: column;
align-items: center;

Expand All @@ -91,12 +92,12 @@
}
}
}
@media (max-width: 900px) {
.footer-content {
position: relative;
margin:0;
}
}
// @media (max-width: 900px) {
// .footer-content {
// position: relative;
// margin: 0;
// }
// }
@media (max-width: 585px) {
.footer-content {
flex-direction: column;
Expand Down
26 changes: 22 additions & 4 deletions src/assets/styles/components/landing/searchView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
.error {
font-weight: bold;
text-align: center;
padding: 0 0 70px 0;
padding: 0 0 18px 0;
}

.qr-container {
Expand Down Expand Up @@ -441,6 +441,26 @@
.stream-container {
margin-top: 15px;
margin-bottom: 30px;
width: 300px;
height: 300px;
}
}
}

@media (max-height: 650px) {
.home-page-container {
.stream-container {
width: 250px;
height: 250px;
}
}
}

@media (max-height: 590px) {
.home-page-container {
.stream-container {
width: 200px;
height: 200px;
}
}
}
Expand All @@ -455,10 +475,8 @@
}

.stream-container {
margin-top: 15px;
margin-top: 5px;
margin-bottom: 30px;
width: 200px;
height: 200px;
}
.logotype-container {
img {
Expand Down
93 changes: 93 additions & 0 deletions src/components/general/QrcodeStrem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<!--
Catena-X - Product Passport Consumer Frontend

Copyright (c) 2022, 2023 BASF SE, BMW AG, Henkel AG & Co. KGaA

See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.

This program and the accompanying materials are made available under the
terms of the Apache License, Version 2.0 which is available at
https://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the
License for the specific language govern in permissions and limitations
under the License.

SPDX-License-Identifier: Apache-2.0
-->

<template>
<qrcode-stream
class="qrcode-stream"
@init="onInit"
@decode="onDecode"
:camera="facingMode"
>
</qrcode-stream>
</template>

<script>
import { QrcodeStream } from "vue3-qrcode-reader";
import store from "@/store/index";

export default {
name: "QRcodeStream",
components: {
QrcodeStream,
},
data() {
return {
error: "",
decodedString: "",
};
},
props: {
facingMode: {
type: String,
default: "front",
},
},
methods: {
async onInit(promise) {
try {
await promise;
} catch (error) {
store.commit("setQrError", error);
if (error.name === "NotAllowedError") {
this.error = "ERROR: you need to grant camera access permission";
} else if (error.name === "NotFoundError") {
this.error = "ERROR: no camera on this device";
} else if (error.name === "NotSupportedError") {
this.error = "ERROR: secure context required (HTTPS, localhost)";
} else if (error.name === "NotReadableError") {
this.error = "ERROR: is the camera already in use?";
} else if (error.name === "OverconstrainedError") {
this.error = "ERROR: installed cameras are not suitable";
} else if (error.name === "StreamApiNotSupportedError") {
this.error = "ERROR: Stream API is not supported in this browser";
} else if (error.name === "InsecureContextError") {
this.error =
"ERROR: Camera access is only permitted in secure context. Use HTTPS or localhost rather than HTTP.";
} else {
this.error = `ERROR: Camera error (${error.name})`;
}
}
},
onDecode(decodedString) {
this.decodedString = decodedString;
this.$router.push({
path: `/${this.processDecodedString(decodedString)}`,
});
},
processDecodedString(decodedString) {
const match = /CX:.*$/.exec(decodedString);
// This regex looks for a match "CX:" and returns it + everything to the right
return match ? match[0] : decodedString;
},
},
};
</script>
9 changes: 8 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export default createStore({
],
processId: null,
searchContractId: null,
irsState: false
irsState: false,
qrError: ""
},
getters: {
getClientId(state) {
Expand All @@ -78,6 +79,9 @@ export default createStore({
getIrsState(state) {
return state.irsState;
},
getQrError(state) {
return state.qrError;
},
},
mutations: {
setEmail(state, newEmail) {
Expand Down Expand Up @@ -112,6 +116,9 @@ export default createStore({
},
setProcessId(state, processId) {
state.processId = processId;
},
setQrError(state, qrError) {
state.qrError = qrError;
}
},
actions: {},
Expand Down
Loading

0 comments on commit 8274105

Please sign in to comment.