diff options
-rw-r--r-- | css/admin.scss | 4 | ||||
-rw-r--r-- | js/admin.js | 15 | ||||
-rw-r--r-- | lib/AppInfo/Application.php | 6 | ||||
-rw-r--r-- | lib/Controller/TemplatesController.php | 18 | ||||
-rw-r--r-- | lib/Settings/Admin.php | 20 | ||||
-rw-r--r-- | templates/admin.php | 31 |
6 files changed, 66 insertions, 28 deletions
diff --git a/css/admin.scss b/css/admin.scss index 3c4e065f..9ba9b734 100644 --- a/css/admin.scss +++ b/css/admin.scss @@ -16,6 +16,10 @@ margin: -6px; margin-left: 10px; opacity: .5; + white-space: nowrap; + line-height: 44px; + padding-left: 44px; + font-size: 16px; &:hover, &:focus, &:active { diff --git a/js/admin.js b/js/admin.js index 6c7f3b49..9984fd77 100644 --- a/js/admin.js +++ b/js/admin.js @@ -274,26 +274,29 @@ function initTemplateManager() { add: function (e, data) { // submit on file selection data.submit(); - console.log(e, data) + inputElmt.disabled = true; + buttonElmt.className = 'icon-loading-small'; }, submit: function(e, data) { - data.formData = _.extend(data.formData || {}, { requesttoken: OC.requestToken }); }, - done: function(e, data) { + success: function(e, data) { inputElmt.disabled = false; buttonElmt.className = 'icon-add'; - console.log(e, data) }, fail: function(e, data) { - inputElmt.disabled = false; buttonElmt.className = 'icon-add'; - console.log(e, data) + buttonElmt.textContent = t('richdocuments', 'An error occured'); + // TODO: add error message from server + setTimeout(function() { + inputElmt.disabled = false; + buttonElmt.textContent = ''; + }, 2000) } }); } diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index fea4d0fe..5f4468ca 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -24,21 +24,19 @@ namespace OCA\Richdocuments\AppInfo; -use OC\AppFramework\Utility\TimeFactory; use OCA\Richdocuments\Capabilities; use OCA\Richdocuments\Preview\MSExcel; use OCA\Richdocuments\Preview\MSWord; use OCA\Richdocuments\Preview\OOXML; use OCA\Richdocuments\Preview\OpenDocument; use OCP\AppFramework\App; -use OCP\AppFramework\IAppContainer; use OCP\IPreview; -class Application extends App { +class Application extends App { const APPNAME = 'richdocuments'; - public function __construct (array $urlParams = array()) { + public function __construct(array $urlParams = array()) { parent::__construct(self::APPNAME, $urlParams); $this->getContainer()->registerCapability(Capabilities::class); diff --git a/lib/Controller/TemplatesController.php b/lib/Controller/TemplatesController.php index dabcdcea..5bb701f8 100644 --- a/lib/Controller/TemplatesController.php +++ b/lib/Controller/TemplatesController.php @@ -56,18 +56,18 @@ class TemplatesController extends Controller { * @param string $appName * @param IRequest $request * @param L10N $l10n - * @param TemplateManager $templateManager + * @param TemplateManager $manager */ public function __construct(string $appName, IRequest $request, IL10N $l10n, - TemplateManager $templateManager) { + TemplateManager $manager) { parent::__construct($appName, $request); - $this->appName = $appName; - $this->request = $request; - $this->l10n = $l10n; - $this->manager = $templateManager; + $this->appName = $appName; + $this->request = $request; + $this->l10n = $l10n; + $this->manager = $manager; } /** @@ -81,7 +81,7 @@ class TemplatesController extends Controller { */ public function getPreview(string $templateName) { try { - $template = $this->manager->get($templateName); + $template = $this->templateManager->get($templateName); //return DataDisplayResponse($template->getPreview(), Http::STATUS_OK, ['Content-Type' => 'image/png']); } catch (NotFoundException $e) { @@ -115,7 +115,7 @@ class TemplatesController extends Controller { unlink($files['tmp_name'][0]); - $template = $this->manager->add($templateName, $templateFile); + $template = $this->templateManager->add($templateName, $templateFile); return new JSONResponse( ['data' => ['data' => $template]], @@ -138,7 +138,7 @@ class TemplatesController extends Controller { */ public function delete(string $templateName) { try { - $manager->delete($templateName); + $this->templateManager->delete($templateName); return new JSONResponse( ['data' => ['status' => 'success']], diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index bb95371d..13db7aaf 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -25,9 +25,7 @@ namespace OCA\Richdocuments\Settings; use OCA\Richdocuments\TemplateManager; use OCP\AppFramework\Http\TemplateResponse; -use OCP\Defaults; use OCP\IConfig; -use OCP\IL10N; use OCP\Settings\ISettings; class Admin implements ISettings { @@ -37,13 +35,17 @@ class Admin implements ISettings { /** @var TemplateManager */ private $templateManager; + /** + * Admin template settings + * + * @param string $appName * @param IConfig $config * @param TemplateManager $templateManager */ public function __construct(IConfig $config, TemplateManager $templateManager) { - $this->config = $config; + $this->config = $config; $this->templateManager = $templateManager; } /** @@ -54,13 +56,13 @@ class Admin implements ISettings { 'richdocuments', 'admin', [ - 'wopi_url' => $this->config->getAppValue('richdocuments', 'wopi_url'), - 'edit_groups' => $this->config->getAppValue('richdocuments', 'edit_groups'), - 'use_groups' => $this->config->getAppValue('richdocuments', 'use_groups'), - 'doc_format' => $this->config->getAppValue('richdocuments', 'doc_format'), - 'external_apps' => $this->config->getAppValue('richdocuments', 'external_apps'), + 'wopi_url' => $this->config->getAppValue('richdocuments', 'wopi_url'), + 'edit_groups' => $this->config->getAppValue('richdocuments', 'edit_groups'), + 'use_groups' => $this->config->getAppValue('richdocuments', 'use_groups'), + 'doc_format' => $this->config->getAppValue('richdocuments', 'doc_format'), + 'external_apps' => $this->config->getAppValue('richdocuments', 'external_apps'), 'canonical_webroot' => $this->config->getAppValue('richdocuments', 'canonical_webroot'), - 'templates' => $this->templateManager->getGlobals(), + 'templates' => $this->templateManager->getGlobals() ], 'blank' ); diff --git a/templates/admin.php b/templates/admin.php index 2f9c962d..00db10bf 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -1,6 +1,8 @@ <?php style('richdocuments', 'admin'); script('richdocuments', 'admin'); +script('files', 'jquery.fileupload'); + /** @var array $_ */ ?> <div class="section" id="richdocuments"> @@ -50,3 +52,32 @@ script('richdocuments', 'admin'); <p class="rd-settings-documentation"><em><?php p($l->t('Canonical webroot, in case there are multiple, for Collabora to use. Provide the one with least restrictions. Eg: Use non-shibbolized webroot if this instance is accessed by both shibbolized and non-shibbolized webroots. You can ignore this setting if only one webroot is used to access this instance.')) ?></em></p> </div> </div> +<form class="section" id="richdocuments-templates" method="post" action="/template/"> + <input class="hidden-visually" id="add-template" type="file" /> + <h2> + <?php p($l->t('Global templates')) ?> + <label for="add-template" class="icon-add" title="<?php p($l->t('Add a new template')); ?>"></label> + </h2> + <?php if (!empty($_['templates'])) { ?> + <ul> + <?php foreach ($_['templates'] as $template) {?> + <li> + <figure> + <figcaption><?php p($l->t('description')) ?></figcaption> + </figure> + <div> + <a href="#" class="icon-delete"></a> + </div> + </li> + <?php } ?> + </ul> + <?php } else { ?> + <div id="emptycontent"> + <div class="icon-file"></div> + <h2> + <?php p($l->t('No templates defined.')); ?> + </h2> + <label for="add-template"><?php p($l->t('Add a new one?')); ?></label> + </div> + <?php } ?> +</form> |