Skip to content

Commit

Permalink
Symfony backend compatibility (#2)
Browse files Browse the repository at this point in the history
* Replace PATCH by POST in order to fix issue with PHP PUT/PATCH management

* comment date creation (server responsibility)

* add api services and models

* Update UI

* Add current user to app header

* Existing components and services refactoring

* Add logout and update app logo

* Lint

* Fix import example feature

* Fix api deletion

* Prevent session loss

* Move API settings to environment file

* Fix token expiry check

* Add token expiry date format to env settings

* Fix evaluation status label

* Fix http query params format

* [CI] Add some Basic LiCi tools (#3) (#4)

* limit unnecessary requests and fix issues in entry-content/*

* fix summary component

* Remove unused component

* Add role based authorization

* reduce the number of request during evaluation and validation

* Fix attachment download

* fix Pia import and date manipulation

* add Pia progress computation in CardsComponent::refreshContent()

* call sortPia after import

* fix issue when evaluation* is undefiend in action-plan.service

* [CI] Add env management with etcd and confd

* [CI] Add explicit version of etcd api

* [CI] Add some ci-script to automate various process

* Fix summary component
  • Loading branch information
RomainSanchez authored May 11, 2018
1 parent 42b89d5 commit c15f8c0
Show file tree
Hide file tree
Showing 130 changed files with 5,162 additions and 3,265 deletions.
1 change: 1 addition & 0 deletions .angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"styles.scss"
],
"scripts": [
"../node_modules/save-svg-as-png/saveSvgAsPng.js",
"../node_modules/tinymce/tinymce.js",
"../node_modules/tinymce/themes/modern/theme.js",
"../node_modules/tinymce/plugins/lists/plugin.js",
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Pia
# Le logiciel PIA / The PIA Software
<img src="https://raw.githubusercontent.com/LINCnil/pia/develop/src/assets/images/pia-auth-logo.png" align="left" hspace="10" vspace="6"> Le logiciel PIA est un outil distribué librement par la [CNIL](https://www.cnil.fr/fr/outil-pia-telechargez-et-installez-le-logiciel-de-la-cnil) afin de faciliter la réalisation d’analyses d’impact sur la protection des données prévues par le RGPD.
Version web front office de l’application PIA à déployer sur un serveur afin d’en donner l’accès via un navigateur web. Ce projet est généré avec [Angular CLI](https://github.com/angular/angular-cli).

The PIA software is a free tool published by the [CNIL](https://www.cnil.fr/en/open-source-pia-software-helps-carry-out-data-protection-impact-assesment) which aims to help data controllers build and demonstrate compliance to the GDPR.
Front office of the PIA application to be deployed on a server in order to access it through a web browser. This project was generated with [Angular CLI](https://github.com/angular/angular-cli).

This project was generated with [Angular CLI](https://github.com/angular/angular-cli).

## Development server

Expand All @@ -13,7 +17,12 @@ Run `ng generate component component-name` to generate a new component. You can
## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
Use `ng build --prod --build-optimizer --sourcemaps` for a production build.

## Build for production

First you need to rename the file `src/environments/environment.prod.ts.example` to `src/environments/environment.prod.ts`.
Then set the version number inside this file.
And use the command `ng build --prod --build-optimizer --sourcemaps` for a production build.

## Running unit tests

Expand All @@ -24,6 +33,10 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.

## Run in production mode
Run `ng build --prod`
Put `dist/` directory which is generated by ng build into your `www/` directory (like /var/www/html for default in Apache)

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
14 changes: 14 additions & 0 deletions bin/ci-scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
set -ex

if [ -f ${NVM_DIR}/nvm.sh ]
then
. ${NVM_DIR}/nvm.sh
else
echo "NVM_DIR have to be set"
exit 42
fi

# todo : add build option env variable
ng build

29 changes: 29 additions & 0 deletions bin/ci-scripts/gen_archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -ex

Name=Pialab-front

if [ -z ${Branch} ]
then
Branch=$(git name-rev --name-only $(git rev-parse HEAD) | sed -e s/\\^.*//g | awk -F'/' '{print $(NF)}')
fi

# Clean current git dir
git clean -df
git checkout -- .

Filename=${Name}_${Branch}.tar.gz

rm -f ${Filename}

rm -rf \
*.log \
*.nbr \
*.dist

tar --exclude-vcs \
--exclude=build \
--exclude=bin/git-scripts \
-czhf ${Filename} ./*

sha256sum ${Filename} > ${Filename}.sha256.txt
13 changes: 13 additions & 0 deletions bin/ci-scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -ex

if [ -f ${NVM_DIR}/nvm.sh ]
then
. ${NVM_DIR}/nvm.sh
else
echo "NVM_DIR have to be set"
exit 42
fi


npm install --no-interaction
6 changes: 6 additions & 0 deletions bin/ci-scripts/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -ex


echo "waiting for test creation"

56 changes: 56 additions & 0 deletions bin/ci-scripts/set_env_with_etcd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
set -ex

export ETCDCTL_API=3

# rand number to avoid build colision (same db used by two build)
if [ ! -f shuf.nbr ]
then
shuf -i 200-600 -n 1 > shuf.nbr
fi

if [ -z "$Suffix" ]
then
#RND may contain branch with '-' or upper case char which may not work as database name for postgre
Suffix=$(echo $RND|sed -e s/-/_/g|tr '[:upper:]' '[:lower:]')$(echo -n $(cat shuf.nbr ))
fi

if [ -z "$Prefix" ]
then
Prefix="/pialab/build/$Suffix"
fi

if [ -z "$ETCDHOST" ]
then
ETCDHOST="etcd.host"
fi
ETCDENDPOINT="--endpoints=http://${ETCDHOST}:2379"

if [ -z "$ETCDCTLCMD" ]
then
ETCDCTLCMD="etcdctl"
fi

if [ -z "${APICLIENTID}" ]
then
APICLIENTID=1234
fi

if [ -z "${APICLIENTSECRET}" ]
then
APICLIENTSECRET=4321
fi

if [ -z "${BACKURL}" ]
then
BACKURL='http://localhost:8000'
fi

# todo add env management (prod and dev)

$ETCDCTLCMD put $Prefix/api/client/id ${APICLIENTID} $ETCDENDPOINT
$ETCDCTLCMD put $Prefix/api/client/secret ${APICLIENTSECRET} $ETCDENDPOINT
$ETCDCTLCMD put $Prefix/api/host/url ${BACKURL} $ETCDENDPOINT

confd -onetime -backend etcdv3 -node http://${ETCDHOST}:2379 -confdir ./etc/confd -log-level debug -prefix $Prefix
cat src/environments/environment.ts
8 changes: 8 additions & 0 deletions etc/confd/conf.d/environment.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[template]
src = "environment.ts.tmpl"
dest = "src/environments/environment.ts"
keys = [
"/api/client/id",
"/api/client/secret",
"/api/host/url",
]
14 changes: 14 additions & 0 deletions etc/confd/templates/environment.ts.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

export const environment = {
name: 'development',
production: false,
version: 'DEV',
rollbar_key: '',
date_format: 'DD MM YY HH:mm:ss',
api: {
client_id: '{{getv "/api/client/id"}}',
client_secret: '{{getv "/api/client/secret"}}',
host: '{{getv "/api/host/url"}}',
token_path: '/oauth/v2/token'
},
};
42 changes: 42 additions & 0 deletions etc/dockerfile.jenkins
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM debian:stable

RUN apt-get update && apt-get install --no-install-recommends -y apt-transport-https lsb-release ca-certificates net-tools lsof postgresql-client wget \
&& apt-get install --no-install-recommends -y git curl build-essential unzip python-pip python-setuptools \
&& apt-get install --no-install-recommends -y dnsutils vim-nox\
&& apt-get autoremove -y && apt-get clean

ENV HOME=/home/jenkins
ENV USER=jenkins
ENV GROUP=users

ARG UID
ARG GID
RUN useradd -d $HOME -g ${GID} -u ${UID} -m $USER -s /bin/bash \
&& mkdir -p $HOME/bin \
&& chown -R $USER:$GROUP $HOME

ARG ETCDVER=3.3.1
RUN wget -q https://github.com/coreos/etcd/releases/download/v${ETCDVER}/etcd-v${ETCDVER}-linux-amd64.tar.gz -O /tmp/etcd.tar.gz \
&& tar -xzf /tmp/etcd.tar.gz -C /tmp \
&& mv /tmp/etcd-v${ETCDVER}-linux-amd64/etcd* /usr/local/bin/ \
&& chmod 755 /usr/local/bin/etcd* \
&& rm -rf /tmp/etcd*

ARG CONFDVER=0.15.0
RUN wget -q https://github.com/kelseyhightower/confd/releases/download/v${CONFDVER}/confd-${CONFDVER}-linux-amd64 -O /usr/local/bin/confd \
&& chmod 755 /usr/local/bin/confd \
&& mkdir -p /etc/confd/conf.d \
&& mkdir -p /etc/confd/templates

USER $USER:$GROUP
WORKDIR $HOME

ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin/:$HOME/bin:$HOME/.local/bin/

ENV NVM_DIR="$HOME/.nvm"
RUN curl -so- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash \
&& [ -s "$NVM_DIR/nvm.sh" ] \
&& . "$NVM_DIR/nvm.sh" \
&& nvm install 8.11.1 \
&& npm install -g @angular/cli

71 changes: 71 additions & 0 deletions etc/pipeline.jenkins
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
pipeline {
agent {
dockerfile {
filename "etc/dockerfile.jenkins"
additionalBuildArgs '--build-arg UID=$(id -u) --build-arg GID=$(id -g)'
args '--network=ci.network'
}
}

environment {
NVM_DIR="/home/jenkins/.nvm"
ETCDHOST="etcd.host"
/* warnings, can't use "$HOME/.nvm" as it is not the same in docker and host ... */
}

