Merge pull request #133 from Yurko-Fedoriv/title-improvements

Various page title view improvements; misc fixes
This commit is contained in:
hamza zia 2015-03-22 21:55:27 +08:00
commit 772268ef38
5 changed files with 28 additions and 24 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.DS_STORE .DS_STORE
.idea

View File

@ -1,36 +1,38 @@
angular angular
.module('webui.services.configuration', []) .module('webui.services.configuration', [])
.constant('$name', 'webui-aria2') // name used accross the entire UI .constant('$name', 'Aria2 WebUI') // name used across the entire UI
.constant('$titlePattern', 'active: {active} - waiting: {waiting} - stopped: {stopped} — {name}')
.constant('$pageSize', 11) // number of downloads shown before pagination kicks in .constant('$pageSize', 11) // number of downloads shown before pagination kicks in
.constant('$authconf', { // default authentication configuration, never fill it in case the webui is hosted in public IP as it can be compromised .constant('$authconf', { // default authentication configuration, never fill it in case the webui is hosted in public IP as it can be compromised
host: 'localhost', host: 'localhost',
port: 6800, port: 6800,
encrypt: false, encrypt: false,
auth: { // either add the token field or the user and pass field, not both. auth: { // either add the token field or the user and pass field, not both.
// token: '$YOUR_SECRET_ATOKEN$', // token: '$YOUR_SECRET_TOKEN$'
/*-----------------------------*/
// user: '*YOUR_USERNAME*', // user: '*YOUR_USERNAME*',
// pass: '*YOUR_SECRET_PASS*', // pass: '*YOUR_SECRET_PASS*'
} }
}) })
.constant('$enable', { .constant('$enable', {
torrent: true, // bittorrent support only enabled if supported by aria2 build, set to false otherwise to permanantly disable it torrent: true, // bittorrent support only enabled if supported by aria2 build, set to false otherwise to permanently disable it
metalink: true, // metalink support only enabled if supported by aria2 build, set to false to permanantly disable it metalink: true, // metalink support only enabled if supported by aria2 build, set to false to permanently disable it
sidebar: { // configuration related to the sidebar next to the list of downloads sidebar: { // configuration related to the sidebar next to the list of downloads
show: true, // set to false to completly hide the sidebar. Other elements inside will be automatically hidden show: true, // set to false to completely hide the sidebar. Other elements inside will be automatically hidden
stats: true, // set to false to hide the global statistic section (containts the speed graph for now) stats: true, // set to false to hide the global statistic section (contains the speed graph for now)
filters: true, // set to false to hide the Download Filters filters: true, // set to false to hide the Download Filters
starredProps: true, // only shown when atleast one property is added to the starred list, set to false to permanantly hide the Quick Access Settings inside the sidebar starredProps: true // only shown when at least one property is added to the starred list, set to false to permanently hide the Quick Access Settings inside the sidebar
} }
}) })
.constant('$starredProps', [ // default list of Quick Access Properties. Can be overwriden by making modification through the Global Settings dialog .constant('$starredProps', [ // default list of Quick Access Properties. Can be overridden by making modification through the Global Settings dialog
// go to Global Settings dialog to see their description // go to Global Settings dialog to see their description
'dir', 'conf-path', 'auto-file-renaming', 'max-connection-per-server', 'dir', 'conf-path', 'auto-file-renaming', 'max-connection-per-server'
]) ])
.constant('$downloadProps', [ // Similar to starred Quick Access properties but for adding new downloads. .constant('$downloadProps', [ // Similar to starred Quick Access properties but for adding new downloads.
// go to Advance Download Options when adding a new download to view the list of possible options // go to Advance Download Options when adding a new download to view the list of possible options

View File

@ -9,7 +9,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title ng-controller="NavCtrl">{{ name }}</title> <title ng-bind="$root.pageTitle">Aria2 WebUI</title>
<link rel="stylesheet" href="css/bootstrap.css"> <link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/font-awesome.min.css"> <link rel="stylesheet" href="css/font-awesome.min.css">
@ -210,7 +210,7 @@
<!-- {{{ alerts --> <!-- {{{ alerts -->
<div ng-controller="AlertCtrl" class="row-fluid alerts"> <div ng-controller="AlertCtrl" class="row-fluid alerts">
<div class="alert alert-{{alert.type}}" ng-repeat="alert in pendingAlerts"> <div class="alert alert-{{alert.type == 'error' ? 'danger' : alert.type}}" ng-repeat="alert in pendingAlerts">
<button type="button" class="close" ng-click="removeAlert($index)">x</button> <button type="button" class="close" ng-click="removeAlert($index)">x</button>
<span ng-bind-html="alert.msg"></span> <span ng-bind-html="alert.msg"></span>
</div> </div>

View File

@ -8,11 +8,11 @@ angular
'$scope', '$name', '$enable', '$rpc', '$rpchelpers', '$utils', '$alerts', '$modals', '$scope', '$name', '$enable', '$rpc', '$rpchelpers', '$utils', '$alerts', '$modals',
'$fileSettings', '$activeInclude', '$waitingExclude', '$pageSize', '$fileSettings', '$activeInclude', '$waitingExclude', '$pageSize',
// for document title // for document title
'$window', '$rootScope',
function( function(
scope, name, enable, rpc, rhelpers, utils, alerts, modals, scope, name, enable, rpc, rhelpers, utils, alerts, modals,
fsettings, activeInclude, waitingExclude, pageSize, fsettings, activeInclude, waitingExclude, pageSize,
window rootScope
) { ) {
scope.name = name; // default UI name scope.name = name; // default UI name
@ -152,10 +152,11 @@ function(
}); });
}); });
rootScope.pageTitle = utils.getTitle();
rpc.subscribe('getGlobalStat', [], function(data) { rpc.subscribe('getGlobalStat', [], function(data) {
scope.$apply(function() { scope.$apply(function() {
scope.gstats = data[0]; scope.gstats = data[0];
window.document.title = utils.getTitle(scope.gstats); rootScope.pageTitle = utils.getTitle(scope.gstats);
}); });
}); });

View File

@ -1,5 +1,5 @@
angular.module('webui.services.utils', ['webui.services.configuration']) angular.module('webui.services.utils', ['webui.services.configuration'])
.factory('$utils', ['$filter', "$name", function(filter, $name) { .factory('$utils', ['$filter', '$name', '$titlePattern', function(filter, $name, $titlePattern) {
var rnd16 = (function() { var rnd16 = (function() {
"use strict"; "use strict";
var rndBuffer = new Uint8Array(16); var rndBuffer = new Uint8Array(16);
@ -118,14 +118,14 @@ angular.module('webui.services.utils', ['webui.services.configuration'])
}, },
// get info title from global statistics // get info title from global statistics
getTitle: function(stats) { getTitle: function(stats) {
var title = if(!stats) {
'active: ' + stats.numActive stats = {};
+ ' - waiting: ' + stats.numWaiting }
+ ' - stopped: ' + stats.numStopped return $titlePattern
+ ' — ' .replace('{active}', stats.numActive || '⌛')
+ $name; .replace('{waiting}', stats.numWaiting || '⌛')
.replace('{stopped}', stats.numStopped || '⌛')
return title; .replace('{name}', $name);
}, },
// get download chunks from aria2 bitfield // get download chunks from aria2 bitfield