add version and git commit hash in AriaNg settings page

This commit is contained in:
MaysWind 2018-11-21 20:46:21 +08:00
parent 73c8aec0cd
commit d87d49ce61
11 changed files with 51 additions and 4 deletions

View file

@ -3,6 +3,7 @@ var gulpLoadPlugins = require('gulp-load-plugins');
var browserSync = require('browser-sync'); var browserSync = require('browser-sync');
var del = require('del'); var del = require('del');
var fs = require('fs'); var fs = require('fs');
var git = require('git-rev-sync');
var $ = gulpLoadPlugins(); var $ = gulpLoadPlugins();
var reload = browserSync.reload; var reload = browserSync.reload;
@ -54,6 +55,8 @@ gulp.task('prepare-scripts', function () {
return gulp.src([ return gulp.src([
'src/scripts/**/*.js' 'src/scripts/**/*.js'
]).pipe($.plumber()) ]).pipe($.plumber())
.pipe($.injectVersion({replace: '${ARIANG_VERSION}'}))
.pipe($.replace(/\${ARIANG_BUILD_COMMIT}/g, git.short()))
.pipe(gulp.dest('.tmp/scripts')) .pipe(gulp.dest('.tmp/scripts'))
.pipe(reload({stream: true})); .pipe(reload({stream: true}));
}); });
@ -70,7 +73,6 @@ gulp.task('prepare-html', ['prepare-styles', 'prepare-scripts', 'prepare-views']
return gulp.src([ return gulp.src([
'src/*.html' 'src/*.html'
]).pipe($.useref({searchPath: ['.tmp', 'src', '.']})) ]).pipe($.useref({searchPath: ['.tmp', 'src', '.']}))
.pipe($.injectVersion())
.pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, ''))) .pipe($.if('js/*.js', $.replace(/\/\/# sourceMappingURL=.*/g, '')))
.pipe($.if('css/*.css', $.replace(/\/\*# sourceMappingURL=.* \*\/$/g, ''))) .pipe($.if('css/*.css', $.replace(/\/\*# sourceMappingURL=.* \*\/$/g, '')))
.pipe($.if(['js/moment-with-locales-*.min.js', 'js/plugins.min.js', 'js/aria-ng.min.js'], $.uglify({preserveComments: 'license'}))) .pipe($.if(['js/moment-with-locales-*.min.js', 'js/plugins.min.js', 'js/aria-ng.min.js'], $.uglify({preserveComments: 'license'})))

22
package-lock.json generated
View file

@ -3986,6 +3986,17 @@
"integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=",
"dev": true "dev": true
}, },
"git-rev-sync": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/git-rev-sync/-/git-rev-sync-1.12.0.tgz",
"integrity": "sha1-RGhAbH5sO6TPRYeZnhrbKNnRr1U=",
"dev": true,
"requires": {
"escape-string-regexp": "1.0.5",
"graceful-fs": "4.1.11",
"shelljs": "0.7.7"
}
},
"glob": { "glob": {
"version": "7.1.2", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
@ -9656,6 +9667,17 @@
"jsonify": "~0.0.0" "jsonify": "~0.0.0"
} }
}, },
"shelljs": {
"version": "0.7.7",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.7.tgz",
"integrity": "sha1-svXHfvlxSPS09uImguELuoZnz/E=",
"dev": true,
"requires": {
"glob": "^7.0.0",
"interpret": "^1.0.0",
"rechoir": "^0.6.2"
}
},
"sigmund": { "sigmund": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",

View file

@ -42,6 +42,7 @@
"del": "^3.0.0", "del": "^3.0.0",
"eslint-config-angular": "^0.5.0", "eslint-config-angular": "^0.5.0",
"eslint-plugin-angular": "^3.3.0", "eslint-plugin-angular": "^3.3.0",
"git-rev-sync": "^1.12.0",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-angular-templatecache": "^2.2.1", "gulp-angular-templatecache": "^2.2.1",
"gulp-autoprefixer": "^5.0.0", "gulp-autoprefixer": "^5.0.0",

View file

@ -50,7 +50,7 @@
<header class="main-header"> <header class="main-header">
<div class="logo"> <div class="logo">
<div class="logo-mini">AriaNg</div> <div class="logo-mini">AriaNg</div>
<div class="logo-lg" title="AriaNg %%GULP_INJECT_VERSION%%"> <div class="logo-lg" title="AriaNg {{ariaNgVersion}}">
<div class="dropdown"> <div class="dropdown">
<span class="dropdown-toggle" data-toggle="dropdown"> <span class="dropdown-toggle" data-toggle="dropdown">
<span class="logo-lg-title">AriaNg</span><i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i> <span class="logo-lg-title">AriaNg</span><i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i>
@ -351,6 +351,7 @@
<script src="scripts/core/router.js"></script> <script src="scripts/core/router.js"></script>
<script src="scripts/core/root.js"></script> <script src="scripts/core/root.js"></script>
<script src="scripts/config/constants.js"></script> <script src="scripts/config/constants.js"></script>
<script src="scripts/config/buildConfiguration.js"></script>
<script src="scripts/config/configuration.js"></script> <script src="scripts/config/configuration.js"></script>
<script src="scripts/config/fileTypes.js"></script> <script src="scripts/config/fileTypes.js"></script>
<script src="scripts/config/initiator.js"></script> <script src="scripts/config/initiator.js"></script>

View file

@ -1,4 +1,5 @@
[global] [global]
AriaNg Version=AriaNg 版本
Operation Result=操作结果 Operation Result=操作结果
Operation Succeeded=操作成功 Operation Succeeded=操作成功
{{name}} is connected={{name}} 已连接 {{name}} is connected={{name}} 已连接

View file

@ -1,4 +1,5 @@
[global] [global]
AriaNg Version=AriaNg 版本
Operation Result=操作結果 Operation Result=操作結果
Operation Succeeded=操作成功 Operation Succeeded=操作成功
{{name}} is connected={{name}} 已連線 {{name}} is connected={{name}} 已連線

View file

@ -0,0 +1,8 @@
(function () {
'use strict';
angular.module('ariaNg').constant('ariaNgBuildConfiguration', {
buildVersion: '${ARIANG_VERSION}',
buildCommit: '${ARIANG_BUILD_COMMIT}'
});
}());

View file

@ -3,6 +3,7 @@
angular.module('ariaNg').config(['$translateProvider', 'ariaNgConstants', function ($translateProvider, ariaNgConstants) { angular.module('ariaNg').config(['$translateProvider', 'ariaNgConstants', function ($translateProvider, ariaNgConstants) {
var defaultLanguageResource = { var defaultLanguageResource = {
'AriaNg Version': 'AriaNg Version',
'Operation Result': 'Operation Result', 'Operation Result': 'Operation Result',
'Operation Succeeded': 'Operation Succeeded', 'Operation Succeeded': 'Operation Succeeded',
'{{name}} is connected': '{{name}} is connected', '{{name}} is connected': '{{name}} is connected',

View file

@ -1,7 +1,7 @@
(function () { (function () {
'use strict'; 'use strict';
angular.module('ariaNg').controller('MainController', ['$rootScope', '$scope', '$route', '$window', '$location', '$document', '$interval', 'clipboard', 'aria2RpcErrors', 'ariaNgCommonService', 'ariaNgNotificationService', 'ariaNgLocalizationService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgTitleService', 'aria2TaskService', 'aria2SettingService', function ($rootScope, $scope, $route, $window, $location, $document, $interval, clipboard, aria2RpcErrors, ariaNgCommonService, ariaNgNotificationService, ariaNgLocalizationService, ariaNgSettingService, ariaNgMonitorService, ariaNgTitleService, aria2TaskService, aria2SettingService) { angular.module('ariaNg').controller('MainController', ['$rootScope', '$scope', '$route', '$window', '$location', '$document', '$interval', 'clipboard', 'ariaNgBuildConfiguration', 'aria2RpcErrors', 'ariaNgCommonService', 'ariaNgNotificationService', 'ariaNgLocalizationService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgTitleService', 'aria2TaskService', 'aria2SettingService', function ($rootScope, $scope, $route, $window, $location, $document, $interval, clipboard, ariaNgBuildConfiguration, aria2RpcErrors, ariaNgCommonService, ariaNgNotificationService, ariaNgLocalizationService, ariaNgSettingService, ariaNgMonitorService, ariaNgTitleService, aria2TaskService, aria2SettingService) {
var pageTitleRefreshPromise = null; var pageTitleRefreshPromise = null;
var globalStatRefreshPromise = null; var globalStatRefreshPromise = null;
@ -31,6 +31,8 @@
ariaNgNotificationService.requestBrowserPermission(); ariaNgNotificationService.requestBrowserPermission();
} }
$scope.ariaNgVersion = ariaNgBuildConfiguration.buildVersion;
$scope.globalStatusContext = { $scope.globalStatusContext = {
isEnabled: ariaNgSettingService.getGlobalStatRefreshInterval() > 0, isEnabled: ariaNgSettingService.getGlobalStatRefreshInterval() > 0,
data: ariaNgMonitorService.getGlobalStatsData() data: ariaNgMonitorService.getGlobalStatsData()

View file

@ -1,7 +1,7 @@
(function () { (function () {
'use strict'; 'use strict';
angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$routeParams', '$window', '$interval', '$timeout', '$filter', 'clipboard', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgNotificationService', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgFileService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgTitleService', 'aria2SettingService', function ($rootScope, $scope, $routeParams, $window, $interval, $timeout, $filter, clipboard, ariaNgLanguages, ariaNgCommonService, ariaNgNotificationService, ariaNgLocalizationService, ariaNgLogService, ariaNgFileService, ariaNgSettingService, ariaNgMonitorService, ariaNgTitleService, aria2SettingService) { angular.module('ariaNg').controller('AriaNgSettingsController', ['$rootScope', '$scope', '$routeParams', '$window', '$interval', '$timeout', '$filter', 'clipboard', 'ariaNgBuildConfiguration', 'ariaNgLanguages', 'ariaNgCommonService', 'ariaNgNotificationService', 'ariaNgLocalizationService', 'ariaNgLogService', 'ariaNgFileService', 'ariaNgSettingService', 'ariaNgMonitorService', 'ariaNgTitleService', 'aria2SettingService', function ($rootScope, $scope, $routeParams, $window, $interval, $timeout, $filter, clipboard, ariaNgBuildConfiguration, ariaNgLanguages, ariaNgCommonService, ariaNgNotificationService, ariaNgLocalizationService, ariaNgLogService, ariaNgFileService, ariaNgSettingService, ariaNgMonitorService, ariaNgTitleService, aria2SettingService) {
var extendType = $routeParams.extendType; var extendType = $routeParams.extendType;
var lastRefreshPageNotification = null; var lastRefreshPageNotification = null;
@ -33,6 +33,8 @@
$scope.context = { $scope.context = {
currentTab: 'global', currentTab: 'global',
ariaNgVersion: ariaNgBuildConfiguration.buildVersion,
buildCommit: ariaNgBuildConfiguration.buildCommit,
languages: ariaNgLanguages, languages: ariaNgLanguages,
titlePreview: getFinalTitle(), titlePreview: getFinalTitle(),
availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true), availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true),

View file

@ -21,6 +21,12 @@
<div class="tab-content no-padding"> <div class="tab-content no-padding">
<div class="tab-pane" ng-class="{'active': isCurrentGlobalTab()}"> <div class="tab-pane" ng-class="{'active': isCurrentGlobalTab()}">
<div class="settings-table striped hoverable"> <div class="settings-table striped hoverable">
<div class="row" ng-if="context.ariaNgVersion">
<div class="setting-key col-sm-4">
<span translate>AriaNg Version</span>
</div>
<div class="setting-value col-sm-8" ng-bind="context.ariaNgVersion + (context.buildCommit ? ' (' + context.buildCommit + ')' : '')"></div>
</div>
<div class="row"> <div class="row">
<div class="setting-key setting-key-without-desc col-sm-4"> <div class="setting-key setting-key-without-desc col-sm-4">
<span translate>Language</span> <span translate>Language</span>