Skip to content
This repository has been archived by the owner on Sep 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from wellingWilliam/create-upgraded
Browse files Browse the repository at this point in the history
Create & Upgrade
  • Loading branch information
wwelling committed May 4, 2016
2 parents 3b012a2 + a7a178a commit a7053d9
Show file tree
Hide file tree
Showing 26 changed files with 120 additions and 126 deletions.
18 changes: 5 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,14 @@
"postinstall": "typings install"
},
"dependencies": {
"angular2": "2.0.0-beta.15",
"angular2-express-engine": "0.10.0",
"angular2-hapi-engine": "0.10.1",
"angular2-universal": "0.94.2",
"angular2-universal-polyfills": "0.4.1",
"angular2": "2.0.0-beta.17",
"angular2-universal": "0.99.0",
"bootstrap": "3.3.6",
"css": "2.2.1",
"es6-shim": "0.35.0",
"express": "4.13.4",
"ng2-translate": "1.11.1",
"ng2-translate": "2.0.0",
"object-hash": "1.1.2",
"parse5": "1.5.0",
"preboot": "2.0.7",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.6.12"
"preboot": "2.0.9",
"rxjs": "5.0.0-beta.6"
},
"devDependencies": {
"commander": "2.9.0",
Expand Down
45 changes: 26 additions & 19 deletions src/app/boot.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
import 'angular2-universal/polyfills';
import {prebootComplete} from 'angular2-universal';

import {bootstrap} from 'angular2/platform/browser';
import {HTTP_PROVIDERS, Http} from 'angular2/http';
import {ROUTER_PROVIDERS} from 'angular2/router';
import {FORM_PROVIDERS} from 'angular2/common';
import {enableProdMode, provide} from 'angular2/core';
import {
bootstrap,
enableProdMode,
prebootComplete,
BROWSER_ROUTER_PROVIDERS,
BROWSER_HTTP_PROVIDERS} from 'angular2-universal';

import {Http} from 'angular2/http';

import {provide} from 'angular2/core';

import {
TranslateLoader,
TranslateStaticLoader, TranslateService
TranslateStaticLoader,
TranslateService
} from "ng2-translate/ng2-translate";

import {AppComponent} from './app.component';
import {DSpaceService} from './dspace/services/dspace.service';
import {AuthorizationService} from './dspace/authorization/services/authorization.service';
import {BreadcrumbService} from './navigation/services/breadcrumb.service';
import {PaginationService} from './navigation/services/pagination.service';
import {ContextProviderService} from './dspace/services/context-provider.service';
import {DSpaceConstants} from './dspace/dspace.constants';
import {DSpaceDirectory} from './dspace/dspace.directory';
import {DSpaceService} from './dspace/services/dspace.service';
import {GoogleScholarMetadataService} from './utilities/services/google-scholar-metadata.service.ts';
import {HttpService} from './utilities/services/http.service';
import {MetadataHelper} from './utilities/metadata.helper';
import {MetaTagService} from "./utilities/meta-tag/meta-tag.service";
import {StorageService} from './utilities/services/storage.service';
import {PaginationService} from './navigation/services/pagination.service';
import {PagingStoreService} from './dspace/services/paging-store.service';
import {ContextProviderService} from './dspace/services/context-provider.service';
import {DSpaceDirectory} from './dspace/dspace.directory';
import {DSpaceConstants} from './dspace/dspace.constants';
import {StorageService} from './utilities/services/storage.service';

// Disable Angular 2's "development mode".
// See: https://angular.io/docs/ts/latest/api/core/enableProdMode-function.html
Expand All @@ -39,24 +46,24 @@ enableProdMode();
* http://blog.thoughtram.io/angular/2015/05/18/dependency-injection-in-angular-2.html
**/
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
HTTP_PROVIDERS,
FORM_PROVIDERS,
...BROWSER_ROUTER_PROVIDERS,
...BROWSER_HTTP_PROVIDERS,
provide(TranslateLoader, {
useFactory: (http: Http) => new TranslateStaticLoader(http, 'i18n', '.json'),
deps: [Http]
}),
AuthorizationService,
BreadcrumbService,
ContextProviderService,
DSpaceConstants,
DSpaceDirectory,
DSpaceService,
GoogleScholarMetadataService,
HttpService,
ContextProviderService,
MetadataHelper,
MetaTagService,
PaginationService,
PagingStoreService,
StorageService,
TranslateService
])
.then(prebootComplete);
]).then(prebootComplete);
19 changes: 16 additions & 3 deletions src/app/dspace/authorization/components/login-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {FormModal, ModalAction} from '../../../utilities/components/form-modal.c
directives: [FormModal],
pipes: [TranslatePipe],
template: `
<form-modal
<form-modal *ngIf="active"
id="login"
[title]="'login.title'"
[cancel-label]="'login.cancel'"
Expand All @@ -25,7 +25,7 @@ import {FormModal, ModalAction} from '../../../utilities/components/form-modal.c
<fieldset class="form-group" [class.has-error]="!loginEmail.valid && !loginEmail.pristine">
<label for="login-email">{{'login.email-gloss' | translate}}</label>
<input type="email"
<input type="text"
id="login-email"
placeholder="{{'login.email-placeholder' | translate}}"
[(ngModel)]="email"
Expand Down Expand Up @@ -73,6 +73,8 @@ import {FormModal, ModalAction} from '../../../utilities/components/form-modal.c
`
})
export class LoginFormComponent {

private active: boolean = true;

/**
* Actual FormModal used to show and hide modal.
Expand Down Expand Up @@ -139,7 +141,7 @@ export class LoginFormComponent {
this.authorization.status(token).subscribe(response => {
this.login.hide();
this.login.finished();
this.unauthorized = false;
this.reset();
},
error => {
this.unauthorized = true;
Expand All @@ -152,6 +154,17 @@ export class LoginFormComponent {
this.login.finished();
});
}
else if(action == ModalAction.CANCEL) {
this.reset();
}
}

reset(): void {
this.email = '';
this.password = '';
this.active = false;
this.unauthorized = false;
setTimeout(() => this.active = true, 0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,8 @@ export class AuthorizationService {
let statusResponse: Observable<Response> = this.dspace.status(token);

statusResponse.subscribe(response => {
console.log(response);
this.user = new User(response);

console.log(this.user);

//{
// this.storageService.store('email', email);
// this.storageService.store('token', token);
Expand Down
4 changes: 2 additions & 2 deletions src/app/dspace/components/item-create.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {Metadatum} from '../models/metadatum.model';
</tr>
</thead>
<tbody>
<tr *ngFor="#input of metadatumInputs">
<tr *ngFor="let input of metadatumInputs">
<td>
<div class="row">
<div class="col-md-11 col-xs-10">
Expand All @@ -71,7 +71,7 @@ import {Metadatum} from '../models/metadatum.model';
<textarea *ngIf="input.type == 'TEXTAREA'" class="form-control" id="{{input.id}}" [(ngModel)]="input.value" ngControl="{{input.id}}"></textarea>
<select *ngIf="input.type == 'SELECT'" class="form-control" id="{{input.id}}" [(ngModel)]="input.value" ngControl="{{input.id}}">
<option *ngFor="#option of input.options" [value]="option.value">{{ option.gloss }}</option>
<option *ngFor="let option of input.options" [value]="option.value">{{ option.gloss }}</option>
</select>
<span [hidden]="form.controls[input.id].valid || form.controls[input.id].pristine" class="validaiton-helper text-danger">
Expand Down
2 changes: 1 addition & 1 deletion src/app/dspace/components/item-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {PaginationComponent} from '../../navigation/components/pagination.compon
inputs: ['items', 'collection'],
template:
`
<div *ngFor="#item of items" id="list-entries" class="row item-list-row"> <!-- for each item, we create an item-list-entry element -->
<div *ngFor="let item of items" id="list-entries" class="row item-list-row"> <!-- for each item, we create an item-list-entry element -->
<list-entry [item]="item"></list-entry>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/app/dspace/components/item.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Component} from 'angular2/core';
import {RouteConfig, RouterOutlet, RouteParams, CanDeactivate, ComponentInstruction, Location} from 'angular2/router';
import {RouteConfig, RouterOutlet, RouteParams, CanDeactivate, ComponentInstruction} from 'angular2/router';

import {DSpaceDirectory} from '../dspace.directory';
import {BreadcrumbService} from '../../navigation/services/breadcrumb.service';
Expand Down
3 changes: 1 addition & 2 deletions src/app/dspace/components/item/authors.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ import {ViewElementComponent} from './view-element.component';
directives: [ViewElementComponent],
inputs: ['itemData'],
pipes: [TranslatePipe],
providers: [MetadataHelper],
template:
`
<view-element [header]="componentTitle | translate"> <!--translate it before passing it on.-->
<!-- calls the view-element component, which takes care of rendering based on the 'header' input parameter, and the child elements of view-element-->
<div *ngFor="#metadatum of filteredFields;">
<div *ngFor="let metadatum of filteredFields;">
<p>{{ metadatum.value }}</p>
</div>
</view-element>
Expand Down
2 changes: 1 addition & 1 deletion src/app/dspace/components/item/bitstreams.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {ViewElementComponent} from './view-element.component'
pipes: [TranslatePipe],
template: `
<view-element [header]="componentTitle | translate">
<div *ngFor="#bitstream of itemBitstreams;">
<div *ngFor="let bitstream of itemBitstreams;">
<a [attr.href]="bitstream.retrieveLink">
<i aria-hidden="true" class="glyphicon glyphicon-file"></i>
<span>{{bitstream.name}}</span>
Expand Down
2 changes: 1 addition & 1 deletion src/app/dspace/components/item/collection.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {ViewElementComponent} from './view-element.component';
directives: [ROUTER_DIRECTIVES, ViewElementComponent],
pipes: [TranslatePipe],
template: `
<view-element [header]="componentTitle| translate">
<view-element [header]="componentTitle | translate">
<a *ngIf="hasValidParent()" [routerLink]="[itemParent.component, {id: itemParent.id}]">{{ itemParent.name }}</a>
</view-element>
`
Expand Down
2 changes: 1 addition & 1 deletion src/app/dspace/components/item/date.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {ViewElementComponent} from './view-element.component'
pipes: [TruncateDatePipe, TranslatePipe],
template: `
<view-element [header]="componentTitle | translate">
<div *ngFor="#metadatum of filteredFields">
<div *ngFor="let metadatum of filteredFields">
<p>{{ metadatum.value | truncatedate}}</p>
<!-- calling our truncate pipe without arguments will is equals to truncate : 10. (Display the first 10 chars or the string) -->
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {ViewElementComponent} from '../view-element.component';
template: `
<view-element [header]="componentTitle | translate">
<div id="bitstreams" class="file-list">
<div *ngFor="#bitstream of itemBitstreams;" class="file-wrapper row">
<div *ngFor="let bitstream of itemBitstreams;" class="file-wrapper row">
<!-- thumbnail -->
<div class="col-xs-6 col-sm-3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {ViewElementComponent} from '../view-element.component';
</tr>
</thead>
<tbody>
<tr *ngFor="#metadatum of itemData">
<tr *ngFor="let metadatum of itemData">
<td>{{ metadatum.key }}</td>
<td class="word-break">{{ metadatum.value }}</td>
<td>{{ metadatum.language }}</td>
Expand Down
3 changes: 2 additions & 1 deletion src/app/dspace/components/item/list/list-entry.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {Item} from '../../../models/item.model';
@Component({
selector: 'list-entry',
inputs: ['item'],
directives:[ListMetadataComponent, ThumbnailComponent],
directives:[ListMetadataComponent,
ThumbnailComponent],
pipes: [TranslatePipe],
template:
`
Expand Down
41 changes: 19 additions & 22 deletions src/app/dspace/components/item/list/list-metadata.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,60 +18,57 @@ import {ObjectUtil} from "../../../../utilities/commons/object.util";
selector: 'item-list-metadata',
inputs: ['item'],
directives: [ROUTER_DIRECTIVES],
pipes: [TranslatePipe, TruncatePipe, TruncateDatePipe],
pipes: [TranslatePipe,
TruncatePipe,
TruncateDatePipe],
template:
`
<!-- create a router link to the simple item-view -->
<a [routerLink]="[item.component, { id: item.id }]" class="item-list-url">{{ item.name }}</a>
<h5 *ngIf="shouldRenderHeader()">{{author}} <span *ngIf="shouldRenderDate()">({{date | truncatedate}})</span></h5>
<!-- the abstract truncated -->
<p *ngIf="shouldRenderAbstract()">{{abstract | truncate : 200}}</p>
`
})

export class ListMetadataComponent
{
export class ListMetadataComponent {

private item : Item;
private author : String;
private abstract : String;
private date : String;
private item: Item;

ngOnInit() {
let helper = new MetadataHelper();
let filteredData:Metadatum[] = helper.filterMetadata(this.item.metadata, ["dc.contributor.author", "dc.creator", "dc.contributor", "dc.description.abstract","dc.date.accessioned"]);
private author: String;

private abstract: String;

if (filteredData != null)
{
private date: String;

constructor(private metadataHelper: MetadataHelper) {}

ngOnInit() {
let filteredData: Array<Metadatum> = this.metadataHelper.filterMetadata(this.item.metadata, ["dc.contributor.author", "dc.creator", "dc.contributor", "dc.description.abstract", "dc.date.accessioned"]);
if (filteredData != null) {
for (let i:number = 0; i < filteredData.length; i++) {
if (filteredData[i].element == "creator") {
this.author = (filteredData[i].value);
}
if (filteredData[i].element == "description" && filteredData[i].value!="Not available") {
this.abstract = filteredData[i].value;
}
if(filteredData[i].element == "date")
{
if(filteredData[i].element == "date") {
this.date = filteredData[i].value;
}
}
}
}

shouldRenderHeader()
{
shouldRenderHeader(): boolean {
return ObjectUtil.hasValue(this.author) || this.shouldRenderDate();
}

shouldRenderDate()
{
shouldRenderDate(): boolean {
return ObjectUtil.hasValue(this.date);
}

shouldRenderAbstract()
{
shouldRenderAbstract(): boolean {
return ObjectUtil.hasValue(this.abstract);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/app/dspace/components/item/metadata.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import {ViewElementComponent} from './view-element.component';
selector: 'item-metadata',
inputs: ['itemData'],
directives: [ViewElementComponent],
providers: [MetadataHelper],
pipes: [TranslatePipe],
template: `
<view-element [header]="componentTitle | translate">
<div class="item" *ngFor="#metadatum of filteredFields.metadata">
<div class="item" *ngFor="let metadatum of filteredFields.metadata">
<strong >{{ metadatum.key }}</strong>
<p>{{ metadatum.value }}</p>
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/app/dspace/components/item/uri.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import {ViewElementComponent} from './view-element.component';
selector: 'item-uri',
inputs: ['itemData'],
directives: [ViewElementComponent],
providers: [MetadataHelper],
pipes: [TranslatePipe],
template: `
<view-element [header]="componentTitle | translate">
<div *ngFor="#metadatum of filteredFields;">
<div *ngFor="let metadatum of filteredFields;">
<a [attr.href]="metadatum.value">{{ metadatum.value}}</a> <!-- renders a clickable URI (in this case of the value inside dc.identifier.uri, e.g the handle)-->
</div>
</view-element>
Expand Down
Loading

0 comments on commit a7053d9

Please sign in to comment.