Skip to content

Commit

Permalink
feat(play): add crafted examples (#132)
Browse files Browse the repository at this point in the history
* fix(play): load script synchronously

* perf(play): will this improve loading perf ?

* style(play): prettify html code

* feat(play): add examples links

* feat(play): create examples

* feat(play): fix NIR example

* feat(play): fix examples links

* feat(play): add SIRET generation example

* feat(play): add anonymization by suppression ex.

* feat(play): add anonymize technical ID

* feat(play): fix typo

* feat(play): add noise example

* feat(play): add coherence non-reversible example

* feat(play): add coherence by caches example

* feat(play): add coherence by caches example

* feat(play): add coherence by encryption example

* feat(play): add last examples

* feat(play): fix example

* chore(play): fix build inject version

* chore(play): fix ff1 example

* chore(play): fix add noise example

* feat(play): add a loading screen

* feat(play): add a loading spinner

* feat(play): add a refresh button

* docs(play): update changelog

* docs(play): update readme

* docs(play): add missing image

* docs(play): move image from docs to assets
  • Loading branch information
adrienaury authored Jun 23, 2022
1 parent 092e6a3 commit 88620b6
Show file tree
Hide file tree
Showing 11 changed files with 523 additions and 18 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ Types of changes

## [1.14.0]

- `Added` (play) possibility to share URL directly from the Play website
- `Added` possibility to share URL directly from the PIMO Play website
- `Added` precrafted examples in the PIMO Play website
- `Added` loading screen when JS is loading on PIMO Play website
- `Added` loading spinner when refreshing output on PIMO Play website
- `Added` a refresh button on PIMO Play website

## [1.13.0]

Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ This takes the `data.json` file, masks the data contained inside it and put the
* `--repeat-until <condition>` This flag will make PIMO keep masking every input until the condition is met. Condition format is using [Template](https://pkg.go.dev/text/template). Last output verifies the condition.
* `--repeat-while <condition>` This flag will make PIMO keep masking every input while the condition is met. Condition format is using [Template](https://pkg.go.dev/text/template).

### PIMO Play

The `play` command will start a local website, where you will find commented examples and a playground to play with the masking configuration.

```console
$ pimo play
⇨ http server started on [::]:3010
```

Then go to [http://localhost:3010/](http://localhost:3010/) in your browser.

![PIMO Play screenshot](assets/pimo-play.png)

## Examples

This section will give examples for every types of mask.
Expand Down
Binary file added assets/pimo-play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ targets:
- $: touch web/play/node_modules/go.mod
- $: rm -rf internal/app/pimo/client/*
- $: cp -r web/play/dist/* internal/app/pimo/client
- $: sed -i 's~{{version}}~={realtag}~g' internal/app/pimo/client/index.html
- $: sed -i 's~{{version}}~={realtag}~g' internal/app/pimo/client/main.js
- $: sed -i 's~{{ version }}~={realtag}~g' internal/app/pimo/client/index.html
- $: sed -i 's~{{ version }}~={realtag}~g' internal/app/pimo/client/main.js
- $: git checkout -- internal/app/pimo/client

# run "neon -props '{buildpaths: ["path/to/main/package1","path/to/main/package2"]}' compile" to compile specific targets
Expand Down
1 change: 1 addition & 0 deletions web/play/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"devDependencies": {
"css-loader": "^6.0.0",
"cssnano": "^5.1.12",
"html-webpack-plugin": "^5.0.0",
"postcss": "^8.4.14",
"postcss-loader": "^7.0.0",
Expand Down
3 changes: 2 additions & 1 deletion web/play/postcss.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
plugins: [
require('tailwindcss'),
require('./tailwind.config.cjs'),
require('autoprefixer')
require('autoprefixer'),
require('cssnano')
]
}
5 changes: 5 additions & 0 deletions web/play/src/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"useTabs": false,
"printWidth": 300
}
126 changes: 119 additions & 7 deletions web/play/src/index.ejs

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions web/play/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ setDiagnosticsOptions({
schemas: [
{
// Id of the first schema
uri: 'https://raw.githubusercontent.com/CGI-FR/PIMO/{{version}}/schema/v1/pimo.schema.json',
uri: 'https://raw.githubusercontent.com/CGI-FR/PIMO/{{ version }}/schema/v1/pimo.schema.json',
// Associate with our model
fileMatch: [String(modelUri)],
},
Expand Down Expand Up @@ -66,6 +66,8 @@ var resultJson = editor.create(document.getElementById('result-json'), {
model: editor.createModel('', 'json', Uri.parse('file://result.jsonl')),
});

document.getElementById('loading').remove();

///////////////////////////////////////////////////////////

async function postData() {
Expand Down Expand Up @@ -111,14 +113,16 @@ async function postData() {
console.log(err)
document.getElementById('result-error').innerText = err
} finally {
document.getElementById('label-output').innerText = "Output"
document.getElementById('refresh-spinner').style.display = 'none';
document.getElementById('refresh-button').style.display = 'inline';
}
}

function debounce(func, timeout = 300){
let timer;
return (...args) => {
document.getElementById('label-output').innerText = "Output (refreshing...)"
document.getElementById('refresh-spinner').style.display = 'inline';
document.getElementById('refresh-button').style.display = 'none';
clearTimeout(timer);
timer = setTimeout(() => { func.apply(this, args); }, timeout);
};
Expand All @@ -133,4 +137,5 @@ document.getElementById('editor-json').onkeyup = autoPostData;
document.getElementById('editor-json').oninput = autoPostData;
document.getElementById('editor-json').onpaste = autoPostData;
document.getElementById('editor-json').oncut = autoPostData;
document.getElementById('refresh-button').onclick = autoPostData;
autoPostData();
4 changes: 4 additions & 0 deletions web/play/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export default {
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
{
test: /\.ttf$/,
type: 'asset',
},
],
},
devServer: {
Expand Down
Loading

0 comments on commit 88620b6

Please sign in to comment.