mirror of
https://github.com/nextcloud/passman.git
synced 2025-09-14 00:44:52 +08:00
Show dialog with incoming share requests
This commit is contained in:
parent
200a18a0e8
commit
ca408ef0a3
9 changed files with 75 additions and 16 deletions
|
@ -496,6 +496,12 @@
|
|||
<notnull>false</notnull>
|
||||
<length>64</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>from_user_id</name>
|
||||
<type>text</type>
|
||||
<notnull>false</notnull>
|
||||
<length>64</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>target_vault_id</name>
|
||||
<type>integer</type>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<description>A password manager for Nextcloud</description>
|
||||
<licence>AGPL</licence>
|
||||
<author>Sander Brand</author>
|
||||
<version>1.0.2.17</version>
|
||||
<version>1.0.2.18</version>
|
||||
<namespace>Passman</namespace>
|
||||
<category>other</category>
|
||||
<website>https://github.com/nextcloud/passman/</website>
|
||||
|
|
|
@ -74,7 +74,8 @@ class ShareController extends ApiController {
|
|||
* Assemble notification
|
||||
*/
|
||||
$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) {
|
||||
$processed_users = array();
|
||||
|
||||
|
|
|
@ -63,6 +63,13 @@ angular.module('passmanApp')
|
|||
|
||||
ShareService.getPendingRequests().then(function (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 () {
|
||||
|
|
|
@ -51,7 +51,11 @@ angular.module('passmanApp')
|
|||
},
|
||||
getPendingRequests: function () {
|
||||
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) {
|
||||
var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/save');
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -31,6 +31,8 @@ use OCP\AppFramework\Db\Entity;
|
|||
* @method integer getPermissions()
|
||||
* @method void setCreated(integer $value)
|
||||
* @method integer getCreated()
|
||||
* @method void setFromUserId(integer $value)
|
||||
* @method integer getFromUserId()
|
||||
*/
|
||||
|
||||
class ShareRequest extends PermissionEntity implements \JsonSerializable {
|
||||
|
@ -43,7 +45,8 @@ class ShareRequest extends PermissionEntity implements \JsonSerializable {
|
|||
$targetVaultGuid,
|
||||
$sharedKey,
|
||||
$permissions,
|
||||
$created;
|
||||
$created,
|
||||
$fromUserId;
|
||||
|
||||
public function __construct() {
|
||||
// add types in constructor
|
||||
|
@ -68,7 +71,7 @@ class ShareRequest extends PermissionEntity implements \JsonSerializable {
|
|||
'target_user_id' => $this->getTargetUserId(),
|
||||
'target_vault_id' => $this->getTargetVaultId(),
|
||||
'target_vault_guid' => $this->getTargetVaultGuid(),
|
||||
'item_guid' => $this->getItemGuid(),
|
||||
'from_user_id' => $this->getFromUserId(),
|
||||
'shared_key' => $this->getSharedKey(),
|
||||
'permissions' => $this->getPermissions(),
|
||||
'created' => $this->getCreated(),
|
||||
|
|
|
@ -36,7 +36,7 @@ class ShareService {
|
|||
* @param $permissions integer Must be created with a bitmask from options on the ShareRequest class
|
||||
* @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();
|
||||
$requests = array();
|
||||
foreach ($request_array as $req){
|
||||
|
@ -49,6 +49,7 @@ class ShareService {
|
|||
$t->setSharedKey($req['key']);
|
||||
$t->setPermissions($permissions);
|
||||
$t->setCreated($created);
|
||||
$t->setFromUserId($credential_owner);
|
||||
array_push($requests, $this->shareRequest->createRequest($t));
|
||||
}
|
||||
return $requests;
|
||||
|
|
|
@ -81,17 +81,20 @@
|
|||
</tr>
|
||||
</table>
|
||||
<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'"
|
||||
ng-if="credential.hidden == 0 && showCredentialRow(credential)"
|
||||
ng-click="selectCredential(credential)"
|
||||
use-theme type="'border-color'">
|
||||
<div class="credential_content" >
|
||||
<div class="label">{{ ::credential.label}}</div>
|
||||
<div class="tags">
|
||||
<div class="tag" ng-repeat="tag in credential.tags_raw">{{ ::tag.text}}</div>
|
||||
<li class="credential"
|
||||
ng-repeat="credential in active_vault.credentials | credentialSearch:filterOptions | tagFilter:selectedtags | orderBy:'label'| as:this:'filtered_credentials'"
|
||||
ng-if="credential.hidden == 0 && showCredentialRow(credential)"
|
||||
ng-click="selectCredential(credential)"
|
||||
use-theme type="'border-color'">
|
||||
<div class="credential_content">
|
||||
<div class="label">{{ ::credential.label}}</div>
|
||||
<div class="tags">
|
||||
<div class="tag" ng-repeat="tag in credential.tags_raw">
|
||||
{{ ::tag.text}}
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="app-sidebar" class="detailsView scroll-container app_sidebar"
|
||||
|
@ -237,4 +240,38 @@
|
|||
</button>
|
||||
</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>
|
Loading…
Add table
Reference in a new issue