📔 Adding UI elements for cover images
This commit is contained in:
@@ -25,11 +25,8 @@ $border-color: red;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
border: 1px solid color(srgb 0.767 0.861 0.848);
|
img {
|
||||||
margin: 0 10rem 10rem 0;
|
max-width: 200px;
|
||||||
div {
|
|
||||||
margin: 10px;
|
|
||||||
border: 1px solid red;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,62 +7,45 @@ import { walkFolder } from "../actions/fileops.actions";
|
|||||||
interface IProps {
|
interface IProps {
|
||||||
comicBookCoversMetadata: any;
|
comicBookCoversMetadata: any;
|
||||||
}
|
}
|
||||||
interface IState {
|
interface IState {}
|
||||||
comicBookCoversMetadata: any[];
|
|
||||||
}
|
|
||||||
|
|
||||||
class Card extends React.Component<IProps, IState> {
|
class Card extends React.Component<IProps, IState> {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
|
||||||
comicBookCoversMetadata: [],
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
public fetchComicBookCoversData = (metadata) => {
|
private removeLeadingPeriod = (string) => {
|
||||||
this.setState((prevState) => {
|
if (string.charAt(0) == ".") {
|
||||||
// Get previous state
|
string = string.substr(1);
|
||||||
const { comicBookCoversMetadata } = prevState;
|
|
||||||
|
|
||||||
// Add new item to array
|
|
||||||
comicBookCoversMetadata.push(metadata);
|
|
||||||
|
|
||||||
// Return new state
|
|
||||||
return { comicBookCoversMetadata };
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
public drawCoverCard = () => {
|
|
||||||
console.log("cover card", this.state.comicBookCoversMetadata);
|
|
||||||
if (this.state.comicBookCoversMetadata.length >= 1) {
|
|
||||||
return map(this.state.comicBookCoversMetadata, (metadata) => {
|
|
||||||
return <div>{JSON.stringify(metadata)}</div>;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
return string;
|
||||||
};
|
};
|
||||||
public async componentDidMount() {
|
public drawCoverCard = (metadata) => {
|
||||||
const extractionOptions = {
|
return map(metadata, (item) => {
|
||||||
sourceFolder: "./comics",
|
return (
|
||||||
extractTarget: "cover",
|
<div className="card">
|
||||||
targetExtractionFolder: "./userdata/covers",
|
<div className="card-image">
|
||||||
extractionMode: "bulk",
|
<figure className="image">
|
||||||
paginationOptions: {
|
<img
|
||||||
pageLimit: 25,
|
src={
|
||||||
page: 1,
|
"http://localhost:3000" +
|
||||||
},
|
this.removeLeadingPeriod(item.path) +
|
||||||
};
|
"/" +
|
||||||
const walkedFolders = await walkFolder("./comics");
|
item.name
|
||||||
socket.emit("call", {
|
}
|
||||||
action: "getComicCovers",
|
alt="Placeholder image"
|
||||||
params: {
|
/>
|
||||||
extractionOptions,
|
</figure>
|
||||||
walkedFolders,
|
</div>
|
||||||
},
|
<div className="card-content">
|
||||||
opts: { garam: "pasha" },
|
<div className="content">{item.name}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
});
|
});
|
||||||
socket.on("comicBookCoverMetadata", this.fetchComicBookCoversData);
|
};
|
||||||
}
|
|
||||||
public render() {
|
public render() {
|
||||||
return <div className="card">{this.drawCoverCard()}</div>;
|
return <div>{this.drawCoverCard(this.props.comicBookCoversMetadata)}</div>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import * as React from "react";
|
|
||||||
import { IFolderData } from "../shared/interfaces/comicinfo.interfaces";
|
|
||||||
import { isArray, map, isUndefined, isEmpty, flatten } from "lodash";
|
|
||||||
import { socket } from "./Import";
|
|
||||||
import { walkFolder } from "../actions/fileops.actions";
|
|
||||||
|
|
||||||
interface IProps {
|
|
||||||
comicBookCoversMetadata: any;
|
|
||||||
}
|
|
||||||
interface IState {}
|
|
||||||
|
|
||||||
class Card extends React.Component<IProps, IState> {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
public drawCoverCard = (metadata) => {
|
|
||||||
return map(metadata, (item) => {
|
|
||||||
return <div className="card">{JSON.stringify(item)}</div>;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
public render() {
|
|
||||||
return <div>{this.drawCoverCard(this.props.comicBookCoversMetadata)}</div>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Card;
|
|
||||||
@@ -3,7 +3,7 @@ import _ from "lodash";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { fetchComicBookMetadata } from "../actions/fileops.actions";
|
import { fetchComicBookMetadata } from "../actions/fileops.actions";
|
||||||
import { IFolderData } from "../shared/interfaces/comicinfo.interfaces";
|
import { IFolderData } from "../shared/interfaces/comicinfo.interfaces";
|
||||||
import Card from "./Card2";
|
import Card from "./Card";
|
||||||
import { io } from "socket.io-client";
|
import { io } from "socket.io-client";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
@@ -40,11 +40,11 @@ class Import extends React.Component<IProps, IState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidMount() {
|
public initiateSocketConnection = () => {
|
||||||
if (typeof this.props.path !== "undefined") {
|
if (typeof this.props.path !== "undefined") {
|
||||||
this.props.fetchComicMetadata();
|
this.props.fetchComicMetadata();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
@@ -71,7 +71,10 @@ class Import extends React.Component<IProps, IState> {
|
|||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
<p className="buttons">
|
<p className="buttons">
|
||||||
<button className="button is-medium">
|
<button
|
||||||
|
className="button is-medium"
|
||||||
|
onClick={this.initiateSocketConnection}
|
||||||
|
>
|
||||||
<span className="icon">
|
<span className="icon">
|
||||||
<i className="fas fa-file-import"></i>
|
<i className="fas fa-file-import"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ const initialState = {
|
|||||||
function fileOpsReducer(state = initialState, action) {
|
function fileOpsReducer(state = initialState, action) {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case IMS_SOCKET_DATA_FETCHED:
|
case IMS_SOCKET_DATA_FETCHED:
|
||||||
console.log("ke me hu garam garam");
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
comicBookMetadata: [...state.comicBookMetadata, action.data.data],
|
comicBookMetadata: [...state.comicBookMetadata, action.data.data],
|
||||||
|
|||||||
Reference in New Issue
Block a user