You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Removed Irrelevant codes
class StuffWidget extends api.NoteContextAwareWidget {
get position() { return 100; } // higher value means position towards the bottom/right
get parentWidget() { return 'center-pane'; }
isEnabled() {
return super.isEnabled()
&& this.note.type === 'text'
&& this.note.hasLabel('purchasedPrice')
&& this.note.hasLabel('purchasedPrice') > 0;
}
async refreshWithNote(note) {
---
let maintenance = 0;
try {
maintenance = note.getLabelValues('maintenance') && note.getLabelValues('maintenance') != null ? note.getLabelValues('maintenance').reduce((a, b) => parseFloat(a) + parseFloat(b), 0) : 0;
} catch (e) {
console.log(e)
// Prints TypeError: note.getLabelValues is not a function
}
---
}
It works flawlessly here:
async function getPlacesTableData() {
try {
const notes = await api.runOnBackend(() => {
const notes = api.getNotesWithLabel('purchasedPrice');
const places = [];
for (const note of notes) {
const noteId = note.noteId;
const located = note.getRelationValue('Located');
const url = note.getLabelValue('url');
const purchasedPrice = parseFloat(note.getLabelValue('purchasedPrice')).toFixed(2);
const purchasedDate = note.getLabelValue('purchasedDate');
const dormantDate = note.getLabelValue('dormantDate');
const retiredDate = note.getLabelValue('retiredDate');
let maintenance = 0;
try {
maintenance = note.getLabelValues('maintenance') && note.getLabelValues('maintenance') != null ? note.getLabelValues('maintenance').reduce((a, b) => parseFloat(a) + parseFloat(b), 0) : 0;
}catch(e){
console.log(e)
}
if (noteId && purchasedPrice) {
places.push({ noteId, purchasedPrice, located, url, purchasedDate, retiredDate, dormantDate,maintenance });
}
}
return places.reverse(); // Reverse the sorted data
});
if (!notes || notes.length === 0) {
throw new Error('No places data found.');
}
return notes;
} catch (error) {
console.error('Error retrieving networth data:', error);
return []; // Return an empty array in case of error
}
}
// Function to calculate difference in days
function calculateDaysSince(dateFrom, dateSince) {
console.log(dateFrom,dateSince)
dateFrom = new Date(dateFrom);
// if dateSince is not provided, use the current date
if (!dateSince) {
dateSince = new Date();
}else{
dateSince = new Date(dateSince);
}
const diffInTime = dateSince - dateFrom;
const diffInDays = Math.floor(diffInTime / (1000 * 60 * 60 * 24)); // Convert time to days
return diffInDays;
}
Error logs
Object { froca: {…}, attributes: (8) […], targetRelations: [], parents: (1) […], children: [], parentToBranch: {…}, childToBranch: {}, attachments: null, noteId: "1fRdzPCtiOBT", title: "Office-Air-Purifier", … }
attachments: null
attributes: Array(8) [ "QNPCcsluGWfL", "Ny8swu0XtpXp", "Lm34ABaHhtTt", … ]
blobId: "z4PhNX7vuL3xVChQ1m2A"
childToBranch: Object { }
children: Array []
froca: Object { initializedPromise: Promise { "fulfilled" }, notes: {…}, branches: {…}, … }
isProtected: false
mime: "text/html"
noteId: "1fRdzPCtiOBT"
parentToBranch: Object { EwHXBQHkq1ik: "EwHXBQHkq1ik_1fRdzPCtiOBT" }
parents: Array [ "EwHXBQHkq1ik" ]
targetRelations: Array [ "9GMQ8ZsElGJR" ]
title: "Office-Air-Purifier"
type: "text"
: Object { … }
__filterAttrs: function __filterAttrs(t, e, n)
__getCachedAttributes: function __getCachedAttributes(t)
__getInheritableAttributes: function __getInheritableAttributes(t)
__validateTypeName: function __validateTypeName(t, e)
addChild: function addChild(t, e, n)
addParent: function addParent(t, e, n)
constructor: class g { constructor(t, e) }
dto:
executeScript: async function executeScript()
getAllNotePaths: function getAllNotePaths()
getAttachmentById: async function getAttachmentById(t)
getAttachments: async function getAttachments()
getAttachmentsByRole: async function getAttachmentsByRole(t)
getAttribute: function getAttribute(t, e)
getAttributeValue: function getAttributeValue(t, e)
getAttributes: function getAttributes(t, e)
getBestNotePath: function getBestNotePath(t)
getBestNotePathString: function getBestNotePathString(t)
getBlob: async function getBlob()
getBranchIds: function getBranchIds()
getBranches: function getBranches()
getChildBranches: function getChildBranches()
getChildNoteIds: function getChildNoteIds()
getChildNotes: async function getChildNotes()
getColorClass: function getColorClass()
getContent: async function getContent()
getCssClass: function getCssClass()
getFilteredChildBranches: function getFilteredChildBranches()
getIcon: function getIcon()
getJsonContent: async function getJsonContent()
getLabel: function getLabel(t)
getLabelValue: function getLabelValue(t)
getLabels: function getLabels(t)
getMetadata: async function getMetadata()
getNoteComplement: async function getNoteComplement()
getNotesToInheritAttributesFrom: function getNotesToInheritAttributesFrom()
getOwnedAttribute: function getOwnedAttribute(t, e)
getOwnedAttributeValue: function getOwnedAttributeValue(t, e)
getOwnedAttributes: function getOwnedAttributes(t, e)
getOwnedLabel: function getOwnedLabel(t)
getOwnedLabelValue: function getOwnedLabelValue(t)
getOwnedLabels: function getOwnedLabels(t)
getOwnedRelation: function getOwnedRelation(t)
getOwnedRelationValue: function getOwnedRelationValue(t)
getOwnedRelations: function getOwnedRelations(t)
getParentBranchIds: function getParentBranchIds()
getParentBranches: function getParentBranches()
getParentNoteIds: function getParentNoteIds()
getParentNotes: function getParentNotes()
getPromotedDefinitionAttributes: function getPromotedDefinitionAttributes()
getRelation: function getRelation(t)
getRelationTarget: async function getRelationTarget(t)
getRelationTargets: async function getRelationTargets(t)
getRelationValue: function getRelationValue(t)
getRelations: function getRelations(t)
getScriptEnv: function getScriptEnv()
getSortedNotePathRecords: function getSortedNotePathRecords(t)
getTargetRelationSourceNotes: async function getTargetRelationSourceNotes()
getTargetRelations: function getTargetRelations()
getWorkspaceIconClass: function getWorkspaceIconClass()
getWorkspaceTabBackgroundColor: function getWorkspaceTabBackgroundColor()
hasAncestor: function hasAncestor(t, e, n)
hasAttribute: function hasAttribute(t, e)
hasChildren: function hasChildren()
hasLabel: function hasLabel(t)
hasOwnedAttribute: function hasOwnedAttribute(t, e)
hasOwnedLabel: function hasOwnedLabel(t)
hasOwnedRelation: function hasOwnedRelation(t)
hasRelation: function hasRelation(t)
invalidateAttributeCache: function invalidateAttributeCache()
isArchived:
isContentAvailable: function isContentAvailable()
isEligibleForConversionToAttachment: function isEligibleForConversionToAttachment()
isFolder: function isFolder()
isHiddenCompletely: function isHiddenCompletely()
isHtml: function isHtml()
isInHiddenSubtree: function isInHiddenSubtree()
isJavaScript: function isJavaScript()
isJson: function isJson()
isLabelTruthy: function isLabelTruthy(t)
isLaunchBarConfig: function isLaunchBarConfig()
isOptions: function isOptions()
isRoot: function isRoot()
isShared: function isShared()
sortChildren: function sortChildren()
sortParents: function sortParents()
toString: function toString()
update: function update(t)
<get dto()>: function dto()
<get isArchived()>: function isArchived()
: Object { … }
desktop.js line 1 > eval:70:21
The text was updated successfully, but these errors were encountered:
VarunBatraIT
changed the title
(Bug report) getLabeValues doesn't work in widget.
(Bug report) node.getLabelValues doesn't work in widget.
Oct 24, 2024
TriliumNext Version
0.90.8
What operating system are you using?
Other Linux
What is your setup?
Server access only
Operating System Version
Docker
Description
I have a setup in which I am adding multiple label values where label name is maintenance.
node.getLabelValues() works when I create a list
node.getLabelValues() doesn't work when I am using widget.
I have same code placed in both
It doesn't work here:
It works flawlessly here:
Error logs
Object { froca: {…}, attributes: (8) […], targetRelations: [], parents: (1) […], children: [], parentToBranch: {…}, childToBranch: {}, attachments: null, noteId: "1fRdzPCtiOBT", title: "Office-Air-Purifier", … }
attachments: null
attributes: Array(8) [ "QNPCcsluGWfL", "Ny8swu0XtpXp", "Lm34ABaHhtTt", … ]
blobId: "z4PhNX7vuL3xVChQ1m2A"
childToBranch: Object { }
children: Array []
froca: Object { initializedPromise: Promise { "fulfilled" }, notes: {…}, branches: {…}, … }
isProtected: false
mime: "text/html"
noteId: "1fRdzPCtiOBT"
parentToBranch: Object { EwHXBQHkq1ik: "EwHXBQHkq1ik_1fRdzPCtiOBT" }
parents: Array [ "EwHXBQHkq1ik" ]
targetRelations: Array [ "9GMQ8ZsElGJR" ]
title: "Office-Air-Purifier"
type: "text"
: Object { … }
__filterAttrs: function __filterAttrs(t, e, n)
__getCachedAttributes: function __getCachedAttributes(t)
__getInheritableAttributes: function __getInheritableAttributes(t)
__validateTypeName: function __validateTypeName(t, e)
addChild: function addChild(t, e, n)
addParent: function addParent(t, e, n)
constructor: class g { constructor(t, e) }
dto:
executeScript: async function executeScript()
getAllNotePaths: function getAllNotePaths()
getAttachmentById: async function getAttachmentById(t)
getAttachments: async function getAttachments()
getAttachmentsByRole: async function getAttachmentsByRole(t)
getAttribute: function getAttribute(t, e)
getAttributeValue: function getAttributeValue(t, e)
getAttributes: function getAttributes(t, e)
getBestNotePath: function getBestNotePath(t)
getBestNotePathString: function getBestNotePathString(t)
getBlob: async function getBlob()
getBranchIds: function getBranchIds()
getBranches: function getBranches()
getChildBranches: function getChildBranches()
getChildNoteIds: function getChildNoteIds()
getChildNotes: async function getChildNotes()
getColorClass: function getColorClass()
getContent: async function getContent()
getCssClass: function getCssClass()
getFilteredChildBranches: function getFilteredChildBranches()
getIcon: function getIcon()
getJsonContent: async function getJsonContent()
getLabel: function getLabel(t)
getLabelValue: function getLabelValue(t)
getLabels: function getLabels(t)
getMetadata: async function getMetadata()
getNoteComplement: async function getNoteComplement()
getNotesToInheritAttributesFrom: function getNotesToInheritAttributesFrom()
getOwnedAttribute: function getOwnedAttribute(t, e)
getOwnedAttributeValue: function getOwnedAttributeValue(t, e)
getOwnedAttributes: function getOwnedAttributes(t, e)
getOwnedLabel: function getOwnedLabel(t)
getOwnedLabelValue: function getOwnedLabelValue(t)
getOwnedLabels: function getOwnedLabels(t)
getOwnedRelation: function getOwnedRelation(t)
getOwnedRelationValue: function getOwnedRelationValue(t)
getOwnedRelations: function getOwnedRelations(t)
getParentBranchIds: function getParentBranchIds()
getParentBranches: function getParentBranches()
getParentNoteIds: function getParentNoteIds()
getParentNotes: function getParentNotes()
getPromotedDefinitionAttributes: function getPromotedDefinitionAttributes()
getRelation: function getRelation(t)
getRelationTarget: async function getRelationTarget(t)
getRelationTargets: async function getRelationTargets(t)
getRelationValue: function getRelationValue(t)
getRelations: function getRelations(t)
getScriptEnv: function getScriptEnv()
getSortedNotePathRecords: function getSortedNotePathRecords(t)
getTargetRelationSourceNotes: async function getTargetRelationSourceNotes()
getTargetRelations: function getTargetRelations()
getWorkspaceIconClass: function getWorkspaceIconClass()
getWorkspaceTabBackgroundColor: function getWorkspaceTabBackgroundColor()
hasAncestor: function hasAncestor(t, e, n)
hasAttribute: function hasAttribute(t, e)
hasChildren: function hasChildren()
hasLabel: function hasLabel(t)
hasOwnedAttribute: function hasOwnedAttribute(t, e)
hasOwnedLabel: function hasOwnedLabel(t)
hasOwnedRelation: function hasOwnedRelation(t)
hasRelation: function hasRelation(t)
invalidateAttributeCache: function invalidateAttributeCache()
isArchived:
isContentAvailable: function isContentAvailable()
isEligibleForConversionToAttachment: function isEligibleForConversionToAttachment()
isFolder: function isFolder()
isHiddenCompletely: function isHiddenCompletely()
isHtml: function isHtml()
isInHiddenSubtree: function isInHiddenSubtree()
isJavaScript: function isJavaScript()
isJson: function isJson()
isLabelTruthy: function isLabelTruthy(t)
isLaunchBarConfig: function isLaunchBarConfig()
isOptions: function isOptions()
isRoot: function isRoot()
isShared: function isShared()
sortChildren: function sortChildren()
sortParents: function sortParents()
toString: function toString()
update: function update(t)
<get dto()>: function dto()
<get isArchived()>: function isArchived()
: Object { … }
desktop.js line 1 > eval:70:21
The text was updated successfully, but these errors were encountered: