1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-06 03:50:04 +02:00
OpenSTF/res/app/device-list/device-list-details-controller.js
Gunther Brunner 37ec53fcd7 Device details now separated from Device icon view.
Tabs are not shown if the settings are not loaded yet.
2014-05-14 19:19:13 +09:00

112 lines
2.3 KiB
JavaScript

module.exports = function DeviceListCtrlDetails(
$scope
, DeviceService
, GroupService
, ControlService
, ngTableParams
, SettingsService
, $filter
, $location
, gettext
, $q
) {
// TODO: this is not working, why?
$scope.filterEnabled = false
SettingsService.bind($scope, {
key: 'filterEnabled'
, storeName: 'DeviceList.filterEnabled'
})
$scope.statusFilter = function () {
var def = $q.defer()
var statuses = [
{ id: true
, title: gettext('Available')
}
, { id: false
, title: gettext('N/A')
}
]
def.resolve(statuses)
return def
}
$scope.tableFilter = {
usable: ''
}
// SettingsService.bind($scope, {
// key: 'tableFilter',
// storeName: 'DeviceList.tableFilter'
// })
$scope.tableSorting = {
state: 'desc' // initial sorting
}
// SettingsService.bind($scope, {
// key: 'tableSorting',
// storeName: 'DeviceList.tableSorting'
// })
// $scope.$watchCollection('tableParams.sorting()', function (data) {
// $scope.tableSorting = data
// })
//
// $scope.$watchCollection('tableParams.filter()', function (data) {
// $scope.tableFilter = data
// })
$scope.tableParams = new ngTableParams(
{ filter: $scope.tableFilter
, sorting: $scope.tableSorting
}
, { total: 1
, counts: []
, filterDelay: 0
, getData: function ($defer, params) {
var data = $scope.tracker.devices
var filteredData = params.filter() ?
$filter('filter')(data, params.filter()) :
data
var orderedData = params.sorting() ?
$filter('orderBy')(filteredData, params.orderBy()) :
data
$defer.resolve(orderedData)
}
})
$scope.$on('devices.update', function () {
$scope.tableParams.reload()
})
$scope.userContactUrl = function (mail) {
var config = {
hipchatEnabled: true
, hipchatUrl: 'https://cyberagent.hipchat.com/chat?focus_jid='
}
if (config.hipchatEnabled) {
return config.hipchatUrl + mail
} else {
return 'mailto:' + mail
}
}
$scope.columns = [
{ title: 'Model'
, field: 'model'
, sortable: 'model'
, filter: {model: 'text'}
, visible: true
}
, { title: 'Product'
, field: 'name'
, sortable: 'name'
, filter: {name: 'text'}
, visible: true
}
]
}