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

Removing $rootScope for device and control, not needed anymore.

This commit is contained in:
Gunther Brunner 2014-04-08 20:50:35 +09:00
parent b4e30aae75
commit e10a58c881
11 changed files with 41 additions and 89 deletions

View file

@ -1,6 +1,5 @@
module.exports = function ControlServiceFactory( module.exports = function ControlServiceFactory(
$rootScope $upload
, $upload
, $http , $http
, socket , socket
, TransactionService , TransactionService

View file

@ -1,7 +1,7 @@
var oboe = require('oboe') var oboe = require('oboe')
var _ = require('lodash') var _ = require('lodash')
module.exports = function DeviceServiceFactory($rootScope, $http, socket) { module.exports = function DeviceServiceFactory($http, socket) {
var deviceService = {} var deviceService = {}
function Tracker($scope, options) { function Tracker($scope, options) {

View file

@ -1,4 +1,4 @@
module.exports = function SettingsServiceFactory($rootScope, $localForage) { module.exports = function SettingsServiceFactory($localForage) {
return $localForage return $localForage
} }

View file

@ -1,4 +1,4 @@
module.exports = function ($scope, gettext, $rootScope, $routeParams, $location, module.exports = function ($scope, gettext, $routeParams, $location,
DeviceService, GroupService, ControlService) { DeviceService, GroupService, ControlService) {
var sharedTabs = [ var sharedTabs = [
@ -52,18 +52,18 @@ module.exports = function ($scope, gettext, $rootScope, $routeParams, $location,
} }
].concat(angular.copy(sharedTabs)) ].concat(angular.copy(sharedTabs))
$scope.device = null
$rootScope.device = null $scope.control = null
$rootScope.control = null
DeviceService.get($routeParams.serial, $rootScope) DeviceService.get($routeParams.serial, $scope)
.then(function (device) { .then(function (device) {
return GroupService.invite(device) return GroupService.invite(device)
}) })
.then(function (device) { .then(function (device) {
$rootScope.device = device $scope.device = device
$rootScope.control = ControlService.create(device, device.channel) $scope.control = ControlService.create(device, device.channel)
return device return device
}) })
.catch(function () { .catch(function () {

View file

@ -1,4 +1,4 @@
module.exports = function ShellCtrl($scope, $rootScope, gettext) { module.exports = function ShellCtrl($scope, gettext) {
// TODO: implement multiple devices // TODO: implement multiple devices
// $scope.results = [] // $scope.results = []
$scope.result = null $scope.result = null
@ -11,7 +11,7 @@ module.exports = function ShellCtrl($scope, $rootScope, gettext) {
return return
} }
var cmd = $rootScope.control.shell(command) var cmd = $scope.control.shell(command)
$scope.command = '' $scope.command = ''
return cmd.promise return cmd.promise

View file

@ -1,6 +1,6 @@
var _ = require('lodash') var _ = require('lodash')
module.exports = function ActivitiesCtrl($scope, $rootScope) { module.exports = function ActivitiesCtrl($scope) {
$scope.selectedAction = '' $scope.selectedAction = ''
$scope.selectedCategory = '' $scope.selectedCategory = ''
$scope.selectedData = '' $scope.selectedData = ''
@ -82,10 +82,11 @@ module.exports = function ActivitiesCtrl($scope, $rootScope) {
command += ' -d ' + $scope.selectedData command += ' -d ' + $scope.selectedData
} }
if ($scope.selectedPackageName && $scope.selectedActivityName) { if ($scope.selectedPackageName && $scope.selectedActivityName) {
command += ' -n ' + $scope.selectedPackageName + '/' + $scope.selectedActivityName command += ' -n ' +
$scope.selectedPackageName + '/' + $scope.selectedActivityName
} }
var cmd = $rootScope.control.shell(command) var cmd = $scope.control.shell(command)
return cmd.promise.then(function (result) { return cmd.promise.then(function (result) {
console.log(result) console.log(result)
}) })

View file

@ -1,4 +1,4 @@
module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettext) { module.exports = function UploadCtrl($scope, SettingsService, gettext) {
$scope.upload = null $scope.upload = null
$scope.installation = null $scope.installation = null
@ -10,13 +10,13 @@ module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettex
$scope.installation = null $scope.installation = null
} }
$rootScope.installUrl = function (url) { $scope.installUrl = function (url) {
$scope.upload = { $scope.upload = {
progress: 0, progress: 0,
lastData: 'uploading' lastData: 'uploading'
} }
var upload = $rootScope.control.uploadUrl(url) var upload = $scope.control.uploadUrl(url)
$scope.installation = null $scope.installation = null
return upload.promise return upload.promise
.progressed(function (uploadResult) { .progressed(function (uploadResult) {
@ -34,13 +34,13 @@ module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettex
}) })
} }
$rootScope.installFile = function ($files) { $scope.installFile = function ($files) {
$scope.upload = { $scope.upload = {
progress: 0, progress: 0,
lastData: 'uploading' lastData: 'uploading'
} }
var upload = $rootScope.control.uploadFile($files) var upload = $scope.control.uploadFile($files)
$scope.installation = null $scope.installation = null
return upload.promise return upload.promise
.progressed(function (uploadResult) { .progressed(function (uploadResult) {
@ -60,7 +60,7 @@ module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettex
$scope.maybeInstall = function (options) { $scope.maybeInstall = function (options) {
if ($scope.installEnabled) { if ($scope.installEnabled) {
var install = $rootScope.control.install(options) var install = $scope.control.install(options)
return install.promise return install.promise
.progressed(function (installResult) { .progressed(function (installResult) {
$scope.$apply(function () { $scope.$apply(function () {
@ -79,7 +79,7 @@ module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettex
} }
$scope.uninstall = function (packageName) { $scope.uninstall = function (packageName) {
var tx = $rootScope.control.uninstall(packageName) var tx = $scope.control.uninstall(packageName)
return tx.promise.then(function (result) { return tx.promise.then(function (result) {
if (result.success) { if (result.success) {
$scope.$apply(function () { $scope.$apply(function () {

View file

@ -14,15 +14,15 @@
//.col-md-10.col-md-offset-1 //.col-md-10.col-md-offset-1
.input-group.form-inline .input-group.form-inline
input(type=text, ng-model='remoteUrl', ng-enter='$root.installUrl(remoteUrl)', input(type=text, ng-model='remoteUrl', ng-enter='installUrl(remoteUrl)',
placeholder='http://...').form-control placeholder='http://...').form-control
span.input-group-btn span.input-group-btn
button.btn.btn-primary-outline(ng-click='$root.installUrl(remoteUrl)', button.btn.btn-primary-outline(ng-click='installUrl(remoteUrl)',
tooltip='Upload From Link', ng-disabled='!remoteUrl') tooltip='Upload From Link', ng-disabled='!remoteUrl')
i.fa.fa-upload i.fa.fa-upload
.drop-area(ng-file-drop='$root.installFile($files)').file-input.btn-file .drop-area(ng-file-drop='installFile($files)').file-input.btn-file
input(type='file', ng-file-select='$root.installFile($files)') input(type='file', ng-file-select='installFile($files)')
i.fa.fa-2x.fa-download.drop-area-icon i.fa.fa-2x.fa-download.drop-area-icon
p.drop-area-text(translate) Drop file to upload p.drop-area-text(translate) Drop file to upload

View file

@ -1,6 +1,6 @@
var _ = require('lodash') var _ = require('lodash')
module.exports = function DeviceControlCtrl($scope, $rootScope, DeviceService, GroupService, $location) { module.exports = function DeviceControlCtrl($scope, DeviceService, GroupService, $location) {
$scope.groupTracker = DeviceService.trackGroup($scope) $scope.groupTracker = DeviceService.trackGroup($scope)
@ -9,14 +9,14 @@ module.exports = function DeviceControlCtrl($scope, $rootScope, DeviceService, G
$scope.kickDevice = function (device) { $scope.kickDevice = function (device) {
// If we're trying to kick current device // If we're trying to kick current device
if (device.serial === $rootScope.device.serial) { if (device.serial === $scope.device.serial) {
// If there is more than one device left // If there is more than one device left
if ($scope.groupDevices.length > 1) { if ($scope.groupDevices.length > 1) {
// Control first free device first // Control first free device first
var firstFreeDevice = _.find($scope.groupDevices, function (dev) { var firstFreeDevice = _.find($scope.groupDevices, function (dev) {
return dev.serial !== $rootScope.device.serial return dev.serial !== $scope.device.serial
}) })
$scope.controlDevice(firstFreeDevice) $scope.controlDevice(firstFreeDevice)
@ -41,46 +41,4 @@ module.exports = function DeviceControlCtrl($scope, $rootScope, DeviceService, G
$scope.controlDevice = function (device) { $scope.controlDevice = function (device) {
$location.path('/control/' + device.serial) $location.path('/control/' + device.serial)
} }
} }
// $scope
//, $routeParams
//, $location
//, DeviceService
//, GroupService
//, ControlService
//) {
// $scope.device = null
// $scope.control = null
// $scope.installation = null
//
// $scope.install = function($files) {
// return $scope.control.install($files)
// .then(function(tx) {
// return tx.promise
// .progressed(function(result) {
// $scope.$apply(function() {
// $scope.installation = result
// })
// })
// .then(function(result) {
// $scope.$apply(function() {
// $scope.installation = result
// })
// })
// })
// }
//
// DeviceService.get($routeParams.serial, $scope)
// .then(function(device) {
// return GroupService.invite(device)
// })
// .then(function(device) {
// $scope.device = device
// $scope.control = ControlService.create(device, device.channel)
// return device
// })
// .catch(function() {
// $location.path('/')
// })
//}

View file

@ -5,13 +5,13 @@
.stf-vnc-navbar.as-row .stf-vnc-navbar.as-row
.pull-right .pull-right
button(ng-click='$root.control.identify()', tooltip='Find Device', tooltip-placement='bottom').btn.btn-sm.btn-info-outline button(ng-click='control.identify()', tooltip='Find Device', tooltip-placement='bottom').btn.btn-sm.btn-info-outline
i.fa.fa-info i.fa.fa-info
span span
button(type='button', ng-click='$root.control.rotate(0)', tooltip='Portrait', tooltip-placement='bottom').btn.btn-sm.btn-primary-outline button(type='button', ng-click='control.rotate(0)', tooltip='Portrait', tooltip-placement='bottom').btn.btn-sm.btn-primary-outline
i.fa.fa-mobile i.fa.fa-mobile
button(type='button', ng-click='$root.control.rotate(90)', tooltip='Landscape', tooltip-placement='bottom').btn.btn-sm.btn-primary-outline button(type='button', ng-click='control.rotate(90)', tooltip='Landscape', tooltip-placement='bottom').btn.btn-sm.btn-primary-outline
i.fa.fa-mobile.fa-rotate-90 i.fa.fa-mobile.fa-rotate-90
button(type='button', ng-model='showScreen', btn-checkbox).btn.btn-sm.btn-danger button(type='button', ng-model='showScreen', btn-checkbox).btn.btn-sm.btn-danger
@ -22,31 +22,31 @@
a.stf-vnc-device-name.pointer.unselectable.dropdown-toggle a.stf-vnc-device-name.pointer.unselectable.dropdown-toggle
p p
.device-small-image .device-small-image
img(ng-src='{{$root.device.image ? "/static/devices/" + $root.device.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}') img(ng-src='{{device.image ? "/static/devices/" + device.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}')
span {{ $root.device.name }} span {{ device.name }}
span.caret(ng-show='groupDevices.length > 0') span.caret(ng-show='groupDevices.length > 0')
span(ng-show='$root.device && !$root.device.present', translate) (Absent) span(ng-show='device && !device.present', translate) (Absent)
ul.dropdown-menu.pointer.unselectable(ng-show='groupDevices.length > 0') ul.dropdown-menu.pointer.unselectable(ng-show='groupDevices.length > 0')
li(ng-repeat='groupDevice in groupDevices') li(ng-repeat='groupDevice in groupDevices')
a(ng-click='controlDevice(groupDevice); $event.stopPropagation()') a(ng-click='controlDevice(groupDevice); $event.stopPropagation()')
.device-small-image .device-small-image
img(ng-src='{{groupDevice.image ? "/static/devices/" + groupDevice.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}') img(ng-src='{{groupDevice.image ? "/static/devices/" + groupDevice.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}')
span(ng-class='{"current-device": groupDevice.serial === $root.device.serial }') {{ groupDevice.name }} span(ng-class='{"current-device": groupDevice.serial === device.serial }') {{ groupDevice.name }}
span.pull-right(ng-click='kickDevice(groupDevice); $event.stopPropagation()').kick-device span.pull-right(ng-click='kickDevice(groupDevice); $event.stopPropagation()').kick-device
i.fa.fa-times i.fa.fa-times
.as-row.fill-height(ng-file-drop='$root.install($files)') .as-row.fill-height(ng-file-drop='controll.install($files)')
div(ng-controller='DeviceScreenCtrl') div(ng-controller='DeviceScreenCtrl')
device-screen(style='width: 400px; height: 600px; background: gray') device-screen(style='width: 400px; height: 600px; background: gray')
.stf-vnc-bottom.as-row .stf-vnc-bottom.as-row
.controls .controls
.btn-group.btn-group-justified .btn-group.btn-group-justified
a(ng-click='$root.control.menu()', title='{{"Menu"|translate}}').btn.btn-primary.btn-lg a(ng-click='control.menu()', title='{{"Menu"|translate}}').btn.btn-primary.btn-lg
i.fa.fa-bars i.fa.fa-bars
a(ng-click='$root.control.home()', title='{{"Home"|translate}}').btn.btn-primary.btn-lg a(ng-click='control.home()', title='{{"Home"|translate}}').btn.btn-primary.btn-lg
i.fa.fa-home i.fa.fa-home
a(ng-click='$root.control.back()', title='{{"Back"|translate}}').btn.btn-primary.btn-lg a(ng-click='control.back()', title='{{"Back"|translate}}').btn.btn-primary.btn-lg
i.fa.fa-mail-reply i.fa.fa-mail-reply

View file

@ -21,11 +21,5 @@ module.exports = angular.module('control-panes', [
controller: 'ControlPanesCtrl' controller: 'ControlPanesCtrl'
}) })
}]) }])
// .config(['$routeProvider', function ($routeProvider) {
// $routeProvider.when('/control-panes', {
// template: require('./control-panes.jade'),
// controller: 'ControlPanesCtrl'
// })
// }])
.factory('ControlPanesService', require('./control-panes-service')) .factory('ControlPanesService', require('./control-panes-service'))
.controller('ControlPanesCtrl', require('./control-panes-controller')) .controller('ControlPanesCtrl', require('./control-panes-controller'))