Skip to content

Commit

Permalink
V3 event bus (#3259)
Browse files Browse the repository at this point in the history
* Remove duplicate import

* Add v3 ui to tsdev.sh

* Add event bus

* Update timesketch/frontend-v3/src/event-bus.js

* update deps

---------

Co-authored-by: Johan Berggren <jberggren@gmail.com>
  • Loading branch information
Annoraaq and berggren authored Jan 27, 2025
1 parent d1690f5 commit 79c693f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
3 changes: 2 additions & 1 deletion timesketch/frontend-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"roboto-fontface": "*",
"vue": "^3.4.31",
"vuetify": "^3.6.11",
"axios": "^1.7.7"
"axios": "^1.7.7",
"tiny-emitter": "^2.1.0"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
Expand Down
23 changes: 23 additions & 0 deletions timesketch/frontend-v3/src/event-bus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2025 Google Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import emitter from 'tiny-emitter/instance'

export default {
$on: (...args) => emitter.on(...args),
$once: (...args) => emitter.once(...args),
$off: (...args) => emitter.off(...args),
$emit: (...args) => emitter.emit(...args)
}
5 changes: 3 additions & 2 deletions timesketch/frontend-v3/src/views/Sketch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ limitations under the License.
<script>
import ApiClient from '../utils/RestApiClient.js'
import dayjs from '@/plugins/dayjs'
import EventBus from '../event-bus.js'
import { useAppStore } from "@/stores/app";

export default {
Expand Down Expand Up @@ -80,10 +81,10 @@ export default {
this.updateDocumentTitle();
this.loadingSketch = false
})
// EventBus.$on('showContextWindow', this.showContextWindow)
EventBus.$on('showContextWindow', this.showContextWindow)
},
beforeDestroy() {
// EventBus.$off('showContextWindow')
EventBus.$off('showContextWindow')
},
computed: {
sketch() {
Expand Down
5 changes: 5 additions & 0 deletions timesketch/frontend-v3/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2588,6 +2588,11 @@ text-table@^0.2.0:
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==

tiny-emitter@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423"
integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==

to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
Expand Down

0 comments on commit 79c693f

Please sign in to comment.