WIP: updates, remove graphql (many things commented out)

This commit is contained in:
phil 2024-02-28 01:19:35 +05:30
parent 38ff5b8e59
commit d464897b8b
28 changed files with 6391 additions and 5166 deletions

View file

@ -96,19 +96,19 @@
"serve": { "serve": {
"builder": "@angular-devkit/build-angular:dev-server", "builder": "@angular-devkit/build-angular:dev-server",
"options": { "options": {
"browserTarget": "gisaf-app:build", "proxyConfig": "proxy.conf.json",
"proxyConfig": "proxy.conf.json" "buildTarget": "gisaf-app:build"
}, },
"configurations": { "configurations": {
"production": { "production": {
"browserTarget": "gisaf-app:build:production" "buildTarget": "gisaf-app:build:production"
} }
} }
}, },
"extract-i18n": { "extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n", "builder": "@angular-devkit/build-angular:extract-i18n",
"options": { "options": {
"browserTarget": "gisaf-app:build" "buildTarget": "gisaf-app:build"
} }
}, },
"test": { "test": {

7849
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -27,39 +27,36 @@
], ],
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^15.2.1", "@angular/animations": "^16.2.12",
"@angular/cdk": "^15.2.1", "@angular/cdk": "^16.2.14",
"@angular/common": "^15.2.1", "@angular/common": "^16.2.12",
"@angular/compiler": "^15.2.1", "@angular/compiler": "^16.2.12",
"@angular/core": "^15.2.1", "@angular/core": "^16.2.12",
"@angular/forms": "^15.2.1", "@angular/forms": "^16.2.12",
"@angular/material": "^15.2.1", "@angular/material": "^16.2.14",
"@angular/platform-browser": "^15.2.1", "@angular/platform-browser": "^16.2.12",
"@angular/platform-browser-dynamic": "^15.2.1", "@angular/platform-browser-dynamic": "^16.2.12",
"@angular/platform-server": "^15.2.1", "@angular/platform-server": "^16.2.12",
"@angular/router": "^15.2.1", "@angular/router": "^16.2.12",
"@apollo/client": "^3.4.16",
"@mapbox/point-geometry": "^0.1.0", "@mapbox/point-geometry": "^0.1.0",
"@maplibre/ngx-maplibre-gl": "^13.0.0", "@maplibre/ngx-maplibre-gl": "^13.0.0",
"@turf/bbox": "^6.5.0", "@turf/bbox": "^6.5.0",
"@turf/distance": "^6.5.0", "@turf/distance": "^6.5.0",
"angular-plotly.js": "^4.0.4", "angular-plotly.js": "^5.2.2",
"apollo-angular": "^4.2.1",
"core-js": "^2.6.3", "core-js": "^2.6.3",
"graphql": "^15.6.1",
"maplibre-gl": "^2.4.0", "maplibre-gl": "^2.4.0",
"ngx-flexible-layout": "15.0.1", "ngx-flexible-layout": "~16.0",
"plotly.js-basic-dist-min": "^2.8.1", "plotly.js-basic-dist-min": "2.29.1",
"rxjs": "^7.4.0", "rxjs": "^7.4.0",
"subscriptions-transport-ws": "^0.9.17", "subscriptions-transport-ws": "^0.9.17",
"ts-helpers": "^1.1.2", "ts-helpers": "^1.1.2",
"zone.js": "~0.11.4" "zone.js": "~0.13.3"
}, },
"devDependencies": { "devDependencies": {
"@angular-devkit/build-angular": "^15.2.1", "@angular-devkit/build-angular": "^16.2.12",
"@angular/cli": "^15.2.1", "@angular/cli": "^16.2.12",
"@angular/compiler-cli": "^15.2.1", "@angular/compiler-cli": "^16.2.12",
"@angular/language-service": "^15.2.1", "@angular/language-service": "^16.2.12",
"@types/core-js": "^2.5.0", "@types/core-js": "^2.5.0",
"@types/geojson": "^7946.0.7", "@types/geojson": "^7946.0.7",
"@types/jasmine": "~3.6.0", "@types/jasmine": "~3.6.0",
@ -82,6 +79,6 @@
"ts-node": "^8.0.2", "ts-node": "^8.0.2",
"tslib": "^2.0.0", "tslib": "^2.0.0",
"tslint": "~6.1.0", "tslint": "~6.1.0",
"typescript": "~4.8.4" "typescript": "~5.1.6"
} }
} }

View file

@ -1,9 +1,9 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Observable, pipe, BehaviorSubject } from 'rxjs' import { Observable, pipe, BehaviorSubject, of as observableOf } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular' // import { Apollo, gql } from 'apollo-angular'
import { Tag } from '../info/info-tags/tags.service' import { Tag } from '../info/info-tags/tags.service'
import { TaggedLayer, TaggedFeature, FormFieldInput } from '../info/info-data.service' import { TaggedLayer, TaggedFeature, FormFieldInput } from '../info/info-data.service'
@ -70,63 +70,63 @@ export class Store {
} }
const getTagsActionsQuery = gql` // const getTagsActionsQuery = gql`
query actionsPlugins { // query actionsPlugins {
actionsPlugins { // actionsPlugins {
store // store
actions { // actions {
name // name
roles // roles
params { // params {
name // name
type // type
dflt // dflt
} // }
} // }
} // }
} // }
` // `
const executeTagsActionsQuery = gql` // const executeTagsActionsQuery = gql`
mutation executeAction( // mutation executeAction(
$stores: [String]!, // $stores: [String]!,
$ids: [[String]]!, // $ids: [[String]]!,
$names: [String]!, // $names: [String]!,
$params: [ActionParamInput], // $params: [ActionParamInput],
$formFields: [FormFieldInput] // $formFields: [FormFieldInput]
) { // ) {
executeAction( // executeAction(
stores: $stores, // stores: $stores,
ids: $ids, // ids: $ids,
names: $names, // names: $names,
params: $params, // params: $params,
formFields: $formFields, // formFields: $formFields,
) { // ) {
result { // result {
message // message
actionResults { // actionResults {
name // name
message // message
actionResults { // actionResults {
message // message
taggedLayers { // taggedLayers {
store // store
taggedFeatures { // taggedFeatures {
id // id
lon // lon
lat // lat
tags { // tags {
key // key
value // value
} // }
} // }
} // }
} // }
} // }
} // }
} // }
} // }
` // `
@Injectable() @Injectable()
@ -137,7 +137,7 @@ export class ActionsService {
public actionsProviderService$ = this.actionsProviderService.asObservable() public actionsProviderService$ = this.actionsProviderService.asObservable()
constructor( constructor(
private apollo: Apollo, // private apollo: Apollo,
) { ) {
this.getTagsActionsStores().subscribe( this.getTagsActionsStores().subscribe(
actionsStores => { actionsStores => {
@ -147,32 +147,34 @@ export class ActionsService {
} }
public getTagsActionsStores(): Observable<ActionsStore[]> { public getTagsActionsStores(): Observable<ActionsStore[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getTagsActionsQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => { // query: getTagsActionsQuery,
let actionStores = res['data']['actionsPlugins'].map(pipe( // }).pipe(map(
store => new Store( // res => {
store['store'], // let actionStores = res['data']['actionsPlugins'].map(pipe(
store['actions'].map( // store => new Store(
action => new Action( // store['store'],
action['name'], // store['actions'].map(
action['roles'], // action => new Action(
action['params'].map( // action['name'],
param => new ActionParam( // action['roles'],
param['name'], // action['params'].map(
param['type'], // param => new ActionParam(
param['dflt'] // param['name'],
) // param['type'],
) // param['dflt']
) // )
) // )
) // )
)) // )
this.actionsProviderService.next(actionStores) // )
return actionStores // ))
} // this.actionsProviderService.next(actionStores)
)) // return actionStores
// }
// ))
} }
public execute( public execute(
@ -182,51 +184,53 @@ export class ActionsService {
params: ActionParam[], params: ActionParam[],
formFields?: FormFieldInput[] formFields?: FormFieldInput[]
): Observable<ActionsResults> { ): Observable<ActionsResults> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: executeTagsActionsQuery, return observableOf()
variables: { // return this.apollo.mutate({
stores: stores, // mutation: executeTagsActionsQuery,
ids: ids, // variables: {
names: actionNames, // stores: stores,
params: params, // ids: ids,
formFields: formFields // names: actionNames,
} // params: params,
}).pipe(map( // formFields: formFields
result => result['data']['executeAction']['result'].map( // }
res => new ActionsResults( // }).pipe(map(
res['message'], // result => result['data']['executeAction']['result'].map(
res['actionResults'].map( // res => new ActionsResults(
r => new ActionResults( // res['message'],
r['name'], // res['actionResults'].map(
r['message'], // r => new ActionResults(
r['actionResults'] && r['actionResults'].map( // r['name'],
actionResults => new ActionResult( // r['message'],
actionResults['name'], // r['actionResults'] && r['actionResults'].map(
actionResults['message'], // actionResults => new ActionResult(
(actionResults['taggedLayers'] || []).map( // actionResults['name'],
taggedLayer => new TaggedLayer( // actionResults['message'],
taggedLayer['store'], // (actionResults['taggedLayers'] || []).map(
taggedLayer['taggedFeatures'].map( // taggedLayer => new TaggedLayer(
taggedFeature => new TaggedFeature( // taggedLayer['store'],
taggedFeature['id'], // taggedLayer['taggedFeatures'].map(
taggedFeature['lon'], // taggedFeature => new TaggedFeature(
taggedFeature['lat'], // taggedFeature['id'],
taggedFeature['tags'].map( // taggedFeature['lon'],
tag => new Tag( // taggedFeature['lat'],
tag['key'], // taggedFeature['tags'].map(
tag['value'] // tag => new Tag(
) // tag['key'],
) // tag['value']
) // )
) // )
) // )
) // )
) // )
) // )
) // )
) // )
) // )
) // )
)) // )
// )
// ))
} }
} }

View file

