Compare commits
52 Commits
feat/push
...
f4e412d792
| Author | SHA1 | Date | |
|---|---|---|---|
| f4e412d792 | |||
| 61786797c8 | |||
| 57587a4a97 | |||
| fd048d5a0e | |||
| 229893dc95 | |||
| 26c6e2103d | |||
| 8830b5ccde | |||
| 2bc2d87b8c | |||
| 278c558c9e | |||
| 98545707b3 | |||
| 52d105efb4 | |||
| 027c3fd2d1 | |||
| 824ff9f1ec | |||
| 606e29280b | |||
| 3a29c647dd | |||
| 57dd053693 | |||
| e57173f835 | |||
| 8f4ef35ddf | |||
| 346b788f83 | |||
| edf35c74e8 | |||
| 75f2bbf6a7 | |||
| 0cbe670c90 | |||
| 2d595c1c3a | |||
| 98ebde7e72 | |||
| d607962523 | |||
| b4ae35f4a6 | |||
| be37e97a19 | |||
| d21febaaa1 | |||
| 6acba9c082 | |||
| 65147a9ac6 | |||
| a366ed749e | |||
| 87f6956958 | |||
| 3a78ac68f2 | |||
| 39774c1ed9 | |||
| bd477b3354 | |||
| 86e33a5e0a | |||
| 365c71751d | |||
| 46399bd8ed | |||
| c3a8fa73cd | |||
| fe7c9992a5 | |||
| 1922ab328b | |||
| a91f2df040 | |||
| 1a4e81963e | |||
| 5ae61ff2c7 | |||
| 995bb0b43e | |||
| 4c841aaafa | |||
| 49abf8d86f | |||
| e3ca74f09b | |||
| 6818e82c92 | |||
| 2ea95f529e | |||
| 6cec286886 | |||
| f38d22d70d |
@@ -25,12 +25,12 @@ else
|
||||
DC=ENV=$(ENV) CLIENT=$(CLIENT) "$(DOCKERCOMPOSE)" --project-name "$(CLIENT)_$(ENV)" --file conf/docker-compose.win.yml $(DC_OVERRIDE) $(DC_OVERRIDE_ENV)
|
||||
endif
|
||||
|
||||
|
||||
default:
|
||||
$(info $(USAGE))
|
||||
$(error Exiting)
|
||||
|
||||
docker-build:
|
||||
$(DC) pull
|
||||
$(DC) build
|
||||
$(DC) up -d
|
||||
|
||||
@@ -64,8 +64,8 @@ config:
|
||||
|
||||
@echo " --> Generating mysql auth file"
|
||||
@cat conf/env/store-mysql.env \
|
||||
| python -c "import sys; import string; v=sys.stdin.readline().split('MYSQL_ROOT_PASSWORD=')[1]; print(string.Template(open('conf/build/mysql/my.cnf').read()).substitute({'PASSWORD':v}))" \
|
||||
| docker exec -i $(CLIENT).store-mysql.$(ENV) sh -c 'cat > /root/.my.cnf'
|
||||
| python -c "import sys; import string; v=sys.stdin.readline().split('MYSQL_ROOT_PASSWORD=')[1]; print(string.Template(open('conf/build/mysql/my.cnf').read()).substitute({'PASSWORD':v}))" \
|
||||
| docker exec -i $(CLIENT).store-mysql.$(ENV) sh -c 'cat > /root/.my.cnf'
|
||||
|
||||
db-backup-all: db-backup-website db-backup-store
|
||||
|
||||
@@ -83,6 +83,11 @@ db-backup-store:
|
||||
|
||||
db-restore-all: db-restore-website db-restore-store
|
||||
|
||||
db-backup-script:
|
||||
@mkdir -p backup/
|
||||
@docker exec $(CLIENT).postgres.$(ENV) pg_dumpall --database database -c -U postgres > backup/postgres_$(ENV)_`date +%d-%m-%Y"_"%H_%M_%S`.sql
|
||||
@docker exec $(CLIENT).store-mysql.$(ENV) mysqldump -uroot database > backup/store-mysql_$(ENV)_`date +%d-%m-%Y"_"%H_%M_%S`.sql
|
||||
|
||||
db-restore-website:
|
||||
@echo "Restoring file to database (backup/postgres.sql)"
|
||||
@cat backup/postgres.sql | docker exec -i $(CLIENT).postgres.$(ENV) psql --dbname database -U user
|
||||
@@ -114,4 +119,4 @@ es-populate:
|
||||
|
||||
sys:
|
||||
@echo $(SYS)
|
||||
@echo $(DC)
|
||||
@echo $(DC)
|
||||
|
||||
+27
-26
@@ -1,53 +1,54 @@
|
||||
FROM php:7.1-fpm
|
||||
FROM php:7.1-fpm-buster
|
||||
|
||||
ENV TERM=xterm
|
||||
|
||||
RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main" > /etc/apt/sources.list.d/debian-backports.list
|
||||
#RUN printf "deb http://archive.debian.org/debian/ jessie main\ndeb-src http://archive.debian.org/debian/ jessie main\ndeb http://security.debian.org jessie/updates main\ndeb-src http://security.debian.org jessie/updates main\ndeb http://archive.debian.org/debian/ jessie-backports main" > /etc/apt/sources.list.d/debian-backports.list
|
||||
|
||||
RUN apt-get clean \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y lsof nano less git locales
|
||||
&& apt-get update \
|
||||
&& apt-get install -y lsof nano less git locales
|
||||
|
||||
RUN echo 'fr_FR.UTF-8 UTF-8' > /etc/locale.gen \
|
||||
&& /usr/sbin/locale-gen
|
||||
&& /usr/sbin/locale-gen
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get -y install libgmp-dev \
|
||||
&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/local/include/gmp.h \
|
||||
&& docker-php-ext-install gmp \
|
||||
&& docker-php-ext-configure gmp
|
||||
&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/local/include/gmp.h \
|
||||
&& docker-php-ext-install gmp \
|
||||
&& docker-php-ext-configure gmp
|
||||
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y ffmpeg exiftool graphviz libfreetype6-dev libjpeg62-turbo-dev libpng-dev libmcrypt-dev libxslt-dev libicu-dev libxml2-dev libpq-dev libgeoip-dev libedit-dev mysql-client nodejs npm \
|
||||
&& 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 \
|
||||
&& pecl install geoip-1.1.1 redis imagick mongodb \
|
||||
&& docker-php-ext-enable geoip redis imagick mongodb
|
||||
&& apt-get install -y ffmpeg exiftool graphviz libfreetype6-dev libjpeg62-turbo-dev libpng-dev libmcrypt-dev libxslt-dev libicu-dev libxml2-dev libpq-dev libgeoip-dev libedit-dev mariadb-client nodejs npm \
|
||||
&& 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 \
|
||||
&& pecl install geoip-1.1.1 redis imagick mongodb \
|
||||
&& docker-php-ext-enable geoip redis imagick mongodb
|
||||
|
||||
RUN { \
|
||||
echo 'opcache.memory_consumption=128'; \
|
||||
echo 'opcache.interned_strings_buffer=8'; \
|
||||
echo 'opcache.max_accelerated_files=4000'; \
|
||||
echo 'opcache.revalidate_freq=60'; \
|
||||
echo 'opcache.fast_shutdown=1'; \
|
||||
echo 'opcache.enable_cli=1'; \
|
||||
} >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
|
||||
echo 'opcache.memory_consumption=128'; \
|
||||
echo 'opcache.interned_strings_buffer=8'; \
|
||||
echo 'opcache.max_accelerated_files=4000'; \
|
||||
echo 'opcache.revalidate_freq=60'; \
|
||||
echo 'opcache.fast_shutdown=1'; \
|
||||
echo 'opcache.enable_cli=1'; \
|
||||
} >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
|
||||
|
||||
COPY zz-logformat.conf /usr/local/etc/php-fpm.d/
|
||||
COPY php.ini /usr/local/etc/php/conf.d/
|
||||
|
||||
RUN (curl --silent --show-error https://getcomposer.org/installer | php) \
|
||||
&& mv composer.phar /usr/local/bin/composer
|
||||
&& mv composer.phar /usr/local/bin/composer
|
||||
|
||||
RUN curl --location --silent --show-error https://symfony.com/installer -o /usr/local/bin/symfony \
|
||||
&& chmod a+x /usr/local/bin/symfony
|
||||
&& chmod a+x /usr/local/bin/symfony
|
||||
|
||||
RUN curl --location --silent --show-error https://s3.amazonaws.com/files.drush.org/drush.phar -o /usr/local/bin/drush \
|
||||
&& chmod a+x /usr/local/bin/drush
|
||||
&& chmod a+x /usr/local/bin/drush
|
||||
|
||||
RUN (npm install -g uglify-es) \
|
||||
&& ln -s /usr/bin/nodejs /usr/local/bin/node
|
||||
&& ln -s /usr/bin/nodejs /usr/local/bin/node
|
||||
|
||||
RUN apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
&& rm -rf /var/lib/apt/lists/
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
{#<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>#}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</div>
|
||||
<div class="header-video-inner">
|
||||
<video loop="" preload="metadata" autoplay="" id="vid" muted="muted">
|
||||
{# <source src="/img/home_video.mp4" type="video/mp4"> #}
|
||||
<source src="/img/home_video.mp4" type="video/mp4">
|
||||
</video>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
fos_elastica:
|
||||
clients:
|
||||
default: { host: %elastic_host%, port: %elastic_port% }
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
indexes:
|
||||
tags:
|
||||
types:
|
||||
@@ -143,4 +141,4 @@ fos_elastica:
|
||||
model: AppBundle\Entity\User
|
||||
provider: ~
|
||||
finder: ~
|
||||
>>>>>>> origin/master
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,8 +8,8 @@ parameters:
|
||||
database_port: '5432'
|
||||
database_name: database
|
||||
database_user: user
|
||||
#database_password: 7C|Uk2B[.>"6{QO{
|
||||
database_password: b|RN:iR<g,TNMqM6
|
||||
database_password: 7C|Uk2B[.>"6{QO{
|
||||
#database_password: b|RN:iR<g,TNMqM6
|
||||
#Mongo
|
||||
mongodb_server: "mongodb://tt-website.mongo.preprod:27017"
|
||||
#Prestashop
|
||||
|
||||
@@ -36,6 +36,6 @@ parameters:
|
||||
service_mail_subject: 'mailto:looping@talentstube.com'
|
||||
ttl: 300
|
||||
urgency: high
|
||||
topic: Emploi
|
||||
topic: Emploi
|
||||
push_params.public_key: BG2lV673DvB67dzEwX9GKfds3sXaEdtZo2oWO1cO2xUdTJAFZ_rV_UrP1nHQz-F8LJNO9HxG0kmQRIb54JL1ZCA
|
||||
|
||||
|
||||
@@ -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,32 @@
|
||||
<?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;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,10 @@ use FOS\UserBundle\Event\GetResponseUserEvent;
|
||||
use FOS\UserBundle\Model\UserInterface;
|
||||
use AppBundle\Entity\Company;
|
||||
use AppBundle\Exception\ResourceValidationException;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||
|
||||
class SecurityController extends FOSRestController
|
||||
{
|
||||
|
||||
/**
|
||||
* @Rest\Post(path="/api/confirmAccount", name="api_confirm_account")
|
||||
* @Rest\View
|
||||
@@ -107,24 +107,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é.");
|
||||
}
|
||||
@@ -207,6 +241,7 @@ class SecurityController extends FOSRestController
|
||||
// https://graph.facebook.com/debug_token?
|
||||
// input_token=EAAhJAcmfVSoBAFESNEQPJFv4fOqY5G6pSUwU3BOVzmhfoP9DTu827RUelrUQHFJshZBHsHZAlZA22MvfZArsZAlJBvZBWgbuJAJQjbMcgr9dwtHZBWZCI61nsvSBbsjiA8RgonGu0zcMD8GZCJDoZA26fZAgmURRgJUprfZCOvEzZBFgfUo1UjIHhiqey&access_token=2332071840142634|afb8bbca72bd8c517c64f81e998e4f12
|
||||
|
||||
//TODO: à mettre en config
|
||||
$req = 'https://graph.facebook.com/debug_token?input_token=' . ($token) . '&access_token=1800752833559014|454de729b1e58f506f94c8b50ca5c011';//PROD PREPROD
|
||||
//'&access_token=2332071840142634|afb8bbca72bd8c517c64f81e998e4f12'; //DEV
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -6,16 +6,15 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use FOS\UserBundle\Model\User as BaseUser;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
<<<<<<< HEAD
|
||||
|
||||
use JMS\Serializer\Annotation\ExclusionPolicy;
|
||||
use JMS\Serializer\Annotation\Expose;
|
||||
use Hateoas\Configuration\Annotation as Hateoas;
|
||||
use JMS\Serializer\Annotation\Groups;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
=======
|
||||
use AppBundle\Utils\Traits\CareerJsonTrait;
|
||||
>>>>>>> origin/master
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
|
||||
* @ORM\Table(name="fos_user")
|
||||
@@ -230,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()
|
||||
|
||||
@@ -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;
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
../doctrine/dbal/bin/doctrine-dbal
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
XSym
|
||||
0028
|
||||
6ad9c04ba34037260849b181387a137a
|
||||
../doctrine/orm/bin/doctrine
|
||||
|
||||
0034
|
||||
9c0044dbf9d81c454fd8aeca68e706da
|
||||
../doctrine/dbal/bin/doctrine-dbal
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
XSym
|
||||
0044
|
||||
2a11eaeab3acf944b97bb7a15e6c72bf
|
||||
../symfony/phpunit-bridge/bin/simple-phpunit
|
||||
|
||||
@@ -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
File diff suppressed because one or more lines are too long
@@ -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 don’t include the
|
||||
// userVisibleOnly key or pass in false you’ll 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)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -121,7 +121,7 @@
|
||||
|
||||
.fix-search{
|
||||
position: fixed;
|
||||
top: 89px;
|
||||
top: 60px;
|
||||
width: 100%;
|
||||
-webkit-transition: all 0.5s;
|
||||
-moz-transition: all 0.5s;
|
||||
|
||||
Reference in New Issue
Block a user