mirror of
https://github.com/zadam/trilium.git
synced 2025-10-30 18:05:55 +01:00
chore(demo): move to right directory
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
<div style="padding: 20px">
|
||||
<canvas class="stats-canvas" style="width: 500px; margin: auto;"></canvas>
|
||||
|
||||
<br/>
|
||||
|
||||
<table class="table stats-table" style="font-size: 90%;">
|
||||
<tr>
|
||||
<th>Attribute name</th>
|
||||
<th>Count</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
const attrCounts = await api.runOnBackend(() => {
|
||||
return api.sql.getRows(`
|
||||
SELECT
|
||||
name, COUNT(*) AS count
|
||||
FROM attributes
|
||||
WHERE isDeleted = 0
|
||||
GROUP BY name
|
||||
ORDER BY count DESC`);
|
||||
});
|
||||
|
||||
renderPieChart(attrCounts.length <= 10 ? attrCounts : attrCounts.splice(0, 10));
|
||||
renderTable(attrCounts);
|
||||
@@ -0,0 +1,45 @@
|
||||
module.exports = data => {
|
||||
const ctx = api.$container.find('.stats-canvas')[0].getContext("2d");
|
||||
|
||||
const myPieChart = new Chart(ctx, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
datasets: [{
|
||||
data: data.map(nc => nc.count),
|
||||
backgroundColor: ['#3366CC','#DC3912','#FF9900','#109618','#990099','#3B3EAC','#0099C6','#DD4477','#66AA00','#B82E2E','#316395','#994499','#22AA99','#AAAA11','#6633CC','#E67300','#8B0707','#329262','#5574A6','#3B3EAC'],
|
||||
datalabels: {
|
||||
anchor: 'end'
|
||||
}
|
||||
}],
|
||||
labels: data.map(nc => nc.name)
|
||||
},
|
||||
options: {
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
plugins: {
|
||||
datalabels: {
|
||||
backgroundColor: function(context) {
|
||||
return context.dataset.backgroundColor;
|
||||
},
|
||||
borderColor: 'white',
|
||||
borderRadius: 25,
|
||||
borderWidth: 2,
|
||||
color: 'white',
|
||||
display: function(context) {
|
||||
var dataset = context.dataset;
|
||||
var count = dataset.data.length;
|
||||
var value = dataset.data[context.dataIndex];
|
||||
return value > count * 1.5;
|
||||
},
|
||||
font: {
|
||||
weight: 'bold'
|
||||
},
|
||||
formatter: function(value, context) {
|
||||
return context.chart.data.labels[context.dataIndex] + ": " + Math.round(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../../../../../../../../style.css">
|
||||
<base target="_parent">
|
||||
<title data-trilium-title>chart.js</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<h1 data-trilium-h1>chart.js</h1>
|
||||
|
||||
<div class="ck-content">
|
||||
<p>This is a clone of a note. Go to its <a href="../../../../../Weight%20Tracker/Implementation/JS%20code/chart.js">primary location</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../../../../../../../../../style.css">
|
||||
<base target="_parent">
|
||||
<title data-trilium-title>chart.js</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<h1 data-trilium-h1>chart.js</h1>
|
||||
|
||||
<div class="ck-content">
|
||||
<p>This is a clone of a note. Go to its <a href="../../../../../../Weight%20Tracker/Implementation/JS%20code/chart.js">primary location</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,17 @@
|
||||
module.exports = counts => {
|
||||
const $statsTable = api.$container.find('.stats-table');
|
||||
|
||||
addRow('total', counts.reduce((acc, cur) => acc + cur.count, 0));
|
||||
|
||||
for (const count of counts) {
|
||||
addRow(count.name, count.count);
|
||||
}
|
||||
|
||||
function addRow(name, count) {
|
||||
$statsTable.append(
|
||||
$("<tr>")
|
||||
.append($("<td>").text(name))
|
||||
.append($("<td>").text(count))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<div style="padding: 20px">
|
||||
<p>This table shows 100 largest notes, including their revisions and attachments.</p>
|
||||
|
||||
<table class="table stats-table" style="font-size: 90%;">
|
||||
<tr>
|
||||
<th>Note</th>
|
||||
<th nowrap>Size</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,47 @@
|
||||
const notes = await api.runOnBackend(() => {
|
||||
const blobSizes = api.sql.getMap(`SELECT blobId, LENGTH(content) FROM blobs`);
|
||||
const noteBlobIds = api.sql.getRows(`
|
||||
SELECT
|
||||
notes.noteId,
|
||||
notes.blobId,
|
||||
GROUP_CONCAT(revisions.blobId) AS revisions_blobIds,
|
||||
GROUP_CONCAT(note_attachments.blobId) AS note_attachments_blobIds,
|
||||
GROUP_CONCAT(revision_attachments.blobId) AS revision_attachments_blobIds
|
||||
FROM
|
||||
notes
|
||||
LEFT JOIN revisions USING (noteId)
|
||||
LEFT JOIN attachments AS note_attachments ON notes.noteId = note_attachments.ownerId
|
||||
LEFT JOIN attachments AS revision_attachments ON revisions.revisionId = revision_attachments.ownerId
|
||||
GROUP BY noteId`);
|
||||
|
||||
let noteSizes = [];
|
||||
|
||||
for (const {noteId, blobId, revisions_blobIds, note_attachments_blobIds, revision_attachments_blobIds} of noteBlobIds) {
|
||||
const blobIds = new Set(`${blobId},${revisions_blobIds},${note_attachments_blobIds},${revision_attachments_blobIds}`.split(',').filter(blobId => !!blobId));
|
||||
|
||||
const lengths = [...blobIds].map(blobId => blobSizes[blobId] || 0);
|
||||
const totalLength = lengths.reduce((partialSum, a) => partialSum + a, 0);
|
||||
|
||||
noteSizes.push({ noteId, size: totalLength });
|
||||
}
|
||||
|
||||
noteSizes.sort((a, b) => a.size > b.size ? -1 : 1);
|
||||
|
||||
noteSizes = noteSizes.splice(0, 100);
|
||||
|
||||
return noteSizes;
|
||||
});
|
||||
|
||||
const $statsTable = api.$container.find('.stats-table');
|
||||
|
||||
for (const note of notes) {
|
||||
$statsTable.append(
|
||||
$("<tr>")
|
||||
.append(
|
||||
$("<td>").append(await api.createNoteLink(note.noteId, {showNotePath: true}))
|
||||
)
|
||||
.append(
|
||||
$("<td nowrap>").text(note.size + " bytes")
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<div style="padding: 20px">
|
||||
<table class="table stats-table" style="font-size: 90%;">
|
||||
<tr>
|
||||
<th>Note</th>
|
||||
<th nowrap>Clone count</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,26 @@
|
||||
const notes = await api.runOnBackend(() => {
|
||||
return api.sql.getRows(`
|
||||
SELECT
|
||||
notes.noteId,
|
||||
COUNT(branches.branchId) AS count
|
||||
FROM notes
|
||||
JOIN branches USING (noteId)
|
||||
WHERE notes.isDeleted = 0
|
||||
AND branches.isDeleted = 0
|
||||
GROUP BY notes.noteId
|
||||
HAVING count > 1
|
||||
ORDER BY count DESC
|
||||
LIMIT 100`);
|
||||
});
|
||||
|
||||
const $statsTable = api.$container.find('.stats-table');
|
||||
|
||||
for (const note of notes) {
|
||||
$statsTable.append(
|
||||
$("<tr>")
|
||||
.append(
|
||||
$("<td>").append(await api.createNoteLink(note.noteId, {showNotePath: true}))
|
||||
)
|
||||
.append($("<td nowrap>").text(note.count))
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<div style="padding: 20px">
|
||||
<p>This table shows notes with most revisions</p>
|
||||
|
||||
<table class="table stats-table" style="font-size: 90%;">
|
||||
<tr>
|
||||
<th>Note</th>
|
||||
<th nowrap>Revision count</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,24 @@
|
||||
const notes = await api.runOnBackend(() => {
|
||||
return api.sql.getRows(`
|
||||
SELECT
|
||||
notes.noteId,
|
||||
COUNT(revisions.revisionId) AS count
|
||||
FROM notes
|
||||
JOIN revisions USING (noteId)
|
||||
WHERE notes.isDeleted = 0
|
||||
GROUP BY notes.noteId
|
||||
ORDER BY count DESC
|
||||
LIMIT 100`);
|
||||
});
|
||||
|
||||
const $statsTable = api.$container.find('.stats-table');
|
||||
|
||||
for (const note of notes) {
|
||||
$statsTable.append(
|
||||
$("<tr>")
|
||||
.append(
|
||||
$("<td>").append(await api.createNoteLink(note.noteId, {showNotePath: true}))
|
||||
)
|
||||
.append($("<td nowrap>").text(note.count))
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<div style="padding: 20px">
|
||||
<p>This table shows notes which are linked by other notes through relations</p>
|
||||
|
||||
<table class="table stats-table" style="font-size: 90%;">
|
||||
<tr>
|
||||
<th>Note</th>
|
||||
<th nowrap>Relation count</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,26 @@
|
||||
const notes = await api.runOnBackend(() => {
|
||||
return api.sql.getRows(`
|
||||
SELECT
|
||||
notes.noteId,
|
||||
COUNT(attributes.attributeId) AS count
|
||||
FROM notes
|
||||
JOIN attributes ON attributes.value = notes.noteId
|
||||
WHERE notes.isDeleted = 0
|
||||
AND attributes.isDeleted = 0
|
||||
AND attributes.type = 'relation'
|
||||
GROUP BY notes.noteId
|
||||
ORDER BY count DESC
|
||||
LIMIT 100`);
|
||||
});
|
||||
|
||||
const $statsTable = api.$container.find('.stats-table');
|
||||
|
||||
for (const note of notes) {
|
||||
$statsTable.append(
|
||||
$("<tr>")
|
||||
.append(
|
||||
$("<td>").append(await api.createLink(note.noteId, {showNotePath: true}))
|
||||
)
|
||||
.append($("<td nowrap>").text(note.count))
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<div style="padding: 20px">
|
||||
<canvas class="stats-canvas" style="width: 500px; margin: auto;"></canvas>
|
||||
|
||||
<br/>
|
||||
|
||||
<table class="table stats-table" style="font-size: 90%;">
|
||||
<tr>
|
||||
<th>Note type</th>
|
||||
<th>Count (not deleted)</th>
|
||||
<th>Count (deleted)</th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
const noteCounts = await api.runOnBackend(() => {
|
||||
return api.sql.getRows(`
|
||||
SELECT
|
||||
type,
|
||||
isDeleted,
|
||||
SUM(CASE WHEN isDeleted=0 THEN 1 ELSE 0 END) AS countNotDeleted,
|
||||
SUM(CASE WHEN isDeleted=1 THEN 1 ELSE 0 END) AS countDeleted
|
||||
FROM notes
|
||||
GROUP BY type
|
||||
ORDER BY countNotDeleted DESC`);
|
||||
});
|
||||
|
||||
renderPieChart(noteCounts.map(nc => {
|
||||
return {
|
||||
name: nc.type,
|
||||
count: nc.countNotDeleted
|
||||
};
|
||||
}));
|
||||
|
||||
renderTable(noteCounts);
|
||||
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="../../../../../../../style.css">
|
||||
<base target="_parent">
|
||||
<title data-trilium-title>renderPieChart</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="content">
|
||||
<h1 data-trilium-h1>renderPieChart</h1>
|
||||
|
||||
<div class="ck-content">
|
||||
<p>This is a clone of a note. Go to its <a href="../../../Attribute%20count/template/js/renderPieChart.js">primary location</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,21 @@
|
||||
module.exports = counts => {
|
||||
const $statsTable = api.$container.find('.stats-table');
|
||||
|
||||
addRow('total',
|
||||
counts.reduce((acc, cur) => acc + cur.countNotDeleted, 0),
|
||||
counts.reduce((acc, cur) => acc + cur.countDeleted, 0)
|
||||
);
|
||||
|
||||
for (const count of counts) {
|
||||
addRow(count.type, count.countNotDeleted, count.countDeleted);
|
||||
}
|
||||
|
||||
function addRow(type, countNotDeleted, countDeleted) {
|
||||
$statsTable.append(
|
||||
$("<tr>")
|
||||
.append($("<td>").text(type))
|
||||
.append($("<td>").text(countNotDeleted))
|
||||
.append($("<td>").text(countDeleted))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user