@@ -13,6 +13,7 @@ import { formatJSON } from '../../../utils/utils';
1313export class EditorPage {
1414 @Prop ( ) url : string ;
1515 @Prop ( ) permissions : string ;
16+ @Prop ( ) mode : string ;
1617
1718 @State ( ) selectedNodeName : string ;
1819 @State ( ) nodeList : string [ ] = [ ] ;
@@ -43,7 +44,6 @@ export class EditorPage {
4344 . catch ( err => {
4445 this . loadingNodes = false ;
4546 this . nodeError = err ;
46- console . log ( err ) ;
4747 } ) ;
4848 } ;
4949
@@ -70,6 +70,14 @@ export class EditorPage {
7070 state . viewParameter . dispatch ( transactionToFormatParameter ) ;
7171 } ;
7272
73+ checkIfValidDemoQuery ( value : string ) {
74+ const demoConstraints = [ "drop" , "addv" , "addvertex" , "addedge" , "adde" , "property" , "addlabel" ]
75+ demoConstraints . forEach ( constraint => {
76+ if ( value . toLowerCase ( ) . includes ( constraint ) ) {
77+ throw Error ( `You can perform this operation in Demo mode !` )
78+ }
79+ } )
80+ }
7381 onClickRun = async ( ) => {
7482 if ( state . editorTextFlag ) {
7583 state . selectedNodeName = null ;
@@ -93,6 +101,9 @@ export class EditorPage {
93101
94102 if ( isValid ) {
95103 state . timeTaken = null ;
104+
105+ if ( this . mode === "demo" ) this . checkIfValidDemoQuery ( query )
106+
96107 const res = await axios . post ( `${ state . hostUrl } /query/` , {
97108 query,
98109 parameters : JSON . parse ( parameters ) ,
@@ -108,9 +119,8 @@ export class EditorPage {
108119 state . errorMessage = error ;
109120 }
110121 } catch ( error ) {
111- console . log ( { error } ) ;
112122 state . isError = true ;
113- state . errorMessage = error ?. response ?. data ?. error ? error . response . data . error : 'Failed to fetch data from db server.' ;
123+ state . errorMessage = error ?. response ?. data ?. error ? error . response . data . error : error . message ?? 'Failed to fetch data from db server.' ;
114124 }
115125 state . isLoading = false ;
116126 }
0 commit comments