Skip to content

Update devices.js #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
May 4, 2025
30 changes: 28 additions & 2 deletions views/devices/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,26 @@ import { siteURL, container, showSpinner } from '../../js/const.js'

var devicesList = []
const gerritURL = 'https://gerrit.omnirom.org'
const githubAPIURL = 'https://api.github.com'
const rawURL = 'https://raw.githubusercontent.com/omnirom/'
var currentVersion = 'android-15'
var branchMapping = {
'android-13_0': 'android-13.0',
'android-14_0': 'android-14.0',
'android-15_0': 'android-15'
}
// temporary
var repo_dict = {
"android_device_google_raven" : 1,
"android_device_google_oriole" : 1,
"android_device_asus_zenfone7" : 1,
"android_device_asus_zenfone8" : 1,
"android_device_asus_zenfone9" : 1,
}

class DevicesView {

async loadGithubRepos() {
async loadGithubReposFromGerrit() {
try {
let url = gerritURL + "/projects/?b=" + currentVersion + "&p=android_device";
let response = await axios.get(url, {});
Expand All @@ -27,6 +36,23 @@ class DevicesView {
}
}

async loadGithubReposFromGithub() {
try {
// TODO filter for branch
//let url = githubAPIURL + "/search/repositories?q=android_device+owner:omnirom&per_page=100";
//let response = await axios.get(url, {});
//let s = response.data;
//var repo_dict = {};
//for (const [key, value] of Object.entries(s["items"])){
// repo_dict[value["name"]] = 1;
//}
console.log("loadGithubReposFromGithub repo_dict " + Object.keys(repo_dict));
this.loadDevice(repo_dict);

} catch (error) {
console.log("loadGithubRepos error " + error);
}
}
async loadDevice(devices) {
var requests = Object.keys(devices).map(repo => axios.get(rawURL + repo + "/" + currentVersion + "/meta/config.json"));
await Promise.allSettled(requests).then(results => {
Expand Down Expand Up @@ -127,7 +153,7 @@ class DevicesView {
d['image'] = "/images/default_phone_omni.png";
d['changelog'] = gerritURL + "/q/status:merged+android_device"
devicesList.push(d)
await this.loadGithubRepos();
await this.loadGithubReposFromGithub();
} catch (error) {
console.log("display device view error: " + error);
}
Expand Down