1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +02:00

Add browser icons. Currently requires stf-browser-db to be npm linked to work.

This commit is contained in:
Simo Kinnunen 2014-05-08 18:58:13 +09:00
parent 76b9555f4a
commit 0c24cb7ec6
7 changed files with 68 additions and 31 deletions

View file

@ -1,4 +1,5 @@
var deviceData = require('stf-devices-db')
var browserData = require('stf-browser-db')
var express = require('express')
var pathutil = require('./pathutil')
@ -53,6 +54,18 @@ datautil.applyData = function(device) {
return device
}
datautil.applyBrowsers = function(device) {
if (device.browser) {
device.browser.apps.forEach(function(app) {
var data = browserData[app.type]
if (data) {
app.developer = data.developer
}
})
}
return device
}
datautil.applyOwner = function(device, user) {
device.using = !!device.owner && device.owner.email === user.email
return device
@ -60,12 +73,9 @@ datautil.applyOwner = function(device, user) {
datautil.normalize = function(device, user) {
datautil.applyData(device)
datautil.applyBrowsers(device)
datautil.applyOwner(device, user)
if (!device.present) {
device.owner = null
}
}
datautil.middleware = function() {
return express.static(pathutil.root('node_modules/stf-devices-db/data/small'))
}