Skip to content

Commit

Permalink
Merge pull request #2658 from BKapelari/More-Dashboard-Widgets-#2643
Browse files Browse the repository at this point in the history
  • Loading branch information
juliushaertl committed Oct 18, 2023
2 parents 8aa4fdc + 7c774bd commit ea67956
Show file tree
Hide file tree
Showing 11 changed files with 519 additions and 57 deletions.
2 changes: 1 addition & 1 deletion l10n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,4 @@
"Limit deck usage of groups" : "Nutzung auf Gruppen einschränken",
"Limiting Deck will block users not part of those groups from creating their own boards. Users will still be able to work on boards that have been shared with them." : "Wenn Sie Deck einschränken, können Benutzer, die nicht zu diesen Gruppen gehören, keine eigenen Boards erstellen. Die Benutzer können weiterhin an Boards arbeiten, die für sie freigegeben wurden."
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
}
8 changes: 6 additions & 2 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
use OCA\Deck\Capabilities;
use OCA\Deck\Collaboration\Resources\ResourceProvider;
use OCA\Deck\Collaboration\Resources\ResourceProviderCard;
use OCA\Deck\Dashboard\DeckWidget;
use OCA\Deck\Dashboard\DeckWidgetToday;
use OCA\Deck\Dashboard\DeckWidgetTomorrow;
use OCA\Deck\Dashboard\DeckWidgetUpcoming;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Event\AclCreatedEvent;
Expand Down Expand Up @@ -135,7 +137,9 @@ public function register(IRegistrationContext $context): void {

$context->registerSearchProvider(DeckProvider::class);
$context->registerSearchProvider(CardCommentProvider::class);
$context->registerDashboardWidget(DeckWidget::class);
$context->registerDashboardWidget(DeckWidgetUpcoming::class);
$context->registerDashboardWidget(DeckWidgetToday::class);
$context->registerDashboardWidget(DeckWidgetTomorrow::class);

$context->registerReferenceProvider(CreateCardReferenceProvider::class);

Expand Down
85 changes: 85 additions & 0 deletions lib/Dashboard/DeckWidgetToday.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Deck\Dashboard;

use OCP\Dashboard\IWidget;
use OCP\IL10N;

class DeckWidgetToday implements IWidget {

/**
*
* @var IL10N
*/
private $l10n;

public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
}

/**
* @inheritDoc
*/
public function getId(): string {
return 'deckToday';
}

/**
* @inheritDoc
*/
public function getTitle(): string {
return $this->l10n->t('Cards due today');
}

/**
* @inheritDoc
*/
public function getOrder(): int {
return 20;
}

/**
* @inheritDoc
*/
public function getIconClass(): string {
return 'icon-deck';
}

/**
* @inheritDoc
*/
public function getUrl(): ?string {
return null;
}

/**
* @inheritDoc
*/
public function load(): void {
\OCP\Util::addScript('deck', 'dashboard');
}
}
85 changes: 85 additions & 0 deletions lib/Dashboard/DeckWidgetTomorrow.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

declare(strict_types=1);

/**
* @copyright Copyright (c) 2020 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Deck\Dashboard;

use OCP\Dashboard\IWidget;
use OCP\IL10N;

class DeckWidgetTomorrow implements IWidget {

/**
*
* @var IL10N
*/
private $l10n;

public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
}

/**
* @inheritDoc
*/
public function getId(): string {
return 'deckTomorrow';
}

/**
* @inheritDoc
*/
public function getTitle(): string {
return $this->l10n->t('Cards due tomorrow');
}

/**
* @inheritDoc
*/
public function getOrder(): int {
return 20;
}

/**
* @inheritDoc
*/
public function getIconClass(): string {
return 'icon-deck';
}

/**
* @inheritDoc
*/
public function getUrl(): ?string {
return null;
}

