Skip to content

Commit

Permalink
🔖 0.2.1-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
silencesys committed Feb 19, 2021
1 parent 7c65215 commit b59700f
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spring",
"version": "0.2.0-beta",
"version": "0.2.1-beta",
"private": true,
"author": {
"name": "Martin Roček",
Expand Down
24 changes: 23 additions & 1 deletion src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,15 @@ body {
list-style: none;
overflow: auto !important;
max-height: 70vh;
columns: 2;
text-align-last: left;
display: flex;
flex-wrap: wrap;
flex-direction: row;
justify-content: flex-start;
align-items: stretch;
}
.modal-body__option-list li {
flex-basis: 50%;
}
.modal-body__option-list button {
background: none;
Expand Down Expand Up @@ -473,6 +481,8 @@ body {
.graph__tabs {
margin-top: 2rem;
margin-bottom: 1.6rem;
display: flex;
justify-content: space-between;
}
.graph__tabs a {
background: none;
Expand All @@ -490,6 +500,18 @@ body {
.graph__tabs a.router-link-exact-active {
color: var(--blue-500);
}
.chart-filter-warning {
font-size: .9rem;
color: var(--blue-300);
cursor: pointer;
transition: all .4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chart-filter-warning:hover {
color: var(--blue-500);
}
.chart-filter-warning svg {
margin-right: .5rem;
}

.chart-range-sliders {
padding-top: .25rem;
Expand Down
6 changes: 6 additions & 0 deletions src/assets/settings.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ body {

--green-200: #69BAA8;

--yellow-200: #DEA422;

--shadow-sm: 0 3px 6px rgba(0, 42, 110, 6%);

--modal-bg: rgba(24, 29, 51, 50%);
Expand All @@ -36,6 +38,8 @@ body {

--green-200: #7EE095;

--yellow-200: #DBC476;

--shadow-sm: 0 3px 6px rgba(12, 14, 26, 10%);
}
}
Expand All @@ -56,6 +60,8 @@ body.theme-dark {

--green-200: #7EE095;

--yellow-200: #DBC476;

--shadow-sm: 0 3px 6px rgba(12, 14, 26, 10%);
}

Expand Down
4 changes: 4 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ ipcMain.handle('open-xslx-file', async (event, path) => {
const data = await openFile(event, path)

const jsonFile = new Store(`${data.fileName}.json`)
// Save file content.
jsonFile.set({ key: 'columns', value: data.columns })
jsonFile.set({ key: 'content', value: data.content })
jsonFile.set({ key: 'fileName', value: data.fileName })
// Reset copy data when file was re-opened.
jsonFile.set({ key: 'copy', value: { content: [], columns: [] } })
// Set last opened file, so we can start with already opened file.
store.set({ key: 'lastOpenedFile', value: `${data.fileName}.json` })
})

Expand Down
5 changes: 4 additions & 1 deletion src/components/AxisChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ export default {
*/
loadAfterFile () {
// Prepare rows for chart rendering
this.chart.rows = this.prepareRowsForChart(this.file)
this.chart.rows = this.prepareRowsForChart(this.chartData, this.file.arrayableColumns)
// Set default choices for every select
this.setChartFilterCategory(this.file.columns[0])
this.setChartFilterValue('Četnost')
this.setChartFilterSubCategory(this.subCategories[0])
this.emitDocumentFiltersSharingStatus()
},
updateChartRange () {
clearTimeout(this.rangeUpdateTimer)
Expand Down Expand Up @@ -302,6 +304,7 @@ export default {
options.quality = 1
chart.exporting.setFormatOptions('png', options)
chart.exporting.backgroundColor = am4core.color("#f00", 0)
chart.exporting.filePrefix = 'spring'
// Define methods that can be used to draw the chart based on the data type.
const chartConstructor = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ fileName || 'žádný soubor nebyl vybrán' }}
</h3>
<div>
<button class="button__round" style="margin-right: 1rem;" @click.prevent="exportChart"><!--
<button v-if="$route.meta.exportable" class="button__round" style="margin-right: 1rem;" @click.prevent="exportChart"><!--
--><font-awesome-icon :icon="['far', 'file-export']" /><!--
--></button>
<button class="button__round" @click.prevent="openXslxFile"><!--
Expand Down
7 changes: 5 additions & 2 deletions src/components/PieChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ export default {
computed: {
subCategories () {
return Object.keys(this.chart.subCategories)
},
}
},
methods: {
loadAfterFile () {
this.chart.rows = this.prepareRowsForChart(this.file)
this.chart.rows = this.prepareRowsForChart(this.chartData, this.file.arrayableColumns)
// Set default choices for every select
this.setChartFilterCategory(this.file.columns[0])
this.setChartFilterValue(this.file.columns[1])
this.setChartFilterSubCategory(this.subCategories[0])
this.emitDocumentFiltersSharingStatus()
},
setChartFilterCategory (value) {
this.chart.filters.category = value
Expand Down Expand Up @@ -165,6 +167,7 @@ export default {
options.quality = 1
chart.exporting.setFormatOptions('png', options)
chart.exporting.backgroundColor = am4core.color("#f00", 0)
chart.exporting.filePrefix = 'spring'
this.chart.instance = chart
}
Expand Down
1 change: 0 additions & 1 deletion src/components/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default {
if (this.scopedValue) {
if (this.isObject(this.columns[0])) {
const index = this.columns.findIndex(item => item.key === this.scopedValue)
console.log(index)
if (index > -1) {
this.selected = this.columns[index].value
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { library } from '@fortawesome/fontawesome-svg-core'
import {
faFile, faSearch, faColumns, faChartPie, faCog, faFolderOpen, faCaretDown,
faTimesCircle, faPlusCircle, faSquare, faCheckSquare, faFilter, faCompressAlt,
faExpandAlt, faFileExport
faExpandAlt, faFileExport, faBrowser, faExclamationTriangle
} from '@fortawesome/pro-regular-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { Quasar, QVirtualScroll } from 'quasar'
Expand All @@ -18,7 +18,7 @@ import './assets/responsive.css'
library.add(
faFile, faSearch, faColumns, faChartPie, faCog, faFolderOpen, faCaretDown,
faTimesCircle, faPlusCircle, faSquare, faCheckSquare, faFilter, faCompressAlt,
faExpandAlt, faFileExport
faExpandAlt, faFileExport, faBrowser, faExclamationTriangle
)

const app = createApp(App)
Expand Down
27 changes: 26 additions & 1 deletion src/mixins/chartOperations.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import applicationSettings from '@/mixins/applicationSettings'

export default {
emits: ['data-are-filtered'],
mixins: [applicationSettings],
computed: {
shareFilterSettings () {
return this.appStore.get('sharedDocumentFilters') || false
},
chartData () {
if (this.shareFilterSettings && this.copy.content.length > 0) {
return {
content: this.copy.content,
// Charts should always have all columns available
columns: this.file.columns
}
}

return this.file
},
},
methods: {
prepareRowsForChart ({ content, arrayableColumns }) {
emitDocumentFiltersSharingStatus () {
this.$emit('data-are-filtered', {
active: this.shareFilterSettings, filters: this.file.filters
})
},
prepareRowsForChart ({ content }, arrayableColumns) {
const rows = []

content.forEach((row) => {
Expand Down
7 changes: 7 additions & 0 deletions src/mixins/fileOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export default {
setDataTypes: [],
arrayableColumns: []
},
copy: {
content: [],
columns: []
},
store: {}
}
},
Expand All @@ -36,6 +40,9 @@ export default {
this.file.content = store.content
this.file.setDataTypes = store.setDataTypes || []
this.file.arrayableColumns = store.arrayableColumns || []
this.file.filters = store.filters || []
this.copy = store.copy

if (this.loadAfterFile && typeof this.loadAfterFile === 'function') {
this.loadAfterFile()
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ const routes = [
path: '',
name: 'PieChart',
component: () => import(/* webpackChunkName: "graph-pie" */ '../components/PieChart.vue'),
meta: {
exportable: true
}
},
{
path: '/axis',
name: 'AxisChart',
component: () => import(/* webpackChunkName: "graph-axis" */ '../components/AxisChart.vue'),
meta: {
exportable: true
}
}
]
},
Expand Down
56 changes: 53 additions & 3 deletions src/views/Graphs.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,70 @@
<template>
<div id="app-graphs">
<div class="graph__tabs">
<router-link :to="{ name: 'PieChart' }">Koláčový</router-link>
<router-link :to="{ name: 'AxisChart' }">Sloupcový</router-link>
<div>
<router-link :to="{ name: 'PieChart' }">Koláčový</router-link>
<router-link :to="{ name: 'AxisChart' }">Sloupcový</router-link>
</div>
<div>
<span v-if="documentFilters.active" class="chart-filter-warning" @click.stop="toggleModal">
<font-awesome-icon :icon="['far', 'exclamation-triangle']" />
filtry z dokumentu jsou aktivní
</span>
</div>
</div>
<router-view :current-file="currentFile"></router-view>
<router-view :current-file="currentFile" @data-are-filtered="documentFilterActive"></router-view>
<Modal v-if="modalVisible">
<div class="modal-body w-400">
<h3>Aktivní filtry</h3>
<ul class="modal-body__option-list">
<li v-for="filter in Object.keys(documentFilters.filters)" :key="filter">
{{ filter }}: {{ documentFilters.filters[filter].values.join(', ') }}
</li>
</ul>
<button class="button__primary" @click.prevent="toggleModal">Zavřít</button>
</div>
</Modal>
</div>
</template>

<script>
import Modal from '@/components/Modal'
export default {
name: 'chart-page',
components: {
Modal
},
props: {
currentFile: {
type: String,
default: null
},
},
data () {
return {
documentFilters: {
active: false,
filters: {}
},
modalVisible: false
}
},
methods: {
documentFilterActive ({ active, filters }) {
console.log(Object.keys(filters).length)
if (Object.keys(filters).length > 0) {
this.documentFilters.active = active
this.documentFilters.filters = filters
}
},
toggleModal () {
this.modalVisible = !this.modalVisible
}
}
}
</script>
Loading

0 comments on commit b59700f

Please sign in to comment.