+
+
+
+
diff --git a/src/mixins/color.js b/src/mixins/color.js
new file mode 100644
index 000000000..7f2397ebd
--- /dev/null
+++ b/src/mixins/color.js
@@ -0,0 +1,85 @@
+/*
+ * @copyright Copyright (c) 2018 Julius Härtl
+ *
+ * @author Julius Härtl
+ *
+ * @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 .
+ *
+ */
+
+export default {
+ methods: {
+ hexToRgb(hex) {
+ let result = /^#?([A-Fa-f\d]{2})([A-Fa-f\d]{2})([A-Fa-f\d]{2})$/i.exec(hex)
+ return result
+ ? {
+ r: parseInt(result[1], 16),
+ g: parseInt(result[2], 16),
+ b: parseInt(result[3], 16)
+ } : null
+ },
+ rgb2hls(rgb) {
+ // RGB2HLS by Garry Tan
+ // http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c
+ const r = rgb.r / 255
+ const g = rgb.g / 255
+ const b = rgb.b / 255
+ let max = Math.max(r, g, b)
+ let min = Math.min(r, g, b)
+ let h
+ let s
+ let l = (max + min) / 2
+
+ if (max === min) {
+ h = s = 0 // achromatic
+ } else {
+ const d = max - min
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min)
+ switch (max) {
+ case r:
+ h = (g - b) / d + (g < b ? 6 : 0)
+ break
+ case g:
+ h = (b - r) / d + 2
+ break
+ case b:
+ h = (r - g) / d + 4
+ break
+ }
+ h /= 6
+ }
+ return {
+ h, l, s
+ }
+ },
+ textColor(hex) {
+
+ let rgb = this.hexToRgb(hex)
+ if (rgb === null) {
+ return '#000000'
+ }
+ const { l } = this.rgb2hls(rgb)
+
+ if (l < 0.5) {
+ return '#ffffff'
+ } else {
+ return '#000000'
+ }
+
+ }
+
+ }
+}
diff --git a/src/router.js b/src/router.js
index 836a34d7a..29c295607 100644
--- a/src/router.js
+++ b/src/router.js
@@ -26,6 +26,9 @@ import { generateUrl } from 'nextcloud-server/dist/router'
import { BOARD_FILTERS } from './store/main'
import Boards from './components/boards/Boards'
import Board from './components/board/Board'
+import Sidebar from './components/Sidebar'
+import BoardSidebar from './components/board/BoardSidebar'
+import CardSidebar from './components/card/CardSidebar'
Vue.use(Router)
@@ -65,12 +68,34 @@ export default new Router({
{
path: '/boards/:id',
name: 'board',
- component: Board,
- props: (route) => {
- return {
- id: parseInt(route.params.id, 10)
+ components: {
+ default: Board,
+ sidebar: Sidebar
+ },
+ props: {
+ default: (route) => {
+ return {
+ id: parseInt(route.params.id, 10)
+ }
}
- }
+ },
+ children: [
+ {
+ path: 'details',
+ name: 'board.details',
+ components: {
+ default: Boards,
+ sidebar: BoardSidebar
+ }
+ },
+ {
+ path: 'cards/:cardId',
+ name: 'card',
+ components: {
+ sidebar: CardSidebar
+ }
+ }
+ ]
}
]
})
diff --git a/src/services/StackApi.js b/src/services/StackApi.js
new file mode 100644
index 000000000..5b2785117
--- /dev/null
+++ b/src/services/StackApi.js
@@ -0,0 +1,109 @@
+/*
+ * @copyright Copyright (c) 2018 Michael Weimann
+ *
+ * @author Michael Weimann
+ *
+ * @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 .
+ *
+ */
+
+import axios from 'nextcloud-axios'
+
+/**
+ * This class handles all the api communication with the Deck backend.
+ */
+export class BoardApi {
+
+ url(url) {
+ url = `/apps/deck${url}`
+ return OC.generateUrl(url)
+ }
+
+ /**
+ * Updates a board.
+ *
+ * @param {Board} board
+ * @return Promise
+ */
+ updateBoard(board) {
+ return axios.put(this.url(`/boards/${board.id}`), board)
+ .then(
+ (response) => {
+ return Promise.resolve(response.data)
+ },
+ (err) => {
+ return Promise.reject(err)
+ }
+ )
+ .catch((err) => {
+ return Promise.reject(err)
+ })
+ }
+
+ /**
+ * Creates a new board.
+ *
+ * @param {{String title, String color, String hashedColor}} boardData The board data to send.
+ * hashedColor is the color in hex format, e.g. "#ff0000"
+ * color is the same color without the "#"
+ * @return Promise
+ */
+ createBoard(boardData) {
+ return axios.post(this.url('/boards'), boardData)
+ .then(
+ (response) => {
+ return Promise.resolve(response.data)
+ },
+ (err) => {
+ return Promise.reject(err)
+ }
+ )
+ .catch((err) => {
+ return Promise.reject(err)
+ })
+ }
+
+ loadBoards() {
+ return axios.get(this.url('/boards'))
+ .then(
+ (response) => {
+ return Promise.resolve(response.data)
+ },
+ (err) => {
+ return Promise.reject(err)
+ }
+ )
+ .catch((err) => {
+ return Promise.reject(err)
+ })
+ }
+
+ loadById(id) {
+ return axios.get(this.url(`/boards/${id}`))
+ .then(
+ (response) => {
+ return Promise.resolve(response.data)
+ },
+ (err) => {
+ return Promise.reject(err)
+ }
+ )
+ .catch((err) => {
+ return Promise.reject(err)
+ })
+ }
+
+}