@@ -3,13 +3,14 @@ import { siteURL, container, showSpinner } from '../../js/const.js'
3
3
var devicesList = [ ]
4
4
const gerritURL = 'https://gerrit.omnirom.org'
5
5
const rawURL = 'https://raw.githubusercontent.com/omnirom/'
6
+ var currentVersion = 'android-11'
6
7
7
8
class DevicesView {
8
9
9
- async loadGithubRepos ( branch ) {
10
+ async loadGithubRepos ( ) {
10
11
try {
11
12
let response = await axios
12
- . get ( gerritURL + "/projects/?b=" + branch + "&p=android_device" , {
13
+ . get ( gerritURL + "/projects/?b=" + currentVersion + "&p=android_device" , {
13
14
} ) ;
14
15
15
16
let magic = ")]}'" ;
@@ -24,7 +25,7 @@ class DevicesView {
24
25
}
25
26
26
27
async loadDevice ( devices ) {
27
- var requests = Object . keys ( devices ) . map ( repo => axios . get ( rawURL + repo + "/android-10 /meta/config.json" ) ) ;
28
+ var requests = Object . keys ( devices ) . map ( repo => axios . get ( rawURL + repo + "/" + currentVersion + " /meta/config.json") ) ;
28
29
await Promise . allSettled ( requests ) . then ( results => {
29
30
results . forEach ( result => {
30
31
if ( result . value ) {
@@ -61,8 +62,8 @@ class DevicesView {
61
62
62
63
devicesList . forEach ( device => {
63
64
const card = `
64
- <div class="card device-card" style="width: 18rem; ">
65
- <img src="${ device [ 'image' ] } " class="card-img-top" width="250" alt="${ device [ 'model' ] } " >
65
+ <div class="card device-card col-lg-3 col-md-4 col-sm-5 ">
66
+ <img src="${ device [ 'image' ] } " class="card-img-top" alt="${ device [ 'model' ] } " >
66
67
<div class="card-body">
67
68
<h5 class="card-title">${ device [ 'model' ] } </h5>
68
69
<p class="card-text">${ device [ 'make' ] } <br>${ device [ 'state' ] } </p>
@@ -73,26 +74,32 @@ class DevicesView {
73
74
devicesContainer . innerHTML += card
74
75
} )
75
76
77
+ let activeButton = tempObject . querySelector ( '#' + currentVersion )
78
+ activeButton . classList . add ( "btn-dark" ) ;
79
+
76
80
container . innerHTML = tempObject . innerHTML
77
81
}
78
82
79
- async displayView ( ) {
83
+ async displayView ( hash ) {
80
84
try {
81
- if ( devicesList . length === 0 ) {
82
- showSpinner ( true ) ;
83
- let d = { } ;
84
- d [ 'model' ] = "All Devices" ;
85
- d [ 'make' ] = "All Manufactures" ;
86
- d [ 'state' ] = "official" ;
87
- d [ 'pageUrl' ] = "https://dl.omnirom.org/" ;
88
- d [ 'image' ] = "/images/default_phone_omni.png" ;
89
- d [ 'changelog' ] = gerritURL + "/q/status:merged+android_device"
90
- devicesList . push ( d )
91
- await this . loadGithubRepos ( 'android-10' ) ;
92
- } else {
93
- this . showDevices ( )
85
+ if ( hash ) {
86
+ let androidVersion = hash . split ( "/" ) [ 1 ]
87
+ if ( androidVersion !== currentVersion ) {
88
+ currentVersion = androidVersion
89
+ }
94
90
}
95
91
92
+ devicesList = [ ]
93
+ showSpinner ( true ) ;
94
+ let d = { } ;
95
+ d [ 'model' ] = "All Devices" ;
96
+ d [ 'make' ] = "All Manufactures" ;
97
+ d [ 'state' ] = "official" ;
98
+ d [ 'pageUrl' ] = "https://dl.omnirom.org/" ;
99
+ d [ 'image' ] = "/images/default_phone_omni.png" ;
100
+ d [ 'changelog' ] = gerritURL + "/q/status:merged+android_device"
101
+ devicesList . push ( d )
102
+ await this . loadGithubRepos ( ) ;
96
103
} catch ( error ) {
97
104
console . log ( "display device view error: " + error ) ;
98
105
}
0 commit comments