/**
* @inheritDoc
*/
public function load(): void {
\OCP\Util::addScript('deck', 'dashboard');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
use OCP\IURLGenerator;
use OCP\Util;

class DeckWidget implements IAPIWidget, IButtonWidget, IIconWidget {
class DeckWidgetUpcoming implements IAPIWidget, IButtonWidget, IIconWidget {
private IL10N $l10n;
private OverviewService $dashboardService;
private IURLGenerator $urlGenerator;
Expand Down
79 changes: 79 additions & 0 deletions src/components/dashboard/Card.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<a :key="card.id"
:href="cardLink"
target="_blank"
class="card">
<div class="card--header">
<DueDate class="right" :card="card" />
<span class="title">{{ card.title }}</span>
</div>
<ul v-if="card.labels && card.labels.length"
class="labels">
<li v-for="label in card.labels" :key="label.id" :style="labelStyle(label)">
<span>{{ label.title }}</span>
</li>
</ul>
</a>
</template>

<script>
import DueDate from '../cards/badges/DueDate.vue'
import { generateUrl } from '@nextcloud/router'
import labelStyle from '../../mixins/labelStyle.js'
export default {
name: 'Card',
components: { DueDate },
mixins: [labelStyle],
props: {
card: {
type: Object,
required: true,
},
},
computed: {
cardLink() {
return generateUrl('/apps/deck') + `#/board/${this.card.boardId}/card/${this.card.id}`
},
},
}
</script>

<style lang="scss" scoped>
@import '../../css/labels';
.card {
display: block;
border-radius: var(--border-radius-large);
padding: 8px;
height: 60px;
&:hover {
background-color: var(--color-background-hover);
}
}
.card--header {
overflow: hidden;
.title {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
display: block;
}
}
.labels {
margin-left: 0;
}
.duedate:deep(.due) {
margin: 0 0 0 10px;
padding: 2px 4px;
font-size: 90%;
}
.right {
float: right;
}
</style>
73 changes: 56 additions & 17 deletions src/init-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,64 @@ import './shared-init.js'

const debug = process.env.NODE_ENV !== 'production'

let _imports = null

const getAsyncImports = async () => {
if (_imports) {
return _imports
}

const { default: Vue } = await import('vue')
const { default: Vuex } = await import('vuex')
const { default: dashboard } = await import('./store/dashboard.js')

Vue.prototype.t = t
Vue.prototype.n = n
Vue.prototype.OC = OC
Vue.use(Vuex)

const store = new Vuex.Store({
modules: {
dashboard,
},
strict: debug,
})

_imports = {
store, Vue,
}

return _imports
}

document.addEventListener('DOMContentLoaded', () => {
OCA.Dashboard.register('deck', async (el) => {
const { default: Vue } = await import('vue')
const { default: Vuex } = await import('vuex')
const { default: dashboard } = await import('./store/dashboard.js')

const { default: Dashboard } = await import('./views/Dashboard.vue')
Vue.prototype.t = t
Vue.prototype.n = n
Vue.prototype.OC = OC
Vue.use(Vuex)

const store = new Vuex.Store({
modules: {
dashboard,
},
strict: debug,
})
const View = Vue.extend(Dashboard)
const { Vue, store } = await getAsyncImports()
const { default: DashboardUpcoming } = await import('./views/DashboardUpcoming.vue')

const View = Vue.extend(DashboardUpcoming)
const vm = new View({
propsData: {},
store,
}).$mount(el)
return vm
})

OCA.Dashboard.register('deckToday', async (el) => {
const { Vue, store } = await getAsyncImports()
const { default: DashboardToday } = await import('./views/DashboardToday.vue')
const View = Vue.extend(DashboardToday)
const vm = new View({
propsData: {},
store,
}).$mount(el)
return vm
})

OCA.Dashboard.register('deckTomorrow', async (el) => {
const { Vue, store } = await getAsyncImports()
const { default: DashboardTomorrow } = await import('./views/DashboardTomorrow.vue')
const View = Vue.extend(DashboardTomorrow)
const vm = new View({
propsData: {},
store,
Expand Down

0 comments on commit ea67956

Please sign in to comment.