Browse Source

Removed websockets references

rigwild 1 year ago
parent
commit
8b152497dd

+ 4 - 9
DOCUMENTATION/01-application-file-tree.md

@@ -51,7 +51,7 @@ The following file tree represents the full application.
 │   ├── favicon.ico                  || Website favicon
 │   └── index.html                   || 
 ├── README.md                        || 
-├── server                           || Server, database and WebSockets server code
+├── server                           || Server and database code
 │   └── ...                          || 
 ├── src                              || Front-end code
 │   └── ...                          || 
@@ -113,14 +113,12 @@ The `/logs` directory contains all the logs of the application.
     ├── extractsRemoverService.error.log || Extracts remover service errors
     ├── extractsRemoverService.log       || Extracts remover service logs
     ├── server.combined.log              || Server combined logs
-    ├── server.error.log                 || Server errors
-    ├── ws.error.log                     || WebSockets server errors
-    └── ws.log                           || WebSockets server logs
+    └── server.error.log                 || Server errors
 ```
 
 ## `/server` directory
 
-The [`/server`](../server) directory contains the Back-end: server, database and WebSockets server code.
+The [`/server`](../server) directory contains the Back-end: server and database code.
 
 ```console
 └── server                    || 
@@ -131,14 +129,11 @@ The [`/server`](../server) directory contains the Back-end: server, database and
     │   └── models            || Database models (Schemas, types)
     │       └── Data.js       || 
     ├── functions.js          || Common utils for the server
-    ├── index.js              || Server module: links server, database and WebSockets server
+    ├── index.js              || Server module: links server and database
     ├── routes                || All API routes
     │   ├── index.js          || Router module to inject all routes
     │   ├── getImage.js       || 
     │   └── ...               || 
-    ├── webSocket             || WebSockets server
-    │   ├── index.js          || Websockets server module: starts server
-    │   └── messageHandler.js || Handle WebSockets messages (JSON)
     └── winston.config.js     || All the server's logging configuration
 ```
 

+ 1 - 1
DOCUMENTATION/02-npm-scripts.md

@@ -64,7 +64,7 @@ yarn doc
 ```
 
 ## `test`
