mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 20:10:11 +03:00
adding request usb permissions UI (DEV only)
This commit is contained in:
parent
cda43ac9bf
commit
a0582fd79f
8 changed files with 98 additions and 6 deletions
|
@ -112,10 +112,26 @@
|
|||
"message": "Cycle Time:"
|
||||
},
|
||||
|
||||
"please_grant_usb_permissions": {
|
||||
"message": "Please click on <strong>\"Request Optional Permissions\"</strong> button to grant application <strong style=\"color: red\">required</strong> <strong>USB</strong> access"
|
||||
},
|
||||
"usb_permissions_granted": {
|
||||
"message": "Optional <strong>USB</strong> permissions <strong style=\"color: green\">granted</strong>"
|
||||
},
|
||||
|
||||
"eeprom_saved_ok": {
|
||||
"message": "EEPROM <span style=\"color: green\">saved</span>"
|
||||
},
|
||||
|
||||
"default_optional_permissions_head": {
|
||||
"message": "Optional USB Permissions"
|
||||
},
|
||||
"default_optional_permissions_text": {
|
||||
"message": "Due to addition of <strong>Naze32PRO</strong> to the supported hardware family, Configurator <strong style=\"color: red\">requires</strong> USB access to allow firmware flashing via DFU"
|
||||
},
|
||||
"default_request_optional_permissions": {
|
||||
"message": "Request Optional Permissions"
|
||||
},
|
||||
"defaultWelcomeText": {
|
||||
"message": "This application is a configuration utility for baseflight, a 32 bit fork of the popular open source RC flight control firmware project <a href=\"http://www.multiwii.org/\" title=\"www.multiwii.org\" target=\"_blank\">MultiWii</a>.<br /><br />Application supports hardware that run Baseflight <strong>exclusively</strong> (acro naze, naze, afromini)<br /><br /><strong>Official Resellers & Backers</strong><br />• <a href=\"http://www.abusemark.com/store/\" title=\"www.abusemark.com\" target=\"_blank\">AbuseMark</a> - International (Japan)<br />• <a href=\"http://www.multirotorsuperstore.com/\" title=\"www.multirotorsuperstore.com\" target=\"_blank\">Multirotor Superstore</a> - International (United States)<br /><br />The firmware source code can be downloaded from <a href=\"https://github.com/multiwii/baseflight\" title=\"www.github.com\" target=\"_blank\">here</a><br />The newest binary firmware image is available <a href=\"https://github.com/multiwii/baseflight/blob/master/obj/baseflight.hex\" title=\"www.github.com\" target=\"_blank\">here</a><br />"
|
||||
},
|
||||
|
|
|
@ -4,6 +4,7 @@ var GUI_control = function() {
|
|||
this.connected_to = false;
|
||||
this.active_tab;
|
||||
this.operating_system;
|
||||
this.optional_usb_permissions = false; // controlled by usb permissions code
|
||||
this.interval_array = [];
|
||||
this.timeout_array = [];
|
||||
|
||||
|
|
|
@ -53,12 +53,6 @@ var STM32DFU_protocol = function() {
|
|||
dfuUPLOAD_IDLE: 9, // The device is processing an upload operation. Expecting DFU_UPLOAD requests.
|
||||
dfuERROR: 10 // An error has occurred. Awaiting the DFU_CLRSTATUS request.
|
||||
};
|
||||
|
||||
this.usbDevices = {
|
||||
F3DiscoveryDFU: {'vendorId': 1155, 'productId': 57105}
|
||||
};
|
||||
|
||||
this.usbPermissions = {permissions: [{'usbDevices': [this.usbDevices.F3DiscoveryDFU]}]};
|
||||
};
|
||||
|
||||
STM32DFU_protocol.prototype.openDevice = function(callback) {
|
||||
|
|
32
js/usb.js
Normal file
32
js/usb.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
var usbDevices = {
|
||||
STM32DFU: {'vendorId': 1155, 'productId': 57105}
|
||||
};
|
||||
var usbPermissions = {permissions: [{'usbDevices': [usbDevices.STM32DFU]}]};
|
||||
|
||||
function check_usb_permissions(callback) {
|
||||
chrome.permissions.contains(usbPermissions, function(result) {
|
||||
if (result) {
|
||||
GUI.optional_usb_permissions = true;
|
||||
} else {
|
||||
console.log('Optional USB permissions: missing');
|
||||
GUI.log(chrome.i18n.getMessage('please_grant_usb_permissions'));
|
||||
|
||||
// display optional usb permissions request box
|
||||
$('div.optional_permissions').show();
|
||||
|
||||
// UI hooks
|
||||
document.getElementById("requestOptionalPermissions").addEventListener('click', function() {
|
||||
chrome.permissions.request(usbPermissions, function(result) {
|
||||
if (result) {
|
||||
GUI.log(chrome.i18n.getMessage('usb_permissions_granted'));
|
||||
$('div.optional_permissions').hide();
|
||||
|
||||
GUI.optional_usb_permissions = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (callback) callback();
|
||||
});
|
||||
}
|
|
@ -25,6 +25,7 @@
|
|||
<script type="text/javascript" src="./js/port_handler.js"></script>
|
||||
<script type="text/javascript" src="./js/port_usage.js"></script>
|
||||
<script type="text/javascript" src="./js/serial.js"></script>
|
||||
<script type="text/javascript" src="./js/usb.js"></script>
|
||||
<script type="text/javascript" src="./js/gui.js"></script>
|
||||
<script type="text/javascript" src="./js/request_balancer.js"></script>
|
||||
<script type="text/javascript" src="./js/serial_backend.js"></script>
|
||||
|
|
|
@ -8,6 +8,45 @@
|
|||
|
||||
width: calc(40% - 10px);
|
||||
}
|
||||
.tab-default .optional_permissions {
|
||||
display: none;
|
||||
|
||||
margin-bottom: 10px;
|
||||
|
||||
border: 1px solid silver;
|
||||
}
|
||||
.tab-default .optional_permissions .title {
|
||||
line-height: 20px;
|
||||
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
|
||||
border-bottom: 1px solid silver;
|
||||
background-color: #cd4c4c;
|
||||
}
|
||||
.tab-default .optional_permissions p {
|
||||
padding: 5px;
|
||||
}
|
||||
.tab-default .optional_permissions a {
|
||||
display: block;
|
||||
float: left;
|
||||
|
||||
height: 28px;
|
||||
line-height: 28px;
|
||||
|
||||
margin: 0 0 5px 5px;
|
||||
padding: 0 15px 0 15px;
|
||||
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
|
||||
border: 1px solid silver;
|
||||
background-color: #ececec;
|
||||
}
|
||||
.tab-default .optional_permissions a:hover {
|
||||
background-color: #dedcdc;
|
||||
}
|
||||
.welcome {
|
||||
margin-bottom: 10px;
|
||||
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<div class="tab-default">
|
||||
<div class="left">
|
||||
<div class="optional_permissions">
|
||||
<div class="title" i18n="default_optional_permissions_head"></div>
|
||||
<p i18n="default_optional_permissions_text">
|
||||
</p>
|
||||
<a id="requestOptionalPermissions" href="#" i18n="default_request_optional_permissions"></a>
|
||||
<div class="clear-both"></div>
|
||||
</div>
|
||||
<div class="welcome" i18n="defaultWelcomeText">
|
||||
</div>
|
||||
<div class="donate">
|
||||
|
|
|
@ -2,6 +2,8 @@ function tab_initialize_default() {
|
|||
GUI.active_tab = 'default';
|
||||
|
||||
$('#content').load("./tabs/default.html", function() {
|
||||
check_usb_permissions(); // temporary enabled in dev branch, should be commented out untill DFU support goes live
|
||||
|
||||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue