Skip to content

Commit

Permalink
WIP: add link
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Weber committed Nov 6, 2018
1 parent 3d89831 commit 192519f
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 151 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ puis convertissez votre fichier .mov en gif avec "mov_to_git.sh"
* cd openmediavault-webdesk
* ./build.sh


## Tester l'install d'un package debian
* cd openmediavault-webdesk
* docker-compose -f docker-compose-empty.yml up -d
* ./enter
* dpkg -i openmediavault-webdesk_X.X.X_all.deb


## Développement sous docker

* choisir un port dans .env
Expand All @@ -54,6 +62,7 @@ Ensuite vous pouvez activer le plugin dans la section "WebDesk", et vous connect

Basé sur le tuto: https://github.com/skyajal/diypluginguide3.x/blob/master/OMV3.xDIYPluginGuide.pdf


## Installation manuelle

* Create a new user "webdesk"
Expand Down
2 changes: 1 addition & 1 deletion openmediavault-webdesk/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ case "$1" in
omv_config_add_key "${SERVICE_XPATH}" "enable" "0"
omv_config_add_key "${SERVICE_XPATH}" "name" "WebDesk for OpenMediaVault"
omv_config_add_key "${SERVICE_XPATH}" "port" "90"
omv_config_add_node "${SERVICE_XPATH}" "shares"
omv_config_add_node "${SERVICE_XPATH}" "links"
fi

