Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
enasequence
webin-portal
Commits
fec8ca8a
Commit
fec8ca8a
authored
May 12, 2022
by
Rajkumar-D
Browse files
Changes for taxonomy attachment
parent
91bfcf47
Pipeline
#278480
passed with stages
in 5 minutes and 20 seconds
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
11 deletions
+54
-11
src/app/taxonomy-management/taxonomy-management.component.ts
src/app/taxonomy-management/taxonomy-management.component.ts
+43
-7
src/app/webin-rest.service.ts
src/app/webin-rest.service.ts
+11
-4
No files found.
src/app/taxonomy-management/taxonomy-management.component.ts
View file @
fec8ca8a
...
@@ -274,18 +274,22 @@ export class TaxonomyManagementComponent implements OnInit {
...
@@ -274,18 +274,22 @@ export class TaxonomyManagementComponent implements OnInit {
this
.
_webinAuthService
.
getSubmissionAccount
()
this
.
_webinAuthService
.
getSubmissionAccount
()
);
);
let
mail
=
{};
let
mail
=
{};
let
headerList
=
[
"
proposedName
"
,
"
nameType
"
,
"
host
"
,
"
projectId
"
,
"
description
"
]
mail
[
"
from
"
]
=
this
.
submissionAccount
[
"
submissionContacts
"
]
mail
[
"
from
"
]
=
this
.
submissionAccount
[
"
submissionContacts
"
]
.
filter
((
contact
)
=>
contact
.
mainContact
)
.
filter
((
contact
)
=>
contact
.
mainContact
)
.
map
((
contact
)
=>
contact
.
emailAddress
)[
0
];
.
map
((
contact
)
=>
contact
.
emailAddress
)[
0
];
mail
[
"
to
"
]
=
environment
.
taxonomySubmissionEmail
;
mail
[
"
to
"
]
=
environment
.
taxonomySubmissionEmail
;
this
.
constructTaxonContentAndSendMail
(
this
.
constructTaxonContentAndSendMail
(
function
(
taxonContent
,
thisObj
)
{
function
(
jsonContent
,
taxonContent
,
thisObj
)
{
mail
[
"
content
"
]
=
taxonContent
;
mail
[
"
content
"
]
=
taxonContent
;
mail
[
"
subject
"
]
=
"
Taxonomy Consultation -
"
+
taxonContent
.
match
(
proposedNameRegexp
)[
2
];
mail
[
"
subject
"
]
=
"
Taxonomy Consultation -
"
+
jsonContent
[
0
].
proposedName
;
mail
[
"
attachedFileName
"
]
=
"
taxonomy.csv
"
console
.
log
(
taxonContent
);
console
.
log
(
taxonContent
);
const
observable
:
Observable
<
string
>
=
thisObj
.
_webinRestService
.
sendTaxonEmail
(
const
observable
:
Observable
<
string
>
=
thisObj
.
_webinRestService
.
sendTaxonEmail
(
mail
mail
,
thisObj
.
convertToCSV
(
jsonContent
,
headerList
)
);
);
let
title
=
"
Taxonomy Registration
"
;
let
title
=
"
Taxonomy Registration
"
;
let
redirect
=
"
/taxonomy
"
let
redirect
=
"
/taxonomy
"
...
@@ -330,7 +334,8 @@ export class TaxonomyManagementComponent implements OnInit {
...
@@ -330,7 +334,8 @@ export class TaxonomyManagementComponent implements OnInit {
let
count
=
0
;
let
count
=
0
;
let
tableArr
=
let
tableArr
=
source
===
"
Form
"
?
this
.
validFormArray
:
this
.
validSpreadsheetArray
;
source
===
"
Form
"
?
this
.
validFormArray
:
this
.
validSpreadsheetArray
;
for
(
const
taxon
of
tableArr
)
{
// Remove the commented code if the taxonomy content is not needed in email body
/*for (const taxon of tableArr) {
contentStr += "\n";
contentStr += "\n";
contentStr += "Number " + ++count + "\n";
contentStr += "Number " + ++count + "\n";
contentStr += "Name type: " + taxon.nameType + "\n";
contentStr += "Name type: " + taxon.nameType + "\n";
...
@@ -339,10 +344,10 @@ export class TaxonomyManagementComponent implements OnInit {
...
@@ -339,10 +344,10 @@ export class TaxonomyManagementComponent implements OnInit {
contentStr += "Project / Study id: " + taxon.projectId + "\n";
contentStr += "Project / Study id: " + taxon.projectId + "\n";
contentStr += "Short description: " + taxon.description + "\n";
contentStr += "Short description: " + taxon.description + "\n";
contentStr += "\n";
contentStr += "\n";
}
}
*/
contentStr
+=
"
Dear ENA
"
+
"
\n\n
"
;
contentStr
+=
"
Dear ENA
"
+
"
\n\n
"
;
contentStr
+=
"
Please examine a
bove
"
+
count
+
"
organism
s
.
"
+
"
\n
"
;
contentStr
+=
"
Please examine a
ttached
organism
(s)
.
"
+
"
\n
"
;
contentStr
+=
"
Below are my contact details:
"
+
"
\n\n
"
;
contentStr
+=
"
Below are my contact details:
"
+
"
\n\n
"
;
contentStr
+=
"
Webin account id:
"
+
this
.
submissionAccount
[
"
id
"
]
+
"
\n
"
;
contentStr
+=
"
Webin account id:
"
+
this
.
submissionAccount
[
"
id
"
]
+
"
\n
"
;
contentStr
+=
contentStr
+=
...
@@ -358,7 +363,7 @@ export class TaxonomyManagementComponent implements OnInit {
...
@@ -358,7 +363,7 @@ export class TaxonomyManagementComponent implements OnInit {
)
+
)
+
"
\n\n
"
;
"
\n\n
"
;
contentStr
+=
"
Thank you and regards
"
;
contentStr
+=
"
Thank you and regards
"
;
callback
(
contentStr
,
thisComponent
);
callback
(
tableArr
,
contentStr
,
thisComponent
);
}
}
getContactName
(
contact
)
{
getContactName
(
contact
)
{
...
@@ -436,4 +441,35 @@ export class TaxonomyManagementComponent implements OnInit {
...
@@ -436,4 +441,35 @@ export class TaxonomyManagementComponent implements OnInit {
isBroker
():
boolean
{
isBroker
():
boolean
{
return
this
.
_webinAuthenticationService
.
isBroker
();
return
this
.
_webinAuthenticationService
.
isBroker
();
}
}
convertToCSV
(
objArray
,
headerList
)
{
let
array
=
typeof
objArray
!=
'
object
'
?
JSON
.
parse
(
objArray
)
:
objArray
;
let
str
=
''
;
let
row
=
'
Number,
'
;
for
(
let
index
=
0
;
index
<
headerList
.
length
;
index
++
)
{
row
+=
this
.
capitalize
(
headerList
[
index
])
+
'
,
'
;
}
//row = row.slice(0, -1);
str
+=
row
+
'
\r\n
'
;
for
(
let
i
=
0
;
i
<
array
.
length
;
i
++
)
{
let
line
=
i
+
1
+
'
,
'
;
for
(
let
j
=
0
;
j
<
headerList
.
length
;
j
++
)
{
let
head
=
headerList
[
j
];
line
+=
array
[
i
][
head
]
+
'
,
'
;
}
str
+=
line
+
'
\r\n
'
;
}
console
.
log
(
str
)
let
blob
=
new
Blob
([
str
],
{
type
:
'
text/csv
'
});
return
blob
;
}
capitalize
(
string
)
{
return
string
.
charAt
(
0
).
toUpperCase
()
+
string
.
slice
(
1
);
}
}
}
src/app/webin-rest.service.ts
View file @
fec8ca8a
...
@@ -81,8 +81,9 @@ export class WebinRestService implements WebinRestServiceInterface {
...
@@ -81,8 +81,9 @@ export class WebinRestService implements WebinRestServiceInterface {
}
}
private
postEmail
(
mail
)
{
private
postEmail
(
formData
)
{
return
this
.
_http
.
post
(
environment
.
webinRestUrl
+
'
/email
'
,
mail
);
const
headers
=
this
.
headers
();
return
this
.
_http
.
post
(
environment
.
webinRestUrl
+
'
/email
'
,
formData
,
{
headers
});
}
}
submitProjectXml
(
formData
)
{
submitProjectXml
(
formData
)
{
...
@@ -338,9 +339,15 @@ export class WebinRestService implements WebinRestServiceInterface {
...
@@ -338,9 +339,15 @@ export class WebinRestService implements WebinRestServiceInterface {
return
this
.
postTaxon
(
formData
);
return
this
.
postTaxon
(
formData
);
}
}
sendTaxonEmail
(
mail
:
any
)
{
sendTaxonEmail
(
mail
:
any
,
attachment
)
{
const
mailStr
=
JSON
.
stringify
(
mail
);
const
mailBytes
=
new
TextEncoder
().
encode
(
mailStr
);
console
.
log
(
'
** Send email for taxon **
'
);
console
.
log
(
'
** Send email for taxon **
'
);
return
this
.
postEmail
(
mail
)
const
formData
:
FormData
=
new
FormData
();
formData
.
append
(
"
mail
"
,
new
Blob
([
mailBytes
],
{
type
:
'
application/json
'
}));
formData
.
append
(
"
attachmentFile
"
,
attachment
,
"
taxonomy.csv
"
);
return
this
.
postEmail
(
formData
)
}
}
isValidTabSubmissionFile
(
blob
:
Blob
)
{
isValidTabSubmissionFile
(
blob
:
Blob
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment