Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export namespace Components {
"doc": any;
}
interface EditorPage {
"mode": string;
"permissions": string;
"url": string;
}
Expand Down Expand Up @@ -928,6 +929,7 @@ declare namespace LocalJSX {
"doc"?: any;
}
interface EditorPage {
"mode"?: string;
"permissions"?: string;
"url"?: string;
}
Expand Down
16 changes: 13 additions & 3 deletions src/components/editorPage/editor-page/editor-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { formatJSON } from '../../../utils/utils';
export class EditorPage {
@Prop() url: string;
@Prop() permissions: string;
@Prop() mode: string;

@State() selectedNodeName: string;
@State() nodeList: string[] = [];
Expand Down Expand Up @@ -43,7 +44,6 @@ export class EditorPage {
.catch(err => {
this.loadingNodes = false;
this.nodeError = err;
console.log(err);
});
};

Expand All @@ -70,6 +70,14 @@ export class EditorPage {
state.viewParameter.dispatch(transactionToFormatParameter);
};

checkIfValidDemoQuery(value: string) {
const demoConstraints = ["drop", "addv", "addvertex", "addedge", "adde", "property", "addlabel"]
demoConstraints.forEach(constraint => {
if (value.toLowerCase().includes(constraint)) {
throw Error(`You can perform this operation in Demo mode !`)
}
})
}
onClickRun = async () => {
if (state.editorTextFlag) {
state.selectedNodeName = null;
Expand All @@ -93,6 +101,9 @@ export class EditorPage {

if (isValid) {
state.timeTaken = null;

if (this.mode === "demo") this.checkIfValidDemoQuery(query)

const res = await axios.post(`${state.hostUrl}/query/`, {
query,
parameters: JSON.parse(parameters),
Expand All @@ -108,9 +119,8 @@ export class EditorPage {
state.errorMessage = error;
}
} catch (error) {
console.log({ error });
state.isError = true;
state.errorMessage = error?.response?.data?.error ? error.response.data.error : 'Failed to fetch data from db server.';
state.errorMessage = error?.response?.data?.error ? error.response.data.error : error.message ?? 'Failed to fetch data from db server.';
}
state.isLoading = false;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/editorPage/editor-page/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

| Property | Attribute | Description | Type | Default |
| ------------- | ------------- | ----------- | -------- | ----------- |
| `mode` | `mode` | | `string` | `undefined` |
| `permissions` | `permissions` | | `string` | `undefined` |
| `url` | `url` | | `string` | `undefined` |

Expand Down
9 changes: 0 additions & 9 deletions src/components/editorPage/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,6 @@ onChange('nodes', value => {
});
});

onChange('query', value => {
if (state.viewQuery) {
let transactionToAdd = state.viewQuery.state.update({
changes: { from: 0, to: state.viewQuery.state.doc.toString().length, insert: `${value}` },
});
state.viewQuery.dispatch(transactionToAdd);
}
});

onChange('queryParameter', value => {
if (state.viewParameter) {
let transactionToAdd = state.viewParameter.state.update({
Expand Down
4 changes: 2 additions & 2 deletions src/components/loginPage/login-form/login-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class LoginForm {
@Prop() email: string = ''
@Prop() password: string = ''

componentWillLoad() {
componentDidLoad() {
if (this.mode === 'demo') {
this.autoSubmitter()
}
Expand All @@ -26,7 +26,7 @@ export class LoginForm {
email: this.email,
password: this.password
})
// location.assign('/')
location.assign('/')
} catch (error) {
throw Error("Form could not be submitted")
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<!-- <editor-res></editor-res> -->
<!-- <permission-editor url="http://localhost:3000/api/permissions" rolesurl="http://localhost:3000/api/permissions/all"></permission-editor> -->
<!-- <tabs-component></tabs-component> -->
<!-- <editor-page url="http://localhost:3000/api/editor"></editor-page> -->
<editor-page url="http://localhost:3000/api/editor"></editor-page>
<!-- <query-logs ></query-logs> -->
<!-- <navigators-component></navigators-component> -->
<!-- <users-component></users-component> -->
Expand All @@ -49,7 +49,7 @@
<!-- <login-form></login-form> -->
<!-- </fluid-container> -->
<!-- <banner-component></banner-component> -->
<insert-node-model ></insert-node-model>
<!-- <insert-node-model ></insert-node-model> -->
</div>
</body>

Expand Down