diff --git a/lib/browser/app.js b/lib/browser/app.js
index c941effd..a276384d 100644
--- a/lib/browser/app.js
+++ b/lib/browser/app.js
@@ -30,30 +30,27 @@ require('angular-ui-router');
require('./browser/models/selection-state');
require('./browser/modules/drive-scanner');
require('./browser/modules/image-writer');
-require('./browser/modules/path');
-require('./browser/modules/notifier');
require('./browser/modules/analytics');
-require('./browser/modules/notification');
require('./browser/components/progress-button/progress-button');
require('./browser/components/drive-selector/drive-selector');
require('./browser/pages/finish/finish');
require('./browser/pages/settings/settings');
-require('./browser/utils/window-progress/window-progress');
-require('./browser/utils/open-external/open-external');
+require('./browser/os/notification/notification');
+require('./browser/os/window-progress/window-progress');
+require('./browser/os/open-external/open-external');
+require('./browser/os/dropzone/dropzone');
require('./browser/utils/if-state/if-state');
-require('./browser/utils/dropzone/dropzone');
+require('./browser/utils/notifier/notifier');
+require('./browser/utils/path/path');
const app = angular.module('Etcher', [
'ui.router',
'ui.bootstrap',
// Etcher modules
- 'Etcher.path',
'Etcher.drive-scanner',
'Etcher.image-writer',
- 'Etcher.notifier',
'Etcher.analytics',
- 'Etcher.notification',
// Models
'Etcher.Models.SelectionState',
@@ -67,11 +64,16 @@ const app = angular.module('Etcher', [
'Etcher.Pages.Finish',
'Etcher.Pages.Settings',
+ // OS
+ 'Etcher.OS.WindowProgress',
+ 'Etcher.OS.OpenExternal',
+ 'Etcher.OS.Dropzone',
+ 'Etcher.OS.Notification',
+
// Utils
- 'Etcher.Utils.WindowProgress',
- 'Etcher.Utils.OpenExternal',
'Etcher.Utils.IfState',
- 'Etcher.Utils.Dropzone'
+ 'Etcher.Utils.Notifier',
+ 'Etcher.Utils.Path'
]);
app.run(function(AnalyticsService) {
@@ -100,8 +102,8 @@ app.controller('AppController', function(
ImageWriterService,
AnalyticsService,
DriveSelectorService,
- WindowProgressService,
- NotificationService
+ OSWindowProgressService,
+ OSNotificationService
) {
let self = this;
this.selection = SelectionStateModel;
@@ -128,7 +130,7 @@ app.controller('AppController', function(
NotifierService.subscribe($scope, 'image-writer:state', function(state) {
AnalyticsService.log(`Progress (${state.type}): ${state.progress}% at ${state.speed} MB/s`);
- WindowProgressService.set(state.progress);
+ OSWindowProgressService.set(state.progress);
});
this.scanner.start(2000).on('error', dialog.showError).on('scan', function(drives) {
@@ -257,15 +259,15 @@ app.controller('AppController', function(
self.success = success;
if (self.success) {
- NotificationService.send('Success!', 'Your flash is complete');
+ OSNotificationService.send('Success!', 'Your flash is complete');
AnalyticsService.logEvent('Done');
$state.go('success');
} else {
- NotificationService.send('Oops!', 'Looks like your flash has failed');
+ OSNotificationService.send('Oops!', 'Looks like your flash has failed');
AnalyticsService.logEvent('Flash error');
}
})
.catch(dialog.showError)
- .finally(WindowProgressService.clear);
+ .finally(OSWindowProgressService.clear);
};
});
diff --git a/lib/browser/modules/image-writer.js b/lib/browser/modules/image-writer.js
index 2e8319a9..71ff02b1 100644
--- a/lib/browser/modules/image-writer.js
+++ b/lib/browser/modules/image-writer.js
@@ -30,10 +30,10 @@ if (window.mocha) {
}
require('../models/settings');
-require('./notifier');
+require('../utils/notifier/notifier');
const imageWriter = angular.module('Etcher.image-writer', [
'Etcher.Models.Settings',
- 'Etcher.notifier'
+ 'Etcher.Utils.Notifier'
]);
imageWriter.service('ImageWriterService', function($q, $timeout, SettingsModel, NotifierService) {
diff --git a/lib/browser/utils/dropzone/directives/dropzone.js b/lib/browser/os/dropzone/directives/dropzone.js
similarity index 93%
rename from lib/browser/utils/dropzone/directives/dropzone.js
rename to lib/browser/os/dropzone/directives/dropzone.js
index a2bb9350..7c4183b0 100644
--- a/lib/browser/utils/dropzone/directives/dropzone.js
+++ b/lib/browser/os/dropzone/directives/dropzone.js
@@ -31,13 +31,13 @@ const _ = require('lodash');
* @returns {Object} directive
*
* @example
- *
Drag a file here
+ * Drag a file here
*/
module.exports = function($timeout) {
return {
restrict: 'A',
scope: {
- dropzone: '&'
+ osDropzone: '&'
},
link: function(scope, element) {
const domElement = element[0];
@@ -55,7 +55,7 @@ module.exports = function($timeout) {
// Safely bring this to the word of Angular
$timeout(function() {
- scope.dropzone({
+ scope.osDropzone({
// Pass the filename as a named
// parameter called `$file`
diff --git a/lib/browser/utils/dropzone/dropzone.js b/lib/browser/os/dropzone/dropzone.js
similarity index 80%
rename from lib/browser/utils/dropzone/dropzone.js
rename to lib/browser/os/dropzone/dropzone.js
index a6d41600..bbb04ba5 100644
--- a/lib/browser/utils/dropzone/dropzone.js
+++ b/lib/browser/os/dropzone/dropzone.js
@@ -17,9 +17,9 @@
'use strict';
/**
- * @module Etcher.Utils.Dropzone
+ * @module Etcher.OS.Dropzone
*/
const angular = require('angular');
-const Dropzone = angular.module('Etcher.Utils.Dropzone', []);
-Dropzone.directive('dropzone', require('./directives/dropzone'));
+const OSDropzone = angular.module('Etcher.OS.Dropzone', []);
+OSDropzone.directive('osDropzone', require('./directives/dropzone'));
diff --git a/lib/browser/os/notification/notification.js b/lib/browser/os/notification/notification.js
new file mode 100644
index 00000000..1f0a70f4
--- /dev/null
+++ b/lib/browser/os/notification/notification.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016 Resin.io
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+/**
+ * @module Etcher.OS.Notification
+ *
+ * The purpose of this module is to provide an easy way
+ * to send desktop notifications.
+ */
+
+const angular = require('angular');
+const OSNotification = angular.module('Etcher.OS.Notification', []);
+OSNotification.service('OSNotificationService', require('./services/notification'));
diff --git a/lib/browser/modules/notification.js b/lib/browser/os/notification/services/notification.js
similarity index 79%
rename from lib/browser/modules/notification.js
rename to lib/browser/os/notification/services/notification.js
index 4ba982ac..844b913e 100644
--- a/lib/browser/modules/notification.js
+++ b/lib/browser/os/notification/services/notification.js
@@ -16,16 +16,9 @@
'use strict';
-/**
- * @module Etcher.notification
- */
-
-const angular = require('angular');
const electron = require('electron');
-const app = electron.remote.app;
-const notification = angular.module('Etcher.notification', []);
-notification.service('NotificationService', function() {
+module.exports = function() {
/**
* @summary Send a notification
@@ -42,7 +35,7 @@ notification.service('NotificationService', function() {
* @returns {Object} HTML5 notification object
*
* @example
- * const notification = NotificationService.send('Hello', 'Foo Bar Bar');
+ * const notification = OSNotificationService.send('Hello', 'Foo Bar Bar');
* notification.onclick = function() {
* console.log('The notification has been clicked');
* };
@@ -50,8 +43,8 @@ notification.service('NotificationService', function() {
this.send = function(title, body) {
// `app.dock` is only defined in OS X
- if (app.dock) {
- app.dock.bounce();
+ if (electron.remote.app.dock) {
+ electron.remote.app.dock.bounce();
}
return new Notification(title, {
@@ -59,4 +52,4 @@ notification.service('NotificationService', function() {
});
};
-});
+};
diff --git a/lib/browser/utils/open-external/directives/open-external.js b/lib/browser/os/open-external/directives/open-external.js
similarity index 91%
rename from lib/browser/utils/open-external/directives/open-external.js
rename to lib/browser/os/open-external/directives/open-external.js
index b9ced94d..c79a993e 100644
--- a/lib/browser/utils/open-external/directives/open-external.js
+++ b/lib/browser/os/open-external/directives/open-external.js
@@ -27,14 +27,14 @@ const nodeOpen = require('open');
*
* Example:
*
- *
+ *
*/
module.exports = function() {
return {
restrict: 'A',
scope: {
- openExternal: '@'
+ osOpenExternal: '@'
},
link: function(scope, element) {
@@ -59,10 +59,10 @@ module.exports = function() {
//
// See https://github.com/electron/electron/issues/5039
if (os.platform() === 'linux') {
- return nodeOpen(scope.openExternal);
+ return nodeOpen(scope.osOpenExternal);
}
- shell.openExternal(scope.openExternal);
+ shell.openExternal(scope.osOpenExternal);
});
}
};
diff --git a/lib/browser/utils/open-external/open-external.js b/lib/browser/os/open-external/open-external.js
similarity index 77%
rename from lib/browser/utils/open-external/open-external.js
rename to lib/browser/os/open-external/open-external.js
index 821e707f..b27741cb 100644
--- a/lib/browser/utils/open-external/open-external.js
+++ b/lib/browser/os/open-external/open-external.js
@@ -17,9 +17,9 @@
'use strict';
/**
- * @module Etcher.Utils.OpenExternal
+ * @module Etcher.OS.OpenExternal
*/
const angular = require('angular');
-const OpenExternal = angular.module('Etcher.Utils.OpenExternal', []);
-OpenExternal.directive('openExternal', require('./directives/open-external'));
+const OSOpenExternal = angular.module('Etcher.OS.OpenExternal', []);
+OSOpenExternal.directive('osOpenExternal', require('./directives/open-external'));
diff --git a/lib/browser/utils/window-progress/services/window-progress.js b/lib/browser/os/window-progress/services/window-progress.js
similarity index 95%
rename from lib/browser/utils/window-progress/services/window-progress.js
rename to lib/browser/os/window-progress/services/window-progress.js
index be821c6a..32908735 100644
--- a/lib/browser/utils/window-progress/services/window-progress.js
+++ b/lib/browser/os/window-progress/services/window-progress.js
@@ -45,7 +45,7 @@ module.exports = function() {
* @param {Number} percentage - percentage
*
* @example
- * WindowProgressService.set(85);
+ * OSWindowProgressService.set(85);
*/
this.set = function(percentage) {
if (percentage > 100 || percentage < 0) {
@@ -61,7 +61,7 @@ module.exports = function() {
* @public
*
* @example
- * WindowProgressService.clear();
+ * OSWindowProgressService.clear();
*/
this.clear = function() {
diff --git a/lib/browser/utils/window-progress/window-progress.js b/lib/browser/os/window-progress/window-progress.js
similarity index 80%
rename from lib/browser/utils/window-progress/window-progress.js
rename to lib/browser/os/window-progress/window-progress.js
index dfc6072c..c7b2c076 100644
--- a/lib/browser/utils/window-progress/window-progress.js
+++ b/lib/browser/os/window-progress/window-progress.js
@@ -17,7 +17,7 @@
'use strict';
/**
- * @module Etcher.Utils.WindowProgress
+ * @module Etcher.OS.WindowProgress
*
* The purpose of this module is to provide an easy way
* to interact with the operating system's window progress
@@ -25,5 +25,5 @@
*/
const angular = require('angular');
-const WindowProgress = angular.module('Etcher.Utils.WindowProgress', []);
-WindowProgress.service('WindowProgressService', require('./services/window-progress'));
+const OSWindowProgress = angular.module('Etcher.OS.WindowProgress', []);
+OSWindowProgress.service('OSWindowProgressService', require('./services/window-progress'));
diff --git a/lib/browser/utils/notifier/notifier.js b/lib/browser/utils/notifier/notifier.js
new file mode 100644
index 00000000..84e36eee
--- /dev/null
+++ b/lib/browser/utils/notifier/notifier.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016 Resin.io
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+/**
+ * @module Etcher.Utils.Notifier
+ *
+ * The purpose of this module is to provide a safe way
+ * to emit and receive events from the $rootScope.
+ */
+
+const angular = require('angular');
+const Notifier = angular.module('Etcher.Utils.Notifier', []);
+Notifier.service('NotifierService', require('./services/notifier'));
diff --git a/lib/browser/modules/notifier.js b/lib/browser/utils/notifier/services/notifier.js
similarity index 89%
rename from lib/browser/modules/notifier.js
rename to lib/browser/utils/notifier/services/notifier.js
index 7295a09f..118b3a18 100644
--- a/lib/browser/modules/notifier.js
+++ b/lib/browser/utils/notifier/services/notifier.js
@@ -16,19 +16,12 @@
'use strict';
-/**
- * @module Etcher.notifier
- */
-
-const angular = require('angular');
-const notifier = angular.module('Etcher.notifier', []);
-
/*
* Based on:
* http://www.codelord.net/2015/05/04/angularjs-notifying-about-changes-from-services-to-controllers/
*/
-notifier.service('NotifierService', function($rootScope) {
+module.exports = function($rootScope) {
/**
* @summary Safely subscribe to an event
@@ -71,4 +64,4 @@ notifier.service('NotifierService', function($rootScope) {
$rootScope.$emit(name, data);
};
-});
+};
diff --git a/lib/browser/modules/path.js b/lib/browser/utils/path/filters/basename.js
similarity index 83%
rename from lib/browser/modules/path.js
rename to lib/browser/utils/path/filters/basename.js
index 4337aa00..6df56189 100644
--- a/lib/browser/modules/path.js
+++ b/lib/browser/utils/path/filters/basename.js
@@ -16,16 +16,9 @@
'use strict';
-/**
- * @module Etcher.path
- */
-
-const angular = require('angular');
const path = require('path');
-const pathModule = angular.module('Etcher.path', []);
-
-pathModule.filter('basename', function() {
+module.exports = function() {
/**
* @summary Get the basename of a path
@@ -39,4 +32,5 @@ pathModule.filter('basename', function() {
* {{ '/foo/bar/baz' | basename }}
*/
return path.basename;
-});
+
+};
diff --git a/lib/browser/utils/path/path.js b/lib/browser/utils/path/path.js
new file mode 100644
index 00000000..76717c92
--- /dev/null
+++ b/lib/browser/utils/path/path.js
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016 Resin.io
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+/**
+ * @module Etcher.Utils.Path
+ *
+ * The purpose of this module is to provide utilities
+ * to work with file paths.
+ */
+
+const angular = require('angular');
+const Path = angular.module('Etcher.Utils.Path', []);
+Path.filter('basename', require('./filters/basename'));
diff --git a/lib/index.html b/lib/index.html
index 00f758fd..1ecd95ab 100644
--- a/lib/index.html
+++ b/lib/index.html
@@ -21,7 +21,7 @@