-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1107 from solaris-games/dev
Update 243
- Loading branch information
Showing
83 changed files
with
1,336 additions
and
752 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import BaseApiService from "./base"; | ||
import axios from "axios"; | ||
|
||
class AnnouncementsService extends BaseApiService { | ||
getCurrentAnnouncements () { | ||
return axios.get(`${this.BASE_URL}announcements/`, { withCredentials: true }); | ||
} | ||
|
||
getLatestAnnouncement () { | ||
return axios.get(`${this.BASE_URL}announcements/latest/`, { withCredentials: true }); | ||
} | ||
|
||
getAnnouncementState () { | ||
return axios.get(`${this.BASE_URL}announcements/state/`, { withCredentials: true }); | ||
} | ||
|
||
markAsRead () { | ||
return axios.patch(`${this.BASE_URL}announcements/state/markAsRead/`, {}, { withCredentials: true }); | ||
} | ||
} | ||
|
||
export default new AnnouncementsService(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,43 @@ | ||
import axios from 'axios' | ||
import router from '../../router' | ||
import axios from 'axios'; | ||
import { v7 as generateV7Uuid } from 'uuid'; | ||
import router from '../../router'; | ||
|
||
class BaseApiService { | ||
constructor () { | ||
this.BASE_URL = process.env.VUE_APP_API_HOST + '/api/' | ||
|
||
axios.interceptors.request.use(config => { | ||
config.headers['Idempotency-Key'] = this.buildIdempotencyKey(); | ||
|
||
return config; | ||
}, | ||
error => { | ||
return Promise.reject(error); | ||
}, { synchronous: true, runWhen: this.isUnsafeMethod }); | ||
|
||
axios.interceptors.response.use( | ||
response => { | ||
return response | ||
}, error => { | ||
console.log(error); | ||
// If any Unauthorized responses come back, redirect to login page. | ||
if (error.response.status === 401) { | ||
if (error.response?.status === 401) { | ||
router.push({ name: 'home' }) | ||
} | ||
|
||
return Promise.reject({ ...error }) | ||
}) | ||
} | ||
|
||
isUnsafeMethod(config) { | ||
// Rather than just going for idempotent methods, ie the safe ones and put and delete, | ||
// We are electing here to NOT trust that put or delete currently behave in an idempotent way on the server... | ||
return !['get', 'head', 'options', 'trace'].includes(config.method); | ||
} | ||
|
||
buildIdempotencyKey() { | ||
return `${generateV7Uuid()}`; | ||
} | ||
} | ||
|
||
export default BaseApiService |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { marked } from 'marked'; | ||
|
||
marked.use({ | ||
gfm: true, | ||
}); | ||
|
||
export const renderMarkdown = (markdown) => { | ||
return marked.parse(markdown); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<template> | ||
<view-container :hideTopBar="true"> | ||
<view-title | ||
title="Announcements" | ||
:showSocialLinks="true" | ||
/> | ||
|
||
<loading-spinner v-if="!announcementState || !announcements" /> | ||
|
||
<div v-else> | ||
<p> | ||
<a href="https://discord.com/invite/v7PD33d" target="_blank" title="Discord" style="text-decoration: none;"> | ||
Join the Discord | ||
</a>to stay up-to-date, discuss the game and chat with the community! | ||
</p> | ||
|
||
<announcement | ||
v-for="announcement in announcements" | ||
:key="announcement._id" | ||
:announcement="announcement" | ||
:highlighted="isUnread(announcement)" | ||
/> | ||
</div> | ||
</view-container> | ||
</template> | ||
|
||
<script> | ||
import ViewContainer from "./components/ViewContainer.vue"; | ||
import ViewTitle from "./components/ViewTitle.vue"; | ||
import LoadingSpinner from "./components/LoadingSpinner.vue"; | ||
import Announcement from "./components/Announcement.vue"; | ||
import AnnouncementsApiService from "../services/api/announcements"; | ||
export default { | ||
name: "Announcements", | ||
components: { | ||
'view-container': ViewContainer, | ||
'view-title': ViewTitle, | ||
'loading-spinner': LoadingSpinner, | ||
'announcement': Announcement | ||
}, | ||
data() { | ||
return { | ||
announcements: null, | ||
announcementState: null | ||
} | ||
}, | ||
async mounted () { | ||
const resp1 = await AnnouncementsApiService.getAnnouncementState(); | ||
if (resp1.status === 200) { | ||
this.announcementState = resp1.data; | ||
const resp2 = await AnnouncementsApiService.getCurrentAnnouncements(); | ||
if (resp2.status === 200) { | ||
this.announcements = resp2.data; | ||
await AnnouncementsApiService.markAsRead(); | ||
} else { | ||
console.error(resp2); | ||
} | ||
} else { | ||
console.error(resp1); | ||
} | ||
}, | ||
methods: { | ||
isUnread (announcement) { | ||
if (!announcement || !this.announcementState) { | ||
return false; | ||
} | ||
return this.announcementState.unreadAnnouncements.includes(announcement._id); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.