Skip to content

Commit

Permalink
feat(Projects): add project page commands and repository (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
lilian-delouvy authored Mar 22, 2022
1 parent 0a9621b commit 2b78fb3
Show file tree
Hide file tree
Showing 58 changed files with 980 additions and 322 deletions.
6 changes: 5 additions & 1 deletion Scripts/Release/SQL/Azure_R1/001_drop_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[sch_ECOTAG].[T_D
DROP table [sch_ECOTAG].[T_Dataset]
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[sch_ECOTAG].[T_File]'))
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[sch_ECOTAG].[T_File]'))
DROP table [sch_ECOTAG].[T_File]
GO

IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[sch_ECOTAG].[T_Project]'))
DROP table [sch_ECOTAG].[T_Project]
GO
17 changes: 17 additions & 0 deletions Scripts/Release/SQL/Azure_R1/002_create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,21 @@ END

GO

/****** Object: Table [sch_ECOTAG].[T_Project] ******/
if not exists (select * from sysobjects where name='T_Project' and xtype='U')
BEGIN
CREATE TABLE [sch_ECOTAG].[T_Project](
[PRJ_Id] uniqueidentifier NOT NULL DEFAULT newid(),
[PRJ_DatasetId] uniqueidentifier NOT NULL,
[PRJ_GroupId] uniqueidentifier NOT NULL,
[PRJ_Name] [varchar](16) NOT NULL,
[PRJ_NumberCrossAnnotation] [int] NOT NULL CHECK (PRJ_NumberCrossAnnotation between 1 and 10),
[PRJ_CreateDate] BIGINT NOT NULL,
[PRJ_AnnotationType] int NOT NULL,
[PRJ_LabelsJson] [varchar](2048) NOT NULL,
[PRJ_CreatorNameIdentifier] [varchar](32) NOT NULL,
CONSTRAINT [PK_T_Project] UNIQUE([PRJ_Id])
)
END

GO
14 changes: 14 additions & 0 deletions Scripts/Release/SQL/Azure_R1/004_insert_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ DECLARE @firstGroupId uniqueidentifier
DECLARE @secondGroupId uniqueidentifier
DECLARE @thirdGroupId uniqueidentifier

DECLARE @firstProjectId uniqueidentifier
DECLARE @secondProjectId uniqueidentifier
DECLARE @thirdProjectId uniqueidentifier

SET @firstUserId = newid()
SET @secondUserId = newid()
SET @thirdUserId = newid()
Expand All @@ -17,6 +21,10 @@ SET @firstGroupId = newid()
SET @secondGroupId = newid()
SET @thirdGroupId = newid()

SET @firstProjectId = newid()
SET @secondProjectId = newid()
SET @thirdProjectId = newid()

INSERT INTO [sch_ECOTAG].[T_User]([USR_Id],[USR_Email],[USR_Subject]) VALUES (@firstUserId,"[email protected]","S111111")
INSERT INTO [sch_ECOTAG].[T_User]([USR_Id],[USR_Email],[USR_Subject]) VALUES (@secondUserId,"[email protected]","S222222")
INSERT INTO [sch_ECOTAG].[T_User]([USR_Id],[USR_Email],[USR_Subject]) VALUES (@thirdUserId,"[email protected]","S333333")
Expand All @@ -30,4 +38,10 @@ INSERT INTO [sch_ECOTAG].[T_GroupUsers]([GPU_Id],[GRP_Id],[USR_Id]) VALUES (newi
INSERT INTO [sch_ECOTAG].[T_GroupUsers]([GPU_Id],[GRP_Id],[USR_Id]) VALUES (newid(), @firstGroupId, @thirdUserId)
INSERT INTO [sch_ECOTAG].[T_GroupUsers]([GPU_Id],[GRP_Id],[USR_Id]) VALUES (newid(), @secondGroupId, @secondUserId)

INSERT INTO [sch_ECOTAG].[T_Project](
[PRJ_Id],[PRJ_DatasetId],[PRJ_GroupId],[PRJ_Name],[PRJ_NumberCrossAnnotation],[PRJ_CreateDate],[PRJ_AnnotationType],[PRJ_LabelsJson],[PRJ_CreatorNameIdentifier]
) VALUES (
newid(), newid(), @firstGroupId, "firstproject", 10, 1647129600, 0, '[{"name": "Recto", "color": "#212121", "id": "0"}, {"name": "Verso", "color": "#ffbb00", "id": "1"}, {"name": "Signature", "color": "#f20713", "id": "2"}]',"s666666"
)

GO
2 changes: 1 addition & 1 deletion docker/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=Your_password123
COPY ./ /
#ENTRYPOINT [ "/bin/bash", "entrypoint.sh" ]
ENTRYPOINT [ "/bin/bash", "entrypoint.sh" ]
CMD [ "/opt/mssql/bin/sqlservr" ]
34 changes: 34 additions & 0 deletions docker/initBase.sql
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,26 @@ END
GO


/****** Object: Table [sch_ECOTAG].[T_Project] ******/
if not exists (select * from sysobjects where name='T_Project' and xtype='U')
BEGIN
CREATE TABLE [sch_ECOTAG].[T_Project](
[PRJ_Id] uniqueidentifier NOT NULL DEFAULT newid(),
[PRJ_DatasetId] uniqueidentifier NOT NULL,
[PRJ_GroupId] uniqueidentifier NOT NULL,
[PRJ_Name] [varchar](16) NOT NULL,
[PRJ_NumberCrossAnnotation] [int] NOT NULL CHECK (PRJ_NumberCrossAnnotation between 1 and 10),
[PRJ_CreateDate] BIGINT NOT NULL,
[PRJ_AnnotationType] int NOT NULL,
[PRJ_LabelsJson] [varchar](2048) NOT NULL,
[PRJ_CreatorNameIdentifier] [varchar](32) NOT NULL,
CONSTRAINT [PK_T_Project] UNIQUE([PRJ_Id])
)
END

GO


CREATE CLUSTERED INDEX [IND_DatasetIsLocked] ON [sch_ECOTAG].[T_Dataset]
(
[DTS_IsLocked] ASC
Expand All @@ -176,6 +196,10 @@ DECLARE @firstGroupId uniqueidentifier
DECLARE @secondGroupId uniqueidentifier
DECLARE @thirdGroupId uniqueidentifier

DECLARE @firstProjectId uniqueidentifier
DECLARE @secondProjectId uniqueidentifier
DECLARE @thirdProjectId uniqueidentifier

SET @firstUserId = newid()
SET @secondUserId = newid()
SET @thirdUserId = newid()
Expand All @@ -184,6 +208,10 @@ SET @firstGroupId = newid()
SET @secondGroupId = newid()
SET @thirdGroupId = newid()

SET @firstProjectId = newid()
SET @secondProjectId = newid()
SET @thirdProjectId = newid()

INSERT INTO [sch_ECOTAG].[T_User]([USR_Id],[USR_Email],[USR_Subject]) VALUES (@firstUserId,"[email protected]","S111111")
INSERT INTO [sch_ECOTAG].[T_User]([USR_Id],[USR_Email],[USR_Subject]) VALUES (@secondUserId,"[email protected]","S222222")
INSERT INTO [sch_ECOTAG].[T_User]([USR_Id],[USR_Email],[USR_Subject]) VALUES (@thirdUserId,"[email protected]","S333333")
Expand All @@ -197,6 +225,12 @@ INSERT INTO [sch_ECOTAG].[T_GroupUsers]([GPU_Id],[GRP_Id],[USR_Id]) VALUES (newi
INSERT INTO [sch_ECOTAG].[T_GroupUsers]([GPU_Id],[GRP_Id],[USR_Id]) VALUES (newid(), @firstGroupId, @thirdUserId)
INSERT INTO [sch_ECOTAG].[T_GroupUsers]([GPU_Id],[GRP_Id],[USR_Id]) VALUES (newid(), @secondGroupId, @secondUserId)

INSERT INTO [sch_ECOTAG].[T_Project](
[PRJ_Id],[PRJ_DatasetId],[PRJ_GroupId],[PRJ_Name],[PRJ_NumberCrossAnnotation],[PRJ_CreateDate],[PRJ_AnnotationType],[PRJ_LabelsJson],[PRJ_CreatorNameIdentifier]
) VALUES (
newid(), newid(), @firstGroupId, "firstproject", 10, 1647129600, 0, '[{"name": "Recto", "color": "#212121", "id": "0"}, {"name": "Verso", "color": "#ffbb00", "id": "1"}, {"name": "Signature", "color": "#f20713", "id": "2"}]',"s666666"
)

GO

USE [ecotag]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
TYPE,
MSG_REQUIRED,
LABELS,
MSG_PROJECT_NAME_ALREADY_EXIST
MSG_PROJECT_NAME_ALREADY_EXIST, MSG_MIN_LENGTH, MSG_MAX_LENGTH, MSG_TEXT_REGEX, MSG_MAX_LABELS_LENGTH
} from './constants';
import compose from '../../../compose';
import withCustomFetch from '../../../withCustomFetch';
Expand Down Expand Up @@ -69,7 +69,26 @@ export const reducer = (state, action) => {
let newFields;
switch (name) {
case LABELS:
const message = newValues.length > 0 ? null : MSG_REQUIRED
let message = null;
if(newValues.length === 0){
message = MSG_REQUIRED
}
else if(newValues.length > 10){
message = MSG_MAX_LABELS_LENGTH
}
else{
newValues.forEach(function(value, index){
if(value.name.length < 3){
message = `Label numéro ${index + 1} : ${MSG_MIN_LENGTH}`
}
else if(value.name.length > 16){
message = `Label numéro ${index + 1} : ${MSG_MAX_LENGTH}`
}
else if(!value.name.match(/^[a-zA-Z-_]*$/)){
message = `Label numéro ${index + 1} : ${MSG_TEXT_REGEX}`
}
})
}
newFields = {
...fields,
[name]: {
Expand All @@ -92,24 +111,24 @@ export const reducer = (state, action) => {
}else if(DATASET === name) {

const options = [{
value: 'CROPPING',
label: "Séléction de zone d'image",
value: 'Cropping',
label: "Sélection de zone d'image",
type: "Image"
},
{
value: 'ImageClassifier',
label: 'Saisi de texte contenu dans une image',
label: 'Saisie de texte contenu dans une image',
type: "Image"
},
{
value: 'NAMED_ENTITY',
label: 'Séléction de zone de texte',
value: 'NamedEntity',
label: 'Sélection de zone de texte',
type: "Text"
}];
const datasetId = event.value
const datsetType = state.datasets.find(dataset => dataset.id === datasetId).type;
const datasetType = state.datasets.find(dataset => dataset.id === datasetId).type;
const reducer = (previousValue, currentValue) => {
if(currentValue.type === datsetType) {
if(currentValue.type === datasetType) {
previousValue.push({value:currentValue.value, label:currentValue.label});
}
return previousValue;
Expand Down Expand Up @@ -163,12 +182,11 @@ export const createProject = async (history, fetch, state, dispatch) => {
return;
}
dispatch({ type: 'onSubmitStarted'});
const datasetId = state.fields[DATASET].value
const newProject = {
name: state.fields[NAME].value,
dataSetId: state.fields[DATASET].value,
groupId: state.fields[GROUP].value,
typeAnnotation: state.fields[TYPE].value,
annotationType: state.fields[TYPE].value,
numberCrossAnnotation: state.fields[NUMBER_CROSS_ANNOTATION].value,
labels: state.fields[LABELS].values,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const fetch = () => {
"id": "0001",
"name": "Relevé d'information",
"dataSetId": "0004",
"classification": "Publique",
"numberTagToDo": 10,
"createDate": new Date("04-04-2011").getTime(),
"typeAnnotation": "NER",
Expand Down Expand Up @@ -136,7 +135,7 @@ describe('New.container', () => {
jest.clearAllMocks();
});

it('should call fetchDeleteProject and dispatch', async () => {
it('should call createProject and dispatch', async () => {
try {
await createProject(givenHistory, givenFetch, givenState, givenDispatch);
expect(givenFetch).toHaveBeenCalledTimes(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { NAME, DATASET, NUMBER_CROSS_ANNOTATION, TYPE, MSG_REQUIRED, LABELS, GROUP } from './constants';

const rulesRequired = {
Expand All @@ -8,23 +9,35 @@ const rulesRequired = {

const rulesMaxLength = max => ({
maxLength: {
maxLength: max,
message: 'Le champ contient trop de caractères',
maxLength: max
},
});

const rulesMinLength = min => ({
minLength: {
minLength: min
}
});

const ruleText = {
pattern: {
regex: /^[a-zA-Z0-9-_]*$/,
message: "Veuillez saisir un caractère alpha numérique, – et _ inclus, accents exclus"
}
}

const ruleNumber = {
pattern: {
regex: /^[0-9]*$/,
message: 'Veuillez saisir un nombre',
regex: /^([1-9]|10)$/,
message: 'Veuillez saisir un nombre entier compris entre 1 et 10',
},
};

export const rules = {
[NAME]: [rulesRequired],
[NAME]: [rulesRequired, rulesMaxLength(16), rulesMinLength(3), ruleText],
[DATASET]: [rulesRequired],
[TYPE]: [rulesRequired],
[LABELS]: [],
[NUMBER_CROSS_ANNOTATION]: [rulesMaxLength(10), ruleNumber],
[NUMBER_CROSS_ANNOTATION]: [ruleNumber],
[GROUP]: [rulesRequired],
};
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
export const NAME = 'NAME';
export const DATASET = 'DATASET';
export const CLASSIFICATION = 'CLASSIFICATION';
export const TYPE = 'TYPE';
export const NUMBER_CROSS_ANNOTATION = 'NUMBER_CROSS_ANNOTATION';
export const LABELS = 'LABELS';
export const GROUP = 'GROUP';

export const MSG_REQUIRED = 'Le champs est obligatoire';
export const MSG_REQUIRED = 'Le champ est obligatoire';
export const MSG_MAX_LABELS_LENGTH = 'Le nombre de labels maximum est limité à 10';
export const MSG_MIN_LENGTH = 'Le champ ne contient pas assez de caractères (3 min)';
export const MSG_MAX_LENGTH = 'Le champ contient trop de caractères (16 max)';
export const MSG_TEXT_REGEX = "Veuillez respecter le bon format (Lettres, '-' ou '_' uniquement)";
export const MSG_PROJECT_NAME_ALREADY_EXIST = 'Un projet avec ce nom existe déjà';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const fetch = async (url, config) => {
await sleep(1);

return {
classification: "Publique",
createDate: "1977-04-22T06:00:00Z",
dataSetId: "0001",
groupId: "0002",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const fetch = () => Promise.resolve({
"id": "0001",
"name": "Relevé d'information",
"dataSetId": "0004",
"classification": "Publique",
"numberTagToDo": 10,
"createDate": "04/04/2011",
"typeAnnotation": "NER",
Expand All @@ -33,15 +32,13 @@ describe('AnnotationDispatch.container', () => {
"id": "0001",
"name": "Carte verte",
"type": "Image",
"classification": "Publique",
"numberFiles": 300,
"createDate": "30/10/2019"
};
const givenProject = {
"id": "0001",
"name": "Relevé d'information",
"dataSetId": "0004",
"classification": "Publique",
"numberTagToDo": 10,
"createDate": new Date("04-04-2011").getTime(),
"typeAnnotation": "NER",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {withResilience} from "../../shared/Resilience";

export const PageAnnotation = ({project, currentItem, onSubmit, onNext, onPrevious, hasPrevious, hasNext, reservationStatus, documentId, annotationStatus, apiUrl}) => <>
<Title title={project.name}
subtitle={`Project de type ${project.typeAnnotation} classification ${project.classification}`}
subtitle={`Project de type ${project.typeAnnotation}`}
goTo={`/projects/${project.id}`}/>
<Content reservationStatus={reservationStatus}
annotationStatus={annotationStatus}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { computeNumberPages, filterPaging, getItemsFiltered, getItemsSorted } fr
const HomeWithResilience = withResilience(Home);

export const HomeContainer = ({ fetch }) => {
const { state, onChangePaging, onChangeFilter, onChangeSort, onDeleteProject } = useHome(fetch);
const { state, onChangePaging, onChangeFilter, onChangeSort } = useHome(fetch);
let filtersState = state.filters;
const itemsFiltered = getItemsFiltered(state.items, filtersState.filterValue);
const itemsSorted = getItemsSorted(itemsFiltered, filtersState.columns);
Expand All @@ -32,7 +32,6 @@ export const HomeContainer = ({ fetch }) => {
onChangePaging={onChangePaging}
onChangeSort={onChangeSort}
onChangeFilter={onChangeFilter}
onDeleteProject={onDeleteProject}
/>
);
};
Expand Down
Loading

0 comments on commit 2b78fb3

Please sign in to comment.