options {
timeout(time: 1, unit: 'HOURS')
timestamps()
disableConcurrentBuilds()
ansiColor('xterm')
}

stages {
stage ('Where Am I') {
steps {
sh "uname -a"
sh ". ${env.NVM_DIR}/nvm.sh && npm -v"
sh ". ${env.NVM_DIR}/nvm.sh && node -v"
}
}

stage ('Set Env') {
steps {
sh "./bin/ci-scripts/set_env_with_etcd.sh"
}
}

stage ('Composer Install') {
steps {
sh "./bin/ci-scripts/install.sh"
}
}

stage ('Build Project') {
steps {
sh "./bin/ci-scripts/build.sh"
}
}

stage ('Run Test') {
steps {
sh "./bin/ci-scripts/run_test.sh"
}
}

stage ('Create Archive') {
steps {
sh 'Branch=${BRANCH_NAME} ./bin/ci-scripts/gen_archive.sh'
archiveArtifacts artifacts: "*.tar.gz*", fingerprint: true
build job: 'Copy Artifact', parameters: [string(name: 'Job', value: "${JOB_NAME}"), string(name: 'Project', value: "Pialab"), string(name: 'Branch', value: "${BRANCH_NAME}"), string(name: 'DoDeploy', value: "false")], wait: false
}
}

}

post {
always {
cleanWs()
}
}
}
Loading

0 comments on commit c15f8c0

Please sign in to comment.