From e85876e273dbc91963e9b177cf5ea2318b0b8a49 Mon Sep 17 00:00:00 2001 From: Scott Date: Mon, 8 Aug 2016 14:52:25 +1000 Subject: [PATCH] Enhances configuration page Adds Notification angular module Adds Requestify for ExpressJS to make posting ezpz Now can post data to gocryptoCore GoCrypto can now receive data on settings save --- configRoutes.go | 16 ++++++ web/app/app.js | 13 ++++- web/app/index.html | 7 ++- web/app/views/home/home.js | 3 +- web/app/views/settings/settings.html | 83 +++++++++++++++------------- web/app/views/settings/settings.js | 46 ++++++++++++++- web/bower.json | 3 +- web/package.json | 4 +- web/server.js | 23 +++++++- 9 files changed, 152 insertions(+), 46 deletions(-) diff --git a/configRoutes.go b/configRoutes.go index 604c7f79..c34056b1 100644 --- a/configRoutes.go +++ b/configRoutes.go @@ -14,6 +14,15 @@ func getAllSettings(w http.ResponseWriter, r *http.Request) { } } +func saveAllSettings(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json; charset=UTF-8") + w.WriteHeader(http.StatusOK) + + if err := json.NewEncoder(w).Encode(true); err != nil { + panic(err) + } +} + var configRoutes = Routes{ Route{ "GetAllSettings", @@ -21,4 +30,11 @@ var configRoutes = Routes{ "/config/all", getAllSettings, }, + + Route{ + "SaveAllSettings", + "POST", + "/config/all/save", + saveAllSettings, + }, } diff --git a/web/app/app.js b/web/app/app.js index bb0aef2a..c3760c57 100644 --- a/web/app/app.js +++ b/web/app/app.js @@ -3,12 +3,23 @@ // Declare app level module which depends on views, and components angular.module('myApp', [ 'ngRoute', + 'ui-notification', 'myApp.home', 'myApp.about', 'myApp.settings', 'myApp.version' ]). -config(['$locationProvider', '$routeProvider', function($locationProvider, $routeProvider) { +config(['$locationProvider', '$routeProvider' ,'NotificationProvider', function($locationProvider, $routeProvider, NotificationProvider) { + NotificationProvider.setOptions({ + delay: 10000, + startTop: 60, + startRight: 10, + verticalSpacing: 10, + horizontalSpacing: 20, + positionX: 'right', + positionY: 'top' + }); + $locationProvider.hashPrefix('!'); $routeProvider.otherwise({redirectTo: '/'}); diff --git a/web/app/index.html b/web/app/index.html index b6ff3be1..f5f1b470 100644 --- a/web/app/index.html +++ b/web/app/index.html @@ -11,12 +11,14 @@ + - + + - +