diff --git a/admin.php b/admin.php index 0a542924..84c8ad7c 100644 --- a/admin.php +++ b/admin.php @@ -13,5 +13,24 @@ namespace OCA\Updater; \OCP\User::checkAdminUser(); + +\OCP\Util::addScript(App::APP_ID, '3rdparty/angular'); +\OCP\Util::addScript(App::APP_ID, 'app'); +\OCP\Util::addScript(App::APP_ID, 'controllers'); + +\OCP\Util::addStyle(App::APP_ID, 'updater'); + +if (!@file_exists(App::getBackupBase())){ + Helper::mkdir(App::getBackupBase()); +} + +$updater = new \OC\Updater(); +$data = $updater->check('http://apps.owncloud.com/updater.php'); +$isNewVersionAvailable = isset($data['version']) && $data['version'] != '' && $data['version'] !== Array(); + $tmpl = new \OCP\Template(App::APP_ID, 'admin'); +$lastCheck = \OC_Appconfig::getValue('core', 'lastupdatedat'); +$tmpl->assign('checkedAt', \OCP\Util::formatDate($lastCheck)); +$tmpl->assign('isNewVersionAvailable', $isNewVersionAvailable); +$tmpl->assign('version', isset($data['versionstring']) ? $data['versionstring'] : ''); return $tmpl->fetchPage(); \ No newline at end of file diff --git a/ajax/backup/list.php b/ajax/backup/list.php index 5ffd9c22..5f98edfa 100644 --- a/ajax/backup/list.php +++ b/ajax/backup/list.php @@ -28,8 +28,16 @@ } $result[] = array( 'title' => $item, - 'date' => date ("F d Y H:i:s", filectime(App::getBackupBase() . '/' . $item)) + 'date' => date ("F d Y H:i:s", filectime(App::getBackupBase() . '/' . $item)), + 'size' => human_filesize(filesize(App::getBackupBase() . '/' . $item)) ); } \OCP\JSON::success(array('data' => $result)); + +/* adapted from http://php.net/manual/de/function.filesize.php */ +function human_filesize($bytes, $decimals = 2) { + $sz = 'BKMGTP'; + $factor = floor((strlen($bytes) - 1) / 3); + return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$sz[$factor]; +} diff --git a/appinfo/routes.php b/appinfo/routes.php index edb29fa7..027dd71f 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -2,8 +2,6 @@ /** @var $this \OC\Route\Router */ -$this->create('updater_update', 'update.php') - ->actionInclude('updater/update.php'); $this->create('updater_admin', 'admin.php') ->actionInclude('updater/admin.php'); $this->create('updater_ajax_backup', 'ajax/backup.php') diff --git a/css/updater.css b/css/updater.css index d0961782..8220ffa4 100644 --- a/css/updater.css +++ b/css/updater.css @@ -1,40 +1,28 @@ -#upd-progress { - margin: 30px 0; +.updater-progress { + margin: 2em 0; } -#updater-content p { - margin: 10px 0; +.updater-admin p { + margin: 0.5em 0; } -#updater-content { - width: 640px; - margin: 20px 0 20px -180px; - padding: 5px 20px 10px 20px; - background: #fff; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - cursor: default; -} - -#updater-content table { +.updater-backups-table { width: 100%; - margin: 20px 0; + margin: 0.8em 0; } -#updater-content table th { - padding: 5px 10px; +.updater-backups-table th { -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; filter: alpha(opacity=50); opacity: .5; } -#updater-content table td { - padding: 10px; +.updater-backups-table td { + padding: 10px 0; } -#updater-content .icon-delete { +.updater-backups-table .icon-delete { cursor: pointer; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; filter: alpha(opacity=50); @@ -46,14 +34,25 @@ display: inline-block; position: relative; margin: 0; - padding: 0 20px; - text-align: center; + padding: 0 2.3em 0 1.2em; + text-align: left; line-height: 30px; height: 30px; - min-width: 150px; background-position: right; } +.updater-warning-p { + padding-left: 0.5em; +} + +.updater-space-bottom { + padding-bottom: 1em; +} + +.track-progress li:first-child { + padding-left: 0; +} + .track-progress li.current { font-weight: bold; } diff --git a/js/app.js b/js/app.js index 6115e245..0c734f36 100644 --- a/js/app.js +++ b/js/app.js @@ -2,7 +2,7 @@ angular.module('updater', []). config(['$routeProvider', function($routeProvider) { $routeProvider. - when('/index', { controller: backupCtrl}). - when('/update', {templateUrl: 'templates/partials/update.html', controller: updateCtrl}). - otherwise({redirectTo: '/index'}); + when('/index', { controller: backupCtrl } ). + when('/update', { templateUrl: 'templates/partials/update.html', controller: updateCtrl } ). + otherwise( { redirectTo: '/index' } ); }]); diff --git a/js/controllers.js b/js/controllers.js index 98feee31..6f7dca0a 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -1,4 +1,5 @@ /* global oc_requesttoken */ + function updateCtrl($scope, $http) { $scope.step = 0; $scope.backup = ''; @@ -10,17 +11,17 @@ function updateCtrl($scope, $http) { if (data && data.message) { message = data.message; } - $('
').append($('

