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

Route #13

Merged
merged 12 commits into from
Sep 27, 2024
39 changes: 31 additions & 8 deletions 40-create-ghcred.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
#/bin/sh
# create nginx config from evironment
# *prevent envsubst from killing nginx vars with 'tr' and '@'*
cat <<EOT | envsubst | tr '@' '$' >/GH_OAUTH_CLIENT.conf
set @CLIENT_ID $CLIENT_ID;
set @CLIENT_SECRET $CLIENT_SECRET;
set @CALL_BACK $CALL_BACK
EOT
#!/bin/sh

# Set default value for VUE_APP_PUBLIC_PATH if not provided
# Get VUE_APP_PUBLIC_PATH from Docker endpoint

# Copy files with the specified public path
#cp -r /usr/app/dist /usr/share/nginx/html/$VUE_APP_PUBLIC_PATH

# Remove leading and trailing whitespace and slashes

VUE_APP_PUBLIC_PATH=$(echo $VUE_APP_PUBLIC_PATH | xargs | sed 's/^\///;s/\/$//')



# Add leading slash only if string is not empty
if [ "$VUE_APP_PUBLIC_PATH" != "/" ] && [ "$VUE_APP_PUBLIC_PATH" != "" ]; then
VUE_APP_PUBLIC_PATH=/$VUE_APP_PUBLIC_PATH
fi


ln -s /usr/share/nginx/html /usr/share/nginx/html/"$VUE_APP_PUBLIC_PATH"
sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/index.html
sed -i "s+/myAppPlaceholder+$VUE_APP_PUBLIC_PATH+g" /usr/share/nginx/html/js/app.*.js

# Create nginx config from environment variables
# # *prevent envsubst from killing nginx vars with 'tr' and '@'*
# cat <<EOT | envsubst | tr '@' '$' >/GH_OAUTH_CLIENT.conf
# set @CLIENT_ID $CLIENT_ID;
# set @CLIENT_SECRET $CLIENT_SECRET;
# set @CALL_BACK $CALL_BACK;
# EOT
10 changes: 4 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
FROM node:latest as builder
ARG VUE_APP_PUBLIC_PATH=""
ENV VUE_APP_PUBLIC_PATH=$VUE_APP_PUBLIC_PATH

WORKDIR /usr/app
COPY . .
# RUN echo "VUE_APP_CLIENT_ID=$CLIENT_ID" >.env.development.local
Expand All @@ -10,9 +9,8 @@ RUN npm install --legacy-peer-deps --force && npm run build


FROM nginx:alpine
ARG VUE_APP_PUBLIC_PATH=""
ENV VUE_APP_PUBLIC_PATH=$VUE_APP_PUBLIC_PATH
ENV VUE_APP_PUBLIC_PATH="/"
WORKDIR /etc/nginx
COPY 40-create-ghcred.sh /docker-entrypoint.d
COPY ngnix.conf /etc/nginx/nginx.d/default.conf
COPY --from=builder /usr/app/dist/ /usr/share/nginx/html/${VUE_APP_PUBLIC_PATH}
COPY ngnix.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /usr/app/dist/ /usr/share/nginx/html
23 changes: 2 additions & 21 deletions ngnix.conf
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
server {
listen 80;

# declare token is "" (empty str) for original request without args,because $is_args concat any var will be `?`
set $token "";
# if the request has args update token to "&"
# request without args doesn't make sense in this case
if ($is_args) {
set $token "&";
}
# file created on container start from env vars (40-create-ghcred.sh)
include "/GH_OAUTH_CLIENT.conf";
# reverse proxy to github access_token
# set rule to /auth explicitly
location = /auth {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need the GitHub authentication?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing changed here in 2e41245?!

set $args "${args}${token}client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}";
proxy_pass https://github.com/login/oauth/access_token$is_args$args;
proxy_set_header accept "application/json";
}

# Serve Vue.js application from VUE_APP_PUBLIC_PATH
# Serve Vue.js application from VUE_APP_PUBLIC_PATH

# default rule to access app
location / {
Expand All @@ -27,8 +11,5 @@ server {
try_files $uri $uri/ /index.html;
}
# Redirect requests without trailing slash to include it
location ~ ^(.*)/$ {
return 301 $1;
}

}
s
15 changes: 14 additions & 1 deletion src/components/OsdComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,31 @@ export default {
// The users has selected an existing annotation
// console.log('selected annotation')
// console.log(annotation)
console.log("anno is clicked")
console.log("anno is clicked " , annotation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are the changes to this file relevant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more or less the same as above: the changes here are irrelevant(?) for the PR, so please remove them.
In 2e41245 you only removed one change but not the all


})

this.anno.on('createAnnotation', (annotation) => {


// const { x, y, width, height } = annotation.shapes[0].geometry;

// Update the x and y coordinates of the rectangle
// const newX = x + width; // Example: Move the rectangle to the right of the selected area
// const newY = y + height; // Example: Move the rectangle below the selected area
console.log("this is x ", annotation)
// console.log("this is y " + newX)
// The users has created a new annotation
const newId = 'z' + uuid()
annotation.id = newId
this.$store.dispatch('createZone', annotation)
this.$store.dispatch('selectZone', null)
this.anno.clearAnnotations()
this.renderZones()
console.log("anno is clicked ", annotation.target.selector)



})

this.anno.on('updateAnnotation', (annotation) => {
Expand Down
2 changes: 1 addition & 1 deletion src/public-path.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/* global __webpack_public_path__:writable */
/* exported __webpack_public_path__ */
__webpack_public_path__ = window.PUBLIC_PATH,process.env.PUBLIC_PATH;
//__webpack_public_path__ = '/myapp';
21 changes: 11 additions & 10 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1096,16 +1096,17 @@ export default createStore({
},
pages: state => {
const arr = []
state.pages.forEach(page => {
const obj = {
tileSource: page.uri,
width: page.width,
x: 0,
y: 0
}
arr.push(obj)
})
return arr
state.pages.forEach(page => {
const obj = {
tileSource: page.uri,
width: page.width,
height: page.height ,
x: 0,
y: 0
}
arr.push(obj)
})
return arr
},
pagesDetailed: state => {
const arr = []
Expand Down
6 changes: 2 additions & 4 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? process.env.VUE_APP_PUBLIC_PATH
: '/'
}
publicPath: "/myAppPlaceholder"
}