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

Relax API support (new features + bug fix) #148

Open
wants to merge 29 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f81bc4a
.DS_Store ignored
rlaiola Jul 6, 2021
01e102c
Added API route support to :filename and :index
rlaiola Jul 6, 2021
95ae943
Bug fix: in case the :filename and :index are set in the URL, it is n…
rlaiola Jul 6, 2021
e637b59
Added support to load API data synchronously
rlaiola Jul 6, 2021
bb767d3
Set project requirement: Node@12. NOTE: It does not run with Node@14 …
rlaiola Jul 6, 2021
27d76ed
Fix issue of parsing + as a space
rlaiola Aug 9, 2021
898d73d
Merge branch 'dbis-uibk:development' into development
rlaiola Mar 8, 2022
0c14e29
Merge branch 'dbis-uibk:development' into development
rlaiola Apr 20, 2022
24a72b6
Merge branch 'dbis-uibk:development' into development
rlaiola May 6, 2022
8f2a3c1
Merge branch 'dbis-uibk:development' into development
rlaiola May 12, 2022
5dabfed
Merge branch 'dbis-uibk:development' into development
rlaiola May 20, 2022
cdc17f5
Merge branch 'dbis-uibk:development' into development
rlaiola May 29, 2022
70f85c0
Merge branch 'dbis-uibk:development' into development
rlaiola Jul 5, 2022
709d3c1
Merge branch 'dbis-uibk:development' into development
rlaiola Jul 26, 2022
3f4e47f
Merge pull request #7 from dbis-uibk/development
github-actions[bot] Aug 20, 2022
0434c07
Merge pull request #9 from dbis-uibk/development
github-actions[bot] Sep 2, 2022
3aabb94
Merge pull request #11 from dbis-uibk/development
github-actions[bot] Sep 19, 2022
441eb7d
Bug fix
rlaiola Oct 18, 2022
79ae9e1
Merge branch 'development' of https://github.com/rlaiola/relax into c…
rlaiola Oct 18, 2022
cad9825
Update .gitignore
rlaiola Oct 10, 2023
49088bb
Update README.md
rlaiola Oct 10, 2023
c050818
Update .gitignore
rlaiola Oct 10, 2023
a22cc65
fix request ajax without timeout
luizfelmach Nov 8, 2023
b1e849a
Merge pull request #21 from luizfelmach/development
rlaiola Nov 8, 2023
009b624
Merge branch 'development' into development
rlaiola Oct 3, 2024
7f5d768
Update ValueExpr.ts
rlaiola Oct 14, 2024
d99aba8
Merge branch 'dbis-uibk:development' into development
rlaiola Oct 14, 2024
52b276e
Update help.tsx
rlaiola Oct 18, 2024
027eba9
Update .gitignore
rlaiola Oct 18, 2024
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
2 changes: 1 addition & 1 deletion src/calc2/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class Main extends React.Component<Props, State> {
<Redirect from="/relax/calc" to="/relax/calc/local/uibk/local/0" exact strict />
<Route path="/relax/calc/:source/:id/:filename/:index" component={ConnectedCalc} />
<Route path="/relax/calc/:source/:id" component={ConnectedCalc} />
<Route path="/relax/calc/:source/:id/:filename/:index" component={ConnectedCalc} />
<Route path="/relax/api/:source/:id/:filename/:index" component={ConnectedCalc} />
<Route path="/relax/api/:source/:id" component={ConnectedCalc} />
<Route render={match => (
<div className="view-min"><h1>404</h1>
Expand Down
43 changes: 33 additions & 10 deletions src/calc2/store/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,39 @@ export function* rootSaga() {
};
yield saga.put(success);
if (setCurrent !== undefined && loadedGroups.length > 0) {
const { source, id, filename } = loadedGroups[0].groupInfo;

const setCurrent: GROUP_SET_CURRENT = {
type: 'GROUP_SET_CURRENT',
source,
id,
filename,
index: 0,
};
yield saga.put(setCurrent);
// In case the :filename and :index are set in the URL,
// it's necessary to set the correct group accordingly
if (setCurrent && setCurrent != 'first' &&
setCurrent.filename && setCurrent.index) {
for(var i=0;i<loadedGroups.length;i++) {
const g = loadedGroups[i];
const { source, id, filename, index } = g.groupInfo;
if (filename == setCurrent.filename && index == setCurrent.index) {
const setCurrent: GROUP_SET_CURRENT = {
type: 'GROUP_SET_CURRENT',
source,
id,
filename,
index,
};
yield saga.put(setCurrent);
break;
}
}
}
// Otherwise, just try using the first group
else {
const { source, id, filename } = loadedGroups[0].groupInfo;

const setCurrent: GROUP_SET_CURRENT = {
type: 'GROUP_SET_CURRENT',
source,
id,
filename,
index: 0,
};
yield saga.put(setCurrent);
}
}
}
catch (e) {
Expand Down
3 changes: 2 additions & 1 deletion src/calc2/utils/groupUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export function loadGroupsFromSource(source: GroupSourceType, id: string, mainta
reject(new Error('gist ' + id + ' not found'));
},
},
async: true,
timeout: 10000,
async: false,
});
break;
}
Expand Down
9 changes: 7 additions & 2 deletions src/calc2/views/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ export class Api extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {};
this.mode = props.params.mode;
this.query = atob(props.params.query)
this.mode = props.params.mode;
// Fix issue of parsing + as a space
// https://www.npmjs.com/package/query-string
// https://github.com/sindresorhus/query-string/issues/305
// https://stackoverflow.com/questions/2678551/when-to-encode-space-to-plus-or-20
// https://stackoverflow.com/questions/3794919/replace-all-spaces-in-a-string-with
this.query = atob(props.params.query.split(' ').join('+'))
}

componentDidMount() {
Expand Down
5 changes: 5 additions & 0 deletions src/calc2/views/calc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class Calc extends React.Component<Props> {
})*/
this.apiView = this.props.location.pathname.split("/")[2] == "api"
this.params = queryString.parse(this.props.location.search)

// It's necessary to load remote group synchronouly
if (this.apiView) {
this.loadGroup(this.props);
}
}

componentDidUpdate(prevProps: Props): void {
Expand Down