mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-01-18 14:14:50 +08:00
minor stuff
Signed-off-by: MiniDigger <admin@minidigger.me>
This commit is contained in:
parent
add4d0265b
commit
7b41a49dd1
@ -305,6 +305,8 @@ const msgs: LocaleMessageObject = {
|
||||
discuss: {
|
||||
login: 'Log in',
|
||||
toReply: 'to reply to this discussion',
|
||||
noTopic: 'There is no discussion for this project',
|
||||
send: 'Reply posted!',
|
||||
},
|
||||
},
|
||||
page: {
|
||||
|
@ -1,21 +1,28 @@
|
||||
<template>
|
||||
<div>
|
||||
<div id="discourse-comments">
|
||||
<iframe
|
||||
id="discourse-embed-frame"
|
||||
ref="iframe"
|
||||
:src="url"
|
||||
referrerpolicy="no-referrer-when-downgrade"
|
||||
sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"
|
||||
></iframe>
|
||||
</div>
|
||||
<div v-if="isLoggedIn">
|
||||
<MarkdownEditor ref="editor" saveable editing :cancellable="false" :deletable="false" @save="postReply"></MarkdownEditor>
|
||||
</div>
|
||||
<div v-else>
|
||||
<a @click="$auth.login($route.fullPath)">{{ $t('project.discuss.login') }}</a>
|
||||
{{ $t('project.discuss.toReply') }}
|
||||
</div>
|
||||
<template v-if="project.topicId">
|
||||
<div id="discourse-comments">
|
||||
<iframe
|
||||
id="discourse-embed-frame"
|
||||
ref="iframe"
|
||||
:src="url"
|
||||
referrerpolicy="no-referrer-when-downgrade"
|
||||
sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"
|
||||
></iframe>
|
||||
</div>
|
||||
<div v-if="isLoggedIn">
|
||||
<MarkdownEditor ref="editor" saveable editing :cancellable="false" :deletable="false" @save="postReply"></MarkdownEditor>
|
||||
</div>
|
||||
<div v-else>
|
||||
<a @click="$auth.login($route.fullPath)">{{ $t('project.discuss.login') }}</a>
|
||||
{{ $t('project.discuss.toReply') }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<v-alert type="info">
|
||||
{{ $t('project.discuss.noTopic') }}
|
||||
</v-alert>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -36,8 +43,13 @@ interface DiscourseEmbed {
|
||||
components: { MarkdownEditor },
|
||||
})
|
||||
export default class ProjectDiscussPage extends HangarProjectMixin {
|
||||
// TODO get topic id from project, get discourse url from backend
|
||||
DE: DiscourseEmbed = { discourseUrl: 'http://localhost/', topicId: 13, discourseUserName: null, discourseEmbedUrl: null };
|
||||
// TODO get discourse url from backend
|
||||
DE: DiscourseEmbed = {
|
||||
discourseUrl: 'http://localhost/',
|
||||
topicId: this.project.topicId,
|
||||
discourseUserName: null,
|
||||
discourseEmbedUrl: null,
|
||||
};
|
||||
|
||||
$refs!: {
|
||||
iframe: any;
|
||||
@ -48,12 +60,12 @@ export default class ProjectDiscussPage extends HangarProjectMixin {
|
||||
window.addEventListener('message', this.postMessageReceived, false);
|
||||
}
|
||||
|
||||
// TODO implement
|
||||
async postReply(message: string) {
|
||||
await this.$api.requestInternal('discourse/' + this.project.id + '/comment', true, 'POST', { content: message });
|
||||
this.$refs.editor.isEditing = true;
|
||||
this.$refs.editor.loading.save = false;
|
||||
this.$refs.editor.rawEdited = '';
|
||||
this.$util.success(this.$t('project.discuss.send'));
|
||||
}
|
||||
|
||||
get url() {
|
||||
|
@ -64,8 +64,8 @@
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-list>
|
||||
<!--todo route for user action log-->
|
||||
<v-list-item v-if="$perms.canViewLogs" nuxt :to="`ddd`">
|
||||
<!--todo route for user action log, with filtering-->
|
||||
<v-list-item v-if="$perms.canViewLogs" nuxt :to="`/admin/log`">
|
||||
<v-list-item-title>
|
||||
{{ $t('version.page.userAdminLogs') }}
|
||||
</v-list-item-title>
|
||||
|
2
frontend/types/api/projects.d.ts
vendored
2
frontend/types/api/projects.d.ts
vendored
@ -68,6 +68,8 @@ declare module 'hangar-api' {
|
||||
lastUpdated: Date;
|
||||
userActions: UserActions;
|
||||
settings: ProjectSettings;
|
||||
postId: number;
|
||||
topicId: number;
|
||||
promotedVersions: PromotedVersion[];
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,10 @@ public class LoginController extends HangarComponent {
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public void invalidateRefreshToken(@CookieValue(name = SecurityConfig.AUTH_NAME_REFRESH_COOKIE) String refreshToken) {
|
||||
tokenService.invalidateToken(refreshToken);
|
||||
HttpSession session = request.getSession(false);
|
||||
if (session != null) {
|
||||
session.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO needed?
|
||||
@ -95,13 +99,6 @@ public class LoginController extends HangarComponent {
|
||||
return redirectToSso(ssoService.getVerifyUrl(config.getBaseUrl() + returnPath));
|
||||
}
|
||||
|
||||
// TODO needed?
|
||||
@GetMapping("/logout")
|
||||
public ModelAndView logout(HttpSession session) {
|
||||
session.invalidate();
|
||||
return Routes.getRedirectToUrl(config.getAuthUrl() + "/accounts/logout/");
|
||||
}
|
||||
|
||||
@GetMapping("/signup")
|
||||
public RedirectView signUp(@RequestParam(defaultValue = "") String returnUrl) {
|
||||
if (config.fakeUser.isEnabled()) {
|
||||
|
@ -29,12 +29,10 @@ public interface HangarUsersDAO {
|
||||
|
||||
@SqlUpdate("DELETE FROM project_stars WHERE user_id = :userId AND project_id = :projectId")
|
||||
void setNotStarred(long projectId, long userId);
|
||||
// TODO useful to have a un-star all for users
|
||||
|
||||
@SqlUpdate("INSERT INTO project_watchers VALUES (:projectId, :userId)")
|
||||
void setWatching(long projectId, long userId);
|
||||
|
||||
@SqlUpdate("DELETE FROM project_watchers WHERE project_id = :projectId AND user_id = :userId")
|
||||
void setNotWatching(long projectId, long userId);
|
||||
// TODO useful to have an un-watch all for users
|
||||
}
|
||||
|
@ -94,6 +94,8 @@ public interface ProjectsApiDAO {
|
||||
" p.license_url," +
|
||||
" p.keywords," +
|
||||
" p.forum_sync," +
|
||||
" p.topic_id," +
|
||||
" p.post_id," +
|
||||
" p.donation_enabled," +
|
||||
" p.donation_email," +
|
||||
" p.donation_default_amount," +
|
||||
|
@ -45,7 +45,6 @@ public class MultiHangarApiException extends ResponseStatusException {
|
||||
gen.writeBooleanField("isHangarApiException", true);
|
||||
gen.writeArrayFieldStart("exceptions");
|
||||
for (HangarApiException exception : value.exceptions) {
|
||||
// TODO for some reason, can't use serializers.defaultSerializeValue
|
||||
String message = exception.getReason();
|
||||
if (message == null || message.isBlank()) {
|
||||
message = exception.getStatus().getReasonPhrase();
|
||||
|
@ -62,15 +62,15 @@ public class ProjectsApiService extends HangarComponent {
|
||||
relevance = "ts_rank(hp.search_words, websearch_to_tsquery('english', :query)) DESC";
|
||||
}
|
||||
String orderingFirstHalf;
|
||||
// 1483056000 is the Ore epoch TODO change to hangar epoch
|
||||
// 1609459200 is the hangar epoch
|
||||
// 86400 seconds to days
|
||||
// 604800 seconds to weeks
|
||||
switch(sort){
|
||||
case STARS: orderingFirstHalf = "hp.stars * "; break;
|
||||
case DOWNLOADS: orderingFirstHalf ="(hp.downloads / 100) * "; break;
|
||||
case VIEWS: orderingFirstHalf ="(hp.views / 200) *"; break;
|
||||
case NEWEST: orderingFirstHalf ="((EXTRACT(EPOCH FROM hp.created_at) - 1483056000) / 86400) *"; break;
|
||||
case UPDATED: orderingFirstHalf ="((EXTRACT(EPOCH FROM hp.last_updated) - 1483056000) / 604800) *"; break;
|
||||
case NEWEST: orderingFirstHalf ="((EXTRACT(EPOCH FROM hp.created_at) - 1609459200) / 86400) *"; break;
|
||||
case UPDATED: orderingFirstHalf ="((EXTRACT(EPOCH FROM hp.last_updated) - 1609459200) / 604800) *"; break;
|
||||
case ONLY_RELEVANCE: orderingFirstHalf = ""; break;
|
||||
case RECENT_DOWNLOADS : orderingFirstHalf ="hp.recent_views *"; break;
|
||||
case RECENT_VIEWS: orderingFirstHalf ="hp.recent_downloads *"; break;
|
||||
|
Loading…
Reference in New Issue
Block a user