Skip to content

Commit

Permalink
fix: draw charts when document is ready
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Mar 2, 2024
1 parent 70aafbe commit 335a373
Showing 1 changed file with 48 additions and 41 deletions.
89 changes: 48 additions & 41 deletions otterdog/webapp/templates/home/organization.html
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ <h3 class="card-title">Branch Protections</h3>
if (hash) {
$('[data-toggle="pill"][href="' + hash + '"]').trigger('click');
}

drawSecretScanningChart();
drawBranchProtectionChart();
});

$('.tab-link').on('click', function(event) {
Expand Down Expand Up @@ -439,52 +442,56 @@ <h3 class="card-title">Branch Protections</h3>
}
};

const secret_scanning_ctx = document.getElementById('secret-scanning-chart');
function drawSecretScanningChart() {
const secret_scanning_ctx = document.getElementById('secret-scanning-chart');

new Chart(secret_scanning_ctx, {
type: 'doughnut',
data: {
labels: ['disabled', 'alert mode', 'protection mode'],
datasets: [{
label: 'secret scanning',
data: {{ secret_scanning_data|safe }},
backgroundColor: [
'#dc3545',
'#ffc107',
'#28a745'
],
borderWidth: 1
}]
},
options: {
animation: {
animateRotate: false
new Chart(secret_scanning_ctx, {
type: 'doughnut',
data: {
labels: ['disabled', 'alert mode', 'protection mode'],
datasets: [{
label: 'secret scanning',
data: {{ secret_scanning_data|safe }},
backgroundColor: [
'#dc3545',
'#ffc107',
'#28a745'
],
borderWidth: 1
}]
},
options: {
animation: {
animateRotate: false
}
}
}
});
});
};

const branch_protections_ctx = document.getElementById('branch-protection-chart');
function drawBranchProtectionChart() {
const branch_protections_ctx = document.getElementById('branch-protection-chart');

new Chart(branch_protections_ctx, {
type: 'doughnut',
data: {
labels: ['not protected', 'protected'],
datasets: [{
label: 'branch protections',
data: {{ branch_protection_data|safe }},
backgroundColor: [
'#dc3545',
'#28a745'
],
borderWidth: 1
}]
},
options: {
animation: {
animateRotate: false
new Chart(branch_protections_ctx, {
type: 'doughnut',
data: {
labels: ['not protected', 'protected'],
datasets: [{
label: 'branch protections',
data: {{ branch_protection_data|safe }},
backgroundColor: [
'#dc3545',
'#28a745'
],
borderWidth: 1
}]
},
options: {
animation: {
animateRotate: false
}
}
}
});
});
};
</script>

{% endblock javascripts %}

0 comments on commit 335a373

Please sign in to comment.