Add new api procedures: getDefaultTaskColor(), getDefaultTaskColors() and getColorList()
This commit is contained in:
parent
f595fb2786
commit
2d6b6533ac
|
|
@ -19,4 +19,19 @@ class App extends \Core\Base
|
|||
{
|
||||
return APP_VERSION;
|
||||
}
|
||||
|
||||
public function getDefaultTaskColor()
|
||||
{
|
||||
return $this->color->getDefaultColor();
|
||||
}
|
||||
|
||||
public function getDefaultTaskColors()
|
||||
{
|
||||
return $this->color->getDefaultColors();
|
||||
}
|
||||
|
||||
public function getColorList()
|
||||
{
|
||||
return $this->color->getList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ abstract class Base extends \Core\Base
|
|||
private $both_allowed_procedures = array(
|
||||
'getTimezone',
|
||||
'getVersion',
|
||||
'getDefaultTaskColor',
|
||||
'getDefaultTaskColors',
|
||||
'getColorList',
|
||||
'getProjectById',
|
||||
'getTask',
|
||||
'getTaskByReference',
|
||||
|
|
@ -67,6 +70,7 @@ abstract class Base extends \Core\Base
|
|||
{
|
||||
if (! empty($task)) {
|
||||
$task['url'] = $this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), '', true);
|
||||
$task['color'] = $this->color->getColorProperties($task['color_id']);
|
||||
}
|
||||
|
||||
return $task;
|
||||
|
|
|
|||
|
|
@ -122,6 +122,22 @@ class Color extends Base
|
|||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get color properties
|
||||
*
|
||||
* @access public
|
||||
* @param string $color_id
|
||||
* @return array
|
||||
*/
|
||||
public function getColorProperties($color_id)
|
||||
{
|
||||
if (isset($this->default_colors[$color_id])) {
|
||||
return $this->default_colors[$color_id];
|
||||
}
|
||||
|
||||
return $this->default_colors[$this->getDefaultColor()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available colors
|
||||
*
|
||||
|
|
@ -150,6 +166,17 @@ class Color extends Base
|
|||
return $this->config->get('default_color', 'yellow');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default colors
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getDefaultColors()
|
||||
{
|
||||
return $this->default_colors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Bordercolor from string
|
||||
*
|
||||
|
|
@ -159,11 +186,8 @@ class Color extends Base
|
|||
*/
|
||||
public function getBorderColor($color_id)
|
||||
{
|
||||
if (isset($this->default_colors[$color_id])) {
|
||||
return $this->default_colors[$color_id]['border'];
|
||||
}
|
||||
|
||||
return $this->default_colors[$this->getDefaultColor()]['border'];
|
||||
$color = $this->getColorProperties($color_id);
|
||||
return $color['border'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -175,11 +199,8 @@ class Color extends Base
|
|||
*/
|
||||
public function getBackgroundColor($color_id)
|
||||
{
|
||||
if (isset($this->default_colors[$color_id])) {
|
||||
return $this->default_colors[$color_id]['background'];
|
||||
}
|
||||
|
||||
return $this->default_colors[$this->getDefaultColor()]['background'];
|
||||
$color = $this->getColorProperties($color_id);
|
||||
return $color['background'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ Almost the same thing as XML-RPC but with the JSON format.
|
|||
We use the [version 2 of the protocol](http://www.jsonrpc.org/specification).
|
||||
You must call the API with a `POST` HTTP request.
|
||||
|
||||
Kanboard support batch requests, so you can make multiple API calls in a single HTTP request. It's particularly useful for mobile clients with higher network latency.
|
||||
|
||||
Authentication
|
||||
--------------
|
||||
|
||||
|
|
@ -295,6 +297,182 @@ Response example:
|
|||
}
|
||||
```
|
||||
|
||||
### getDefaultTaskColors
|
||||
|
||||
- Purpose: **Get all default task colors**
|
||||
- Parameters: None
|
||||
- Result on success: **Color properties**
|
||||
|
||||
Request example:
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "getDefaultTaskColors",
|
||||
"id": 2108929212
|
||||
}
|
||||
```
|
||||
|
||||
Response example:
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 2108929212,
|
||||
"result": {
|
||||
"yellow": {
|
||||
"name": "Yellow",
|
||||
"background": "rgb(245, 247, 196)",
|
||||
"border": "rgb(223, 227, 45)"
|
||||
},
|
||||
"blue": {
|
||||
"name": "Blue",
|
||||
"background": "rgb(219, 235, 255)",
|
||||
"border": "rgb(168, 207, 255)"
|
||||
},
|
||||
"green": {
|
||||
"name": "Green",
|
||||
"background": "rgb(189, 244, 203)",
|
||||
"border": "rgb(74, 227, 113)"
|
||||
},
|
||||
"purple": {
|
||||
"name": "Purple",
|
||||
"background": "rgb(223, 176, 255)",
|
||||
"border": "rgb(205, 133, 254)"
|
||||
},
|
||||
"red": {
|
||||
"name": "Red",
|
||||
"background": "rgb(255, 187, 187)",
|
||||
"border": "rgb(255, 151, 151)"
|
||||
},
|
||||
"orange": {
|
||||
"name": "Orange",
|
||||
"background": "rgb(255, 215, 179)",
|
||||
"border": "rgb(255, 172, 98)"
|
||||
},
|
||||
"grey": {
|
||||
"name": "Grey",
|
||||
"background": "rgb(238, 238, 238)",
|
||||
"border": "rgb(204, 204, 204)"
|
||||
},
|
||||
"brown": {
|
||||
"name": "Brown",
|
||||
"background": "#d7ccc8",
|
||||
"border": "#4e342e"
|
||||
},
|
||||
"deep_orange": {
|
||||
"name": "Deep Orange",
|
||||
"background": "#ffab91",
|
||||
"border": "#e64a19"
|
||||
},
|
||||
"dark_grey": {
|
||||
"name": "Dark Grey",
|
||||
"background": "#cfd8dc",
|
||||
"border": "#455a64"
|
||||
},
|
||||
"pink": {
|
||||
"name": "Pink",
|
||||
"background": "#f48fb1",
|
||||
"border": "#d81b60"
|
||||
},
|
||||
"teal": {
|
||||
"name": "Teal",
|
||||
"background": "#80cbc4",
|
||||
"border": "#00695c"
|
||||
},
|
||||
"cyan": {
|
||||
"name": "Cyan",
|
||||
"background": "#b2ebf2",
|
||||
"border": "#00bcd4"
|
||||
},
|
||||
"lime": {
|
||||
"name": "Lime",
|
||||
"background": "#e6ee9c",
|
||||
"border": "#afb42b"
|
||||
},
|
||||
"light_green": {
|
||||
"name": "Light Green",
|
||||
"background": "#dcedc8",
|
||||
"border": "#689f38"
|
||||
},
|
||||
"amber": {
|
||||
"name": "Amber",
|
||||
"background": "#ffe082",
|
||||
"border": "#ffa000"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### getDefaultTaskColor
|
||||
|
||||
- Purpose: **Get default task color**
|
||||
- Parameters: None
|
||||
- Result on success: **color_id**
|
||||
|
||||
Request example:
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "getDefaultTaskColor",
|
||||
"id": 1144775215
|
||||
}
|
||||
```
|
||||
|
||||
Response example:
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1144775215,
|
||||
"result": "yellow"
|
||||
}
|
||||
```
|
||||
|
||||
### getColorList
|
||||
|
||||
- Purpose: **Get the list of task colors**
|
||||
- Parameters: none
|
||||
- Result on success: **Dictionary of color_id => color_name**
|
||||
|
||||
Request example:
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"method": "getColorList",
|
||||
"id": 1677051386
|
||||
}
|
||||
```
|
||||
|
||||
Response example:
|
||||
|
||||
```json
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1677051386,
|
||||
"result": {
|
||||
"yellow": "Yellow",
|
||||
"blue": "Blue",
|
||||
"green": "Green",
|
||||
"purple": "Purple",
|
||||
"red": "Red",
|
||||
"orange": "Orange",
|
||||
"grey": "Grey",
|
||||
"brown": "Brown",
|
||||
"deep_orange": "Deep Orange",
|
||||
"dark_grey": "Dark Grey",
|
||||
"pink": "Pink",
|
||||
"teal": "Teal",
|
||||
"cyan": "Cyan",
|
||||
"lime": "Lime",
|
||||
"light_green": "Light Green",
|
||||
"amber": "Amber"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### createProject
|
||||
|
||||
- Purpose: **Create a new project**
|
||||
|
|
@ -2045,7 +2223,12 @@ Response example:
|
|||
"recurrence_basedate": "0",
|
||||
"recurrence_parent": null,
|
||||
"recurrence_child": null,
|
||||
"url": "http:\/\/127.0.0.1:8000\/?controller=task&action=show&task_id=1&project_id=1"
|
||||
"url": "http:\/\/127.0.0.1:8000\/?controller=task&action=show&task_id=1&project_id=1",
|
||||
"color": {
|
||||
"name": "Yellow",
|
||||
"background": "rgb(245, 247, 196)",
|
||||
"border": "rgb(223, 227, 45)"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
|||
|
|
@ -97,6 +97,26 @@ class UserApi extends PHPUnit_Framework_TestCase
|
|||
$this->assertEquals('master', $this->user->getVersion());
|
||||
}
|
||||
|
||||
public function testGetDefaultColor()
|
||||
{
|
||||
$this->assertEquals('yellow', $this->user->getDefaultTaskColor());
|
||||
}
|
||||
|
||||
public function testGetDefaultColors()
|
||||
{
|
||||
$colors = $this->user->getDefaultTaskColors();
|
||||
$this->assertNotEmpty($colors);
|
||||
$this->assertArrayHasKey('red', $colors);
|
||||
}
|
||||
|
||||
public function testGetColorList()
|
||||
{
|
||||
$colors = $this->user->getColorList();
|
||||
$this->assertNotEmpty($colors);
|
||||
$this->assertArrayHasKey('red', $colors);
|
||||
$this->assertEquals('Red', $colors['red']);
|
||||
}
|
||||
|
||||
public function testGetMe()
|
||||
{
|
||||
$profile = $this->user->getMe();
|
||||
|
|
@ -137,6 +157,11 @@ class UserApi extends PHPUnit_Framework_TestCase
|
|||
$task = $this->user->getTask(1);
|
||||
$this->assertNotEmpty($task);
|
||||
$this->assertEquals('my user title', $task['title']);
|
||||
$this->assertEquals('yellow', $task['color_id']);
|
||||
$this->assertArrayHasKey('color', $task);
|
||||
$this->assertArrayHasKey('name', $task['color']);
|
||||
$this->assertArrayHasKey('border', $task['color']);
|
||||
$this->assertArrayHasKey('background', $task['color']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue