Sleep button on main screen for etcher-pro

Change-type: patch
This commit is contained in:
Alexis Svinartchouk 2019-06-28 12:42:50 +02:00
parent c3b3957fbf
commit 47f29626b6
6 changed files with 76 additions and 4 deletions

View File

@ -456,6 +456,32 @@ app.controller('HeaderController', function (OSOpenExternalService) {
this.shouldShowHelp = () => {
return !settings.get('disableExternalLinks')
}
/**
* @summary Whether to show the sleep button
* @function
* @public
*
* @returns {Boolean}
*
* @example
* HeaderController.shouldShowSleep()
*/
this.shouldShowSleep = () => {
return settings.get('showScreensaverDelay')
}
/**
* @summary Enables the screensaver
* @function
* @public
*
* @example
* HeaderController.sleep()
*/
this.sleep = () => {
screensaver.off()
}
})
app.controller('StateController', function ($rootScope, $scope) {

View File

@ -11,22 +11,36 @@
</head>
<body>
<header class="section-header" ng-controller="HeaderController as header">
<button
class="button button-link sleep-button"
tabindex="4"
ng-if="header.shouldShowSleep()"
ng-click="header.sleep()"
>
<svg-icon paths="[ '../../assets/moon.svg' ]"
width="'14px'"
height="'14px'"></svg-icon>
<span >
Sleep
</span>
</button>
<button class="button button-link"
ng-if="header.shouldShowHelp()"
ng-click="header.openHelpPage()"
tabindex="4">
tabindex="5">
<span class="glyphicon glyphicon-question-sign"></span>
</button>
<button class="button button-link"
ui-sref="settings"
hide-if-state="settings"
tabindex="5">
tabindex="6">
<span class="glyphicon glyphicon-cog"></span>
</button>
<button class="button button-link"
tabindex="5"
tabindex="7"
ui-sref="main"
show-if-state="settings">
<span class="glyphicon glyphicon-chevron-left"></span> Back

View File

@ -48,7 +48,7 @@ async function ledsOff(): Promise<void> {
// TODO
}
async function off() {
export async function off() {
await Promise.all([ledsOff(), screenOff()]);
}

View File

@ -238,3 +238,19 @@ featured-project {
overflow: hidden;
}
}
.sleep-button {
float: left;
background-color: #3c3e42;
width: 76px;
height: 24px;
border-radius: 24px;
padding: 0px;
margin-top: 10px;
margin-left: 6px;
font-size: 12px;
&:hover {
background-color: #414347;
}
}

3
lib/gui/assets/moon.svg Normal file
View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="#D3D6DB" fill-rule="evenodd" stroke="#D3D6DB" stroke-linecap="round" d="M5.313 1.002a.173.173 0 0 0-.038.01C2.559 2.02 1 4.642 1 7.686a7.12 7.12 0 0 0 7.116 7.116c3.044 0 5.667-1.565 6.673-4.28a.173.173 0 0 0-.226-.221c-.77.309-1.607.468-2.49.468-3.686 0-7.046-3.354-7.046-7.04 0-.883.16-1.72.469-2.49a.173.173 0 0 0-.183-.237zm-.248.49a7.033 7.033 0 0 0-.383 2.237c0 3.894 3.497 7.386 7.39 7.386.786 0 1.53-.147 2.237-.383-1.04 2.362-3.399 3.725-6.193 3.725-3.741 0-6.771-3.03-6.771-6.77 0-2.794 1.36-5.154 3.72-6.195z"/>
</svg>

After

Width:  |  Height:  |  Size: 630 B

View File

@ -9992,3 +9992,16 @@ featured-project.fp-visible webview {
top: 45px;
border-radius: 7px;
overflow: hidden; }
.sleep-button {
float: left;
background-color: #3c3e42;
width: 76px;
height: 24px;
border-radius: 24px;
padding: 0px;
margin-top: 10px;
margin-left: 6px;
font-size: 12px; }
.sleep-button:hover {
background-color: #414347; }