1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

Refactoring to use Google Angular Best Practices.

This commit is contained in:
Gunther Brunner 2014-02-18 19:26:30 +09:00
parent 6df8ed7184
commit 80d0bb7ad2
12 changed files with 29 additions and 49 deletions

View file

@ -6,7 +6,8 @@ var pathutil = require('../util/pathutil')
module.exports = webpackMiddleware(webpack({
cache: true,
debug: true,
devtool: 'eval-source-map',
// devtool: 'eval-source-map',
devtool: 'eval',
entry: pathutil.resource('app') + '/app.js',
output: {
path: '/static/build/',

View file

@ -1,9 +1,11 @@
require('angular')
require('angular-route')
require('./app-styles')
angular.module('app', [
'ngRoute',
require('./components/device-list').name
require('./device-list').name
])
.config(['$routeProvider', '$locationProvider',
function ($routeProvider, $locationProvider) {

View file

@ -9,4 +9,4 @@ module.exports = angular.module('device-list', [])
controller: 'DeviceListCtrl'
})
}])
.controller('DeviceListCtrl', require('./DeviceListCtrl'));
.controller('DeviceListCtrl', require('./device-list-controller'));

View file

@ -1,46 +0,0 @@
module.exports = function DeviceListCtrl($scope) {
$scope.devices = [
{serial: '1231231', present: true, owner: {email: 'fefe@f.com'}},
{serial: '123122', present: true, owner: {email: 'fefe2@f.com'}}
];
$scope.invite = function (device) {
groupService.invite({
serial: {
value: device.serial, match: 'exact'
}
})
}
$scope.kick = function (device) {
groupService.kick({
serial: {
value: device.serial, match: 'exact'
}
})
}
};
//module.exports = function DeviceListCtrl($scope, deviceService, groupService) {
//
// $scope.devices = deviceService.devices
//
// $scope.invite = function (device) {
// groupService.invite({
// serial: {
// value: device.serial, match: 'exact'
// }
// })
// }
//
// $scope.kick = function (device) {
// groupService.kick({
// serial: {
// value: device.serial, match: 'exact'
// }
// })
// }
//}

View file

@ -0,0 +1,4 @@
require('angular')
module.exports = angular.module('socket', [])
.factory('SocketService', require('./socket-service'));

View file

@ -0,0 +1,6 @@
var io = require('socket.io')
module.exports = function SocketServiceFactory() {
var socketService = io.connect()
return socketService
}

View file

View file

@ -0,0 +1,13 @@
require('angular')
require('./device-list.css')
module.exports = angular.module('device-list', [
require('./../components/socket').name
])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/devices', {
template: require('./device-list.jade'),
controller: 'DeviceListCtrl'
})
}])
.controller('DeviceListCtrl', require('./device-list-controller'))