mario-education 9000.0.0 → 9000.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -5224,6 +5224,9 @@ var UploadCSVButton = function UploadCSVButton(_ref) {
|
|
|
5224
5224
|
|
|
5225
5225
|
var CSV_FILE_URL = marioCore.BASE_URL + "/api/ImportCsv/csv";
|
|
5226
5226
|
var CSV_FILE_TEACHER = marioCore.BASE_URL + "/api/Teacher";
|
|
5227
|
+
var importCSV = function importCSV(formData, subFolder) {
|
|
5228
|
+
return marioCore.apiUpload.post(CSV_FILE_URL + "/" + subFolder, formData);
|
|
5229
|
+
};
|
|
5227
5230
|
var importStudentCSV = function importStudentCSV(formData) {
|
|
5228
5231
|
return marioCore.apiUpload.post(CSV_FILE_TEACHER + "/adminImportStudent", formData);
|
|
5229
5232
|
};
|
|
@@ -5243,9 +5246,9 @@ var CSVType;
|
|
|
5243
5246
|
})(CSVType || (CSVType = {}));
|
|
5244
5247
|
|
|
5245
5248
|
var buttons = [{
|
|
5246
|
-
text: "Import
|
|
5247
|
-
backgroundColor: "#
|
|
5248
|
-
type: CSVType.
|
|
5249
|
+
text: "Import class reflections",
|
|
5250
|
+
backgroundColor: "#e74c3c",
|
|
5251
|
+
type: CSVType.ClassReflection
|
|
5249
5252
|
}];
|
|
5250
5253
|
var title = "CSV Import";
|
|
5251
5254
|
var id = "csvupload";
|
|
@@ -5278,29 +5281,62 @@ var useCSVImport = function useCSVImport() {
|
|
|
5278
5281
|
initImportReflection = _useState4[0],
|
|
5279
5282
|
setInitImportReflection = _useState4[1];
|
|
5280
5283
|
|
|
5284
|
+
var domainName = window.location.hostname;
|
|
5285
|
+
var isCheckDomainIBS = domainName.includes('isb');
|
|
5281
5286
|
React.useEffect(function () {
|
|
5282
5287
|
document.title = title;
|
|
5283
5288
|
}, []);
|
|
5284
5289
|
var upload = React.useCallback(function (file) {
|
|
5285
5290
|
try {
|
|
5286
|
-
var
|
|
5291
|
+
var _temp8 = function _temp8() {
|
|
5287
5292
|
dispatch(marioCore.setLoading(false));
|
|
5293
|
+
var inputId = document.getElementById(id);
|
|
5288
5294
|
var input = document.getElementById('import-student');
|
|
5295
|
+
var importClass = document.getElementById('import-classReflection');
|
|
5296
|
+
inputId && (inputId.value = "");
|
|
5289
5297
|
input && (input.value = "");
|
|
5298
|
+
importClass && (importClass.value = "");
|
|
5290
5299
|
};
|
|
5291
5300
|
|
|
5292
5301
|
if (!type || !file) return Promise.resolve();
|
|
5293
5302
|
dispatch(marioCore.setLoading(true));
|
|
5294
5303
|
|
|
5295
|
-
var
|
|
5296
|
-
|
|
5297
|
-
formData.append("file", file, file.name);
|
|
5298
|
-
return Promise.resolve(importStudentCSV(formData)).then(function () {
|
|
5304
|
+
var _temp9 = _catch(function () {
|
|
5305
|
+
function _temp5() {
|
|
5299
5306
|
dispatch(marioCore.setAlert({
|
|
5300
5307
|
type: "success",
|
|
5301
5308
|
message: "Import CSV successfully"
|
|
5302
5309
|
}));
|
|
5303
|
-
}
|
|
5310
|
+
}
|
|
5311
|
+
|
|
5312
|
+
var formData = new FormData();
|
|
5313
|
+
formData.append("file", file, file.name);
|
|
5314
|
+
|
|
5315
|
+
var _temp4 = function () {
|
|
5316
|
+
if (isCheckDomainIBS) {
|
|
5317
|
+
var _temp10 = function _temp10() {
|
|
5318
|
+
var _temp = function () {
|
|
5319
|
+
if (type == CSVType.ClassReflection) {
|
|
5320
|
+
return Promise.resolve(importClassReflectionCSV(formData)).then(function () {});
|
|
5321
|
+
}
|
|
5322
|
+
}();
|
|
5323
|
+
|
|
5324
|
+
if (_temp && _temp.then) return _temp.then(function () {});
|
|
5325
|
+
};
|
|
5326
|
+
|
|
5327
|
+
var _temp11 = function () {
|
|
5328
|
+
if (type == CSVType.Students) {
|
|
5329
|
+
return Promise.resolve(importStudentCSV(formData)).then(function () {});
|
|
5330
|
+
}
|
|
5331
|
+
}();
|
|
5332
|
+
|
|
5333
|
+
return _temp11 && _temp11.then ? _temp11.then(_temp10) : _temp10(_temp11);
|
|
5334
|
+
} else {
|
|
5335
|
+
return Promise.resolve(importCSV(formData, type.toString())).then(function () {});
|
|
5336
|
+
}
|
|
5337
|
+
}();
|
|
5338
|
+
|
|
5339
|
+
return _temp4 && _temp4.then ? _temp4.then(_temp5) : _temp5(_temp4);
|
|
5304
5340
|
}, function (err) {
|
|
5305
5341
|
var _err$response, _err$response$data;
|
|
5306
5342
|
|
|
@@ -5310,7 +5346,7 @@ var useCSVImport = function useCSVImport() {
|
|
|
5310
5346
|
}));
|
|
5311
5347
|
});
|
|
5312
5348
|
|
|
5313
|
-
return Promise.resolve(
|
|
5349
|
+
return Promise.resolve(_temp9 && _temp9.then ? _temp9.then(_temp8) : _temp8(_temp9));
|
|
5314
5350
|
} catch (e) {
|
|
5315
5351
|
return Promise.reject(e);
|
|
5316
5352
|
}
|
|
@@ -5318,7 +5354,7 @@ var useCSVImport = function useCSVImport() {
|
|
|
5318
5354
|
|
|
5319
5355
|
var onConfirm = function onConfirm(values) {
|
|
5320
5356
|
try {
|
|
5321
|
-
var
|
|
5357
|
+
var _temp14 = function _temp14() {
|
|
5322
5358
|
dispatch(marioCore.setLoading(false));
|
|
5323
5359
|
var input = document.getElementById(id);
|
|
5324
5360
|
input && (input.value = "");
|
|
@@ -5327,7 +5363,7 @@ var useCSVImport = function useCSVImport() {
|
|
|
5327
5363
|
if (!dataFile || !dataFile) return Promise.resolve();
|
|
5328
5364
|
dispatch(marioCore.setLoading(true));
|
|
5329
5365
|
|
|
5330
|
-
var
|
|
5366
|
+
var _temp15 = _catch(function () {
|
|
5331
5367
|
var formData = new FormData();
|
|
5332
5368
|
formData.append("file", dataFile, dataFile.name);
|
|
5333
5369
|
formData.append("teacherName", values.teacherName);
|
|
@@ -5351,7 +5387,7 @@ var useCSVImport = function useCSVImport() {
|
|
|
5351
5387
|
}));
|
|
5352
5388
|
});
|
|
5353
5389
|
|
|
5354
|
-
return Promise.resolve(
|
|
5390
|
+
return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(_temp14) : _temp14(_temp15));
|
|
5355
5391
|
} catch (e) {
|
|
5356
5392
|
return Promise.reject(e);
|
|
5357
5393
|
}
|
|
@@ -5370,7 +5406,8 @@ var useCSVImport = function useCSVImport() {
|
|
|
5370
5406
|
dataFile: dataFile,
|
|
5371
5407
|
setDataFile: setDataFile,
|
|
5372
5408
|
setArrStudent: setArrStudent,
|
|
5373
|
-
arrStudent: arrStudent
|
|
5409
|
+
arrStudent: arrStudent,
|
|
5410
|
+
isCheckDomainIBS: isCheckDomainIBS
|
|
5374
5411
|
};
|
|
5375
5412
|
};
|
|
5376
5413
|
|
|
@@ -5394,13 +5431,13 @@ var CSVImport = function CSVImport() {
|
|
|
5394
5431
|
dataFile = _useCSVImport.dataFile,
|
|
5395
5432
|
setDataFile = _useCSVImport.setDataFile,
|
|
5396
5433
|
setArrStudent = _useCSVImport.setArrStudent,
|
|
5397
|
-
arrStudent = _useCSVImport.arrStudent,
|
|
5398
5434
|
buttons = _useCSVImport.buttons,
|
|
5399
|
-
upload = _useCSVImport.upload
|
|
5435
|
+
upload = _useCSVImport.upload,
|
|
5436
|
+
isCheckDomainIBS = _useCSVImport.isCheckDomainIBS;
|
|
5400
5437
|
|
|
5401
5438
|
return React__default.createElement("div", {
|
|
5402
5439
|
className: "animated fadeIn pt-3"
|
|
5403
|
-
}, React__default.createElement(reactstrap.Input, {
|
|
5440
|
+
}, isCheckDomainIBS ? React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Input, {
|
|
5404
5441
|
className: "d-none",
|
|
5405
5442
|
type: "file",
|
|
5406
5443
|
id: "import-student",
|
|
@@ -5408,6 +5445,14 @@ var CSVImport = function CSVImport() {
|
|
|
5408
5445
|
return upload(e.target.files[0]);
|
|
5409
5446
|
},
|
|
5410
5447
|
accept: "text/csv"
|
|
5448
|
+
}), React__default.createElement(reactstrap.Input, {
|
|
5449
|
+
className: "d-none",
|
|
5450
|
+
type: "file",
|
|
5451
|
+
id: "import-classReflection",
|
|
5452
|
+
onChange: function onChange(e) {
|
|
5453
|
+
return upload(e.target.files[0]);
|
|
5454
|
+
},
|
|
5455
|
+
accept: "text/csv"
|
|
5411
5456
|
}), React__default.createElement("div", {
|
|
5412
5457
|
className: "class-reflection"
|
|
5413
5458
|
}, React__default.createElement(formik.Formik, {
|
|
@@ -5421,11 +5466,8 @@ var CSVImport = function CSVImport() {
|
|
|
5421
5466
|
actions.resetForm();
|
|
5422
5467
|
}
|
|
5423
5468
|
}, function (formProps) {
|
|
5424
|
-
var
|
|
5425
|
-
|
|
5426
|
-
errors = formProps.errors,
|
|
5427
|
-
handleSubmit = formProps.handleSubmit,
|
|
5428
|
-
handleChange = formProps.handleChange;
|
|
5469
|
+
var touched = formProps.touched,
|
|
5470
|
+
errors = formProps.errors;
|
|
5429
5471
|
return React__default.createElement(reactstrap.Row, {
|
|
5430
5472
|
className: "mb-2"
|
|
5431
5473
|
}, React__default.createElement(reactstrap.Input, {
|
|
@@ -5446,55 +5488,11 @@ var CSVImport = function CSVImport() {
|
|
|
5446
5488
|
md: 12,
|
|
5447
5489
|
className: "mb-2"
|
|
5448
5490
|
}, React__default.createElement(marioCore.RequiredLabel, {
|
|
5449
|
-
text: "Class
|
|
5450
|
-
}), React__default.createElement(reactstrap.Input, {
|
|
5451
|
-
name: "teacherName",
|
|
5452
|
-
value: values.teacherName,
|
|
5453
|
-
type: "text",
|
|
5454
|
-
onChange: function onChange(e) {
|
|
5455
|
-
handleChange(e);
|
|
5456
|
-
}
|
|
5457
|
-
}), touched.teacherName && errors.teacherName && React__default.createElement(marioCore.ErrorHandler, {
|
|
5458
|
-
text: errors.teacherName
|
|
5459
|
-
})), React__default.createElement(reactstrap.Col, {
|
|
5460
|
-
md: 12,
|
|
5461
|
-
className: "mb-2"
|
|
5462
|
-
}, React__default.createElement(marioCore.RequiredLabel, {
|
|
5463
|
-
text: "Class Teacher Email"
|
|
5464
|
-
}), React__default.createElement(reactstrap.Input, {
|
|
5465
|
-
name: "teacherEmail",
|
|
5466
|
-
value: values.teacherEmail,
|
|
5467
|
-
type: "text",
|
|
5468
|
-
onChange: function onChange(e) {
|
|
5469
|
-
handleChange(e);
|
|
5470
|
-
}
|
|
5471
|
-
}), touched.teacherEmail && errors.teacherEmail && React__default.createElement(marioCore.ErrorHandler, {
|
|
5472
|
-
text: errors.teacherEmail
|
|
5473
|
-
})), React__default.createElement(reactstrap.Col, {
|
|
5474
|
-
md: 12,
|
|
5475
|
-
className: "mb-2"
|
|
5476
|
-
}, React__default.createElement(reactstrap.Label, null, "Students"), React__default.createElement(StudentSelector, {
|
|
5477
|
-
onChange: function onChange(e) {
|
|
5478
|
-
setArrStudent(e);
|
|
5479
|
-
formProps.setFieldValue("studentIds", e.map(function (i) {
|
|
5480
|
-
return i.value;
|
|
5481
|
-
}) || []);
|
|
5482
|
-
},
|
|
5483
|
-
value: arrStudent
|
|
5484
|
-
})), React__default.createElement(reactstrap.Col, {
|
|
5485
|
-
md: 12,
|
|
5486
|
-
className: "mb-2"
|
|
5487
|
-
}, touched.studentIds && errors.studentIds && React__default.createElement(marioCore.ErrorHandler, {
|
|
5488
|
-
text: errors.studentIds
|
|
5489
|
-
})), React__default.createElement(reactstrap.Col, {
|
|
5490
|
-
md: 12,
|
|
5491
|
-
className: "mb-2"
|
|
5492
|
-
}, React__default.createElement(marioCore.RequiredLabel, {
|
|
5493
|
-
text: "Upload File Class Reflection"
|
|
5491
|
+
text: "Import Class Reflection"
|
|
5494
5492
|
}), React__default.createElement(UploadCSVButton, {
|
|
5495
5493
|
key: "Import class reflections",
|
|
5496
|
-
htmlFor:
|
|
5497
|
-
text: "Import
|
|
5494
|
+
htmlFor: "import-classReflection",
|
|
5495
|
+
text: "Import Class Reflection",
|
|
5498
5496
|
isDisabled: isLoading,
|
|
5499
5497
|
backgroundColor: "#e74c3c",
|
|
5500
5498
|
onClick: function onClick() {
|
|
@@ -5511,15 +5509,7 @@ var CSVImport = function CSVImport() {
|
|
|
5511
5509
|
className: "mb-2"
|
|
5512
5510
|
}, touched.file && errors.file && React__default.createElement(marioCore.ErrorHandler, {
|
|
5513
5511
|
text: errors.file
|
|
5514
|
-
})), React__default.createElement(reactstrap.Col, {
|
|
5515
|
-
md: 12
|
|
5516
|
-
}, React__default.createElement(reactstrap.Button, {
|
|
5517
|
-
color: "primary",
|
|
5518
|
-
className: "float-right",
|
|
5519
|
-
onClick: function onClick() {
|
|
5520
|
-
return handleSubmit();
|
|
5521
|
-
}
|
|
5522
|
-
}, "Import"), ' '))), React__default.createElement(reactstrap.Col, {
|
|
5512
|
+
})))), React__default.createElement(reactstrap.Col, {
|
|
5523
5513
|
md: 6,
|
|
5524
5514
|
className: "mb-2"
|
|
5525
5515
|
}, React__default.createElement(reactstrap.Row, null, React__default.createElement(reactstrap.Col, {
|
|
@@ -5539,7 +5529,28 @@ var CSVImport = function CSVImport() {
|
|
|
5539
5529
|
}
|
|
5540
5530
|
});
|
|
5541
5531
|
})))));
|
|
5542
|
-
})))
|
|
5532
|
+
}))) : React__default.createElement(React__default.Fragment, null, React__default.createElement(reactstrap.Input, {
|
|
5533
|
+
className: "d-none",
|
|
5534
|
+
type: "file",
|
|
5535
|
+
id: id,
|
|
5536
|
+
onChange: function onChange(e) {
|
|
5537
|
+
return upload(e.target.files[0]);
|
|
5538
|
+
},
|
|
5539
|
+
accept: "text/csv"
|
|
5540
|
+
}), React__default.createElement("div", {
|
|
5541
|
+
className: "d-flex align-items-center"
|
|
5542
|
+
}, buttons.map(function (button) {
|
|
5543
|
+
return React__default.createElement(UploadCSVButton, {
|
|
5544
|
+
key: button.text,
|
|
5545
|
+
htmlFor: id,
|
|
5546
|
+
text: button.text,
|
|
5547
|
+
isDisabled: isLoading,
|
|
5548
|
+
backgroundColor: button.backgroundColor,
|
|
5549
|
+
onClick: function onClick() {
|
|
5550
|
+
return setType(button.type);
|
|
5551
|
+
}
|
|
5552
|
+
});
|
|
5553
|
+
}))));
|
|
5543
5554
|
};
|
|
5544
5555
|
|
|
5545
5556
|
var schema$5 = yup.object({
|