From 8ba647a000a77d78d6715e577707ecc57ee77b4e Mon Sep 17 00:00:00 2001 From: brantje Date: Mon, 3 Oct 2016 11:42:19 +0200 Subject: [PATCH] Pimp my public share page --- Gruntfile.js | 7 + css/public-page.css | 64 ++++++ css/public-page.css.map | 7 + js/app/app_public.js | 14 ++ js/app/controllers/edit_credential.js | 2 +- .../controllers/public_shared_credential.js | 89 ++++++++ js/app/services/shareservice.js | 10 + templates/public_share.php | 193 +++++++++++++++++- 8 files changed, 384 insertions(+), 2 deletions(-) create mode 100644 css/public-page.css create mode 100644 css/public-page.css.map create mode 100644 js/app/app_public.js create mode 100644 js/app/controllers/public_shared_credential.js diff --git a/Gruntfile.js b/Gruntfile.js index cd58cf62..639b9fdd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -42,6 +42,13 @@ module.exports = function (grunt) { src: ["**/bookmarklet.scss"], dest: "css", ext: ".css" + }, + { + expand: true, + cwd: "sass", + src: ["**/public-page.scss"], + dest: "css", + ext: ".css" } ] } diff --git a/css/public-page.css b/css/public-page.css new file mode 100644 index 00000000..a40be5f9 --- /dev/null +++ b/css/public-page.css @@ -0,0 +1,64 @@ +header { + display: none; } + +#content-wrapper { + padding-top: 0; } + +.credential_container { + margin-top: 20px; + margin-bottom: 20px; + padding: 20px; + background: #f8f8f8; + border: 1px solid #c9c9c9; + -webkit-border-radius: 5px; + border-radius: 5px; + background-clip: padding-box; + /* stops bg color from leaking outside the border: */ } + .credential_container .text { + text-align: center; } + .credential_container h2 { + font-weight: bold; } + .credential_container button, .credential_container .text { + margin: 0 auto; + display: block; } + .credential_container button i, .credential_container .text i { + margin-right: 5px; } + +.credential_field { + overflow: hidden; } + .credential_field .cell, .credential_field .value { + float: left; } + .credential_field .tools { + margin-left: 10px; + overflow: hidden; + float: left; } + .credential_field .tools .cell { + cursor: pointer; + margin-right: 4px; } + +table { + white-space: normal; } + table td:first-child { + min-width: 110px; } + table td { + padding-bottom: 1em; } + +.tags .tag { + background-color: rgba(240, 240, 240, 0.9); + padding: 4px; + font-size: 12px; + margin-right: 3px; + -webkit-border-radius: 5px; + border-radius: 5px; + background-clip: padding-box; + /* stops bg color from leaking outside the border: */ } +.tags .tag:last-child { + margin-right: 8px; } + +.footer { + font-size: 10px; + position: relative; + bottom: -20px; + text-align: center; } + +/*# sourceMappingURL=public-page.css.map */ diff --git a/css/public-page.css.map b/css/public-page.css.map new file mode 100644 index 00000000..88a663f6 --- /dev/null +++ b/css/public-page.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAEA,MAAO;EACL,OAAO,EAAE,IAAI;;AAGf,gBAAiB;EACf,WAAW,EAAE,CAAC;;AAGhB,qBAAqB;EACnB,UAAU,EAAE,IAAI;EAChB,aAAa,EAAE,IAAI;EACnB,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,OAAO;EACnB,MAAM,EAAE,iBAAiB;ECJzB,qBAAqB,EDKE,GAAG;ECJ1B,aAAa,EDIU,GAAG;ECH1B,eAAe,EAAE,WAAW;EAAG,qDAAqD;EDIpF,2BAAK;IACJ,UAAU,EAAE,MAAM;EAEnB,wBAAE;IACA,WAAW,EAAE,IAAI;EAEnB,yDAAa;IACX,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,KAAK;IACd,6DAAC;MACC,YAAY,EAAE,GAAG;;AAKvB,iBAAkB;EAChB,QAAQ,EAAE,MAAM;EAChB,iDAAc;IACZ,KAAK,EAAE,IAAI;EAEb,wBAAO;IACL,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,IAAI;IACX,8BAAM;MACJ,MAAM,EAAE,OAAO;MACf,YAAY,EAAE,GAAG;;AAIvB,KAAK;EACF,WAAW,EAAE,MAAM;EAClB,oBAAc;IACZ,SAAS,EAAE,KAAK;EAElB,QAAE;IACA,cAAc,EAAE,GAAG;;AAKvB,UAAK;EACH,gBAAgB,EAAE,wBAAuB;EACzC,OAAO,EAAE,GAAG;EACZ,SAAS,EAAE,IAAI;EACf,YAAY,EAAE,GAAG;ECnDnB,qBAAqB,EDoDI,GAAG;ECnD5B,aAAa,EDmDY,GAAG;EClD5B,eAAe,EAAE,WAAW;EAAG,qDAAqD;ADoDpF,qBAAgB;EACd,YAAY,EAAE,GAAG;;AAGrB,OAAO;EACL,SAAS,EAAE,IAAI;EACf,QAAQ,EAAE,QAAQ;EAClB,MAAM,EAAE,KAAK;EACb,UAAU,EAAE,MAAM", +"sources": ["../sass/public-page.scss","../sass/mixins.scss"], +"names": [], +"file": "public-page.css" +} diff --git a/js/app/app_public.js b/js/app/app_public.js new file mode 100644 index 00000000..a56dc867 --- /dev/null +++ b/js/app/app_public.js @@ -0,0 +1,14 @@ +'use strict'; +angular + .module('passmanApp', [ + 'ngAnimate', + 'ngCookies', + 'ngResource', + 'ngRoute', + 'ngSanitize', + 'ngTouch', + 'ngclipboard', + + ]).config(['$httpProvider', function ($httpProvider) { + $httpProvider.defaults.headers.common.requesttoken = oc_requesttoken; +}]); diff --git a/js/app/controllers/edit_credential.js b/js/app/controllers/edit_credential.js index d6b409ff..8be47c12 100644 --- a/js/app/controllers/edit_credential.js +++ b/js/app/controllers/edit_credential.js @@ -214,7 +214,7 @@ angular.module('passmanApp') $scope.saveCredential = function () { //@TODO validation //@TODO When credential is expired and has renew interval set, calc new expire time. - + console.log(JSON.stringify($scope.storedCredential)); delete $scope.storedCredential.password_repeat; if (!$scope.storedCredential.credential_id) { $scope.storedCredential.vault_id = $scope.active_vault.vault_id; diff --git a/js/app/controllers/public_shared_credential.js b/js/app/controllers/public_shared_credential.js new file mode 100644 index 00000000..0bc411d8 --- /dev/null +++ b/js/app/controllers/public_shared_credential.js @@ -0,0 +1,89 @@ +/** + * @ngdoc function + * @name passmanApp.controller:MainCtrl + * @description + * # MainCtrl + * Controller of the passmanApp + */ +angular.module('passmanApp') + .controller('PublicSharedCredential', ['$scope', 'ShareService', function ($scope, ShareService) { + $scope.test = 'hello world'; + + $scope.loading = false; + + + var example_shared_credential = { + "credential_id": 292, + "guid": "3D18EAD3-CF40-4B2B-B568-82CD7CB3D47F", + "user_id": "sander", + "vault_id": 2, + "label": "donnelly.com", + "description": null, + "created": 1475479693, + "changed": 1475479693, + "tags": [{"text": "Games"}], + "email": null, + "username": "ebrekke", + "password": "hd%/U_%vzvh%", + "url": "http://api.namefake.com/english-united-states/male/2854dda4938c9c5f60a288fa6fbe5095", + "favicon": null, + "renew_interval": null, + "expire_time": 0, + "delete_time": 0, + "files": [{ + "file_id": 1, + "filename": "20160925-Clipperz_Export.html", + "guid": "6DA2CE41-A26B-4F97-A334-2CC74F7E9890", + "size": 13863, + "created": 1475485368, + "mimetype": "text/html", + "$$hashKey": "object:1261" + }, { + "file_id": 2, + "filename": "20160925_Clipperz_Offline.html", + "guid": "9337D189-B79E-4750-BEF9-3C912A9EA59D", + "size": 3088428, + "created": 1475485376, + "mimetype": "text/html", + "$$hashKey": "object:1268" + }], + "custom_fields": [{ + "label": "Test field", + "value": "blah blah", + "secret": false, + "$$hashKey": "object:1205" + }, { + "label": "another field =)", + "value": "vlaue", + "secret": true, + "$$hashKey": "object:1220" + }], + "otp": { + "type": "totp", + "label": "Google:fake@gmail.com", + "qr_uri": { + "qrData": "otpauth://totp/Google%3Afake%40gmail.com?secret=oyonyttithtryvpnqqrxluytgwon2mhw&issuer=Google", + "image": "" + }, + "secret": "oyonyttithtryvpnqqrxluytgwon2mhw", + "issuer": "Google" + }, + "hidden": 0, + "shared_key": null, + "tags_raw": [{"text": "Games"}] + }; + + $scope.loadSharedCredential = function () { + $scope.loading = true; + ShareService.getPublicSharedCredential().then(function (sharedCredential) { + //Decrypt stuff here + + //And then set it + $scope.loading = false; + $scope.shared_credential = example_shared_credential; + }) + + } + }]) +; + diff --git a/js/app/services/shareservice.js b/js/app/services/shareservice.js index b1c184c2..2cef04f8 100644 --- a/js/app/services/shareservice.js +++ b/js/app/services/shareservice.js @@ -67,6 +67,16 @@ angular.module('passmanApp') return response.data; }) }, + getPublicSharedCredential: function (request, crypted_shared_key) { + var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/public/view'); + return $http.get(queryUrl).then(function (response) { + if (response.data) { + return response.data; + } else { + return response; + } + }); + }, getCredendialsSharedWithUs: function (vault_guid) { var queryUrl = OC.generateUrl('apps/passman/api/v2/sharing/vault/'+ vault_guid +'/get'); return $http.get(queryUrl).then(function (response) { diff --git a/templates/public_share.php b/templates/public_share.php index 95c0c0e2..43e9438f 100644 --- a/templates/public_share.php +++ b/templates/public_share.php @@ -1 +1,192 @@ -Public shared credential \ No newline at end of file + +
+
+
+

Passman

+
+ {name} has shared a credential with you. + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Label + + {{shared_credential.label}} +
+ Account + + +
+ Password + + +
+ OTP + + +
+ E-mail + + +
+ URL + + +
+ Files + + +
+ {{field.label}} + + +
+ Expire time + + {{shared_credential.expire_time * 1000 | + date:'dd-MM-yyyy @ HH:mm:ss'}} +
+ Changed + + {{shared_credential.changed * 1000 | + date:'dd-MM-yyyy @ HH:mm:ss'}} +
+ Created + + {{shared_credential.created * 1000 | + date:'dd-MM-yyyy @ HH:mm:ss'}} +
+ +
+ {{tag.text}} + +
+
+ +
+
+
\ No newline at end of file