Compare commits

...

54 Commits

Author SHA1 Message Date
Grégoire e35cb0c461 fix : link mail answer spontaneous 2019-12-30 16:22:13 +01:00
Grégoire db084707bb fix : search bar v2 2019-12-30 13:20:11 +01:00
Grégoire 1a9fff778a fix : search bar 2019-12-30 12:27:11 +01:00
Sébastien 90a38edb29 Fix: Add new noreply email 2019-11-28 08:31:58 +01:00
Sébastien fc1b4a3e2a Feat: add popup when change company user email 2019-11-26 08:52:59 +01:00
Sebastien Glatz 94a946e36d Fix: little space fix 2019-11-22 16:12:09 +01:00
Sébastien f06cbe296f Fix: Banner color and padding 2019-11-21 15:56:48 +01:00
Sébastien e2a98aaed3 Feat: Edit form to add bootstrap style on input 2019-11-21 15:36:32 +01:00
Sébastien beee2c5635 Feat: Add field email on Company Edition 2019-11-21 14:33:42 +01:00
Grégoire bca29b9547 delete TalentController api 2019-11-05 14:07:50 +01:00
Grégoire 823a781d3a minor fix Push Notification 2019-11-05 11:24:34 +01:00
Grégoire 2a9e728354 correctif Menu 2019-10-28 17:03:46 +01:00
Grégoire 074c125f8c Redirect monCompte API 2019-10-28 14:36:14 +01:00
Grégoire 0b2898d170 Add twitter, linkedin … for getIdCard() 2019-10-15 09:57:37 +02:00
Grégoire 12525dbf16 Merge branch 'master' of https://git.e-declic.net/talents-tube/website 2019-10-14 16:43:13 +02:00
Grégoire 4a17adf687 add phone / linkedin / twitter … field for API form 2019-10-14 16:32:39 +02:00
Huaoe f4e412d792 Merge branch 'master' of https://git.e-declic.net/talents-tube/website 2019-10-11 15:48:44 +02:00
Grégoire 61786797c8 API : add getUserSubscriptionToPush (old : isUserSubscribedToPush) 2019-10-11 15:17:43 +02:00
Huaoe 57587a4a97 Merge branch 'master' of https://git.e-declic.net/talents-tube/website 2019-10-11 14:29:20 +02:00
Grégoire fd048d5a0e Merge branch 'master' of https://git.e-declic.net/talents-tube/website 2019-10-11 14:19:28 +02:00
Grégoire 229893dc95 API : add isUserSubscribedToPush 2019-10-11 14:19:02 +02:00
Grégoire 26c6e2103d API : ad visit record for companies and ads pages 2019-10-10 16:59:08 +02:00
Grégoire 8830b5ccde Set isPrivate true by default for companies 2019-10-10 16:57:50 +02:00
Huaoe 2bc2d87b8c UpdateUser fix request->request 2019-10-10 16:24:23 +02:00
Huaoe 278c558c9e Merge branch 'master' of https://git.e-declic.net/talents-tube/website 2019-10-10 14:49:02 +02:00
Huaoe 98545707b3 photo return 2019-10-09 17:01:58 +02:00
Sébastien 52d105efb4 Feat: add field phone and edit set extra 2019-10-09 11:31:53 +02:00
Sébastien 027c3fd2d1 Fix: presentationVideo syntax error 2019-10-09 11:27:52 +02:00
Grégoire 824ff9f1ec Change query / no selecting talent video in chat 2019-10-09 10:48:56 +02:00
Grégoire 606e29280b Fix bug draft message show app 2019-10-08 16:05:19 +02:00
Sébastien 3a29c647dd Fix: serialize tags for answer 2019-10-07 15:15:18 +02:00
Huaoe 57dd053693 Merge branch 'master' of https://git.e-declic.net/talents-tube/website 2019-10-07 09:51:42 +02:00
Huaoe e57173f835 upload profil picture 2019-10-07 09:51:35 +02:00
Sébastien 8f4ef35ddf Feat: Serialize publicTag for offer detail 2019-10-04 13:48:37 +02:00
Sébastien 346b788f83 Feat: Add titleTalent in extra to update from app 2019-10-04 13:48:08 +02:00
Sébastien edf35c74e8 Feat: Serialize territory type 2019-10-01 18:11:08 +02:00
Sébastien 75f2bbf6a7 Fix: php syntax error 2019-10-01 18:10:15 +02:00
Grégoire 0cbe670c90 change order for entreprises 2019-10-01 16:28:52 +02:00
Sébastien 2d595c1c3a Serialize territories for ad detail 2019-09-26 11:41:08 +02:00
Sébastien 98ebde7e72 Add linkedin twitter and website data for app 2019-09-26 11:40:36 +02:00
Huaoe d607962523 style.css generated 2019-09-16 16:20:09 +02:00
Huaoe b4ae35f4a6 yellow banner Off 2019-09-16 16:18:44 +02:00
Huaoe be37e97a19 fix PWA link 2019-09-16 15:50:53 +02:00
Huaoe d21febaaa1 css update 2019-09-16 14:54:03 +02:00
Huaoe 6acba9c082 css + tag manager 2019-09-16 14:43:38 +02:00
Huaoe 65147a9ac6 dev BDDD paswword 2019-09-13 14:00:00 +02:00
Huaoe a366ed749e merge Ad repo 2019-09-12 12:02:22 +02:00
Huaoe 87f6956958 isPrivate 2019-09-12 12:00:27 +02:00
Huaoe 3a78ac68f2 isPrivate in search ad 2019-09-11 16:21:11 +02:00
Sébastien 39774c1ed9 Merge branch 'master' of https://git.e-declic.net/talents-tube/website 2019-09-10 15:40:15 +02:00
Sébastien bd477b3354 Fix: ads order list 2019-09-10 15:38:13 +02:00
Sébastien 86e33a5e0a Fix: mysql-client to mariadb-client 2019-09-10 08:45:20 +02:00
Huaoe 365c71751d assetic fix 2019-09-09 17:27:40 +02:00
Huaoe 46399bd8ed typo notifications 2019-09-09 15:07:52 +02:00
50 changed files with 6654 additions and 10277 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
FROM php:7.1-fpm
FROM php:7.1-fpm-buster
ENV TERM=xterm
@@ -10,7 +10,7 @@ RUN echo 'fr_FR.UTF-8 UTF-8' > /etc/locale.gen \
&& /usr/sbin/locale-gen
RUN apt-get update \
&& apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev libmcrypt-dev libxslt-dev libicu-dev libxml2-dev libpq-dev libgeoip-dev libedit-dev mysql-client \
&& apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev libmcrypt-dev libxslt-dev libicu-dev libxml2-dev libpq-dev libgeoip-dev libedit-dev mariadb-client \
&& apt-get install -y --no-install-recommends libmagickwand-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j4 gd mcrypt xsl zip intl gettext soap pdo_pgsql pdo_mysql mysqli pgsql json readline opcache \
+6
View File
@@ -14,6 +14,12 @@ Copy this before composer require : COMPOSER_MEMORY_LIMIT=-1
In php container, root@php:/home/www/website/www# php bin/console doctrine:schema:update --force
It'll update database based on entities
## For Js : use assetic commande inside server container
- do a cache-clear to update the assectic.yml file
bin/console cache:clear --env=prod --no-debug
- then
php bin/console assetic:dump --env=prod --no-debug
## To push notifications
- Create new .json file in web/push folder.
+52 -2
View File
@@ -14,7 +14,28 @@
{% endblock %}
{% block content %}
{{ form_start(formUser, {'id': 'formUser'}) }}
<div class="row">
<div class="col-xs-8">
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">Compte utilisateur</h3>
</div>
<div class="box-body">
{{ form_errors(formUser) }}
{{ form_label(formUser.email, 'Email') }}
{{ form_widget(formUser.email, {'attr': {'class': 'form-control'}}) }}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<button class="btn btn-success edit-email-user" data-toggle="tooltip" type="submit">Enregistrer</button>
</div>
</div>
{{ form_end(formUser) }}
<br/>
{{ form_start(form) }}
<div class="row">
<div class="col-xs-8">
@@ -37,7 +58,6 @@
{{ form_row(form.website) }}
{{ form_row(form.tagsComma) }}
{{ form_row(form.file) }}
</div>
</div>
</div>
@@ -66,3 +86,33 @@
{{ form_end(form) }}
{% endblock %}
{% block javascripts %}
<script>
$(document).ready(function () {
$('[data-toggle="popover"]').popover();
$(".edit-email-user").confirm({
title: "Êtes vous sûr de modifier l'adresse mail de cet utilisateur ?",
content: "Si une erreur de saisie est présente, l'utilisateur ne pourra plus recevoir vos mails.",
type: 'ored',
boxWidth: '30%',
useBootstrap: false,
buttons: {
confirm: {
text: 'Confirmer',
action: function() {
$("[name='user_company']").submit();
return true;
}
},
cancel: {
text: 'Annuler'
}
}
});
});
</script>
{% endblock %}
@@ -3,20 +3,11 @@
<head>
<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(), event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'UA-98246968-1');
</script>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-P4G65WJ');</script>
<!-- End Google Tag Manager -->
<script type="text/javascript" defer="defer" src="https://extend.vimeocdn.com/ga/64189815.js"></script>
@@ -3,20 +3,11 @@
<head>
<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({
'gtm.start': new Date().getTime(), event: 'gtm.js'
});
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : '';
j.async = true;
j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-P4G65WJ');
</script>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-P4G65WJ');</script>
<!-- End Google Tag Manager -->
<script type="text/javascript" defer="defer" src="https://extend.vimeocdn.com/ga/64189815.js"></script>
@@ -65,6 +56,7 @@
'@global'
output='assetic/main.base.dash.js' filter='?uglifyjs2' %}
<script src="{{ asset_url }}"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDYV8IJGtIoWLfXJQQvIuDQ88n2aEuRgpg&libraries=places"></script>
{% endjavascripts %}
{% endblock %}
</body>
@@ -83,13 +83,13 @@
</div>
</div>
</div>
{#<div id="newApp" class="container-fluid">
<div id="newApp" class="container-fluid">
<div class="row">
<div class="col s12 m12">
<p>"Nouveau ! Trouvez un job plus facilement avec notre <a href="http://pp.app.talentstube.com">web application</a>.📲"</p>
<p>"Nouveau ! Trouvez un job plus facilement avec notre <a href="http://app.talentstube.com">web application</a>.📲"</p>
</div>
</div>
</div>#}
</div>
</div>
<div class="nav-wrapper">
<ul class="side-nav collapsible" data-collapsible="accordion" id="mobile-demo">
@@ -100,10 +100,10 @@
<a class="collapsible-header" title="Talents">Talents</a>
<div class="collapsible-body">
<ul>
<li><ahref="{{ path('ad_search_result') }}" title="Offres d'emploi vidéos">Offres d'emploi</a></li>
<li><ahref="{{ path('page_cvVideo') }}" title="Le Cv vidéo">Le CV vidéo</a></li>
<li><ahref="{{ path('page_reussirCVvideo') }}" title="Comment faire son CV Vidéo ?">Comment faire son CV Vidéo ?</a></li>
<li><ahref="{{ path('page_accompagnementTalent') }}" title="Accompagnement talent">Accompagnement</a></li>
<li><a href="{{ path('ad_search_result') }}" title="Offres d'emploi vidéos">Offres d'emploi</a></li>
<li><a href="{{ path('page_cvVideo') }}" title="Le Cv vidéo">Le CV vidéo</a></li>
<li><a href="{{ path('page_reussirCVvideo') }}" title="Comment faire son CV Vidéo ?">Comment faire son CV Vidéo ?</a></li>
<li><a href="{{ path('page_accompagnementTalent') }}" title="Accompagnement talent">Accompagnement</a></li>
</ul>
</div>
</li>
@@ -114,11 +114,11 @@
<a class="collapsible-header" title="Les entreprises de talents">Entreprises</a>
<div class="collapsible-body">
<ul>
<li><ahref="{{ path('company_list') }}" title="Listes entreprises">Listes entreprises</a></li>
<li><ahref="{{ path('page_OffreEmploi') }}" title="L'offre d'emploi en vidéo">L'offre d'emploi en vidéo</a></li>
<li><ahref="{{ path('page_reussirOffrevideo') }}" title="Comment faire une offre en vidéo">Comment faire une offre en vidéo</a></li>
<li><ahref="{{ path('page_MarqueEmployeur') }}" title="Vidéo Marque Employeur">Vidéo Marque Employeur</a></li>
<li><ahref="{{ path('page_accompagnementEntreprise') }}" title="Conseils & accompagnement">Conseils & accompagnement</a></li>
<li><a href="{{ path('company_list') }}" title="Listes entreprises">Listes entreprises</a></li>
<li><a href="{{ path('page_OffreEmploi') }}" title="L'offre d'emploi en vidéo">L'offre d'emploi en vidéo</a></li>
<li><a href="{{ path('page_reussirOffrevideo') }}" title="Comment faire une offre en vidéo">Comment faire une offre en vidéo</a></li>
<li><a href="{{ path('page_MarqueEmployeur') }}" title="Vidéo Marque Employeur">Vidéo Marque Employeur</a></li>
<li><a href="{{ path('page_accompagnementEntreprise') }}" title="Conseils & accompagnement">Conseils & accompagnement</a></li>
</ul>
</div>
</li>
@@ -126,9 +126,9 @@
<a class="collapsible-header" title="Les territoires">Territoires</a>
<div class="collapsible-body">
<ul>
<li><ahref="{{ path('territory_list') }}">Liste des territoires</a></li>
<li><ahref="{{ path('page_VideoTerritory') }}">La vidéo territoire</a></li>
<li><ahref="{{ path('page_AccompagnementTerritory') }}">Conseils et accompagnement</a></li>
<li><a href="{{ path('territory_list') }}">Liste des territoires</a></li>
<li><a href="{{ path('page_VideoTerritory') }}">La vidéo territoire</a></li>
<li><a href="{{ path('page_AccompagnementTerritory') }}">Conseils et accompagnement</a></li>
</ul>
</div>
</li>
@@ -16,7 +16,11 @@
<br/>
<br/>
<div style="text-align:center;">
<a class="btn btn-default" href="{{ absolute_url(path('talent_ad_detail',{'alias': answer.ad.alias,'id': answer.id })) }}">Visionner la réponse vidéo</a>
{% if answer.ad.alias is null %}
<a class="btn btn-default" href="{{ absolute_url(path('talent_ad_detail',{'alias': aliasCompany,'id': answer.id })) }}">Visionner la réponse</a>
{% else %}
<a class="btn btn-default" href="{{ absolute_url(path('talent_ad_detail',{'alias': answer.ad.alias,'id': answer.id })) }}">Visionner la réponse</a>
{% endif %}
</div>
{% else %}
<br />
@@ -26,7 +30,11 @@
<br/>
<br/>
<div style="text-align:center;">
<a class="btn btn-default" href="{{ absolute_url(path('talent_ad_detail',{'alias': answer.ad.alias,'id': answer.id })) }}">Consulter la réponse</a>
{% if answer.ad.alias is null %}
<a class="btn btn-default" href="{{ absolute_url(path('talent_ad_detail',{'alias': aliasCompany,'id': answer.id })) }}">Consulter la réponse</a>
{% else %}
<a class="btn btn-default" href="{{ absolute_url(path('talent_ad_detail',{'alias': answer.ad.alias,'id': answer.id })) }}">Consulter la réponse</a>
{% endif %}
</div>
{% endif %}
<br>
@@ -18,11 +18,3 @@
</div>
{% endblock %}
{% block javascripts %}
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDYV8IJGtIoWLfXJQQvIuDQ88n2aEuRgpg&libraries=places"></script>
{% javascripts
'@talents'
output='assetic/main.dashboard.talent.js' filter='?uglifyjs2' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
@@ -33,7 +33,7 @@
<input type="checkbox" id="notificationChecked" name="notificationChecked" {{isNotificationAllowed ? "checked=checked":""}}/>
<label for="notificationChecked">Autoriser les notificaitons</label>
<label for="notificationChecked">Autoriser les notifications</label>
</div>
</div>
@@ -5,8 +5,8 @@ assetic:
filters:
cssrewrite: ~
uglifyjs2:
bin: /usr/lib/node_modules/uglify-es/bin/uglifyjs
# bin: /usr/local/bin/uglifyjs2
#bin: /usr/lib/node_modules/uglify-es/bin/uglifyjs
bin: /usr/local/bin/uglifyjs #sym linked in container (see makefile)
assets:
vendors:
inputs:
@@ -46,6 +46,8 @@ assetic:
- 'js/vendors/datepicker.min.js'
- 'js/vendors/jquery.validate.min.js'
- 'js/talent.js'
- 'js/EdeclicTools.js'
- 'js/EdeclicPushAndNotificationClient.js'
admin:
inputs:
- 'admin/AdminLTE/plugins/jQuery/jquery-2.2.3.min.js'
+18 -1
View File
@@ -106,7 +106,7 @@ fos_user:
email:
template: email/password_resetting.email.twig
from_email:
address: noreply@talentstube.com
address: noreply@talentstube.io
sender_name: talentstube.com
service:
mailer: fos_user.mailer.twig_swift
@@ -250,6 +250,7 @@ fos_rest:
serialize_null: true
format_listener:
rules:
- { path: '^/api/talent', priorities: ['html'], fallback_format: 'html' }
- { path: '^/api/', priorities: ['json'], fallback_format: 'json' }
param_fetcher_listener: true
exception:
@@ -264,6 +265,22 @@ lexik_jwt_authentication:
public_key: '%kernel.root_dir%/../app/config/jwt/public.pem' # required for token verification
pass_phrase: 'talentstubeforever' # required for token creation, usage of an environment variable is recommended
token_ttl: 3600000
token_extractors:
# look for a token as Authorization Header
authorization_header:
enabled: true
prefix: Bearer
name: Authorization
# check token in a cookie
cookie:
enabled: false
name: BEARER
# check token in query string parameter
query_parameter:
enabled: true
name: bearer
nelmio_cors:
paths:
@@ -10,7 +10,7 @@ parameters:
database_port: '5432'
database_name: database
database_user: user
database_password: edcl56
database_password: b|RN:iR<g,TNMqM6
mongodb_server: 'mongodb://tt-website.mongo.dev:27017'
prestashop_key: 9YUQ5jPqT4Z4x5s9B25pb1yuGBtpaeBDxpWDgicPF3CuP8F2p9aK18ZS
prestashop_path: /home/projects/prestashop1/store
@@ -15,9 +15,9 @@ services:
class: AppBundle\Utils\Services\AfterLoginRedirection
arguments: ['@router']
#app.ad_searcher:
# class: AppBundle\Utils\Services\AdSearcher
# arguments: ['@fos_elastica.finder.ads.adfr']
app.ad_searcher:
class: AppBundle\Utils\Services\AdSearcher
arguments: ['@fos_elastica.finder.ads.adfr']
app.ad_tags_searcher:
class: AppBundle\Utils\Services\AdSearcher
@@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputOption;
class SendPushCommand extends ContainerAwareCommand
{
private const defaultEmail = 'thomas.berrod@e-declic.com';
private const defaultEmail = 'lognone.gregoire@hotmail.fr';
protected function configure()
@@ -309,8 +309,8 @@ class AdController extends Controller
} else {
$session->remove('contratSearch');
}
//$adSearcher = $this->get('app.ad_searcher');
$ads = array();//$adSearcher->process($data);
$adSearcher = $this->get('app.ad_searcher');
$ads = $adSearcher->process($data);
if(empty($ads)){
$ads = $this->getPublishedAds($promoted);
$noResults = true;
@@ -5,6 +5,7 @@ namespace AppBundle\Controller\Admin;
use AppBundle\Entity\Company;
use AppBundle\Entity\Product;
use AppBundle\Form\Admin\CompanyAdminType;
use AppBundle\Form\Admin\UserCompanyType;
use AppBundle\Form\TokenAddType;
use Edeclic\PrestashopBridgeBundle\Event\PrestashopBridgeEvents;
use Edeclic\PrestashopBridgeBundle\Event\UserEvent;
@@ -36,14 +37,26 @@ class CompanyController extends Controller
$user = $company->getUsers()->first();
$form = $this->createForm(CompanyAdminType::class, $company);
$form->handleRequest($request);
$formUser = $this->createForm(UserCompanyType::class, $user);
$formUser->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$companyManager = $this->get('app.company_manager');
$companyManager->updateCompany($company);
$event = new UserEvent($user);
$this->get('event_dispatcher')->dispatch(PrestashopBridgeEvents::USER_PROFIL_EDIT_SUCCESS, $event);
}
if ($formUser->isSubmitted() && $formUser->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($user);
$em->flush();
}
return $this->render('admin/company_edit.html.twig', array(
'form' => $form->createView(),
'formUser' => $formUser->createView(),
'company' => $company,
));
}
@@ -327,9 +327,11 @@ class AnswerController extends Controller
if ($answer->getAd() == null) {
$type = 'spontaneous';
$title = $answer->getCompany()->getBrandName();
$aliasCompany = $answer->getCompany()->getAlias();
} else {
$type = 'answer';
$title = $answer->getAd()->getTitle();
$aliasCompany = '';
}
$user = $this->getUser();
$form = $this->createForm(ContactTalentType::class);
@@ -365,6 +367,7 @@ class AnswerController extends Controller
'user' => $answer->getUser(),
'video' => $message->getVideo(),
'message' => $message,
'aliasCompany' => $aliasCompany,
));
$plainView = $this->renderView('email/contact_talent_plain.html.twig', array(
@@ -116,4 +116,21 @@ class AdController extends FOSRestController
['Location' => $this->generateUrl('api_ad_show', ['id' => $ad->getId(), UrlGeneratorInterface::ABSOLUTE_URL])]
);
}
/**
* @Rest\Get("/api/adAjaxRecStat/{id}", name="adAjaxRecStat")
* @Rest\View(statusCode=200)
*/
public function adAjaxRecStatAction(Ad $ad)
{
$history = $this->get('edeclic.history.record');
if ($this->getUser()) {
$idUser = $this->getUser()->getId();
$history->recordIt($idUser, "r", get_class($ad), $ad->getId(), serialize($ad));
} else {
$history->recordIt("Anonymous", "r", get_class($ad), $ad->getId(), serialize($ad));
}
return new JsonResponse(array('code' => "ok"));
}
}
@@ -33,7 +33,7 @@ class AnswerController extends FOSRestController
public function showAction(Answer $answer)
{
$usr = $this->getUser();
$userAnswer = $this->getDoctrine()->getRepository('AppBundle:Answer')->findOneBy(array('user' => $usr, 'id' => $answer->getId()));
$userAnswer = $this->getDoctrine()->getRepository('AppBundle:Answer')->findOneByWithCorrespondences($usr, $answer->getId());
if ($userAnswer) {
$data = $this->get('jms_serializer')->serialize($answer, 'json', SerializationContext::create()->setGroups(array('answer_detail')));
return new JsonResponse($data, 200, [], true);
@@ -248,6 +248,7 @@ class AnswerController extends FOSRestController
*/
public function fetchMessageAction(Answer $answer)
{
$em = $this->getDoctrine()->getManager();
$usr = $this->get('security.token_storage')->getToken()->getUser();
if ($answer->getUser()->getId() !== $usr->getId()) {
@@ -256,7 +257,7 @@ class AnswerController extends FOSRestController
throw new ResourceValidationException($message, $status);
}
$messages = $answer->getMessages();
$messages = $em->getRepository('AppBundle:Message')->searchCorrespondences($answer);
//
$status = array('status' => "success", "messages" => $messages);
//
@@ -16,6 +16,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use JMS\Serializer\SerializationContext;
use Symfony\Component\HttpFoundation\JsonResponse;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class CompanyController extends FOSRestController
{
@@ -93,4 +94,23 @@ class CompanyController extends FOSRestController
Response::HTTP_CREATED,
['Location' => $this->generateUrl('api_company_show', ['id' => $company->getId(), UrlGeneratorInterface::ABSOLUTE_URL])]);
}
/**
* @Rest\Get(path="/api/companyAjaxRecStat/{id}", name="companyAjaxRecStat", requirements={"id"="\d+"})
* @Rest\View(statusCode=200)
*/
public function companyAjaxRecStatAction(Company $company)
{
$history = $this->get('edeclic.history.record');
if ($this->getUser() && $this->getUser()->getCompany() != null) {
if ($this->getUser()->getCompany()->getId() !== $company->getId()) {
$history->recordIt($this->getUser()->getId(), "r", get_class($company), $company->getId(), serialize($company));
}
} else {
$history->recordIt("Anonymous", "r", 'AppBundle\Entity\Company', $company->getId(), serialize($company));
}
return new JsonResponse(array('code' => "ok"));
}
}
@@ -0,0 +1,59 @@
<?php
namespace AppBundle\Controller\Api;
use AppBundle\Entity\User;
use FOS\RestBundle\Controller\Annotations as Rest;
use FOS\RestBundle\Controller\Annotations\Get;
use FOS\RestBundle\Controller\Annotations\Post;
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\Request\ParamFetcherInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use JMS\Serializer\SerializationContext;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpFoundation\Request;
class PushController extends FOSRestController
{
/**
* @Rest\Get("/api/userSubscriptionToPush", name="getUserSubscriptionToPush")
* @Rest\View(statusCode=200)
*/
public function getUserSubscriptionToPush()
{
$user = $this->getUser();
$managerPush = $this->get('app.user_subscription_manager');
$isUserSubscribed = ($managerPush->findByUser($user))? true : false;
return new JsonResponse(array('isUserSubscribed' => $isUserSubscribed));
}
/**
* @Rest\Post("/api/userSubscriptionToPush", name="postUserSubscriptionToPush")
* @Rest\View(statusCode=200)
*/
public function saveSubscription(Request $request)
{
$user = $this->getUser();
$subscription = json_decode($request->getContent(), true);
if (JSON_ERROR_NONE !== json_last_error()) {
throw new BadRequestHttpException(json_last_error_msg());
}
if (!isset($subscription['endpoint'])) {
throw new BadRequestHttpException('Invalid subscription object.');
}
$manager = $this->container->get("app.user_subscription_manager");
$subscriptionHash = $manager->hash($subscription['endpoint']);
$userSubscription = $manager->getUserSubscription($user, $subscriptionHash)
or $userSubscription = $manager->factory($user, $subscriptionHash, $subscription);
$manager->save($userSubscription);
return new JsonResponse(array('success' => true),200);
}
}
@@ -15,6 +15,14 @@ use FOS\UserBundle\Model\UserInterface;
use AppBundle\Entity\Company;
use AppBundle\Exception\ResourceValidationException;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use AppBundle\Form\ContactTalentType;
use AppBundle\Form\MediaType;
use AppBundle\Form\TalentProfileType;
use AppBundle\Form\TalentType;
use AppBundle\Form\CareersType;
use AppBundle\Form\FormationsType;
use AppBundle\Form\LanguagesType;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
class SecurityController extends FOSRestController
{
@@ -107,24 +115,58 @@ class SecurityController extends FOSRestController
*/
public function UpdateUser(Request $request)
{
$userManager = $this->get('fos_user.user_manager');
$companyManager = $this->get('app.company_manager');
$usr = $this->getUser();
$talent = $usr->getCompany();
if ($usr !== null){
$newLastName = htmlspecialchars($request->request->get('lastname'));
$newFirstName = htmlspecialchars($request->request->get('firstname'));
$newLastName = htmlspecialchars($request->get('lastname'));
$newFirstName = htmlspecialchars($request->get('firstname'));
$phoneTalent = htmlspecialchars($request->get('phone'));
$titleTalent = htmlspecialchars($request->get('currentJob'));
$newLinkedin = htmlspecialchars($request->get('linkedin'));
$newTwitter = htmlspecialchars($request->get('twitter'));
$newWebsite = htmlspecialchars($request->get('website'));
if (!isset($newLastName) || !isset($newFirstName) || $newLastName == null || $newFirstName == null){
$message = 'Vous devez rentrer votre nom et votre prénom pour continuer';
throw new ResourceValidationException($message,'');
} else {
$file = $request->files->get('file');
$usr->setLastName($newLastName);
$usr->setFirstName($newFirstName);
$talent->setWebsite($newWebsite);
$talent->setLinkedin($newLinkedin);
$talent->setTwitter($newTwitter);
$talent->setTitleTalent($titleTalent);
$talent->setPhoneTalent($phoneTalent);
$companyManager->updateTalent($usr);
$status = array('status' => "success");
}
} else {
$status = array('status' => "failure", 'message' => "Vous n'êtes pas connecté.");
}
return new JsonResponse($status);
}
/**
* @Rest\post(path="/api/update_profile_picture", name="api_update_profile_picture")
* @Rest\View
*/
public function UpdateProfilPicture(Request $request)
{
$userManager = $this->get('fos_user.user_manager');
$usr = $this->getUser();
if ($usr !== null){
$file = $request->files->get('file');
$usr->setFile($file);
$usr->upload();
$userManager->updateUser($usr);
$status = array('status' => "success", 'file' => $usr->getFile(), 'id' => $usr->getId());
}
$status = array('status' => "success", 'file' => $usr->getPhoto());
} else {
$status = array('status' => "failure", 'message' => "Vous n'êtes pas connecté.");
}
@@ -520,4 +562,25 @@ class SecurityController extends FOSRestController
$data = json_decode($response);
return $data;
}
/**
* @Rest\Get(path="/api/talent", name="api_talent")
* @Rest\View
*/
public function goToMonCompte(Request $request)
{
$user = $this->getUser();
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));
$event = new InteractiveLoginEvent($request, $token);
$this->get("event_dispatcher")->dispatch("security.interactive_login", $event);
$view = $this->redirectView($this->generateUrl('talent_dashboard'), 301);
return $this->handleView($view);
}
}
@@ -187,7 +187,7 @@ class CompanyController extends Controller
$history->recordIt("Anonymous", "r", 'AppBundle\Entity\Company', $company->getId(), serialize($company));
}
return new JsonResponse(array('code' => "ok"));
return new JsonResponse(array('code' => "ok", "user" => $this->getUser()->getUsername()));
}
/***********************
@@ -17,7 +17,7 @@ class DefaultController extends Controller
$ads = $em->getRepository('AppBundle:Ad')->findBy(array("status" => "PUBLISHED", "isPromoted" => false), array('id' => 'DESC'));
}
$talents = $em->getRepository('AppBundle:Company')->findBy(array("type" => "TALENT", "emphasis" => true), array('emphasisOrder' => 'DESC'));
$companies = $em->getRepository('AppBundle:Company')->findBy(array("type" => "COMPANY", "emphasis" => true), array('emphasisOrder' => 'ASC'));
$companies = $em->getRepository('AppBundle:Company')->findBy(array("type" => "COMPANY", "emphasis" => true), array('emphasisOrder' => 'DESC'));
$territories = $em->getRepository('AppBundle:Company')->findBy(array("type" => "TERRITORY", "emphasis" => true), array('emphasisOrder' => 'ASC'));
$arrayTalents = array();
@@ -49,6 +49,7 @@ class PushController extends Controller
return new JsonResponse(array('success' => true),200);
}
/**
* @Route("/push/delete-subscription/", name="delete-subscription")
*/
@@ -160,7 +160,7 @@ class Ad
*
* @ORM\Column(name="public_tag", type="json_document", nullable=true, options={"jsonb":true})
*
*
* @Groups({"ad_detail", "answer_detail"})
*/
private $publicTag;
@@ -249,11 +249,14 @@ class Ad
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\TerritoryAd", mappedBy="ad", cascade={"persist", "remove"})
*
* @Groups({"ad_detail" , "answer_detail"})
*/
private $territories;
/**
* @ORM\OneToMany(targetEntity="AppBundle\Entity\BookmarkAd", mappedBy="ad", cascade={"persist", "remove"})
*
*/
private $bookmarkAds;
@@ -60,7 +60,7 @@ class Company
*
* @ORM\Column(name="brand_name", type="string", length=255, options={"comment":"Nom commercial"}, nullable=true)
*
* @Groups({"ad_detail", "company_list", "company_detail", "answer_list", "answer_detail"})
* @Groups({"ad_detail", "ad_list", "company_list", "company_detail","answer_detail","answer_list"})
*/
private $brandName;
@@ -351,7 +351,7 @@ class Company
if (empty($this->publicTag))
$empty++;
if ($this->presentation_video === null)
if ($this->presentationVideo == null)
$empty++;
if (is_array($this->ad) && empty($this->ad))
@@ -24,26 +24,28 @@ class TerritoryAd
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"company_detail"})
* @Groups({"ad_detail" , "company_detail"})
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Company", inversedBy="territoryAds")
* @ORM\JoinColumn(nullable=false)
* @Groups({"company_detail"})
* @Groups({"ad_detail" , "company_detail"})
*/
private $territory;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Ad", inversedBy="territories")
* @ORM\JoinColumn(nullable=true)
* @Groups({"ad_detail" , "company_detail"})
*/
private $ad;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Company", inversedBy="territoryAds")
* @ORM\JoinColumn(nullable=true)
* @Groups({"ad_detail" , "company_detail"})
*/
private $company;
@@ -229,6 +229,7 @@ class User extends BaseUser
$name = md5(uniqid()) . '.' . $this->file->guessExtension();
$this->file->move($this->getUploadRootDir(), $name);
$this->photo = $name;
}
public function getUploadDir()
@@ -373,7 +374,12 @@ class User extends BaseUser
"lastname" => $this->getLastname(),
"email" => $this->getEmail(),
"picture" => $this->getPhoto(),
"socialPicture" => $this->getSocialPicture()
"socialPicture" => $this->getSocialPicture(),
"phone" => $this->getCompany()->getExtra()["phoneTalent"],
"linkedin" => $this->getCompany()->getExtra()["linkedin"],
"twitter" => $this->getCompany()->getExtra()["twitter"],
"currentJob" => $this->getCompany()->getExtra()["titleTalent"],
"website" => $this->getCompany()->getWebsite(),
);
return $card;
}
@@ -0,0 +1,25 @@
<?php
namespace AppBundle\Form\Admin;
use AppBundle\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class UserCompanyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('email', null, array('required' => true, 'label' => 'Email'));
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => User::class,
));
}
}
@@ -23,8 +23,9 @@ class AdRepository extends AbstractRepository
->createQueryBuilder('a')
->select('a')
->where('a.isVisible = true')
->orderBy('a.title', $order);
->andWhere('a.isPrivate = false')
->orderBy('a.title', $order)
->orderBy('a.publishedAt', 'desc');
$qb
->andWhere('a.isPromoted = ?3')
@@ -25,6 +25,27 @@ class AnswerRepository extends AbstractRepository
return $this->paginate($qb, $limit, $offset);
}
// Query to find messages excluding Draft message and talent video for chat
public function findOneByWithCorrespondences($user, $answerId)
{
$qb = $this
->createQueryBuilder('a')
->select(['a','m','ad'])
->where('a.user = :user')
->andWhere('a.id = :id')
->setParameter('user', $user)
->setParameter('id', $answerId)
->leftJoin('a.messages', 'm','WITH', 'm.status NOT IN(\'DRAFT\',\'CONTACT_TALENT\')')
// ->setParameter(':status', array('DRAFT','CONTACT_TALENT'))
->leftJoin('a.ad', 'ad')
->leftJoin('a.company', 'company')
;
return $qb
->getQuery()
->getResult();
}
public function getAnswerByCompany($id)
{
$qb = $this
@@ -77,21 +77,10 @@ class CompanyRepository extends AbstractRepository
public function search($term, $order = 'asc', $limit = 10, $offset = 1,
$isEmphasis)
{
// $qb = $this
// ->createQueryBuilder('c')
// ->select('c')
// ->leftJoin('c.ads', 'a', 'WITH', 'a.status =:status')
// ->setParameter(':status', "PUBLISHED")
// ->where("c.type = 'COMPANY'")
// ->orWhere('c.presentationVideo IS NOT NULL')
// ->orderBy('a.publishedAt', 'DESC')
// ->orderBy('c.cTime', 'DESC');
$qb = $this->createQueryBuilder('c')
->select('c')
->where("c.type = 'COMPANY'")
->andWhere("c.isPrivate = false")
->leftJoin('c.ads', 'a', 'WITH', 'a.status =:status')
->setParameter(':status', "PUBLISHED")
->orderBy('a.publishedAt', 'DESC')
@@ -10,4 +10,21 @@ namespace AppBundle\Repository;
*/
class MessageRepository extends \Doctrine\ORM\EntityRepository
{
public function searchCorrespondences($answer)
{
$qb = $this
->createQueryBuilder('m')
->select('m')
->where('m.answer = :answer')
->setParameter('answer', $answer)
->andWhere('m.status <> :status')
->setParameter(':status', 'DRAFT')
;
return $qb
->getQuery()
->getResult();
}
}
// add status = SENDED;
@@ -67,18 +67,18 @@ class UserSubscriptionRepository extends \Doctrine\ORM\EntityRepository
) AS decimal) / 15) * 100 ) >= :percent')
->setParameters(array('percent' => $completenessPercentage));
dump($qb->getQuery()->getSql());
//dump($qb->getQuery()->getSql());
$result = $qb->getQuery()->getResult();
dump($result);
//dump($result);
return $result;
}
public function findByTagMatching($tags)
{
dump($tags);
//dump($tags);
$config = $this->_em->getConfiguration();
$config->addCustomNumericFunction('CAST', 'AppBundle\Repository\Query\CastAs');
@@ -96,11 +96,11 @@ class UserSubscriptionRepository extends \Doctrine\ORM\EntityRepository
}
}
dump($qb->getQuery()->getSql());
//dump($qb->getQuery()->getSql());
$result = $qb->getQuery()->getResult();
dump($result);
//dump($result);
return $result;
}
@@ -106,6 +106,7 @@ class RegistrationListener implements EventSubscriberInterface
$company->setType("TALENT");
} elseif ($user->hasRole('ROLE_COMPANY')) {
$company->setType("COMPANY");
$company->setIsPrivate(true);
} elseif ($user->hasRole('ROLE_TERRITORY')) {
$company->setType("TERRITORY");
} else {
@@ -91,6 +91,7 @@ class CompanyManager
'titleTalent' => $talent->getTitleTalent(),
'situationTalent' => $talent->getSituationTalent(),
'descriptionTalent' => $talent->getDescriptionTalent(),
'phoneTalent' => $talent->getPhoneTalent(),
);
$talent->setExtra($extra);
@@ -105,9 +105,9 @@ class NotificationSender implements ContainerAwareInterface
$user = $this->userManager->findUserBy(array('email' => $email));
$output->writeln('$user : ' . $user->getFirstname());
$users = $this->subscriptionManager->getAll();
$subscriptions = $this->subscriptionManager->findByEmails(array($email));
foreach ($users as $subscription) {
foreach ($subscriptions as $subscription) {
$this->sendNotification($output, $subscription);
}
@@ -142,6 +142,8 @@ class NotificationSender implements ContainerAwareInterface
private function sendNotification(OutputInterface $output, $subscription)
{
$output->writeln(' ====== subscription ======');
$output->writeln($subscription->getEndpoint());
!$output->isVerbose()?:$output->writeln('send to user ---> ' . $subscription->getEndpoint());
$this->sender->sendNotification(
@@ -12,7 +12,7 @@ trait ExtraJsonTrait
*
* @ORM\Column(name="extra", type="json_document", nullable=true)
*
* @Groups({"company_detail", "company_list"})
* @Groups({"ad_detail" , "company_detail", "company_list"})
*/
private $extra;
@@ -24,6 +24,7 @@ trait ExtraJsonTrait
private $size;
private $siren;
private $phoneTalent;
private $titleTalent;
private $situationTalent;
private $descriptionTalent;
@@ -41,6 +42,7 @@ trait ExtraJsonTrait
isset($extra['linkedin']) ? $this->linkedin = $extra['linkedin'] : null;
isset($extra['size']) ? $this->size = $extra['size'] : null;
isset($extra['siren']) ? $this->siren = $extra['siren'] : null;
isset($extra['phoneTalent']) ? $this->phoneTalent = $extra['phoneTalent'] : null;
isset($extra['titleTalent']) ? $this->titleTalent = $extra['titleTalent'] : null;
isset($extra['situationTalent']) ? $this->situationTalent = $extra['situationTalent'] : null;
isset($extra['descriptionTalent']) ? $this->descriptionTalent = $extra['descriptionTalent'] : null;
@@ -115,6 +117,18 @@ trait ExtraJsonTrait
return $this->siren;
}
public function setPhoneTalent($phoneTalent)
{
$this->phoneTalent = $phoneTalent;
return $this;
}
public function getPhoneTalent()
{
return $this->phoneTalent;
}
public function setTitleTalent($titleTalent)
{
$this->titleTalent = $titleTalent;
+3 -2
View File
@@ -745,7 +745,8 @@ EdeclicLib = window.EdeclicLib || {},
navigator.serviceWorker.addEventListener('message', event => {
var toastHTML = '<div class="card white horizontal"><div class="card-image">' +
var toastHTML =
'<div class="card white horizontal"><div class="card-image">' +
'<img style="max-height:100px;" src="' +
event.data.image + '"></div><div class="card-stacked"><div class="card-content dark-text">' +
'<span class="card-title dark-text">' +
@@ -759,5 +760,5 @@ EdeclicLib = window.EdeclicLib || {},
'</div></div></div>'
Materialize.toast(toastHTML, 10000000);
});
}(jQuery)
File diff suppressed because one or more lines are too long
+337 -1
View File
@@ -4610,4 +4610,340 @@ $("#profile_picture_file, #profile_logo_file").change(function () {
}
}
}
});
});
EdeclicLib = window.EdeclicLib || {},
function (d) {
"use strict";
d.extend(EdeclicLib, {
/* GESTION des cookies pour la modal du tuto */
setCookie: function (name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
},
getCookie: function (name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
},
eraseCookie: function (name) {
document.cookie = name + '=; Max-Age=-99999999;';
}
})
}(jQuery);
/// EdeclicPushAndNotificationClient.js
/// A push and notification client
/// inspired by https://github.com/gauntface/web-push-book
///
EdeclicLib = window.EdeclicLib || {},
function (d) {
"use strict";
d.extend(EdeclicLib, {
askForNotifications: function (resolve, reject) {
var publicKey, saveUrl, deleteUrl, serviceWorkerUrl;
if (!IsFeatureDetected()) {
//alert feature unavailable
alert("Votre navigateur ne permet pas d'envoyer des push.");
reject();
return;
}
var conf = document.getElementById('pushParams');
if (conf === null) {
console.warn('The pushParams div is not found. can\'t get datadash config.');
reject();
return;
}
publicKey = conf.dataset.pushPublicKey;
saveUrl = conf.dataset.saveSubscriptionUrl;
deleteUrl = conf.dataset.deleteSubscriptionUrl;
serviceWorkerUrl = conf.dataset.serviceWorkerUrl;
return Promise.all([
registerServiceWorker(),
getNotificationPermissionState()
])
.then(function (results) {
const registration = results[0];
const currentPermissionState = results[1];
if (currentPermissionState === 'denied') {
console.warn('The notification permission has been blocked. Nothing we can do.');
alert("Les notifications sont désactivés, veuillez modifier vos paramètres pour bénéficier de cette fonctionnalité.");
reject();
return;
}
let promiseChain = Promise.resolve();
if (currentPermissionState !== 'granted') {
promiseChain = askPermission();
}
promiseChain
.then(subscribeUserToPush)
.then(function (subscription) {
if (subscription) {
return sendSubscriptionToBackEnd(subscription)
.then(function () {
return subscription;
});
}
return subscription;
})
.then(function (subscription) {
// We got a subscription AND it was sent to our backend,
// re-enable our UI and set up state.
console.log('SUBSCRIPTION', subscription);
resolve();
return;
})
.catch(function (err) {
console.error('Failed to subscribe the user.', err);
reject();
return;
});
// if (currentPermissionState !== 'granted') {
// // If permission isn't granted then we can't be subscribed for Push.
// console.log("permission isn't granted then we can't be subscribed for Push.");
// return;
// }
},
reject
).catch(function (err) {
console.log('Unable to register the service worker: ' + err);
reject();
return;
});
function IsFeatureDetected() {
if (!('serviceWorker' in navigator)) {
// Service Worker isn't supported on this browser, disable or hide UI.
console.info("Service Worker isn't supported on this browser, disable or hide UI.");
return false;
}
if (!('PushManager' in window)) {
// Push isn't supported on this browser, disable or hide UI.
console.info("Push isn't supported on this browser, disable or hide UI.");
return false;
}
console.info("Push and serviceWorker supported on this browser.");
return true;
}
//https://stackoverflow.com/questions/39136625/service-worker-registration-failed
function registerServiceWorker() {
console.log('registerServiceWorker');
return navigator.serviceWorker.register(serviceWorkerUrl)
.then(function (registration) {
console.log('Service worker successfully registered.');
registration.update();
return registration;
})
.catch(function (err) {
console.error('Unable to register service worker.', err);
});
}
function askPermission() {
return new Promise(function (resolve, reject) {
const permissionResult = Notification.requestPermission(function (result) {
resolve(result);
});
if (permissionResult) {
permissionResult.then(resolve, reject);
}
})
.then(function (permissionResult) {
if (permissionResult !== 'granted') {
throw new Error('We weren\'t granted permission.');
}
});
}
function getNotificationPermissionState() {
if (navigator.permissions) {
return navigator.permissions.query({ name: 'notifications' })
.then((result) => {
return result.state;
});
}
return new Promise((resolve) => {
resolve(Notification.permission);
});
}
function getSWRegistration() {
return navigator.serviceWorker.register(serviceWorkerUrl);
}
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 subscribeUserToPush() {
getSWRegistration();
return navigator.serviceWorker.ready.then(function (registration) {
const subscribeOptions = {
// At the moment you must pass in a value of true. If you dont include the
// userVisibleOnly key or pass in false youll get the following error:
// 9
// Chrome currently only supports the Push API for subscriptions that
// will result in user-visible messages. You can indicate this by calling
// pushManager.subscribe({userVisibleOnly: true}) instead.
// See https://goo.gl/yqv4Q4 for more details.
userVisibleOnly: true,
applicationServerKey: urlBase64ToUint8Array(
publicKey)
};
return registration.pushManager.subscribe(subscribeOptions);
})
.then(function (pushSubscription) {
return pushSubscription;
});
}
function sendSubscriptionToBackEnd(subscription) {
return fetch(saveUrl, {
method: 'POST',
//edge requirements
credentials: "same-origin",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(subscription)
})
.then(function (response) {
if (!response.ok) {
throw new Error('Bad status code from server.');
}
return response.json();
})
.then(function (responseData) {
if (!(responseData && responseData.success)) {
throw new Error('Bad response from server.');
}
});
}
},
delayedAsk: function () {
var pushTrigger = EdeclicLib.getCookie("pushTrigger") * 1;
if (pushTrigger == 3) {
new Promise(EdeclicLib.askForNotifications)
.then(() =>Materialize.toast("Vous êtes bien enregistré aux alertes.", 5000));
}
if (pushTrigger <= 3) {
EdeclicLib.setCookie("pushTrigger", pushTrigger + 1);
}
},
unsubscribe: function () {
navigator.serviceWorker.ready
.then((serviceWorkerRegistration) => {
serviceWorkerRegistration.pushManager.getSubscription()
.then((subscription) => {
if (!subscription) {
console.log("Not subscribed, nothing to do.");
return;
}
subscription.unsubscribe()
.then(function () {
console.log("Successfully unsubscribed!.");
})
.catch((e) => {
logger.error('Error thrown while unsubscribing from push messaging', e);
});
});
});
},
unsubscribeUserFromPush: function () {
return registration.pushManager.getSubscription()
.then(function (subscription) {
if (subscription) {
return subscription.unsubscribe();
}
})
.then(function () {
return fetch(deleteUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(subscription)
})
.then(function (response) {
if (!response.ok) {
throw new Error('Bad status code from server.');
}
///TODO bind UI
return true;
})
})
.catch(function (err) {
console.error('Failed to unsubscribe the user.', err);
getNotificationPermissionState()
.then((permissionState) => {
// pushCheckbox.disabled = permissionState === 'denied';
// pushCheckbox.checked = false;
});
});
}
});
navigator.serviceWorker.addEventListener('message', event => {
var toastHTML =
'<div class="card white horizontal"><div class="card-image">' +
'<img style="max-height:100px;" src="' +
event.data.image + '"></div><div class="card-stacked"><div class="card-content dark-text">' +
'<span class="card-title dark-text">' +
event.data.title +
'</span>' +
'<p>' +
event.data.body +
'</p>' +
'</div><div class="card-action right-align">' +
'<a href="' + event.data.data.link + '">Voir</a>' +
'</div></div></div>'
Materialize.toast(toastHTML, 10000000);
});
}(jQuery)
+2
View File
@@ -2912,3 +2912,5 @@ a.link-white-underline {
/*Modules
---------------------------------------------------*/
/*# sourceMappingURL=admin.css.map */
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,9 +1,7 @@
{
"parameters": {
"pushType": "tags",
"keywords": "surf;voile",
"profilCompletenessPercentage": "10",
"users": "thomas.berrod@e-declic.com;thomas.berrod@e-declic.com;thomas.berrod@e-declic.com"
"keywords": "trytodev"
},
"notification": {
"title": "Coriolis composites",
@@ -12,7 +10,7 @@
"image": "https://i.vimeocdn.com/video/668043830.webp?mw=1100&mh=619&q=70",
"tag": "open-window",
"data": {
"link": "http://localhost/app_dev.php/annonce/7-composites-studies-engineer"
"link": "http://localhost/annonce/7-composites-studies-engineer"
}
}
}
@@ -1,7 +1,7 @@
{
"parameters": {
"pushType": "tags",
"keywords": "surf;voile"
"keywords": "trytodev"
},
"notification": {
"title": "D'après vous",
@@ -20,7 +20,7 @@ $grey6 : #999CA2;
$grey7 : #1E2327;
$orange: #ff9800;
$orangeNewApp: #ffe600;
$orangeNewApp: #FFCE00;
$font-1: 'Raleway', sans-serif;
$font-2: "Varela Round", sans-serif;
@@ -121,7 +121,7 @@
.fix-search{
position: fixed;
top: 60px;
top: 89px;
width: 100%;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;