Skip to content
Snippets Groups Projects
README.md 6.43 KiB
Newer Older
LIOTIER MARION's avatar
LIOTIER MARION committed
# mth-metexplore-biodata-grid
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
`MthNetworkGrid` and `MthBiodataGrid` are Vue 3 component that display data in a grid with 2 modes to either fetch data from an API or provide it yourself.
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
## Types
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
| Name | Value |
| --- | --- |
| `Biodata` | `enum { PATHWAY, REACTION, METABOLITE, ENZYME, GENE, PROTEIN, NETWORK }` |
LIOTIER MARION's avatar
LIOTIER MARION committed
| `MappingColumns` | `{ [key: string]: { onColumn?: string; listIds: string[]; stats?: { id: string, pval: number, bonferroni_pval: number, bh_pval: number }[] } };` |
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
## MthNetworkGrid
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
### Props
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
| Name              | Description                                   | Type                                     | Default    |
| ----------------- | --------------------------------------------- | ---------------------------------------- | ---------- |
| `mode`            | remote : the data is fetched from the API with `backendPath`. local : the user provides the data with `data`. | `"local"\|"remote"`                                 | -          |
| `backendPath?`    | path to the api if mode is remote             | `string`                                 | -          |
| `data?`           | the data to display if mode is local          | `MthGridItem[]`                          | -          |
| `filterBy`        | By which properties the data must be filtered | `null \| "PRIVATE" \| "PUBLIC" \| "TOP"` | -          |
| `selectStrategy?` | the select type : single or multiple          | `"all" \| "page" \| "single"`            | `"single"` |
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
### Events
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
| Name        | Description                                    | Type of `$event`                     |
| ----------- | ---------------------------------------------- | ------------------------------------ |
| `selection` | triggered when a row is selected or unselected | `MthGridItem[]`                      |
| `error`     | triggered when there is an error with the API  | `{ title: string, message: string }` |
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
### Slots
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
| Name          | Description                                             | Data                          |
| ------------- | ------------------------------------------------------- | ----------------------------- |
LIOTIER MARION's avatar
LIOTIER MARION committed
| `gridActions` | buttons for each row to display in the `Actions` column | `{ itemAction: MthGridItem }` |

### Use example

