mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-24 23:37:18 +00:00
Implement settings screen
This commit is contained in:
parent
ff2a375179
commit
61a1527c7e
@ -1085,11 +1085,11 @@ textarea {
|
|||||||
line-height: inherit; }
|
line-height: inherit; }
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #5793db;
|
color: #ddd;
|
||||||
text-decoration: none; }
|
text-decoration: none; }
|
||||||
a:hover, a:focus {
|
a:hover, a:focus {
|
||||||
color: #296cbd;
|
color: #b7b7b7;
|
||||||
text-decoration: underline; }
|
text-decoration: none; }
|
||||||
a:focus {
|
a:focus {
|
||||||
outline: thin dotted;
|
outline: thin dotted;
|
||||||
outline: 5px auto -webkit-focus-ring-color;
|
outline: 5px auto -webkit-focus-ring-color;
|
||||||
@ -3067,7 +3067,7 @@ fieldset[disabled] a.btn {
|
|||||||
background-color: #fff; }
|
background-color: #fff; }
|
||||||
|
|
||||||
.btn-link {
|
.btn-link {
|
||||||
color: #5793db;
|
color: #ddd;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
border-radius: 0; }
|
border-radius: 0; }
|
||||||
.btn-link, .btn-link:active, .btn-link.active, .btn-link[disabled],
|
.btn-link, .btn-link:active, .btn-link.active, .btn-link[disabled],
|
||||||
@ -3078,8 +3078,8 @@ fieldset[disabled] a.btn {
|
|||||||
.btn-link, .btn-link:hover, .btn-link:focus, .btn-link:active {
|
.btn-link, .btn-link:hover, .btn-link:focus, .btn-link:active {
|
||||||
border-color: transparent; }
|
border-color: transparent; }
|
||||||
.btn-link:hover, .btn-link:focus {
|
.btn-link:hover, .btn-link:focus {
|
||||||
color: #296cbd;
|
color: #b7b7b7;
|
||||||
text-decoration: underline;
|
text-decoration: none;
|
||||||
background-color: transparent; }
|
background-color: transparent; }
|
||||||
.btn-link[disabled]:hover, .btn-link[disabled]:focus,
|
.btn-link[disabled]:hover, .btn-link[disabled]:focus,
|
||||||
fieldset[disabled] .btn-link:hover,
|
fieldset[disabled] .btn-link:hover,
|
||||||
@ -3579,7 +3579,7 @@ tbody.collapse.in {
|
|||||||
cursor: initial; }
|
cursor: initial; }
|
||||||
.nav .open > a, .nav .open > a:hover, .nav .open > a:focus {
|
.nav .open > a, .nav .open > a:hover, .nav .open > a:focus {
|
||||||
background-color: #eeeeee;
|
background-color: #eeeeee;
|
||||||
border-color: #5793db; }
|
border-color: #ddd; }
|
||||||
.nav .nav-divider {
|
.nav .nav-divider {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
@ -4099,7 +4099,7 @@ tbody.collapse.in {
|
|||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
line-height: 1.42857;
|
line-height: 1.42857;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #5793db;
|
color: #ddd;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
margin-left: -1px; }
|
margin-left: -1px; }
|
||||||
@ -4116,7 +4116,7 @@ tbody.collapse.in {
|
|||||||
.pagination > li > span:hover,
|
.pagination > li > span:hover,
|
||||||
.pagination > li > span:focus {
|
.pagination > li > span:focus {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
color: #296cbd;
|
color: #b7b7b7;
|
||||||
background-color: #eeeeee;
|
background-color: #eeeeee;
|
||||||
border-color: #ddd; }
|
border-color: #ddd; }
|
||||||
.pagination > .active > a, .pagination > .active > a:hover, .pagination > .active > a:focus,
|
.pagination > .active > a, .pagination > .active > a:hover, .pagination > .active > a:focus,
|
||||||
@ -4284,7 +4284,7 @@ a.label:hover, a.label:focus {
|
|||||||
padding: 1px 5px; }
|
padding: 1px 5px; }
|
||||||
.list-group-item.active > .badge,
|
.list-group-item.active > .badge,
|
||||||
.nav-pills > .active > a > .badge {
|
.nav-pills > .active > a > .badge {
|
||||||
color: #5793db;
|
color: #ddd;
|
||||||
background-color: #fff; }
|
background-color: #fff; }
|
||||||
.list-group-item > .badge {
|
.list-group-item > .badge {
|
||||||
float: right; }
|
float: right; }
|
||||||
@ -4357,7 +4357,7 @@ a.badge:hover, a.badge:focus {
|
|||||||
a.thumbnail:hover,
|
a.thumbnail:hover,
|
||||||
a.thumbnail:focus,
|
a.thumbnail:focus,
|
||||||
a.thumbnail.active {
|
a.thumbnail.active {
|
||||||
border-color: #5793db; }
|
border-color: #ddd; }
|
||||||
|
|
||||||
.alert {
|
.alert {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
@ -5854,6 +5854,9 @@ button.close {
|
|||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
margin-bottom: 15px; }
|
margin-bottom: 15px; }
|
||||||
|
|
||||||
|
.space-top-huge {
|
||||||
|
margin-top: 45px; }
|
||||||
|
|
||||||
.space-vertical-large {
|
.space-vertical-large {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
margin-bottom: 30px; }
|
margin-bottom: 30px; }
|
||||||
@ -5862,6 +5865,9 @@ button.close {
|
|||||||
margin-left: 30px;
|
margin-left: 30px;
|
||||||
margin-right: 30px; }
|
margin-right: 30px; }
|
||||||
|
|
||||||
|
.space-bottom-large {
|
||||||
|
margin-bottom: 30px; }
|
||||||
|
|
||||||
.space-bottom-huge {
|
.space-bottom-huge {
|
||||||
margin-bottom: 45px; }
|
margin-bottom: 45px; }
|
||||||
|
|
||||||
@ -5971,3 +5977,12 @@ body {
|
|||||||
.checkbox input[type="checkbox"] {
|
.checkbox input[type="checkbox"] {
|
||||||
position: initial;
|
position: initial;
|
||||||
margin-right: 2px; }
|
margin-right: 2px; }
|
||||||
|
|
||||||
|
.checkbox input[type="checkbox"]:not(:checked) + * {
|
||||||
|
color: #ddd; }
|
||||||
|
|
||||||
|
.btn-navigation {
|
||||||
|
position: fixed;
|
||||||
|
top: 10px;
|
||||||
|
right: 15px;
|
||||||
|
font-size: 15px; }
|
||||||
|
@ -30,6 +30,7 @@ const currentWindow = BrowserWindow.fromId(1);
|
|||||||
|
|
||||||
require('angular-ui-bootstrap');
|
require('angular-ui-bootstrap');
|
||||||
require('./browser/modules/selection-state');
|
require('./browser/modules/selection-state');
|
||||||
|
require('./browser/modules/settings');
|
||||||
require('./browser/modules/drive-scanner');
|
require('./browser/modules/drive-scanner');
|
||||||
require('./browser/modules/image-writer');
|
require('./browser/modules/image-writer');
|
||||||
require('./browser/modules/path');
|
require('./browser/modules/path');
|
||||||
@ -41,13 +42,22 @@ const app = angular.module('Etcher', [
|
|||||||
// Etcher modules
|
// Etcher modules
|
||||||
'Etcher.path',
|
'Etcher.path',
|
||||||
'Etcher.selection-state',
|
'Etcher.selection-state',
|
||||||
|
'Etcher.settings',
|
||||||
'Etcher.drive-scanner',
|
'Etcher.drive-scanner',
|
||||||
'Etcher.image-writer',
|
'Etcher.image-writer',
|
||||||
'Etcher.analytics'
|
'Etcher.analytics'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
app.controller('AppController', function($q, DriveScannerService, SelectionStateService, ImageWriterService, AnalyticsService) {
|
app.controller('AppController', function(
|
||||||
|
$q,
|
||||||
|
DriveScannerService,
|
||||||
|
SettingsService,
|
||||||
|
SelectionStateService,
|
||||||
|
ImageWriterService,
|
||||||
|
AnalyticsService
|
||||||
|
) {
|
||||||
let self = this;
|
let self = this;
|
||||||
|
this.settings = SettingsService;
|
||||||
this.selection = SelectionStateService;
|
this.selection = SelectionStateService;
|
||||||
this.writer = ImageWriterService;
|
this.writer = ImageWriterService;
|
||||||
this.scanner = DriveScannerService;
|
this.scanner = DriveScannerService;
|
||||||
|
94
lib/browser/modules/settings.js
Normal file
94
lib/browser/modules/settings.js
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* 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.settings
|
||||||
|
*/
|
||||||
|
|
||||||
|
const angular = require('angular');
|
||||||
|
|
||||||
|
require('ngstorage');
|
||||||
|
const settings = angular.module('Etcher.settings', [
|
||||||
|
'ngStorage'
|
||||||
|
]);
|
||||||
|
|
||||||
|
settings.service('SettingsService', function($localStorage) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Settings data
|
||||||
|
* @type Object
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
this.data = $localStorage.$default({
|
||||||
|
errorReporting: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// All this functionality should be gone once
|
||||||
|
// we make use of a real router on the application.
|
||||||
|
// This is not the case yet since when the application
|
||||||
|
// was first prototyped there was only one screen
|
||||||
|
// and therefore a router would have been overkill.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Configuring state
|
||||||
|
* @type Boolean
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
let configuring = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Check if the user is configuring
|
||||||
|
* @function
|
||||||
|
* @public
|
||||||
|
*
|
||||||
|
* @returns {Boolean} whether is configuring
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* if (SettingsService.isConfiguring()) {
|
||||||
|
* console.log('User is on settings screen');
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
this.isConfiguring = function() {
|
||||||
|
return configuring;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Enter settings screen
|
||||||
|
* @function
|
||||||
|
* @public
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* SettingsService.enter();
|
||||||
|
*/
|
||||||
|
this.enter = function() {
|
||||||
|
configuring = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Leave settings screen
|
||||||
|
* @function
|
||||||
|
* @public
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* SettingsService.leave();
|
||||||
|
*/
|
||||||
|
this.leave = function() {
|
||||||
|
configuring = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
@ -25,7 +25,7 @@
|
|||||||
<script src="./browser/app.js"></script>
|
<script src="./browser/app.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body ng-app="Etcher" ng-controller="AppController as app" style="display: none">
|
<body ng-app="Etcher" ng-controller="AppController as app" style="display: none">
|
||||||
<div class="content row middle-xs space-horizontal-large">
|
<div class="content row middle-xs space-horizontal-large" ng-hide="app.settings.isConfiguring()">
|
||||||
<div class="col-xs">
|
<div class="col-xs">
|
||||||
<div class="row around-xs space-bottom-huge" ng-hide="app.state.progress == 100 && !app.writer.isBurning()">
|
<div class="row around-xs space-bottom-huge" ng-hide="app.state.progress == 100 && !app.writer.isBurning()">
|
||||||
<div class="col-xs">
|
<div class="col-xs">
|
||||||
@ -136,6 +136,25 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="content row space-horizontal-large space-top-huge" ng-show="app.settings.isConfiguring()">
|
||||||
|
<div class="col-xs" ng-show="app.settings.isConfiguring()">
|
||||||
|
<button class="btn btn-link btn-navigation" ng-click="app.settings.leave()">
|
||||||
|
<span class="glyphicon glyphicon-chevron-left"></span> Back
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="box text-left space-horizontal-large">
|
||||||
|
<h1 class="space-bottom-large">Settings</h1>
|
||||||
|
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" ng-model="app.settings.data.errorReporting">
|
||||||
|
<span>Enable error reporting</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="section-footer row between-xs middle-xs">
|
<div class="section-footer row between-xs middle-xs">
|
||||||
<div class="col-xs">
|
<div class="col-xs">
|
||||||
<div class="box text-left">
|
<div class="box text-left">
|
||||||
|
@ -26,6 +26,8 @@ $btn-disabled: rgb(49, 51, 57);
|
|||||||
$badge-disabled: rgb(92, 94, 92);
|
$badge-disabled: rgb(92, 94, 92);
|
||||||
$btn-padding: 10px;
|
$btn-padding: 10px;
|
||||||
$btn-min-width: 170px;
|
$btn-min-width: 170px;
|
||||||
|
$link-color: $gray-light;
|
||||||
|
$link-hover-decoration: none;
|
||||||
|
|
||||||
@import "../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
|
@import "../../node_modules/bootstrap-sass/assets/stylesheets/bootstrap";
|
||||||
|
|
||||||
@ -177,3 +179,14 @@ body {
|
|||||||
position: initial;
|
position: initial;
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.checkbox input[type="checkbox"]:not(:checked) + * {
|
||||||
|
color: $gray-light;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-navigation {
|
||||||
|
position: fixed;
|
||||||
|
top: 10px;
|
||||||
|
right: 15px;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
@ -28,6 +28,10 @@ $spacing-tiny: 5px;
|
|||||||
margin-bottom: $spacing-medium;
|
margin-bottom: $spacing-medium;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.space-top-huge {
|
||||||
|
margin-top: $spacing-huge;
|
||||||
|
}
|
||||||
|
|
||||||
.space-vertical-large {
|
.space-vertical-large {
|
||||||
margin-top: $spacing-large;
|
margin-top: $spacing-large;
|
||||||
margin-bottom: $spacing-large;
|
margin-bottom: $spacing-large;
|
||||||
@ -38,6 +42,10 @@ $spacing-tiny: 5px;
|
|||||||
margin-right: $spacing-large;
|
margin-right: $spacing-large;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.space-bottom-large {
|
||||||
|
margin-bottom: $spacing-large;
|
||||||
|
}
|
||||||
|
|
||||||
.space-bottom-huge {
|
.space-bottom-huge {
|
||||||
margin-bottom: $spacing-huge;
|
margin-bottom: $spacing-huge;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,7 @@
|
|||||||
"flexboxgrid": "^6.3.0",
|
"flexboxgrid": "^6.3.0",
|
||||||
"is-elevated": "^1.0.0",
|
"is-elevated": "^1.0.0",
|
||||||
"lodash": "^4.5.1",
|
"lodash": "^4.5.1",
|
||||||
|
"ngstorage": "^0.3.10",
|
||||||
"resin-image-write": "^2.0.5",
|
"resin-image-write": "^2.0.5",
|
||||||
"sudo-prompt": "^2.2.0",
|
"sudo-prompt": "^2.2.0",
|
||||||
"trackjs": "^2.1.16",
|
"trackjs": "^2.1.16",
|
||||||
|
51
tests/browser/modules/settings.spec.js
Normal file
51
tests/browser/modules/settings.spec.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const m = require('mochainon');
|
||||||
|
const angular = require('angular');
|
||||||
|
require('angular-mocks');
|
||||||
|
require('../../../lib/browser/modules/settings');
|
||||||
|
|
||||||
|
describe('Browser: Settings', function() {
|
||||||
|
|
||||||
|
beforeEach(angular.mock.module('Etcher.settings'));
|
||||||
|
|
||||||
|
describe('SettingsService', function() {
|
||||||
|
|
||||||
|
let SettingsService;
|
||||||
|
|
||||||
|
beforeEach(angular.mock.inject(function(_SettingsService_) {
|
||||||
|
SettingsService = _SettingsService_;
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('.isConfiguring()', function() {
|
||||||
|
|
||||||
|
it('should initially return false', function() {
|
||||||
|
m.chai.expect(SettingsService.isConfiguring()).to.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('.enter()', function() {
|
||||||
|
|
||||||
|
it('should be able to enter settings', function() {
|
||||||
|
m.chai.expect(SettingsService.isConfiguring()).to.be.false;
|
||||||
|
SettingsService.enter();
|
||||||
|
m.chai.expect(SettingsService.isConfiguring()).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('.leave()', function() {
|
||||||
|
|
||||||
|
it('should be able to leave settings', function() {
|
||||||
|
SettingsService.enter();
|
||||||
|
m.chai.expect(SettingsService.isConfiguring()).to.be.true;
|
||||||
|
SettingsService.leave();
|
||||||
|
m.chai.expect(SettingsService.isConfiguring()).to.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user