@ -3,10 +3,10 @@ import { Validators, UntypedFormGroup, UntypedFormControl } from '@angular/forms
import { MatTableDataSource } from '@angular/material/table' import { MatTableDataSource } from '@angular/material/table'
import { Observable, forkJoin } from 'rxjs' import { Observable, forkJoin, of as observableOf } from 'rxjs'
import { map, mergeMap } from 'rxjs/operators' import { map, mergeMap } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular' // import { Apollo, gql } from 'apollo-angular'
const fieldTypeMap = { const fieldTypeMap = {
Int: 'number', Int: 'number',
@ -14,57 +14,57 @@ const fieldTypeMap = {
Boolean: 'checkbox', Boolean: 'checkbox',
} }
const introspectionQuery = gql` // const introspectionQuery = gql`
query introspect ($modelName: String!) { // query introspect ($modelName: String!) {
__type(name: $modelName) { // __type(name: $modelName) {
name // name
fields { // fields {
name // name
type { // type {
name // name
kind // kind
ofType { // ofType {
name // name
} // }
} // }
} // }
} // }
} // }
` // `
const inspectionQuery = gql` // const inspectionQuery = gql`
query inspect ($modelName: String!) { // query inspect ($modelName: String!) {
inspect(modelName: $modelName) { // inspect(modelName: $modelName) {
pkFields // pkFields
relation_fields // relation_fields
joins { // joins {
name // name
target // target
rel_field // rel_field
} // }
} // }
} // }
` // `
const dashboardPageQuery = gql` // const dashboardPageQuery = gql`
query dashboard_page ($group: String!, $name: String!) { // query dashboard_page ($group: String!, $name: String!) {
dashboard_page(group: $group, name: $name) { // dashboard_page(group: $group, name: $name) {
name // name
group // group
description // description
html // html
notebook // notebook
time // time
dfData // dfData
plotData // plotData
attachment // attachment
expandedPanes // expandedPanes
sections { // sections {
name // name
plot // plot
} // }
} // }
}` // }`
export class FieldIntrospection { export class FieldIntrospection {
constructor( constructor(
@ -128,13 +128,15 @@ export class ModelIntrospection {
} }
getMutationQuery() { getMutationQuery() {
return gql` console.warn('Migrate Graphql')
mutation mutation(${this.mutationFields}) { return observableOf()
mutation(${this.mutationVars}) { // return gql`
${this.mutationData} // mutation mutation(${this.mutationFields}) {
} // mutation(${this.mutationVars}) {
} // ${this.mutationData}
` // }
// }
// `
} }
} }
@ -220,7 +222,7 @@ export class Model {
@Injectable() @Injectable()
export class ModelDataService { export class ModelDataService {
constructor( constructor(
private apollo: Apollo // private apollo: Apollo
) {} ) {}
fullInspect(modelName): Observable<Model> { fullInspect(modelName): Observable<Model> {
@ -233,64 +235,70 @@ export class ModelDataService {
} }
inspect(modelName): Observable<ModelInspection> { inspect(modelName): Observable<ModelInspection> {
console.warn('Migrate Graphql')
return observableOf()
// Inspection (Gisaf) // Inspection (Gisaf)
return this.get(inspectionQuery, {'modelName': modelName}).pipe(map( // return this.get(inspectionQuery, {'modelName': modelName}).pipe(map(
res => { // res => {
let joins = res['inspect']['joins'].map( // let joins = res['inspect']['joins'].map(
join => new JoinField(join['name'], join['target'], join['rel_field']) // join => new JoinField(join['name'], join['target'], join['rel_field'])
) // )
return new ModelInspection( // return new ModelInspection(
res['inspect']['pkFields'], // res['inspect']['pkFields'],
res['inspect']['relation_fields'], // res['inspect']['relation_fields'],
joins // joins
) // )
} // }
)) // ))
} }
introspect(modelName): Observable<ModelIntrospection> { introspect(modelName): Observable<ModelIntrospection> {
// Introspection (Graphql) // Introspection (Graphql)
return this.get(introspectionQuery, {'modelName': modelName}).pipe(map( console.warn('Migrate Graphql')
res => { return observableOf()
var relations = [] // return this.get(introspectionQuery, {'modelName': modelName}).pipe(map(
let _fields = res['__type']['fields'] // res => {
// Find the primary keys // var relations = []
var fields = _fields.filter(f => !f.type.name && f.type.kind=='NON_NULL').map( // let _fields = res['__type']['fields']
f => new FieldIntrospection(f.name, f['type']['ofType']['name'], true) // // Find the primary keys
) // var fields = _fields.filter(f => !f.type.name && f.type.kind=='NON_NULL').map(
var pkFieldNames = fields.map(f => f.name) // f => new FieldIntrospection(f.name, f['type']['ofType']['name'], true)
_fields.forEach( // )
resField => { // var pkFieldNames = fields.map(f => f.name)
let name = resField['name'] // _fields.forEach(
let type = resField['type'] // resField => {
// Skip primary keys // let name = resField['name']
if (pkFieldNames.indexOf(name) != -1) { // let type = resField['type']
return // // Skip primary keys
} // if (pkFieldNames.indexOf(name) != -1) {
if (name == 'geom') { // return
// Remove geom column // }
// XXX: Should be marked as geojson type // if (name == 'geom') {
// and might be a link to the map or something like that // // Remove geom column
return // // XXX: Should be marked as geojson type
} // // and might be a link to the map or something like that
if (type['kind'] == 'OBJECT') { // return
// Relation // }
return // if (type['kind'] == 'OBJECT') {
} // // Relation
fields.push(new FieldIntrospection(name, type['name'])) // return
} // }
) // fields.push(new FieldIntrospection(name, type['name']))
return new ModelIntrospection(modelName, fields, relations) // }
} // )
)) // return new ModelIntrospection(modelName, fields, relations)
// }
// ))
} }
mutate(model: ModelIntrospection, values: object): Observable<object> { mutate(model: ModelIntrospection, values: object): Observable<object> {
let mutationQuery = model.getMutationQuery() console.warn('Migrate Graphql')
return this.apollo.mutate({ return observableOf()
mutation: mutationQuery, // let mutationQuery = model.getMutationQuery()
variables: values, // return this.apollo.mutate({
}) // mutation: mutationQuery,
// variables: values,
// })
} }
resolveItemData(modelName: string, pk: string): Observable<object> { resolveItemData(modelName: string, pk: string): Observable<object> {
@ -299,22 +307,24 @@ export class ModelDataService {
model => { model => {
// XXX: get pk type and name from model introspection // XXX: get pk type and name from model introspection
let pkField = model.introspection.pkFields()[0] let pkField = model.introspection.pkFields()[0]
let query = gql` console.warn('Migrate Graphql')
query item ($pk: ID) { return observableOf()
${modelName} (pk:$pk) { // let query = gql`
${model.introspection.columnsForGql()} // query item ($pk: ID) {
} // ${modelName} (pk:$pk) {
}` // ${model.introspection.columnsForGql()}
return this.get(query, {pk: pk}).pipe(map( // }
item => { // }`
if (item) { // return this.get(query, {pk: pk}).pipe(map(
return { // item => {
'item': item, // if (item) {
'model': model, // return {
} // 'item': item,
} // 'model': model,
} // }
)) // }
// }
// ))
} }
) )
) )
@ -325,80 +335,88 @@ export class ModelDataService {
fields = model.columns() fields = model.columns()
} }
const fieldList = fields.join(' ') const fieldList = fields.join(' ')
const query = gql`query model {${model.name}{${fieldList}}}` console.warn('Migrate Graphql')
return this.get(query) return observableOf()
// const query = gql`query model {${model.name}{${fieldList}}}`
// return this.get(query)
} }
get(query, vars: object = {}): Observable<any> { get(query, vars: object = {}): Observable<any> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: query, return observableOf()
variables: vars, // return this.apollo.query({
errorPolicy: 'all', // query: query,
}).pipe(map( // variables: vars,
result => { // errorPolicy: 'all',
if (result.errors) { // }).pipe(map(
throw result.errors.map(err => err.message).join(', ') // result => {
} // if (result.errors) {
else { // throw result.errors.map(err => err.message).join(', ')
return result.data // }
} // else {
} // return result.data
)) // }
// }
// ))
} }
} }
@Injectable() @Injectable()
export class DashboardDataService { export class DashboardDataService {
constructor( constructor(
private apollo: Apollo // private apollo: Apollo
) {} ) {}
getDashboardPage(group: string, name: string): Observable<DashboardPage> { getDashboardPage(group: string, name: string): Observable<DashboardPage> {
return this.get(dashboardPageQuery, {'name': name, 'group': group}).pipe(map( console.warn('Migrate Graphql')
res => { return observableOf()
if (res['errors'] && res['errors'].length > 0) { // return this.get(dashboardPageQuery, {'name': name, 'group': group}).pipe(map(
return new DashboardPage( // res => {
name, // if (res['errors'] && res['errors'].length > 0) {
group, // return new DashboardPage(
res['errors'].map(e => e.message).join(', '), // name,
) // group,
} // res['errors'].map(e => e.message).join(', '),
// )
// }
let page = res['dashboard_page'] // let page = res['dashboard_page']
return new DashboardPage( // return new DashboardPage(
page['name'], // page['name'],
page['group'], // page['group'],
'', // '',
page['description'], // page['description'],
page['html'], // page['html'],
page['notebook'], // page['notebook'],
JSON.parse(page['dfData']), // JSON.parse(page['dfData']),
JSON.parse(page['plotData']), // JSON.parse(page['plotData']),
page['time'], // page['time'],
page['attachment'], // page['attachment'],
page['expandedPanes'], // page['expandedPanes'],
page['sections'] ? page['sections'].map( // page['sections'] ? page['sections'].map(
section => new DashboardPageSection( // section => new DashboardPageSection(
section['name'], // section['name'],
section['plot'] // section['plot']
) // )
) : [] // ) : []
) // )
} // }
)) // ))
} }
get(query, vars: object = {}): Observable<any> { get(query, vars: object = {}): Observable<any> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: query, return observableOf()
variables: vars // return this.apollo.query({
}).pipe(map( // query: query,
result => { // variables: vars
if (result.errors && result.errors.length > 0) { // }).pipe(map(
return result // result => {
} // if (result.errors && result.errors.length > 0) {
return result.data // return result
} // }
)) // return result.data
// }
// ))
} }
} }

View file

@ -1,12 +1,12 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router' import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable, forkJoin } from 'rxjs' import { Observable, forkJoin } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { AdminBasket, AdminBasketDataService } from './data.service' import { AdminBasket, AdminBasketDataService } from './data.service'
@Injectable() @Injectable()
export class BasketResolver implements Resolve<object> { export class BasketResolver {
constructor( constructor(
private router: Router, private router: Router,
private basketDataService: AdminBasketDataService, private basketDataService: AdminBasketDataService,

View file

@ -1,9 +1,9 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Observable } from 'rxjs' import { Observable, of as observableOf } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular' // import { Apollo, gql } from 'apollo-angular'
import { Project } from '../admin-data.service' import { Project } from '../admin-data.service'
@ -53,171 +53,181 @@ export class AdminBasketUploadFieldData {
) {} ) {}
} }
const getAdminBasketsQuery = gql` // const getAdminBasketsQuery = gql`
query admin_baskets { // query admin_baskets {
admin_baskets { // admin_baskets {
name // name
} // }
} // }
` // `
const getAdminBasketUploadFieldDataQuery = gql` // const getAdminBasketUploadFieldDataQuery = gql`
query admin_basket_upload_field_data { // query admin_basket_upload_field_data {
admin_basket_upload_field_data { // admin_basket_upload_field_data {
store // store
status // status
project // project
surveyor // surveyor
equipment // equipment
} // }
} // }
` // `
const getAdminBasketQuery = gql` // const getAdminBasketQuery = gql`
query admin_basket ($name: String!) { // query admin_basket ($name: String!) {
admin_basket (name: $name) { // admin_basket (name: $name) {
name // name
files { // files {
id // id
name // name
dir // dir
url // url
md5 // md5
time // time
comment // comment
status // status
store // store
project // project
surveyor // surveyor
equipment // equipment
} // }
columns // columns
uploadFields // uploadFields
projects // projects
} // }
} // }
` // `
const deleteAdminBasketItemMutation = gql` // const deleteAdminBasketItemMutation = gql`
mutation deleteBasketItem ($basket: String!, $id: Int!) { // mutation deleteBasketItem ($basket: String!, $id: Int!) {
deleteBasketItem (basket: $basket, id: $id) { // deleteBasketItem (basket: $basket, id: $id) {
result // result
} // }
} // }
` // `
const importAdminBasketItemMutation = gql` // const importAdminBasketItemMutation = gql`
mutation importBasketItem ($basket: String!, $id: Int!, $dryRun: Boolean) { // mutation importBasketItem ($basket: String!, $id: Int!, $dryRun: Boolean) {
importBasketItem (basket: $basket, id: $id, dryRun: $dryRun) { // importBasketItem (basket: $basket, id: $id, dryRun: $dryRun) {
result { // result {
message // message
time // time
details // details
} // }
} // }
} // }
` // `
@Injectable() @Injectable()
export class AdminBasketDataService { export class AdminBasketDataService {
constructor( constructor(
private apollo: Apollo, // private apollo: Apollo,
) {} ) {}
getBaskets(): Observable<AdminBasket[]> { getBaskets(): Observable<AdminBasket[]> {
// Get the list a basket names // Get the list a basket names
return this.apollo.query({ console.warn('Migrate Graphql')
query: getAdminBasketsQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['data']['admin_baskets'].map( // query: getAdminBasketsQuery,
(data: object) => new AdminBasket( // }).pipe(map(
data['name'], // res => res['data']['admin_baskets'].map(
) // (data: object) => new AdminBasket(
) // data['name'],
)) // )
// )
// ))
} }
getBasketUploadFieldData(): Observable<AdminBasketUploadFieldData> { getBasketUploadFieldData(): Observable<AdminBasketUploadFieldData> {
// Get the list a basket names // Get the list a basket names
return this.apollo.query({ console.warn('Migrate Graphql')
query: getAdminBasketUploadFieldDataQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['data']['admin_basket_upload_field_data'].map( // query: getAdminBasketUploadFieldDataQuery,
(data: object) => new AdminBasketUploadFieldData( // }).pipe(map(
data['store'], // res => res['data']['admin_basket_upload_field_data'].map(
data['status'], // (data: object) => new AdminBasketUploadFieldData(
data['project'], // data['store'],
data['surveyor'], // data['status'],
data['equipment'], // data['project'],
) // data['surveyor'],
) // data['equipment'],
)) // )
// )
// ))
} }
getBasket(name: string): Observable<AdminBasket> { getBasket(name: string): Observable<AdminBasket> {
// Get all info and content of a basket // Get all info and content of a basket
return this.apollo.query({ console.warn('Migrate Graphql')
query: getAdminBasketQuery, return observableOf()
variables: { // return this.apollo.query({
name: name // query: getAdminBasketQuery,
} // variables: {
}).pipe(map( // name: name
res => { // }
let data = res['data']['admin_basket'] // }).pipe(map(
return new AdminBasket( // res => {
data['name'], // let data = res['data']['admin_basket']
data['files'].map(file => new AdminBasketFile( // return new AdminBasket(
file['id'], // data['name'],
file['dir'], // data['files'].map(file => new AdminBasketFile(
file['name'], // file['id'],
file['url'], // file['dir'],
file['md5'], // file['name'],
new Date(file['time']), // file['url'],
file['comment'], // file['md5'],
file['status'], // new Date(file['time']),
file['store'], // file['comment'],
file['project'], // file['status'],
file['surveyor'], // file['store'],
file['equipment'], // file['project'],
)), // file['surveyor'],
data['columns'], // file['equipment'],
data['uploadFields'], // )),
// XXX: the proejct id isn't actually used in the UI, // data['columns'],
// but required in class definition // data['uploadFields'],
data['projects'] && data['projects'].map( // // XXX: the proejct id isn't actually used in the UI,
(projectName: string) => new Project(undefined, projectName) // // but required in class definition
), // data['projects'] && data['projects'].map(
) // (projectName: string) => new Project(undefined, projectName)
} // ),
)) // )
// }
// ))
} }
importItem(basket: string, id: number, dryRun: boolean=false): Observable<BasketImportResult> { importItem(basket: string, id: number, dryRun: boolean=false): Observable<BasketImportResult> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: importAdminBasketItemMutation, return observableOf()
variables: { // return this.apollo.mutate({
basket: basket, // mutation: importAdminBasketItemMutation,
id: id, // variables: {
dryRun: dryRun // basket: basket,
} // id: id,
}).pipe(map( // dryRun: dryRun
resp => new BasketImportResult( // }
resp['data']['importBasketItem']['result']['time'], // }).pipe(map(
resp['data']['importBasketItem']['result']['message'], // resp => new BasketImportResult(
JSON.parse(resp['data']['importBasketItem']['result']['details']), // resp['data']['importBasketItem']['result']['time'],
) // resp['data']['importBasketItem']['result']['message'],
)) // JSON.parse(resp['data']['importBasketItem']['result']['details']),
// )
// ))
} }
deleteItem(basket: string, id: number) { deleteItem(basket: string, id: number) {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: deleteAdminBasketItemMutation, return observableOf()
variables: { // return this.apollo.mutate({
basket: basket, // mutation: deleteAdminBasketItemMutation,
id: id, // variables: {
} // basket: basket,
}).pipe(map( // id: id,
resp => resp['data']['deleteBasketItem']['result'] // }
)) // }).pipe(map(
// resp => resp['data']['deleteBasketItem']['result']
// ))
} }
} }

View file

@ -1,8 +1,8 @@
import { Injectable, Input } from '@angular/core' import { Injectable, Input } from '@angular/core'
import { Observable } from 'rxjs' import { Observable, of as observableOf } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular' // import { Apollo, gql } from 'apollo-angular'
import { Store } from './admin-manage/data.service' import { Store } from './admin-manage/data.service'
@ -39,87 +39,91 @@ export class SurveyMeta {
) {} ) {}
} }
const getSurveyMeta = gql` // const getSurveyMeta = gql`
query survey_meta { // query survey_meta {
survey_meta { // survey_meta {
projects { // projects {
id // id
name // name
} // }
surveyors { // surveyors {
id // id
name // name
} // }
equipments { // equipments {
id // id
name // name
} // }
stores_misc { // stores_misc {
name // name
} // }
stores_line_work { // stores_line_work {
name // name
} // }
statuses // statuses
default // default
} // }
} // }
` // `
const admin_models_menu_bar_query = gql` // const admin_models_menu_bar_query = gql`
query admin_models_menu_bar { // query admin_models_menu_bar {
admin_models_menu_bar{ // admin_models_menu_bar{
name // name
items{ // items{
name // name
module // module
} // }
} // }
}` // }`
@Injectable() @Injectable()
export class AdminDataService { export class AdminDataService {
surveyMeta: SurveyMeta surveyMeta: SurveyMeta
constructor( constructor(
private apollo: Apollo, // private apollo: Apollo,
) {} ) {}
getModelsMenuBar(): Observable<object[]> { getModelsMenuBar(): Observable<object[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: admin_models_menu_bar_query return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['admin_models_menu_bar_query'] // query: admin_models_menu_bar_query
)) // }).pipe(map(
// res => res['admin_models_menu_bar_query']
// ))
} }
getSurveyMeta(): Observable<SurveyMeta> { getSurveyMeta(): Observable<SurveyMeta> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getSurveyMeta, return observableOf()
}).pipe(map( // return this.apollo.query({
resp => { // query: getSurveyMeta,
let data = resp['data']['survey_meta'] // }).pipe(map(
this.surveyMeta = new SurveyMeta( // resp => {
data['projects'].map( // let data = resp['data']['survey_meta']
item => new Project(item['id'], item['name']) // this.surveyMeta = new SurveyMeta(
).sort((i, j) => i.name > j.name ? 1 : -1), // data['projects'].map(
data['surveyors'].map( // item => new Project(item['id'], item['name'])
item => new Surveyor(item['id'], item['name']) // ).sort((i, j) => i.name > j.name ? 1 : -1),
).sort((i, j) => i.name > j.name ? 1 : -1), // data['surveyors'].map(
data['equipments'].map( // item => new Surveyor(item['id'], item['name'])
item => new Equipment(item['id'], item['name']) // ).sort((i, j) => i.name > j.name ? 1 : -1),
).sort((i, j) => i.name > j.name ? 1 : -1), // data['equipments'].map(
data['statuses'], // item => new Equipment(item['id'], item['name'])
data['stores_misc'].map( // ).sort((i, j) => i.name > j.name ? 1 : -1),
item => new Store(item['name']) // data['statuses'],
).sort((i, j) => i.name > j.name ? 1 : -1), // data['stores_misc'].map(
data['stores_line_work'].map( // item => new Store(item['name'])
item => new Store(item['name']) // ).sort((i, j) => i.name > j.name ? 1 : -1),
).sort((i, j) => i.name > j.name ? 1 : -1), // data['stores_line_work'].map(
JSON.parse(data['default']), // item => new Store(item['name'])
) // ).sort((i, j) => i.name > j.name ? 1 : -1),
return this.surveyMeta // JSON.parse(data['default']),
} // )
)) // return this.surveyMeta
// }
// ))
} }
} }

View file

