diff --git a/server.js b/server.js
index 4d2f793..5043c03 100644
--- a/server.js
+++ b/server.js
@@ -46,6 +46,7 @@ var orcidLogger = new console.Console(orcidOutput, orcidErrorOutput);
//Endpoints
var CONFIG = '/config';
var CREATE_SMID_AUTHORIZE = '/create-smid-authorize';
+var CREATE_SMID_EMAIL = '/create-smid-email';
var CONFIG = '/config';
var CREATE_SMID_URI = '/create-smid-redirect';
var COLLECTION_DETAILS = '/:publicKey/details';
@@ -210,12 +211,13 @@ app.post(EMAIL_SMID, function(req, res) {
console.log(error);
if (body != null && body.message != null && body.message.includes("Great job"))
res.status(200).json({'email': data.email, 'redirect': create_smid_authorization_uri }); // using test credentials
+
else
res.status(400).json({'error':error, 'body': body});
} else {
console.log("mailgun body:");
console.log(body);
- res.status(200).json({'email': data.email});
+ res.status(200).json({'email': data.email, 'redirect': create_smid_authorization_uri });
}
});
});
@@ -273,6 +275,10 @@ app.get([COLLECTION_EDIT], function(req, res) { // Index page
});
});
+app.get([CREATE_SMID_EMAIL, '/'], function(req, res) { // Index page
+ res.status(200).sendFile(index_file);
+});
+
app.get([COLLECTION_SHARE, ADD_ID_SUCCESS, ADD_ID_ERROR], function(req, res) { // Index page
smidManger.detailsExist(req.params.publicKey, function(err, bool) {
if (bool == true)
@@ -281,7 +287,3 @@ app.get([COLLECTION_SHARE, ADD_ID_SUCCESS, ADD_ID_ERROR], function(req, res) { /
res.sendFile(PAGE_404);
});
});
-
-app.get('/', function(req, res) { // Index page
- res.status(200).sendFile(index_file);
-});
\ No newline at end of file
diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts
index f40274e..f99ad7e 100644
--- a/src/app/app-routing.module.ts
+++ b/src/app/app-routing.module.ts
@@ -4,6 +4,7 @@ import { Routes, RouterModule } from '@angular/router';
import { AddIdErrorComponent } from './add-id-error/add-id-error.component';
import { AddIdSuccessComponent } from './add-id-success/add-id-success.component';
import { CollectionEditComponent } from './collection-edit/collection-edit.component';
+import { CollectionEmailComponent } from './collection-email/collection-email.component';
import { CollectionShareComponent } from './collection-share/collection-share.component';
import { PageHomeComponent } from './page-home/page-home.component';
@@ -12,6 +13,10 @@ const routes: Routes = [
component: PageHomeComponent, // Authenticate -> Redirects to editCollection
path: ''
},
+ {
+ component: CollectionEmailComponent,
+ path: 'create-smid-email'
+ },
/* Be sure to put urls with :dinamicParam after the ones that are static. Other way the evaluation will
redirect to them instead of the expected url. */
{
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 3fe38db..b0f7687 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -19,6 +19,7 @@ import { OrcidUtilService } from './shared/orcid-util/orcid-util.service';
import { FooterComponent } from './footer/footer.component';
import { HeaderComponent } from './header/header.component';
import { PageHomeComponent } from './page-home/page-home.component';
+import { CollectionEmailComponent } from './collection-email/collection-email.component';
@NgModule({
@@ -30,7 +31,8 @@ import { PageHomeComponent } from './page-home/page-home.component';
CollectionShareComponent,
FooterComponent,
HeaderComponent,
- PageHomeComponent
+ PageHomeComponent,
+ CollectionEmailComponent,
],
imports: [
Angular2FontAwesomeModule,
diff --git a/src/app/collection-edit/collection-edit.component.html b/src/app/collection-edit/collection-edit.component.html
index 27d681e..0371062 100644
--- a/src/app/collection-edit/collection-edit.component.html
+++ b/src/app/collection-edit/collection-edit.component.html
@@ -74,36 +74,8 @@
Collection Links Hold onto these!
-
-
Uh oh, email not sent! Check the address and try again.
-
Success! Links sent to {{email}}
-
Administration Link
+
Administration Link
Use this link to edit collection details:
{{windowLocationOrigin}}/{{publicKey}}/edit/{{privateKey}}
Share Link
diff --git a/src/app/collection-edit/collection-edit.component.ts b/src/app/collection-edit/collection-edit.component.ts
index bdbfdc5..7aa47fc 100644
--- a/src/app/collection-edit/collection-edit.component.ts
+++ b/src/app/collection-edit/collection-edit.component.ts
@@ -105,33 +105,6 @@ export class CollectionEditComponent implements OnInit, OnDestroy {
this.sub.unsubscribe();
}
- submitEmail( form: any ): void {
- this.formEmailSubmitted = true;
- var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
- if (re.test(form.email) == false) {
- console.log("invalid email");
- this.showEmailErrorMessage = true;
- this.showEmailSuccessMessage = false;
- } else {
- var formString = JSON.stringify(form);
- this.collectionService.editEmail( formString, this.publicKey, this.privateKey ).subscribe(
- (response) => {
- this.response = response;
- console.log(this.response);
- this.showEmailErrorMessage = false;
- this.showEmailSuccessMessage = true; // <- Update to change the status on the ajax call result
- },
- (err) => {
- console.log(err);
- this.showEmailErrorMessage = true;
- this.showEmailSuccessMessage = false;
-
- },
- () => {}
- );
- }
- }
-
submitForm( form: any ): void {
this.formSubmitted = true;
this.collectionService.editCollection( form, this.publicKey, this.privateKey ).subscribe(
diff --git a/src/app/collection-email/collection-email.component.html b/src/app/collection-email/collection-email.component.html
new file mode 100644
index 0000000..fa53cea
--- /dev/null
+++ b/src/app/collection-email/collection-email.component.html
@@ -0,0 +1,58 @@
+
+
+
+
+
Create a new iD collection
+
To get started, we'll need your email address
+
Used only to send collection editing instructions to you. We don't save or display this.
+
+
Oops, something went wrong. Check the address and try again.
+
Don't have an ORCID iD? Register for an iD and create your collection at the same time. Click 'Sign into ORCID' above, then 'Register now' on the next screen.
+
+
+
Thanks! To finish creating your collection, sign into ORCID.
+
+
+ Sign into ORCID
+
+
Don't have an ORCID iD? Register for an iD and create your collection at the same time. Click 'Sign into ORCID' above, then 'Register now' on the next screen.
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/collection-email/collection-email.component.scss b/src/app/collection-email/collection-email.component.scss
new file mode 100644
index 0000000..67c5b3a
--- /dev/null
+++ b/src/app/collection-email/collection-email.component.scss
@@ -0,0 +1,66 @@
+@import '../../variables';
+
+form p {
+ margin-bottom: 2rem;
+
+ &.form-control-label {
+ margin-bottom: 0;
+ }
+}
+
+legend {
+ color: $title-h1-font-color;
+ font: bold 2.5rem $font-stack;
+}
+
+small{
+ font-style: italic;
+ line-height: .8rem;
+ }
+
+.card .card {
+
+ background-color: $gray97;
+
+ h2 {
+ text-align: left;
+ }
+
+ h3 {
+ font: bold 1rem $font-stack;
+ margin: 1rem 0 0 0;
+ }
+
+ p {
+ margin: .1rem 0;
+ }
+
+ small{
+ font: italic 1rem $font-stack;
+ }
+
+ button {
+ float: left;
+ margin: 1rem 0 0 0;
+
+ fa {
+ color: $white;
+ }
+ }
+
+ .card-block {
+ padding-top: .5rem;
+ }
+
+ #collection-links{
+ a {
+ word-break: break-all;
+ }
+ }
+
+ div.text-success {
+ float: left;
+ margin: 1.5rem 0 0 1rem;
+ }
+
+}
\ No newline at end of file
diff --git a/src/app/collection-email/collection-email.component.spec.ts b/src/app/collection-email/collection-email.component.spec.ts
new file mode 100644
index 0000000..64c7758
--- /dev/null
+++ b/src/app/collection-email/collection-email.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { CollectionEmailComponent } from './collection-email.component';
+
+describe('CollectionEmailComponent', () => {
+ let component: CollectionEmailComponent;
+ let fixture: ComponentFixture
;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ CollectionEmailComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(CollectionEmailComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/collection-email/collection-email.component.ts b/src/app/collection-email/collection-email.component.ts
new file mode 100644
index 0000000..f9b222b
--- /dev/null
+++ b/src/app/collection-email/collection-email.component.ts
@@ -0,0 +1,59 @@
+import { Component, OnInit } from '@angular/core';
+
+import { Collection } from './../shared/collection/collection';
+import { CollectionService } from './../shared/collection/collection.service';
+
+@Component({
+ selector: 'app-collection-email',
+ templateUrl: './collection-email.component.html',
+ styleUrls: ['./collection-email.component.scss']
+})
+export class CollectionEmailComponent implements OnInit {
+ public publicKey: string;
+ public privateKey: string;
+ private response: any;
+
+ email: string;
+ formEmailSubmitted: boolean;
+ ngForm: any;
+ showEmailErrorMessage: boolean;
+ showEmailWarningMessage: boolean;
+
+ constructor(
+ private collectionService: CollectionService
+ ) {
+ this.email = '';
+ this.formEmailSubmitted = false
+ this.showEmailErrorMessage = false;
+ this.showEmailWarningMessage = false;
+ }
+
+ ngOnInit() {
+ }
+
+ submitEmail( form: any ): void {
+ this.formEmailSubmitted = true;
+ var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+ if (re.test(form.email) == false) {
+ console.log("invalid email");
+ this.showEmailErrorMessage = true;
+ } else {
+ var formString = JSON.stringify(form);
+ this.collectionService.editEmail(formString).subscribe(
+ (response) => {
+ this.response = response;
+ console.log(this.response);
+ var response_parsed = JSON.parse(JSON.stringify(this.response, null, 2));
+ this.showEmailErrorMessage = false;
+ window.location.replace(response_parsed.redirect + '&email=' + response_parsed.email);
+ },
+ (err) => {
+ console.log(err);
+ this.showEmailErrorMessage = true;
+ },
+ () => {}
+ );
+ }
+ }
+
+}
diff --git a/src/app/page-home/page-home.component.html b/src/app/page-home/page-home.component.html
index cf07c7e..58e05e4 100644
--- a/src/app/page-home/page-home.component.html
+++ b/src/app/page-home/page-home.component.html
@@ -4,12 +4,12 @@
- Create a new iD collection
+ Create a new iD collection
Collect authenticated ORCID iDs, just by sending a link!
Want to get ORCID iDs from attendees at your next conference or event? Or maybe from everyone in your research group/lab? Share My iD makes it simple!
- Create a new iD collection (anyone with an ORCID iD can create a new collection!)
+ Create a new iD collection (anyone with an ORCID iD can create a new collection!)
Share the collection URL with people whose ORCID iDs you want to get (or display the page on a laptop/tablet at your event).
Visit the collection URL to see and download iDs you've collected.
diff --git a/src/app/shared/collection/collection.service.ts b/src/app/shared/collection/collection.service.ts
index f35ae39..2247861 100644
--- a/src/app/shared/collection/collection.service.ts
+++ b/src/app/shared/collection/collection.service.ts
@@ -48,11 +48,11 @@ export class CollectionService {
).map(( res: Response ) => res.json()).catch(this.handleError);
}
- editEmail( data: any, publicKey, privateKey ): Observable
{
+ editEmail( data: any) {
const headers = new Headers({ 'Content-Type': 'application/json' });
const options = new RequestOptions({ headers: headers });
- return this.http.put(
- '/' + publicKey + '/details/' + privateKey + '/details/owner/email',
+ return this.http.post(
+ '/email-smid',
data,
options
).map(( res: Response ) => res.json()).catch(this.handleError);