From 5eea45655b0f697e99fb559554412d6584bd6774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Micha=C5=82ek?= Date: Tue, 14 Apr 2020 13:19:12 +0200 Subject: [PATCH] feat: add push notifications --- .../Controllers/NotificationController.php | 213 +++++++++ app/Models/Gmc.php | 12 + app/Models/Notification.php | 11 + .../2020_03_12_111401_create_gmc_table.php | 32 ++ ...03_12_111402_create_notification_table.php | 36 ++ package-lock.json | 450 +++++++++++++++++- package.json | 6 +- public/mix-manifest.json | 2 + public/service-worker.js | 29 ++ resources/js/coreui/notifications.js | 264 ++++++++++ resources/js/coreui/service-worker.js | 29 ++ .../dashboard/notification/create.blade.php | 60 +++ .../dashboard/notification/edit.blade.php | 74 +++ .../dashboard/notification/index.blade.php | 82 ++++ .../dashboard/notification/public.blade.php | 47 ++ .../dashboard/notification/show.blade.php | 38 ++ routes/web.php | 12 + webpack.mix.js | 3 + 18 files changed, 1395 insertions(+), 5 deletions(-) create mode 100644 app/Http/Controllers/NotificationController.php create mode 100644 app/Models/Gmc.php create mode 100644 app/Models/Notification.php create mode 100644 database/migrations/2020_03_12_111401_create_gmc_table.php create mode 100644 database/migrations/2020_03_12_111402_create_notification_table.php create mode 100644 public/service-worker.js create mode 100644 resources/js/coreui/notifications.js create mode 100644 resources/js/coreui/service-worker.js create mode 100644 resources/views/dashboard/notification/create.blade.php create mode 100644 resources/views/dashboard/notification/edit.blade.php create mode 100644 resources/views/dashboard/notification/index.blade.php create mode 100644 resources/views/dashboard/notification/public.blade.php create mode 100644 resources/views/dashboard/notification/show.blade.php diff --git a/app/Http/Controllers/NotificationController.php b/app/Http/Controllers/NotificationController.php new file mode 100644 index 0000000..2025326 --- /dev/null +++ b/app/Http/Controllers/NotificationController.php @@ -0,0 +1,213 @@ + $notifications]); + } + + /** + * Show the form for creating a new resource. + * + * @return \Illuminate\Http\Response + */ + public function create() + { + return view('dashboard.notification.create'); + } + + /** + * Store a newly created resource in storage. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Http\Response + */ + public function store(Request $request) + { + $validatedData = $request->validate([ + 'title' => 'required', + 'message' => 'required', + 'logo' => 'required', + 'name' => 'required', + 'url' => 'required' + ]); + $notify = new Notification(); + $notify->title = $request->input('title'); + $notify->message = $request->input('message'); + $notify->logo = $request->input('logo'); + $notify->name = $request->input('name'); + $notify->url = $request->input('url'); + $notify->save(); + //send notification + $url = 'https://fcm.googleapis.com/fcm/send'; + $headers = array ( + 'Authorization: key=' . env('API_KEY_FIREBASE', ''), + 'Content-Type: application/json' + ); + /* + $rids = Gmc::all(); + $fields = array ( + 'registration_ids' => array (), + 'message_id' => 'm-' . $notify->id . '-' . rand(0, 1000000), + 'data' => array ( + "message" => 'abc' + ), + "time_to_live" => 1000 + ); + + foreach($rids as $rid){ + array_push($fields['registration_ids'], $rid->rid ); + } + + $fields = json_encode ($fields); + */ + + $rids = Gmc::all(); + $tokens = array(); + foreach($rids as $rid){ + array_push($tokens, $rid->rid ); + } + + + if(!empty($rid)){ + $fields = array ( + 'registration_ids' => $tokens, + 'message_id' => 'm-' . $notify->id . '-' . rand(0, 1000000), + 'data' => array ( + "message" => 'abc' + ), + "time_to_live" => 1000 + ); + $fields = json_encode ($fields); + + $ch = curl_init (); + curl_setopt ( $ch, CURLOPT_URL, $url ); + curl_setopt ( $ch, CURLOPT_POST, true ); + curl_setopt ( $ch, CURLOPT_HTTPHEADER, $headers ); + curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); + curl_setopt ( $ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); + curl_setopt ( $ch, CURLOPT_POSTFIELDS, $fields ); + $result = curl_exec ( $ch ); + curl_close ( $ch ); + var_dump($result); + var_dump($fields); + die(); + }else{ + + } + + $request->session()->flash('message', 'Successfully created new notification'); + return redirect()->route('notification.index'); + } + + /** + * Display the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function show($id) + { + return view('dashboard.notification.show', ['notification' => Notification::find($id)]); + } + + /** + * Show the form for editing the specified resource. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function edit($id) + { + return view('dashboard.notification.edit', ['notification' => Notification::find($id)]); + } + + /** + * Update the specified resource in storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\Response + */ + public function update(Request $request, $id) + { + $validatedData = $request->validate([ + 'title' => 'required', + 'message' => 'required', + 'logo' => 'required', + 'name' => 'required', + 'url' => 'required' + ]); + $notify = Notification::find($id); + $notify->title = $request->input('title'); + $notify->message = $request->input('message'); + $notify->logo = $request->input('logo'); + $notify->name = $request->input('name'); + $notify->url = $request->input('url'); + $notify->save(); + $request->session()->flash('message', 'Successfully updated notification'); + return redirect()->route('notification.index'); + } + + /** + * Remove the specified resource from storage. + * + * @param int $id + * @return \Illuminate\Http\Response + */ + public function destroy($id, Request $request) + { + $notify = Notification::find($id); + if($notify){ + $notify->delete(); + } + $request->session()->flash('message', 'Successfully deleted notification'); + return redirect()->route('notification.index'); + } + + public function getNotification(){ + return response()->json(array( + 'notification' => Notification::latest()->first() + )); + } + + public function getGMC(){ + $user = auth()->user(); + $gmc = Gmc::where('user_id', '=', $user->id)->first(); + if(empty($gmc)){ + $result = false; + }else{ + $result = true; + } + return response()->json(array('result' => $result)); + } + + public function setGMC(Request $request){ + $user = auth()->user(); + $gmc = new Gmc(); + $gmc->user_id = $user->id; + $gmc->rid = $request->input('gmc'); + $gmc->save(); + return response()->json(array('result' => 'success')); + } + + public function deleteGMC(Request $request){ + $user = auth()->user(); + $gmc = Gmc::where('user_id', '=', $user->id)->first(); + $gmc->delete(); + return response()->json(array('result' => 'success')); + } +} diff --git a/app/Models/Gmc.php b/app/Models/Gmc.php new file mode 100644 index 0000000..83a49ae --- /dev/null +++ b/app/Models/Gmc.php @@ -0,0 +1,12 @@ +bigIncrements('id'); + $table->text('rid'); + $table->integer('user_id')->unsigned(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('gmc'); + } +} diff --git a/database/migrations/2020_03_12_111402_create_notification_table.php b/database/migrations/2020_03_12_111402_create_notification_table.php new file mode 100644 index 0000000..9d46898 --- /dev/null +++ b/database/migrations/2020_03_12_111402_create_notification_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->timestamps(); + $table->string('title'); + $table->string('message'); + $table->string('logo'); + $table->string('name'); + $table->string('url'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('notification'); + } +} diff --git a/package-lock.json b/package-lock.json index 4361ce6..496a61a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1089,6 +1089,290 @@ "source-map": "^0.5.6" } }, + "@firebase/analytics": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@firebase/analytics/-/analytics-0.3.2.tgz", + "integrity": "sha512-z4mYytlmnNipXQrGB6bN0tzWa9GzCtK0M2HD86C9OFYpwBeDQGc3UQPAM6kbfkv50Mnl4vlS5Ta2qEw/CvWwug==", + "requires": { + "@firebase/analytics-types": "0.3.0", + "@firebase/component": "0.1.9", + "@firebase/installations": "0.4.7", + "@firebase/logger": "0.2.1", + "@firebase/util": "0.2.44", + "tslib": "1.11.1" + } + }, + "@firebase/analytics-types": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@firebase/analytics-types/-/analytics-types-0.3.0.tgz", + "integrity": "sha512-0AJ6xn53Qn0D/YOVHHvlWFfnzzRSdd98Lr8Oqe1PJ2HPIN+o7qf03YmOG7fLpR1uplcWd+7vGKmxUrN3jKUBwg==" + }, + "@firebase/app": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/@firebase/app/-/app-0.6.1.tgz", + "integrity": "sha512-KSzSFQfiJgxi+7Ff/EZQcdvCnqKj2db9xa7I8z1UoRIRez9e0Q6+GpW3mrSVmmSCrBbKYsOO/SJh5NaFot0evg==", + "requires": { + "@firebase/app-types": "0.6.0", + "@firebase/component": "0.1.9", + "@firebase/logger": "0.2.1", + "@firebase/util": "0.2.44", + "dom-storage": "2.1.0", + "tslib": "1.11.1", + "xmlhttprequest": "1.8.0" + } + }, + "@firebase/app-types": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@firebase/app-types/-/app-types-0.6.0.tgz", + "integrity": "sha512-ld6rzjXk/SUauHiQZJkeuSJpxIZ5wdnWuF5fWBFQNPaxsaJ9kyYg9GqEvwZ1z2e6JP5cU9gwRBlfW1WkGtGDYA==" + }, + "@firebase/auth": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/@firebase/auth/-/auth-0.14.2.tgz", + "integrity": "sha512-5HaEGne2JbcVvzK9FeOEGi8NNQwq00thmL88uduqI8LTXHSOWaC8Y4El9DesVu6aFEOXELpf7W4I34CG9WwjlA==", + "requires": { + "@firebase/auth-types": "0.10.0" + } + }, + "@firebase/auth-interop-types": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@firebase/auth-interop-types/-/auth-interop-types-0.1.4.tgz", + "integrity": "sha512-CLKNS84KGAv5lRnHTQZFWoR11Ti7gIPFirDDXWek/fSU+TdYdnxJFR5XSD4OuGyzUYQ3Dq7aVj5teiRdyBl9hA==" + }, + "@firebase/auth-types": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/@firebase/auth-types/-/auth-types-0.10.0.tgz", + "integrity": "sha512-VuW7c+RAk3AYPU0Hxmun3RzXn7fbJDdjQbxvvpRMnQ9zrhk8mH42cY466M0n4e/UGQ+0smlx5BqZII8aYQ5XPg==" + }, + "@firebase/component": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/@firebase/component/-/component-0.1.9.tgz", + "integrity": "sha512-i58GsVpxBGnKn1rx2RCAH0rk1Ldp6WterfBNDHyxmuyRO6BaZAgvxrZ3Ku1/lqiI7XMbmmRpP3emmwrStbFt9Q==", + "requires": { + "@firebase/util": "0.2.44", + "tslib": "1.11.1" + } + }, + "@firebase/database": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.6.0.tgz", + "integrity": "sha512-b1wt4BpzFOXxAaUtkFqfoeZzmZIQ3sLiznqOYaAROnK2JMxpFF41Nh9wZ2tCze6rOkpN+3Kx33hsPCsrQcn0WQ==", + "requires": { + "@firebase/auth-interop-types": "0.1.4", + "@firebase/component": "0.1.9", + "@firebase/database-types": "0.5.0", + "@firebase/logger": "0.2.1", + "@firebase/util": "0.2.44", + "faye-websocket": "0.11.3", + "tslib": "1.11.1" + }, + "dependencies": { + "faye-websocket": { + "version": "0.11.3", + "resolved": "https://registry.npmjs.org/faye-websocket/-/faye-websocket-0.11.3.tgz", + "integrity": "sha512-D2y4bovYpzziGgbHYtGCMjlJM36vAl/y+xUyn1C+FVx8szd1E+86KwVw6XvYSzOP8iMpm1X0I4xJD+QtUb36OA==", + "requires": { + "websocket-driver": ">=0.5.1" + } + } + } + }, + "@firebase/database-types": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@firebase/database-types/-/database-types-0.5.0.tgz", + "integrity": "sha512-6/W3frFznYOALtw2nrWVPK2ytgdl89CzTqVBHCCGf22wT6uKU63iDBo+Nw+7olFGpD15O0zwYalFIcMZ27tkew==", + "requires": { + "@firebase/app-types": "0.6.0" + } + }, + "@firebase/firestore": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-1.14.0.tgz", + "integrity": "sha512-JpwP6LWtNRjCtRbRvzhdtJ1tHL6r0MjCvmMr2Nv7bKmcjqoN8FiP+fZ9KkiZiqsSUhNsFFajyvx9n7R6vC+d2w==", + "requires": { + "@firebase/component": "0.1.9", + "@firebase/firestore-types": "1.10.1", + "@firebase/logger": "0.2.1", + "@firebase/util": "0.2.44", + "@firebase/webchannel-wrapper": "0.2.38", + "@grpc/grpc-js": "0.7.5", + "@grpc/proto-loader": "^0.5.0", + "tslib": "1.11.1" + } + }, + "@firebase/firestore-types": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@firebase/firestore-types/-/firestore-types-1.10.1.tgz", + "integrity": "sha512-vyKdm+AYUFT8XeUX62IOqaqPFCs/mAMoSEsqIz9HnSVsqCw/IocNjtjSa+3M80kRw4V8fI7JI+Xz6Wg5VJXLqA==" + }, + "@firebase/functions": { + "version": "0.4.40", + "resolved": "https://registry.npmjs.org/@firebase/functions/-/functions-0.4.40.tgz", + "integrity": "sha512-Yd0P+/xLt2Lc7AJpi1zff6xjVcJXpT7coTCBjb+58RQhECkoEh1ESx46VzoUGy+4ldoh/ZFFU7p0d/lG/+wDvg==", + "requires": { + "@firebase/component": "0.1.9", + "@firebase/functions-types": "0.3.16", + "@firebase/messaging-types": "0.4.4", + "isomorphic-fetch": "2.2.1", + "tslib": "1.11.1" + } + }, + "@firebase/functions-types": { + "version": "0.3.16", + "resolved": "https://registry.npmjs.org/@firebase/functions-types/-/functions-types-0.3.16.tgz", + "integrity": "sha512-kHhBvSYiY2prY4vNQCALYs1+OruTdylvGemHG6G6Bs/rj3qw7ui3WysBsDU/rInJitHIcsZ35qrtanoJeQUIXQ==" + }, + "@firebase/installations": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/@firebase/installations/-/installations-0.4.7.tgz", + "integrity": "sha512-Fz9B/H58xfkAnDGVTW1V/73Jd5LAN9o5dpz1K3+u2W+zp0iU6HoRTwm9Bgk+aV6/0FYjqmtYEDjK8T0OYPoIQA==", + "requires": { + "@firebase/component": "0.1.9", + "@firebase/installations-types": "0.3.3", + "@firebase/util": "0.2.44", + "idb": "3.0.2", + "tslib": "1.11.1" + } + }, + "@firebase/installations-types": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@firebase/installations-types/-/installations-types-0.3.3.tgz", + "integrity": "sha512-XvWhPPAGeZlc+CfCA8jTt2pv19Jovi/nUV73u30QbjBbk5xci9bp5I29aBZukHsR6YNBjFCLSkLPbno4m/bLUg==" + }, + "@firebase/logger": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.2.1.tgz", + "integrity": "sha512-H4nttTqUzEw3TA/JYl8ma6oMSNKHcdpEWV2L2qA+ZEcpM2OLAzagi//DrYBFR5xpPb17IGagpzSxFgx937Sq/A==" + }, + "@firebase/messaging": { + "version": "0.6.12", + "resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.6.12.tgz", + "integrity": "sha512-U5piZd/0JFI4/2ZqTiIGYPcQBeTit6fTUbozGn2RSKcQw6WuNb9QJDbTZCzo1BzrHf1zoIqyakggL2AvIq48vA==", + "requires": { + "@firebase/component": "0.1.9", + "@firebase/installations": "0.4.7", + "@firebase/messaging-types": "0.4.4", + "@firebase/util": "0.2.44", + "idb": "3.0.2", + "tslib": "1.11.1" + } + }, + "@firebase/messaging-types": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@firebase/messaging-types/-/messaging-types-0.4.4.tgz", + "integrity": "sha512-JGtkr+1A1Dw7+yCqQigqBfGKtq0gTCruFScBD4MVjqZHiqGIYpnQisWnpGbkzPR6aOt6iQxgwxUhHG1ulUQGeg==" + }, + "@firebase/performance": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/@firebase/performance/-/performance-0.3.0.tgz", + "integrity": "sha512-206klc2wzajagbHlR7T2GWvFHsfoRMMWLa2K3GIe6ikDGlPYa/F2byXYzv6e3mSOw6aKLSbTVcIaLBBourpOTA==", + "requires": { + "@firebase/component": "0.1.9", + "@firebase/installations": "0.4.7", + "@firebase/logger": "0.2.1", + "@firebase/performance-types": "0.0.12", + "@firebase/util": "0.2.44", + "tslib": "1.11.1" + } + }, + "@firebase/performance-types": { + "version": "0.0.12", + "resolved": "https://registry.npmjs.org/@firebase/performance-types/-/performance-types-0.0.12.tgz", + "integrity": "sha512-eIDF7CHetOE5sc+hCaUebEn/2Aiaju7UkgZDTl7lNQHz5fK9wJ/11HaE8WdnDr//ngS3lQAGC2RB4lAZeEWraA==" + }, + "@firebase/polyfill": { + "version": "0.3.33", + "resolved": "https://registry.npmjs.org/@firebase/polyfill/-/polyfill-0.3.33.tgz", + "integrity": "sha512-Arp9JViyD2i0K01NCCY0WZK5p16kQB/wddf44+Qboh+u3eIrFbVk0OO2IknjrkzIW392u73Ts7TkVxLPGPJF9g==", + "requires": { + "core-js": "3.6.4", + "promise-polyfill": "8.1.3", + "whatwg-fetch": "2.0.4" + }, + "dependencies": { + "core-js": { + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.4.tgz", + "integrity": "sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw==" + }, + "whatwg-fetch": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", + "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" + } + } + }, + "@firebase/remote-config": { + "version": "0.1.18", + "resolved": "https://registry.npmjs.org/@firebase/remote-config/-/remote-config-0.1.18.tgz", + "integrity": "sha512-ufbhnP3O6bRYs74jFIyYZ0dPsv/PsMSmGs669Os5SkEdfjEWX8hnhssfuZCg5VfJQiCrqoSQD/KfPGACmeBcbQ==", + "requires": { + "@firebase/component": "0.1.9", + "@firebase/installations": "0.4.7", + "@firebase/logger": "0.2.1", + "@firebase/remote-config-types": "0.1.8", + "@firebase/util": "0.2.44", + "tslib": "1.11.1" + } + }, + "@firebase/remote-config-types": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/@firebase/remote-config-types/-/remote-config-types-0.1.8.tgz", + "integrity": "sha512-K12IBHO7OD4gCW0FEqZL9zMqVAfS4+joC4YIn3bHezZfu3RL+Bw1wCb0cAD7RfDPcQxWJjxOHpce4YhuqSxPFA==" + }, + "@firebase/storage": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@firebase/storage/-/storage-0.3.31.tgz", + "integrity": "sha512-b5rwcMa89mFnKDlhFmGRC0QFpOgqGoNVn4klJDvSnpRGmwOcByQXoos8w1IWP0DW+EWhHcafy7DvUHFlr70onw==", + "requires": { + "@firebase/component": "0.1.9", + "@firebase/storage-types": "0.3.11", + "@firebase/util": "0.2.44", + "tslib": "1.11.1" + } + }, + "@firebase/storage-types": { + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/@firebase/storage-types/-/storage-types-0.3.11.tgz", + "integrity": "sha512-EMOo5aeiJIa8eQ/VqjIa/DYlDcEJX1V84FOxmLfNWZIlmCSvcqx9E9mcNlOnoUB4iePqQjTMQRtKlIBvvEVhVg==" + }, + "@firebase/util": { + "version": "0.2.44", + "resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.44.tgz", + "integrity": "sha512-yWnFdeuz7P0QC4oC77JyPdAQ/rTGPDfhHcR5WsoMsKBBHTyqEhaKWL9HeRird+p3AL9M4++ep0FYFNd1UKU3Wg==", + "requires": { + "tslib": "1.11.1" + } + }, + "@firebase/webchannel-wrapper": { + "version": "0.2.38", + "resolved": "https://registry.npmjs.org/@firebase/webchannel-wrapper/-/webchannel-wrapper-0.2.38.tgz", + "integrity": "sha512-mp1XmAJsuqaSWm5WQYo7R0zfZWe9EmwMCxsxkKr+ubLOumyNy4NG5aV45hEpFTosQv4myXpiCiS4GFE9mNqLZQ==" + }, + "@grpc/grpc-js": { + "version": "0.7.5", + "resolved": "https://registry.npmjs.org/@grpc/grpc-js/-/grpc-js-0.7.5.tgz", + "integrity": "sha512-hhWT+vHPtG4tn0zZJw4ndfv730pBPb+lhJfvQhc7ANBvqixtlNOaXm9VNI98wYF/em0PnrskXnOr8rHh96zjlg==", + "requires": { + "semver": "^6.2.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" + } + } + }, + "@grpc/proto-loader": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.5.4.tgz", + "integrity": "sha512-HTM4QpI9B2XFkPz7pjwMyMgZchJ93TVkL3kWPW8GDMDKYxsMnmf4w2TNMJK7+KNiYHS5cJrCEAFlF+AwtXWVPA==", + "requires": { + "lodash.camelcase": "^4.3.0", + "protobufjs": "^6.8.6" + } + }, "@mrmlnc/readdir-enhanced": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz", @@ -1136,6 +1420,60 @@ "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.1.1.tgz", "integrity": "sha512-sLqWxCzC5/QHLhziXSCAksBxHfOnQlhPRVgPK0egEw+ktWvG75T2k+aYWVjVh9+WKeT3tlG3ZNbZQvZLmfuOIw==" }, + "@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + }, + "@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + }, + "@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "requires": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + }, + "@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + }, + "@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + }, + "@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + }, + "@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + }, "@types/babel-types": { "version": "7.0.7", "resolved": "https://registry.npmjs.org/@types/babel-types/-/babel-types-7.0.7.tgz", @@ -1172,6 +1510,11 @@ "@types/node": "*" } }, + "@types/long": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", + "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + }, "@types/minimatch": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", @@ -4601,6 +4944,11 @@ } } }, + "dom-storage": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/dom-storage/-/dom-storage-2.1.0.tgz", + "integrity": "sha512-g6RpyWXzl0RR6OTElHKBl7nwnK87GUyZMYC7JWsB/IA73vpqK2K6LT39x4VepLxlSsWBFrPVLnsSR5Jyty0+2Q==" + }, "domain-browser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", @@ -4776,6 +5124,14 @@ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" }, + "encoding": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", + "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", + "requires": { + "iconv-lite": "~0.4.13" + } + }, "end-of-stream": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", @@ -6216,6 +6572,27 @@ "resolve-dir": "^1.0.1" } }, + "firebase": { + "version": "7.14.0", + "resolved": "https://registry.npmjs.org/firebase/-/firebase-7.14.0.tgz", + "integrity": "sha512-4QjP8WxVwVh6lvP8I96Wg11coJQ8si093xxUmafdOL7hWzG8u80EdlJOClK9zG8R37OjJRNsmXdslqFiJoGK5g==", + "requires": { + "@firebase/analytics": "0.3.2", + "@firebase/app": "0.6.1", + "@firebase/app-types": "0.6.0", + "@firebase/auth": "0.14.2", + "@firebase/database": "0.6.0", + "@firebase/firestore": "1.14.0", + "@firebase/functions": "0.4.40", + "@firebase/installations": "0.4.7", + "@firebase/messaging": "0.6.12", + "@firebase/performance": "0.3.0", + "@firebase/polyfill": "0.3.33", + "@firebase/remote-config": "0.1.18", + "@firebase/storage": "0.3.31", + "@firebase/util": "0.2.44" + } + }, "flat-cache": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-2.0.1.tgz", @@ -7917,6 +8294,11 @@ } } }, + "idb": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/idb/-/idb-3.0.2.tgz", + "integrity": "sha512-+FLa/0sTXqyux0o6C+i2lOR0VoS60LU/jzUo5xjfY6+7sEEgy4Gz1O7yFBXvjd7N0NyIGWIRg8DcQSLEG+VSPw==" + }, "ieee754": { "version": "1.1.13", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", @@ -8641,6 +9023,15 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, + "isomorphic-fetch": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz", + "integrity": "sha1-YRrhrPFPXoH3KVB0coGf6XM1WKk=", + "requires": { + "node-fetch": "^1.0.1", + "whatwg-fetch": ">=0.10.0" + } + }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", @@ -9337,8 +9728,7 @@ "lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", - "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=", - "dev": true + "integrity": "sha1-soqmKIorn8ZRA1x3EfZathkDMaY=" }, "lodash.defaultsdeep": { "version": "4.6.1", @@ -9482,6 +9872,11 @@ "resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.7.tgz", "integrity": "sha512-cY2eLFrQSAfVPhCgH1s7JI73tMbg9YC3v3+ZHVW67sBS7UxWzNEk/ZBbSfLykBWHp33dqqtOv82gjhKEi81T/A==" }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", @@ -9995,6 +10390,15 @@ "lower-case": "^1.1.1" } }, + "node-fetch": { + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", + "integrity": "sha512-NhZ4CsKx7cYm2vSrBAr2PvFOe6sWDf0UYLRqA6svUYg7+/TSfVAu49jYC4BvQ4Sms9SZgdqGBgroqfDhJdTyKQ==", + "requires": { + "encoding": "^0.1.11", + "is-stream": "^1.0.1" + } + }, "node-forge": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.9.0.tgz", @@ -12420,12 +12824,44 @@ "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=" }, + "promise-polyfill": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.1.3.tgz", + "integrity": "sha512-MG5r82wBzh7pSKDRa9y+vllNHz3e3d4CNj1PQE4BQYxLme0gKYYBm9YENq+UkEikyZ0XbiGWxYlVw3Rl9O/U8g==" + }, "proto-list": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", "integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=", "dev": true }, + "protobufjs": { + "version": "6.8.9", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.8.9.tgz", + "integrity": "sha512-j2JlRdUeL/f4Z6x4aU4gj9I2LECglC+5qR2TrWb193Tla1qfdaNQTZ8I27Pt7K0Ajmvjjpft7O3KWTGciz4gpw==", + "requires": { + "@protobufjs/aspromise": "^1.1.2", + "@protobufjs/base64": "^1.1.2", + "@protobufjs/codegen": "^2.0.4", + "@protobufjs/eventemitter": "^1.1.0", + "@protobufjs/fetch": "^1.1.0", + "@protobufjs/float": "^1.0.2", + "@protobufjs/inquire": "^1.1.0", + "@protobufjs/path": "^1.1.2", + "@protobufjs/pool": "^1.1.0", + "@protobufjs/utf8": "^1.1.0", + "@types/long": "^4.0.0", + "@types/node": "^10.1.0", + "long": "^4.0.0" + }, + "dependencies": { + "@types/node": { + "version": "10.17.19", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.19.tgz", + "integrity": "sha512-46/xThm3zvvc9t9/7M3AaLEqtOpqlYYYcCZbpYVAQHG20+oMZBkae/VMrn4BTi6AJ8cpack0mEXhGiKmDNbLrQ==" + } + } + }, "proxy-addr": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", @@ -17276,6 +17712,11 @@ "iconv-lite": "0.4.24" } }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" + }, "whatwg-mimetype": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", @@ -17477,6 +17918,11 @@ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "dev": true }, + "xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" + }, "xmlhttprequest-ssl": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-1.5.5.tgz", diff --git a/package.json b/package.json index b8606a3..83b5e1b 100644 --- a/package.json +++ b/package.json @@ -76,12 +76,12 @@ "@coreui/icons": "^1.0.1", "@coreui/utils": "^1.2.2", "@popperjs/core": "^2.0.6", - "chart.js": "^2.9.3", - "perfect-scrollbar": "1.5.0", "axios": "^0.19.0", + "chart.js": "^2.9.3", "cropperjs": "^1.5.6", "laravel-mix": "^5.0.0", - "pace-progress": "1.0.2" + "pace-progress": "1.0.2", + "perfect-scrollbar": "1.5.0" }, "devDependencies": { "@babel/cli": "^7.8.4", diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 59d9c9b..61dc8ae 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -20,6 +20,8 @@ "/js/widgets.js": "/js/widgets.js", "/js/popovers.js": "/js/popovers.js", "/js/tooltips.js": "/js/tooltips.js", + "/js/notifications.js": "/js/notifications.js", + "/service-worker.js": "/service-worker.js", "/css/free.min.css": "/css/free.min.css", "/css/brand.min.css": "/css/brand.min.css", "/css/flag.min.css": "/css/flag.min.css" diff --git a/public/service-worker.js b/public/service-worker.js new file mode 100644 index 0000000..86f38f6 --- /dev/null +++ b/public/service-worker.js @@ -0,0 +1,29 @@ +let self = this; +let urlMain; +let fetchUrl = "http://127.0.0.1:8000/notification/notification/get-notification"; +self.addEventListener("push", function(event) { + event.waitUntil( + fetch(fetchUrl, { + method: "get" + }) + .then(function(response) { + return response.json(); + }) + .then(function(result) { + urlMain = result.data.url; + const options = { + body: result.data.msg, + icon: result.data.logo, + image: result.data.name, + action: result.data.url + }; + self.registration.showNotification(result.data.title, options); + }) + ); +}); + +self.addEventListener("notificationclick", function(event) { + event.notification.close(); + const promiseChain = clients.openWindow(urlMain); + event.waitUntil(promiseChain); +}); \ No newline at end of file diff --git a/resources/js/coreui/notifications.js b/resources/js/coreui/notifications.js new file mode 100644 index 0000000..5df275f --- /dev/null +++ b/resources/js/coreui/notifications.js @@ -0,0 +1,264 @@ +/* +06.04.2020 +notifications.js +*/ + +let self = this; +let isPushEnabled = false; +let pushButton = document.querySelector("#push-button"); +let desc = document.querySelector("#push-info-p"); +let disableText = "Unsubscribe Notifications"; +let enableText = "Subscribe Notifications"; +let disableDesc = "Thank you for enable notifications from page"; +let enableDesc = "Here you can enable notifications from this page"; +let fetchUrl = "http://127.0.0.1:8000/notification/notification"; + +console.log('BBBBBBBBBBBBBBBBB'); + +function sendSubscriptionToServer(subscription) { + var temp = subscription.endpoint.split("/"); + var registration_id = temp[temp.length - 1]; + fetch( + fetchUrl + '/insertGCM/' + registration_id, + { method: "get" } + ).then(function(response) { + return response.json(); + } + ); +} + +function deleteSubscriptionToServer(rid) { + fetch(fetchUrl + '/deleteGCM/' + rid, { + method: "get" + }).then(function(response) { + return response.json(); + } + ); +} + +function serviceWorkerCall() { + if ("serviceWorker" in navigator) { + navigator.serviceWorker.register("/js/service-worker.js").then(initialiseState).then(function(){console.log('call service-worker')}); + }else{ + console.warn("Service workers aren't supported in this browser."); + } + } + + function initialiseState() { + if (!("showNotification" in ServiceWorkerRegistration.prototype)) { + console.log("Notifications aren't supported."); + return; + } + + if (Notification.permission === "denied") { + console.log("The user has blocked notifications."); + return; + } + + if (!("PushManager" in window)) { + console.log("Push messaging isn't supported."); + return; + } + + navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { + serviceWorkerRegistration.pushManager + .getSubscription() + .then(function(subscription) { + pushButton.disabled = false; + if (!subscription) { + return; + } + if (subscription) { + sendSubscriptionToServer(subscription); + } + + pushButton.textContent = disableText; + desc.textContent = disableDesc; + isPushEnabled = true; + }) + .catch(function(e) { + console.log("Error during getSubscription()", e); + }); + }); + } + + function subscribe() { + console.log('A'); + //pushButton.disabled = true; + navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { + console.log('B'); + serviceWorkerRegistration.pushManager.subscribe({ userVisibleOnly: true }) + .then(function(subscription) { + console.log('C'); + isPushEnabled = true; + pushButton.textContent = disableText; + desc.textContent = disableDesc; + pushButton.disadbled = false; + console.log('D'); + if (subscription) { + console.log('E'); + sendSubscriptionToServer(subscription); + } + }) + .catch(function(e) { + console.log('F'); + if (Notification.permission === "denied") { + console.warn("Permission for Notification is denied"); + pushButton.disabled = true; + } else { + console.error("Unable to subscribe to push", e); + pushButton.disabled = true; + pushButton.textContent = "Enable Push Messages"; + } + console.log('G'); + }); + }); + } + + function unsubscribe() { + pushButton.disabled = true; + navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { + serviceWorkerRegistration.pushManager + .getSubscription() + .then(function(pushSubscription) { + if (!pushSubscription) { + isPushEnabled = false; + pushButton.disabled = false; + pushButton.textContent = enableText; + desc.textContent = enableDesc; + return; + } + + var temp = pushSubscription.endpoint.split("/"); + var registration_id = temp[temp.length - 1]; + deleteSubscriptionToServer(registration_id); + + pushSubscription.unsubscribe().then(function(successful) { + pushButton.disabled = false; + pushButton.textContent = enableText; + desc.textContent = enableDesc; + isPushEnabled = false; + }) + .catch(function(e) { + console.error("Error thrown while unsbscribing from push messaging."); + }); + }); + }); + } + + + /* +document.addEventListener("DOMContentLoaded", function() { + if (isPushEnabled) { + console.log('unsubscribe'); + unsubscribe(); + } else { + console.log('subscribe'); + subscribe(); + } + serviceWorkerCall(); +}); +*/ + +function urlBase64ToUint8Array(base64String) { + const padding = '='.repeat((4 - (base64String.length % 4)) % 4); + const base64 = (base64String + padding).replace(/\-/g, '+').replace(/_/g, '/'); + const rawData = window.atob(base64); + const outputArray = new Uint8Array(rawData.length); + for (let i = 0; i < rawData.length; ++i) { + outputArray[i] = rawData.charCodeAt(i); + } + return outputArray; +} + + + + +function initialiseState() { + if(!("showNotification" in ServiceWorkerRegistration.prototype)) { + console.log("Notifications aren't supported."); + return; + } + if(Notification.permission === "denied") { + console.log("The user has blocked notifications."); + return; + } + if(!("PushManager" in window)) { + console.log("Push messaging isn't supported."); + return; + } + console.log('C'); + navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) { + + console.log('D'); + + serviceWorkerRegistration.pushManager + .getSubscription() + .then(function(subscription) { + + console.log('A', subscription); + + pushButton.disabled = false; + if (!subscription) { + console.log('EEE'); + serviceWorkerRegistration.pushManager.subscribe({ + userVisibleOnly: true, + applicationServerKey: urlBase64ToUint8Array(window.vapidPublicKey), + //applicationServerKey: window.vapidPublicKey, + }).then(function(subscription) { + console.log('EEE-2'); + isPushEnabled = true; + pushButton.textContent = disableText; + desc.textContent = disableDesc; + pushButton.disadbled = false; + if (subscription) { + console.log('EEE-3'); + sendSubscriptionToServer(subscription); + } + }).catch(function(err){ + console.log('error subscribe: ' + err); + }); + } + if (subscription) { + sendSubscriptionToServer(subscription); + } + + pushButton.textContent = disableText; + desc.textContent = disableDesc; + isPushEnabled = true; + }) + .catch(function(e) { + console.log("Error during getSubscription()", e); + }); + }).catch(function(){ + console.log('B'); + }); +} + +function sendSubscriptionToServer(subscription) { + var temp = subscription.endpoint.split("/"); + var registration_id = temp[temp.length - 1]; + console.log(subscription); + fetch( + fetchUrl + '/set-gmc?gmc=' + registration_id, + { method: "get" } + ).then(function(response) { + console.log('send subscription to server'); + return response.json(); + }).catch(function(){ + console.log('set-gmc server error'); + }); +} + +function serviceWorkerCall() { + if ("serviceWorker" in navigator) { + navigator.serviceWorker.register("/service-worker.js").then(initialiseState).then(function(){console.log('call service-worker')}); + }else{ + console.warn("Service workers aren't supported in this browser."); + } +} + +document.addEventListener("DOMContentLoaded", function() { + serviceWorkerCall(); + +}); diff --git a/resources/js/coreui/service-worker.js b/resources/js/coreui/service-worker.js new file mode 100644 index 0000000..86f38f6 --- /dev/null +++ b/resources/js/coreui/service-worker.js @@ -0,0 +1,29 @@ +let self = this; +let urlMain; +let fetchUrl = "http://127.0.0.1:8000/notification/notification/get-notification"; +self.addEventListener("push", function(event) { + event.waitUntil( + fetch(fetchUrl, { + method: "get" + }) + .then(function(response) { + return response.json(); + }) + .then(function(result) { + urlMain = result.data.url; + const options = { + body: result.data.msg, + icon: result.data.logo, + image: result.data.name, + action: result.data.url + }; + self.registration.showNotification(result.data.title, options); + }) + ); +}); + +self.addEventListener("notificationclick", function(event) { + event.notification.close(); + const promiseChain = clients.openWindow(urlMain); + event.waitUntil(promiseChain); +}); \ No newline at end of file diff --git a/resources/views/dashboard/notification/create.blade.php b/resources/views/dashboard/notification/create.blade.php new file mode 100644 index 0000000..7c070bb --- /dev/null +++ b/resources/views/dashboard/notification/create.blade.php @@ -0,0 +1,60 @@ +@extends('dashboard.base') + +@section('content') + +
+
+
+
+
+
+

Add Notification

+
+
+ @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif +
+ @csrf +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + Return +
+
+
+
+
+
+
+ +@endsection + + +@section('javascript') + +@endsection diff --git a/resources/views/dashboard/notification/edit.blade.php b/resources/views/dashboard/notification/edit.blade.php new file mode 100644 index 0000000..faafcbd --- /dev/null +++ b/resources/views/dashboard/notification/edit.blade.php @@ -0,0 +1,74 @@ +@extends('dashboard.base') + +@section('content') + +
+
+
+
+
+
+ Edit Notification
+
+ @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif +
+ @csrf + @method('PUT') +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ + + Return +
+
+
+
+
+
+
+ +@endsection + +@section('javascript') + +@endsection \ No newline at end of file diff --git a/resources/views/dashboard/notification/index.blade.php b/resources/views/dashboard/notification/index.blade.php new file mode 100644 index 0000000..b2cff8e --- /dev/null +++ b/resources/views/dashboard/notification/index.blade.php @@ -0,0 +1,82 @@ +@extends('dashboard.base') + +@section('content') + +
+
+
+
+
+
+ Enable Notifications +
+
+ +

Here you can enable notifications from this page

+
+
+
+
+
+
+ Notifications +
+
+ @if(Session::has('message')) +
+
+ +
+
+ @endif + +
+ + + + + + + + + + + @foreach($notifications as $notification) + + + + + + + @endforeach + +
Title
{{ $notification->title }} + View + + Edit + +
+ @method('DELETE') + @csrf + +
+
+ {{ $notifications->links() }} +
+
+
+
+
+
+ +@endsection + + +@section('javascript') + + +@endsection \ No newline at end of file diff --git a/resources/views/dashboard/notification/public.blade.php b/resources/views/dashboard/notification/public.blade.php new file mode 100644 index 0000000..8bbcca9 --- /dev/null +++ b/resources/views/dashboard/notification/public.blade.php @@ -0,0 +1,47 @@ +@extends('dashboard.base') + +@section('content') + +
+
+
+
+
+
+ Notification +
+
+ @if(Session::has('message')) +
+
+ +
+
+ @endif + + + Lorem ipsum dolor cet emit. Emit cet dolor ipsum lorem. Dolor ipsum lorem emit cet. + Lorem ipsum dolor cet emit. Emit cet dolor ipsum lorem. Dolor ipsum lorem emit cet. + Lorem ipsum dolor cet emit. Emit cet dolor ipsum lorem. Dolor ipsum lorem emit cet. + Lorem ipsum dolor cet emit. Emit cet dolor ipsum lorem. Dolor ipsum lorem emit cet. + Lorem ipsum dolor cet emit. Emit cet dolor ipsum lorem. Dolor ipsum lorem emit cet. + Lorem ipsum dolor cet emit. Emit cet dolor ipsum lorem. Dolor ipsum lorem emit cet. +
+
+
+
+
+
+ +@endsection + + +@section('javascript') + + + +@endsection \ No newline at end of file diff --git a/resources/views/dashboard/notification/show.blade.php b/resources/views/dashboard/notification/show.blade.php new file mode 100644 index 0000000..f1b7845 --- /dev/null +++ b/resources/views/dashboard/notification/show.blade.php @@ -0,0 +1,38 @@ +@extends('dashboard.base') + +@section('content') + +
+
+
+
+
+
+ Notification +
+
+
+

Title:

+

{{ $notification->title }}

+

Message:

+

{{ $notification->message }}

+

Logo:

+

{{ $notification->logo }}

+

Name:

+

{{ $notification->name }}

+

URL:

+

{{ $notification->url }}

+ Return +
+
+
+
+
+
+ +@endsection + + +@section('javascript') + +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index ba776cc..ef63b73 100644 --- a/routes/web.php +++ b/routes/web.php @@ -59,6 +59,7 @@ Route::get('/modals', function(){ return view('dashboard.notifications.modals'); }); }); Route::resource('notes', 'NotesController'); + //Route::get('/notification', function () { return view('dashboard.notification.public'); }); }); Auth::routes(); @@ -73,6 +74,17 @@ ]); Route::group(['middleware' => ['role:admin']], function () { + + Route::resource('notification', 'NotificationController'); + Route::prefix('notification/notification')->group(function () { + Route::get('get-notification', 'NotificationController@getNotification'); + Route::get('get-gmc', 'NotificationController@getGmc'); + Route::get('set-gmc', 'NotificationController@setGmc'); + Route::get('delete-gmc', 'NotificationController@deleteGmc'); + }); + + + Route::resource('bread', 'BreadController'); //create BREAD (resource) Route::resource('users', 'UsersController')->except( ['create', 'store'] ); Route::resource('roles', 'RolesController'); diff --git a/webpack.mix.js b/webpack.mix.js index d13ec8f..0067c23 100644 --- a/webpack.mix.js +++ b/webpack.mix.js @@ -40,11 +40,14 @@ mix.copy('resources/js/coreui/charts.js', 'public/js'); mix.copy('resources/js/coreui/widgets.js', 'public/js'); mix.copy('resources/js/coreui/popovers.js', 'public/js'); mix.copy('resources/js/coreui/tooltips.js', 'public/js'); +mix.copy('resources/js/coreui/notifications.js', 'public/js'); // details scripts admin-panel mix.js('resources/js/coreui/menu-create.js', 'public/js'); mix.js('resources/js/coreui/menu-edit.js', 'public/js'); mix.js('resources/js/coreui/media.js', 'public/js'); mix.js('resources/js/coreui/media-cropp.js', 'public/js'); +//service-worker +mix.copy('resources/js/coreui/service-worker.js', 'public'); //*************** OTHER ****************** //fonts mix.copy('node_modules/@coreui/icons/fonts', 'public/fonts'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy