From dc470fd131fa4d9200c6e37c9d1158f0824de36c Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 21 Oct 2017 15:10:24 -0400 Subject: [PATCH 1/4] Finish keyInfo modal and API routes --- app/public/css/panel.css | 139 ++++++++++++++++++++++++++++---- app/public/panel/controllers/ApiCtrl.js | 25 ++++++ app/public/services/ApiSvc.js | 17 ++++ app/routes/keys.js | 6 ++ public/views/panel/api.html | 65 ++++++++++----- 5 files changed, 217 insertions(+), 35 deletions(-) diff --git a/app/public/css/panel.css b/app/public/css/panel.css index 7930aab..0010830 100644 --- a/app/public/css/panel.css +++ b/app/public/css/panel.css @@ -200,35 +200,140 @@ body { user-select: none; } -.modal { +.key-name { + color: #2a9fd6; + font-family: 'Roboto Mono', monospace; +} + +pre { + overflow: auto; + line-height: 1.7em; + font-family: 'Roboto Mono', monospace; + border: 1px solid #666; + border-radius: 4px; display: block; + padding: 10px; + font-size: 14px; + margin: 10px 0; + background: #222; + color: #2a9fd6; +} + +.modal, +.modal-box { + z-index: 900; +} + +.modal-sandbox { position: fixed; - z-index: 1; - left: 0; - top: 0; width: 100%; height: 100%; + top: 0; + left: 0; + background: transparent; +} + +.modal { + display: none; + position: fixed; + width: 100%; + height: 100%; + left: 0; + top: 0; + background: rgb(0,0,0); + background: rgba(0,0,0,.8); overflow: auto; - background-color: rgba(0, 0, 0, 0.4); +} + +.modal-box { + position: relative; + width: 80%; + max-width: 700px; + margin: 100px auto; + animation-name: modalbox; + animation-duration: .3s; + animation-timing-function: ease; } .modal-header { - margin: 15% auto; - padding: 20px; - border: 1px solid #888; - width: 80%; + border: 2px solid #2a9fd6; + border-radius: 8px 8px 0 0; + display: flex; + flex-direction: row; + justify-content: space-between; + padding: 20px 40px; + background: #000; + color: #ffffff; } .modal-body { - margin: auto; - padding: 20px; - border: 1px solid #888; - width: 80%; + border: 2px solid #2a9fd6; + border-top: none; + background: #000; + padding: 30px; } .modal-footer { - margin: auto; + display: flex; + justify-content: flex-end; + border: 2px solid #2a9fd6; + border-radius: 0 0 8px 8px; + border-top: none; + background: #000; padding: 20px; - border: 1px solid #888; - width: 80%; -} \ No newline at end of file +} + +.close-modal { + text-align: right; + font-size: 24px; + cursor: pointer; +} + +@keyframes modalbox { + 0% { + top: -250px; + opacity: 0; + } + 100% { + top: 0; + opacity: 1; + } +} + +button { + margin-left: 20px; + color: #d3d3d3; + background: #000; + border: 2px solid #2a9fd6; + border-radius: 5px; + padding: 10px; + cursor: pointer; + transition: background-color 0.25s; +} + +button:hover { + color: #fff; + background-color: #2a9fd6; + text-decoration: none; + outline: none; +} + +::-moz-focus-inner { + outline: none; +} + +.btn-del { + text-transform: uppercase; + border: 2px solid #ff6666; + color: #ccc; +} + +.btn-del:hover { + background-color: #ff6666; +} + +em { + text-transform: uppercase; + font-weight: bold; +} + diff --git a/app/public/panel/controllers/ApiCtrl.js b/app/public/panel/controllers/ApiCtrl.js index 45fc2da..b05a108 100644 --- a/app/public/panel/controllers/ApiCtrl.js +++ b/app/public/panel/controllers/ApiCtrl.js @@ -7,4 +7,29 @@ angular.module('ApiCtrl', ['ApiSvc', 'AuthSvc']).controller('ApiController', ['$ }); console.log($scope.keys); }; + + $scope.hideNewKey = function() { + $scope.nModalShow = false; + }; + $scope.showNewKey = function() { + $scope.nModalShow = true; + }; + + $scope.hideKeyInfo = function() { + $scope.kModalShow = false; + }; + $scope.showKeyInfo = function(key) { + $scope.kModalShow = true; + $scope.currKey = key; + }; + + $scope.deleteKey = function(key) { + ApiService.deleteKey(key, function() { + var index = $scope.keys.indexOf(key); + console.log('removing index' + index); + $scope.keys.splice(index, 1); + $scope.hideKeyInfo(); + $scope.currKey = {}; + }); + }; }]); \ No newline at end of file diff --git a/app/public/services/ApiSvc.js b/app/public/services/ApiSvc.js index 4135a26..a844621 100644 --- a/app/public/services/ApiSvc.js +++ b/app/public/services/ApiSvc.js @@ -19,4 +19,21 @@ angular.module('ApiSvc', []).service('ApiService', ['$http', '$window', function cb(res.data); }); }; + + this.deleteKey = function(key, cb) { + $http({ + method: 'POST', + url: '/api/keys/delete', + headers: {'Content-Type': 'application/x-www-form-urlencoded'}, + transformRequest: function(obj) { + var str = []; + for (var p in obj) + str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); + return str.join("&"); + }, + data: {key: key.key} + }).then(function(res) { + cb(res.data); + }); + } }]); diff --git a/app/routes/keys.js b/app/routes/keys.js index 36e868e..dbecf23 100644 --- a/app/routes/keys.js +++ b/app/routes/keys.js @@ -64,4 +64,10 @@ router.get('/get', function (req, res, next) { }) }); +router.post('/delete', function(req, res, next) { + console.log('Tried to delete ' + req.body.key); + res.status(200).json({'message': 'Successfully deleted.'}); + //Key.deleteOne({key: req.body.key}) +}); + module.exports = router; diff --git a/public/views/panel/api.html b/public/views/panel/api.html index b2591e3..ab4a42e 100644 --- a/public/views/panel/api.html +++ b/public/views/panel/api.html @@ -1,30 +1,59 @@ -
+
-
+
{{key.identifier}}
-
+
Create
-