# Activate package triggers. These triggers are only set during the
Expand Down
18 changes: 18 additions & 0 deletions openmediavault-webdesk/docker-compose-empty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '2.0'
services:
omv:
container_name: omv
build: ./build
volumes:
- "..:/var/www/test"
restart: always
working_dir: /var/www/test
ports:
- "0:80"
- "0:22"
- "0:90"
- "0:3000"
networks:
default:
aliases:
- "openmediavault.plugin.test"
2 changes: 1 addition & 1 deletion openmediavault-webdesk/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
- "./usr/share/openmediavault/locale/fr_FR/openmediavault-webdesk.po:/usr/share/openmediavault/locale/fr_FR/openmediavault-webdesk.po"
- "./usr/share/openmediavault/locale/openmediavault-webdesk.po:/usr/share/openmediavault/locale/openmediavault-webdesk.po"
- "./usr/share/openmediavault/datamodels/conf.service.webdesk.json:/usr/share/openmediavault/datamodels/conf.service.webdesk.json"
- "./usr/share/openmediavault/datamodels/conf.service.webdesk.share.json:/usr/share/openmediavault/datamodels/conf.service.webdesk.share.json"
- "./usr/share/openmediavault/datamodels/conf.service.webdesk.link.json:/usr/share/openmediavault/datamodels/conf.service.webdesk.link.json"
- "./usr/share/openmediavault/datamodels/rpc.webdesk.json:/usr/share/openmediavault/datamodels/rpc.webdesk.json"
- "./usr/share/openmediavault/mkconf/webdesk:/usr/share/openmediavault/mkconf/webdesk"
- "./etc/webdesk:/etc/webdesk"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@
"maximum": 65535,
"default": 8200
},
"shares": {
"links": {
"type": "object",
"properties": {
"share": {
"link": {
"type": "array",
"items": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuidv4"
"id": {
"type": "string"
},
"image": {
"type": "string"
},
"sharedfolderref": {
"type": "string",
"format": "uuidv4"
"title": {
"type": "string"
},
"text": {
"type": "string"
},
"mtype": {
"iframe": {
"type": "string"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "config",
"id": "conf.service.webdesk.link",
"title": "WebDesk Links",
"queryinfo": {
"xpath": "//services/webdesk/links/link",
"iterable": true,
"idproperty": "uuid"
},
"properties": {
"id": {
"type": "string"
},
"image": {
"type": "string"
},
"title": {
"type": "string"
},
"text": {
"type": "string"
},
"iframe": {
"type": "string"
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,30 @@
}
},{
"type": "rpc",
"id": "rpc.webdesk.setshare",
"id": "rpc.webdesk.setlink",
"params": {
"type": "object",
"properties": {
"uuid": {
"type": "string",
"format": "uuidv4",
"required": true
},
"sharedfolderref": {
"type": "string",
"format": "uuidv4",
"required": true
},
"mtype": {
"type": "string",
"enum":[ "A", "P", "V", "" ],
"required": true
}
"id": {
"type": "string",
"required": true
},
"image": {
"type": "string",
"required": true
},
"title": {
"type": "string",
"required": false
},
"text": {
"type": "string",
"required": false
},
"iframe": {
"type": "string",
"required": false
}
}
}
}]
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class OMVModuleMiniDlna extends \OMV\Engine\Module\ServiceAbstract
);
$dispatcher->addListener(
OMV_NOTIFY_CREATE | OMV_NOTIFY_MODIFY | OMV_NOTIFY_DELETE,
"org.openmediavault.conf.service.webdesk.share",
"org.openmediavault.conf.service.webdesk.link",
[ $this, "setDirty" ]
);
/*$dispatcher->addListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class OMVRpcServiceMiniDlna extends \OMV\Rpc\ServiceAbstract
{
$this->registerMethod("getSettings");
$this->registerMethod("setSettings");
$this->registerMethod("getShareList");
$this->registerMethod("getShare");
$this->registerMethod("setShare");
$this->registerMethod("deleteShare");
$this->registerMethod("getLinkList");
$this->registerMethod("getLink");
$this->registerMethod("setLink");
$this->registerMethod("deleteLink");
$this->registerMethod("doRescan");
}

Expand All @@ -43,7 +43,7 @@ class OMVRpcServiceMiniDlna extends \OMV\Rpc\ServiceAbstract
$db = \OMV\Config\Database::getInstance();
$object = $db->get("conf.service.webdesk");
// Remove useless properties from the object.
$object->remove("shares");
$object->remove("links");
return $object->getAssoc();
}

Expand All @@ -59,78 +59,68 @@ class OMVRpcServiceMiniDlna extends \OMV\Rpc\ServiceAbstract
$object->setAssoc($params);
$db->set($object);
// Remove useless properties from the object.
$object->remove("shares");
$object->remove("links");
// Return the configuration object.
return $object->getAssoc();
}

public function getShareList($params, $context)
public function getLinkList($params, $context)
{
// Validate the RPC caller context.
$this->validateMethodContext($context, ["role" => OMV_ROLE_ADMINISTRATOR]);
// Validate the parameters of the RPC service method.
$this->validateMethodParams($params, "rpc.common.getlist");
// Get the configuration object.
$db = \OMV\Config\Database::getInstance();
$objects = $db->get("conf.service.webdesk.share");
// Add additional share informations.
$objects = $db->get("conf.service.webdesk.link");
// Add additional link informations.
$objectsAssoc = [];
foreach ($objects as $objectk => &$objectv) {
// Add the new property 'sharedfoldername'.
$objectv->add("sharedfoldername", "string", gettext("n/a"));
// Get the shared folder configuration object.
$sfObject = $db->get("conf.system.sharedfolder",
$objectv->get("sharedfolderref"));
// Update the 'sharedfoldername' property.
$objectv->set("sharedfoldername", $sfObject->get("name"));
$objectsAssoc[] = $objectv->getAssoc();
}
// Filter the result.
return $this->applyFilter($objectsAssoc, $params['start'], $params['limit'],
$params['sortfield'], $params['sortdir']);
}

public function getShare($params, $context)
public function getLink($params, $context)
{
// Validate the RPC caller context.
$this->validateMethodContext($context, ["role" => OMV_ROLE_ADMINISTRATOR]);
// Validate the parameters of the RPC service method.
$this->validateMethodParams($params, "rpc.common.objectuuid");
// Get the configuration object.
$db = \OMV\Config\Database::getInstance();
return $db->getAssoc("conf.service.webdesk.share", $params['uuid']);
return $db->getAssoc("conf.service.webdesk.link", $params['id']);
}

public function setShare($params, $context)
public function setLink($params, $context)
{
// Validate the RPC caller context.
$this->validateMethodContext($context, ["role" => OMV_ROLE_ADMINISTRATOR]);
// Validate the parameters of the RPC service method.
$this->validateMethodParams($params, "rpc.webdesk.setshare");
$this->validateMethodParams($params, "rpc.webdesk.setlink");
// Prepare the configuration object.
$object = new \OMV\Config\ConfigObject("conf.service.webdesk.share");
$object = new \OMV\Config\ConfigObject("conf.service.webdesk.link");
$object->setAssoc($params);
// Set the configuration object.
$isNew = $object->isNew();
$db = \OMV\Config\Database::getInstance();
if (TRUE === $isNew) {
// Check uniqueness - Shared folder
$db->assertIsUnique($object, "sharedfolderref");
// Check uniqueness - Linkd folder
$db->assertIsUnique($object, "id");
}
$db->set($object);
// Return the configuration object.
return $object->getAssoc();
}

public function deleteShare($params, $context)
public function deleteLink($params, $context)
{
// Validate the RPC caller context.
$this->validateMethodContext($context, ["role" => OMV_ROLE_ADMINISTRATOR]);
// Validate the parameters of the RPC service method.
$this->validateMethodParams($params, "rpc.common.objectuuid");
// Delete the configuration object.
$db = \OMV\Config\Database::getInstance();
$object = $db->get("conf.service.webdesk.share", $params['uuid']);
$object = $db->get("conf.service.webdesk.link", $params['id']);
$db->delete($object);
// Return the deleted configuration object.
return $object->getAssoc();
Expand Down
Loading

0 comments on commit 192519f

Please sign in to comment.