diff --git a/res/app/components/stf/control/control-service.js b/res/app/components/stf/control/control-service.js index a7cfdf1f..c4035955 100644 --- a/res/app/components/stf/control/control-service.js +++ b/res/app/components/stf/control/control-service.js @@ -1,6 +1,5 @@ module.exports = function ControlServiceFactory( - $rootScope -, $upload + $upload , $http , socket , TransactionService diff --git a/res/app/components/stf/device/device-service.js b/res/app/components/stf/device/device-service.js index 0ded8e08..f7fd0511 100644 --- a/res/app/components/stf/device/device-service.js +++ b/res/app/components/stf/device/device-service.js @@ -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) { diff --git a/res/app/components/stf/settings/settings-service.js b/res/app/components/stf/settings/settings-service.js index b7e9b312..82c3f1fd 100644 --- a/res/app/components/stf/settings/settings-service.js +++ b/res/app/components/stf/settings/settings-service.js @@ -1,4 +1,4 @@ -module.exports = function SettingsServiceFactory($rootScope, $localForage) { +module.exports = function SettingsServiceFactory($localForage) { return $localForage } diff --git a/res/app/control-panes/control-panes-controller.js b/res/app/control-panes/control-panes-controller.js index 42b26cc3..ad91776f 100644 --- a/res/app/control-panes/control-panes-controller.js +++ b/res/app/control-panes/control-panes-controller.js @@ -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 () { diff --git a/res/app/control-panes/dashboard/shell/shell-controller.js b/res/app/control-panes/dashboard/shell/shell-controller.js index 950d7482..fb8284fa 100644 --- a/res/app/control-panes/dashboard/shell/shell-controller.js +++ b/res/app/control-panes/dashboard/shell/shell-controller.js @@ -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 diff --git a/res/app/control-panes/dashboard/upload/activities/activities-controller.js b/res/app/control-panes/dashboard/upload/activities/activities-controller.js index 991c60fd..11fd76dd 100644 --- a/res/app/control-panes/dashboard/upload/activities/activities-controller.js +++ b/res/app/control-panes/dashboard/upload/activities/activities-controller.js @@ -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) }) diff --git a/res/app/control-panes/dashboard/upload/upload-controller.js b/res/app/control-panes/dashboard/upload/upload-controller.js index 40a1d26b..19203afc 100644 --- a/res/app/control-panes/dashboard/upload/upload-controller.js +++ b/res/app/control-panes/dashboard/upload/upload-controller.js @@ -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 () { diff --git a/res/app/control-panes/dashboard/upload/upload.jade b/res/app/control-panes/dashboard/upload/upload.jade index 7b7e1c5d..55a190bb 100644 --- a/res/app/control-panes/dashboard/upload/upload.jade +++ b/res/app/control-panes/dashboard/upload/upload.jade @@ -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 diff --git a/res/app/control-panes/device-control/device-control-controller.js b/res/app/control-panes/device-control/device-control-controller.js index 81c30241..71c48d63 100644 --- a/res/app/control-panes/device-control/device-control-controller.js +++ b/res/app/control-panes/device-control/device-control-controller.js @@ -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('/') -// }) -//} diff --git a/res/app/control-panes/device-control/device-control.jade b/res/app/control-panes/device-control/device-control.jade index 032b5892..d9704f48 100644 --- a/res/app/control-panes/device-control/device-control.jade +++ b/res/app/control-panes/device-control/device-control.jade @@ -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 diff --git a/res/app/control-panes/index.js b/res/app/control-panes/index.js index 78b77acf..48fb4035 100644 --- a/res/app/control-panes/index.js +++ b/res/app/control-panes/index.js @@ -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'))