mirror of
https://github.com/openstf/stf
synced 2025-10-06 03:50:04 +02:00
add groups feature
This commit is contained in:
parent
6fd750dad5
commit
7f5dc4c152
119 changed files with 12416 additions and 402 deletions
|
@ -1,3 +1,7 @@
|
|||
/**
|
||||
* Copyright © 2019 contains code contributed by Orange SA, authors: Denis Barbaron - Licensed under the Apache license 2.0
|
||||
**/
|
||||
|
||||
var _ = require('lodash')
|
||||
|
||||
var filterOps = {
|
||||
|
@ -18,7 +22,7 @@ var filterOps = {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = function DeviceColumnService($filter, gettext) {
|
||||
module.exports = function DeviceColumnService($filter, gettext, SettingsService, AppState) {
|
||||
// Definitions for all possible values.
|
||||
return {
|
||||
state: DeviceStatusCell({
|
||||
|
@ -27,6 +31,52 @@ module.exports = function DeviceColumnService($filter, gettext) {
|
|||
return $filter('translate')(device.enhancedStateAction)
|
||||
}
|
||||
})
|
||||
, group: TextCell({
|
||||
title: gettext('Group Name')
|
||||
, value: function(device) {
|
||||
return $filter('translate')(device.group.name)
|
||||
}
|
||||
})
|
||||
, groupSchedule: TextCell({
|
||||
title: gettext('Group Class')
|
||||
, value: function(device) {
|
||||
return $filter('translate')(device.group.class)
|
||||
}
|
||||
})
|
||||
, groupOwner: LinkCell({
|
||||
title: gettext('Group Owner')
|
||||
, target: '_blank'
|
||||
, value: function(device) {
|
||||
return $filter('translate')(device.group.owner.name)
|
||||
}
|
||||
, link: function(device) {
|
||||
return device.enhancedGroupOwnerProfileUrl
|
||||
}
|
||||
})
|
||||
, groupEndTime: TextCell({
|
||||
title: gettext('Group Expiration Date')
|
||||
, value: function(device) {
|
||||
return $filter('date')(device.group.lifeTime.stop, SettingsService.get('dateFormat'))
|
||||
}
|
||||
})
|
||||
, groupStartTime: TextCell({
|
||||
title: gettext('Group Starting Date')
|
||||
, value: function(device) {
|
||||
return $filter('date')(device.group.lifeTime.start, SettingsService.get('dateFormat'))
|
||||
}
|
||||
})
|
||||
, groupRepetitions: TextCell({
|
||||
title: gettext('Group Repetitions')
|
||||
, value: function(device) {
|
||||
return device.group.repetitions
|
||||
}
|
||||
})
|
||||
, groupOrigin: TextCell({
|
||||
title: gettext('Group Origin')
|
||||
, value: function(device) {
|
||||
return $filter('translate')(device.group.originName)
|
||||
}
|
||||
})
|
||||
, model: DeviceModelCell({
|
||||
title: gettext('Model')
|
||||
, value: function(device) {
|
||||
|
@ -38,7 +88,7 @@ module.exports = function DeviceColumnService($filter, gettext) {
|
|||
, value: function(device) {
|
||||
return device.name || device.model || device.serial
|
||||
}
|
||||
})
|
||||
}, AppState.user.email)
|
||||
, operator: TextCell({
|
||||
title: gettext('Carrier')
|
||||
, value: function(device) {
|
||||
|
@ -305,8 +355,10 @@ function zeroPadTwoDigit(digit) {
|
|||
}
|
||||
|
||||
function compareIgnoreCase(a, b) {
|
||||
var la = (a || '').toLowerCase()
|
||||
var lb = (b || '').toLowerCase()
|
||||
/***** fix bug: cast to String for Safari compatibility ****/
|
||||
var la = (String(a) || '').toLowerCase()
|
||||
var lb = (String(b) || '').toLowerCase()
|
||||
/***********************************************************/
|
||||
if (la === lb) {
|
||||
return 0
|
||||
}
|
||||
|
@ -316,8 +368,10 @@ function compareIgnoreCase(a, b) {
|
|||
}
|
||||
|
||||
function filterIgnoreCase(a, filterValue) {
|
||||
var va = (a || '').toLowerCase()
|
||||
var vb = filterValue.toLowerCase()
|
||||
/***** fix bug: cast to String for Safari compatibility ****/
|
||||
var va = (String(a) || '').toLowerCase()
|
||||
var vb = String(filterValue).toLowerCase()
|
||||
/***********************************************************/
|
||||
return va.indexOf(vb) !== -1
|
||||
}
|
||||
|
||||
|
@ -551,7 +605,7 @@ function DeviceModelCell(options) {
|
|||
})
|
||||
}
|
||||
|
||||
function DeviceNameCell(options) {
|
||||
function DeviceNameCell(options, ownerEmail) {
|
||||
return _.defaults(options, {
|
||||
title: options.title
|
||||
, defaultOrder: 'asc'
|
||||
|
@ -566,11 +620,11 @@ function DeviceNameCell(options) {
|
|||
var a = td.firstChild
|
||||
var t = a.firstChild
|
||||
|
||||
if (device.using) {
|
||||
if (device.using && device.owner.email === ownerEmail) {
|
||||
a.className = 'device-product-name-using'
|
||||
a.href = '#!/control/' + device.serial
|
||||
}
|
||||
else if (device.usable) {
|
||||
else if (device.usable && !device.using) {
|
||||
a.className = 'device-product-name-usable'
|
||||
a.href = '#!/control/' + device.serial
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue