http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/index.actions.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/index.actions.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/index.actions.ts new file mode 100755 index 0000000..1304644 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/index.actions.ts @@ -0,0 +1,119 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Action } from '@ngrx/store'; +import { Index } from '../models/asterixDB.model'; + +/* +* Definition of Index Actions +*/ +export const SELECT_INDEXES = '[Index Collection] Select Indexes'; +export const SELECT_INDEXES_SUCCESS = '[Index Collection] Select Indexes Success'; +export const SELECT_INDEXES_FAIL = '[Index Collection] Select Indexes Fail'; +export const CREATE_INDEX = '[Index Collection] Create Index'; +export const CREATE_INDEX_SUCCESS = '[Index Collection] Create Index Success'; +export const CREATE_INDEX_FAIL = '[Index Collection] Create Index Fail'; +export const UPDATE_INDEX = '[Index Collection] Update Index'; +export const UPDATE_INDEX_SUCCESS = '[Index Collection] Update Index Success'; +export const UPDATE_INDEX_FAIL = '[Index Collection] Update Index Fail'; +export const DROP_INDEX = '[Index Collection] Drop Indexes'; +export const DROP_INDEX_SUCCESS = '[Index Collection] Drop Indexes Success'; +export const DROP_INDEX_FAIL = '[Index Collection] Drop Indexes Fail'; + +/* +* Select Indexes +*/ +export class SelectIndexes implements Action { + readonly type = SELECT_INDEXES; + constructor(public payload: string) {} +} + +export class SelectIndexesSuccess implements Action { + readonly type = SELECT_INDEXES_SUCCESS; + constructor(public payload: Index[]) {} +} + +export class SelectIndexesFail implements Action { + readonly type = SELECT_INDEXES_FAIL; + constructor(public payload: Index[]) {} +} + +/* +* Create Index +*/ +export class CreateIndex implements Action { + readonly type = CREATE_INDEX; + constructor(public payload: string) {} +} + +export class CreateIndexSuccess implements Action { + readonly type = CREATE_INDEX_SUCCESS; + constructor(public payload: Index[]) {} +} + +export class CreateIndexFail implements Action { + readonly type = CREATE_INDEX_FAIL; + constructor(public payload: Index) {} +} + +/* +* Update Index +*/ +export class UpdateIndex implements Action { + readonly type = UPDATE_INDEX; + constructor(public payload: Index) {} +} + +export class UpdateIndexSuccess implements Action { + readonly type = UPDATE_INDEX_SUCCESS; + constructor(public payload: Index[]) {} +} + +export class UpdateIndexFail implements Action { + readonly type = UPDATE_INDEX_FAIL; + constructor(public payload: Index) {} +} + +/* +* Remove Index +*/ +export class DropIndex implements Action { + readonly type = DROP_INDEX; + constructor(public payload: string) {} +} + +export class DropIndexSuccess implements Action { + readonly type = DROP_INDEX_SUCCESS; + constructor(public payload: Index[]) {} +} + +export class DropIndexFail implements Action { + readonly type = DROP_INDEX_FAIL; + constructor(public payload: Index) {} +} + +/* +* Exports of indexes actions +*/ +export type All = SelectIndexes | + SelectIndexesSuccess | + SelectIndexesFail | + CreateIndex | + CreateIndexSuccess | + CreateIndexFail | + UpdateIndex | + UpdateIndexSuccess | + UpdateIndexFail | + DropIndex | + DropIndexSuccess | + DropIndexFail;
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/metadata.actions.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/metadata.actions.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/metadata.actions.ts new file mode 100755 index 0000000..4a3c125 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/metadata.actions.ts @@ -0,0 +1,46 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Action } from '@ngrx/store'; + +/* +* Definition of Metadata Tree Actions +*/ +export const UPDATE_METADATA_TREE = '[Metadata Tree Query] UPDATE Metadata tree'; +export const UPDATE_METADATA_TREE_SUCCESS = '[Metadata Tree Query] UPDATE Metadata tree Success'; +export const UPDATE_METADATA_TREE_FAIL = '[Metadata Tree Query] UPDATE Metadata tree Fail'; + +/* +* Construct Metadata Tree Actions +*/ +export class UpdateMetadataTree implements Action { + readonly type = UPDATE_METADATA_TREE + constructor() {} +} + +export class UpdateMetadataTreeSuccess implements Action { + readonly type = UPDATE_METADATA_TREE_SUCCESS; + constructor(public payload: any) {} +} + +export class UpdateMetadataTreeFail implements Action { + readonly type = UPDATE_METADATA_TREE_FAIL; + constructor(public payload: any) {} +} + +/* +* Exports of Metatada Tree actions +*/ +export type All = UpdateMetadataTree | + UpdateMetadataTreeSuccess | + UpdateMetadataTreeFail; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/query.actions.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/query.actions.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/query.actions.ts new file mode 100755 index 0000000..866b3e9 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/actions/query.actions.ts @@ -0,0 +1,71 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Action } from '@ngrx/store'; +import { AsterixDBQueryMessage } from '../models/asterixDB.model'; + +/* +* Definition of SQL++ Actions +*/ +export const EXECUTE_QUERY = '[Query] Execute SQL++ Query'; +export const EXECUTE_QUERY_SUCCESS = '[Query] Execute SQL++ Query Success'; +export const EXECUTE_QUERY_FAIL = '[Query] Execute SQL++ Query Fail'; +export const EXECUTE_METADATA_QUERY = '[Query] Execute Metadata SQL++ Query'; +export const EXECUTE_METADATA_QUERY_SUCCESS = '[Query] Execute Metadata SQL++ Query Success'; +export const EXECUTE_METADATA_QUERY_FAIL = '[Query] Execute Metadata SQL++ Query Fail'; + +/* +* Execute SQL++ Query +*/ +export class ExecuteQuery implements Action { + readonly type = EXECUTE_QUERY; + constructor(public payload: string) {} // the AsterixDB Query String +} + +export class ExecuteQuerySuccess implements Action { + readonly type = EXECUTE_QUERY_SUCCESS; + constructor(public payload: AsterixDBQueryMessage[]) {} +} + +export class ExecuteQueryFail implements Action { + readonly type = EXECUTE_QUERY_FAIL; + constructor(public payload: AsterixDBQueryMessage[]) {} +} + +/* +* Execute Metadata SQL++ Query +*/ +export class ExecuteMetadataQuery implements Action { + readonly type = EXECUTE_METADATA_QUERY; + constructor(public payload: string) {} // the AsterixDB Query String +} + +export class ExecuteMetadataQuerySuccess implements Action { + readonly type = EXECUTE_METADATA_QUERY_SUCCESS; + constructor(public payload: AsterixDBQueryMessage[]) {} +} + +export class ExecuteMetadataQueryFail implements Action { + readonly type = EXECUTE_METADATA_QUERY_FAIL; + constructor(public payload: AsterixDBQueryMessage[]) {} +} + +/* +* Exports of SQL++ actions +*/ +export type All = ExecuteQuery | + ExecuteQuerySuccess | + ExecuteQueryFail | + ExecuteMetadataQuery | + ExecuteMetadataQuerySuccess | + ExecuteMetadataQueryFail; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/dataset.effects.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/dataset.effects.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/dataset.effects.ts new file mode 100755 index 0000000..b5624a4 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/dataset.effects.ts @@ -0,0 +1,65 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { Action } from '@ngrx/store'; +import { Effect, Actions } from '@ngrx/effects'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; +import * as datasetActions from '../actions/dataset.actions'; +import { SQLService } from '../services/async-query.service'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/catch'; + +export type Action = datasetActions.All + +@Injectable() +export class DatasetEffects { + constructor(private actions: Actions, + private sqlService: SQLService) {} + + /* Effect to load a collection of all Datasets from AsterixDB + */ + @Effect() + selectDatasets$: Observable<Action> = this.actions + .ofType(datasetActions.SELECT_DATASETS) + .switchMap(query => { + return this.sqlService.selectDatasets() + .map(dataset => new datasetActions.SelectDatasetsSuccess(dataset)) + .catch(err => of(new datasetActions.SelectDatasetsFail(err))); + }); + + /* Effect to create a Datasets from AsterixDB + */ + @Effect() + createDatasets$: Observable<Action> = this.actions + .ofType(datasetActions.CREATE_DATASET) + .switchMap(dataset => { + return this.sqlService.createDataset((dataset as any).payload) + .map(dataset => new datasetActions.CreateDatasetSuccess(dataset)) + .catch(err => of(new datasetActions.CreateDatasetFail(err))); + }); + + /* Effect to drop a Datasets from AsterixDB + */ + @Effect() + dropDatasets$: Observable<Action> = this.actions + .ofType(datasetActions.DROP_DATASET) + .switchMap(dataset => { + console.log((dataset as any).payload) + return this.sqlService.dropDataset((dataset as any).payload) + .map(dataset => new datasetActions.DropDatasetSuccess(dataset)) + .catch(err => of(new datasetActions.DropDatasetFail(err))); + }); +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/datatype.effects.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/datatype.effects.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/datatype.effects.ts new file mode 100755 index 0000000..4fa187f --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/datatype.effects.ts @@ -0,0 +1,63 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { Effect, Actions } from '@ngrx/effects'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; +import * as datatypeActions from '../actions/datatype.actions'; +import { SQLService } from '../services/async-query.service'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/catch'; + +export type Action = datatypeActions.All + +@Injectable() +export class DatatypeEffects { + constructor(private actions: Actions, + private sqlService: SQLService) {} + + /* Effect to load a collection of all Datatypes from AsterixDB + */ + @Effect() + selectDatatypes$: Observable<Action> = this.actions + .ofType(datatypeActions.SELECT_DATATYPES) + .switchMap(query => { + return this.sqlService.selectDatatypes() + .map(datatype => new datatypeActions.SelectDatatypesSuccess(datatype)) + .catch(err => of(new datatypeActions.SelectDatatypesFail(err))); + }); + + /* Effect to create a Datatype from AsterixDB + */ + @Effect() + createDatatypes$: Observable<Action> = this.actions + .ofType(datatypeActions.CREATE_DATATYPE) + .switchMap(datatype => { + return this.sqlService.createDatatype((datatype as any).payload) + .map(datatype => new datatypeActions.CreateDatatypeSuccess(datatype)) + .catch(err => of(new datatypeActions.CreateDatatypeFail(err))); + }); + + /* Effect to drop a Datatype from AsterixDB + */ + @Effect() + dropDatatypes$: Observable<Action> = this.actions + .ofType(datatypeActions.DROP_DATATYPE) + .switchMap(datatype => { + return this.sqlService.dropDatatype((datatype as any).payload) + .map(datatype => new datatypeActions.DropDatatypeSuccess(datatype)) + .catch(err => of(new datatypeActions.DropDatatypeFail(err))); + }); +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/dataverse.effects.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/dataverse.effects.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/dataverse.effects.ts new file mode 100755 index 0000000..d917420 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/dataverse.effects.ts @@ -0,0 +1,63 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { Effect, Actions } from '@ngrx/effects'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; +import * as dataverseActions from '../actions/dataverse.actions'; +import { SQLService } from '../services/async-query.service'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/catch'; + +export type Action = dataverseActions.All + +@Injectable() +export class DataverseEffects { + constructor(private actions: Actions, + private sqlService: SQLService) {} + + /* Effect to load a collection of all Dataverses from AsterixDB + */ + @Effect() + selectDataverses$: Observable<Action> = this.actions + .ofType(dataverseActions.SELECT_DATAVERSES) + .switchMap(query => { + return this.sqlService.selectDataverses() + .map(dataverse => new dataverseActions.SelectDataversesSuccess(dataverse)) + .catch(err => of(new dataverseActions.SelectDataversesFail(err))); + }); + + /* Effect to create Dataverse from AsterixDB + */ + @Effect() + createDataverses$: Observable<Action> = this.actions + .ofType(dataverseActions.CREATE_DATAVERSE) + .switchMap(dataverseName => { + return this.sqlService.createDataverse((dataverseName as any).payload) + .map(dataverse => new dataverseActions.CreateDataverseSuccess(dataverse)) + .catch(err => of(new dataverseActions.CreateDataverseFail(err))); + }); + + /* Effect to drop a Dataverse from AsterixDB + */ + @Effect() + dropDataverses$: Observable<Action> = this.actions + .ofType(dataverseActions.DROP_DATAVERSE) + .switchMap(dataverseName => { + return this.sqlService.dropDataverse((dataverseName as any).payload) + .map(dataverse => new dataverseActions.DropDataverseSuccess(dataverse)) + .catch(err => of(new dataverseActions.DropDataverseFail(err))); + }); +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/index.effects.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/index.effects.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/index.effects.ts new file mode 100755 index 0000000..8491392 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/index.effects.ts @@ -0,0 +1,63 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { Effect, Actions } from '@ngrx/effects'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; +import * as indexActions from '../actions/index.actions'; +import { SQLService } from '../services/async-query.service'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/catch'; + +export type Action = indexActions.All + +@Injectable() +export class IndexEffects { + constructor(private actions: Actions, + private sqlService: SQLService) {} + + /* Effect to load a collection of all Index from AsterixDB + */ + @Effect() + selectIndexes$: Observable<Action> = this.actions + .ofType(indexActions.SELECT_INDEXES) + .switchMap(query => { + return this.sqlService.selectIndexes() + .map(index => new indexActions.SelectIndexesSuccess(index)) + .catch(err => of(new indexActions.SelectIndexesFail(err))); + }); + + /* Effect to create a Index + */ + @Effect() + createIndexes$: Observable<Action> = this.actions + .ofType(indexActions.CREATE_INDEX) + .switchMap(index => { + return this.sqlService.createIndex((index as any).payload) + .map(index => new indexActions.CreateIndexSuccess(index)) + .catch(err => of(new indexActions.CreateIndexFail(err))); + }); + + /* Effect to drop a Index + */ + @Effect() + dropIndexes$: Observable<Action> = this.actions + .ofType(indexActions.DROP_INDEX) + .switchMap(index => { + return this.sqlService.dropIndex((index as any).payload) + .map(index => new indexActions.DropIndexSuccess(index)) + .catch(err => of(new indexActions.DropIndexFail(err))); + }); +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/metadata.effects.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/metadata.effects.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/metadata.effects.ts new file mode 100755 index 0000000..ddcdb27 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/metadata.effects.ts @@ -0,0 +1,41 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { Action } from '@ngrx/store'; +import { Effect, Actions } from '@ngrx/effects'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; +import { MetadataService } from '../services/async-metadata.service'; +import * as metadataActions from '../actions/metadata.actions'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/catch'; + +export type Action = metadataActions.All + +@Injectable() +export class MetadataEffects { + constructor(private actions: Actions, + private metadataService: MetadataService) {} + + /* Effect to update and retrieve the Metadata Tree + */ + @Effect() + calculateDBTree$: Observable<Action> = this.actions + .ofType(metadataActions.UPDATE_METADATA_TREE) + .switchMap(() => { + return this.metadataService.getMetadataTree() + .map(tree => new metadataActions.UpdateMetadataTreeSuccess(tree)) + }); +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/query.effects.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/query.effects.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/query.effects.ts new file mode 100755 index 0000000..cb78255 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/effects/query.effects.ts @@ -0,0 +1,53 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { Action } from '@ngrx/store'; +import { Effect, Actions } from '@ngrx/effects'; +import { Observable } from 'rxjs/Observable'; +import { of } from 'rxjs/observable/of'; +import { SQLService } from '../services/async-query.service'; +import * as sqlQueryActions from '../actions/query.actions'; +import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; +import 'rxjs/add/operator/catch'; + +export type Action = sqlQueryActions.All + +@Injectable() +export class SQLQueryEffects { + constructor(private actions: Actions, + private sqlService: SQLService) {} + + /* Effect to Execute an SQL++ Query against the AsterixDB + */ + @Effect() + executeQuery$: Observable<Action> = this.actions + .ofType(sqlQueryActions.EXECUTE_QUERY) + .switchMap(query => { + return this.sqlService.executeSQLQuery((query as any).payload) + .map(sqlQueryResult => new sqlQueryActions.ExecuteQuerySuccess(sqlQueryResult)) + .catch(sqlQueryError => of(new sqlQueryActions.ExecuteQueryFail(sqlQueryError))); + }); + + /* Effect to Execute an SQL++ Metadata Query against the AsterixDB + */ + @Effect() + executeMetadataQuery$: Observable<Action> = this.actions + .ofType(sqlQueryActions.EXECUTE_METADATA_QUERY) + .switchMap(query => { + return this.sqlService.executeSQLQuery((query as any).payload) + .map(sqlMetadataQueryResult => new sqlQueryActions.ExecuteMetadataQuerySuccess(sqlMetadataQueryResult)) + .catch(sqlMetadataQueryError => of(new sqlQueryActions.ExecuteMetadataQueryFail(sqlMetadataQueryError))); + }); +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/models/asterixDB.model.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/models/asterixDB.model.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/models/asterixDB.model.ts new file mode 100755 index 0000000..bbdabe2 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/models/asterixDB.model.ts @@ -0,0 +1,112 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +/* +* Interfaces representing AsterixDB data model structures. +*/ + +export interface Dataverse { + dataFormat: string; + dataverseName: string; + pendingOp: string; + timeStamp: string; +}; + +export interface ResultsM { + dataFormat: string; + dataverseName: string; + pendingOp: string; + timeStamp: string; +}; + +export interface Dataset { + compactionPolicy: string; + compactionPolicyProperties: CompactionPolicyProperties[]; + datasetId: string; + datasetName: string; + datasetType:string; + datatypeDataverseName: string; + datatypeName: string; + dataverseName: string; + groupName:string; + hints: string[]; + internalDetails: InternalDetails; + pendingOp: string; + timestamp: string; +}; + +export interface CompactionPolicyProperties { + name: string; + value: string; +}; + +export interface InternalDetails { + autogenerated: string; + fileStructure: string; + partitioningKey: string; + partitioningStrategy: string; + primaryKey: string[]; +}; + +// Message format coming back from AsterixDB REST API +export interface AsterixDBQueryMessage { + metrics: Metrics; + requestId: string; + results: any[]; + signature: string; + status: string; +}; + +export interface Metrics { + elapsedTime: string; + executionTime: string; + resultCount: string; + resultSize: string; +}; + +// Datatype Data Model comming from AsterixDB REST API +export interface Datatype { + datatypeName: string; + dataverseName: string; + derived: DatatypeDerived; + timeStamp: string; +}; + +export interface DatatypeDerived { + isAnonymous: boolean; + record: DatatypeDerivedRecord; + tag: string; +}; + +export interface DatatypeDerivedRecord { + Fields: DatatypeDerivedRecordField[]; + isOpen: boolean; +}; + +export interface DatatypeDerivedRecordField { + fieldName: string; + fieldType: "string"; + isNullable: boolean; +} + +// Index Data Model comming from AsterixDB REST API +export interface Index { + dataverseName: string; + datasetName: string; + indexName: string; + indexStructure: string; + searchKey: string[]; + isPrimary: boolean; + timestamp: string; + pendingOp: string; +}; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/keys.pipe.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/keys.pipe.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/keys.pipe.ts new file mode 100755 index 0000000..77cac5a --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/keys.pipe.ts @@ -0,0 +1,25 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { PipeTransform, Pipe } from '@angular/core'; + +@Pipe({name: 'keys'}) +export class KeysPipe implements PipeTransform { + transform(value, args:string[]) : any { + let keys = []; + for (let key in value) { + keys.push(key); + } + return keys; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/objectArrayType.pipe.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/objectArrayType.pipe.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/objectArrayType.pipe.ts new file mode 100755 index 0000000..220b53c --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/objectArrayType.pipe.ts @@ -0,0 +1,23 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// Detecting if an object is an array +import { PipeTransform, Pipe } from '@angular/core'; + +@Pipe({name: 'isObjectArray'}) +export class ObjectArrayTypePipe implements PipeTransform { + transform(value, args:string[]) : any { + return value && (value.constructor.toString().indexOf("Array") != -1) + && value[0] && (value[0].constructor.toString().indexOf("Object") != -1); + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/objectType.pipe.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/objectType.pipe.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/objectType.pipe.ts new file mode 100755 index 0000000..5b8f795 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/pipes/objectType.pipe.ts @@ -0,0 +1,21 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { PipeTransform, Pipe } from '@angular/core'; + +@Pipe({name: 'isObject'}) +export class ObjectTypePipe implements PipeTransform { + transform(value, args:string[]) : any { + return value && (value.constructor.toString().indexOf("Object") != -1); + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/app.reducer.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/app.reducer.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/app.reducer.ts new file mode 100755 index 0000000..01c65ac --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/app.reducer.ts @@ -0,0 +1,73 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { AsterixDBQueryMessage } from '../models/asterixDB.model'; +import * as appActions from '../actions/app.actions'; + +export type Action = appActions.All; + +/* +** Interfaces for app state in store/state +*/ +export interface State { + loading: boolean, + loaded: boolean, + success: boolean, + sqlQueryString: string, + sqlQueryResult: AsterixDBQueryMessage[], + sqlQueryError: AsterixDBQueryMessage[], + sqlMetadataQueryString: string, + sqlMetadataQueryResult: AsterixDBQueryMessage[], + sqlMetadataQueryError: AsterixDBQueryMessage[] +}; + +const initialState: State = { + loading: false, + loaded: false, + success: false, + sqlQueryString: "", + sqlQueryResult: [], + sqlQueryError: [], + sqlMetadataQueryString: "", + sqlMetadataQueryResult: [], + sqlMetadataQueryError: [], +}; + +/* +** Reducer function for app state in store/state +*/ +export function appReducer(state = initialState, action: Action) { + switch (action.type) { + + /* + * Change the load state to true, and clear previous results + * to signaling that a EXECUTE a SQL++ Query is ongoing + */ + case appActions.APP_MODE_CHANGE: { + return Object.assign({}, state, { + loading: false, + loaded: true, + success: false, + sqlQueryString: action.payload, + sqlQueryResult: [], + sqlQueryError: [] + }); + } + + /* + * Just returns the current store/state object + */ + default: + return state; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/dataset.reducer.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/dataset.reducer.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/dataset.reducer.ts new file mode 100755 index 0000000..25d09b9 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/dataset.reducer.ts @@ -0,0 +1,177 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Dataset } from '../models/asterixDB.model'; +import * as DatasetAction from '../actions/dataset.actions'; + +export type Action = DatasetAction.All; + +/* +** Interfaces for datasets in store/state +*/ +export interface State { + loaded: boolean, + loading: boolean, + datasets: any[], + createDataset: any[], + createDatasetError: any[], + createDatasetSuccess: boolean, + createDatasetFailed: boolean, + dropDataset: any[], + dropDatasetError: any[], + dropDatasetSuccess: boolean, + dropDatasetFailed: boolean, + guideSelectsDataset: string, +}; + +const initialState: State = { + loaded: false, + loading: false, + datasets: [], + createDataset: [], + createDatasetError: [], + createDatasetSuccess: false, + createDatasetFailed: false, + dropDataset: [], + dropDatasetError: [], + dropDatasetSuccess: false, + dropDatasetFailed: false, + guideSelectsDataset: "" +}; + +/* +** Reducer function for datasets in store/state +*/ +export function datasetReducer(state = initialState, action: Action) { + switch (action.type) { + + /* + * Change the selected dataset state to true to signaling + * UI from metadata guide + */ + case DatasetAction.GUIDE_SELECT_DATASET: { + return Object.assign({}, state, { guideSelectsDataset: action.payload }); + } + + /* + * Change the load state to true to signaling + * that a SELECT Query is ongoing + */ + case DatasetAction.SELECT_DATASETS: { + return Object.assign({}, state, { loading: true }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a SELECT Query is success and there is datasets available in the + * store + */ + case DatasetAction.SELECT_DATASETS_SUCCESS: { + return Object.assign({}, state, { + loaded: true, + loading: false, + datasets: action.payload + }) + } + + /* + * Change the load state to true to signaling + * that a CREATE a Dataset Query is ongoing + */ + case DatasetAction.CREATE_DATASET: { + return Object.assign({}, state, { + createDataset: [], + createDatasetError: [], + createDatasetSuccess: false, + createDatasetFailed: false, + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a CREATE a Dataset Query is success and there is datasets available in the + * store + */ + case DatasetAction.CREATE_DATASET_SUCCESS: { + return Object.assign({}, state, { + createDataset: action.payload, + createDatasetName: action.payload, + createDatasetError: [], + createDatasetSuccess: true, + createDatasetFailed: false + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a CREATE a Dataset Query is failed and there is an error message available in the + * store + */ + case DatasetAction.CREATE_DATASET_FAIL: { + return Object.assign({}, state, { + createDataset: [], + createDatasetError: action.payload, + createDatasetSuccess: false, + createDatasetFailed: true + }) + } + + /* + * Change the load state to true to signaling + * that a DROP a Dataset Query is ongoing + */ + case DatasetAction.DROP_DATASET: { + return Object.assign({}, state, { + dropDataset: [], + dropDatasetError: [], + dropDatasetName: action.payload, + dropDatasetSuccess: false, + dropDatasetFailed: false + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a DROP a Dataset Query is success and there is datasets available in the + * store + */ + case DatasetAction.DROP_DATASET_SUCCESS: { + return Object.assign({}, state, { + dropDataset: action.payload, + dropDatasetError: [], + dropDatasetSuccess: true, + dropDatasetFailed: false + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a DROP a Dataset Query is failed and there is an error message available in the + * store + */ + case DatasetAction.DROP_DATASET_FAIL: { + return Object.assign({}, state, { + dropDataset: [], + dropDatasetError: action.payload, + dropDatasetSuccess: false, + dropDatasetFailed: true + }) + } + + /* + * Just returns the current store/state object + */ + default: + return state; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/datatype.reducer.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/datatype.reducer.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/datatype.reducer.ts new file mode 100755 index 0000000..1036fdb --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/datatype.reducer.ts @@ -0,0 +1,167 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Datatype } from '../models/asterixDB.model'; +import * as DatatypeAction from '../actions/datatype.actions'; + +export type Action = DatatypeAction.All; + +/* +** Interfaces for datatype in store/state +*/ +export interface State { + loaded: boolean, + loading: boolean, + datatypes: Datatype[], + createDatatype: any[], + createDatatypeError: any[], + createDatatypeSuccess: boolean, + createDatatypeFailed: boolean, + dropDatatype: any[], + dropDatatypeError: any[], + dropDatatypeSuccess: boolean, + dropDatatypeFailed: boolean +}; + +const initialState: State = { + loaded: false, + loading: false, + datatypes: [], + createDatatype: [], + createDatatypeError: [], + createDatatypeSuccess: false, + createDatatypeFailed: false, + dropDatatype: [], + dropDatatypeError: [], + dropDatatypeSuccess: false, + dropDatatypeFailed: false +}; + +/* +** Reducer function for datatypes in store/state +*/ +export function datatypeReducer(state = initialState, action: Action) { + switch (action.type) { + + /* + * Change the load state to true to signaling + * that a SELECT Query is ongoing + */ + case DatatypeAction.SELECT_DATATYPES: { + return Object.assign({}, state, { loading: true }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a SELECT Query is success and there is datatypes available in the + * store + */ + case DatatypeAction.SELECT_DATATYPES_SUCCESS: { + return Object.assign({}, state, { + loaded: true, + loading: false, + datatypes: action.payload + }) + } + + /* + * Change the load state to true to signaling + * that a CREATE a Datatype Query is ongoing + */ + case DatatypeAction.CREATE_DATATYPE: { + return Object.assign({}, state, { + createDatatype: [], + createDatatypeName: action.payload, + createDatatypeError: [], + createDatatypeSuccess: false, + createDatatypeFailed: false, + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a CREATE a Datatype Query is success and there is datasets available in the + * store + */ + case DatatypeAction.CREATE_DATATYPE_SUCCESS: { + return Object.assign({}, state, { + createDatatype: action.payload, + createDatatypeError: [], + createDatatypeSuccess: true, + createDatatypeFailed: false + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a CREATE a Datatype Query is failed and there is an error message available in the + * store + */ + case DatatypeAction.CREATE_DATATYPE_FAIL: { + return Object.assign({}, state, { + createDatatype: [], + createDatatypeError: action.payload, + createDatatypeSuccess: false, + createDatatypeFailed: true + }) + } + + /* + * Change the load state to true to signaling + * that a DROP a Datatype Query is ongoing + */ + case DatatypeAction.DROP_DATATYPE: { + return Object.assign({}, state, { + dropDatatype: [], + dropDatatypeName: action.payload, + dropDatatypeError: [], + dropDatatypeSuccess: false, + dropDatatypeFailed: false + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a DROP a Datatype Query is success and there is datasets available in the + * store + */ + case DatatypeAction.DROP_DATATYPE_SUCCESS: { + return Object.assign({}, state, { + dropDatatype: action.payload, + dropDatatypeError: [], + dropDatatypeSuccess: true, + dropDatatypeFailed: false + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a DROP a Datatype Query is failed and there is an error message available in the + * store + */ + case DatatypeAction.DROP_DATATYPE_FAIL: { + return Object.assign({}, state, { + dropDatatype: [], + dropDatatypeError: action.payload, + dropDatatypeSuccess: false, + dropDatatypeFailed: true + }) + } + + /* + * Just returns the current store/state object + */ + default: + return state; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/dataverse.reducer.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/dataverse.reducer.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/dataverse.reducer.ts new file mode 100755 index 0000000..7ac78ea --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/dataverse.reducer.ts @@ -0,0 +1,171 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Dataverse } from '../models/asterixDB.model'; +import * as DataverseAction from '../actions/dataverse.actions'; + +export type Action = DataverseAction.All; + +/* +** Interfaces for dataverses in store/state +*/ +export interface State { + loaded: boolean, + loading: boolean, + dataverses: any[], + createDataverse: any[], + createDataverseName: string, + createDataverseError: any[], + createDataverseSuccess: boolean, + createDataverseFailed: boolean + dropDataverse: any[], + dropDataverseName: string; + dropDataverseError: any[], + dropDataverseSuccess: boolean, + dropDataverseFailed: boolean +}; + +const initialState: State = { + loaded: false, + loading: false, + dataverses: [], + createDataverse: [], + createDataverseName: "", + createDataverseError: [], + createDataverseSuccess: false, + createDataverseFailed: false, + dropDataverse: [], + dropDataverseName: "", + dropDataverseError: [], + dropDataverseSuccess: false, + dropDataverseFailed: false +}; + +/* +** Reducer function for dataverses in store/state +*/ +export function dataverseReducer(state = initialState, action: Action) { + switch (action.type) { + + /* + * Change the load state to true to signaling + * that a SELECT Query is ongoing + */ + case DataverseAction.SELECT_DATAVERSES: { + return Object.assign({}, state, { loading: true }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a SELECT Query is success and there is dataverses available in the + * store + */ + case DataverseAction.SELECT_DATAVERSES_SUCCESS: { + return Object.assign({}, state, { + loaded: true, + loading: false, + dataverses: action.payload // _.sortBy(_.values(action.payload), 'dataverseName') + }) + } + + /* + * Change the load state to true to signaling + * that a CREATE a Dataset Query is ongoing + */ + case DataverseAction.CREATE_DATAVERSE: { + return Object.assign({}, state, { + createDataverse: [], + createDataverseName: action.payload, + createDataverseError: [], + createDataverseSuccess: false, + createDataverseFailed: false + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a CREATE a Dataverse Query is success and there is a success message available in the + * store + */ + case DataverseAction.CREATE_DATAVERSE_SUCCESS: { + return Object.assign({}, state, { + createDataverse: action.payload, + createDataverseError: [], + createDataverseSuccess: true, + createDataverseFailed: false + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a CREATE a Dataverse Query is failed and there is an error message available in the + * store + */ + case DataverseAction.CREATE_DATAVERSE_FAIL: { + return Object.assign({}, state, { + createDataverse: [], + createDataverseError: action.payload, + createDataverseSuccess: false, + createDataverseFailed: true + }) + } + + /* + * Change the load state to true to signaling + * that a DROP a Dataverse Query is ongoing + */ + case DataverseAction.DROP_DATAVERSE: { + return Object.assign({}, state, { + dropDataverse: [], + dropDataverseName: action.payload, + dropDataverseError: [], + dropDataverseSuccess: false, + dropDataverseFailed: false + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a DROP a Dataverse Query is success and there is success message available in the + * store + */ + case DataverseAction.DROP_DATAVERSE_SUCCESS: { + return Object.assign({}, state, { + dropDataverse: action.payload, + dropDataverseError: [], + dropDataverseSuccess: true, + dropDataverseFailed: false + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a DROP a Dataverse Query is failed and there is an error message available in the + * store + */ + case DataverseAction.DROP_DATAVERSE_FAIL: { + return Object.assign({}, state, { + dropDataverse: [], + dropDataverseError: action.payload, + dropDataverseSuccess: false, + dropDataverseFailed: true + }) + } + + /* + * Just returns the current store/state object + */ + default: + return state; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/index.reducer.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/index.reducer.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/index.reducer.ts new file mode 100755 index 0000000..792abc7 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/index.reducer.ts @@ -0,0 +1,167 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Index } from '../models/asterixDB.model'; +import * as IndexAction from '../actions/index.actions'; + +export type Action = IndexAction.All; + +/* +** Interfaces for indexes in store/state +*/ +export interface State { + loaded: boolean, + loading: boolean, + indexes: Index[], + createIndex: any[], + createIndexError: any[], + createIndexSuccess: boolean, + createIndexFailed: boolean, + dropIndex: any[], + dropIndexError: any[], + dropIndexSuccess: boolean, + dropIndexFailed: boolean +}; + +const initialState: State = { + loaded: false, + loading: false, + indexes: [], + createIndex: [], + createIndexError: [], + createIndexSuccess: false, + createIndexFailed: false, + dropIndex: [], + dropIndexError: [], + dropIndexSuccess: false, + dropIndexFailed: false +}; + +/* +** Reducer function for indexes in store/state +*/ +export function indexReducer(state = initialState, action: Action) { + switch (action.type) { + + /* + * Change the load state to true to signaling + * that a SELECT Query is ongoing + */ + case IndexAction.SELECT_INDEXES: { + return Object.assign({}, state, { loading: true }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a SELECT Query is success and there is indexes available in the + * store + */ + case IndexAction.SELECT_INDEXES_SUCCESS: { + return Object.assign({}, state, { + loaded: true, + loading: false, + indexes: action.payload + }) + } + + /* + * Change the load state to true to signaling + * that a CREATE a Index Query is ongoing + */ + case IndexAction.CREATE_INDEX: { + return Object.assign({}, state, { + createIndex: [], + createIndexName: action.payload, + createIndexError: [], + createIndexSuccess: false, + createIndexFailed: false + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a CREATE a Index Query is success and there is datasets available in the + * store + */ + case IndexAction.CREATE_INDEX_SUCCESS: { + return Object.assign({}, state, { + createIndex: [], + createIndexError: [], + createIndexSuccess: true, + createIndexFailed: false + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a CREATE a Index Query is success and there is datasets available in the + * store + */ + case IndexAction.CREATE_INDEX_SUCCESS: { + return Object.assign({}, state, { + createIndex: action.payload, + createIndexError: [], + createIndexSuccess: false, + createIndexFailed: true + }) + } + + /* + * Change the load state to true to signaling + * that a DROP a Index Query is ongoing + */ + case IndexAction.DROP_INDEX: { + return Object.assign({}, state, { + dropIndex: [], + dropIndexError: [], + dropIndexName: action.payload, + dropIndexSuccess: false, + dropIndexFailed: false + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a DROP a Index Query is success and there is datasets available in the + * store + */ + case IndexAction.DROP_INDEX_SUCCESS: { + return Object.assign({}, state, { + dropIndex: action.payload, + dropIndexError: [], + dropIndexSuccess: true, + dropIndexFailed: false + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a DROP a Index Query is failed and there is an error message available in the + * store + */ + case IndexAction.DROP_INDEX_FAIL: { + return Object.assign({}, state, { + dropIndex: [], + dropIndexError: action.payload, + dropIndexSuccess: false, + dropIndexFailed: true + }) + } + + /* + * Just returns the current store/state object + */ + default: + return state; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/index.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/index.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/index.ts new file mode 100755 index 0000000..1965d8c --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/index.ts @@ -0,0 +1,49 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { ActionReducer } from '@ngrx/store'; +import * as fromDataverse from './dataverse.reducer'; +import * as fromDataset from './dataset.reducer'; +import * as fromDatatype from './datatype.reducer'; +import * as fromIndex from './index.reducer'; +import * as fromQuery from './query.reducer'; +import * as fromQueryMetadata from './query-metadata.reducer'; +import * as fromMetadata from './metadata.reducer'; +import * as fromAppState from './app.reducer'; + +/* +** Global Interfaces store/state +*/ +export interface ModelState { + dataverse: fromDataverse.State, + dataset: fromDataset.State, + datatype: fromDatatype.State, + index: fromIndex.State, + sqlQuery: fromQuery.State, + sqlMetadataQuery: fromQueryMetadata.State, + metadata: fromMetadata.State, + appState: fromAppState.State, +} + +/* +** Global Reducers configuration +*/ +export const reducers = { + dataverse: fromDataverse.dataverseReducer, + dataset: fromDataset.datasetReducer, + datatype: fromDatatype.datatypeReducer, + index: fromIndex.indexReducer, + sqlQuery: fromQuery.sqlReducer, + sqlMetadataQuery: fromQueryMetadata.sqlMetadataReducer, + metadata: fromMetadata.metadataTreeReducer +}; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/metadata.reducer.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/metadata.reducer.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/metadata.reducer.ts new file mode 100755 index 0000000..52b88f2 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/metadata.reducer.ts @@ -0,0 +1,56 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import * as metadataTreeActions from '../actions/metadata.actions'; + +export type Action = metadataTreeActions.All; + +/* +** Interfaces for the metadata tree in store/state +*/ +export interface State { + tree: any[], + loading: boolean, + loaded: boolean, +}; + +const initialState: State = { + tree: [], + loading: false, + loaded: false +}; + +export function metadataTreeReducer(state = initialState, action: Action) { + switch (action.type) { + case metadataTreeActions.UPDATE_METADATA_TREE: { + return Object.assign({}, state, { + tree: [], + loading: true, + loaded: false + }); + } + + case metadataTreeActions.UPDATE_METADATA_TREE_SUCCESS: { + return Object.assign({}, state, { + tree: [...state.tree, action.payload], + loading: false, + loaded: true + }); + } + /* + * Just returns the current store/state object + */ + default: + return state; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/query-metadata.reducer.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/query-metadata.reducer.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/query-metadata.reducer.ts new file mode 100755 index 0000000..e360e95 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/query-metadata.reducer.ts @@ -0,0 +1,96 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { AsterixDBQueryMessage } from '../models/asterixDB.model'; +import * as sqlQueryActions from '../actions/query.actions'; + +export type Action = sqlQueryActions.All; + +/* +** Interfaces for sql++ queries in store/state +*/ +export interface State { + loading: boolean, + loaded: boolean, + success: boolean, + sqlQueryMetadataString: string, + sqlQueryMetadataResult: AsterixDBQueryMessage[], + sqlQueryMetadataError: AsterixDBQueryMessage[] +}; + +const initialState: State = { + loading: false, + loaded: false, + success: false, + sqlQueryMetadataString: "", + sqlQueryMetadataResult: [], + sqlQueryMetadataError: [], +}; + +/* +** Reducer function for sql++ queries in store/state +*/ +export function sqlMetadataReducer(state = initialState, action: Action) { + switch (action.type) { + /* + * Change the load state to true, and clear previous results + * to signaling that a METADATA EXECUTE a SQL++ Query is ongoing + */ + case sqlQueryActions.EXECUTE_METADATA_QUERY: { + return Object.assign({}, state, { + loading: false, + loaded: true, + success: false, + sqlQueryMetadataString: action.payload, + sqlQueryMetadataResult: [], + sqlQueryMetadataError: [] + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a METADATA EXECUTE Query is success and there is data available in the + * store + */ + case sqlQueryActions.EXECUTE_METADATA_QUERY_SUCCESS: { + return Object.assign({}, state, { + loading: false, + loaded: true, + success: true, + sqlQueryMetadataResult: action.payload, + sqlQueryMetadataError: [] + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a METADATA EXECUTE Query is failed and there is error data available in the + * store + */ + case sqlQueryActions.EXECUTE_METADATA_QUERY_FAIL: { + return Object.assign({}, state, { + loading: false, + loaded: true, + success: false, + sqlQueryMetadataResult: [], + sqlQueryMetadataError: action.payload + }) + } + + /* + * Just returns the current store/state object + */ + default: + return state; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/query.reducer.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/query.reducer.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/query.reducer.ts new file mode 100755 index 0000000..5c8ad08 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/reducers/query.reducer.ts @@ -0,0 +1,97 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { AsterixDBQueryMessage } from '../models/asterixDB.model'; +import * as sqlQueryActions from '../actions/query.actions'; + +export type Action = sqlQueryActions.All; + +/* +** Interfaces for sql++ queries in store/state +*/ +export interface State { + loading: boolean, + loaded: boolean, + success: boolean, + sqlQueryString: string, + sqlQueryResult: AsterixDBQueryMessage[], + sqlQueryError: AsterixDBQueryMessage[] +}; + +const initialState: State = { + loading: false, + loaded: false, + success: false, + sqlQueryString: "", + sqlQueryResult: [], + sqlQueryError: [] +}; + +/* +** Reducer function for sql++ queries in store/state +*/ +export function sqlReducer(state = initialState, action: Action) { + switch (action.type) { + + /* + * Change the load state to true, and clear previous results + * to signaling that a EXECUTE a SQL++ Query is ongoing + */ + case sqlQueryActions.EXECUTE_QUERY: { + return Object.assign({}, state, { + loading: false, + loaded: true, + success: false, + sqlQueryString: action.payload, + sqlQueryResult: [], + sqlQueryError: [] + }); + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a EXECUTE Query is success and there is data available in the + * store + */ + case sqlQueryActions.EXECUTE_QUERY_SUCCESS: { + return Object.assign({}, state, { + loading: false, + loaded: true, + success: true, + sqlQueryResult: action.payload, + sqlQueryError: [] + }) + } + + /* + * Change the load state to false, and loaded to true to signaling + * that a EXECUTE Query is failed and there is error data available in the + * store + */ + case sqlQueryActions.EXECUTE_QUERY_FAIL: { + return Object.assign({}, state, { + loading: false, + loaded: true, + success: false, + sqlQueryResult: [], + sqlQueryError: action.payload + }) + } + + /* + * Just returns the current store/state object + */ + default: + return state; + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/app-core.service.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/app-core.service.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/app-core.service.ts new file mode 100755 index 0000000..ed38c26 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/app-core.service.ts @@ -0,0 +1,38 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { Store } from '@ngrx/store'; +import * as dataverseActions from '../../shared/actions/dataverse.actions' +import * as datasetActions from '../../shared/actions/dataset.actions' +import * as datatypesActions from '../../shared/actions/datatype.actions' +import * as indexesActions from '../../shared/actions/index.actions' +import * as metadataActions from '../../shared/actions/metadata.actions' + +/* +* Main application service to initialize, +* load, set App status and initial data, and synchronize app level functionality +*/ +@Injectable() +export class AppCoreService { + /* + * Initialize and load metadata store structures + */ + constructor(private store: Store<any>) { + console.log('AsterixDB Web Console Core Service') + this.store.dispatch(new dataverseActions.SelectDataverses('-')); + this.store.dispatch(new datasetActions.SelectDatasets('-')); + this.store.dispatch(new datatypesActions.SelectDatatypes('-')); + this.store.dispatch(new indexesActions.SelectIndexes('-')); + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/async-metadata.service.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/async-metadata.service.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/async-metadata.service.ts new file mode 100755 index 0000000..8492a54 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/async-metadata.service.ts @@ -0,0 +1,120 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable, ApplicationRef } from '@angular/core'; +import { Store } from '@ngrx/store'; +import { Observable } from "rxjs/Observable"; +import 'rxjs/add/operator/map'; +import 'rxjs/add/observable/from'; +import * as dataverseActions from '../../shared/actions/dataverse.actions' +import * as datasetActions from '../../shared/actions/dataset.actions' +import * as datatypesActions from '../../shared/actions/datatype.actions' +import * as indexesActions from '../../shared/actions/index.actions' +import * as metadataActions from '../../shared/actions/metadata.actions' + +/* + Metadata service watch any changes in Dataverses, Datasets, Datatypes, indexes + state in store and builds a tree state structure with datasets->dataverse->datatype->index relationship +*/ +@Injectable() +export class MetadataService { + + /* Arrays to expose updated dataverses, datasets, datatypes, + indexes collections*/ + dv = []; + ds = []; + dt = []; + idx = []; + + /* + * contructor will initialize the store state watchers + */ + constructor(private store: Store<any>, private ref: ApplicationRef ) { + + /* Watching changes in dataverse collection */ + this.store.select(s => s.dataverse.dataverses).subscribe((data: any) => { + if (data.results) { + this.dv = [] + for (let i = 0; i < data.results.length; i++) { + let node = { id: 0, DataverseName: "", Datasets:[] } + node.id = i + node.DataverseName = data.results[i]['DataverseName'] + this.dv.push(node) + } + this.updateMetadataTree(); + } + }) + + /* Watching changes in datasets collections */ + this.store.select(s => s.dataset.datasets).subscribe((data: any) => { + if (data.results) { + this.ds = data.results; + this.updateMetadataTree(); + } + }) + + /* Watching changes in datatypes collections */ + this.store.select(s => s.datatype.datatypes).subscribe((data: any) => { + if (data.results) { + this.dt = data.results; + this.updateMetadataTree(); + } + }) + + /* Watching changes in index collections */ + this.store.select(s => s.index.indexes).subscribe((data: any) => { + if (data.results) { + this.idx = data.results; + this.updateMetadataTree(); + } + }) + } + + /* + * convenience function to update and return the metadata tree. + */ + getMetadataTree(): Observable<any[]> { + return Observable.from(this.dv); + } + + updateMetadataTree() { + for (let i = 0; i < this.dv.length; i++) { + // Filling datasets + this.dv[i]['Datasets'] = []; + for (let j = 0; j < this.ds.length; j++) { + if (this.ds[j]['DataverseName'] === this.dv[i]['DataverseName']){ + + // Filling datatypes, there is one datatype per dataset + this.ds[j]['Datatype'] = []; + for (let k = 0; k < this.dt.length; k++) { + if (this.dt[k]['DatatypeName'] === this.ds[j]['DatatypeName']){ + this.ds[j]['Datatype'] = this.dt[k]; // push(this.dt[k]) + } + } + + // Filling indexes + this.ds[j]['Indexes'] = []; + for (let l = 0; l < this.idx.length; l++) { + if (this.idx[l]['DatasetName'] === this.ds[j]['DatasetName']){ + this.ds[j]['Indexes'].push(this.idx[l]) + } + } + + this.dv[i]['Datasets'].push(this.ds[j]) + } + } + } + + this.store.dispatch(new metadataActions.UpdateMetadataTree()); + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/async-query.service.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/async-query.service.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/async-query.service.ts new file mode 100755 index 0000000..e37872e --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/app/shared/services/async-query.service.ts @@ -0,0 +1,190 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Store } from '@ngrx/store'; +import { Observable } from "rxjs/Observable"; +import 'rxjs/add/operator/map'; + +var AsterixRestApiUrl = 'http://localhost:19002/query/service'; +//var AsterixRestApiUrl = '/query-service'; + +/* +* SQL query service using AsterixDB REST API /query/service +*/ +@Injectable() +export class SQLService { + + /* + * SQLQueryService constructor using + * HttpClient from Angular 4 + */ + constructor(private http: HttpClient) {} + + /* + * sends a select sql++ query to return all the dataverses + * from AsterixDB Metadata + */ + selectDataverses() : Observable<any[]> { + let query = "SELECT VALUE dv FROM Metadata.`Dataverse` dv" + return this.executeSQLQuery(query); + } + + /* + * sends a select sql++ query to return all the datasets + * from AsterixDB Metadata + */ + selectDatasets() : Observable<any[]> { + let query = "SELECT VALUE ds FROM Metadata.`Dataset` ds" + return this.executeSQLQuery(query); + } + + /* + * sends a select sql++ query to return all the datatypes + * from AsterixDB Metadata + */ + selectDatatypes() : Observable<any[]> { + let query = "SELECT VALUE dt FROM Metadata.`Datatype` dt" + return this.executeSQLQuery(query); + } + + /* + * sends a select sql++ query to return all the indexes + * from AsterixDB Metadata + */ + selectIndexes() : Observable<any[]> { + let query = "SELECT VALUE ix FROM Metadata.`Index` ix" + return this.executeSQLQuery(query); + } + + /* + * creates a sql++ ddl query to create a Dataverse + * from AsterixDB Metadata + */ + createDataverse(dataverse: string) : Observable<any[]> { + let ddlQuery = "CREATE DATAVERSE " + dataverse + ";"; + return this.executeDDLSQLQuery(ddlQuery); + } + + /* + * creates a sql++ ddl query to drop a Dataverse + * from AsterixDB Metadata + */ + dropDataverse(dataverse: string) : Observable<any[]> { + let ddlQuery = "DROP DATAVERSE " + dataverse; // " IF EXISTS;"; + return this.executeDDLSQLQuery(ddlQuery); + } + + /* + * creates a sql++ ddl query to create a Dataset + * from AsterixDB Metadata + */ + createDataset(dataset: string) : Observable<any[]> { + let ddlQuery = "CREATE DATASET " + dataset + ";"; + return this.executeDDLSQLQuery(ddlQuery); + } + + /* + * creates a sql++ ddl query to drop a Dataset + * from AsterixDB Metadata + */ + dropDataset(dataset: string) : Observable<any[]> { + let ddlQuery = "DROP DATASET " + dataset; //" IF EXISTS;"; + return this.executeDDLSQLQuery(ddlQuery); + } + + /* + * creates a sql++ ddl query to create a Datatype + * from AsterixDB Metadata + */ + createDatatype(datatype: string) : Observable<any[]> { + let ddlQuery = "CREATE DATATYPE " + datatype + ";"; + return this.executeDDLSQLQuery(ddlQuery); + } + + /* + * creates a sql++ ddl query to drop a Datatype + * from AsterixDB Metadata + */ + dropDatatype(datatype: string) : Observable<any[]> { + let ddlQuery = "DROP TYPE " + datatype; //" IF EXISTS;"; + return this.executeDDLSQLQuery(ddlQuery); + } + + /* + * creates a sql++ ddl query to create a Index + * from AsterixDB Metadata + */ + createIndex(index: string) : Observable<any[]> { + let ddlQuery = "CREATE INDEX " + index + ";"; + return this.executeDDLSQLQuery(ddlQuery); + } + + /* + * creates a sql++ ddl query to drop a Index + * from AsterixDB Metadata + */ + dropIndex(index: string) : Observable<any[]> { + let ddlQuery = "DROP INDEX " + index; // + " IF EXISTS;"; + return this.executeDDLSQLQuery(ddlQuery); + } + + /* + * Executes a sql++ ddl query against AsterixDB + * response is a JSON object with following structure: + metrics: Metrics; + requestId: string; + results: any[]; + signature: string; + status: string; + */ + executeDDLSQLQuery(ddlQuery: string): Observable<any[]> { + const apiUrl = AsterixRestApiUrl; + return this.http.post(apiUrl, {statement: ddlQuery}) + .map((response: Response) => { return response }) + .catch((error: any) => this.handleExecuteQueryError(error)); + } + + /* + * Executes a sql++ query against AsterixDB + * response is a JSON object with following structure: + metrics: Metrics; + requestId: string; + results: any[]; + signature: string; + status: string; + */ + executeSQLQuery(query: string): Observable<any[]> { + const apiUrl = AsterixRestApiUrl; + return this.http.post(apiUrl, {statement: query}) + .map((response: Response) => { return response }) + .catch((error: any) => this.handleExecuteQueryError(error)); + } + + /* + * AsterixDB query-service API raises HTTP errors if the sql++ query has some + * syntax error, or some elements in the query are not found + * this function extract the error JSON object with the relevant information + response is a JSON object with following structure: + metrics: Metrics; + requestId: string; + errors: any[]; + signature: string; + status: string; + */ + private handleExecuteQueryError(error: any): Promise<any> { + console.log(error) + return Promise.reject(error.error || error); + } +} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/assets/asterixdb_tm.png ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/assets/asterixdb_tm.png b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/assets/asterixdb_tm.png new file mode 100755 index 0000000..0fa2ff0 Binary files /dev/null and b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/assets/asterixdb_tm.png differ http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/environments/environment.prod.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/environments/environment.prod.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/environments/environment.prod.ts new file mode 100755 index 0000000..ca15503 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/environments/environment.prod.ts @@ -0,0 +1,16 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +export const environment = { + production: true +}; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/environments/environment.ts ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/environments/environment.ts b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/environments/environment.ts new file mode 100755 index 0000000..2750f0a --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/environments/environment.ts @@ -0,0 +1,21 @@ +/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +// The file contents for the current environment will overwrite these during build. +// The build system defaults to the dev environment which uses `environment.ts`, but if you do +// `ng build --env=prod` then `environment.prod.ts` will be used instead. +// The list of which env maps to which file can be found in `.angular-cli.json`. + +export const environment = { + production: false +}; http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/favicon.ico ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/favicon.ico b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/favicon.ico new file mode 100755 index 0000000..282c28d Binary files /dev/null and b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/favicon.ico differ http://git-wip-us.apache.org/repos/asf/asterixdb/blob/a7e8dbe3/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/index.html ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/index.html b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/index.html new file mode 100755 index 0000000..8dab418 --- /dev/null +++ b/asterixdb/asterix-dashboard/src/main/resources/dashboard/src/index.html @@ -0,0 +1,30 @@ +<!--/* +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/--> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + <title>AsterixDb Administration Console</title> + <base href="/"> + <link rel="icon" type="image/x-icon" href="favicon.ico"> + <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Mono"> + <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500"> + <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> + </head> + <body> + <awc-root></awc-root> + </body> +</html>