@ -1,12 +1,12 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router' import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable } from 'rxjs' import { Observable } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { ModelDataService } from '../../_services/apollo.service' import { ModelDataService } from '../../_services/apollo.service'
@Injectable() @Injectable()
export class DetailResolver implements Resolve<object> { export class DetailResolver {
constructor( constructor(
private modelDataService: ModelDataService, private modelDataService: ModelDataService,
private router: Router private router: Router

View file

@ -5,7 +5,7 @@ import { UntypedFormGroup, FormControl } from '@angular/forms'
import { map, switchMap } from 'rxjs/operators' import { map, switchMap } from 'rxjs/operators'
import { gql } from 'apollo-angular' // import { gql } from 'apollo-angular'
import { ModelDataService, JoinField } from '../../_services/apollo.service' import { ModelDataService, JoinField } from '../../_services/apollo.service'
import { Relation } from '../models' import { Relation } from '../models'
@ -27,7 +27,9 @@ export class JoinSelectComponent implements OnInit {
ngOnInit() { ngOnInit() {
var modelName = this.join.target.split('.').pop() var modelName = this.join.target.split('.').pop()
let query = gql`query model {${modelName}{name id}}` console.warn('Migrate Graphql')
let query = ''
// let query = gql`query model {${modelName}{name id}}`
this.modelDataService.get(query).pipe(map(data => { this.modelDataService.get(query).pipe(map(data => {
return data[modelName] return data[modelName]
})).subscribe(data => { })).subscribe(data => {

View file

@ -1,9 +1,9 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Observable, BehaviorSubject, forkJoin } from 'rxjs' import { Observable, BehaviorSubject, forkJoin, of as observableOf } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular' // import { Apollo, gql } from 'apollo-angular'
import { MatDialog } from '@angular/material/dialog' import { MatDialog } from '@angular/material/dialog'
@ -12,128 +12,128 @@ import { GisafAdminAccessUserDialogComponent } from './user-dialog.component'
import { Role, User, ACL } from './models' import { Role, User, ACL } from './models'
const getUsersQuery = gql` // const getUsersQuery = gql`
query users { // query users {
users { // users {
id // id
name // name
email // email
active // active
} // }
} // }
` // `
const getRolesQuery = gql` // const getRolesQuery = gql`
query getRoles { // query getRoles {
roles { // roles {
id // id
name // name
description // description
} // }
} // }
` // `
const getAclsQuery = gql` // const getAclsQuery = gql`
query acls { // query acls {
acls { // acls {
user_id // user_id
role_ids // role_ids
} // }
} // }
` // `
const addUserRoleMutation = gql` // const addUserRoleMutation = gql`
mutation addUserRole( // mutation addUserRole(
$user_id: Int!, // $user_id: Int!,
$role_id: Int!, // $role_id: Int!,
) { // ) {
addUserRole( // addUserRole(
user_id: $user_id, // user_id: $user_id,
role_id: $role_id, // role_id: $role_id,
) { // ) {
result // result
} // }
} // }
` // `
const deleteUserRoleMutation = gql` // const deleteUserRoleMutation = gql`
mutation deleteUserRole( // mutation deleteUserRole(
$user_id: Int!, // $user_id: Int!,
$role_id: Int!, // $role_id: Int!,
) { // ) {
deleteUserRole( // deleteUserRole(
user_id: $user_id, // user_id: $user_id,
role_id: $role_id, // role_id: $role_id,
) { // ) {
result // result
} // }
} // }
` // `
const deleteUserMutation = gql` // const deleteUserMutation = gql`
mutation deleteUser( // mutation deleteUser(
$id: Int!, // $id: Int!,
) { // ) {
deleteUser( // deleteUser(
id: $id, // id: $id,
) { // ) {
id // id
} // }
} // }
` // `
const deleteRoleMutation = gql` // const deleteRoleMutation = gql`
mutation deleteRole( // mutation deleteRole(
$id: Int!, // $id: Int!,
) { // ) {
deleteRole( // deleteRole(
id: $id, // id: $id,
) { // ) {
id // id
} // }
} // }
` // `
const saveRoleMutation = gql` // const saveRoleMutation = gql`
mutation saveRole( // mutation saveRole(
$id: Int, // $id: Int,
$name: String!, // $name: String!,
$description: String! // $description: String!
) { // ) {
saveRole ( // saveRole (
id: $id, // id: $id,
name: $name, // name: $name,
description: $description // description: $description
) { // ) {
id // id
} // }
} // }
` // `
const saveUserMutation = gql` // const saveUserMutation = gql`
mutation saveUser( // mutation saveUser(
$id: Int, // $id: Int,
$name: String!, // $name: String!,
$email: String!, // $email: String!,
$password: String, // $password: String,
$active: Boolean!, // $active: Boolean!,
) { // ) {
saveUser ( // saveUser (
id: $id, // id: $id,
name: $name, // name: $name,
email: $email, // email: $email,
active: $active, // active: $active,
password: $password // password: $password
) { // ) {
id // id
} // }
} // }
` // `
@Injectable() @Injectable()
export class AdminManageAccessDataService { export class AdminManageAccessDataService {
constructor( constructor(
private apollo: Apollo, // private apollo: Apollo,
public dialog: MatDialog, public dialog: MatDialog,
) {} ) {}
@ -183,45 +183,51 @@ export class AdminManageAccessDataService {
} }
getUsers(): Observable<User[]> { getUsers(): Observable<User[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getUsersQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => // query: getUsersQuery,
res['data']['users'].map( // }).pipe(map(
// Really create an object because User has roles in its constructor // res =>
(item: object) => new User( // res['data']['users'].map(
item['id'], // // Really create an object because User has roles in its constructor
item['name'], // (item: object) => new User(
item['email'], // item['id'],
item['active'], // item['name'],
) // item['email'],
) // item['active'],
) // )
) // )
// )
// )
} }
getRoles(): Observable<Role[]> { getRoles(): Observable<Role[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getRolesQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => // query: getRolesQuery,
res['data']['roles'].map( // }).pipe(map(
(item: object) => item as Role // res =>
) // res['data']['roles'].map(
) // (item: object) => item as Role
) // )
// )
// )
} }
getACLs(): Observable<ACL[]> { getACLs(): Observable<ACL[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getAclsQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => // query: getAclsQuery,
res['data']['acls'].map( // }).pipe(map(
(item: object) => item as ACL // res =>
) // res['data']['acls'].map(
) // (item: object) => item as ACL
) // )
// )
// )
} }
getAllAccessData(): Observable<void> { getAllAccessData(): Observable<void> {
@ -254,87 +260,99 @@ export class AdminManageAccessDataService {
} }
addUserRole(user: User, role: Role) { addUserRole(user: User, role: Role) {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: addUserRoleMutation, return observableOf()
variables: { // return this.apollo.mutate({
user_id: user.id, // mutation: addUserRoleMutation,
role_id: role.id // variables: {
} // user_id: user.id,
}).pipe(map( // role_id: role.id
res => { // }
this.getACLs().subscribe( // }).pipe(map(
res => this._acls.next(res) // res => {
) // this.getACLs().subscribe(
return res['data']['addUserRole'] // res => this._acls.next(res)
} // )
)) // return res['data']['addUserRole']
// }
// ))
} }
deleteUserRole(user: User, role: Role) { deleteUserRole(user: User, role: Role) {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: deleteUserRoleMutation, return observableOf()
variables: { // return this.apollo.mutate({
user_id: user.id, // mutation: deleteUserRoleMutation,
role_id: role.id // variables: {
} // user_id: user.id,
}).pipe(map( // role_id: role.id
res => { // }
this.getACLs().subscribe( // }).pipe(map(
res => this._acls.next(res) // res => {
) // this.getACLs().subscribe(
return res['data']['deleteUserRole'] // res => this._acls.next(res)
} // )
)) // return res['data']['deleteUserRole']
// }
// ))
} }
deleteUser(user: User) { deleteUser(user: User) {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: deleteUserMutation, return observableOf()
variables: { // return this.apollo.mutate({
id: user.id, // mutation: deleteUserMutation,
} // variables: {
}).pipe(map( // id: user.id,
res => res['data']['deleteUser'] // }
)) // }).pipe(map(
// res => res['data']['deleteUser']
// ))
} }
deleteRole(role: Role) { deleteRole(role: Role) {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: deleteRoleMutation, return observableOf()
variables: { // return this.apollo.mutate({
id: role.id, // mutation: deleteRoleMutation,
} // variables: {
}).pipe(map( // id: role.id,
res => res['data']['deleteRole'] // }
)) // }).pipe(map(
// res => res['data']['deleteRole']
// ))
} }
saveRole(role: Role) { saveRole(role: Role) {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: saveRoleMutation, return observableOf()
variables: { // return this.apollo.mutate({
id: role.id, // mutation: saveRoleMutation,
name: role.name, // variables: {
description: role.description // id: role.id,
} // name: role.name,
}).pipe(map( // description: role.description
res => res['data']['saveRole'] // }
)) // }).pipe(map(
// res => res['data']['saveRole']
// ))
} }
saveUser(user: User) { saveUser(user: User) {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: saveUserMutation, return observableOf()
variables: { // return this.apollo.mutate({
id: user.id, // mutation: saveUserMutation,
name: user.name, // variables: {
email: user.email, // id: user.id,
active: user.active, // name: user.name,
password: user.password, // email: user.email,
} // active: user.active,
}).pipe(map( // password: user.password,
res => res['data']['saveUser'] // }
)) // }).pipe(map(
// res => res['data']['saveUser']
// ))
} }
openUserDialog(user?: User) { openUserDialog(user?: User) {

View file

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router' import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable } from 'rxjs' import { Observable } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
@ -7,7 +7,7 @@ import { AdminManageDataService, Category } from '../data.service'
@Injectable() @Injectable()
export class CategoryResolver implements Resolve<object> { export class CategoryResolver {
constructor( constructor(
private adminManageDataService: AdminManageDataService, private adminManageDataService: AdminManageDataService,
private router: Router private router: Router

View file

@ -3,213 +3,213 @@ import { Injectable } from '@angular/core'
import { Observable, BehaviorSubject, forkJoin, of as observableOf } from 'rxjs' import { Observable, BehaviorSubject, forkJoin, of as observableOf } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular' // import { Apollo, gql } from 'apollo-angular'
const getSurveyStores = gql` // const getSurveyStores = gql`
query geo_survey_stores { // query geo_survey_stores {
geo_survey_stores { // geo_survey_stores {
name // name
} // }
} // }
` // `
const getRawSurveyStores = gql` // const getRawSurveyStores = gql`
query geo_raw_survey_stores { // query geo_raw_survey_stores {
geo_raw_survey_stores { // geo_raw_survey_stores {
name // name
} // }
} // }
` // `
const getRawSurveyPoints = gql` // const getRawSurveyPoints = gql`
query raw_survey_points ($orig_id: String!) { // query raw_survey_points ($orig_id: String!) {
raw_survey_points(orig_id: $orig_id) { // raw_survey_points(orig_id: $orig_id) {
id // id
category // category
date // date
orig_id // orig_id
store // store
status // status
type // type
project // project
} // }
} // }
` // `
const reconciliationItemMutation = gql` // const reconciliationItemMutation = gql`
mutation reconciliationItem( // mutation reconciliationItem(
$id: String!, // $id: String!,
$category: String! // $category: String!
) { // ) {
reconciliationItem( // reconciliationItem(
id: $id, // id: $id,
category: $category // category: $category
) { // ) {
result { // result {
message // message
} // }
} // }
} // }
` // `
const changeSurveyPointMutation = gql` // const changeSurveyPointMutation = gql`
mutation changeSurveyPointStatus( // mutation changeSurveyPointStatus(
$id: String!, // $id: String!,
$status: String! // $status: String!
) { // ) {
changePointStatus( // changePointStatus(
id: $id, // id: $id,
status: $status // status: $status
) { // ) {
result { // result {
message // message
} // }
} // }
} // }
` // `
const deleteSurveyPointMutation = gql` // const deleteSurveyPointMutation = gql`
mutation deletePoint( // mutation deletePoint(
$id: String!, // $id: String!,
) { // ) {
deletePoint( // deletePoint(
id: $id, // id: $id,
) { // ) {
result { // result {
message // message
} // }
} // }
} // }
` // `
const categoryMutation = gql` // const categoryMutation = gql`
mutation categoryMutation( // mutation categoryMutation(
$category: CategoryInput!, // $category: CategoryInput!,
) { // ) {
editCategory( // editCategory(
category: $category, // category: $category,
) { // ) {
result { // result {
name // name
_message // _message
_mode // _mode
} // }
} // }
} // }
` // `
const projectMutation = gql` // const projectMutation = gql`
mutation projectMutation( // mutation projectMutation(
$project: ProjectInput!, // $project: ProjectInput!,
) { // ) {
editProject( // editProject(
project: $project, // project: $project,
) { // ) {
result { // result {
id // id
} // }
} // }
} // }
` // `
const categoryDeleteMutation = gql` // const categoryDeleteMutation = gql`
mutation deleteCategory( // mutation deleteCategory(
$name: String! // $name: String!
) { // ) {
deleteCategory( // deleteCategory(
name: $name, // name: $name,
) { // ) {
result // result
} // }
} // }
` // `
const projectDeleteMutation = gql` // const projectDeleteMutation = gql`
mutation deleteProject( // mutation deleteProject(
$id: Int! // $id: Int!
) { // ) {
deleteProject( // deleteProject(
id: $id, // id: $id,
) { // ) {
result // result
} // }
} // }
` // `
const categoriesQuery = gql` // const categoriesQuery = gql`
query categories { // query categories {
categories { // categories {
name // name
description // description
group // group
minor_group_1 // minor_group_1
minor_group_2 // minor_group_2
status // status
auto_import // auto_import
model_type // model_type
long_name // long_name
symbol // symbol
mapbox_type_custom // mapbox_type_custom
mapbox_paint // mapbox_paint
mapbox_layout // mapbox_layout
viewable_role // viewable_role
extra // extra
} // }
} // }
` // `
const projectsQuery = gql` // const projectsQuery = gql`
query projects { // query projects {
projects { // projects {
id // id
name // name
contact_person // contact_person
site // site
date_approved // date_approved
start_date_planned // start_date_planned
start_date_effective // start_date_effective
end_date_planned // end_date_planned
end_date_effective // end_date_effective
} // }
} // }
` // `
const updateRegistryQuery = gql` // const updateRegistryQuery = gql`
query updateRegistry { // query updateRegistry {
updateRegistry // updateRegistry
} // }
` // `
const vacuumDbQuery = gql` // const vacuumDbQuery = gql`
query vacuumDb { // query vacuumDb {
vacuumDb // vacuumDb
} // }
` // `
const runIntegrityCheckQuery = gql` // const runIntegrityCheckQuery = gql`
query runIntegrityCheck( // query runIntegrityCheck(
$integrityCheckId: String! // $integrityCheckId: String!
) { // ) {
integrityCheckRun( // integrityCheckRun(
integrityCheckId: $integrityCheckId // integrityCheckId: $integrityCheckId
) { // ) {
name // name
description // description
dfData // dfData
} // }
} // }
` // `
const integrityCheckQuery = gql` // const integrityCheckQuery = gql`
query integrityChecks { // query integrityChecks {
integrityChecks { // integrityChecks {
id // id
name // name
description // description
} // }
} // }
` // `
export class Store { export class Store {
constructor( constructor(
@ -301,225 +301,257 @@ export class IntegrityCheck {
@Injectable() @Injectable()
export class AdminManageDataService { export class AdminManageDataService {
constructor( constructor(
private apollo: Apollo, // private apollo: Apollo,
) {} ) {}
getRawSurveyStores(): Observable<Store[]> { getRawSurveyStores(): Observable<Store[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getRawSurveyStores, return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['data']['geo_raw_survey_stores'].map( // query: getRawSurveyStores,
(store: object) => new Store( // }).pipe(map(
store['name'], // res => res['data']['geo_raw_survey_stores'].map(
) // (store: object) => new Store(
) // store['name'],
)) // )
// )
// ))
} }
getSurveyStores(): Observable<Store[]> { getSurveyStores(): Observable<Store[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getSurveyStores, return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['data']['geo_survey_stores'].map( // query: getSurveyStores,
(store: object) => new Store( // }).pipe(map(
store['name'], // res => res['data']['geo_survey_stores'].map(
) // (store: object) => new Store(
) // store['name'],
)) // )
// )
// ))
} }
getRawSurveyPoints(orig_id: string): Observable<RawSurveyPoint[]> { getRawSurveyPoints(orig_id: string): Observable<RawSurveyPoint[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getRawSurveyPoints, return observableOf()
variables: { // return this.apollo.query({
orig_id: orig_id // query: getRawSurveyPoints,
} // variables: {
}).pipe(map( // orig_id: orig_id
res => res['data']['raw_survey_points'].map( // }
(rawSurveyPoint: object) => new RawSurveyPoint( // }).pipe(map(
rawSurveyPoint['id'], // res => res['data']['raw_survey_points'].map(
rawSurveyPoint['orig_id'], // (rawSurveyPoint: object) => new RawSurveyPoint(
rawSurveyPoint['date'], // rawSurveyPoint['id'],
rawSurveyPoint['category'], // rawSurveyPoint['orig_id'],
rawSurveyPoint['status'], // rawSurveyPoint['date'],
rawSurveyPoint['store'], // rawSurveyPoint['category'],
rawSurveyPoint['type'], // rawSurveyPoint['status'],
rawSurveyPoint['project'], // rawSurveyPoint['store'],
) // rawSurveyPoint['type'],
) // rawSurveyPoint['project'],
)) // )
// )
// ))
} }
reconcile(item: RawSurveyPoint, category: string): Observable<string> { reconcile(item: RawSurveyPoint, category: string): Observable<string> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: reconciliationItemMutation, return observableOf()
variables: { // return this.apollo.mutate({
id: item.id, // mutation: reconciliationItemMutation,
category: category // variables: {
} // id: item.id,
}).pipe(map( // category: category
res => res['data']['reconciliationItem']['result'] // }
)) // }).pipe(map(
// res => res['data']['reconciliationItem']['result']
// ))
} }
changeStatus(item: RawSurveyPoint, status: string): Observable<string> { changeStatus(item: RawSurveyPoint, status: string): Observable<string> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: changeSurveyPointMutation, return observableOf()
variables: { // return this.apollo.mutate({
id: item.id, // mutation: changeSurveyPointMutation,
status: status // variables: {
} // id: item.id,
}).pipe(map( // status: status
res => res['data']['changePointStatus']['result'] // }
)) // }).pipe(map(
// res => res['data']['changePointStatus']['result']
// ))
} }
delete(item: RawSurveyPoint): Observable<string> { delete(item: RawSurveyPoint): Observable<string> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: deleteSurveyPointMutation, return observableOf()
variables: { // return this.apollo.mutate({
id: item.id, // mutation: deleteSurveyPointMutation,
} // variables: {
}).pipe(map( // id: item.id,
res => res['data']['deletePoint']['result'] // }
)) // }).pipe(map(
// res => res['data']['deletePoint']['result']
// ))
} }
getCategories(): Observable<Category[]> { getCategories(): Observable<Category[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: categoriesQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['data']['categories'].map( // query: categoriesQuery,
(category: object) => new Category( // }).pipe(map(
category['name'], // res => res['data']['categories'].map(
category['description'], // (category: object) => new Category(
category['group'], // category['name'],
category['minor_group_1'], // category['description'],
category['minor_group_2'], // category['group'],
category['status'], // category['minor_group_1'],
category['auto_import'], // category['minor_group_2'],
category['model_type'], // category['status'],
category['long_name'], // category['auto_import'],
category['symbol'], // category['model_type'],
category['mapbox_type_custom'], // category['long_name'],
category['mapbox_paint'], // category['symbol'],
category['mapbox_layout'], // category['mapbox_type_custom'],
category['viewable_role'], // category['mapbox_paint'],
category['extra'], // category['mapbox_layout'],
) // category['viewable_role'],
) // category['extra'],
)) // )
// )
// ))
} }
getProjects(): Observable<Project[]> { getProjects(): Observable<Project[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: projectsQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['data']['projects'].map( // query: projectsQuery,
(project: object) => project as Project // }).pipe(map(
) // res => res['data']['projects'].map(
)) // (project: object) => project as Project
// )
// ))
} }
saveCategory(category: Category): Observable<object> { saveCategory(category: Category): Observable<object> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: categoryMutation, return observableOf()
variables: { // return this.apollo.mutate({
category: category, // mutation: categoryMutation,
} // variables: {
}).pipe(map( // category: category,
res => res['data']['editCategory']['result'] // }
)) // }).pipe(map(
// res => res['data']['editCategory']['result']
// ))
} }
deleteCategory(category: Category): Observable<string> { deleteCategory(category: Category): Observable<string> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: categoryDeleteMutation, return observableOf()
variables: { // return this.apollo.mutate({
name: category.name, // mutation: categoryDeleteMutation,
} // variables: {
}).pipe(map( // name: category.name,
// TODO: distinguish message and error // }
res => res['data']['deleteCategory']['result'] // }).pipe(map(
)) // // TODO: distinguish message and error
// res => res['data']['deleteCategory']['result']
// ))
} }
saveProject(project: Project): Observable<number> { saveProject(project: Project): Observable<number> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: projectMutation, return observableOf()
variables: { // return this.apollo.mutate({
project: project, // mutation: projectMutation,
} // variables: {
}).pipe(map( // project: project,
res => res['data']['editProject']['result']['id'] // }
)) // }).pipe(map(
// res => res['data']['editProject']['result']['id']
// ))
} }
deleteProject(project: Project): Observable<number> { deleteProject(project: Project): Observable<number> {
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: projectDeleteMutation, return observableOf()
variables: { // return this.apollo.mutate({
id: project.id, // mutation: projectDeleteMutation,
} // variables: {
}).pipe(map( // id: project.id,
res => res['data']['deleteProject']['result']['id'] // }
)) // }).pipe(map(
// res => res['data']['deleteProject']['result']['id']
// ))
} }
updateRegistry() { updateRegistry() {
return this.apollo.query({ console.warn('Migrate Graphql')
query: updateRegistryQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['data']['updateRegistry']['result'] // query: updateRegistryQuery,
)) // }).pipe(map(
// res => res['data']['updateRegistry']['result']
// ))
} }
vacuumDb(): Observable<boolean> { vacuumDb(): Observable<boolean> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: vacuumDbQuery, return observableOf()
}).pipe(map( // return this.apollo.query({
res => res['data']['vacuumDb'] // query: vacuumDbQuery,
)) // }).pipe(map(
// res => res['data']['vacuumDb']
// ))
} }
runIntegrityCheck(integrityCheck: IntegrityCheck): Observable<IntegrityReport> { runIntegrityCheck(integrityCheck: IntegrityCheck): Observable<IntegrityReport> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: runIntegrityCheckQuery, return observableOf()
variables: { // return this.apollo.query({
integrityCheckId: integrityCheck.id // query: runIntegrityCheckQuery,
} // variables: {
}).pipe(map( // integrityCheckId: integrityCheck.id
res => { // }
let report = res['data']['integrityCheckRun'] // }).pipe(map(
let dfData = JSON.parse(report['dfData']) // res => {
return new IntegrityReport( // let report = res['data']['integrityCheckRun']
report['name'], // let dfData = JSON.parse(report['dfData'])
report['description'], // return new IntegrityReport(
dfData && new DF( // report['name'],
dfData['schema']['fields'].map( // report['description'],
field => new Field(field['name'], field['type']) // dfData && new DF(
), // dfData['schema']['fields'].map(
dfData['data'] // field => new Field(field['name'], field['type'])
), // ),
) // dfData['data']
} // ),
)) // )
// }
// ))
} }
getIntegrityChecks(): Observable<IntegrityCheck[]> { getIntegrityChecks(): Observable<IntegrityCheck[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: integrityCheckQuery return observableOf()
}).pipe(map( // return this.apollo.query({
resp => { // query: integrityCheckQuery
let data = resp['data']['integrityChecks'] // }).pipe(map(
return data.map( // resp => {
(item: object) => new IntegrityCheck( // let data = resp['data']['integrityChecks']
item['id'], // return data.map(
item['name'], // (item: object) => new IntegrityCheck(
item['description'] // item['id'],
) // item['name'],
) // item['description']
} // )
)) // )
// }
// ))
} }
} }