LIOTIER MARION's avatar
LIOTIER MARION committed
This web component requires [Vuetify](https://vuetifyjs.com/en/).

LIOTIER MARION's avatar
LIOTIER MARION committed
```html
<MthNetworkGrid
LIOTIER MARION's avatar
LIOTIER MARION committed
  mode="remote"
LIOTIER MARION's avatar
LIOTIER MARION committed
  backendPath="http://localhost:1337"
  :filterBy="null"
  @selection="selection($event)"
>
  <template #gridActions="{ itemAction }">
    <v-btn @click="console.log(itemAction)">Info</v-btn>
  </template>
</MthNetworkGrid>
LIOTIER MARION's avatar
LIOTIER MARION committed

<script setup lang="ts">
LIOTIER MARION's avatar
LIOTIER MARION committed
import { MthNetworkGrid } from "@metabohub/mth-metexplore-biodata-grid";
LIOTIER MARION's avatar
LIOTIER MARION committed
</script>
LIOTIER MARION's avatar
LIOTIER MARION committed

<style scoped>
@import "@metabohub/mth-metexplore-biodata-grid/dist/style.css";
</style>
LIOTIER MARION's avatar
LIOTIER MARION committed
```
LIOTIER MARION's avatar
LIOTIER MARION committed

LIOTIER MARION's avatar
LIOTIER MARION committed
## MthBiodataGrid

### Props

LIOTIER MARION's avatar
LIOTIER MARION committed
| Name                        | Description                                                 | Type                  | Default     |
| --------------------------- | ----------------------------------------------------------- | --------------------- | ----------- |
| `mode`                      | remote : the data is fetched from the API with `backendPath`. local : the user provides the data with `data`. | `"local"\|"remote"`                                 | -          |
| `backendPath?`              | path to the api if mode is remote                           | `string`              | -           |
| `network?`                  | Id of the network if mode is remote                         | `number`              | -           |
| `data?`                     | the data to display if mode is local                        | `MthGridItem[]`       | -           |
| `biodata`                   | Type of biodata to display                                  | `Biodata`             | -           |
| `filterOnIds?`              | List of the ids to display, or null to display all the data | `Array<string>\|null` | `null`      |
| `mapping?`                  | the mappings with their list of mapped ids                  | `MappingColumns`      | `undefined` |
| `numberMappingPreSelected?` | the maximum number of mappings that will show in the table  | `number`              | 3           |
LIOTIER MARION's avatar
LIOTIER MARION committed
| `selectStrategy?`           |	the type of select for the rows : single or multiple        | `SelectStrategy`      | `"all"`     |
LIOTIER MARION's avatar
LIOTIER MARION committed

## Events

LIOTIER MARION's avatar
LIOTIER MARION committed
| Name        | Description                                    | Type of `$event`                     |
| ----------- | ---------------------------------------------- | ------------------------------------ |
| `selection` | triggered when a row is selected or unselected | `MthGridItem[]`                      |
| `error`     | triggered when there is an error with the API  | `{ title: string, message: string }` |
LIOTIER MARION's avatar
LIOTIER MARION committed

## Slots

| Name          | Description                                             | Data                          |
| ------------- | ------------------------------------------------------- | ----------------------------- |
| `gridActions` | buttons for each row to display in the `Actions` column | `{ itemAction: MthGridItem }` |

## Use example

LIOTIER MARION's avatar
LIOTIER MARION committed
This web component requires [Vuetify](https://vuetifyjs.com/en/).

LIOTIER MARION's avatar
LIOTIER MARION committed
```html
<MthBiodataGrid
LIOTIER MARION's avatar
LIOTIER MARION committed
  mode="remote"
LIOTIER MARION's avatar
LIOTIER MARION committed
  backendPath="http://localhost:1337"
  :network="207"
  :biodata="Biodata.METABOLITE"
  @selection="selection($event)"
>
  <template #gridActions="{ itemAction }">
    <v-btn @click="info(itemAction)">Info</v-btn>
  </template>
</MthBiodataGrid>

<script setup lang="ts">
LIOTIER MARION's avatar
LIOTIER MARION committed
import { MthMetaboliteGrid, Biodata } from "@metabohub/mth-metexplore-biodata-grid";
LIOTIER MARION's avatar
LIOTIER MARION committed
</script>
LIOTIER MARION's avatar
LIOTIER MARION committed

<style scoped>
@import "@metabohub/mth-metexplore-biodata-grid/dist/style.css";
</style>
LIOTIER MARION's avatar
LIOTIER MARION committed
```

## Project Setup

```sh
npm install
```

### Compile and Hot-Reload for Development

```sh
npm run dev
```

LIOTIER MARION's avatar
LIOTIER MARION committed
### Type-Check, Compile and Minify for Production
LIOTIER MARION's avatar
LIOTIER MARION committed

```sh
npm run build
```

### Run Unit Tests with [Vitest](https://vitest.dev/)

```sh
npm run test:unit
```

LIOTIER MARION's avatar
LIOTIER MARION committed
Check the coverage of the unit tests :
LIOTIER MARION's avatar
LIOTIER MARION committed
```sh
npm run coverage
```

### Lint with [ESLint](https://eslint.org/)

```sh
npm run lint
```

LIOTIER MARION's avatar
LIOTIER MARION committed
### View documentation
LIOTIER MARION's avatar
LIOTIER MARION committed

```sh
npm run storybook
```
LIOTIER MARION's avatar
LIOTIER MARION committed

## CICD pipeline

### Tests

```yml
test:
  image: node:latest
  stage: test
  before_script:
    - npm install
  script:
    - npm run test:unit
```

LIOTIER MARION's avatar
LIOTIER MARION committed
This runs the unit tests defined in `src/components/__tests__/`
LIOTIER MARION's avatar
LIOTIER MARION committed

### Deploy

```yml
.publish:
  stage: deploy
  before_script:
    - apt-get update && apt-get install -y git default-jre
    - npm install
    - npm run build
```

LIOTIER MARION's avatar
LIOTIER MARION committed
This builds the component as an npm package.