Merge branch 'api_call_enum' into 'master'
add API node type instead of always use string to define api node See merge request lukas/openmediacenter!33
This commit is contained in:
@ -3,7 +3,7 @@ import React from 'react';
|
||||
import ActorTile from '../../ActorTile/ActorTile';
|
||||
import style from './AddActorPopup.module.css';
|
||||
import {NewActorPopupContent} from '../NewActorPopup/NewActorPopup';
|
||||
import {callAPI} from '../../../utils/Api';
|
||||
import {APINode, callAPI} from '../../../utils/Api';
|
||||
import {ActorType} from '../../../types/VideoTypes';
|
||||
import {GeneralSuccess} from '../../../types/GeneralTypes';
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
||||
@ -127,22 +127,12 @@ class AddActorPopup extends React.Component<props, state> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* enable filterfield and focus into searchbar
|
||||
*/
|
||||
private enableFilterField(): void {
|
||||
this.setState({filtervisible: true}, () => {
|
||||
// focus filterfield after state update
|
||||
this.filterfield?.focus();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* event handling for ActorTile Click
|
||||
*/
|
||||
tileClickHandler(actor: ActorType): void {
|
||||
// fetch the available actors
|
||||
callAPI<GeneralSuccess>('actor.php', {
|
||||
callAPI<GeneralSuccess>(APINode.Actor, {
|
||||
action: 'addActorToVideo',
|
||||
actorid: actor.actor_id,
|
||||
videoid: this.props.movie_id
|
||||
@ -160,11 +150,21 @@ class AddActorPopup extends React.Component<props, state> {
|
||||
* load the actors from backend and set state
|
||||
*/
|
||||
loadActors(): void {
|
||||
callAPI<ActorType[]>('actor.php', {action: 'getAllActors'}, result => {
|
||||
callAPI<ActorType[]>(APINode.Actor, {action: 'getAllActors'}, result => {
|
||||
this.setState({actors: result});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* enable filterfield and focus into searchbar
|
||||
*/
|
||||
private enableFilterField(): void {
|
||||
this.setState({filtervisible: true}, () => {
|
||||
// focus filterfield after state update
|
||||
this.filterfield?.focus();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* filter the actor array for search matches
|
||||
* @param actor
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import Tag from '../../Tag/Tag';
|
||||
import PopupBase from '../PopupBase';
|
||||
import {callAPI} from '../../../utils/Api';
|
||||
import {APINode, callAPI} from '../../../utils/Api';
|
||||
import {TagType} from '../../../types/VideoTypes';
|
||||
|
||||
interface props {
|
||||
@ -25,7 +25,7 @@ class AddTagPopup extends React.Component<props, state> {
|
||||
}
|
||||
|
||||
componentDidMount(): void {
|
||||
callAPI('tags.php', {action: 'getAllTags'}, (result: TagType[]) => {
|
||||
callAPI(APINode.Tags, {action: 'getAllTags'}, (result: TagType[]) => {
|
||||
this.setState({
|
||||
items: result
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import PopupBase from '../PopupBase';
|
||||
import style from './NewActorPopup.module.css';
|
||||
import {callAPI} from '../../../utils/Api';
|
||||
import {APINode, callAPI} from '../../../utils/Api';
|
||||
import {GeneralSuccess} from '../../../types/GeneralTypes';
|
||||
|
||||
interface NewActorPopupProps {
|
||||
@ -43,7 +43,7 @@ export class NewActorPopupContent extends React.Component<NewActorPopupProps> {
|
||||
// check if user typed in name
|
||||
if (this.value === '' || this.value === undefined) return;
|
||||
|
||||
callAPI('actor.php', {action: 'createActor', actorname: this.value}, (result: GeneralSuccess) => {
|
||||
callAPI(APINode.Actor, {action: 'createActor', actorname: this.value}, (result: GeneralSuccess) => {
|
||||
if (result.result !== 'success') {
|
||||
console.log('error occured while writing to db -- todo error handling');
|
||||
console.log(result.result);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import PopupBase from '../PopupBase';
|
||||
import style from './NewTagPopup.module.css';
|
||||
import {callAPI} from '../../../utils/Api';
|
||||
import {APINode, callAPI} from '../../../utils/Api';
|
||||
import {GeneralSuccess} from '../../../types/GeneralTypes';
|
||||
|
||||
interface props {
|
||||
@ -29,7 +29,7 @@ class NewTagPopup extends React.Component<props> {
|
||||
* store the filled in form to the backend
|
||||
*/
|
||||
storeselection(): void {
|
||||
callAPI('tags.php', {action: 'createTag', tagname: this.value}, (result: GeneralSuccess) => {
|
||||
callAPI(APINode.Tags, {action: 'createTag', tagname: this.value}, (result: GeneralSuccess) => {
|
||||
if (result.result !== 'success') {
|
||||
console.log('error occured while writing to db -- todo error handling');
|
||||
console.log(result.result);
|
||||
|
@ -9,7 +9,8 @@ describe('<PopupBase/>', function () {
|
||||
});
|
||||
|
||||
let events;
|
||||
function mockKeyPress(){
|
||||
|
||||
function mockKeyPress() {
|
||||
events = [];
|
||||
document.addEventListener = jest.fn((event, cb) => {
|
||||
events[event] = cb;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {shallow} from "enzyme";
|
||||
import React from "react";
|
||||
import SubmitPopup from "./SubmitPopup";
|
||||
import {shallow} from 'enzyme';
|
||||
import React from 'react';
|
||||
import SubmitPopup from './SubmitPopup';
|
||||
|
||||
describe('<SubmitPopup/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
|
@ -3,7 +3,7 @@ import style from './Preview.module.css';
|
||||
import {Spinner} from 'react-bootstrap';
|
||||
import {Link} from 'react-router-dom';
|
||||
import GlobalInfos from '../../utils/GlobalInfos';
|
||||
import {callAPIPlain} from '../../utils/Api';
|
||||
import {APINode, callAPIPlain} from '../../utils/Api';
|
||||
|
||||
interface PreviewProps {
|
||||
name: string;
|
||||
@ -28,7 +28,7 @@ class Preview extends React.Component<PreviewProps, PreviewState> {
|
||||
}
|
||||
|
||||
componentDidMount(): void {
|
||||
callAPIPlain('video.php', {action: 'readThumbnail', movieid: this.props.movie_id}, (result) => {
|
||||
callAPIPlain(APINode.Video, {action: 'readThumbnail', movieid: this.props.movie_id}, (result) => {
|
||||
this.setState({
|
||||
previewpicture: result
|
||||
});
|
||||
|
Reference in New Issue
Block a user