Module:ToolInventoryData: Difference between revisions
From Claremont MakerSpace
(Remove model number, switch to status_meta) |
No edit summary |
||
Line 18: | Line 18: | ||
function p.ToolInstanceTable(frame) | function p.ToolInstanceTable(frame) | ||
local out = '{| class="wikitable" style="margin: 0;"\n! Asset Tag | local out = '{| class="wikitable" style="margin: 0;"\n! Asset Tag || Status \n|-\n' | ||
for idx, asset_tag in ipairs(mw.text.split(frame.args[1], ';')) | for idx, asset_tag in ipairs(mw.text.split(frame.args[1], ';')) | ||
do | do |
Revision as of 21:15, 7 July 2020
Documentation for this module may be created at Module:ToolInventoryData/doc
local p = {} local function getToolInfo(asset_tag) mw.getCurrentFrame():callParserFunction( '#get_web_data', { url = 'SNIPEIT_URL/api/v1/hardware/bytag/' .. asset_tag, format='json', 'use jsonpath', data='status=$.status_label.status_meta' } ) return { status = mw.getCurrentFrame():callParserFunction('#external_value', {'status'}) } end function p.ToolInstanceTable(frame) local out = '{| class="wikitable" style="margin: 0;"\n! Asset Tag || Status \n|-\n' for idx, asset_tag in ipairs(mw.text.split(frame.args[1], ';')) do local data = getToolInfo(asset_tag) local link ='[https://inventory.claremontmakerspace.org/hardware/bytag?assetTag='..asset_tag..' '..asset_tag..']' out = out .. '|' .. link .. '||' .. data.status .. '\n|-\n' end return out .. '|}' end return p