Skip to content

Commit

Permalink
add version and git commit hash in AriaNg settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
mayswind committed Nov 21, 2018
1 parent 73c8aec commit d87d49c
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 4 deletions.
4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var gulpLoadPlugins = require('gulp-load-plugins');
var browserSync = require('browser-sync');
var del = require('del');
var fs = require('fs');
var git = require('git-rev-sync');

var $ = gulpLoadPlugins();
var reload = browserSync.reload;
Expand Down Expand Up @@ -54,6 +55,8 @@ gulp.task('prepare-scripts', function () {
return gulp.src([
'src/scripts/**/*.js'
]).pipe($.plumber())
.pipe($.injectVersion({replace: '${ARIANG_VERSION}'}))
.pipe($.replace(/\${ARIANG_BUILD_COMMIT}/g, git.short()))
.pipe(gulp.dest('.tmp/scripts'))
.pipe(reload({stream: true}));
});
Expand All @@ -70,7 +73,6 @@ gulp.task('prepare-html', ['prepare-styles', 'prepare-scripts', 'prepare-views']
return gulp.src([
'src/*.html'
]).pipe($.useref({searchPath: ['.tmp', 'src', '.']}))
.pipe($.injectVersion())
.pipe($.if('js/*.js', $.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'})))
Expand Down
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"del": "^3.0.0",
"eslint-config-angular": "^0.5.0",
"eslint-plugin-angular": "^3.3.0",
"git-rev-sync": "^1.12.0",
"gulp": "^3.9.1",
"gulp-angular-templatecache": "^2.2.1",
"gulp-autoprefixer": "^5.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<header class="main-header">
<div class="logo">
<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">
<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>
Expand Down Expand Up @@ -351,6 +351,7 @@
<script src="scripts/core/router.js"></script>
<script src="scripts/core/root.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/fileTypes.js"></script>
<script src="scripts/config/initiator.js"></script>
Expand Down
1 change: 1 addition & 0 deletions src/langs/zh_Hans.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[global]
AriaNg Version=AriaNg 版本
Operation Result=操作结果
Operation Succeeded=操作成功
{{name}} is connected={{name}} 已连接
Expand Down
1 change: 1 addition & 0 deletions src/langs/zh_Hant.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[global]
AriaNg Version=AriaNg 版本
Operation Result=操作結果
Operation Succeeded=操作成功
{{name}} is connected={{name}} 已連線
Expand Down
8 changes: 8 additions & 0 deletions src/scripts/config/buildConfiguration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(function () {
'use strict';

angular.module('ariaNg').constant('ariaNgBuildConfiguration', {
buildVersion: '${ARIANG_VERSION}',
buildCommit: '${ARIANG_BUILD_COMMIT}'
});
}());
1 change: 1 addition & 0 deletions src/scripts/config/defaultLanguage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

angular.module('ariaNg').config(['$translateProvider', 'ariaNgConstants', function ($translateProvider, ariaNgConstants) {
var defaultLanguageResource = {
'AriaNg Version': 'AriaNg Version',
'Operation Result': 'Operation Result',
'Operation Succeeded': 'Operation Succeeded',
'{{name}} is connected': '{{name}} is connected',
Expand Down
4 changes: 3 additions & 1 deletion src/scripts/controllers/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
'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 globalStatRefreshPromise = null;

Expand Down Expand Up @@ -31,6 +31,8 @@
ariaNgNotificationService.requestBrowserPermission();
}

$scope.ariaNgVersion = ariaNgBuildConfiguration.buildVersion;

$scope.globalStatusContext = {
isEnabled: ariaNgSettingService.getGlobalStatRefreshInterval() > 0,
data: ariaNgMonitorService.getGlobalStatsData()
Expand Down
4 changes: 3 additions & 1 deletion src/scripts/controllers/settings-ariang.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(function () {
'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 lastRefreshPageNotification = null;

Expand Down Expand Up @@ -33,6 +33,8 @@

$scope.context = {
currentTab: 'global',
ariaNgVersion: ariaNgBuildConfiguration.buildVersion,
buildCommit: ariaNgBuildConfiguration.buildCommit,
languages: ariaNgLanguages,
titlePreview: getFinalTitle(),
availableTime: ariaNgCommonService.getTimeOptions([1000, 2000, 3000, 5000, 10000, 30000, 60000], true),
Expand Down
6 changes: 6 additions & 0 deletions src/views/settings-ariang.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<div class="tab-content no-padding">
<div class="tab-pane" ng-class="{'active': isCurrentGlobalTab()}">
<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="setting-key setting-key-without-desc col-sm-4">
<span translate>Language</span>
Expand Down

0 comments on commit d87d49c

Please sign in to comment.