In relation to this thread: State tiddler dependent on tiddler title, I would like to capture the filename of the imported json file and use that in my wiki for reference. This way I will be able to see what the last json file I imported was.
The below code is what I use to import the json file. It will delete all current logs, stations, etc. and import a new log json file. I then create the station, date and other tiddlers with another button.
Is there a way to be able to store the filename in a field of my “Refresh Logs” tiddler?
\define dx-refresh-logs()
<div class="tc-block">
<!-- Button: clear existing DXLog tiddlers -->
<$button class="tc-btn-invisible tc-btn-large">
<$list filter="[[$:/core/images/refresh-button]is[tiddler]]">
<$transclude tiddler="$:/core/images/refresh-button" />
</$list>
<span>Clear Current Logs</span>
<!-- Delete all tiddlers tagged DXLog / DXStation -->
<$action-deletetiddler $filter="[tag[DXLog]]" />
<$action-deletetiddler $filter="[tag[DXStation]]" />
<$action-deletetiddler $filter="[tag[DXLogDate]]" />
<!-- NEW: record last refresh time + file on DX Refresh Logs -->
<$action-setfield
$tiddler="Refresh Logs"
last-refresh=<<now "YYYY-0MM-0DD 0hh:0mm:ss">>
/>
</$button>
</div>
<div class="tc-block" style="margin-top:0.5em;">
<!-- Browse control: choose the new JSON export -->
<span class="tc-file-input-wrapper browse-button">
<$browse accept=".json" tooltip="Import DX JSON file"/>
<span>Re-import JSON</span>
</span>
</div>
\end
\define dx-create-station-tiddlers()
<!-- Only look at imported DX log tiddlers -->
<$list
filter="[tag[DXLog]has[dx-station]get[dx-station]trim[]unique[]]"
variable="station"
>
<$let
logs={{{ [tag[DXLog]field:dx-station<station>] }}}
class={{{ [<logs>get[dx-class]trim[]unique[]join[, ]] }}}
loc={{{ [<logs>get[dx-tx-location]trim[]unique[]join[, ]] }}}
state={{{ [<logs>get[dx-state]trim[]unique[]join[, ]] }}}
country={{{ [<logs>get[dx-country]trim[]unique[]join[, ]] }}}
frequency={{{ [<logs>get[dx-freq-khz]trim[]unique[]join[, ]] }}}
count={{{ [tag[DXLog]field:dx-station<station>count[]] }}}
>
<$action-createtiddler
$basetitle=<<station>>
$overwrite="yes"
text=""
tags="DXStation"
station-class=<<cls>>
station-tx-location=<<loc>>
station-state=<<state>>
station-country=<<country>>
station-class=<<class>>
station-freq-khz=<<frequency>>
station-count=<<count>>
/>
</$let>
</$list>
\end
\define dx-create-date-tiddlers()
<$list filter="[tag[DXLog]sort[dx-date]reverse[yes]get[dx-date]unique[]]" variable="dxlogdate">
<$let
dxdate=<<dxlogdate>>
dxdatecount={{{ [tag[DXLog]dx-date<dxlogdate>count[]] }}}
dxnewcount={{{ [tag[DXLog]dx-date<dxlogdate>dx-new-station[Y]count[]] }}}
dxlogqth={{{ [tag[DXLog]dx-date<dxlogdate>get[dx-qth]] }}}
>
<$action-createtiddler
$basetitle=<<dxdate>>
$overwrite="yes"
text=""
tags="DXLogDate"
logs=<<dxdatecount>>
new=<<dxnewcount>>
qth=<<dxlogqth>>
/>
</$let>
</$list>
\end
\define dx-create-qth-tiddlers()
<$list filter="[tag[DXLog]sort[dx-date]reverse[yes]get[dx-qth]unique[]]" variable="dxlogqth">
<$let
dxqth=<<dxlogqth>>
dxqthlogcount={{{ [tag[DXLog]dx-qth<dxlogqth>count[]] }}}
dxqthnewcount={{{ [tag[DXLog]dx-qth<dxlogqth>dx-new-station[Y]count[]] }}}
>
<$action-createtiddler
$basetitle=<<dxqth>>
$overwrite="yes"
text=""
tags="DXQTH"
logs=<<dxqthlogcount>>
new=<<dxqthnewcount>>
/>
</$let>
</$list>
\end
\define dxactions()
<<dx-create-station-tiddlers>>
<<dx-create-date-tiddlers>>
<<dx-create-qth-tiddlers>>
\end
<table class="table-borderless">
<tr>
<td style="padding: 0;"><b>Logs last updated:</b></td>
<td>{{Refresh Logs!!last-refresh}}</td>
</tr>
<tr>
<td style="padding: 0;"><b>Log file used:</b></td>
<td>{{Refresh Logs!!last-file}}</td>
</tr>
</table>
<<dx-refresh-logs>>
<$button class="tc-btn-invisible" actions=<<dxactions>>>
Create / update station tiddlers
</$button>