Skip to content

Commit

Permalink
fix: fixed vite builds!
Browse files Browse the repository at this point in the history
styles fixed by disabling vite server CSP
  • Loading branch information
ErikBjare committed May 3, 2024
1 parent b9978e3 commit a5a6ea0
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ endif
build: install static/logo.png static/logo.svg
npm run build ${androidflag}

vite-build:
npx vite build

vite-dev:
npx vite

static/logo.%: media/logo/logo.%
@mkdir -p static
cp $< $@
Expand Down
4 changes: 0 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<!-- Verify with https://csp-evaluator.withgoogle.com/ -->
<!-- TODO: fix CSP (should depend on prod/dev mode, as pre-vite )-->
<meta http-equiv="Content-Security-Policy" content="default-src 'self' *:5666 ws://*:27180 https://api.github.com/repos/ActivityWatch/activitywatch/releases/latest; img-src 'self' data:; font-src 'self' data:; style-src 'self' 'unsafe-inline'; object-src 'none'; script-src 'self' 'unsafe-eval'">
<!-- TODO: is this really the way? imports in main.js doesn't seem to work -->
<link rel="stylesheet" href="/node_modules/bootstrap/dist/css/bootstrap.css">
<link rel="stylesheet" href="/node_modules/bootstrap-vue/dist/bootstrap-vue.css">
<link rel="stylesheet" href="/src/style/style.scss">
</head>
<body>
<noscript>
Expand Down
2 changes: 1 addition & 1 deletion src/components/CategoryEditTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ export default {
<style scoped lang="scss">
.row.class:hover {
background-color: #eee;
boder-radius: 5px;
border-radius: 5px;
}
</style>
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Vue.component('datetime', Datetime);
// Load the Varela Round font
import 'typeface-varela-round';

// Load the main style
import './style/style.scss';

// Loads all the filters
Expand Down
17 changes: 9 additions & 8 deletions src/visualizations/CategoryTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ div(style="font-size: 0.9em")
import 'vue-awesome/icons/circle';
import 'vue-awesome/icons/regular/plus-square';
import 'vue-awesome/icons/regular/minus-square';
const _ = require('lodash');
const classes = require('~/util/classes.ts');
import _ from 'lodash';
import { build_category_hierarchy, flatten_category_hierarchy } from '../util/classes.ts';
import { IEvent } from '../util/interfaces.ts';
function _get_child_cats(cat, all_cats) {
return _.filter(all_cats, c => _.isEqual(c.parent, cat.name));
Expand Down Expand Up @@ -75,16 +76,16 @@ export default {
},
category_hierarchy: function () {
if (!this.events) return [];
const events = JSON.parse(JSON.stringify(this.events));
const events: IEvent[] = JSON.parse(JSON.stringify(this.events)) as IEvent[];
const hier = classes.build_category_hierarchy(
const hier = build_category_hierarchy(
_.map(events, e => {
return { name: e.data['$category'] };
return { name: e.data['$category'], rule: { type: 'none' } };
})
);
let cats = classes.flatten_category_hierarchy(hier).map(c => {
c.duration = _.sumBy(
let cats = flatten_category_hierarchy(hier).map(c => {
c['duration'] = _.sumBy(
events.filter(e => {
const pcat = e.data['$category'].slice(0, c.name.length);
return _.isEqual(c.name, pcat);
Expand All @@ -96,7 +97,7 @@ export default {
const cats_with_depth0 = _.sortBy(
_.filter(cats, c => c.depth == 0),
c => -c.duration
c => -c['duration']
);
_.map(cats_with_depth0, c => _assign_children(c, cats));
Expand Down
10 changes: 4 additions & 6 deletions src/visualizations/periodusage.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use strict';
import * as d3 from 'd3';
import _ from 'lodash';
import moment from 'moment';

const d3 = require('d3');
const _ = require('lodash');
const moment = require('moment');

import { seconds_to_duration, get_hour_offset } from '../util/time';
import { seconds_to_duration, get_hour_offset } from '../util/time.ts';

function create(svg_elem) {
// Clear element
Expand Down
7 changes: 4 additions & 3 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ export default defineConfig(({ mode }) => {
return {
server: {
port: 27180,
headers: {
'Content-Security-Policy': PRODUCTION ? "default-src 'self'" : "default-src 'self' *:5666",
},
// This breaks a bunch of style-related stuff (at least):
//headers: {
// 'Content-Security-Policy': PRODUCTION ? "default-src 'self'" : "default-src 'self' *:5666",
//},
},
plugins: [vue()],
publicDir: './static',
Expand Down

0 comments on commit a5a6ea0

Please sign in to comment.