View file

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router' import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable } from 'rxjs' import { Observable } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
@ -7,7 +7,7 @@ import { AdminManageDataService, Project } from '../data.service'
@Injectable() @Injectable()
export class ProjectResolver implements Resolve<object> { export class ProjectResolver {
constructor( constructor(
private adminManageDataService: AdminManageDataService, private adminManageDataService: AdminManageDataService,
private router: Router private router: Router

View file

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router' import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable, forkJoin } from 'rxjs' import { Observable, forkJoin } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
@ -9,7 +9,7 @@ import { AdminBasketDataService, AdminBasket } from './admin-basket/data.service
@Injectable() @Injectable()
export class AdminResolver implements Resolve<object> { export class AdminResolver {
constructor( constructor(
private router: Router, private router: Router,
private dataService: AdminDataService, private dataService: AdminDataService,

View file

@ -3,8 +3,6 @@ import { HttpClient } from '@angular/common/http'
import { Observable, Subject, of } from 'rxjs' import { Observable, Subject, of } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
// import { Apollo, QueryRef, gql } from 'apollo-angular'
import { WebsocketService } from '../../_services/websocket.service' import { WebsocketService } from '../../_services/websocket.service'
export class Feature { export class Feature {

View file

@ -6,7 +6,7 @@ import { MatSort } from '@angular/material/sort'
import { Observable, of as observableOf, merge, BehaviorSubject } from 'rxjs' import { Observable, of as observableOf, merge, BehaviorSubject } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { gql } from 'apollo-angular' // import { gql } from 'apollo-angular'
import { ModelDataService } from '../_services/apollo.service' import { ModelDataService } from '../_services/apollo.service'
import { AppInjector } from '../app-injector' import { AppInjector } from '../app-injector'
@ -40,7 +40,9 @@ export class TableDataSource extends DataSource<object[]> {
connect(): Observable<any> { connect(): Observable<any> {
let cols = this.displayedColumns.join(' ') let cols = this.displayedColumns.join(' ')
let query = gql`query model {${this.modelDef['name']}{${cols}}}` console.warn('Migrate Graphql')
let query = ''
// let query = gql`query model {${this.modelDef['name']}{${cols}}}`
return this.fetch(query) return this.fetch(query)
} }

View file

@ -13,13 +13,13 @@ import { MatTooltipModule } from '@angular/material/tooltip'
import { FlexLayoutModule } from 'ngx-flexible-layout' import { FlexLayoutModule } from 'ngx-flexible-layout'
import { ApolloModule, APOLLO_OPTIONS } from 'apollo-angular' // import { ApolloModule, APOLLO_OPTIONS } from 'apollo-angular'
import { HttpLink } from 'apollo-angular/http' // import { HttpLink } from 'apollo-angular/http'
import { onError } from '@apollo/client/link/error' // import { onError } from '@apollo/client/link/error'
import { split, from, ApolloLink, InMemoryCache, ApolloClientOptions } from '@apollo/client/core' // import { split, from, ApolloLink, InMemoryCache, ApolloClientOptions } from '@apollo/client/core'
import { WebSocketLink } from '@apollo/client/link/ws' // import { WebSocketLink } from '@apollo/client/link/ws'
import { getMainDefinition, getOperationName } from '@apollo/client/utilities' // import { getMainDefinition, getOperationName } from '@apollo/client/utilities'
import { DefinitionNode } from 'graphql' // import { DefinitionNode } from 'graphql'
import { AppComponent } from './app.component' import { AppComponent } from './app.component'
import { PageNotFoundComponent } from './pageNotFound.component' import { PageNotFoundComponent } from './pageNotFound.component'
@ -48,7 +48,7 @@ import { environment } from '../environments/environment'
HtmlSnackbarComponent, HtmlSnackbarComponent,
], ],
imports: [ imports: [
ApolloModule, // ApolloModule,
BrowserModule, BrowserModule,
BrowserAnimationsModule, BrowserAnimationsModule,
@ -83,91 +83,91 @@ import { environment } from '../environments/environment'
provide: LOCALE_ID, provide: LOCALE_ID,
useValue: "en-IN" useValue: "en-IN"
}, },
{ // {
provide: APOLLO_OPTIONS, // provide: APOLLO_OPTIONS,
useFactory(httpLink: HttpLink, snackBar: MatSnackBar) { // useFactory(httpLink: HttpLink, snackBar: MatSnackBar) {
const definitionIsMutation = (d: DefinitionNode) => { // const definitionIsMutation = (d: DefinitionNode) => {
return d.kind === 'OperationDefinition' && d.operation === 'mutation' // return d.kind === 'OperationDefinition' && d.operation === 'mutation'
} // }
// See https://github.com/apollographql/apollo-angular/issues/1013 // // See https://github.com/apollographql/apollo-angular/issues/1013
const linkQueries = httpLink.create({ // const linkQueries = httpLink.create({
uri: '/graphql', // uri: '/graphql',
method: 'GET', // method: 'GET',
}) // })
const linkMutations = httpLink.create({ // const linkMutations = httpLink.create({
uri: '/graphql', // uri: '/graphql',
}) // })
const splittedLink = split( // const splittedLink = split(
({ query }) => query.definitions.some(definitionIsMutation), // ({ query }) => query.definitions.some(definitionIsMutation),
linkMutations, // linkMutations,
linkQueries, // linkQueries,
) // )
const schedulerQueriesLink = httpLink.create({ // const schedulerQueriesLink = httpLink.create({
uri: '/graphql_sched', // uri: '/graphql_sched',
method: 'GET', // method: 'GET',
}) // })
const proxyLink = split( // const proxyLink = split(
({ query }) => { // ({ query }) => {
let res = query.definitions[0]['name']['value'].startsWith('scheduler_') // let res = query.definitions[0]['name']['value'].startsWith('scheduler_')
return res // return res
}, // },
schedulerQueriesLink, // schedulerQueriesLink,
splittedLink // splittedLink
) // )
const errorLink = onError(({ graphQLErrors, networkError }) => { // const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors) // if (graphQLErrors)
graphQLErrors.map(({ message, locations, path }) => { // graphQLErrors.map(({ message, locations, path }) => {
snackBar.open(`Error: ${message}`, 'close') // snackBar.open(`Error: ${message}`, 'close')
console.error( // console.error(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`, // `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
graphQLErrors // graphQLErrors
) // )
} // }
) // )
if (networkError) { // if (networkError) {
snackBar.open( // snackBar.open(
`Network error: ${networkError['statusText']}`, // `Network error: ${networkError['statusText']}`,
'close', // 'close',
) // )
console.error(networkError) // console.error(networkError)
} // }
}) // })
const httpLinkWithErrorHandling = from([ // const httpLinkWithErrorHandling = from([
errorLink, // errorLink,
proxyLink, // proxyLink,
]) // ])
return { // return {
link: httpLinkWithErrorHandling, // link: httpLinkWithErrorHandling,
cache: new InMemoryCache(), // cache: new InMemoryCache(),
defaultOptions: { // defaultOptions: {
watchQuery: { // watchQuery: {
fetchPolicy: 'network-only', // fetchPolicy: 'network-only',
errorPolicy: 'ignore', // errorPolicy: 'ignore',
}, // },
query: { // query: {
fetchPolicy: 'network-only', // fetchPolicy: 'network-only',
errorPolicy: 'all', // errorPolicy: 'all',
}, // },
subscription: { // subscription: {
fetchPolicy: 'network-only', // fetchPolicy: 'network-only',
errorPolicy: 'all', // errorPolicy: 'all',
} // }
}, // },
} // }
}, // },
deps: [ // deps: [
HttpLink, // HttpLink,
MatSnackBar // MatSnackBar
], // ],
} // }
], ],
bootstrap: [ bootstrap: [
AppComponent AppComponent

View file

@ -1,11 +1,11 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router' import { RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable } from 'rxjs' import { Observable } from 'rxjs'
import { DashboardDataService } from '../../_services/apollo.service' import { DashboardDataService } from '../../_services/apollo.service'
@Injectable() @Injectable()
export class DashboardPageResolver implements Resolve<object> { export class DashboardPageResolver {
constructor( constructor(
private dashboardDataService: DashboardDataService, private dashboardDataService: DashboardDataService,
) {} ) {}

View file

@ -4,7 +4,7 @@ import { UntypedFormGroup, UntypedFormControl } from '@angular/forms'
import { Observable, BehaviorSubject, forkJoin, of as observableOf, Subject } from 'rxjs' import { Observable, BehaviorSubject, forkJoin, of as observableOf, Subject } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular' // import { Apollo, gql } from 'apollo-angular'
import { MapControlService } from '../map/map-control.service' import { MapControlService } from '../map/map-control.service'
import { LayerNode } from '../map/models' import { LayerNode } from '../map/models'
@ -13,236 +13,236 @@ import { Tag, TagAction } from './info-tags/tags.service'
import { ConfigService } from '../config.service' import { ConfigService } from '../config.service'
import { DataService } from '../_services/data.service' import { DataService } from '../_services/data.service'
const getModelInfoQuery = gql` // const getModelInfoQuery = gql`
query modelInfo ($store: String!) { // query modelInfo ($store: String!) {
modelInfo(store: $store) { // modelInfo(store: $store) {
store // store
modelName // modelName
symbol // symbol
values { // values {
name // name
title // title
unit // unit
chartType // chartType
chartColor // chartColor
} // }
actions { // actions {
name // name
icon // icon
formFields { // formFields {
name // name
type // type
} // }
} // }
formName // formName
formFields { // formFields {
name // name
type // type
} // }
tagPlugins // tagPlugins
tagActions { // tagActions {
domain // domain
key // key
actions { // actions {
plugin // plugin
name // name
link // link
action // action
roles // roles
} // }
} // }
downloaders { // downloaders {
name // name
icon // icon
} // }
legend { // legend {
key // key
value // value
} // }
} // }
} // }
` // `
const getTagKeysQuery = gql` // const getTagKeysQuery = gql`
query tagKeyList { // query tagKeyList {
tagKeyList { // tagKeyList {
keys // keys
} // }
} // }
` // `
const createTagMutation = gql` // const createTagMutation = gql`
mutation createTag( // mutation createTag(
$store: String! // $store: String!
$id: String! // $id: String!
$key: String! // $key: String!
$value: String! // $value: String!
) { // ) {
createTag( // createTag(
store: $store, // store: $store,
id: $id, // id: $id,
key: $key, // key: $key,
value: $value // value: $value
) { // ) {
tags { // tags {
key // key
value // value
} // }
} // }
} // }
` // `
const createTagsMutations = gql` // const createTagsMutations = gql`
mutation createTags( // mutation createTags(
$keys: [String]! // $keys: [String]!
$values: [String]! // $values: [String]!
$stores: [String]! // $stores: [String]!
$ids: [[String]]! // $ids: [[String]]!
) { // ) {
createTags( // createTags(
keys: $keys, // keys: $keys,
values: $values, // values: $values,
stores: $stores, // stores: $stores,
ids: $ids, // ids: $ids,
) { // ) {
tags { // tags {
key // key
value // value
} // }
} // }
} // }
` // `
const getPlotParamsQuery = gql` // const getPlotParamsQuery = gql`
query plotParams($store: String!, $id:String!, $value:String!) { // query plotParams($store: String!, $id:String!, $value:String!) {
plotParams(store: $store, id: $id, value: $value) { // plotParams(store: $store, id: $id, value: $value) {
baseLines { // baseLines {
name // name
value // value
color // color
} // }
bgShapes { // bgShapes {
name // name
valueTop // valueTop
valueBottom // valueBottom
color // color
} // }
barBase // barBase
} // }
} // }
` // `
const getFeatureInfoQuery = gql` // const getFeatureInfoQuery = gql`
query featureInfo($store: String!, $id:String!) { // query featureInfo($store: String!, $id:String!) {
featureInfo(store: $store, id: $id) { // featureInfo(store: $store, id: $id) {
id // id
itemName // itemName
geoInfoItems { // geoInfoItems {
key // key
value // value
} // }
surveyInfoItems { // surveyInfoItems {
key // key
value // value
} // }
infoItems { // infoItems {
key // key
value // value
} // }
categorizedInfoItems { // categorizedInfoItems {
name // name
infoItems { // infoItems {
key // key
value // value
} // }
} // }
tags { // tags {
key // key
value // value
} // }
graph // graph
files { // files {
name // name
path // path
} // }
images { // images {
name // name
path // path
} // }
externalRecordUrl // externalRecordUrl
} // }
} // }
` // `
const deleteTagQuery = gql` // const deleteTagQuery = gql`
mutation deleteTag( // mutation deleteTag(
$store: String! // $store: String!
$id: String! // $id: String!
$key: String! // $key: String!
) { // ) {
deleteTag( // deleteTag(
store: $store, // store: $store,
id: $id, // id: $id,
key: $key, // key: $key,
) { // ) {
tags { // tags {
key // key
value // value
} // }
} // }
} // }
` // `
const getTaggedFeaturesQuery = gql` // const getTaggedFeaturesQuery = gql`
query taggedFeatures($stores: [String], $ids: [[String]]) { // query taggedFeatures($stores: [String], $ids: [[String]]) {
taggedFeatures(stores: $stores, ids: $ids) { // taggedFeatures(stores: $stores, ids: $ids) {
store // store
taggedFeatures { // taggedFeatures {
id // id
lon // lon
lat // lat
tags { // tags {
key // key
value // value
} // }
} // }
} // }
} // }
` // `
const getTaggedStoresQuery = gql` // const getTaggedStoresQuery = gql`
query taggedStores($stores: [String]) { // query taggedStores($stores: [String]) {
taggedStores(stores: $stores) { // taggedStores(stores: $stores) {
store // store
taggedFeatures { // taggedFeatures {
id // id
lon // lon
lat // lat
tags { // tags {
key // key
value // value
} // }
} // }
} // }
} // }
` // `
const executeFeatureActionMutation=gql` // const executeFeatureActionMutation=gql`
mutation executeFeatureAction ( // mutation executeFeatureAction (
$store: String!, // $store: String!,
$id: String!, // $id: String!,
$action: String!, // $action: String!,
$value: String, // $value: String,
) { // ) {
executeFeatureAction( // executeFeatureAction(
store: $store, // store: $store,
id: $id, // id: $id,
action: $action, // action: $action,
value: $value, // value: $value,
) { // ) {
result // result
} // }
} // }
` // `
export class TaggedFeature { export class TaggedFeature {
constructor( constructor(
@ -448,7 +448,7 @@ export class FullInfo {
export class InfoDataService { export class InfoDataService {
constructor( constructor(
public configService: ConfigService, public configService: ConfigService,
private apollo: Apollo, // private apollo: Apollo,
public mapControlService: MapControlService, public mapControlService: MapControlService,
protected dataService: DataService, protected dataService: DataService,
) {} ) {}
@ -467,75 +467,77 @@ export class InfoDataService {
public taggedLayers$ = this.taggedLayers.asObservable() public taggedLayers$ = this.taggedLayers.asObservable()
getModelInfo(store: string): Observable<ModelInfo> { getModelInfo(store: string): Observable<ModelInfo> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getModelInfoQuery, return observableOf()
variables: { // return this.apollo.query({
store: store, // query: getModelInfoQuery,
} // variables: {
}).pipe(map( // store: store,
res => { // }
let info: Object = res['data']['modelInfo'] // }).pipe(map(
let values = (info['values'] || []).map( // res => {
(value: Object) => new ModelValue( // let info: Object = res['data']['modelInfo']
value['name'], // let values = (info['values'] || []).map(
value['title'], // (value: Object) => new ModelValue(
value['unit'], // value['name'],
value['chartType'], // value['title'],
value['chartColor'], // value['unit'],
) // value['chartType'],
) // value['chartColor'],
return new ModelInfo( // )
info['store'], // )
info['modelName'], // return new ModelInfo(
info['symbol'], // info['store'],
values, // info['modelName'],
info['actions'] ? info['actions'].map( // info['symbol'],
action => new ModelAction( // values,
action['name'], // info['actions'] ? info['actions'].map(
action['icon'], // action => new ModelAction(
action['formFields'].map( // action['name'],
formField => new FormField( // action['icon'],
formField['name'], // action['formFields'].map(
formField['type'], // formField => new FormField(
formField['dflt'] // formField['name'],
) // formField['type'],
) // formField['dflt']
) // )
): [], // )
info['formName'], // )
info['formFields'] ? info['formFields'].map( // ): [],
(formField: Object) => new FormField( // info['formName'],
formField['name'], // info['formFields'] ? info['formFields'].map(
formField['type'], // (formField: Object) => new FormField(
) // formField['name'],
) : [], // formField['type'],
info['tagPlugins'], // )
info['tagActions'] ? info['tagActions'].map( // ) : [],
tagAction => new TagAction( // info['tagPlugins'],
// FIXME: set real data!!! // info['tagActions'] ? info['tagActions'].map(
'**name**', // tagAction => new TagAction(
'**plugin_name**', // // FIXME: set real data!!!
//tagAction['key'], // '**name**',
tagAction.actions[0]['action'], // '**plugin_name**',
['**role**'], // //tagAction['key'],
'**link**', // tagAction.actions[0]['action'],
) // ['**role**'],
) : [], // '**link**',
info['downloaders'] ? info['downloaders'].map( // )
downloader => new Downloader( // ) : [],
downloader['name'], // info['downloaders'] ? info['downloaders'].map(
downloader['icon'], // downloader => new Downloader(
) // downloader['name'],
) : [], // downloader['icon'],
info['legend'] ? info['legend'].map( // )
legendItem => new LegendItem( // ) : [],
legendItem['key'], // info['legend'] ? info['legend'].map(
legendItem['value'], // legendItem => new LegendItem(
) // legendItem['key'],
) : [], // legendItem['value'],
) // )
} // ) : [],
)) // )
// }
// ))
} }
getPlotDataAndParams(store: string, id: string, value: string, resampling: string): Observable<PlotDataParams> { getPlotDataAndParams(store: string, id: string, value: string, resampling: string): Observable<PlotDataParams> {
@ -552,71 +554,75 @@ export class InfoDataService {
} }
getPlotParams(store: string, id: string, value: string): Observable<PlotParams> { getPlotParams(store: string, id: string, value: string): Observable<PlotParams> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getPlotParamsQuery, return observableOf()
variables: { // return this.apollo.query({
store: store, // query: getPlotParamsQuery,
id: id, // variables: {
value: value // store: store,
} // id: id,
}).pipe(map( // value: value
info => info.data['plotParams'] ? new PlotParams( // }
(info.data['plotParams']['baseLines'] || []).map( // }).pipe(map(
bl => new PlotBaseLine( // info => info.data['plotParams'] ? new PlotParams(
bl['name'], // (info.data['plotParams']['baseLines'] || []).map(
bl['value'], // bl => new PlotBaseLine(
bl['color'] // bl['name'],
) // bl['value'],
), // bl['color']
(info.data['plotParams']['bgShapes'] || []).map( // )
bl => new PlotBgShape( // ),
bl['name'], // (info.data['plotParams']['bgShapes'] || []).map(
bl['valueTop'], // bl => new PlotBgShape(
bl['valueBottom'], // bl['name'],
bl['color'] // bl['valueTop'],
) // bl['valueBottom'],
), // bl['color']
info.data['plotParams']['barBase'] // )
) : new PlotParams() // ),
)) // info.data['plotParams']['barBase']
// ) : new PlotParams()
// ))
} }
getFeatureInfo(store: string, id: string): Observable<FeatureInfo> { getFeatureInfo(store: string, id: string): Observable<FeatureInfo> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getFeatureInfoQuery, return observableOf()
variables: { // return this.apollo.query({
store: store, // query: getFeatureInfoQuery,
id: id // variables: {
} // store: store,
}).pipe(map( // id: id
res => { // }
const info = res['data']['featureInfo'] // }).pipe(map(
const geoInfoItems = info['geoInfoItems'].map(ii => new InfoItem(ii['key'], ii['value'])) // res => {
const surveyInfoItems = info['surveyInfoItems'].map(ii => new InfoItem(ii['key'], ii['value'])) // const info = res['data']['featureInfo']
const infoItems = info['infoItems'].map(ii => new InfoItem(ii['key'], ii['value'])) // const geoInfoItems = info['geoInfoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
const categorizedInfoItems = info['categorizedInfoItems'] && info['categorizedInfoItems'].map( // const surveyInfoItems = info['surveyInfoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
ic => new InfoCategory( // const infoItems = info['infoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
ic['name'], // const categorizedInfoItems = info['categorizedInfoItems'] && info['categorizedInfoItems'].map(
ic['infoItems'].map(ii => new InfoItem(ii['key'], ii['value'])) // ic => new InfoCategory(
) // ic['name'],
) // ic['infoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
const tags = info['tags'].map(ii => new Tag(ii['key'], ii['value'])) // )
// )
// const tags = info['tags'].map(ii => new Tag(ii['key'], ii['value']))
return new FeatureInfo( // return new FeatureInfo(
info['id'], // info['id'],
info['itemName'], // info['itemName'],
geoInfoItems, // geoInfoItems,
surveyInfoItems, // surveyInfoItems,
infoItems, // infoItems,
categorizedInfoItems, // categorizedInfoItems,
tags, // tags,
info['graph'] && info['graph'].replace(/width="\d+pt"/, '').replace(/height="\d+pt"/, ''), // info['graph'] && info['graph'].replace(/width="\d+pt"/, '').replace(/height="\d+pt"/, ''),
info['files'] && info['files'].map(att => new Attachment(att['name'], att['path'])), // info['files'] && info['files'].map(att => new Attachment(att['name'], att['path'])),
info['images'] && info['images'].map(att => new Attachment(att['name'], att['path'])), // info['images'] && info['images'].map(att => new Attachment(att['name'], att['path'])),
info['externalRecordUrl'] // info['externalRecordUrl']
) // )
} // }
)) // ))
} }
getFullInfo(feature: Feature): Observable<FullInfo> { getFullInfo(feature: Feature): Observable<FullInfo> {
@ -635,13 +641,15 @@ export class InfoDataService {
'key': tag['key'], 'key': tag['key'],
'value': tag['value'], 'value': tag['value'],
} }
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: createTagMutation, return observableOf()
variables: variables, // return this.apollo.mutate({
}).pipe(map( // mutation: createTagMutation,
res => res['data']['createTag']['tags'].map( // variables: variables,
(tag: Object) => new Tag(tag['key'], tag['value'])) // }).pipe(map(
)) // res => res['data']['createTag']['tags'].map(
// (tag: Object) => new Tag(tag['key'], tag['value']))
// ))
} }
public createTags(keys: String[], values: String[], source: Object): Observable<Tag[]> { public createTags(keys: String[], values: String[], source: Object): Observable<Tag[]> {
@ -651,16 +659,18 @@ export class InfoDataService {
'stores': Object.keys(source), 'stores': Object.keys(source),
'ids': Object.values(source).map(ids => Array.from(<Number[][]>ids)), 'ids': Object.values(source).map(ids => Array.from(<Number[][]>ids)),
} }
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: createTagsMutations, return observableOf()
variables: variables, // return this.apollo.mutate({
}).pipe(map( // mutation: createTagsMutations,
res => { // variables: variables,
let tags = res['data']['createTags']['tags'] // }).pipe(map(
return tags.map( // res => {
(tag: Object) => new Tag(tag['key'], tag['value'])) // let tags = res['data']['createTags']['tags']
} // return tags.map(
)) // (tag: Object) => new Tag(tag['key'], tag['value']))
// }
// ))
} }
public deleteTag(tag: Tag | any, fullInfo?: FullInfo): Observable<object> { public deleteTag(tag: Tag | any, fullInfo?: FullInfo): Observable<object> {
@ -682,10 +692,12 @@ export class InfoDataService {
'key': tag.getKey(), 'key': tag.getKey(),
} }
} }
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: deleteTagQuery, return observableOf()
variables: variables, // return this.apollo.mutate({
}) // mutation: deleteTagQuery,
// variables: variables,
// })
} }
public getTagKeys(): Observable<string[]> { public getTagKeys(): Observable<string[]> {
@ -731,58 +743,64 @@ export class InfoDataService {
return observableOf(<TaggedLayer[]>[]) return observableOf(<TaggedLayer[]>[])
} }
let ids = Object.values(features).map(t => Array.from(t)) let ids = Object.values(features).map(t => Array.from(t))
return this.apollo.query({ console.warn('Migrate Graphql')
query: getTaggedFeaturesQuery, return observableOf()
variables: { // return this.apollo.query({
stores: stores, // query: getTaggedFeaturesQuery,
ids: ids // variables: {
} // stores: stores,
}).pipe(map( // ids: ids
res => { // }
let taggedLayers = this._getTaggedLayers(res['data']['taggedFeatures']) // }).pipe(map(
// Add features with no tag // res => {
Object.entries(features).forEach( // let taggedLayers = this._getTaggedLayers(res['data']['taggedFeatures'])
([store, _features]) => { // // Add features with no tag
let taggedFeatures = taggedLayers.find(s => s.store==store) // Object.entries(features).forEach(
if (!taggedFeatures) { // ([store, _features]) => {
taggedFeatures = new TaggedLayer(store, []) // let taggedFeatures = taggedLayers.find(s => s.store==store)
taggedLayers.push(taggedFeatures) // if (!taggedFeatures) {
} // taggedFeatures = new TaggedLayer(store, [])
let taggedFeaturesIds = taggedFeatures.features.map(tf => +tf.id) // taggedLayers.push(taggedFeatures)
let featureIdsNoTag = Array(..._features).filter(x => !taggedFeaturesIds.includes(x)) // }
featureIdsNoTag.forEach( // let taggedFeaturesIds = taggedFeatures.features.map(tf => +tf.id)
id => { // let featureIdsNoTag = Array(..._features).filter(x => !taggedFeaturesIds.includes(x))
taggedFeatures.features.push(new TaggedFeature(id, undefined, undefined, [])) // featureIdsNoTag.forEach(
} // id => {
) // taggedFeatures.features.push(new TaggedFeature(id, undefined, undefined, []))
} // }
) // )
this.taggedFeaturesSelectionService.next(taggedLayers) // }
return taggedLayers // )
} // this.taggedFeaturesSelectionService.next(taggedLayers)
)) // return taggedLayers
// }
// ))
} }
public getTaggedStores(stores: string[]): Observable<TaggedLayer[]> { public getTaggedStores(stores: string[]): Observable<TaggedLayer[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getTaggedStoresQuery, return observableOf()
variables: { // return this.apollo.query({
stores: stores, // query: getTaggedStoresQuery,
} // variables: {
}).pipe(map( // stores: stores,
res => this._getTaggedLayers(res['data']['taggedStores']) // }
)) // }).pipe(map(
// res => this._getTaggedLayers(res['data']['taggedStores'])
// ))
} }
public getTagsActionsStores(stores: string[]): Observable<TaggedLayer[]> { public getTagsActionsStores(stores: string[]): Observable<TaggedLayer[]> {
return this.apollo.query({ console.warn('Migrate Graphql')
query: getTaggedStoresQuery, return observableOf()
variables: { // return this.apollo.query({
stores: stores, // query: getTaggedStoresQuery,
} // variables: {
}).pipe(map( // stores: stores,
res => this._getTaggedLayers(res['data']['taggedStores']) // }
)) // }).pipe(map(
// res => this._getTaggedLayers(res['data']['taggedStores'])
// ))
} }
// Load tags for selected layers // Load tags for selected layers

