diff --git a/src/common/ItemTypeUtil.tsx b/src/common/ItemTypeUtil.tsx
new file mode 100644
index 0000000..d01f265
--- /dev/null
+++ b/src/common/ItemTypeUtil.tsx
@@ -0,0 +1,142 @@
+import React from 'react';
+import { Link } from 'react-router-dom';
+import ItemUtil, { ItemBasicLang, ItemBasicChangeLog, ItemBasicIndex } from './ItemUtil';
+import IndexUtil from './IndexUtil';
+import DatabaseItemType from '../components/DatabaseItemType';
+
+class ItemTypeUtil {
+
+ static Language(props: { lang: ItemBasicLang }) {
+ const { lang } = props;
+ const langStr = {
+ eng: 'English',
+ jpn: 'Japanese',
+ fra: 'French',
+ deu: 'German',
+ esl: 'Spanish',
+ ita: 'Italian',
+ dut: 'Dutch',
+ sve: 'Swedish',
+ nor: 'Norwegian',
+ dan: 'Danish',
+ fin: 'Finnish',
+ por: 'Portuguese',
+ chi: 'Chinese',
+ kor: 'Korean',
+ }
+ if (!(lang in langStr)) {
+ return null;
+ }
+ const label = langStr[lang];
+ return ({label});
+ }
+
+ static FreeKeyword(props: { keyword: string[] }) {
+ const { keyword } = props;
+ if (keyword.length === 0) {
+ return null;
+ }
+ const label = keyword.join(', ');
+ return ({label});
+ }
+
+ static Contributer(props: { uname: string, name: string }) {
+ const { name, uname } = props;
+ const label = (name === '' ? uname : name + ' (' + uname + ')');
+ return ({label});
+ }
+
+ static Date(props: { date: number }) {
+ const { date } = props;
+ const d = new Date(date * 1000);
+ const monthStr = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+ const year = d.getFullYear();
+ const month = monthStr[d.getMonth()];
+ const mday = d.getDate();
+ const hour = d.getHours();
+ const min = d.getMinutes();
+ const sec = d.getSeconds();
+ const label = month + ' ' + mday + ', ' + year + ' ' + hour + ':' + min + ':' + sec;
+ return ({label});
+ }
+
+ static ChangeLogDate(props: { date: number }) {
+ const { date } = props;
+ const d = new Date(date * 1000);
+ const monthStr = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+ const year = d.getFullYear();
+ const month = monthStr[d.getMonth()];
+ const mday = d.getDate();
+ const label = month + ' ' + mday + ', ' + year + ' ';
+ return ({label});
+ }
+
+ static ChangeLog(props: {changelog: ItemBasicChangeLog[]}) {
+ const { changelog } = props;
+ if (changelog.length === 0) {
+ return null;
+ }
+ const elements = changelog.map((value, index) => {
+ return (
+
+ |
+ {value} |
+
+ );
+ });
+ return ();
+ }
+
+ static Author(props: { author: string[] }) {
+ const { author } = props;
+ if (author.length === 0) {
+ return null;
+ }
+ let evenodd = 'even';
+ const elements = author.map((value, index) => {
+ evenodd = evenodd === 'even' ? 'odd' : 'even';
+ return (| {value} |
);
+ });
+ return ();
+ }
+
+ static Index(props: { index: ItemBasicIndex[] }) {
+ const { index } = props;
+ if (index.length === 0) {
+ return null;
+ }
+ let evenodd = 'even';
+ const elements = index.map((value, index) => {
+ evenodd = evenodd === 'even' ? 'odd' : 'even';
+ const url = IndexUtil.getUrl(value.index_id);
+ return (| {value.title} |
);
+ });
+ return ();
+ }
+
+ static RelatedTo(props: { relatedTo: number[] }) {
+ const { relatedTo } = props;
+ if (relatedTo.length === 0) {
+ return null;
+ }
+ let evenodd = 'even';
+ const elements = relatedTo.map((value) => {
+ const item = ItemUtil.get(value);
+ if (item === null) {
+ return null;
+ }
+ evenodd = evenodd === 'even' ? 'odd' : 'even';
+ return ( |
);
+ });
+ return (
+
+
+ | Item summary |
+ {elements}
+
+
+ );
+ }
+}
+
+export default ItemTypeUtil;
diff --git a/src/common/ItemUtil.ts b/src/common/ItemUtil.ts
index ae4785a..8dc865e 100644
--- a/src/common/ItemUtil.ts
+++ b/src/common/ItemUtil.ts
@@ -1,6 +1,23 @@
import loki from 'lokijs';
import itemsJson from '../assets/items.json';
+export type ItemBasicLang = 'eng' | 'jpn' | 'fra' | 'deu' | 'esl' | 'ita' | 'dut' | 'sve' | 'nor' | 'dan' | 'fin' | 'por' | 'chi' | 'kor';
+export interface ItemBasicIndex {
+ index_id: number;
+ title: string;
+}
+export interface ItemBasicChangeLog {
+ log_date: number;
+ log: string;
+}
+export interface ItemBasicFile {
+ file_id: number;
+ original_file_name: string;
+ mime_type: string;
+ file_size: number;
+ timestamp: string;
+ display_name: string;
+}
export interface ItemBasic {
item_id: number;
item_type_id: number;
@@ -12,32 +29,18 @@ export interface ItemBasic {
publication_year: number;
publication_month: number;
publication_mday: number;
- lang: string;
+ lang: ItemBasicLang;
title: string;
item_type_display_name: string;
item_type_name: string;
uname: string;
name: string;
item_url: string;
- index: {
- index_id: number;
- title: string;
- }[];
- changelog: {
- uid: number;
- log_date: number;
- log: string;
- }[];
+ index: ItemBasicIndex[];
+ changelog: ItemBasicChangeLog[];
related_to: number[];
keyword: string[];
- file: {
- file_id: number;
- original_file_name: string;
- mime_type: string;
- file_size: number;
- timestamp: string;
- display_name: string;
- }[];
+ file: ItemBasicFile[];
}
export interface ItemBook extends ItemBasic {
@@ -204,6 +207,13 @@ class ItemUtil {
return items.findOne(filter);
}
+ static getByDoi(doi: string) {
+ const filter = {
+ 'doi': doi
+ }
+ return items.findOne(filter);
+ }
+
static getListByIndexId(indexId: number, condition: SortCondition): SearchResult {
const filter = {
'index.index_id': indexId
diff --git a/src/components/Database.tsx b/src/components/Database.tsx
index 2708e06..73f8a60 100644
--- a/src/components/Database.tsx
+++ b/src/components/Database.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import DatabaseItemType from './DatabaseItemType';
+import DatabaseDetailItem from './DatabaseDetailItem';
import DatabaseSearchByIndexId from './DatabaseSearchByIndexId';
import DatabaseSearchByItemType from './DatabaseSearchByItemType';
import styles from './Database.module.css';
@@ -10,10 +11,12 @@ const Database = () => {
+
+
-
+
);
diff --git a/src/components/DatabaseDetailItem.tsx b/src/components/DatabaseDetailItem.tsx
new file mode 100644
index 0000000..46aab5e
--- /dev/null
+++ b/src/components/DatabaseDetailItem.tsx
@@ -0,0 +1,57 @@
+import React, { Component } from 'react';
+import { RouteComponentProps } from 'react-router';
+import ItemUtil, { Item } from '../common/ItemUtil';
+import DatabaseItemType from './DatabaseItemType';
+
+interface Props extends RouteComponentProps<{ id: string, doi: string }> { }
+
+interface State {
+ item: Item | null;
+}
+
+class DatabaseDetailItem extends Component {
+
+ public state: State = {
+ item: null,
+ };
+
+ constructor(props: Props) {
+ super(props);
+ const { params } = this.props.match;
+ let item = null;
+ if (params.doi !== undefined) {
+ item = ItemUtil.getByDoi(params.doi);
+ } else if (params.id !== undefined) {
+ const itemId = parseInt(params.id, 10);
+ item = ItemUtil.get(itemId);
+ }
+ this.state.item = item;
+ }
+
+ componentWillReceiveProps(nextProps: Props) {
+ const { params } = nextProps.match;
+ let item = null;
+ if (params.doi !== undefined) {
+ item = ItemUtil.getByDoi(params.doi);
+ } else if (params.id !== undefined) {
+ const itemId = parseInt(params.id, 10);
+ item = ItemUtil.get(itemId);
+ }
+ this.setState({ item });
+ }
+
+ render() {
+ if (this.state.item === null) {
+ return (null);
+ }
+ return (
+ <>
+ Detail
+
+
+ >
+ );
+ }
+}
+
+export default DatabaseDetailItem;
\ No newline at end of file
diff --git a/src/components/DatabaseItemType.tsx b/src/components/DatabaseItemType.tsx
index 5c45bf8..cba6924 100644
--- a/src/components/DatabaseItemType.tsx
+++ b/src/components/DatabaseItemType.tsx
@@ -35,7 +35,7 @@ class DatabaseItemType {
-
+
|
@@ -43,7 +43,7 @@ class DatabaseItemType {
);
}
- static List(props: {item:Item}) {
+ static List(props: { item: Item }) {
const item = props.item;
switch (item.item_type_name) {
case 'xnpbook':
@@ -59,7 +59,27 @@ class DatabaseItemType {
case 'xnpurl':
return ();
default:
- return ID:{item.item_id}
+ return (null);
+ }
+ }
+
+ static Detail(props: { item: Item }) {
+ const item = props.item;
+ switch (item.item_type_name) {
+ case 'xnpbook':
+ return ();
+ case 'xnpconference':
+ return ();
+ case 'xnpdata':
+ return ();
+ case 'xnpmodel':
+ return ();
+ case 'xnppaper':
+ return ();
+ case 'xnpurl':
+ return ();
+ default:
+ return (null);
}
}
}
diff --git a/src/components/DatabaseItemTypePaper.tsx b/src/components/DatabaseItemTypePaper.tsx
index d672903..3efe1fb 100644
--- a/src/components/DatabaseItemTypePaper.tsx
+++ b/src/components/DatabaseItemTypePaper.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import ItemUtil, { ItemPaper } from '../common/ItemUtil';
+import ItemTypeUtil from '../common/ItemTypeUtil';
import iconFile from '../assets/images/database/icon_paper.gif';
class DatabaseItemTypePaper {
@@ -37,9 +38,7 @@ class DatabaseItemTypePaper {
const volume = item.volume === null ? '' : ';' + String(item.volume);
const number = item.number === null ? '' : '(' + String(item.number) + ')';
const page = item.page === '' ? '' : ':' + item.page;
- const pubmedUrl = 'https://www.ncbi.nlm.nih.gov/pubmed/' + item.pubmed_id;
- const pubmedLink = ({item.pubmed_id});
- const pubmed = item.pubmed_id === '' ? <>> : [PMID: {pubmedLink}];
+ const pubmed = item.pubmed_id === '' ? <>> : [PMID: ];
return (
@@ -57,6 +56,101 @@ class DatabaseItemTypePaper {
);
}
+
+ static Detail(props: { item: ItemPaper }) {
+ const { item } = props;
+ return (
+
+
+
+ | ID |
+ {item.doi} |
+
+
+ | Language |
+ |
+
+
+ | PubMedID |
+ |
+
+
+ | Title |
+ {item.title} |
+
+
+ | Free Keywords |
+ |
+
+
+ | Description |
+ {item.description} |
+
+
+ | Last Modified Date |
+ |
+
+
+ | Created Date |
+ |
+
+
+ | Contributor |
+ |
+
+
+ | Item Type |
+ {item.item_type_display_name} |
+
+
+ | Change Log(History) |
+ |
+
+
+ | Author |
+ |
+
+
+ | Journal |
+ {item.journal} |
+
+
+ | Publication Year |
+ {item.publication_year} |
+
+
+ | Volume |
+ {item.volume} |
+
+
+ | Number |
+ {item.number} |
+
+
+ | Page |
+ {item.page} |
+
+
+ | Index |
+ |
+
+
+ | Related to |
+ |
+
+
+
+ );
+ }
+
+ static PubmedLink(props: {pubmedId: string}) {
+ const {pubmedId} = props;
+ if (pubmedId === '') {
+ return null;
+ }
+ const url = 'https://www.ncbi.nlm.nih.gov/pubmed/' + pubmedId;
+ return ({pubmedId});
+ }
}
export default DatabaseItemTypePaper;
\ No newline at end of file