-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2765 from balena-io/alexgg/esr-devices
extended-support-release: use dynamic list of supported devices
- Loading branch information
Showing
3 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js" type="text/javascript"></script> | ||
<script type="text/javascript"> | ||
|
||
(function () { | ||
var archAliasMap = { | ||
rpi: 'armv6hf', | ||
}; | ||
// The following pine client query was used to generate the OData url below. | ||
// TODO: Start using the sdk in the docs and use the call directly. | ||
// await sdk.pine.get({ | ||
// resource: 'device_type', | ||
// options: { | ||
// $select: ['name', 'slug', 'logo'], | ||
// $expand: { | ||
// is_of__cpu_architecture: { | ||
// $select: 'slug' | ||
// } | ||
// }, | ||
// $filter: { | ||
// is_default_for__application: { | ||
// $any: { | ||
// $alias: 'idfa', | ||
// $expr: { | ||
// idfa: { | ||
// is_host: true, | ||
// is_archived: false, | ||
// owns__release: { | ||
// $any: { | ||
// $alias: 'r', | ||
// $expr: { | ||
// status: 'success', | ||
// is_final: true, | ||
// is_invalidated: false, | ||
// } | ||
// } | ||
// } | ||
// }, | ||
// $and: { | ||
// idfa: { | ||
// app_name: { | ||
// $contains: '-esr', | ||
// } | ||
// } | ||
// } | ||
// }, | ||
// }, | ||
// }, | ||
// }, | ||
// $orderby: { | ||
// name: 'asc', | ||
// } | ||
// } | ||
// }) | ||
window.jQuery | ||
.ajax({ | ||
url: "https://api.balena-cloud.com/v6/device_type?$select=name,slug,logo&$expand=is_of__cpu_architecture($select=slug)&$filter=is_default_for__application/any(idfa:((idfa/is_host%20eq%20true)%20and%20(idfa/is_archived%20eq%20false)%20and%20(idfa/owns__release/any(r:(status%20eq%20%27success%27)%20and%20(is_final%20eq%20true)%20and%20(is_invalidated%20eq%20false))))%20and(contains(idfa/app_name,%27-esr%27)))&$orderby=name%20asc" | ||
}) | ||
.done(function (deviceTypesResponse) { | ||
var table = _(deviceTypesResponse.d) | ||
.reduce(function (acc, deviceType) { | ||
var archSlug = deviceType.is_of__cpu_architecture[0].slug; | ||
if (archAliasMap[archSlug]) { | ||
archSlug = archAliasMap[archSlug]; | ||
} | ||
var tableCell = | ||
"<tr> <td>" + | ||
"<img class='device_icon' src=" + deviceType.logo + " />" + | ||
"</td> <td>" + | ||
deviceType.name + | ||
"</td> <td>" + | ||
deviceType.slug + | ||
"</td> <td>" + | ||
archSlug + | ||
"</td> </tr>"; | ||
return acc + tableCell; | ||
}, ""); | ||
|
||
return window.jQuery("#support_esr_devices_table").append(table); | ||
}) | ||
.fail(function (error) { | ||
console.error(error) | ||
return window | ||
.jQuery("#support_esr_devices_table") | ||
.append( | ||
'<tr><td colspan="4">Something went wrong.</td></tr>' | ||
); | ||
}); | ||
|
||
}.call(this)); | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters