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

API Workaround and enhancements #16

Merged
merged 22 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 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
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
/nbproject/private/
/node_modules
.brackets.json
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
7 changes: 5 additions & 2 deletions src/calc2/views/help.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2040,9 +2040,12 @@ export class Help extends React.Component<Props> {
</tr>

<tr>
<td><code>concat(a:string [, ...])</code></td>
<td><code>concat(a:"any" [, ...])</code></td>
<td>string</td>
<td>concatenates the given strings</td>
<td>returns the string that results from concatenating the arguments.
<br />May have one or more arguments. A non-string argument is implicitly converted to its equivalent string form and then concatenated. Returns null if any argument is null (like in <a
href="https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat">MySQL</a>).
</td>
</tr>
<tr>
<td><code>upper(a:string)
Expand Down
6 changes: 3 additions & 3 deletions src/db/exec/ValueExpr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,9 +883,9 @@ export class ValueExprGeneric extends ValueExpr {
if (this._dataType === 'null' && dataType !== 'null') {
this._dataTypeCalculated = dataType;
}
else if (dataType !== 'null' && this._dataType !== dataType) {
this.throwExecutionError(i18n.t('db.messages.exec.error-function-expects-arguments-of-same-type', {func: 'CONCAT()'}));
}
// else if (dataType !== 'null' && this._dataType !== dataType) {
// this.throwExecutionError(i18n.t('db.messages.exec.error-function-expects-arguments-of-same-type', {func: 'CONCAT()'}));
// }
}
break;
default:
Expand Down