-Run the API automated tests. It will check for routes/WebSockets server/database errors.
+Run the API automated tests. It will check for routes and database errors.
 
 These tests are automatically ran when using Docker.
 ```sh

+ 0 - 2
DOCUMENTATION/03-npm-dependencies.md

@@ -29,7 +29,6 @@ These dependencies are mostly used by the server.
 | `sharp` | [npm](https://www.npmjs.com/package/sharp) | Node.js image processing library |
 | `ua-parser-js` | [npm](https://www.npmjs.com/package/ua-parser-js) | Parse User Agent strings |
 | `winston` | [npm](https://www.npmjs.com/package/winston) | Server logger |
-| `ws` | [npm](https://www.npmjs.com/package/ws) | Node.js WebSockets server |
 
 ## Development dependencies
 These dependencies are here for developers only. They contain the web application setup, optimized builders and API automated tests. It also contains API documentation generator and `ESLint` with its plugins.
@@ -55,7 +54,6 @@ When the web application files are builded, `Vue.js` and its plugins are not nec
 | `supertest` | [npm](https://www.npmjs.com/package/supertest) | HTTP requests test library |
 | `vue` | [npm](https://www.npmjs.com/package/vue) | `Vue.js` JavaScript framework |
 | `vue-cli-plugin-vuetify` | [npm](https://www.npmjs.com/package/vue-cli-plugin-vuetify) | Just a plugin to use `Vuetify` in `Vue.js` |
-| `vue-native-websocket` | [npm](https://www.npmjs.com/package/vue-native-websocket) | WebSockets client library, plugged to `Vuex` |
 | `vue-router` | [npm](https://www.npmjs.com/package/vue-router) | Web application routing system |
 | `vue-template-compiler` | [npm](https://www.npmjs.com/package/vue-template-compiler) | Build `Vue.js` `.vue` files |
 | `vuetify` | [npm](https://www.npmjs.com/package/vuetify) | `Vue.js` specific CSS framework |

+ 20 - 5
DOCUMENTATION/04-create-an-experiment.md

@@ -110,7 +110,7 @@ When drawing the tree from top mixins to the experiment itself, `ExperimentBase`
 | `finishExperiment()` | `void` | Finish an experiment, sending full data to the server . Don't forget to surcharge this function when using this mixin to add more data! |
 | `getQualitiesList()` | `Promise<void>` | Load qualities list from the API |
 | `getImage(quality: Number)` | `Promise<Object>` | Load an image from the API |
-| `sendMessage({ msgId: String, msg: Object })` | `void` | Send a message using WebSockets, your message will be stored in the database. Message IDs are listed in [`/config.messageId.js`](../config.messageId.js) |
+| `sendMessage({ msgId: String, msg: Object })` | `void` | Send a message using `/experimentCollect` API route, your message will be stored in the database. Message IDs are listed in [`/config.messageId.js`](../config.messageId.js) |
 | `setExperimentFinished([done=true: Boolean])` | `void` | Set the current experiment as finished in the browser's cache |
 
 ### ExperimentBaseAreSameImages
@@ -120,11 +120,17 @@ Extends: [[ExperimentBase](#experimentbase)]
 
 | Data | Type | Default | Description |
 | ---- | ---- | ------- | ----------- |
+| `maxTestCount` | `Number` | `null` | The total number of tests to pass for this scene |
+| `testCount` | `Number` | `1` | Passed tests count |
+| `image1` | `Object` | `null` | One of the two images |
+| `image2` | `Object` | `null` | One of the two images |
 
 | Method | Return type | Description |
 | ------ | ----------- | ----------- |
-
-`TODO: finish this part`
+| `scrollToChoiceButtons()` | `void` | Scroll the page to the answer buttons |
+| `getTest(leftQuality: Number, rightQuality: Number)` | `Promise<Object>` | Load a test using provided qualities |
+| `areTheSameAction(areTheSame: Boolean, getTestFn: Function, additionalData: any)` | `Promise<Object>` | Answer to the versus. `getTestFn` shoud be an async function that returns an object matching `{ image1: Object, image2: Object }`. additionalData is the experiment-specific content you want to send to the database  |
+| `finishExperiment()` | `void` | Finish an experiment |
 
 ### ExperimentBaseExtracts
 File: [`/src/mixins/ExperimentBaseExtracts.vue`](../src/mixins/ExperimentBaseExtracts.vue)
@@ -133,8 +139,17 @@ Extends: [[ExperimentBase](#experimentbase)]
 
 | Data | Type | Default | Description |
 | ---- | ---- | ------- | ----------- |
+| `extractConfig` | `Object` | `{ x=null: Number, y=null: Number }` | Used configuration to cut the image |
+| `extracts` | `Object[]` | `[]` | List of extracts of the cutted image |
+| `extractsInfos` | `Object` | `null` | Informations on the cutted image |
+| `showHoverBorder` | `Boolean` | `null` | Should the extracts be hoverable (white rectangle around the extract) |
+| `lockConfig` | `Boolean` | `null` | Should the extract configuration be editable |
 
 | Method | Return type | Description |
 | ------ | ----------- | ----------- |
-
-`TODO: finish this part`
+| `getExtracts([quality='min']: Number|String)` | `Promise<Object>` | Load image extracts using the provided quality and extract configuration |
+| `setExtractConfig(config: Object, [configuratorRef: Object])` | `Promise<Object>` | Change the extract configuration. It loads the new extracts. `config` is the new extracts configuration to use. If `configuratorRef` is provided, it will extract the extracts configurator |
+| `extractAction(event: MouseEvent, extractObj: Object)` | `Promise<void>` | Used when clicking on an extract. `event` is the mouse event (left/right click). `extractObj` is the object corresponding to the clicked extract (from the extracts array) |
+| `getExtractFullObject(extractsApiObj: Object)` | `Promise<Object>` | Takes the API image extracts response and apply more data to the extracts (like next/prec quality, zone, index or full link to image) |
+| `getClickDataObject(event, extractObj, action)` | `Object` | Calculate data on clicked event. Will get the click position on the responsive image, calculate the ratio to the real-sized image. It returns the full message sent when clicking on an extract |
+| `finishExperiment()` | `void` | Finish an experiment sending final experiment data |

+ 0 - 1
README.md

@@ -33,7 +33,6 @@ Configure more deeply the way the app works by modifying *[config.js](config.js)
 | `sceneFileNameBlackList` | `['config', 'seuilExpe', 'extracts']` | Files to ignore in scenes |
 | `deleteExtractsCronTime` | `0 3 * * *` (every day at 03:00 AM) | Cron time for extracts deletion |
 | `logger` | Logs : `logs/server.combined.log` Errors : `logs/server.error.log` | Default application logger |
-| `wsLogger` | Logs : `logs/ws.log` Errors : `logs/ws.error.log` | WebSocket logger configuration |
 | `dbLogger` | Logs : `logs/db.log` Errors : `logs/db.error.log` | Database logger configuration |
 
 ### Configure experiments

+ 2 - 2
config.js

@@ -1,7 +1,7 @@
 'use strict'
 
 import path from 'path'
-import { logger, wsLogger, dbLogger } from './server/winston.config'
+import { logger, dbLogger } from './server/winston.config'
 
 export const PRODUCTION_MODE = process.env.NODE_ENV === 'production'
 export const TEST_MODE = process.env.NODE_ENV === 'test'
@@ -39,4 +39,4 @@ export const sceneFileNameBlackList = ['config', 'seuilExpe', extractsDirName]
 export const deleteExtractsCronTime = '0 3 * * *'
 
 // Logger configurations (Default application, WebSocket, Database)
-export { logger, wsLogger, dbLogger }
+export { logger, dbLogger }

+ 0 - 16
server/winston.config.js

@@ -18,22 +18,6 @@ export const logger = winston.createLogger({
   exitOnError: false
 })
 
-// WebSocket logger configuration
-export const wsLogger = winston.createLogger({
-  level: 'info',
-  format: winston.format.json(),
-  transports: [
-    new winston.transports.File({ filename: 'logs/ws.log' }),
-    new winston.transports.File({ filename: 'logs/ws.error.log', level: 'error' }),
-    new winston.transports.Console({
-      level: 'debug',
-      handleExceptions: true,
-      format: winston.format.json()
-    })
-  ],
-  exitOnError: false
-})
-
 // Database logger configuration
 export const dbLogger = winston.createLogger({
   level: 'info',