Show dialog with incoming share requests

This commit is contained in:
brantje 2016-10-02 16:10:04 +02:00
parent 200a18a0e8
commit ca408ef0a3
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
9 changed files with 75 additions and 16 deletions

View file

@ -496,6 +496,12 @@
<notnull>false</notnull> <notnull>false</notnull>
<length>64</length> <length>64</length>
</field> </field>
<field>
<name>from_user_id</name>
<type>text</type>
<notnull>false</notnull>
<length>64</length>
</field>
<field> <field>
<name>target_vault_id</name> <name>target_vault_id</name>
<type>integer</type> <type>integer</type>

View file

@ -5,7 +5,7 @@
<description>A password manager for Nextcloud</description> <description>A password manager for Nextcloud</description>
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Sander Brand</author> <author>Sander Brand</author>
<version>1.0.2.17</version> <version>1.0.2.18</version>
<namespace>Passman</namespace> <namespace>Passman</namespace>
<category>other</category> <category>other</category>
<website>https://github.com/nextcloud/passman/</website> <website>https://github.com/nextcloud/passman/</website>

View file

@ -74,7 +74,8 @@ class ShareController extends ApiController {
* Assemble notification * Assemble notification
*/ */
$credential = $this->credentialService->getCredentialById($item_id, $this->userId->getUID()); $credential = $this->credentialService->getCredentialById($item_id, $this->userId->getUID());
$result = $this->shareService->createBulkRequests($item_id, $item_guid, $vaults, $permissions); $credential_owner = $credential->getUserId();
$result = $this->shareService->createBulkRequests($item_id, $item_guid, $vaults, $permissions, $credential_owner);
if ($credential) { if ($credential) {
$processed_users = array(); $processed_users = array();

View file

@ -63,6 +63,13 @@ angular.module('passmanApp')
ShareService.getPendingRequests().then(function (shareRequests) { ShareService.getPendingRequests().then(function (shareRequests) {
console.log(shareRequests) console.log(shareRequests)
if(shareRequests.length > 0){
$scope.incoming_share_requests = shareRequests;
jQuery('.share_popup').dialog({
width: 600,
position:['center', 90]
});
}
}); });
$scope.addCredential = function () { $scope.addCredential = function () {

View file

@ -51,7 +51,11 @@ angular.module('passmanApp')
}, },
getPendingRequests: function () { getPendingRequests: function () {
var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/pending'); var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/pending');
return $http.get(queryUrl); return $http.get(queryUrl).then(function (response) {
if(response.data){
return response.data;
}
});
}, },
saveSharingRequest: function (request, crypted_shared_key) { saveSharingRequest: function (request, crypted_shared_key) {
var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/save'); var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/save');

File diff suppressed because one or more lines are too long

View file

@ -31,6 +31,8 @@ use OCP\AppFramework\Db\Entity;
* @method integer getPermissions() * @method integer getPermissions()
* @method void setCreated(integer $value) * @method void setCreated(integer $value)
* @method integer getCreated() * @method integer getCreated()
* @method void setFromUserId(integer $value)
* @method integer getFromUserId()
*/ */
class ShareRequest extends PermissionEntity implements \JsonSerializable { class ShareRequest extends PermissionEntity implements \JsonSerializable {
@ -43,7 +45,8 @@ class ShareRequest extends PermissionEntity implements \JsonSerializable {
$targetVaultGuid, $targetVaultGuid,
$sharedKey, $sharedKey,
$permissions, $permissions,
$created; $created,
$fromUserId;
public function __construct() { public function __construct() {
// add types in constructor // add types in constructor
@ -68,7 +71,7 @@ class ShareRequest extends PermissionEntity implements \JsonSerializable {
'target_user_id' => $this->getTargetUserId(), 'target_user_id' => $this->getTargetUserId(),
'target_vault_id' => $this->getTargetVaultId(), 'target_vault_id' => $this->getTargetVaultId(),
'target_vault_guid' => $this->getTargetVaultGuid(), 'target_vault_guid' => $this->getTargetVaultGuid(),
'item_guid' => $this->getItemGuid(), 'from_user_id' => $this->getFromUserId(),
'shared_key' => $this->getSharedKey(), 'shared_key' => $this->getSharedKey(),
'permissions' => $this->getPermissions(), 'permissions' => $this->getPermissions(),
'created' => $this->getCreated(), 'created' => $this->getCreated(),

View file

@ -36,7 +36,7 @@ class ShareService {
* @param $permissions integer Must be created with a bitmask from options on the ShareRequest class * @param $permissions integer Must be created with a bitmask from options on the ShareRequest class
* @return array Array of sharing requests * @return array Array of sharing requests
*/ */
public function createBulkRequests($target_item_id, $target_item_guid, $request_array, $permissions) { public function createBulkRequests($target_item_id, $target_item_guid, $request_array, $permissions, $credential_owner) {
$created = (new \DateTime())->getTimestamp(); $created = (new \DateTime())->getTimestamp();
$requests = array(); $requests = array();
foreach ($request_array as $req){ foreach ($request_array as $req){
@ -49,6 +49,7 @@ class ShareService {
$t->setSharedKey($req['key']); $t->setSharedKey($req['key']);
$t->setPermissions($permissions); $t->setPermissions($permissions);
$t->setCreated($created); $t->setCreated($created);
$t->setFromUserId($credential_owner);
array_push($requests, $this->shareRequest->createRequest($t)); array_push($requests, $this->shareRequest->createRequest($t));
} }
return $requests; return $requests;

View file

@ -81,17 +81,20 @@
</tr> </tr>
</table> </table>
<ul class="grid-view" ng-if="view_mode === 'grid'"> <ul class="grid-view" ng-if="view_mode === 'grid'">
<li class="credential" ng-repeat="credential in active_vault.credentials | credentialSearch:filterOptions | tagFilter:selectedtags | orderBy:'label'| as:this:'filtered_credentials'" <li class="credential"
ng-if="credential.hidden == 0 && showCredentialRow(credential)" ng-repeat="credential in active_vault.credentials | credentialSearch:filterOptions | tagFilter:selectedtags | orderBy:'label'| as:this:'filtered_credentials'"
ng-click="selectCredential(credential)" ng-if="credential.hidden == 0 && showCredentialRow(credential)"
use-theme type="'border-color'"> ng-click="selectCredential(credential)"
<div class="credential_content" > use-theme type="'border-color'">
<div class="label">{{ ::credential.label}}</div> <div class="credential_content">
<div class="tags"> <div class="label">{{ ::credential.label}}</div>
<div class="tag" ng-repeat="tag in credential.tags_raw">{{ ::tag.text}}</div> <div class="tags">
<div class="tag" ng-repeat="tag in credential.tags_raw">
{{ ::tag.text}}
</div> </div>
</div> </div>
</li> </div>
</li>
</ul> </ul>
</div> </div>
<div id="app-sidebar" class="detailsView scroll-container app_sidebar" <div id="app-sidebar" class="detailsView scroll-container app_sidebar"
@ -237,4 +240,38 @@
</button> </button>
</div> </div>
</div> </div>
</div>
<div class="share_popup" style="display: none">
You have incoming share requests.<br/>
If you want to the credential in a other vault,<br/> logout of this vault
and login to the vault you want the shared credential in.
{{active_vault.vault_id}}
<table class="table">
<thead>
<tr>
<td>Label</td>
<td>Permissions</td>
<td>Received from</td>
<td>Date</td>
</tr>
</thead>
<tr ng-repeat="share_request in incoming_share_requests" ng-if="share_request.target_vault_id == active_vault.vault_id">
<td>
{{share_request.credential_label}}
</td>
<td>
{{share_request.permissions}}
</td>
<td>
{{share_request.from_user_id}}
</td>
<td>
{{share_request.created * 1000 | date:'dd-MM-yyyy @
HH:mm:ss'}}
</td>
<td>
<span class="link">Accept</span> | <span class="link">Decline</span>
</td>
</tr>
</table>
</div> </div>