Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/rlaiola/relax into c…
Browse files Browse the repository at this point in the history
…oncat_fix
  • Loading branch information
rlaiola committed Oct 18, 2022
2 parents 441eb7d + 3aabb94 commit 79ae9e1
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ build
/bower_components
/tmp
/yarn-error.log
/reports/
/reports/.DS_Store
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A relational algebra calculator

## How to build
* Install yarn https://yarnpkg.com/
* Install node https://nodejs.org/en/
* Install node@12 https://nodejs.org/en/
* Clone the repo
* Checkout the `development` branch
* Execute `yarn install` to install all dependencies
Expand Down
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
2 changes: 1 addition & 1 deletion src/calc2/utils/groupUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export function loadGroupsFromSource(source: GroupSourceType, id: string, mainta
reject(new Error('gist ' + id + ' not found'));
},
},
async: true,
async: false,
});
break;
}
Expand Down
7 changes: 6 additions & 1 deletion src/calc2/views/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ export class Api extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = {};
this.query = atob(props.params.query)
// 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

0 comments on commit 79ae9e1

Please sign in to comment.