Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.

Commit 858621e

Browse files
authored
update with new design (#359)
1 parent ec97c20 commit 858621e

File tree

14 files changed

+170
-69
lines changed

14 files changed

+170
-69
lines changed

annotation-app/src/app/components/admin/admin.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class AdminComponent implements OnInit {
244244
role: this.optionsSet,
245245
name: str.replace(str[0], str[0].toUpperCase()),
246246
};
247-
this.avaService.saveUser(this.userRoleInfo).subscribe(
247+
this.avaService.saveUser([this.userRoleInfo]).subscribe(
248248
(res) => {
249249
this.loading = false;
250250
this.createUserDialog = false;

annotation-app/src/app/components/open-source/basic-login/basic-login.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export class BasicLoginComponent implements OnInit {
140140
password: this.dsForm.get('password').value,
141141
uname: fullName.join(' '),
142142
};
143-
this.avaService.register(param).subscribe(
143+
this.avaService.register([param]).subscribe(
144144
(res) => {
145145
this.registerSuccess = 'Sign Up Complete!';
146146
this.loading = false;

annotation-service/config/code_msg.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module.exports={
22
//OPERATION
33
SUCCESS: { CODE: 200, MSG: "SUCCESS" },
4-
ANNOTATE_DONE: { CODE: 200, "MSG": "ANNOTATION DONE" },
5-
ANNOTATE_DONE: { CODE: 200, "MSG": "REVIEW DONE" },
4+
ANNOTATE_DONE: { CODE: 200, "MSG": "THE TASK HAS BEEN DONE" },
65
ERROR: { CODE: 500, MSG: "SERVER ERROR" },
76

87
//401 auth related
@@ -18,6 +17,7 @@ module.exports={
1817
//2000 user related
1918
VALIDATION_USER_EXIST: {CODE: 2000, MSG: "USER ALREADY EXIST"},
2019
VALIDATION_USER_EMAIL: {CODE: 2001, MSG: "USER EMAIL MUST NOT BE EMPTY"},
20+
VALIDATION_USER_NO_EXIST: {CODE: 2002, MSG: "USER NOT EXIST"},
2121

2222
//3000 tickets related
2323
ERROR_TK_SETDATA: { CODE: 3000, MSG: "HANDLE DATA ERROR" },

annotation-service/db/db-connect.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ const userSchema = new mongoose.Schema({
148148
updateDate: { type: String },
149149
regularNotification: { type: Boolean, default: true },
150150
manul: { type: Boolean, default: false },
151+
dashboard:{
152+
createdDate: { type: String },
153+
updateDate: { type: String },
154+
data:[],
155+
},
151156
}, { _id: false });
152157
userSchema.set("toJSON", { virtuals: true });
153158
userSchema.set("toObject", { virtuals: true });
@@ -238,7 +243,7 @@ const projectSchema = new mongoose.Schema({
238243
source: { type: String, default: "" },
239244
externalId: { type: Array, default: [] },
240245
},
241-
assignSlackChannels: { type: Array }
246+
assignSlackChannels: { type: Array },
242247
}, { _id: true });
243248
projectSchema.index({ projectName: 1 });
244249
projectSchema.set("toJSON", { virtuals: true });
@@ -272,10 +277,12 @@ const dataSetSchema = new mongoose.Schema({
272277
fileSize: { type: Number },
273278
}],
274279
totalRows: { type: Number },
280+
totalColumns: { type: Number },
275281
dataSynchronize:[{
276282
system: { type: String },
277283
_id: { type: String },
278-
}]
284+
}],
285+
projects:{ type: Array },
279286
});
280287
dataSetSchema.set("toJSON", { virtuals: true });
281288
dataSetSchema.index({ dataSetName: 1 });

annotation-service/resources/APIs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module.exports = {
1616
USER_DELETE: "/users", //swagger
1717
USER_ROLE_EDIT: "/users", //swagger
1818
USER_ROLE: "/users/roles", //swagger
19+
USER_DASHBOARD: "/users/dashboard", //swagger
1920
FILE_DATASET_QUERY: "/users/datasets",//swagger
2021
PROJECT_LIST_ANNOTATOR: "/users/projects/names", // no
2122

annotation-service/routers/user-controller.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ router.get(APIs.USER_ROLE, (req, res) => {
6969
});
7070
});
7171

72+
/* PUTCH USER update dashboard */
73+
router.patch(APIs.USER_DASHBOARD, (req, res) => {
74+
console.log(`[ USER ] [ ACCESS ] Router ${req.originalUrl} ${req.auth.email}`);
75+
userService.saveUserDashboard(req).then(response => {
76+
console.log(`[ USER ] [ SUCCESS ] Router ${req.originalUrl} ${req.auth.email}`);
77+
res.status(200).json(response);
78+
}).catch(error => {
79+
console.log(`[ USER ] [ ERROR ] Router ${req.originalUrl} ${req.auth.email}`, error);
80+
res.status(500).send(error);
81+
});
82+
});
83+
7284
/* Get user Rank */
7385
router.get(APIs.USER_RANK, (req, res) => {
7486
console.log(`[ USER ] [ ACCESS ] Router ${req.originalUrl} ${req.auth.email}`);

annotation-service/services/dataSet-service.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const fs = require('fs');
1818
const mongoDb = require('../db/mongo.db');
1919
const { ProjectModel, DataSetModel } = require('../db/db-connect');
2020
const MESSAGE = require('../config/code_msg');
21+
const {updateProjectDatasetInfo} = require('./project.service');
2122

2223
async function saveDataSetInfo(req) {
2324

@@ -38,7 +39,9 @@ async function saveDataSetInfo(req) {
3839
format: req.body.format,
3940
createTime: Date.now(),
4041
updateTime: Date.now(),
41-
dataSynchronize: dataSynchronize
42+
dataSynchronize: dataSynchronize,
43+
totalRows: req.body.totalRows,
44+
totalColumns: req.body.totalColumns? req.body.totalColumns: 0,
4245
};
4346

4447
if (config.useLocalFileSys) {
@@ -86,7 +89,6 @@ async function saveDataSetInfo(req) {
8689

8790
}else if (req.body.format == DATASETTYPE.LOG) {
8891
dataSet.topReview = req.body.topReview;
89-
dataSet.totalRows = req.body.totalRows;
9092
}
9193

9294
let conditions = { dataSetName: req.body.dsname };
@@ -219,7 +221,9 @@ async function deleteDataSet(req) {
219221
}
220222

221223
}
222-
224+
for (const projectName of ds[0].projects) {
225+
await updateProjectDatasetInfo(projectName, ds[0].dataSetName, OPERATION.DELETE);
226+
}
223227
console.log(`[ DATASET ] Service deleteDataSet.removeDataSet`);
224228
await mongoDb.removeByConditions(DataSetModel, { dataSetName: ds[0].dataSetName });
225229

@@ -271,6 +275,25 @@ async function updateDataset(req) {
271275

272276
}
273277

278+
async function updateDatasetProjectInfo(datasetName, projectName, operation) {
279+
280+
const condistion = {datasetName: datasetName};
281+
const options = { new: true, upsert: true };
282+
let update = {};
283+
284+
if (OPERATION.ADD == operation) {
285+
update["$push.projects"] = projectName;
286+
}else if (OPERATION.DELETE == operation) {
287+
update["$pull.projects"] = projectName;
288+
}else{
289+
throw MESSAGE.VALIDATATION_OPERATION;
290+
}
291+
292+
console.log(`[ DATASET ] Service updateDatasetProjectInfo`);
293+
return mongoDb.findOneAndUpdate(DataSetModel, condistion, update, options);
294+
295+
}
296+
274297
module.exports = {
275298
saveDataSetInfo,
276299
queryDataSetByUser,
@@ -279,4 +302,5 @@ module.exports = {
279302
signS3Url,
280303
imageTopPreview,
281304
updateDataset,
305+
updateDatasetProjectInfo,
282306
}

annotation-service/services/file-service.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
const srsImporter = require("../utils/srsImporter");
1010
const createCsvWriter = require("csv-writer").createObjectCsvWriter;
1111
const CSVArrayWriter = require("csv-writer").createArrayCsvWriter;
12-
const { GENERATESTATUS, PAGINATETEXTLIMIT, PAGINATELIMIT, FILEFORMAT, LABELTYPE, PROJECTTYPE, S3OPERATIONS, FILETYPE, DATASETTYPE, FILEPATH, QUERYORDER, ANNOTATION_QUESTION, TICKET_DESCRIPTION, SOURCE, QUERY_STRATEGY, ESTIMATOR } = require("../config/constant");
12+
const { GENERATESTATUS, PAGINATETEXTLIMIT, PAGINATELIMIT, FILEFORMAT, LABELTYPE, PROJECTTYPE, S3OPERATIONS, FILETYPE, DATASETTYPE, FILEPATH, QUERYORDER, ANNOTATION_QUESTION, TICKET_DESCRIPTION, SOURCE, QUERY_STRATEGY, ESTIMATOR, OPERATION } = require("../config/constant");
1313
const fs = require('fs');
1414
const ObjectId = require("mongodb").ObjectID;
1515
const moment = require('moment');
@@ -127,7 +127,7 @@ async function saveProjectInfo(req, userCompleteCase, annotators) {
127127
assignmentLogic: req.body.assignmentLogic ? req.body.assignmentLogic : QUERYORDER.RANDOM,
128128
annotator: annotators,
129129
dataSource: req.body.fileName ? req.body.fileName : "",
130-
selectedDataset: [req.body.selectedDataset ? req.body.selectedDataset : ""],
130+
selectedDataset: req.body.selectedDataset ? [req.body.selectedDataset] : [],
131131
selectedColumn: selectedColumn,
132132
annotationQuestion: req.body.annotationQuestion ? req.body.annotationQuestion : ANNOTATION_QUESTION,
133133
fileSize: req.body.fileSize ? req.body.fileSize : 1,
@@ -157,7 +157,6 @@ async function saveProjectInfo(req, userCompleteCase, annotators) {
157157
const update = { $set: project };
158158
const options = { new: true, upsert: true };
159159

160-
161160
return mongoDb.findOneAndUpdate(ProjectModel, conditions, update, options)
162161
}
163162

annotation-service/services/project.service.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const { formatDate } = require('../utils/common.utils');
1818
const slackChat = require("./slack/slackChat.service");
1919
const { default: axios } = require("axios");
2020
const MESSAGE = require('../config/code_msg');
21+
const dataSetService = require('./dataSet-service')
2122

2223
async function getProjects(req) {
2324
console.log(`[ PROJECT ] Service getProjects query user role`);
@@ -129,9 +130,12 @@ async function deleteProject(req) {
129130
};
130131
await axios.delete(url, reqConfig);
131132
}
132-
133+
134+
for (const dsName of mp.project.selectedDataset) {
135+
await dataSetService.updateDatasetProjectInfo(dsName, mp.project.projectName, OPERATION.DELETE);
136+
}
133137
console.log(`[ PROJECT ] Service delete project`, conditions);
134-
await mongoDb.deleteOneByConditions(ProjectModel, conditions);
138+
return mongoDb.deleteOneByConditions(ProjectModel, conditions);
135139

136140
}
137141
async function updateProject(req) {
@@ -1049,7 +1053,22 @@ async function getProjectsTextTabular(email) {
10491053
return mongoDb.findByConditions(ProjectModel, condition, project, options);
10501054
}
10511055

1056+
async function updateProjectDatasetInfo(projectName, datasetName, operation) {
1057+
const condistion = {projectName: projectName};
1058+
const options = { new: true, upsert: true };
1059+
let update = {};
10521060

1061+
if (OPERATION.ADD == operation) {
1062+
update["$push.selectedDataset"] = datasetName;
1063+
}else if (OPERATION.DELETE == operation) {
1064+
update["$pull.selectedDataset"] = datasetName;
1065+
}else{
1066+
throw MESSAGE.VALIDATATION_OPERATION;
1067+
}
1068+
1069+
console.log(`[ DATASET ] Service updateDatasetProjectInfo`);
1070+
return mongoDb.findOneAndUpdate(ProjectModel, condistion, update, options);
1071+
}
10531072

10541073

10551074
module.exports = {
@@ -1077,4 +1096,5 @@ module.exports = {
10771096
initHierarchicalLabelsCase,
10781097
reduceHierarchicalUnselectedLabel,
10791098
prepareUserInputs,
1099+
updateProjectDatasetInfo,
10801100
}

annotation-service/services/srs-service.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
const ObjectId = require("mongodb").ObjectID;
1010
const projectService = require('./project.service');
1111
const validator = require('../utils/validator');
12-
const { PAGINATELIMIT, APPENDSR, LABELTYPE, PROJECTTYPE, S3OPERATIONS, QUERYORDER } = require("../config/constant");
12+
const { PAGINATELIMIT, APPENDSR, LABELTYPE, PROJECTTYPE, S3OPERATIONS, QUERYORDER, OPERATION } = require("../config/constant");
1313
const csv = require('csvtojson');
1414
const alService = require('./activelearning.service');
1515
const _ = require("lodash");
@@ -23,6 +23,7 @@ const fileSystemUtils = require('../utils/fileSystem.utils');
2323
const config = require('../config/config');
2424
const { reduceHierarchicalUnselectedLabel, initHierarchicalLabelsCase } = require('./project.service');
2525
const MESSAGE = require('../config/code_msg');
26+
const dataSetService = require('./dataSet-service')
2627

2728
async function updateSrsUserInput(req, from) {
2829

@@ -656,7 +657,7 @@ async function appendSrsDataByCSVFile(req, originalHeaders, project) {
656657
$push: { selectedDataset: req.body.selectedDataset }
657658
};
658659
await mongoDb.findOneAndUpdate(ProjectModel, conditions, update);
659-
660+
await dataSetService.updateDatasetProjectInfo(req.body.selectedDataset, req.body.pname, OPERATION.ADD);
660661
await projectService.updateAssinedCase(conditions, caseNum, true);
661662
console.log(`[ SRS ] Service insert sr end: `, Date.now());
662663
} catch (error) {
@@ -710,7 +711,7 @@ async function appendSrsData(req) {
710711
//validate pname and headers
711712
const originalHeaders = mp.project.selectedColumn;
712713
if (req.body.isFile) {
713-
//file append
714+
//file append
714715
await appendSrsDataByCSVFile(req, originalHeaders, project);
715716
console.log(`[ SRS ] Service append tickets by CSV file done`);
716717
} else {

0 commit comments

Comments
 (0)