Commit 6e4bfedb authored by Laurent Wouters's avatar Laurent Wouters
Browse files

Implementing the embedded application

parent 8a367b5603e4
......@@ -188,20 +188,3 @@ export const MIME: { [mime: string]: string } = {
"application/ld+json": "JSON",
"application/trig": "TRIG"
};
/**
* The public interface for the application
*/
export interface Application {
/**
* Sets the content for the application
* @param content The content
*/
onContent(content: RawContent): void;
/**
* Sets the application on error
* @param description The error's description
*/
onError(description: string): void;
}
......@@ -19,7 +19,10 @@
******************************************************************************/
import * as React from "react";
import { RawContent, Application } from "../../common/api";
/// <reference path="../../common/rdflib-interface.d.ts"/>
import { Store } from "rdflib";
import { Application } from "./interface";
enum StateType {
Loading,
......@@ -29,7 +32,7 @@ enum StateType {
class State {
stateType: StateType;
message: string;
content: RawContent;
content: Store;
}
export class Viewer extends React.Component<any, State> implements Application {
......@@ -49,7 +52,7 @@ export class Viewer extends React.Component<any, State> implements Application {
* Sets the content for the application
* @param content The content
*/
public onContent(content: RawContent): void {
public onContent(content: Store): void {
let newState: State = {
stateType: StateType.Displaying,
message: "",
......@@ -91,7 +94,7 @@ export class Viewer extends React.Component<any, State> implements Application {
} else if (this.state.stateType == StateType.Displaying) {
return (
<div style={{ width: "90%", marginLeft: "5%", marginTop: "10vh" }}>
<div>{this.state.content.content}</div>
<div>{this.state.content.toString()}</div>
</div>
);
} else {
......
......@@ -18,9 +18,11 @@
* with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
/// <reference path="../../common/rdflib-interface.d.ts"/>
import { Application } from "./interface";
import * as React from "react";
import * as ReactDOM from "react-dom";
import { Application } from "../../common/api";
import { Viewer } from "./Viewer";
......
/*******************************************************************************
* Copyright 2003-2018 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
* contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
*
* This file is part of CubicWeb.
*
* CubicWeb is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 2.1 of the License, or (at your option)
* any later version.
*
* CubicWeb is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
/// <reference path="../../common/rdflib-interface.d.ts"/>
import { Store } from "rdflib";
/**
* The public interface for the application
*/
export interface Application {
/**
* Sets the content for the application
* @param content The content
*/
onContent(content: Store): void;
/**
* Sets the application on error
* @param description The error's description
*/
onError(description: string): void;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment