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": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "gisaf-app:build",
"proxyConfig": "proxy.conf.json"
"proxyConfig": "proxy.conf.json",
"buildTarget": "gisaf-app:build"
},
"configurations": {
"production": {
"browserTarget": "gisaf-app:build:production"
"buildTarget": "gisaf-app:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "gisaf-app:build"
"buildTarget": "gisaf-app:build"
}
},
"test": {

7849
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -27,39 +27,36 @@
],
"private": true,
"dependencies": {
"@angular/animations": "^15.2.1",
"@angular/cdk": "^15.2.1",
"@angular/common": "^15.2.1",
"@angular/compiler": "^15.2.1",
"@angular/core": "^15.2.1",
"@angular/forms": "^15.2.1",
"@angular/material": "^15.2.1",
"@angular/platform-browser": "^15.2.1",
"@angular/platform-browser-dynamic": "^15.2.1",
"@angular/platform-server": "^15.2.1",
"@angular/router": "^15.2.1",
"@apollo/client": "^3.4.16",
"@angular/animations": "^16.2.12",
"@angular/cdk": "^16.2.14",
"@angular/common": "^16.2.12",
"@angular/compiler": "^16.2.12",
"@angular/core": "^16.2.12",
"@angular/forms": "^16.2.12",
"@angular/material": "^16.2.14",
"@angular/platform-browser": "^16.2.12",
"@angular/platform-browser-dynamic": "^16.2.12",
"@angular/platform-server": "^16.2.12",
"@angular/router": "^16.2.12",
"@mapbox/point-geometry": "^0.1.0",
"@maplibre/ngx-maplibre-gl": "^13.0.0",
"@turf/bbox": "^6.5.0",
"@turf/distance": "^6.5.0",
"angular-plotly.js": "^4.0.4",
"apollo-angular": "^4.2.1",
"angular-plotly.js": "^5.2.2",
"core-js": "^2.6.3",
"graphql": "^15.6.1",
"maplibre-gl": "^2.4.0",
"ngx-flexible-layout": "15.0.1",
"plotly.js-basic-dist-min": "^2.8.1",
"ngx-flexible-layout": "~16.0",
"plotly.js-basic-dist-min": "2.29.1",
"rxjs": "^7.4.0",
"subscriptions-transport-ws": "^0.9.17",
"ts-helpers": "^1.1.2",
"zone.js": "~0.11.4"
"zone.js": "~0.13.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.2.1",
"@angular/cli": "^15.2.1",
"@angular/compiler-cli": "^15.2.1",
"@angular/language-service": "^15.2.1",
"@angular-devkit/build-angular": "^16.2.12",
"@angular/cli": "^16.2.12",
"@angular/compiler-cli": "^16.2.12",
"@angular/language-service": "^16.2.12",
"@types/core-js": "^2.5.0",
"@types/geojson": "^7946.0.7",
"@types/jasmine": "~3.6.0",
@ -82,6 +79,6 @@
"ts-node": "^8.0.2",
"tslib": "^2.0.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 { Observable, pipe, BehaviorSubject } from 'rxjs'
import { Observable, pipe, BehaviorSubject, of as observableOf } from 'rxjs'
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 { TaggedLayer, TaggedFeature, FormFieldInput } from '../info/info-data.service'
@ -70,63 +70,63 @@ export class Store {
}
const getTagsActionsQuery = gql`
query actionsPlugins {
actionsPlugins {
store
actions {
name
roles
params {
name
type
dflt
}
}
}
}
`
// const getTagsActionsQuery = gql`
// query actionsPlugins {
// actionsPlugins {
// store
// actions {
// name
// roles
// params {
// name
// type
// dflt
// }
// }
// }
// }
// `
const executeTagsActionsQuery = gql`
mutation executeAction(
$stores: [String]!,
$ids: [[String]]!,
$names: [String]!,
$params: [ActionParamInput],
$formFields: [FormFieldInput]
) {
executeAction(
stores: $stores,
ids: $ids,
names: $names,
params: $params,
formFields: $formFields,
) {
result {
message
actionResults {
name
message
actionResults {
message
taggedLayers {
store
taggedFeatures {
id
lon
lat
tags {
key
value
}
}
}
}
}
}
}
}
`
// const executeTagsActionsQuery = gql`
// mutation executeAction(
// $stores: [String]!,
// $ids: [[String]]!,
// $names: [String]!,
// $params: [ActionParamInput],
// $formFields: [FormFieldInput]
// ) {
// executeAction(
// stores: $stores,
// ids: $ids,
// names: $names,
// params: $params,
// formFields: $formFields,
// ) {
// result {
// message
// actionResults {
// name
// message
// actionResults {
// message
// taggedLayers {
// store
// taggedFeatures {
// id
// lon
// lat
// tags {
// key
// value
// }
// }
// }
// }
// }
// }
// }
// }
// `
@Injectable()
@ -137,7 +137,7 @@ export class ActionsService {
public actionsProviderService$ = this.actionsProviderService.asObservable()
constructor(
private apollo: Apollo,
// private apollo: Apollo,
) {
this.getTagsActionsStores().subscribe(
actionsStores => {
@ -147,32 +147,34 @@ export class ActionsService {
}
public getTagsActionsStores(): Observable<ActionsStore[]> {
return this.apollo.query({
query: getTagsActionsQuery,
}).pipe(map(
res => {
let actionStores = res['data']['actionsPlugins'].map(pipe(
store => new Store(
store['store'],
store['actions'].map(
action => new Action(
action['name'],
action['roles'],
action['params'].map(
param => new ActionParam(
param['name'],
param['type'],
param['dflt']
)
)
)
)
)
))
this.actionsProviderService.next(actionStores)
return actionStores
}
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: getTagsActionsQuery,
// }).pipe(map(
// res => {
// let actionStores = res['data']['actionsPlugins'].map(pipe(
// store => new Store(
// store['store'],
// store['actions'].map(
// action => new Action(
// action['name'],
// action['roles'],
// action['params'].map(
// param => new ActionParam(
// param['name'],
// param['type'],
// param['dflt']
// )
// )
// )
// )
// )
// ))
// this.actionsProviderService.next(actionStores)
// return actionStores
// }
// ))
}
public execute(
@ -182,51 +184,53 @@ export class ActionsService {
params: ActionParam[],
formFields?: FormFieldInput[]
): Observable<ActionsResults> {
return this.apollo.mutate({
mutation: executeTagsActionsQuery,
variables: {
stores: stores,
ids: ids,
names: actionNames,
params: params,
formFields: formFields
}
}).pipe(map(
result => result['data']['executeAction']['result'].map(
res => new ActionsResults(
res['message'],
res['actionResults'].map(
r => new ActionResults(
r['name'],
r['message'],
r['actionResults'] && r['actionResults'].map(
actionResults => new ActionResult(
actionResults['name'],
actionResults['message'],
(actionResults['taggedLayers'] || []).map(
taggedLayer => new TaggedLayer(
taggedLayer['store'],
taggedLayer['taggedFeatures'].map(
taggedFeature => new TaggedFeature(
taggedFeature['id'],
taggedFeature['lon'],
taggedFeature['lat'],
taggedFeature['tags'].map(
tag => new Tag(
tag['key'],
tag['value']
)
)
)
)
)
)
)
)
)
)
)
)
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.mutate({
// mutation: executeTagsActionsQuery,
// variables: {
// stores: stores,
// ids: ids,
// names: actionNames,
// params: params,
// formFields: formFields
// }
// }).pipe(map(
// result => result['data']['executeAction']['result'].map(
// res => new ActionsResults(
// res['message'],
// res['actionResults'].map(
// r => new ActionResults(
// r['name'],
// r['message'],
// r['actionResults'] && r['actionResults'].map(
// actionResults => new ActionResult(
// actionResults['name'],
// actionResults['message'],
// (actionResults['taggedLayers'] || []).map(
// taggedLayer => new TaggedLayer(
// taggedLayer['store'],
// taggedLayer['taggedFeatures'].map(
// taggedFeature => new TaggedFeature(
// taggedFeature['id'],
// taggedFeature['lon'],
// taggedFeature['lat'],
// taggedFeature['tags'].map(
// 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 { Observable, forkJoin } from 'rxjs'
import { Observable, forkJoin, of as observableOf } from 'rxjs'
import { map, mergeMap } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular'
// import { Apollo, gql } from 'apollo-angular'
const fieldTypeMap = {
Int: 'number',
@ -14,57 +14,57 @@ const fieldTypeMap = {
Boolean: 'checkbox',
}
const introspectionQuery = gql`
query introspect ($modelName: String!) {
__type(name: $modelName) {
name
fields {
name
type {
name
kind
ofType {
name
}
}
}
}
}
`
// const introspectionQuery = gql`
// query introspect ($modelName: String!) {
// __type(name: $modelName) {
// name
// fields {
// name
// type {
// name
// kind
// ofType {
// name
// }
// }
// }
// }
// }
// `
const inspectionQuery = gql`
query inspect ($modelName: String!) {
inspect(modelName: $modelName) {
pkFields
relation_fields
joins {
name
target
rel_field
}
}
}
`
// const inspectionQuery = gql`
// query inspect ($modelName: String!) {
// inspect(modelName: $modelName) {
// pkFields
// relation_fields
// joins {
// name
// target
// rel_field
// }
// }
// }
// `
const dashboardPageQuery = gql`
query dashboard_page ($group: String!, $name: String!) {
dashboard_page(group: $group, name: $name) {
name
group
description
html
notebook
time
dfData
plotData
attachment
expandedPanes
sections {
name
plot
}
}
}`
// const dashboardPageQuery = gql`
// query dashboard_page ($group: String!, $name: String!) {
// dashboard_page(group: $group, name: $name) {
// name
// group
// description
// html
// notebook
// time
// dfData
// plotData
// attachment
// expandedPanes
// sections {
// name
// plot
// }
// }
// }`
export class FieldIntrospection {
constructor(
@ -128,13 +128,15 @@ export class ModelIntrospection {
}
getMutationQuery() {
return gql`
mutation mutation(${this.mutationFields}) {
mutation(${this.mutationVars}) {
${this.mutationData}
}
}
`
console.warn('Migrate Graphql')
return observableOf()
// return gql`
// mutation mutation(${this.mutationFields}) {
// mutation(${this.mutationVars}) {
// ${this.mutationData}
// }
// }
// `
}
}
@ -220,7 +222,7 @@ export class Model {
@Injectable()
export class ModelDataService {
constructor(
private apollo: Apollo
// private apollo: Apollo
) {}
fullInspect(modelName): Observable<Model> {
@ -233,64 +235,70 @@ export class ModelDataService {
}
inspect(modelName): Observable<ModelInspection> {
console.warn('Migrate Graphql')
return observableOf()
// Inspection (Gisaf)
return this.get(inspectionQuery, {'modelName': modelName}).pipe(map(
res => {
let joins = res['inspect']['joins'].map(
join => new JoinField(join['name'], join['target'], join['rel_field'])
)
return new ModelInspection(
res['inspect']['pkFields'],
res['inspect']['relation_fields'],
joins
)
}
))
// return this.get(inspectionQuery, {'modelName': modelName}).pipe(map(
// res => {
// let joins = res['inspect']['joins'].map(
// join => new JoinField(join['name'], join['target'], join['rel_field'])
// )
// return new ModelInspection(
// res['inspect']['pkFields'],
// res['inspect']['relation_fields'],
// joins
// )
// }
// ))
}
introspect(modelName): Observable<ModelIntrospection> {
// Introspection (Graphql)
return this.get(introspectionQuery, {'modelName': modelName}).pipe(map(
res => {
var relations = []
let _fields = res['__type']['fields']
// Find the primary keys
var fields = _fields.filter(f => !f.type.name && f.type.kind=='NON_NULL').map(
f => new FieldIntrospection(f.name, f['type']['ofType']['name'], true)
)
var pkFieldNames = fields.map(f => f.name)
_fields.forEach(
resField => {
let name = resField['name']
let type = resField['type']
// Skip primary keys
if (pkFieldNames.indexOf(name) != -1) {
return
}
if (name == 'geom') {
// Remove geom column
// XXX: Should be marked as geojson type
// and might be a link to the map or something like that
return
}
if (type['kind'] == 'OBJECT') {
// Relation
return
}
fields.push(new FieldIntrospection(name, type['name']))
}
)
return new ModelIntrospection(modelName, fields, relations)
}
))
console.warn('Migrate Graphql')
return observableOf()
// return this.get(introspectionQuery, {'modelName': modelName}).pipe(map(
// res => {
// var relations = []
// let _fields = res['__type']['fields']
// // Find the primary keys
// var fields = _fields.filter(f => !f.type.name && f.type.kind=='NON_NULL').map(
// f => new FieldIntrospection(f.name, f['type']['ofType']['name'], true)
// )
// var pkFieldNames = fields.map(f => f.name)
// _fields.forEach(
// resField => {
// let name = resField['name']
// let type = resField['type']
// // Skip primary keys
// if (pkFieldNames.indexOf(name) != -1) {
// return
// }
// if (name == 'geom') {
// // Remove geom column
// // XXX: Should be marked as geojson type
// // and might be a link to the map or something like that
// return
// }
// if (type['kind'] == 'OBJECT') {
// // Relation
// return
// }
// fields.push(new FieldIntrospection(name, type['name']))
// }
// )
// return new ModelIntrospection(modelName, fields, relations)
// }
// ))
}
mutate(model: ModelIntrospection, values: object): Observable<object> {
let mutationQuery = model.getMutationQuery()
return this.apollo.mutate({
mutation: mutationQuery,
variables: values,
})
console.warn('Migrate Graphql')
return observableOf()
// let mutationQuery = model.getMutationQuery()
// return this.apollo.mutate({
// mutation: mutationQuery,
// variables: values,
// })
}
resolveItemData(modelName: string, pk: string): Observable<object> {
@ -299,22 +307,24 @@ export class ModelDataService {
model => {
// XXX: get pk type and name from model introspection
let pkField = model.introspection.pkFields()[0]
let query = gql`
query item ($pk: ID) {
${modelName} (pk:$pk) {
${model.introspection.columnsForGql()}
}
}`
return this.get(query, {pk: pk}).pipe(map(
item => {
if (item) {
return {
'item': item,
'model': model,
}
}
}
))
console.warn('Migrate Graphql')
return observableOf()
// let query = gql`
// query item ($pk: ID) {
// ${modelName} (pk:$pk) {
// ${model.introspection.columnsForGql()}
// }
// }`
// return this.get(query, {pk: pk}).pipe(map(
// item => {
// if (item) {
// return {
// 'item': item,
// 'model': model,
// }
// }
// }
// ))
}
)
)
@ -325,80 +335,88 @@ export class ModelDataService {
fields = model.columns()
}
const fieldList = fields.join(' ')
const query = gql`query model {${model.name}{${fieldList}}}`
return this.get(query)
console.warn('Migrate Graphql')
return observableOf()
// const query = gql`query model {${model.name}{${fieldList}}}`
// return this.get(query)
}
get(query, vars: object = {}): Observable<any> {
return this.apollo.query({
query: query,
variables: vars,
errorPolicy: 'all',
}).pipe(map(
result => {
if (result.errors) {
throw result.errors.map(err => err.message).join(', ')
}
else {
return result.data
}
}
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: query,
// variables: vars,
// errorPolicy: 'all',
// }).pipe(map(
// result => {
// if (result.errors) {
// throw result.errors.map(err => err.message).join(', ')
// }
// else {
// return result.data
// }
// }
// ))
}
}
@Injectable()
export class DashboardDataService {
constructor(
private apollo: Apollo
// private apollo: Apollo
) {}
getDashboardPage(group: string, name: string): Observable<DashboardPage> {
return this.get(dashboardPageQuery, {'name': name, 'group': group}).pipe(map(
res => {
if (res['errors'] && res['errors'].length > 0) {
return new DashboardPage(
name,
group,
res['errors'].map(e => e.message).join(', '),
)
}
console.warn('Migrate Graphql')
return observableOf()
// return this.get(dashboardPageQuery, {'name': name, 'group': group}).pipe(map(
// res => {
// if (res['errors'] && res['errors'].length > 0) {
// return new DashboardPage(
// name,
// group,
// res['errors'].map(e => e.message).join(', '),
// )
// }
let page = res['dashboard_page']
return new DashboardPage(
page['name'],
page['group'],
'',
page['description'],
page['html'],
page['notebook'],
JSON.parse(page['dfData']),
JSON.parse(page['plotData']),
page['time'],
page['attachment'],
page['expandedPanes'],
page['sections'] ? page['sections'].map(
section => new DashboardPageSection(
section['name'],
section['plot']
)
) : []
)
}
))
// let page = res['dashboard_page']
// return new DashboardPage(
// page['name'],
// page['group'],
// '',
// page['description'],
// page['html'],
// page['notebook'],
// JSON.parse(page['dfData']),
// JSON.parse(page['plotData']),
// page['time'],
// page['attachment'],
// page['expandedPanes'],
// page['sections'] ? page['sections'].map(
// section => new DashboardPageSection(
// section['name'],
// section['plot']
// )
// ) : []
// )
// }
// ))
}
get(query, vars: object = {}): Observable<any> {
return this.apollo.query({
query: query,
variables: vars
}).pipe(map(
result => {
if (result.errors && result.errors.length > 0) {
return result
}
return result.data
}
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: query,
// variables: vars
// }).pipe(map(
// result => {
// if (result.errors && result.errors.length > 0) {
// return result
// }
// return result.data
// }
// ))
}
}

View file

@ -1,12 +1,12 @@
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 { map } from 'rxjs/operators'
import { AdminBasket, AdminBasketDataService } from './data.service'
@Injectable()
export class BasketResolver implements Resolve<object> {
export class BasketResolver {
constructor(
private router: Router,
private basketDataService: AdminBasketDataService,

View file

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

View file

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

View file

@ -1,12 +1,12 @@
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 { map } from 'rxjs/operators'
import { ModelDataService } from '../../_services/apollo.service'
@Injectable()
export class DetailResolver implements Resolve<object> {
export class DetailResolver {
constructor(
private modelDataService: ModelDataService,
private router: Router

View file

@ -5,7 +5,7 @@ import { UntypedFormGroup, FormControl } from '@angular/forms'
import { map, switchMap } from 'rxjs/operators'
import { gql } from 'apollo-angular'
// import { gql } from 'apollo-angular'
import { ModelDataService, JoinField } from '../../_services/apollo.service'
import { Relation } from '../models'
@ -27,7 +27,9 @@ export class JoinSelectComponent implements OnInit {
ngOnInit() {
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 => {
return data[modelName]
})).subscribe(data => {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,8 +3,6 @@ import { HttpClient } from '@angular/common/http'
import { Observable, Subject, of } from 'rxjs'
import { map } from 'rxjs/operators'
// import { Apollo, QueryRef, gql } from 'apollo-angular'
import { WebsocketService } from '../../_services/websocket.service'
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 { map } from 'rxjs/operators'
import { gql } from 'apollo-angular'
// import { gql } from 'apollo-angular'
import { ModelDataService } from '../_services/apollo.service'
import { AppInjector } from '../app-injector'
@ -40,7 +40,9 @@ export class TableDataSource extends DataSource<object[]> {
connect(): Observable<any> {
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)
}

View file

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

View file

@ -1,11 +1,11 @@
import { Injectable } from '@angular/core'
import { Resolve, RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { RouterStateSnapshot, ActivatedRouteSnapshot } from '@angular/router'
import { Observable } from 'rxjs'
import { DashboardDataService } from '../../_services/apollo.service'
@Injectable()
export class DashboardPageResolver implements Resolve<object> {
export class DashboardPageResolver {
constructor(
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 { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular'
// import { Apollo, gql } from 'apollo-angular'
import { MapControlService } from '../map/map-control.service'
import { LayerNode } from '../map/models'
@ -13,236 +13,236 @@ import { Tag, TagAction } from './info-tags/tags.service'
import { ConfigService } from '../config.service'
import { DataService } from '../_services/data.service'
const getModelInfoQuery = gql`
query modelInfo ($store: String!) {
modelInfo(store: $store) {
store
modelName
symbol
values {
name
title
unit
chartType
chartColor
}
actions {
name
icon
formFields {
name
type
}
}
formName
formFields {
name
type
}
tagPlugins
tagActions {
domain
key
actions {
plugin
name
link
action
roles
}
}
downloaders {
name
icon
}
legend {
key
value
}
}
}
`
// const getModelInfoQuery = gql`
// query modelInfo ($store: String!) {
// modelInfo(store: $store) {
// store
// modelName
// symbol
// values {
// name
// title
// unit
// chartType
// chartColor
// }
// actions {
// name
// icon
// formFields {
// name
// type
// }
// }
// formName
// formFields {
// name
// type
// }
// tagPlugins
// tagActions {
// domain
// key
// actions {
// plugin
// name
// link
// action
// roles
// }
// }
// downloaders {
// name
// icon
// }
// legend {
// key
// value
// }
// }
// }
// `
const getTagKeysQuery = gql`
query tagKeyList {
tagKeyList {
keys
}
}
`
// const getTagKeysQuery = gql`
// query tagKeyList {
// tagKeyList {
// keys
// }
// }
// `
const createTagMutation = gql`
mutation createTag(
$store: String!
$id: String!
$key: String!
$value: String!
) {
createTag(
store: $store,
id: $id,
key: $key,
value: $value
) {
tags {
key
value
}
}
}
`
// const createTagMutation = gql`
// mutation createTag(
// $store: String!
// $id: String!
// $key: String!
// $value: String!
// ) {
// createTag(
// store: $store,
// id: $id,
// key: $key,
// value: $value
// ) {
// tags {
// key
// value
// }
// }
// }
// `
const createTagsMutations = gql`
mutation createTags(
$keys: [String]!
$values: [String]!
$stores: [String]!
$ids: [[String]]!
) {
createTags(
keys: $keys,
values: $values,
stores: $stores,
ids: $ids,
) {
tags {
key
value
}
}
}
`
// const createTagsMutations = gql`
// mutation createTags(
// $keys: [String]!
// $values: [String]!
// $stores: [String]!
// $ids: [[String]]!
// ) {
// createTags(
// keys: $keys,
// values: $values,
// stores: $stores,
// ids: $ids,
// ) {
// tags {
// key
// value
// }
// }
// }
// `
const getPlotParamsQuery = gql`
query plotParams($store: String!, $id:String!, $value:String!) {
plotParams(store: $store, id: $id, value: $value) {
baseLines {
name
value
color
}
bgShapes {
name
valueTop
valueBottom
color
}
barBase
}
}
`
// const getPlotParamsQuery = gql`
// query plotParams($store: String!, $id:String!, $value:String!) {
// plotParams(store: $store, id: $id, value: $value) {
// baseLines {
// name
// value
// color
// }
// bgShapes {
// name
// valueTop
// valueBottom
// color
// }
// barBase
// }
// }
// `
const getFeatureInfoQuery = gql`
query featureInfo($store: String!, $id:String!) {
featureInfo(store: $store, id: $id) {
id
itemName
geoInfoItems {
key
value
}
surveyInfoItems {
key
value
}
infoItems {
key
value
}
categorizedInfoItems {
name
infoItems {
key
value
}
}
tags {
key
value
}
graph
files {
name
path
}
images {
name
path
}
externalRecordUrl
}
}
`
// const getFeatureInfoQuery = gql`
// query featureInfo($store: String!, $id:String!) {
// featureInfo(store: $store, id: $id) {
// id
// itemName
// geoInfoItems {
// key
// value
// }
// surveyInfoItems {
// key
// value
// }
// infoItems {
// key
// value
// }
// categorizedInfoItems {
// name
// infoItems {
// key
// value
// }
// }
// tags {
// key
// value
// }
// graph
// files {
// name
// path
// }
// images {
// name
// path
// }
// externalRecordUrl
// }
// }
// `
const deleteTagQuery = gql`
mutation deleteTag(
$store: String!
$id: String!
$key: String!
) {
deleteTag(
store: $store,
id: $id,
key: $key,
) {
tags {
key
value
}
}
}
`
// const deleteTagQuery = gql`
// mutation deleteTag(
// $store: String!
// $id: String!
// $key: String!
// ) {
// deleteTag(
// store: $store,
// id: $id,
// key: $key,
// ) {
// tags {
// key
// value
// }
// }
// }
// `
const getTaggedFeaturesQuery = gql`
query taggedFeatures($stores: [String], $ids: [[String]]) {
taggedFeatures(stores: $stores, ids: $ids) {
store
taggedFeatures {
id
lon
lat
tags {
key
value
}
}
}
}
`
// const getTaggedFeaturesQuery = gql`
// query taggedFeatures($stores: [String], $ids: [[String]]) {
// taggedFeatures(stores: $stores, ids: $ids) {
// store
// taggedFeatures {
// id
// lon
// lat
// tags {
// key
// value
// }
// }
// }
// }
// `
const getTaggedStoresQuery = gql`
query taggedStores($stores: [String]) {
taggedStores(stores: $stores) {
store
taggedFeatures {
id
lon
lat
tags {
key
value
}
}
}
}
`
const executeFeatureActionMutation=gql`
mutation executeFeatureAction (
$store: String!,
$id: String!,
$action: String!,
$value: String,
) {
executeFeatureAction(
store: $store,
id: $id,
action: $action,
value: $value,
) {
result
}
}
`
// const getTaggedStoresQuery = gql`
// query taggedStores($stores: [String]) {
// taggedStores(stores: $stores) {
// store
// taggedFeatures {
// id
// lon
// lat
// tags {
// key
// value
// }
// }
// }
// }
// `
// const executeFeatureActionMutation=gql`
// mutation executeFeatureAction (
// $store: String!,
// $id: String!,
// $action: String!,
// $value: String,
// ) {
// executeFeatureAction(
// store: $store,
// id: $id,
// action: $action,
// value: $value,
// ) {
// result
// }
// }
// `
export class TaggedFeature {
constructor(
@ -448,7 +448,7 @@ export class FullInfo {
export class InfoDataService {
constructor(
public configService: ConfigService,
private apollo: Apollo,
// private apollo: Apollo,
public mapControlService: MapControlService,
protected dataService: DataService,
) {}
@ -467,75 +467,77 @@ export class InfoDataService {
public taggedLayers$ = this.taggedLayers.asObservable()
getModelInfo(store: string): Observable<ModelInfo> {
return this.apollo.query({
query: getModelInfoQuery,
variables: {
store: store,
}
}).pipe(map(
res => {
let info: Object = res['data']['modelInfo']
let values = (info['values'] || []).map(
(value: Object) => new ModelValue(
value['name'],
value['title'],
value['unit'],
value['chartType'],
value['chartColor'],
)
)
return new ModelInfo(
info['store'],
info['modelName'],
info['symbol'],
values,
info['actions'] ? info['actions'].map(
action => new ModelAction(
action['name'],
action['icon'],
action['formFields'].map(
formField => new FormField(
formField['name'],
formField['type'],
formField['dflt']
)
)
)
): [],
info['formName'],
info['formFields'] ? info['formFields'].map(
(formField: Object) => new FormField(
formField['name'],
formField['type'],
)
) : [],
info['tagPlugins'],
info['tagActions'] ? info['tagActions'].map(
tagAction => new TagAction(
// FIXME: set real data!!!
'**name**',
'**plugin_name**',
//tagAction['key'],
tagAction.actions[0]['action'],
['**role**'],
'**link**',
)
) : [],
info['downloaders'] ? info['downloaders'].map(
downloader => new Downloader(
downloader['name'],
downloader['icon'],
)
) : [],
info['legend'] ? info['legend'].map(
legendItem => new LegendItem(
legendItem['key'],
legendItem['value'],
)
) : [],
)
}
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: getModelInfoQuery,
// variables: {
// store: store,
// }
// }).pipe(map(
// res => {
// let info: Object = res['data']['modelInfo']
// let values = (info['values'] || []).map(
// (value: Object) => new ModelValue(
// value['name'],
// value['title'],
// value['unit'],
// value['chartType'],
// value['chartColor'],
// )
// )
// return new ModelInfo(
// info['store'],
// info['modelName'],
// info['symbol'],
// values,
// info['actions'] ? info['actions'].map(
// action => new ModelAction(
// action['name'],
// action['icon'],
// action['formFields'].map(
// formField => new FormField(
// formField['name'],
// formField['type'],
// formField['dflt']
// )
// )
// )
// ): [],
// info['formName'],
// info['formFields'] ? info['formFields'].map(
// (formField: Object) => new FormField(
// formField['name'],
// formField['type'],
// )
// ) : [],
// info['tagPlugins'],
// info['tagActions'] ? info['tagActions'].map(
// tagAction => new TagAction(
// // FIXME: set real data!!!
// '**name**',
// '**plugin_name**',
// //tagAction['key'],
// tagAction.actions[0]['action'],
// ['**role**'],
// '**link**',
// )
// ) : [],
// info['downloaders'] ? info['downloaders'].map(
// downloader => new Downloader(
// downloader['name'],
// downloader['icon'],
// )
// ) : [],
// info['legend'] ? info['legend'].map(
// legendItem => new LegendItem(
// legendItem['key'],
// legendItem['value'],
// )
// ) : [],
// )
// }
// ))
}
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> {
return this.apollo.query({
query: getPlotParamsQuery,
variables: {
store: store,
id: id,
value: value
}
}).pipe(map(
info => info.data['plotParams'] ? new PlotParams(
(info.data['plotParams']['baseLines'] || []).map(
bl => new PlotBaseLine(
bl['name'],
bl['value'],
bl['color']
)
),
(info.data['plotParams']['bgShapes'] || []).map(
bl => new PlotBgShape(
bl['name'],
bl['valueTop'],
bl['valueBottom'],
bl['color']
)
),
info.data['plotParams']['barBase']
) : new PlotParams()
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: getPlotParamsQuery,
// variables: {
// store: store,
// id: id,
// value: value
// }
// }).pipe(map(
// info => info.data['plotParams'] ? new PlotParams(
// (info.data['plotParams']['baseLines'] || []).map(
// bl => new PlotBaseLine(
// bl['name'],
// bl['value'],
// bl['color']
// )
// ),
// (info.data['plotParams']['bgShapes'] || []).map(
// bl => new PlotBgShape(
// bl['name'],
// bl['valueTop'],
// bl['valueBottom'],
// bl['color']
// )
// ),
// info.data['plotParams']['barBase']
// ) : new PlotParams()
// ))
}
getFeatureInfo(store: string, id: string): Observable<FeatureInfo> {
return this.apollo.query({
query: getFeatureInfoQuery,
variables: {
store: store,
id: id
}
}).pipe(map(
res => {
const info = res['data']['featureInfo']
const geoInfoItems = info['geoInfoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
const surveyInfoItems = info['surveyInfoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
const infoItems = info['infoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
const categorizedInfoItems = info['categorizedInfoItems'] && info['categorizedInfoItems'].map(
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']))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: getFeatureInfoQuery,
// variables: {
// store: store,
// id: id
// }
// }).pipe(map(
// res => {
// const info = res['data']['featureInfo']
// const geoInfoItems = info['geoInfoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
// const surveyInfoItems = info['surveyInfoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
// const infoItems = info['infoItems'].map(ii => new InfoItem(ii['key'], ii['value']))
// const categorizedInfoItems = info['categorizedInfoItems'] && info['categorizedInfoItems'].map(
// 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']))
return new FeatureInfo(
info['id'],
info['itemName'],
geoInfoItems,
surveyInfoItems,
infoItems,
categorizedInfoItems,
tags,
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['images'] && info['images'].map(att => new Attachment(att['name'], att['path'])),
info['externalRecordUrl']
)
}
))
// return new FeatureInfo(
// info['id'],
// info['itemName'],
// geoInfoItems,
// surveyInfoItems,
// infoItems,
// categorizedInfoItems,
// tags,
// 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['images'] && info['images'].map(att => new Attachment(att['name'], att['path'])),
// info['externalRecordUrl']
// )
// }
// ))
}
getFullInfo(feature: Feature): Observable<FullInfo> {
@ -635,13 +641,15 @@ export class InfoDataService {
'key': tag['key'],
'value': tag['value'],
}
return this.apollo.mutate({
mutation: createTagMutation,
variables: variables,
}).pipe(map(
res => res['data']['createTag']['tags'].map(
(tag: Object) => new Tag(tag['key'], tag['value']))
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.mutate({
// mutation: createTagMutation,
// variables: variables,
// }).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[]> {
@ -651,16 +659,18 @@ export class InfoDataService {
'stores': Object.keys(source),
'ids': Object.values(source).map(ids => Array.from(<Number[][]>ids)),
}
return this.apollo.mutate({
mutation: createTagsMutations,
variables: variables,
}).pipe(map(
res => {
let tags = res['data']['createTags']['tags']
return tags.map(
(tag: Object) => new Tag(tag['key'], tag['value']))
}
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.mutate({
// mutation: createTagsMutations,
// variables: variables,
// }).pipe(map(
// res => {
// 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> {
@ -682,10 +692,12 @@ export class InfoDataService {
'key': tag.getKey(),
}
}
return this.apollo.mutate({
mutation: deleteTagQuery,
variables: variables,
})
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.mutate({
// mutation: deleteTagQuery,
// variables: variables,
// })
}
public getTagKeys(): Observable<string[]> {
@ -731,58 +743,64 @@ export class InfoDataService {
return observableOf(<TaggedLayer[]>[])
}
let ids = Object.values(features).map(t => Array.from(t))
return this.apollo.query({
query: getTaggedFeaturesQuery,
variables: {
stores: stores,
ids: ids
}
}).pipe(map(
res => {
let taggedLayers = this._getTaggedLayers(res['data']['taggedFeatures'])
// Add features with no tag
Object.entries(features).forEach(
([store, _features]) => {
let taggedFeatures = taggedLayers.find(s => s.store==store)
if (!taggedFeatures) {
taggedFeatures = new TaggedLayer(store, [])
taggedLayers.push(taggedFeatures)
}
let taggedFeaturesIds = taggedFeatures.features.map(tf => +tf.id)
let featureIdsNoTag = Array(..._features).filter(x => !taggedFeaturesIds.includes(x))
featureIdsNoTag.forEach(
id => {
taggedFeatures.features.push(new TaggedFeature(id, undefined, undefined, []))
}
)
}
)
this.taggedFeaturesSelectionService.next(taggedLayers)
return taggedLayers
}
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: getTaggedFeaturesQuery,
// variables: {
// stores: stores,
// ids: ids
// }
// }).pipe(map(
// res => {
// let taggedLayers = this._getTaggedLayers(res['data']['taggedFeatures'])
// // Add features with no tag
// Object.entries(features).forEach(
// ([store, _features]) => {
// let taggedFeatures = taggedLayers.find(s => s.store==store)
// if (!taggedFeatures) {
// taggedFeatures = new TaggedLayer(store, [])
// taggedLayers.push(taggedFeatures)
// }
// let taggedFeaturesIds = taggedFeatures.features.map(tf => +tf.id)
// let featureIdsNoTag = Array(..._features).filter(x => !taggedFeaturesIds.includes(x))
// featureIdsNoTag.forEach(
// id => {
// taggedFeatures.features.push(new TaggedFeature(id, undefined, undefined, []))
// }
// )
// }
// )
// this.taggedFeaturesSelectionService.next(taggedLayers)
// return taggedLayers
// }
// ))
}
public getTaggedStores(stores: string[]): Observable<TaggedLayer[]> {
return this.apollo.query({
query: getTaggedStoresQuery,
variables: {
stores: stores,
}
}).pipe(map(
res => this._getTaggedLayers(res['data']['taggedStores'])
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: getTaggedStoresQuery,
// variables: {
// stores: stores,
// }
// }).pipe(map(
// res => this._getTaggedLayers(res['data']['taggedStores'])
// ))
}
public getTagsActionsStores(stores: string[]): Observable<TaggedLayer[]> {
return this.apollo.query({
query: getTaggedStoresQuery,
variables: {
stores: stores,
}
}).pipe(map(
res => this._getTaggedLayers(res['data']['taggedStores'])
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.query({
// query: getTaggedStoresQuery,
// variables: {
// stores: stores,
// }
// }).pipe(map(
// res => this._getTaggedLayers(res['data']['taggedStores'])
// ))
}
// 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 { map } from 'rxjs/operators'
import { Apollo, gql } from 'apollo-angular'
// import { Apollo, gql } from 'apollo-angular'
const tagsPluginQuery = gql`
query tagsPlugins {
tagsPlugins {
stores {
store
tagActions {
domain
key
actions {
name
plugin
link
roles
action
}
}
}
}
}
`
// const tagsPluginQuery = gql`
// query tagsPlugins {
// tagsPlugins {
// stores {
// store
// tagActions {
// domain
// key
// actions {
// name
// plugin
// link
// roles
// action
// }
// }
// }
// }
// }
// `
const tagsPluginSubmitMutation = gql`
mutation submitTagsPlugin(
$stores: [String],
$ids: [[String]],
$values: [String]!,
$keys: [String]!,
) {
submitTagsPlugin(
stores: $stores,
ids: $ids,
values: $values,
keys: $keys
) {
tags {
key
value
}
}
}
`
const doTagActionMutation=gql`
mutation doTagAction (
$store: String!,
$id: String!,
$plugin: String!,
$action: String!,
$value: String!,
) {
doTagAction(
store: $store,
id: $id,
plugin: $plugin,
action: $action,
value: $value,
) {
result
}
}
`
// const tagsPluginSubmitMutation = gql`
// mutation submitTagsPlugin(
// $stores: [String],
// $ids: [[String]],
// $values: [String]!,
// $keys: [String]!,
// ) {
// submitTagsPlugin(
// stores: $stores,
// ids: $ids,
// values: $values,
// keys: $keys
// ) {
// tags {
// key
// value
// }
// }
// }
// `
// const doTagActionMutation=gql`
// mutation doTagAction (
// $store: String!,
// $id: String!,
// $plugin: String!,
// $action: String!,
// $value: String!,
// ) {
// doTagAction(
// store: $store,
// id: $id,
// plugin: $plugin,
// action: $action,
// value: $value,
// ) {
// result
// }
// }
// `
export class Tag {
constructor(
@ -118,7 +118,7 @@ export class TagsPluginsService {
protected _stores: Stores
constructor(
private apollo: Apollo
// private apollo: Apollo
) {
// FIXME: the stores are available only after the instantiation of the TagsPluginsService
/*
@ -131,58 +131,62 @@ export class TagsPluginsService {
}
getTagsPlugins(): Observable<Stores> {
if (this._stores === undefined) {
return this.apollo.query({
query: tagsPluginQuery,
}).pipe(map(
res => {
const stores = new Stores(
res['data']['tagsPlugins']['stores'].map(
(store: Object) => new Store(
store['store'],
store['tagActions'].map(
(tagKey: Object) => new TagActions(
tagKey['domain'],
tagKey['key'],
tagKey['actions'].map(
(tagAction: Object) => new TagAction(
tagAction['name'],
tagAction['plugin'],
tagAction['action'],
tagAction['roles'],
tagAction['link'],
)
)
)
)
)
)
)
this._stores = stores
return stores
}
))
}
else {
return observableOf(this._stores)
}
console.warn('Migrate Graphql')
return observableOf()
// if (this._stores === undefined) {
// return this.apollo.query({
// query: tagsPluginQuery,
// }).pipe(map(
// res => {
// const stores = new Stores(
// res['data']['tagsPlugins']['stores'].map(
// (store: Object) => new Store(
// store['store'],
// store['tagActions'].map(
// (tagKey: Object) => new TagActions(
// tagKey['domain'],
// tagKey['key'],
// tagKey['actions'].map(
// (tagAction: Object) => new TagAction(
// tagAction['name'],
// tagAction['plugin'],
// tagAction['action'],
// tagAction['roles'],
// tagAction['link'],
// )
// )
// )
// )
// )
// )
// )
// this._stores = stores
// return stores
// }
// ))
// }
// else {
// return observableOf(this._stores)
// }
}
submit(features, keys: string[], values: string[]): Observable<Tag[]> {
let variables = {
stores: Object.keys(features),
ids: Object.values(features).map(ids => Array.from(<Number[][]>ids)),
keys: keys,
values: values,
}
return this.apollo.mutate({
mutation: tagsPluginSubmitMutation,
variables: variables,
}).pipe(map(
res => res['data']['submitTagsPlugin']['tags'].map(
(tag: Object) => new Tag(tag['key'], tag['value'])
)
))
console.warn('Migrate Graphql')
return observableOf()
// let variables = {
// stores: Object.keys(features),
// ids: Object.values(features).map(ids => Array.from(<Number[][]>ids)),
// keys: keys,
// values: values,
// }
// return this.apollo.mutate({
// mutation: tagsPluginSubmitMutation,
// variables: variables,
// }).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> {
@ -193,11 +197,13 @@ export class TagsPluginsService {
"action": action.action,
"value": value,
}
return this.apollo.mutate({
mutation: doTagActionMutation,
variables: variables
}).pipe(map(
res => res['data']['doTagAction']['result']
))
console.warn('Migrate Graphql')
return observableOf()
// return this.apollo.mutate({
// mutation: doTagActionMutation,
// 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 { 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 * as bbox from '@turf/bbox'
@ -19,7 +20,7 @@ import { ConfigService } from '../../config.service'
import { MapControlService } from '../map-control.service'
import { LayerNode } from '../models'
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 {
constructor(
@ -283,7 +284,7 @@ export class GisafMapboxComponent implements OnInit, OnDestroy {
this.mapControlService.mapReady$.subscribe(
_ => {
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 { LayerNode } from './models'
import { Store } from './map-data.service'
import { TaggedLayer, Feature, FeatureWithField } from '../info/info-data.service'
import { BaseMapWithStores } from '../openapi'
@ -21,9 +20,9 @@ export class MapControlService {
private _hasControls = new BehaviorSubject<boolean>(true)
private _toggleInfo = new BehaviorSubject<boolean>(false)
private _layerAdd = new Subject<LayerNode>()
private _baseMapLayerAdd = new Subject<Store>()
private _baseMapLayerAdd = new Subject<string>()
private _layerRemove = new Subject<LayerNode>()
private _baseMapLayerRemove = new Subject<Store>()
private _baseMapLayerRemove = new Subject<string>()
private _filter = new BehaviorSubject<[string, TaggedLayer[], string]>(['', [], ''])
private _zoomToFeatures = new Subject<boolean>()
private _resize = new Subject<boolean>()
@ -35,7 +34,7 @@ export class MapControlService {
public selection = new BehaviorSubject<Object>({})
public tempSelection = new BehaviorSubject<Object>({})
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 hasLabels = new BehaviorSubject<boolean>(false)
public hasTags = new BehaviorSubject<boolean>(false)
@ -122,17 +121,17 @@ export class MapControlService {
addBaseMapLayers(baseMapLayers: string[]) {
for (let item of baseMapLayers) {
this._baseMapLayerAdd.next(new Store(item))
this._baseMapLayerAdd.next(item)
}
}
removeBaseMapLayers(baseMapLayers: string[]) {
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()
values.add(layerId)
this.baseMapLayers.next(values)

View file

@ -6,7 +6,7 @@ import { StyleSpecification } from 'maplibre-gl'
// import { TreeData, PrimaryGroupNode, LayerNode } from './models'
import { MapControlService } from './map-control.service'
import { MapService, MapInitData, BaseMapWithStores } from '../openapi'
import { MapService, MapInitData, BaseMapWithStores, BaseStyle as OApiBaseStyle } from '../openapi'
export class BaseStyle {
constructor(
@ -15,11 +15,11 @@ export class BaseStyle {
) {}
}
export class Store {
constructor(
public name: string,
) {}
}
// export class Store {
// constructor(
// public name: string,
// ) {}
// }
@Injectable()
export class MapDataService {
@ -148,7 +148,9 @@ export class MapDataService {
getBaseStyle(styleName: string): Observable<BaseStyle> {
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({
// query: baseStyleQuery,
// variables: {

View file

@ -31,11 +31,6 @@ export class MapComponent implements OnInit {
) {}
ngOnInit() {
this.activatedRoute.data.subscribe(
(config) => {
console.log(config)
}
)
this.mapControlService.hasControls$.subscribe(
flag => {
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 { Node, PrimaryGroupNode, LayerNode, TreeData } from '../models'
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 { CategoryGroup } from '../../openapi'
@ -73,13 +73,13 @@ export class TreeLayerComponent implements OnInit {
if ('stores' in params) {
let stores = params['stores'].split(',')
for (let store in stores) {
this.mapControlService.addBaseMapLayerById(new Store(store))
this.mapControlService.addBaseMapLayerById(store)
}
}
})
this.mapControlService.layerAddById$.subscribe(
(store: Store) => {
(store: string) => {
let layerNode = this._getNodeByStore(store)
if (!layerNode) {
console.log('No such layer, cannot add it', store)
@ -98,7 +98,7 @@ export class TreeLayerComponent implements OnInit {
)
this.mapControlService.layerRemoveById$.subscribe(
(store: Store) => {
(store: string) => {
let layerNode = this._getNodeByStore(store)
if (!layerNode) {
console.log('No such layer, cannot remove it', store)
@ -117,7 +117,7 @@ export class TreeLayerComponent implements OnInit {
if (!feature) {
return
}
let layerNode: LayerNode = this._getNodeByStore(new Store(feature.store))
let layerNode: LayerNode = this._getNodeByStore(feature.store)
if (!layerNode) {
this.snackBar.open('Unknown layer ' + feature.store, 'OK', {
duration: 3000
@ -190,11 +190,11 @@ export class TreeLayerComponent implements OnInit {
this.cdr.markForCheck()
}
protected _getNodeByStore(store: Store): LayerNode {
protected _getNodeByStore(store: string): LayerNode {
// Get the LayerNode with the store
// Assumes that the tree's depth is 2
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))
}

View file

@ -1,12 +1,12 @@
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 { map, mergeMap, take, first } from 'rxjs/operators'
import { DataService, MeasuresItem } from '../../_services/data.service'
@Injectable()
export class MeasuresListResolver implements Resolve<object> {
export class MeasuresListResolver {
constructor(
protected dataService: DataService,
private router: Router

View file

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