Skip to content

Commit

Permalink
poc code
Browse files Browse the repository at this point in the history
  • Loading branch information
solderq35 committed Sep 16, 2023
1 parent 3f7eec3 commit 9e025b0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VUE_APP_ROOT_API=http://localhost:3000
VUE_APP_ROOT_API=https://api.sustainability.oregonstate.edu/v2/energy
VUE_APP_HOST_ADDRESS=http://localhost:8080
50 changes: 50 additions & 0 deletions src/components/building_list/building_list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ export default {
r['All'] = [building]
}
if ( r[building.group] ) {
// console.log(r)
// console.log(building.group)
console.log( r[building.group] )
r[building.group].push( building )
r[building.group].sort( ( a, b ) => ( a.name > b.name ? 1 : -1 ) )
} else {
Expand All @@ -108,6 +111,31 @@ export default {
for ( let key of keys ) {
if ( key !== 'All' ) r2[key] = r[key]
}
console.log( r2 )
console.log( Object.keys( r2 ) )
if ( this.buildingList ) {
for ( let i = 0; i < Object.keys( r2 ).length; i++ ) {
if ( Object.keys( r2 )[i] === 'Events & Admin, Solar' ) {
console.log( 'gotcha' )
console.log( Object.keys( r2 )[i] )
console.log( Object.keys( r2 )[i].split( ', ' ) )
for ( let j = 0; j < Object.keys( r2 )[i].split( ', ' ).length; j++ ) {
console.log( Object.keys( r2 )[i].split( ', ' )[j] )
console.log( r2[Object.keys( r2 )[i].split( ', ' )[j]] )
console.log( Object.values( r2 )[i] )
// console.log(r2.Object.keys(r2)[i])
// console.log(r2['Events & Admin, Solar'])
r2[Object.keys( r2 )[i].split( ', ' )[j]].push( Object.values( r2 )[i][0] )
console.log( r2[Object.keys( r2 )[i]] )
console.log( r2[Object.keys( r2 )[i].split( ', ' )[j]] )
// delete r2[Object.keys(r2)[i]]
// r2[Object.keys(r2)[i].split(', ')[j]].push(Object.values(r2)[i])
}
delete r2[Object.keys( r2 )[i]]
console.log( Object.values( r2 )[i][0] )
}
}
}
return r2
} else {
return this.$store.getters['user/views']
Expand All @@ -126,6 +154,28 @@ export default {
},
search: function ( v ) {
let groups
/*
console.log(this.groups)
console.log(Object.keys(this.groups))
if (this.buildingList ) {
for (let i = 0; i < Object.keys(this.groups).length; i++) {
if (Object.keys(this.groups)[i] === 'Events & Admin, Solar') {
console.log('gotcha')
console.log(Object.keys(this.groups)[i])
console.log(Object.keys(this.groups)[i].split(', '))
for (let j = 0; j < Object.keys(this.groups)[i].split(', ').length; j++) {
console.log(Object.keys(this.groups)[i].split(', ')[j])
console.log(this.groups[Object.keys(this.groups)[i].split(', ')[j]])
console.log(Object.values(this.groups)[i])
this.groups[Object.keys(this.groups)[i].split(', ')[j]].push(Object.values(this.groups)[i][0])
console.log(this.groups[Object.keys(this.groups)[i].split(', ')[j]])
// this.groups[Object.keys(this.groups)[i].split(', ')[j]].push(Object.values(this.groups)[i])
}
console.log(Object.values(this.groups)[i][0])
}
}
}
*/
if ( this.buildingList ) {
groups = Object.values( this.groups ).reduce( ( a, c ) => {
for ( let d of c ) a.push( d )
Expand Down
24 changes: 22 additions & 2 deletions src/components/map/map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ export default {
}
},
handleSelect: function ( string ) {
console.log( this.$store.getters['map/buildings'] )
console.log( this.selected )
if ( this.selected.indexOf( string ) >= 0 ) {
this.selected.splice( this.selected.indexOf( string ), 1 )
} else {
Expand Down Expand Up @@ -556,8 +558,26 @@ export default {
for ( var layerKey of Object.keys( this.map._layers ) ) {
let layer = this.map._layers[layerKey]
if ( layer.feature ) {
if ( !val.includes( layer.feature.properties.group ) && this.grouping === 'Category' ) {
this.map.removeLayer( layer )
console.log( layer.feature.properties.group )
console.log( layer.feature.properties.group.split( ', ' ) )
if ( layer.feature.properties.group.split( ', ' ).length > 1 ) {
let categoryCoverage = 0
for ( let i = 0; i < layer.feature.properties.group.split( ', ' ).length; i++ ) {
console.log( layer.feature.properties.group.split( ', ' )[i] )
if ( !val.includes( layer.feature.properties.group.split( ', ' )[i] ) && this.grouping === 'Category' ) {
console.log( layer.feature.properties.group.split( ', ' )[i] )
categoryCoverage++
}
}
console.log( categoryCoverage )
if ( categoryCoverage >= layer.feature.properties.group.split( ', ' ).length ) {
this.map.removeLayer( layer )
}
console.log( 'here' )
} else {
if ( !val.includes( layer.feature.properties.group ) && this.grouping === 'Category' ) {
this.map.removeLayer( layer )
}
}
}
}
Expand Down

0 comments on commit 9e025b0

Please sign in to comment.