removed chart.js webjar

This commit is contained in:
Jake Potrebic 2020-09-25 22:06:22 -07:00 committed by MiniDigger
parent b9973a7cfc
commit 223da5e2bb
13 changed files with 154 additions and 113 deletions

View File

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

View File

@ -15,6 +15,7 @@
"@fortawesome/free-solid-svg-icons": "5.14.0",
"axios": "^0.20.0",
"bootstrap": "^4.5.2",
"chart.js": "^2.9.3",
"clipboard": "^2.0.6",
"core-js": "^3.6.5",
"diff-match-patch": "^1.0.5",

View File

@ -87,6 +87,7 @@
<script>
import fileSize from 'filesize';
import moment from 'moment';
import Tag from './components/Tag';
import Pagination from './components/Pagination';
@ -139,7 +140,7 @@ export default {
return fileSize(size);
},
formatDate(date) {
return window.moment(date).format('MMM D, YYYY');
return moment(date).format('MMM D, YYYY');
},
classForVisibility(visibility) {
return Visibility.fromName(visibility).class;

View File

@ -177,7 +177,6 @@ function initColorPicker() {
}
//=====> DOCUMENT READY
$(function() {
initModal();
if (window.initChannelManager) {

View File

@ -4,11 +4,13 @@ import { decodeHtml, numberWithCommas, toggleSpinner } from '@/utils';
//=====> EXTERNAL CONSTANTS
const PROJECT_OWNER = PROJECT_OWNER;
const PROJECT_SLUG = PROJECT_SLUG;
const PROJECT_ID = PROJECT_ID;
const PROJECT_OWNER = window.PROJECT_OWNER;
const PROJECT_SLUG = window.PROJECT_SLUG;
const PROJECT_ID = window.PROJECT_ID;
const ALREADY_STARRED = window.ALREADY_STARRED;
const ACTIVE_NAV = window.ACTIVE_NAV;
//=====> HELPER FUNCTIONS
function initFlagList() {
@ -202,6 +204,11 @@ function initBtnEdit() {
}
//=====> DOCUMENT READY
if (ACTIVE_NAV) {
$('.nav')
.find(ACTIVE_NAV)
.addClass('active');
}
$(function() {
initFlagList();

View File

@ -39,4 +39,15 @@ $(function() {
name.val(text);
}
});
// Basically, hides the form value if its empty. Makes the controller simpler
$('#save').submit(function() {
$(':input[form=save]')
.filter(function() {
return !this.value;
})
.attr('disabled', true);
return true;
});
});

View File

@ -1,9 +1,101 @@
import $ from 'jquery';
import { go } from '@/utils';
import Chart from 'chart.js';
//=====> DOCUMENT READY
$(function() {
const TIME_FRAME = window.DAYS;
var domChartReview = document.getElementById('chart-reviews');
var chartReviews = new Chart(domChartReview, {
responsive: true,
type: 'line',
data: {
labels: TIME_FRAME,
datasets: [
{
label: 'Reviews',
backgroundColor: 'cornflowerblue',
borderColor: 'dodgerblue',
fill: false,
data: window.REVIEW_DATA
},
{
label: 'Uploads',
backgroundColor: 'lightseagreen',
borderColor: 'darkseagreen',
fill: false,
data: window.UPLOAD_DATA
}
]
},
options: {
title: {
text: 'Reviews'
}
}
});
var domChartDownload = document.getElementById('chart-downloads');
var chartDownloads = new Chart(domChartDownload, {
responsive: true,
type: 'line',
data: {
labels: TIME_FRAME,
datasets: [
{
label: 'Total Downloads',
backgroundColor: 'cornflowerblue',
borderColor: 'dodgerblue',
fill: false,
data: window.TOTAL_DOWNLOAD_DATA
},
{
label: 'Unsafe Downloads',
backgroundColor: 'lightseagreen',
borderColor: 'darkseagreen',
fill: false,
data: window.UNSAFE_DOWNLOAD_DATA
}
]
},
options: {
title: {
text: 'Downloads'
}
}
});
var domChartFlags = document.getElementById('chart-flags');
var chartFlags = new Chart(domChartFlags, {
responsive: true,
type: 'line',
data: {
labels: TIME_FRAME,
datasets: [
{
label: 'Opened flags', // 'Open flags' is a bit of a misleading name
backgroundColor: 'cornflowerblue',
borderColor: 'dodgerblue',
fill: false,
data: window.OPEN_FLAGS_DATA
},
{
label: 'Closed flags',
backgroundColor: 'lightseagreen',
borderColor: 'darkseagreen',
fill: false,
data: window.CLOSED_FLAGS_DATA
}
]
},
options: {
title: {
text: 'Flags'
}
}
});
$('#dateGoButton').click(function() {
var from = $('#fromDate').val();
var to = $('#toDate').val();

View File

@ -2557,6 +2557,29 @@ chardet@^0.7.0:
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
chart.js@^2.9.3:
version "2.9.3"
resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-2.9.3.tgz#ae3884114dafd381bc600f5b35a189138aac1ef7"
integrity sha512-+2jlOobSk52c1VU6fzkh3UwqHMdSlgH1xFv9FKMqHiNCpXsGPQa/+81AFa+i3jZ253Mq9aAycPwDjnn1XbRNNw==
dependencies:
chartjs-color "^2.1.0"
moment "^2.10.2"
chartjs-color-string@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/chartjs-color-string/-/chartjs-color-string-0.6.0.tgz#1df096621c0e70720a64f4135ea171d051402f71"
integrity sha512-TIB5OKn1hPJvO7JcteW4WY/63v6KwEdt6udfnDE9iCAZgy+V4SrbSxoIbTw/xkUIapjEI4ExGtD0+6D3KyFd7A==
dependencies:
color-name "^1.0.0"
chartjs-color@^2.1.0:
version "2.4.1"
resolved "https://registry.yarnpkg.com/chartjs-color/-/chartjs-color-2.4.1.tgz#6118bba202fe1ea79dd7f7c0f9da93467296c3b0"
integrity sha512-haqOg1+Yebys/Ts/9bLo/BqUcONQOdr/hoEr2LLTRl6C5LXctUdHxsCYfvQVg5JIxITrfCNUDr4ntqmQk9+/0w==
dependencies:
chartjs-color-string "^0.6.0"
color-convert "^1.9.3"
check-types@^8.0.3:
version "8.0.3"
resolved "https://registry.yarnpkg.com/check-types/-/check-types-8.0.3.tgz#3356cca19c889544f2d7a95ed49ce508a0ecf552"
@ -2764,7 +2787,7 @@ collection-visit@^1.0.0:
map-visit "^1.0.0"
object-visit "^1.0.0"
color-convert@^1.9.0, color-convert@^1.9.1:
color-convert@^1.9.0, color-convert@^1.9.1, color-convert@^1.9.3:
version "1.9.3"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
@ -6492,7 +6515,7 @@ 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:
moment@^2.10.2, moment@^2.29.0:
version "2.29.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.0.tgz#fcbef955844d91deb55438613ddcec56e86a3425"
integrity sha512-z6IJ5HXYiuxvFTI6eiQ9dm77uE0gyy1yXNApVHqTcnIKfY9tIwEjlzsZ6u1LQXvVgKeTnv9Xm7NDvJ7lso3MtA==

View File

@ -63,7 +63,7 @@
</td>
</#if>
<script <#--@CSPNonce.attr-->>
$(function () {
/*$(function () {
initChannelDelete('#channel-delete-${channel.id}', '${channel.name}', ${versions});
initChannelManager(
"#channel-edit-${channel.id}", "${channel.name}", "${channel.color.hex}",
@ -71,7 +71,7 @@
p.project.ownerName, p.project.slug, channel.name)}",
"post", "Save changes", ${channel.isNonReviewed?string('true', 'false')}
);
});
});*/
</script>
</tr>
</#list>

View File

@ -16,7 +16,7 @@ Discussion page within Project overview.
};
</script>
<script type="text/javascript" src="<@hangar.url "js/projectDiscuss.js" />"></script>
<script <#--@CSPNonce.attr-->>$(function() { $('.btn-edit').click(); });</script>
<#--<script>$(function() { $('.btn-edit').click(); });</script>--> <#-- TODO jquery was removed from this scope -->
</#assign>
<@view.view p=p sp=sp active="#discussion" additionalScripts=scriptsVar>

View File

@ -210,17 +210,6 @@
<i class="fas fa-check"></i> Save changes
</button>
</@form.form>
<script>
// Basically, hides the form value if its empty. Makes the controller simpler
$("#save").submit(function() {
$(":input[form=save]").filter(function () {
return !this.value;
}).attr("disabled", true);
return true;
});
</script>
</div>
</div>
</div>

View File

@ -18,7 +18,8 @@ Base template for Project overview.
window.PROJECT_SLUG = "${p.project.slug}";
window.PROJECT_ID = "${p.project.pluginId}";
window.ALREADY_STARRED = ${sp.starred?c};
$(function() { $(".nav").find("${active}").addClass("active"); });
window.ACTIVE_NAV = "${active}";
</script>
<script type="text/javascript" src="<@hangar.url "js/projectDetail.js" />"></script>
<script type="text/javascript" src="<@hangar.url "js/pageEdit.js" />"></script>

View File

@ -3,91 +3,14 @@
<#import "*/layout/base.ftlh" as base />
<#assign scriptsVar>
<script <#--@CSPNonce.attr--> type="text/javascript" src="<@hangar.url "lib/chart.js/dist/Chart.min.js" />"></script>
<script <#--@CSPNonce.attr-->>
$(function(){
var timeFrame = ${days}
var domChartReview = document.getElementById("chart-reviews");
var chartReviews = new Chart(domChartReview, {
responsive: true,
type: 'line',
data: {
labels: timeFrame,
datasets: [{
label: "Reviews",
backgroundColor: "cornflowerblue",
borderColor: "dodgerblue",
fill: false,
data: ${reviewData}
}, {
label: "Uploads",
backgroundColor: "lightseagreen",
borderColor: "darkseagreen",
fill: false,
data: ${uploadData}
}]
},
options: {
title: {
text: "Reviews"
}
}
});
var domChartDownload = document.getElementById("chart-downloads");
var chartDownloads = new Chart(domChartDownload, {
responsive: true,
type: 'line',
data: {
labels: timeFrame,
datasets: [{
label: "Total Downloads",
backgroundColor: "cornflowerblue",
borderColor: "dodgerblue",
fill: false,
data: ${totalDownloadData}
}, {
label: "Unsafe Downloads",
backgroundColor: "lightseagreen",
borderColor: "darkseagreen",
fill: false,
data: ${unsafeDownloadData}
}]
},
options: {
title: {
text: "Downloads"
}
}
});
var domChartFlags = document.getElementById("chart-flags");
var chartFlags = new Chart(domChartFlags, {
responsive: true,
type: 'line',
data: {
labels: timeFrame,
datasets: [{
label: "Opened flags", // 'Open flags' is a bit of a misleading name
backgroundColor: "cornflowerblue",
borderColor: "dodgerblue",
fill: false,
data: ${openFlagsData}
}, {
label: "Closed flags",
backgroundColor: "lightseagreen",
borderColor: "darkseagreen",
fill: false,
data: ${closedFlagsData}
}]
},
options: {
title: {
text: "Flags"
}
}
});
});
window.DAYS = ${days};
window.REVIEW_DATA = ${reviewData};
window.UPLOAD_DATA = ${uploadData};
window.TOTAL_DOWNLOAD_DATA = ${totalDownloadData};
window.UNSAFE_DOWNLOAD_DATA = ${unsafeDownloadData};
window.OPEN_FLAGS_DATA = ${openFlagsData};
window.CLOSED_FLAGS_DATA = ${closedFlagsData};
</script>
<script <#--@CSPNonce.attr--> type="text/javascript" src="<@hangar.url "js/stats.js" />"></script>
</#assign>
@ -105,7 +28,7 @@
<label for="toDate">To:</label>
<input id="toDate" type="date" class="form-control" max="${@helper["java.time.LocalDate"].now()}" <#if toDate??> value="${toDate}"</#if>>
</div>
<button id="dateGoButton" class="btn btn-default">Go</button>
<button id="dateGoButton" class="btn btn-default">Go</button>
</div>
</div>