Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emporio integration #79

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1a7ad3b
feat: add Dialog to load thing model from a server (Emporio)
ivanzy Jun 14, 2022
f3376ca
feat: improve load thing model modal
ivanzy Jun 15, 2022
79f397a
feat: add pagination
ivanzy Jun 16, 2022
4481876
fix: adequate selector and class to React conventions
ivanzy Jun 16, 2022
7417957
feat: get ThingModel server from .env file
ivanzy Jun 16, 2022
0cbd9f9
feat: add scheme to tm repository url
relu91 Jun 24, 2022
fb4260c
fix: remove select propert from TM
ivanzy Jun 24, 2022
b148041
feat: add input to change Emporio URL thorugh the GUI
ivanzy Jun 28, 2022
0b24c44
feat: add url validation
ivanzy Jun 28, 2022
95a696d
feat: inline url form
ivanzy Jun 28, 2022
95edd2a
feat: improve style of url form
ivanzy Jun 28, 2022
445f266
feat: added advances options instead of tm repository, rework the des…
ivanzy Jun 29, 2022
f16d329
feat: change advance options from button to text
ivanzy Jun 29, 2022
ea621b6
fix: rollback change url to button
ivanzy Jun 29, 2022
0ee4dd5
refactor: change multiple state variables to a single useReducer
ivanzy Jul 5, 2022
fa473d6
feat: add no border
ivanzy Jul 5, 2022
90c7a3d
fix: unable to submit 'Load TM' without selecting a thing model
ivanzy Jul 5, 2022
ebac73d
refactor: move pagination buttons to its own component
ivanzy Jul 5, 2022
df4016f
refactor: move search bar and advances options to their own components
ivanzy Jul 5, 2022
01ed563
refactor: changes made are not a new version
ivanzy Jul 11, 2022
38a25be
style: rollback autoformat changes
ivanzy Jul 11, 2022
4e5677e
feat: save remote feature
ivanzy Jul 20, 2022
4c1a0a3
fix: update isThingModel context property
ivanzy Jul 20, 2022
b9d5259
fix: is misleading to have duplicate context definition. Modifying th…
ivanzy Jul 20, 2022
705d56f
feat: add emporio url as a context property
ivanzy Jul 20, 2022
3c27e96
feat: add an enviromental variable to control if a remote TM reposito…
ivanzy Jul 20, 2022
0377ecd
refactor: move AdvancedOptions componet to its own file
ivanzy Jul 20, 2022
6c80de4
feat: add AdvancedOptions in SaveRemote Dialog
ivanzy Jul 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add emporio url as a context property
ivanzy committed Jul 20, 2022
commit 705d56f9cc68f227ae2540336c2a934d2a56c10f
16 changes: 6 additions & 10 deletions src/components/Dialogs/LoadTmDialog.jsx
Original file line number Diff line number Diff line change
@@ -92,7 +92,6 @@ const initialState = {
thingModels: [],
choosenModel: null,
showUrlForm: false,
emporioUrl: `${process.env.REACT_APP_TM_SERVER_SCHEME}://${process.env.REACT_APP_TM_SERVER_HOST}:${process.env.REACT_APP_TM_SERVER_PORT}`,
pagination: {
currentPage: 0,
thingModelsPerPage: 5,
@@ -101,6 +100,7 @@ const initialState = {

export const LoadTmDialog = forwardRef((props, ref) => {
const context = useContext(ediTDorContext);

const [display, setDisplay] = React.useState(() => {
return false;
});
@@ -113,7 +113,6 @@ export const LoadTmDialog = forwardRef((props, ref) => {
thingModels,
choosenModel,
showUrlForm,
emporioUrl,
pagination,
} = state;

@@ -152,7 +151,7 @@ export const LoadTmDialog = forwardRef((props, ref) => {
page = 0,
attribute = false,
searchText,
remoteUrl = emporioUrl,
remoteUrl = context.tmRepositoryUrl,
} = {}) => {
const offset = pagination.thingModelsPerPage * page;
let url = `${remoteUrl}/models?limit=${pagination.thingModelsPerPage}&offset=${offset}`;
@@ -197,11 +196,7 @@ export const LoadTmDialog = forwardRef((props, ref) => {
const thingModels = await fetchThingModels({
remoteUrl: url,
});
dispatch({
type: "field",
fieldName: "emporioUrl",
payload: url,
});
context.updateTmRepositoryUrl(url);

return dispatch({
type: "thingModels",
@@ -243,7 +238,7 @@ export const LoadTmDialog = forwardRef((props, ref) => {
paginate,
show,
showUrlForm,
emporioUrl,
context.tmRepositoryUrl,
changeThingModelUrl
);

@@ -258,6 +253,7 @@ export const LoadTmDialog = forwardRef((props, ref) => {
context.updateLinkedTd(undefined);
context.addLinkedTd(linkedModel);
context.updateShowConvertBtn(true);
context.updateIsThingModel(true);
context.updateOfflineTD(
JSON.stringify(choosenModel, null, "\t"),
"AppHeader"
@@ -292,7 +288,7 @@ const buildForm = (
return (
<>
<SearchBar searchThingModels={searchThingModels} />

<AdvancedOptions
showUrlForm={showUrlForm}
emporioUrl={emporioUrl}
15 changes: 12 additions & 3 deletions src/context/GlobalState.js
Original file line number Diff line number Diff line change
@@ -13,11 +13,15 @@
import React, { useReducer } from 'react';

import EdiTDorContext from './ediTDorContext';
import { editdorReducer, REMOVE_FORM_FROM_TD, REMOVE_LINK_FROM_TD, UPDATE_IS_THINGMODEL, SET_FILE_HANDLE, UPDATE_IS_MODFIED, UPDATE_OFFLINE_TD, ADD_PROPERTYFORM_TO_TD, ADD_ACTIONFORM_TO_TD, ADD_EVENTFORM_TO_TD, REMOVE_ONE_OF_A_KIND_FROM_TD, UPDATE_SHOW_CONVERT_BTN, ADD_LINKED_TD, UPDATE_LINKED_TD} from './editorReducers';
import { editdorReducer, REMOVE_FORM_FROM_TD, REMOVE_LINK_FROM_TD, UPDATE_IS_THINGMODEL, SET_FILE_HANDLE, UPDATE_IS_MODFIED, UPDATE_OFFLINE_TD, ADD_PROPERTYFORM_TO_TD, ADD_ACTIONFORM_TO_TD, ADD_EVENTFORM_TO_TD, REMOVE_ONE_OF_A_KIND_FROM_TD, UPDATE_SHOW_CONVERT_BTN,UPDATE_TM_REPOSITORY_URL, ADD_LINKED_TD, UPDATE_LINKED_TD} from './editorReducers';


const GlobalState = props => {
const [editdorState, dispatch] = useReducer(editdorReducer, { offlineTD: '', theme: 'dark' });
const [editdorState, dispatch] = useReducer(editdorReducer, {
offlineTD: '',
theme: 'dark',
tmRepositoryUrl: `${process.env.REACT_APP_TM_SERVER_SCHEME}://${process.env.REACT_APP_TM_SERVER_HOST}:${process.env.REACT_APP_TM_SERVER_PORT}`
});

const updateOfflineTD = (offlineTD, props) => {
dispatch({ type: UPDATE_OFFLINE_TD, offlineTD: offlineTD });
@@ -59,6 +63,9 @@ const GlobalState = props => {
const updateShowConvertBtn = showConvertBtn => {
dispatch({ type: UPDATE_SHOW_CONVERT_BTN, showConvertBtn: showConvertBtn });
};
const updateTmRepositoryUrl = tmRepositoryUrl => {
dispatch({ type: UPDATE_TM_REPOSITORY_URL, tmRepositoryUrl: tmRepositoryUrl });
};

const addLinkedTd = linkedTd => {
dispatch({ type: ADD_LINKED_TD, linkedTd: linkedTd });
@@ -79,6 +86,7 @@ const GlobalState = props => {
fileHandle: editdorState.fileHandle,
showConvertBtn: editdorState.showConvertBtn,
linkedTd: editdorState.linkedTd,
tmRepositoryUrl: editdorState.tmRepositoryUrl,
updateOfflineTD,
updateIsModified,
updateIsThingModel,
@@ -91,7 +99,8 @@ const GlobalState = props => {
removeOneOfAKindReducer,
updateShowConvertBtn,
addLinkedTd,
updateLinkedTd
updateLinkedTd,
updateTmRepositoryUrl,
}}
>
{props.children}
8 changes: 8 additions & 0 deletions src/context/editorReducers.js
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ export const ADD_ACTIONFORM_TO_TD = 'ADD_ACTIONFORM_TO_TD';
export const ADD_EVENTFORM_TO_TD = 'ADD_EVENTFORM_TO_TD';
export const REMOVE_ONE_OF_A_KIND_FROM_TD = 'REMOVE_ONE_OF_A_KIND_FROM_TD';
export const UPDATE_SHOW_CONVERT_BTN = 'UPDATE_SHOW_CONVERT_BTN';
export const UPDATE_TM_REPOSITORY_URL = 'UPDATE_TM_REPOSITORY_URL';
export const ADD_LINKED_TD = 'ADD_LINKED_TD';
export const UPDATE_LINKED_TD = 'UPDATE_LINKED_TD'

@@ -188,6 +189,11 @@ const updateShowConvertBtn = (showConvertBtn, state) => {
return { ...state, showConvertBtn: showConvertBtn };
};

const updateTmRepositoryUrl = (tmRepositoryUrl, state) => {
console.log('updateTmRepositoryUrl')
return { ...state, tmRepositoryUrl: tmRepositoryUrl };
};

const editdorReducer = (state, action) => {
switch (action.type) {
case UPDATE_OFFLINE_TD:
@@ -213,6 +219,8 @@ const editdorReducer = (state, action) => {
return addEventFormReducer(action.params, state)
case UPDATE_SHOW_CONVERT_BTN:
return updateShowConvertBtn(action.showConvertBtn, state);
case UPDATE_TM_REPOSITORY_URL:
return updateTmRepositoryUrl(action.tmRepositoryUrl, state);
case ADD_LINKED_TD:
return addLinkedTd(action.linkedTd,state)
case UPDATE_LINKED_TD: