Skip to content

Commit 88620b6

Browse files
authored
feat(play): add crafted examples (#132)
* 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
1 parent 092e6a3 commit 88620b6

File tree

11 files changed

+523
-18
lines changed

11 files changed

+523
-18
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ Types of changes
1616

1717
## [1.14.0]
1818

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

2125
## [1.13.0]
2226

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,19 @@ This takes the `data.json` file, masks the data contained inside it and put the
134134
* `--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.
135135
* `--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).
136136

137+
### PIMO Play
138+
139+
The `play` command will start a local website, where you will find commented examples and a playground to play with the masking configuration.
140+
141+
```console
142+
$ pimo play
143+
⇨ http server started on [::]:3010
144+
```
145+
146+
Then go to [http://localhost:3010/](http://localhost:3010/) in your browser.
147+
148+
![PIMO Play screenshot](assets/pimo-play.png)
149+
137150
## Examples
138151

139152
This section will give examples for every types of mask.

assets/pimo-play.png

58.2 KB
Loading

build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ targets:
222222
- $: touch web/play/node_modules/go.mod
223223
- $: rm -rf internal/app/pimo/client/*
224224
- $: cp -r web/play/dist/* internal/app/pimo/client
225-
- $: sed -i 's~{{version}}~={realtag}~g' internal/app/pimo/client/index.html
226-
- $: sed -i 's~{{version}}~={realtag}~g' internal/app/pimo/client/main.js
225+
- $: sed -i 's~{{ version }}~={realtag}~g' internal/app/pimo/client/index.html
226+
- $: sed -i 's~{{ version }}~={realtag}~g' internal/app/pimo/client/main.js
227227
- $: git checkout -- internal/app/pimo/client
228228

229229
# run "neon -props '{buildpaths: ["path/to/main/package1","path/to/main/package2"]}' compile" to compile specific targets

web/play/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"css-loader": "^6.0.0",
18+
"cssnano": "^5.1.12",
1819
"html-webpack-plugin": "^5.0.0",
1920
"postcss": "^8.4.14",
2021
"postcss-loader": "^7.0.0",

web/play/postcss.config.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
plugins: [
33
require('tailwindcss'),
44
require('./tailwind.config.cjs'),
5-
require('autoprefixer')
5+
require('autoprefixer'),
6+
require('cssnano')
67
]
78
}

web/play/src/.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": false,
4+
"printWidth": 300
5+
}

web/play/src/index.ejs

Lines changed: 119 additions & 7 deletions
Large diffs are not rendered by default.

web/play/src/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ setDiagnosticsOptions({
1515
schemas: [
1616
{
1717
// Id of the first schema
18-
uri: 'https://raw.githubusercontent.com/CGI-FR/PIMO/{{version}}/schema/v1/pimo.schema.json',
18+
uri: 'https://raw.githubusercontent.com/CGI-FR/PIMO/{{ version }}/schema/v1/pimo.schema.json',
1919
// Associate with our model
2020
fileMatch: [String(modelUri)],
2121
},
@@ -66,6 +66,8 @@ var resultJson = editor.create(document.getElementById('result-json'), {
6666
model: editor.createModel('', 'json', Uri.parse('file://result.jsonl')),
6767
});
6868

69+
document.getElementById('loading').remove();
70+
6971
///////////////////////////////////////////////////////////
7072

7173
async function postData() {
@@ -111,14 +113,16 @@ async function postData() {
111113
console.log(err)
112114
document.getElementById('result-error').innerText = err
113115
} finally {
114-
document.getElementById('label-output').innerText = "Output"
116+
document.getElementById('refresh-spinner').style.display = 'none';
117+
document.getElementById('refresh-button').style.display = 'inline';
115118
}
116119
}
117120

118121
function debounce(func, timeout = 300){
119122
let timer;
120123
return (...args) => {
121-
document.getElementById('label-output').innerText = "Output (refreshing...)"
124+
document.getElementById('refresh-spinner').style.display = 'inline';
125+
document.getElementById('refresh-button').style.display = 'none';
122126
clearTimeout(timer);
123127
timer = setTimeout(() => { func.apply(this, args); }, timeout);
124128
};
@@ -133,4 +137,5 @@ document.getElementById('editor-json').onkeyup = autoPostData;
133137
document.getElementById('editor-json').oninput = autoPostData;
134138
document.getElementById('editor-json').onpaste = autoPostData;
135139
document.getElementById('editor-json').oncut = autoPostData;
140+
document.getElementById('refresh-button').onclick = autoPostData;
136141
autoPostData();

web/play/webpack.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export default {
88
test: /\.css$/,
99
use: ['style-loader', 'css-loader', 'postcss-loader'],
1010
},
11+
{
12+
test: /\.ttf$/,
13+
type: 'asset',
14+
},
1115
],
1216
},
1317
devServer: {

0 commit comments

Comments
 (0)