@zaidka helped me sort this out a while ago, and I wanted to pass along the knowledge.
The problem I was trying to solve is how to link from the device page to an external system based upon some unique device data. For example, I wanted to click on the PPPoE username and be taken to our subscriber management system page for that user. I also wanted to be able to click on the serial number and be taken to a search page in our system.
In Admin → Config, modify the data in “Edit device page” to incorporate this:
- type: "'parameter-list'"
parameters:
# Your existing params
- label: "'Serial number'"
parameter: DeviceID.SerialNumber
type: "'container'"
components:
- type: "'parameter'"
element:
tag: "'a'"
attributes:
href: '"https://some-url.com/Broadband/Customer/AdvancedSearch?serialNumber=" || ENCODEURICOMPONENT(DeviceID.SerialNumber)'
target: "'_blank'"
- label: "'PPPoE username'"
parameter: VirtualParameters.PPPoEUsername
type: "'container'"
components:
- type: "'parameter'"
element:
tag: "'a'"
attributes:
href: '"https://some-url.com/Broadband/Customer/Account/" || ENCODEURICOMPONENT(VirtualParameters.PPPoEUsername)'
target: "'_blank'"
// VirtualParameters.PPPoEUsername
let result = '';
if ("value" in args[1]) {
result = args[1].value[0];
} else {
let keys = [
'InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username',
'Device.PPP.Interface.*.Username'
];
result = getParameterValue(keys);
}
return {writable: true, value: [result, "xsd:string"]};
function getParameterValue(keys) {
const now = Date.now();
for (let key of keys) {
let d = declare(key, {path: now - (120 * 1000), value: now});
for (let item of d) {
if (item.value && item.value[0]) {
return item.value[0];
}
}
}
return 'UNKNOWN';
}