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:
parent
b4e30aae75
commit
e10a58c881
11 changed files with 41 additions and 89 deletions
|
@ -1,6 +1,5 @@
|
|||
module.exports = function ControlServiceFactory(
|
||||
$rootScope
|
||||
, $upload
|
||||
$upload
|
||||
, $http
|
||||
, socket
|
||||
, TransactionService
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
var oboe = require('oboe')
|
||||
var _ = require('lodash')
|
||||
|
||||
module.exports = function DeviceServiceFactory($rootScope, $http, socket) {
|
||||
module.exports = function DeviceServiceFactory($http, socket) {
|
||||
var deviceService = {}
|
||||
|
||||
function Tracker($scope, options) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function SettingsServiceFactory($rootScope, $localForage) {
|
||||
module.exports = function SettingsServiceFactory($localForage) {
|
||||
|
||||
return $localForage
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function ($scope, gettext, $rootScope, $routeParams, $location,
|
||||
module.exports = function ($scope, gettext, $routeParams, $location,
|
||||
DeviceService, GroupService, ControlService) {
|
||||
|
||||
var sharedTabs = [
|
||||
|
@ -52,18 +52,18 @@ module.exports = function ($scope, gettext, $rootScope, $routeParams, $location,
|
|||
}
|
||||
].concat(angular.copy(sharedTabs))
|
||||
|
||||
|
||||
$rootScope.device = null
|
||||
$rootScope.control = null
|
||||
$scope.device = null
|
||||
$scope.control = null
|
||||
|
||||
|
||||
DeviceService.get($routeParams.serial, $rootScope)
|
||||
DeviceService.get($routeParams.serial, $scope)
|
||||
.then(function (device) {
|
||||
return GroupService.invite(device)
|
||||
})
|
||||
.then(function (device) {
|
||||
$rootScope.device = device
|
||||
$rootScope.control = ControlService.create(device, device.channel)
|
||||
$scope.device = device
|
||||
$scope.control = ControlService.create(device, device.channel)
|
||||
|
||||
return device
|
||||
})
|
||||
.catch(function () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function ShellCtrl($scope, $rootScope, gettext) {
|
||||
module.exports = function ShellCtrl($scope, gettext) {
|
||||
// TODO: implement multiple devices
|
||||
// $scope.results = []
|
||||
$scope.result = null
|
||||
|
@ -11,7 +11,7 @@ module.exports = function ShellCtrl($scope, $rootScope, gettext) {
|
|||
return
|
||||
}
|
||||
|
||||
var cmd = $rootScope.control.shell(command)
|
||||
var cmd = $scope.control.shell(command)
|
||||
$scope.command = ''
|
||||
|
||||
return cmd.promise
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var _ = require('lodash')
|
||||
|
||||
module.exports = function ActivitiesCtrl($scope, $rootScope) {
|
||||
module.exports = function ActivitiesCtrl($scope) {
|
||||
$scope.selectedAction = ''
|
||||
$scope.selectedCategory = ''
|
||||
$scope.selectedData = ''
|
||||
|
@ -82,10 +82,11 @@ module.exports = function ActivitiesCtrl($scope, $rootScope) {
|
|||
command += ' -d ' + $scope.selectedData
|
||||
}
|
||||
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) {
|
||||
console.log(result)
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettext) {
|
||||
module.exports = function UploadCtrl($scope, SettingsService, gettext) {
|
||||
|
||||
$scope.upload = null
|
||||
$scope.installation = null
|
||||
|
@ -10,13 +10,13 @@ module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettex
|
|||
$scope.installation = null
|
||||
}
|
||||
|
||||
$rootScope.installUrl = function (url) {
|
||||
$scope.installUrl = function (url) {
|
||||
$scope.upload = {
|
||||
progress: 0,
|
||||
lastData: 'uploading'
|
||||
}
|
||||
|
||||
var upload = $rootScope.control.uploadUrl(url)
|
||||
var upload = $scope.control.uploadUrl(url)
|
||||
$scope.installation = null
|
||||
return upload.promise
|
||||
.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 = {
|
||||
progress: 0,
|
||||
lastData: 'uploading'
|
||||
}
|
||||
|
||||
var upload = $rootScope.control.uploadFile($files)
|
||||
var upload = $scope.control.uploadFile($files)
|
||||
$scope.installation = null
|
||||
return upload.promise
|
||||
.progressed(function (uploadResult) {
|
||||
|
@ -60,7 +60,7 @@ module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettex
|
|||
|
||||
$scope.maybeInstall = function (options) {
|
||||
if ($scope.installEnabled) {
|
||||
var install = $rootScope.control.install(options)
|
||||
var install = $scope.control.install(options)
|
||||
return install.promise
|
||||
.progressed(function (installResult) {
|
||||
$scope.$apply(function () {
|
||||
|
@ -79,7 +79,7 @@ module.exports = function UploadCtrl($scope, $rootScope, SettingsService, gettex
|
|||
}
|
||||
|
||||
$scope.uninstall = function (packageName) {
|
||||
var tx = $rootScope.control.uninstall(packageName)
|
||||
var tx = $scope.control.uninstall(packageName)
|
||||
return tx.promise.then(function (result) {
|
||||
if (result.success) {
|
||||
$scope.$apply(function () {
|
||||
|
|
|
@ -14,15 +14,15 @@
|
|||
|
||||
//.col-md-10.col-md-offset-1
|
||||
.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
|
||||
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')
|
||||
i.fa.fa-upload
|
||||
|
||||
.drop-area(ng-file-drop='$root.installFile($files)').file-input.btn-file
|
||||
input(type='file', ng-file-select='$root.installFile($files)')
|
||||
.drop-area(ng-file-drop='installFile($files)').file-input.btn-file
|
||||
input(type='file', ng-file-select='installFile($files)')
|
||||
|
||||
i.fa.fa-2x.fa-download.drop-area-icon
|
||||
p.drop-area-text(translate) Drop file to upload
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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)
|
||||
|
||||
|
@ -9,14 +9,14 @@ module.exports = function DeviceControlCtrl($scope, $rootScope, DeviceService, G
|
|||
$scope.kickDevice = function (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 ($scope.groupDevices.length > 1) {
|
||||
|
||||
// Control first free device first
|
||||
var firstFreeDevice = _.find($scope.groupDevices, function (dev) {
|
||||
return dev.serial !== $rootScope.device.serial
|
||||
return dev.serial !== $scope.device.serial
|
||||
})
|
||||
$scope.controlDevice(firstFreeDevice)
|
||||
|
||||
|
@ -41,46 +41,4 @@ module.exports = function DeviceControlCtrl($scope, $rootScope, DeviceService, G
|
|||
$scope.controlDevice = function (device) {
|
||||
$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('/')
|
||||
// })
|
||||
//}
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
.stf-vnc-navbar.as-row
|
||||
|
||||
.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
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
p
|
||||
.device-small-image
|
||||
img(ng-src='{{$root.device.image ? "/static/devices/" + $root.device.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}')
|
||||
span {{ $root.device.name }}
|
||||
img(ng-src='{{device.image ? "/static/devices/" + device.image : "/static/bower_components/stf-graphics/devices/small/default.jpg" }}')
|
||||
span {{ device.name }}
|
||||
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')
|
||||
li(ng-repeat='groupDevice in groupDevices')
|
||||
a(ng-click='controlDevice(groupDevice); $event.stopPropagation()')
|
||||
.device-small-image
|
||||
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
|
||||
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')
|
||||
device-screen(style='width: 400px; height: 600px; background: gray')
|
||||
|
||||
.stf-vnc-bottom.as-row
|
||||
.controls
|
||||
.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
|
||||
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
|
||||
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
|
||||
|
|
|
@ -21,11 +21,5 @@ module.exports = angular.module('control-panes', [
|
|||
controller: 'ControlPanesCtrl'
|
||||
})
|
||||
}])
|
||||
// .config(['$routeProvider', function ($routeProvider) {
|
||||
// $routeProvider.when('/control-panes', {
|
||||
// template: require('./control-panes.jade'),
|
||||
// controller: 'ControlPanesCtrl'
|
||||
// })
|
||||
// }])
|
||||
.factory('ControlPanesService', require('./control-panes-service'))
|
||||
.controller('ControlPanesCtrl', require('./control-panes-controller'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue