bricaud/graphexp

Properties of type Date are not parsed

ncaprivi opened this issue · 1 comments

I use graphexp to visualize my JanusGraph database. It supports java.util.Date as vertex property type. But graphexp displays the value as unix timestamp (number). With a small hack, I was able to change infobox.js:

function _display_vertex_properties(key,value,info_table) {
    if (typeof value === "string" && $('#communication_method').val() =="GraphSON3_4"){
	var new_info_row = info_table.append("tr");
 	new_info_row.append("td").text(key).style("font-size",_font_size);
	var formattedValue = value 
	if (key.includes("time")) {
		formattedValue = new Date(parseInt(value)).toLocaleString("en-GB", {timeZone: "Region/City", timeZoneName: "short", hour12: false})
	} 
 	new_info_row.append("td").text(formattedValue).style("font-size",_font_size);
 	new_info_row.append("td").text('').style("font-size",_font_size);
    }

This would parse the number to a date, each time the property key contains "time".

Anyone has a nice idea for a general, robust solution?

Hi, thanks for the suggestion. Could you make a PR if you have found a more general solution?