Johannes Zellner 11 лет назад
Родитель
Сommit
3d80c86f3d
4 измененных файлов с 24 добавлено и 12 удалено
  1. 7 0
      public/index.css
  2. 13 6
      public/index.html
  3. 2 1
      public/index.js
  4. 2 5
      src/things.js

+ 7 - 0
public/index.css

@@ -28,3 +28,10 @@
     width: 100%;
     width: 100%;
     overflow-x: auto;
     overflow-x: auto;
 }
 }
+
+.settings-action {
+    display: inline-block;
+    position: absolute;
+    top: 20px;
+    right: 20px;
+}

+ 13 - 6
public/index.html

@@ -1,7 +1,7 @@
-<html ng-app="app">
+<html ng-app="app" ng-controller="MainController">
 <head>
 <head>
 
 
-<title> Holy Guacamoly </title>
+<title>{{settings.title}}</title>
 
 
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
 
 
@@ -26,7 +26,7 @@
 
 
 </head>
 </head>
 
 
-<body ng-controller="MainController" ng-style="{'background-image':'url(' + settings.backgroundUrl + ')'}">
+<body ng-style="{'background-image':'url(' + settings.backgroundUrl + ')'}">
 
 
 <div class="modal fade" id="modalAdd">
 <div class="modal fade" id="modalAdd">
   <div class="modal-dialog">
   <div class="modal-dialog">
@@ -55,6 +55,12 @@
       </div>
       </div>
       <div class="modal-body">
       <div class="modal-body">
         <form class="form-horizontal">
         <form class="form-horizontal">
+          <div class="form-group">
+            <label for="inputTitle" class="col-sm-2 control-label">Title</label>
+            <div class="col-sm-10">
+              <input type="text" class="form-control" id="inputTitle" ng-model="settings.title" placeholder="Title">
+            </div>
+          </div>
           <div class="form-group">
           <div class="form-group">
             <label for="inputBackgroundImage" class="col-sm-2 control-label">Background</label>
             <label for="inputBackgroundImage" class="col-sm-2 control-label">Background</label>
             <div class="col-sm-10">
             <div class="col-sm-10">
@@ -71,14 +77,15 @@
   </div>
   </div>
 </div>
 </div>
 
 
+<div class="settings-action">
+  <button class="btn btn-default btn-fab" data-toggle="modal" data-target="#modalSettings"><i class="mdi mdi-dots-horizontal"></i></button>
+</div>
+
 <div class="container main">
 <div class="container main">
   <div class="row">
   <div class="row">
     <div class="col-md-2 col-md-offset-5">
     <div class="col-md-2 col-md-offset-5">
         <button class="btn btn-raised btn-block btn-success" data-toggle="modal" data-target="#modalAdd">Add</button>
         <button class="btn btn-raised btn-block btn-success" data-toggle="modal" data-target="#modalAdd">Add</button>
     </div>
     </div>
-    <div class="col-md-1 col-md-offset-3">
-      <button class="btn btn-default btn-fab" data-toggle="modal" data-target="#modalSettings"><i class="mdi mdi-dots-horizontal"></i></button>
-    </div>
   </div>
   </div>
   <div class="row">
   <div class="row">
     <div class="col-md-6 col-md-offset-3">
     <div class="col-md-6 col-md-offset-3">

+ 2 - 1
public/index.js

@@ -12,7 +12,7 @@ app.config(['markedProvider', function (markedProvider) {
     markedProvider.setOptions({gfm: true});
     markedProvider.setOptions({gfm: true});
 }]);
 }]);
 
 
-app.controller('MainController', function ($scope, $http, $timeout) {
+app.controller('MainController', function ($scope, $http, $timeout, $document) {
 
 
     $scope.things = [];
     $scope.things = [];
     $scope.tags = [];
     $scope.tags = [];
@@ -23,6 +23,7 @@ app.controller('MainController', function ($scope, $http, $timeout) {
     };
     };
 
 
     $scope.settings = {
     $scope.settings = {
+        title: 'Holy Guacamoly',
         backgroundUrl: ''
         backgroundUrl: ''
     };
     };
 
 

+ 2 - 5
src/things.js

@@ -160,10 +160,7 @@ function getTags(req, res, next) {
 }
 }
 
 
 function settingsSave(req, res, next) {
 function settingsSave(req, res, next) {
-
-    console.log('settings', req.body)
-
-    g_settings.update({ type: 'frontend' }, { $set: req.body.settings }, { upsert:true }, function (error) {
+    g_settings.update({ type: 'frontend' }, { type: 'frontend', value: req.body.settings }, { upsert: true }, function (error) {
         if (error) return next(new HttpError(500, error));
         if (error) return next(new HttpError(500, error));
         next(new HttpSuccess(202, {}));
         next(new HttpSuccess(202, {}));
     });
     });
@@ -173,6 +170,6 @@ function settingsGet(req, res, next) {
     g_settings.find({ type: 'frontend' }).toArray(function (error, result) {
     g_settings.find({ type: 'frontend' }).toArray(function (error, result) {
         console.log(error, result);
         console.log(error, result);
         if (error) return next(new HttpError(500, error));
         if (error) return next(new HttpError(500, error));
-        next(new HttpSuccess(200, { settings: result[0] || {} }));
+        next(new HttpSuccess(200, { settings: result[0].value || {} }));
     });
     });
 }
 }