diff --git a/core/core.go b/core/core.go index 596cbb2..3e9b7a6 100644 --- a/core/core.go +++ b/core/core.go @@ -156,6 +156,7 @@ type ResponseData struct { type SummaryData struct { Status string + State string Live map[string]keycache.ActiveUser All map[string]passvault.Summary } @@ -185,7 +186,8 @@ func jsonStatusError(err error) ([]byte, error) { return json.Marshal(ResponseData{Status: err.Error()}) } func jsonSummary() ([]byte, error) { - return json.Marshal(SummaryData{Status: "ok", Live: crypt.LiveSummary(), All: records.GetSummary()}) + state := crypt.Status() + return json.Marshal(SummaryData{Status: "ok", State: state.State, Live: crypt.LiveSummary(), All: records.GetSummary()}) } func jsonResponse(resp []byte) ([]byte, error) { return json.Marshal(ResponseData{Status: "ok", Response: resp}) @@ -300,6 +302,7 @@ func Create(jsonIn []byte) ([]byte, error) { // Summary processes a summary request. func Summary(jsonIn []byte) ([]byte, error) { + log.Println(string(jsonIn)) var s SummaryRequest var err error diff --git a/static.go b/static.go index ba01954..1f13063 100644 --- a/static.go +++ b/static.go @@ -29,6 +29,7 @@ const (
Persistence is '+data.State+'.' + ); $('.summary-results').removeClass('hide'); } }) @@ -666,6 +702,31 @@ const ( }); }); + // Restore + $('body').on('submit', '#user-restore', function(evt){ + evt.preventDefault(); + var $form = $(evt.currentTarget), + data = serialize($form); + + // Force 'uses' to an integer. + data.Uses = parseInt(data.Uses, 10); + + submit( $form, { + data : data, + success : function(d){ + console.log(d.Response); + response = JSON.parse(window.atob(d.Response)); + console.log(response); + $form.find('.feedback') + .append(makeAlert({ + type: 'success', + message: 'Delegating '+htmlspecialchars(data.Name)+ + '; persistence is currently '+response.Status + })); + } + }); + }); + // Encrypt data $('body').on('submit', '#encrypt', function(evt){ evt.preventDefault(); @@ -855,6 +916,9 @@ const ( case "ordernum": setValue = $("#delegate-slot"); break; + case "slot": + setValue = $("#delegate-slot"); + break; default: break; } @@ -870,7 +934,7 @@ const ( var labels = decodeURIComponent(document.getElementById("orderlink-labels").value); var uses = decodeURIComponent(document.getElementById("orderlink-uses").value); - var link = "https://" + document.location.host + "?delegator="+ delegator + "&delegatee="+ delegatee + "&label=" + labels + "&ordernum=" + orderNum + "&uses=" + uses + "&duration="+ duration; + var link = "https://" + document.location.host + "?delegator="+ delegator + "&delegatee="+ delegatee + "&label=" + labels + "&slot=" + orderNum + "&uses=" + uses + "&duration="+ duration; $('.orderlink-feedback').empty().append(makeAlert({ type: 'success', message: '
'+htmlspecialchars(link)+'
' }) ); } function htmlspecialchars(s) { diff --git a/static/index.html b/static/index.html index 76a2575..d1773e3 100644 --- a/static/index.html +++ b/static/index.html @@ -24,6 +24,7 @@Persistence is '+data.State+'.' + ); $('.summary-results').removeClass('hide'); } }) @@ -661,6 +697,31 @@ }); }); + // Restore + $('body').on('submit', '#user-restore', function(evt){ + evt.preventDefault(); + var $form = $(evt.currentTarget), + data = serialize($form); + + // Force 'uses' to an integer. + data.Uses = parseInt(data.Uses, 10); + + submit( $form, { + data : data, + success : function(d){ + console.log(d.Response); + response = JSON.parse(window.atob(d.Response)); + console.log(response); + $form.find('.feedback') + .append(makeAlert({ + type: 'success', + message: 'Delegating '+htmlspecialchars(data.Name)+ + '; persistence is currently '+response.Status + })); + } + }); + }); + // Encrypt data $('body').on('submit', '#encrypt', function(evt){ evt.preventDefault(); @@ -850,6 +911,9 @@ case "ordernum": setValue = $("#delegate-slot"); break; + case "slot": + setValue = $("#delegate-slot"); + break; default: break; } @@ -865,7 +929,7 @@ var labels = decodeURIComponent(document.getElementById("orderlink-labels").value); var uses = decodeURIComponent(document.getElementById("orderlink-uses").value); - var link = "https://" + document.location.host + "?delegator="+ delegator + "&delegatee="+ delegatee + "&label=" + labels + "&ordernum=" + orderNum + "&uses=" + uses + "&duration="+ duration; + var link = "https://" + document.location.host + "?delegator="+ delegator + "&delegatee="+ delegatee + "&label=" + labels + "&slot=" + orderNum + "&uses=" + uses + "&duration="+ duration; $('.orderlink-feedback').empty().append(makeAlert({ type: 'success', message: '
'+htmlspecialchars(link)+'
' }) ); } function htmlspecialchars(s) {