removed momentjs webjar

This commit is contained in:
Jake Potrebic 2020-09-25 21:36:37 -07:00 committed by MiniDigger
parent adb725ddb8
commit b9973a7cfc
9 changed files with 47 additions and 26 deletions

View File

@ -39,9 +39,7 @@
<!-- webjars dependencies -->
<webjars-locator.version>0.40</webjars-locator.version>
<jquery.version>3.5.1</jquery.version>
<moment.version>2.27.0</moment.version>
<chart.js.version>2.9.3</chart.js.version>
<swagger-ui.version>3.31.1</swagger-ui.version>
<!-- plugins -->
<frontend-maven-plugin.version>1.10.0</frontend-maven-plugin.version>
@ -193,11 +191,6 @@
<artifactId>jquery</artifactId>
<version>${jquery.version}</version>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>moment</artifactId>
<version>${moment.version}</version>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>chart.js</artifactId>

View File

@ -22,6 +22,7 @@
"highlight.js": "^10.2.0",
"jquery": "3.5.1",
"lodash": "4.17.20",
"moment": "^2.29.0",
"popper.js": "^1.16.1",
"query-string": "6.13.1",
"swagger-ui": "^3.34.0",

View File

@ -37,7 +37,7 @@ export default {
};
</script>
<style lang="scss">
@import '~swagger-ui/dist/swagger-ui.css';
@use '~swagger-ui/dist/swagger-ui';
html {
box-sizing: border-box;

View File

@ -1,9 +1,32 @@
import $ from 'jquery';
import moment from 'moment';
import { clearUnread, toggleSpinner } from '@/utils';
//=====> EXTERNAL CONSTANTS
const MAX_REVIEW_TIME = window.MAX_REVIEW_TIME;
//=====> DOCUMENT READY
$(function() {
var momentNow = moment();
var maxDifference = MAX_REVIEW_TIME;
$('span[data-ago]').each(function() {
var momentAgo = moment($(this).data('ago'));
$(this).text($(this).data('title') + momentAgo.fromNow());
if (momentNow.diff(momentAgo) >= maxDifference) {
$(this)
.text('pastdue ' + momentAgo.fromNow())
.css('color', 'darkred');
$(this)
.parent()
.parent()
.find('.status')
.removeClass()
.addClass('status far fa-fw fa-clock fa-2x')
.css('color', 'darkred');
}
});
$('.btn-approve').click(function() {
var listItem = $(this).closest('.list-group-item');
var versionPath = listItem.data('version');

View File

@ -6492,6 +6492,11 @@ mkdirp@^0.5.1, mkdirp@^0.5.3, mkdirp@^0.5.5, mkdirp@~0.5.1:
dependencies:
minimist "^1.2.5"
moment@^2.29.0:
version "2.29.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.0.tgz#fcbef955844d91deb55438613ddcec56e86a3425"
integrity sha512-z6IJ5HXYiuxvFTI6eiQ9dm77uE0gyy1yXNApVHqTcnIKfY9tIwEjlzsZ6u1LQXvVgKeTnv9Xm7NDvJ7lso3MtA==
move-concurrently@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92"

View File

@ -9,6 +9,7 @@ import io.papermc.hangar.security.voters.ProjectPermissionVoter;
import io.papermc.hangar.security.voters.UserLockVoter;
import io.papermc.hangar.service.PermissionService;
import io.papermc.hangar.service.UserService;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -31,6 +32,9 @@ import java.util.List;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
private static final String CSP = "script-src 'self'{nonce}";
public String CSP_NONCE;
private final HangarAuthenticationProvider authProvider;
private final PermissionService permissionService;
private final UserService userService;
@ -44,6 +48,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
CSP_NONCE = RandomStringUtils.randomAlphanumeric(64);
// TODO CSP nonce
// http.headers().contentSecurityPolicy(CSP.replace("{nonce}", " 'nonce-" + CSP_NONCE + "'"));
http.csrf().ignoringAntMatchers(
"/api/v2/authenticate", "/api/v2/sessions/current", "/api/v2/keys", "/api/sync_sso"
);

View File

@ -3,16 +3,18 @@ package io.papermc.hangar.config.hangar;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.time.Duration;
@Component
@ConfigurationProperties(prefix = "hangar.queue")
public class QueueConfig {
private String maxReviewTime = "1d";
private Duration maxReviewTime = Duration.ofDays(1);
public String getMaxReviewTime() {
public Duration getMaxReviewTime() {
return maxReviewTime;
}
public void setMaxReviewTime(String maxReviewTime) {
public void setMaxReviewTime(Duration maxReviewTime) {
this.maxReviewTime = maxReviewTime;
}
}

View File

@ -115,7 +115,6 @@ showFooter: Boolean = true, noContainer: Boolean = false, additionalMeta: Html =
<script type="text/javascript" src="<@hangar.url "js/chunk-vendors.js" />"></script>
<script type="text/javascript" src="<@hangar.url "js/font-awesome.js" />"></script>
<script type="text/javascript" src="<@hangar.url "js/chunk-common.js" />"></script>
<script type="text/javascript" src="<@hangar.url "lib/moment/min/moment.min.js" />"></script> <#-- TODO this to go away -->
<script type="text/javascript" src="<@hangar.url "js/bootstrap.js" />"></script>
<script type="text/javascript" src="<@hangar.url "js/main.js" />"></script>
${additionalScripts}

View File

@ -3,21 +3,10 @@
<#import "*/layout/base.ftlh" as base />
<#assign scriptsVar>
<script <#--@CSPNonce.attr--> type="text/javascript" src="<@hangar.url "js/queue.js" />"></script>
<script <#--@CSPNonce.attr-->>
$(function(){
var momentNow = moment();
var maxDifference = "${config.queue.maxReviewTime}";
$('span[data-ago]').each(function() {
var momentAgo = moment($(this).data('ago'))
$(this).text($(this).data('title') + momentAgo.fromNow());
if (momentNow.diff(momentAgo) >= maxDifference) {
$(this).text('pastdue ' + momentAgo.fromNow()).css('color', 'darkred');
$(this).parent().parent().find('.status').removeClass().addClass('status far fa-fw fa-clock fa-2x').css('color', 'darkred');
}
});
});
<script>
window.MAX_REVIEW_TIME = ${config.queue.maxReviewTime.toMillis()};
</script>
<script type="text/javascript" src="<@hangar.url "js/queue.js" />"></script>
</#assign>
<#assign message><@spring.message "user.queue" /></#assign>