View file

@ -2,69 +2,69 @@ import { Injectable } from '@angular/core'
import { Observable, BehaviorSubject, of as observableOf } from 'rxjs' import { Observable, BehaviorSubject, of as observableOf } from 'rxjs'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular' // import { Apollo, gql } from 'apollo-angular'
const tagsPluginQuery = gql` // const tagsPluginQuery = gql`
query tagsPlugins { // query tagsPlugins {
tagsPlugins { // tagsPlugins {
stores { // stores {
store // store
tagActions { // tagActions {
domain // domain
key // key
actions { // actions {
name // name
plugin // plugin
link // link
roles // roles
action // action
} // }
} // }
} // }
} // }
} // }
` // `
const tagsPluginSubmitMutation = gql` // const tagsPluginSubmitMutation = gql`
mutation submitTagsPlugin( // mutation submitTagsPlugin(
$stores: [String], // $stores: [String],
$ids: [[String]], // $ids: [[String]],
$values: [String]!, // $values: [String]!,
$keys: [String]!, // $keys: [String]!,
) { // ) {
submitTagsPlugin( // submitTagsPlugin(
stores: $stores, // stores: $stores,
ids: $ids, // ids: $ids,
values: $values, // values: $values,
keys: $keys // keys: $keys
) { // ) {
tags { // tags {
key // key
value // value
} // }
} // }
} // }
` // `
const doTagActionMutation=gql` // const doTagActionMutation=gql`
mutation doTagAction ( // mutation doTagAction (
$store: String!, // $store: String!,
$id: String!, // $id: String!,
$plugin: String!, // $plugin: String!,
$action: String!, // $action: String!,
$value: String!, // $value: String!,
) { // ) {
doTagAction( // doTagAction(
store: $store, // store: $store,
id: $id, // id: $id,
plugin: $plugin, // plugin: $plugin,
action: $action, // action: $action,
value: $value, // value: $value,
) { // ) {
result // result
} // }
} // }
` // `
export class Tag { export class Tag {
constructor( constructor(
@ -118,7 +118,7 @@ export class TagsPluginsService {
protected _stores: Stores protected _stores: Stores
constructor( constructor(
private apollo: Apollo // private apollo: Apollo
) { ) {
// FIXME: the stores are available only after the instantiation of the TagsPluginsService // FIXME: the stores are available only after the instantiation of the TagsPluginsService
/* /*
@ -131,58 +131,62 @@ export class TagsPluginsService {
} }
getTagsPlugins(): Observable<Stores> { getTagsPlugins(): Observable<Stores> {
if (this._stores === undefined) { console.warn('Migrate Graphql')
return this.apollo.query({ return observableOf()
query: tagsPluginQuery, // if (this._stores === undefined) {
}).pipe(map( // return this.apollo.query({
res => { // query: tagsPluginQuery,
const stores = new Stores( // }).pipe(map(
res['data']['tagsPlugins']['stores'].map( // res => {
(store: Object) => new Store( // const stores = new Stores(
store['store'], // res['data']['tagsPlugins']['stores'].map(
store['tagActions'].map( // (store: Object) => new Store(
(tagKey: Object) => new TagActions( // store['store'],
tagKey['domain'], // store['tagActions'].map(
tagKey['key'], // (tagKey: Object) => new TagActions(
tagKey['actions'].map( // tagKey['domain'],
(tagAction: Object) => new TagAction( // tagKey['key'],
tagAction['name'], // tagKey['actions'].map(
tagAction['plugin'], // (tagAction: Object) => new TagAction(
tagAction['action'], // tagAction['name'],
tagAction['roles'], // tagAction['plugin'],
tagAction['link'], // tagAction['action'],
) // tagAction['roles'],
) // tagAction['link'],
) // )
) // )
) // )
) // )
) // )
this._stores = stores // )
return stores // )
} // this._stores = stores
)) // return stores
} // }
else { // ))
return observableOf(this._stores) // }
} // else {
// return observableOf(this._stores)
// }
} }
submit(features, keys: string[], values: string[]): Observable<Tag[]> { submit(features, keys: string[], values: string[]): Observable<Tag[]> {
let variables = { console.warn('Migrate Graphql')
stores: Object.keys(features), return observableOf()
ids: Object.values(features).map(ids => Array.from(<Number[][]>ids)), // let variables = {
keys: keys, // stores: Object.keys(features),
values: values, // ids: Object.values(features).map(ids => Array.from(<Number[][]>ids)),
} // keys: keys,
return this.apollo.mutate({ // values: values,
mutation: tagsPluginSubmitMutation, // }
variables: variables, // return this.apollo.mutate({
}).pipe(map( // mutation: tagsPluginSubmitMutation,
res => res['data']['submitTagsPlugin']['tags'].map( // variables: variables,
(tag: Object) => new Tag(tag['key'], tag['value']) // }).pipe(map(
) // res => res['data']['submitTagsPlugin']['tags'].map(
)) // (tag: Object) => new Tag(tag['key'], tag['value'])
// )
// ))
} }
doAction(store: string, id: string, action: TagAction, value: string): Observable<string> { doAction(store: string, id: string, action: TagAction, value: string): Observable<string> {
@ -193,11 +197,13 @@ export class TagsPluginsService {
"action": action.action, "action": action.action,
"value": value, "value": value,
} }
return this.apollo.mutate({ console.warn('Migrate Graphql')
mutation: doTagActionMutation, return observableOf()
variables: variables // return this.apollo.mutate({
}).pipe(map( // mutation: doTagActionMutation,
res => res['data']['doTagAction']['result'] // variables: variables
)) // }).pipe(map(
// res => res['data']['doTagAction']['result']
// ))
} }
} }

View file

@ -9,7 +9,8 @@ import { WebSocketSubject } from 'rxjs/webSocket'
import { MatSnackBar } from '@angular/material/snack-bar' import { MatSnackBar } from '@angular/material/snack-bar'
import { Map, MapMouseEvent, LayerSpecification, import { Map, MapMouseEvent, LayerSpecification,
GeoJSONSourceSpecification, FitBoundsOptions, ExpressionSpecification, Source, GeoJSONSource } from 'maplibre-gl' GeoJSONSourceSpecification, FitBoundsOptions,
ExpressionSpecification, Source, GeoJSONSource } from 'maplibre-gl'
import Point from '@mapbox/point-geometry' import Point from '@mapbox/point-geometry'
import * as bbox from '@turf/bbox' import * as bbox from '@turf/bbox'
@ -19,7 +20,7 @@ import { ConfigService } from '../../config.service'
import { MapControlService } from '../map-control.service' import { MapControlService } from '../map-control.service'
import { LayerNode } from '../models' import { LayerNode } from '../models'
import { InfoDataService, Feature, TaggedLayer, FeatureWithField, TaggedFeature } from '../../info/info-data.service' import { InfoDataService, Feature, TaggedLayer, FeatureWithField, TaggedFeature } from '../../info/info-data.service'
import { Store, MapDataService, BaseStyle } from '../map-data.service' import { MapDataService, BaseStyle } from '../map-data.service'
export class LayerWithMetaData { export class LayerWithMetaData {
constructor( constructor(
@ -283,7 +284,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
this.mapControlService.mapReady$.subscribe( this.mapControlService.mapReady$.subscribe(
_ => { _ => {
this.mapControlService.addBaseMapLayers( this.mapControlService.addBaseMapLayers(
params['layers'].split(',').map((store: string) => new Store(store)) params['layers'].split(',')
) )
} }
) )

View file

@ -3,7 +3,6 @@ import { Subject, BehaviorSubject, forkJoin } from 'rxjs'
import { ConfigService } from '../config.service' import { ConfigService } from '../config.service'
import { LayerNode } from './models' import { LayerNode } from './models'
import { Store } from './map-data.service'
import { TaggedLayer, Feature, FeatureWithField } from '../info/info-data.service' import { TaggedLayer, Feature, FeatureWithField } from '../info/info-data.service'
import { BaseMapWithStores } from '../openapi' import { BaseMapWithStores } from '../openapi'
@ -21,9 +20,9 @@ export class MapControlService {
private _hasControls = new BehaviorSubject<boolean>(true) private _hasControls = new BehaviorSubject<boolean>(true)
private _toggleInfo = new BehaviorSubject<boolean>(false) private _toggleInfo = new BehaviorSubject<boolean>(false)
private _layerAdd = new Subject<LayerNode>() private _layerAdd = new Subject<LayerNode>()
private _baseMapLayerAdd = new Subject<Store>() private _baseMapLayerAdd = new Subject<string>()
private _layerRemove = new Subject<LayerNode>() private _layerRemove = new Subject<LayerNode>()
private _baseMapLayerRemove = new Subject<Store>() private _baseMapLayerRemove = new Subject<string>()
private _filter = new BehaviorSubject<[string, TaggedLayer[], string]>(['', [], '']) private _filter = new BehaviorSubject<[string, TaggedLayer[], string]>(['', [], ''])
private _zoomToFeatures = new Subject<boolean>() private _zoomToFeatures = new Subject<boolean>()
private _resize = new Subject<boolean>() private _resize = new Subject<boolean>()
@ -35,7 +34,7 @@ export class MapControlService {
public selection = new BehaviorSubject<Object>({}) public selection = new BehaviorSubject<Object>({})
public tempSelection = new BehaviorSubject<Object>({}) public tempSelection = new BehaviorSubject<Object>({})
public search = new Subject<boolean>() public search = new Subject<boolean>()
public baseMapLayers: BehaviorSubject<Set<Store>> = new BehaviorSubject(new Set()) public baseMapLayers: BehaviorSubject<Set<string>> = new BehaviorSubject(new Set())
public status = new BehaviorSubject<string[]>(this.configService.conf.value.map['defaultStatus']) public status = new BehaviorSubject<string[]>(this.configService.conf.value.map['defaultStatus'])
public hasLabels = new BehaviorSubject<boolean>(false) public hasLabels = new BehaviorSubject<boolean>(false)
public hasTags = new BehaviorSubject<boolean>(false) public hasTags = new BehaviorSubject<boolean>(false)
@ -122,17 +121,17 @@ export class MapControlService {
addBaseMapLayers(baseMapLayers: string[]) { addBaseMapLayers(baseMapLayers: string[]) {
for (let item of baseMapLayers) { for (let item of baseMapLayers) {
this._baseMapLayerAdd.next(new Store(item)) this._baseMapLayerAdd.next(item)
} }
} }
removeBaseMapLayers(baseMapLayers: string[]) { removeBaseMapLayers(baseMapLayers: string[]) {
for (let item of baseMapLayers) { for (let item of baseMapLayers) {
this._baseMapLayerRemove.next(new Store(item)) this._baseMapLayerRemove.next(item)
} }
} }
addBaseMapLayerById(layerId: Store) { addBaseMapLayerById(layerId: string) {
let values = this.baseMapLayers.getValue() let values = this.baseMapLayers.getValue()
values.add(layerId) values.add(layerId)
this.baseMapLayers.next(values) this.baseMapLayers.next(values)

View file

@ -6,7 +6,7 @@ import { StyleSpecification } from 'maplibre-gl'
// import { TreeData, PrimaryGroupNode, LayerNode } from './models' // import { TreeData, PrimaryGroupNode, LayerNode } from './models'
import { MapControlService } from './map-control.service' import { MapControlService } from './map-control.service'
import { MapService, MapInitData, BaseMapWithStores } from '../openapi' import { MapService, MapInitData, BaseMapWithStores, BaseStyle as OApiBaseStyle } from '../openapi'
export class BaseStyle { export class BaseStyle {
constructor( constructor(
@ -15,11 +15,11 @@ export class BaseStyle {
) {} ) {}
} }
export class Store { // export class Store {
constructor( // constructor(
public name: string, // public name: string,
) {} // ) {}
} // }
@Injectable() @Injectable()
export class MapDataService { export class MapDataService {
@ -148,7 +148,9 @@ export class MapDataService {
getBaseStyle(styleName: string): Observable<BaseStyle> { getBaseStyle(styleName: string): Observable<BaseStyle> {
console.log('TODO: getBaseStyle') console.log('TODO: getBaseStyle')
return of({name: ''}) return this.mapService.getBaseStyleApiMapBaseStyleNameGet({name: styleName}).pipe(map(
data => new BaseStyle(data.name, <any>data.style)
))
// return this.apollo.query({ // return this.apollo.query({
// query: baseStyleQuery, // query: baseStyleQuery,
// variables: { // variables: {

View file

@ -31,11 +31,6 @@ export class MapComponent implements OnInit {
) {} ) {}
ngOnInit() { ngOnInit() {
this.activatedRoute.data.subscribe(
(config) => {
console.log(config)
}
)
this.mapControlService.hasControls$.subscribe( this.mapControlService.hasControls$.subscribe(
flag => { flag => {
this.controlsDrawer.toggle(flag).then( this.controlsDrawer.toggle(flag).then(

View file

@ -13,7 +13,7 @@ import { BehaviorSubject, Observable, of as observableOf } from 'rxjs'
import { ConfigService } from '../../config.service' import { ConfigService } from '../../config.service'
import { Node, PrimaryGroupNode, LayerNode, TreeData } from '../models' import { Node, PrimaryGroupNode, LayerNode, TreeData } from '../models'
import { MapControlService } from '../map-control.service' import { MapControlService } from '../map-control.service'
import { MapDataService, Store } from '../map-data.service' import { MapDataService } from '../map-data.service'
import { Feature, FeatureWithField } from '../../info/info-data.service' import { Feature, FeatureWithField } from '../../info/info-data.service'
import { CategoryGroup } from '../../openapi' import { CategoryGroup } from '../../openapi'
@ -73,13 +73,13 @@ export class TreeLayerComponent implements OnInit {
if ('stores' in params) { if ('stores' in params) {
let stores = params['stores'].split(',') let stores = params['stores'].split(',')
for (let store in stores) { for (let store in stores) {
this.mapControlService.addBaseMapLayerById(new Store(store)) this.mapControlService.addBaseMapLayerById(store)
} }
} }
}) })
this.mapControlService.layerAddById$.subscribe( this.mapControlService.layerAddById$.subscribe(
(store: Store) => { (store: string) => {
let layerNode = this._getNodeByStore(store) let layerNode = this._getNodeByStore(store)
if (!layerNode) { if (!layerNode) {
console.log('No such layer, cannot add it', store) console.log('No such layer, cannot add it', store)
@ -98,7 +98,7 @@ export class TreeLayerComponent implements OnInit {
) )
this.mapControlService.layerRemoveById$.subscribe( this.mapControlService.layerRemoveById$.subscribe(
(store: Store) => { (store: string) => {
let layerNode = this._getNodeByStore(store) let layerNode = this._getNodeByStore(store)
if (!layerNode) { if (!layerNode) {
console.log('No such layer, cannot remove it', store) console.log('No such layer, cannot remove it', store)
@ -117,7 +117,7 @@ export class TreeLayerComponent implements OnInit {
if (!feature) { if (!feature) {
return return
} }
let layerNode: LayerNode = this._getNodeByStore(new Store(feature.store)) let layerNode: LayerNode = this._getNodeByStore(feature.store)
if (!layerNode) { if (!layerNode) {
this.snackBar.open('Unknown layer ' + feature.store, 'OK', { this.snackBar.open('Unknown layer ' + feature.store, 'OK', {
duration: 3000 duration: 3000
@ -190,11 +190,11 @@ export class TreeLayerComponent implements OnInit {
this.cdr.markForCheck() this.cdr.markForCheck()
} }
protected _getNodeByStore(store: Store): LayerNode { protected _getNodeByStore(store: string): LayerNode {
// Get the LayerNode with the store // Get the LayerNode with the store
// Assumes that the tree's depth is 2 // Assumes that the tree's depth is 2
return <LayerNode>(this.nestedDataSource.data.map( return <LayerNode>(this.nestedDataSource.data.map(
pg => pg.children.find(node => node.store==store.name pg => pg.children.find(node => node.store==store
)).find(node => !!node)) )).find(node => !!node))
} }

View file

@ -1,12 +1,12 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { Router, Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router' import { Router, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable, of, EMPTY, forkJoin } from 'rxjs' import { Observable, of, EMPTY, forkJoin } from 'rxjs'
import { map, mergeMap, take, first } from 'rxjs/operators' import { map, mergeMap, take, first } from 'rxjs/operators'
import { DataService, MeasuresItem } from '../../_services/data.service' import { DataService, MeasuresItem } from '../../_services/data.service'
@Injectable() @Injectable()
export class MeasuresListResolver implements Resolve<object> { export class MeasuresListResolver {
constructor( constructor(
protected dataService: DataService, protected dataService: DataService,
private router: Router private router: Router

View file

@ -14,7 +14,7 @@
"@types" "@types"
], ],
"lib": [ "lib": [
"es6", "es2019",
"dom", "dom",
"esnext.asynciterable" "esnext.asynciterable"
], ],