Skip to content

Commit

Permalink
Add a share code proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
LucHeart committed Sep 23, 2023
1 parent 0c498c0 commit d93affb
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/globals/config/config.development.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
apiUrl: "https://dev-api.shocklink.net/",
webUiUrl: "https://dev.shocklink.net/#/",
shortUrl: "https://shockl.ink/s/"
shortUrl: "https://shockl.ink/",
}

global.config = config;
2 changes: 1 addition & 1 deletion src/globals/config/config.local.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
apiUrl: "https://localhost/",
webUiUrl: "https://localhost:8080/#/",
shortUrl: "https://shockl.ink/s/"
shortUrl: "https://shockl.ink/"
}

global.config = config;
2 changes: 1 addition & 1 deletion src/globals/config/config.production.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
apiUrl: "https://api.shocklink.net/",
webUiUrl: "https://shocklink.net/#/",
shortUrl: "https://shockl.ink/s/"
shortUrl: "https://shockl.ink/"
}

global.config = config;
5 changes: 5 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ const routes = [
component: lazyLoad('public/proxy/ShareLinksProxy'),
props: true
},
{
path: 'proxy/shares/code/:id',
component: lazyLoad('public/proxy/ShareCodeProxy'),
props: true
},
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/views/dashboard/shares/links/ShareLinksRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default {
},
methods: {
copyUrl(id) {
navigator.clipboard.writeText(config.shortUrl + id);
navigator.clipboard.writeText(config.shortUrl + "s/" + id);
toastr.success('Share Link copied to clipboard');
},
async loadShareLinks() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/dashboard/shares/links/ViewShareLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default {
return '/proxy/shares/links/' + this.id;
},
shareLinkUrl() {
return config.shortUrl + this.id;
return config.shortUrl + "s/" + this.id;
},
existingShockerIds() {
var arr = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export default {
}
this.loadCodes();
this.$swal('Successfully created share code!', `Code: ${res.data.data}`, 'success');
this.$swal('Successfully created share code!', `Link: ${config.shortUrl}c/${res.data.data}<br><br>Code: ${res.data.data}`, 'success');
}
}
}
Expand Down
60 changes: 60 additions & 0 deletions src/views/public/proxy/ShareCodeProxy.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<template>
<div class="proxy-container">
<transition mode="out-in" name="component-fade">
<checkmark v-if="!loading && error" error="true"></checkmark>
<loading-with-text v-else-if="loading">Checking login status...</loading-with-text>
<loading-with-text v-else>Redirecting...</loading-with-text>
</transition>
</div>
</template>

<script>
import Checkmark from '../../utils/Checkmark.vue';
import LoadingWithText from '../../utils/LoadingWithText.vue';
export default {
components: { LoadingWithText, Checkmark },
props: ['id'],
data() {
return {
loading: true,
error: true
}
},
async beforeMount() {
this.loading = true;
var loggedIn = await utils.checkIfLoggedIn();
this.loading = false;
if (!loggedIn) {
this.login();
return;
}
try {
const res = await apiCall.makeCall('POST', `1/shares/code/${this.id}`);
if (res.status !== 200) {
throw new Error(res.statusText);
}
toastr.success(`Failed to add share: ${utils.getError(err)}`);
} catch (err) {
this.error = true;
toastr.error(`Failed to add share: ${utils.getError(err)}`);
return;
}
this.redirectToShares();
},
methods: {
redirectToShares() {
this.$router.push("/dashboard/shockers/shared");
},
login() {
this.$store.dispatch('setReturnUrl', "/proxy/shares/code/" + this.id);
this.$router.push("/account/login");
}
}
}
</script>

<style scoped lang="scss"></style>

0 comments on commit d93affb

Please sign in to comment.