Add checkbox to set note as private. When note is private then no one can see them from non local network.

This commit is contained in:
kplaczek
2018-09-19 20:04:35 +02:00
parent 31e65c4730
commit fcfc0bd58a
4 changed files with 31 additions and 19 deletions

View File

@@ -9,11 +9,8 @@
namespace App\Http\Controllers;
set_time_limit(-1);
use App\Paper\Airly;
use App\Paper\Paper;
use Illuminate\Support\Facades\DB;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
use Intervention\Image\ImageManagerStatic as Image;
use Mike42\Escpos\EscposImage;
use Illuminate\Http\Request;
@@ -219,11 +216,13 @@ class Main extends Controller
'text' => $this->templateReplace($request->input('text')),
'icon' => $request->input('icon'),
'type' => self::NOTE,
'private' => $request->input('private', 0),
'created_at' => time(),
'updated_at' => time()
]);
$note = DB::table('note')->where('id', $id)->first();
} else {
DB::table('note')
->where('id', $note->id)
->update([
@@ -231,6 +230,7 @@ class Main extends Controller
'topic_slug' => str_slug($request->input('title'), '_'),
'text' => $request->input('text'),
'icon' => $request->input('icon'),
'private' => $request->input('private',0),
'updated_at' => time(),
]);
}
@@ -250,6 +250,7 @@ class Main extends Controller
'text' => $note->text,
'icon_selected' => $note->icon,
'type' => $note->type,
'private' => $note->private,
'id' => $note->id,
'icons' => $this->paper->getIcons(),
'topic_slug' => $note->topic_slug,
@@ -273,6 +274,7 @@ class Main extends Controller
'text' => $request->input('text'),
'icon' => $request->input('icon'),
'type' => self::NOTE,
'private' => $request->input('private',0),
'created_at' => time(),
'updated_at' => time()
]);
@@ -286,6 +288,7 @@ class Main extends Controller
'text' => $request->input('text'),
'icon' => $request->input('icon'),
'type' => self::TEMPLATE,
'private' => $request->input('private',0),
'created_at' => time(),
'updated_at' => time()
]);

View File

@@ -12,7 +12,7 @@ return [
| any other location as required by the application or its packages.
*/
'name' => 'Laravel',
'name' => 'Paper.Pi',
/*
|--------------------------------------------------------------------------
@@ -64,7 +64,7 @@ return [
|
*/
'timezone' => 'UTC',
'timezone' => 'Europe/Warsaw',
/*
|--------------------------------------------------------------------------

View File

@@ -33,6 +33,11 @@
@if(isset($id))
<button class="ui delete button js-delete red" type="submit" name="delete">Usuń</button>
@endif
<div class="ui @if(isset($private) && $private == 1) checked @endif checkbox">
<input name="private" id="private" @if(isset($private) && $private == 1) checked="checked" @endif value="1" type="checkbox">
<label for="private">Prywatna notatka</label>
</div>
</form>

View File

@@ -50,7 +50,10 @@
<h1 class="ui header"> @if(isset($filter)) <a href="/">Lista notatek</a> z ikonką <span
class="icon {{ $filter }} display-inline-block"></span>@else Lista notatek @endif</h1>
<div class="ui middle aligned divided list">
@foreach($notes as $note)
@if($note->private != 1 || $_SERVER['REMOTE_ADDR'] == '192.168.0.1')
<div class="item">
<div class="left floated content">
<a href="/filter/{{ $note->icon }}" class="left floated"><span
@@ -66,6 +69,7 @@
</form>
</div>
</div>
@endif
@endforeach
</div>
<h1 class="ui header">Szablony notatek</h1>