Skip to content

Commit

Permalink
Search system, sharing system, context menu added. All ideas implemen…
Browse files Browse the repository at this point in the history
…ted and project finished. Maybe bugfixes will come.
  • Loading branch information
dogukanoksuz committed Mar 7, 2021
1 parent f993ef3 commit be4e7f3
Show file tree
Hide file tree
Showing 34 changed files with 346 additions and 550 deletions.
2 changes: 1 addition & 1 deletion editor/dist/quill.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion editor/dist/quill.bundle.js.map

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions editor/quill.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ window.addEventListener('load', () => {
'data': $(".ql-editor").html()
},
success: function (data, status, xhr) {
//console.log('status: ' + status + ', data: ' + data);
console.log('status: ' + status + ', data: ' + data);
},
error: function (jqXhr, textStatus, errorMessage) {
clearInterval(saveLoop);
Expand All @@ -124,9 +124,7 @@ window.addEventListener('load', () => {
if (!checker) {
clearInterval(saveLoop)
saveLoop = setInterval(() => {
if (document.hasFocus()) {
save()
}
save()
}, 8000)
checker = true
}
Expand Down
9 changes: 9 additions & 0 deletions server/app/Http/Controllers/API/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,13 @@ public function save($documentId, Request $request)

return response()->json(['message' => 'Success', 'state' => 'ok']);
}

public function delete($documentId)
{
$document = Document::where('id', $documentId)->first();

$document->delete();

return response()->json(['message' => 'Success', 'state' => 'ok']);
}
}
27 changes: 1 addition & 26 deletions server/app/Http/Livewire/Breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,16 @@

namespace App\Http\Livewire;

use App\Models\Folder;
use Livewire\Component;

class Breadcrumb extends Component
{
public $documentId;
public $folderId;
public $elements;

public function findIterativeFolders()
public function mount($documentId)
{
$this->elements = [];
if ($this->folderId != null) {
$folder = Folder::find($this->folderId);
array_push($this->elements, $folder);

if (isset($folder->parent_folder_id))
{
while($folder->parent_folder_id != null)
{
$folder = Folder::find($folder->parent_folder_id);
array_unshift($this->elements, $folder);
}
}
}

return $this->elements;
}

public function mount($documentId, $folderId)
{
$this->findIterativeFolders();

$this->documentId = $documentId;
$this->folderId = $folderId;
}

public function render()
Expand Down
35 changes: 6 additions & 29 deletions server/app/Http/Livewire/Document/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

use Livewire\Component;
use App\Models\Document;
use App\Models\Folder;

class Create extends Component
{
public $isCreating = false;
public $name = "";
public $message = "";
public $emitTo;
public $folderId;

public function confirmCreating()
{
Expand All @@ -22,18 +20,10 @@ public function confirmCreating()
public function createNewDocument()
{
try {
if($this->folderId == null)
{
$document = Document::create([
'name' => $this->name,
]);
} else {
$document = Document::create([
'name' => $this->name,
'folder_id' => $this->folderId
]);
}

$document = Document::create([
'name' => $this->name,
]);

$document->user()->attach(auth()->user());
}
catch (\Throwable $e)
Expand All @@ -42,14 +32,7 @@ public function createNewDocument()
}
$this->emitTo($this->emitTo, 'flashMessage', $this->name . " isimli doküman başarıyla eklendi!");

if ($this->folderId == null)
{
$documents = Document::where('folder_id', null)->orderBy('updated_at', 'DESC')->get();
}
else
{
$documents = Folder::findOrFail($this->folderId)->document()->orderBy('updated_at', 'DESC')->get();
}
$documents = Document::orderBy('updated_at', 'DESC')->get();

$this->emitTo($this->emitTo, 'emptyDecrement');

Expand All @@ -58,19 +41,13 @@ public function createNewDocument()
$this->name = "";
}

public function mount($emitTo, $folderId)
public function mount($emitTo)
{
$this->folderId = $folderId;

$this->emitTo = $emitTo;

if(!$emitTo) {
$this->emitTo = 'dashboard';
}

if(!$folderId) {
$this->folderId = null;
}
}

public function render()
Expand Down
3 changes: 0 additions & 3 deletions server/app/Http/Livewire/Document/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
class Edit extends Component
{
public $document;
public $folderId;
public $joining_key;

public function mount($documentId)
{
$this->document = Document::findOrFail($documentId);

$this->folderId = $this->document->folder_id;

$to_be_hashed = env('SOCKET_SECRET') . "||" . $documentId . "||" . auth()->user()->id;
$this->joining_key = md5($to_be_hashed);
Expand Down
65 changes: 65 additions & 0 deletions server/app/Http/Livewire/Document/Share.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace App\Http\Livewire\Document;

use Livewire\Component;

class Share extends Component
{
public $document;
public $users;
public $email;
public $attachUser;
public $message;

protected $listeners = ['newUserAdded', 'flashMessage'];

public function newUserAdded()
{
$this->users = $this->document->user()->get();
}

public function share()
{
$attachUser = \App\Models\User::where('email', $this->email)->first();

if ($attachUser == null) {
$this->flashMessage("Bu kullanıcı sistemde bulunmadığından kendisini yetkilendiremezsiniz.");
return;
} else {
$this->flashMessage("Başarıyla paylaşım eklendi.");
}
$this->document->user()->attach($attachUser);
$this->newUserAdded();
}

public function deleteShare($uid)
{
$deletedUser = \App\Models\User::where('id', $uid)->first();
$this->document->user()->detach($deletedUser);
$this->flashMessage("Kullanıcı paylaşımı kaldırıldı.");
$this->newUserAdded();
}

public function redirectToDocument()
{
return redirect()->to(route('showDocument', $this->document->id));
}

public function flashMessage($message)
{
$this->message = $message;
}

public function mount()
{
$this->document = \App\Models\Document::where('id', request()->documentId)->first();
$this->users = $this->document->user()->get();
$this->message = "";
}

public function render()
{
return view('livewire.document.share');
}
}
9 changes: 6 additions & 3 deletions server/app/Http/Livewire/Document/Show.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,24 @@ class Show extends Component

protected $listeners = ['newDocumentCreated'];

public function newDocumentCreated($documents)
public function newDocumentCreated()
{
$this->documents = auth()->user()->document()
->orderBy('updated_at', 'DESC')
->where('folder_id', null)
->get();
}

public function share()
{

}

public function mount($documents)
{
if (!$documents)
{
$this->documents = auth()->user()->document()
->orderBy('updated_at', 'DESC')
->where('folder_id', null)
->get();
} else {
$this->documents = $documents;
Expand Down
74 changes: 0 additions & 74 deletions server/app/Http/Livewire/Folder/Create.php

This file was deleted.

55 changes: 0 additions & 55 deletions server/app/Http/Livewire/Folder/ListContents.php

This file was deleted.

Loading

0 comments on commit be4e7f3

Please sign in to comment.