').append(message)).addClass('warning').appendTo($('#upd-progress')); + $('
').append($('

').addClass('updater-warning-p').append(message)).addClass('warning').appendTo($('.updater-progress')); }; $scope.crash = function () { var message = t('updater', 'Server error. Please check web server log file for details'); - $('
').append($('

').append(message)).addClass('warning').appendTo($('#upd-progress')); + $('
').append($('

').addClass('updater-warning-p').append(message)).addClass('warning').appendTo($('.updater-progress')); }; $scope.update = function () { if ($scope.step === 0) { - $('#upd-progress').empty().show(); + $('.updater-progress').empty().show(); $('#upd-step-title').show(); $('.track-progress li').first().addClass('current'); $('.updater-spinner').hide(); @@ -49,7 +50,7 @@ function updateCtrl($scope, $http) { $('.updater-spinner:eq(1)').fadeIn(); $('.track-progress li.current').next().addClass('current'); $('.track-progress li.done').removeClass('current'); - $('

').append(t('updater', 'Here is your backup:') + ' ' + $scope.backup).appendTo($('#upd-progress')); + $('

').append(t('updater', 'Here is your backup:') + ' ' + $scope.backup).appendTo($('.updater-progress')); $http.post( OC.filePath('updater', 'ajax', 'download.php'), { @@ -93,8 +94,8 @@ function updateCtrl($scope, $http) { if (OC.webroot !== '') { href = OC.webroot; } - $('

').append(t('updater', 'All done. Click to the link below to start database upgrade.')).appendTo($('#upd-progress')); - $('

').addClass('bold').append($('' + title + '').addClass('button')).appendTo($('#upd-progress')); + $('

').addClass('updater-space-bottom').append(t('updater', 'All done. Click to the link below to start database upgrade.')).appendTo($('.updater-progress')); + $('

').addClass('bold').append($('' + title + '').addClass('button')).appendTo($('.updater-progress')); } else { $scope.fail(data); } diff --git a/templates/admin.php b/templates/admin.php index 15a0028a..19bbf81c 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -11,8 +11,61 @@ */ ?> - -
-

t('Updater')) ?>

- t('Open Update Center')) ?> + +
+
+

t('Updates')) ?>

+

+ t('A new version is available: %s', array($_['version']))) ?> +

+

+ t('Up to date. Checked on %s', array($_['checkedAt']))) ?> +

+ + + +
+
+

t('Update-Backups')) ?>

+

+ t('Backup directory')) ?>: + +

+

t('No backups found')) ?>

+ + + + + + + + + + + + + + + + + +
 t('Backup')) ?>t('Done on')) ?>t('Size')) ?>
{{entry.title}}{{entry.date}}{{entry.size}}
+
diff --git a/templates/update.php b/templates/update.php deleted file mode 100644 index 31ce2337..00000000 --- a/templates/update.php +++ /dev/null @@ -1,69 +0,0 @@ - - -
-
-

t('Updates')) ?>

-

- t('A new version is available: %s', array($_['version']))) ?> -

-

- t('Up to date. Checked on %s', array($_['checkedAt']))) ?> -

- - - -
-
-

t('Backups')) ?>

-

- t('Backup directory')) ?>: - -

-

t('No backups found')) ?>

- - - - - - - - - - - - - - - -
t('Backup')) ?>t('Done on')) ?> 
{{entry.title}}{{entry.date}}
-
-
diff --git a/update.php b/update.php deleted file mode 100644 index d7c09289..00000000 --- a/update.php +++ /dev/null @@ -1,36 +0,0 @@ -check('http://apps.owncloud.com/updater.php'); -$isNewVersionAvailable = isset($data['version']) && $data['version'] != '' && $data['version'] !== Array(); - -$tmpl = new \OCP\Template(App::APP_ID, 'update', 'guest'); -$lastCheck = \OC_Appconfig::getValue('core', 'lastupdatedat'); -$tmpl->assign('checkedAt', \OCP\Util::formatDate($lastCheck)); -$tmpl->assign('isNewVersionAvailable', $isNewVersionAvailable); -$tmpl->assign('version', isset($data['versionstring']) ? $data['versionstring'] : ''); -$tmpl->printPage();