mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-08 22:31:04 +00:00
gui: Show Javascript error indicator on dev builds, remove logging of missing translations
This commit is contained in:
parent
181939c841
commit
492e92d65d
12
gui/default/assets/css/dev.css
Normal file
12
gui/default/assets/css/dev.css
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
.dev-top-bar{
|
||||||
|
display: none;
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dev-error .hasCount{
|
||||||
|
background-color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dev-warn .hasCount{
|
||||||
|
background-color: yellow;
|
||||||
|
}
|
@ -26,6 +26,8 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<script src="syncthing/development/logbar.js"></script>
|
||||||
|
<div ng-if="version.isDevelopmentVersion" ng-include="'syncthing/development/logbar.html'"></div>
|
||||||
<!-- Top bar -->
|
<!-- Top bar -->
|
||||||
|
|
||||||
<nav class="navbar navbar-top navbar-default" role="navigation">
|
<nav class="navbar navbar-top navbar-default" role="navigation">
|
||||||
@ -602,7 +604,6 @@
|
|||||||
<script src="vendor/jquery/jquery-2.2.2.js"></script>
|
<script src="vendor/jquery/jquery-2.2.2.js"></script>
|
||||||
<script src="vendor/angular/angular.js"></script>
|
<script src="vendor/angular/angular.js"></script>
|
||||||
<script src="vendor/angular/angular-translate.js"></script>
|
<script src="vendor/angular/angular-translate.js"></script>
|
||||||
<script src="vendor/angular/angular-translate-handler-log.js"></script>
|
|
||||||
<script src="vendor/angular/angular-translate-loader-static-files.js"></script>
|
<script src="vendor/angular/angular-translate-loader-static-files.js"></script>
|
||||||
<script src="vendor/angular/angular-dirPagination.js"></script>
|
<script src="vendor/angular/angular-dirPagination.js"></script>
|
||||||
<script src="vendor/bootstrap/js/bootstrap.js"></script>
|
<script src="vendor/bootstrap/js/bootstrap.js"></script>
|
||||||
|
@ -56,7 +56,6 @@ syncthing.config(function ($httpProvider, $translateProvider, LocaleServiceProvi
|
|||||||
prefix: 'assets/lang/lang-',
|
prefix: 'assets/lang/lang-',
|
||||||
suffix: '.json'
|
suffix: '.json'
|
||||||
});
|
});
|
||||||
$translateProvider.useMissingTranslationHandlerLog();
|
|
||||||
|
|
||||||
LocaleServiceProvider.setAvailableLocales(validLangs);
|
LocaleServiceProvider.setAvailableLocales(validLangs);
|
||||||
LocaleServiceProvider.setDefaultLocale('en');
|
LocaleServiceProvider.setDefaultLocale('en');
|
||||||
|
@ -97,6 +97,7 @@ angular.module('syncthing.core')
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.version = data;
|
$scope.version = data;
|
||||||
|
$scope.version.isDevelopmentVersion = data.version.indexOf('-')>0;
|
||||||
}).error($scope.emitHTTPError);
|
}).error($scope.emitHTTPError);
|
||||||
|
|
||||||
$http.get(urlbase + '/svc/report').success(function (data) {
|
$http.get(urlbase + '/svc/report').success(function (data) {
|
||||||
@ -810,7 +811,7 @@ angular.module('syncthing.core')
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.deviceName = function (deviceCfg) {
|
$scope.deviceName = function (deviceCfg) {
|
||||||
if (typeof deviceCfg === 'undefined') {
|
if (typeof deviceCfg === 'undefined' || typeof deviceCfg.deviceID === 'undefined') {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (deviceCfg.name) {
|
if (deviceCfg.name) {
|
||||||
|
13
gui/default/syncthing/development/logbar.html
Normal file
13
gui/default/syncthing/development/logbar.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<div class="dev-top-bar" id="dev-top-bar">
|
||||||
|
<link href="assets/css/dev.css" rel="stylesheet">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-4"><b>DEV</b></div>
|
||||||
|
<div id="log" class="col-xs-8">
|
||||||
|
<span>
|
||||||
|
JS:
|
||||||
|
<span class="dev-error fa fa-exclamation-triangle"> errors <span id="log_error">0</span></span>
|
||||||
|
<span class="dev-warn fa fa-frown-o"> warn <span id="log_warn">0</span></span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
39
gui/default/syncthing/development/logbar.js
Normal file
39
gui/default/syncthing/development/logbar.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
function intercept(method, handler) {
|
||||||
|
var console = window.console;
|
||||||
|
var original = console[method];
|
||||||
|
console[method] = function () {
|
||||||
|
handler(method);
|
||||||
|
// do sneaky stuff
|
||||||
|
if (original.apply) {
|
||||||
|
// Do this for normal browsers
|
||||||
|
original.apply(console, arguments);
|
||||||
|
} else {
|
||||||
|
// Do this for IE
|
||||||
|
var message = Array.prototype.slice.apply(arguments).join(' ');
|
||||||
|
original(message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleConsoleCall(type) {
|
||||||
|
var element = document.querySelector('#log_' + type);
|
||||||
|
if (element) {
|
||||||
|
if (!element.classList.contains("hasCount")) {
|
||||||
|
element.classList.add("hasCount");
|
||||||
|
}
|
||||||
|
|
||||||
|
var devTopBar = document.querySelector('#dev-top-bar');
|
||||||
|
devTopBar.style.display = 'block';
|
||||||
|
|
||||||
|
element.innerHTML = parseInt(element.innerHTML) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.console) {
|
||||||
|
var methods = ['error', 'warn'];
|
||||||
|
for (var i = 0; i < methods.length; i++) {
|
||||||
|
intercept(methods[i], handleConsoleCall);
|
||||||
|
}
|
||||||
|
}
|
1
gui/default/vendor/angular/README.md
vendored
1
gui/default/vendor/angular/README.md
vendored
@ -3,5 +3,4 @@ The files contained herein are:
|
|||||||
- angular 1.5.3
|
- angular 1.5.3
|
||||||
- angular-translate 2.9.0.1
|
- angular-translate 2.9.0.1
|
||||||
- angular-translate-loader-static-files 2.11.0
|
- angular-translate-loader-static-files 2.11.0
|
||||||
- angular-translate-handler-log 2.11.0
|
|
||||||
- angular-dirPagination 759009c
|
- angular-dirPagination 759009c
|
@ -1,50 +0,0 @@
|
|||||||
/*!
|
|
||||||
* angular-translate - v2.11.0 - 2016-03-20
|
|
||||||
*
|
|
||||||
* Copyright (c) 2016 The angular-translate team, Pascal Precht; Licensed MIT
|
|
||||||
*/
|
|
||||||
(function (root, factory) {
|
|
||||||
if (typeof define === 'function' && define.amd) {
|
|
||||||
// AMD. Register as an anonymous module unless amdModuleId is set
|
|
||||||
define([], function () {
|
|
||||||
return (factory());
|
|
||||||
});
|
|
||||||
} else if (typeof exports === 'object') {
|
|
||||||
// Node. Does not work with strict CommonJS, but
|
|
||||||
// only CommonJS-like environments that support module.exports,
|
|
||||||
// like Node.
|
|
||||||
module.exports = factory();
|
|
||||||
} else {
|
|
||||||
factory();
|
|
||||||
}
|
|
||||||
}(this, function () {
|
|
||||||
|
|
||||||
$translateMissingTranslationHandlerLog.$inject = ['$log'];
|
|
||||||
angular.module('pascalprecht.translate')
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ngdoc object
|
|
||||||
* @name pascalprecht.translate.$translateMissingTranslationHandlerLog
|
|
||||||
* @requires $log
|
|
||||||
*
|
|
||||||
* @description
|
|
||||||
* Uses angular's `$log` service to give a warning when trying to translate a
|
|
||||||
* translation id which doesn't exist.
|
|
||||||
*
|
|
||||||
* @returns {function} Handler function
|
|
||||||
*/
|
|
||||||
.factory('$translateMissingTranslationHandlerLog', $translateMissingTranslationHandlerLog);
|
|
||||||
|
|
||||||
function $translateMissingTranslationHandlerLog ($log) {
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
return function (translationId) {
|
|
||||||
$log.warn('Translation for ' + translationId + ' doesn\'t exist');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
$translateMissingTranslationHandlerLog.displayName = '$translateMissingTranslationHandlerLog';
|
|
||||||
return 'pascalprecht.translate';
|
|
||||||
|
|
||||||
}));
|
|
Loading…
Reference in New Issue
Block a user