Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add context menu and sketch creation to homepage #3237

Merged
merged 11 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"axios": "^1.7.7"
}
}
12,473 changes: 12,473 additions & 0 deletions timesketch/frontend-ng/yarn.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions timesketch/frontend-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"lint": "eslint . --fix --ignore-path .gitignore"
},
"dependencies": {
"axios": "^1.7.7",
"@mdi/font": "7.4.47",
"core-js": "^3.37.1",
"dayjs": "^1.11.13",
"roboto-fontface": "*",
"vue": "^3.4.31",
"vuetify": "^3.6.11"
"vuetify": "^3.6.11",
"axios": "^1.7.7"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.5",
Expand Down
22 changes: 22 additions & 0 deletions timesketch/frontend-v3/src/filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2024 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.
*/

export const initialLetter = (input) => {
if (!input) return '';
input = input.toString();
return input.charAt(0).toUpperCase();
};

51 changes: 48 additions & 3 deletions timesketch/frontend-v3/src/layouts/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,62 @@ limitations under the License.
>
</v-img>
</template>
<template v-slot:append> Right hand side </template>
<template v-slot:append>
<v-avatar color="grey lighten-1" size="25" class="ml-3">
<span class="white--text">{{ $filters.initialLetter(currentUser) }}</span>
</v-avatar>
<v-menu offset-y>
<template v-slot:activator="{ props }">
<v-btn small icon v-bind="props">
<v-icon title="Timesketch Options">mdi-dots-vertical</v-icon>
</v-btn>
</template>
<v-list>
<v-list-item
prepend-icon="mdi-brightness-6"
v-on:click="toggleTheme"
>
<v-list-item-title>Toggle theme</v-list-item-title>
</v-list-item>
<v-list-item
href="/legacy/"
prepend-icon="mdi-view-dashboard-outline"
>
<v-list-item-title>Use the old UI</v-list-item-title>
berggren marked this conversation as resolved.
Show resolved Hide resolved
</v-list-item>
<v-list-item
href="/logout/"
prepend-icon="mdi-logout"
>
<v-list-item-title>Logout</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</template>
</v-toolbar>
<v-divider></v-divider>
</template>

<script>
import ApiClient from '../utils/RestApiClient.js'
export default {
data() {
return {};
return {
currentUser: '',
};
},
computed: {},
methods: {},
methods: {
toggleTheme: function () {
this.$vuetify.theme.dark = !this.$vuetify.theme.dark
localStorage.setItem('isDarkTheme', this.$vuetify.theme.dark.toString())
},
},
created: function () {
ApiClient.getLoggedInUser().then((response) => {
let currentUser = response.data.objects[0].username;
this.currentUser = currentUser;
});
},
};
</script>
4 changes: 1 addition & 3 deletions timesketch/frontend-v3/src/layouts/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ limitations under the License.
-->
<template>
<v-main>
<v-container fluid class="px-5">
<router-view />
</v-container>
<router-view />
</v-main>
</template>
6 changes: 6 additions & 0 deletions timesketch/frontend-v3/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { registerPlugins } from "@/plugins";
// Components
import App from "./App.vue";

import {initialLetter} from "./filters.js";

// Composables
import { createApp } from "vue";

Expand All @@ -18,3 +20,7 @@ const app = createApp(App);
registerPlugins(app);

app.mount("#app");

app.config.globalProperties.$filters = {
initialLetter
}
7 changes: 7 additions & 0 deletions timesketch/frontend-v3/src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Default from "@/layouts/Default";

// Import App views
import Home from "@/views/Home.vue";
import Overview from "@/views/Overview.vue";
Annoraaq marked this conversation as resolved.
Show resolved Hide resolved

// Routes
const routes = [
Expand All @@ -25,6 +26,12 @@ const routes = [
component: Home,
props: true,
},
{
path: "",
name: "overview",
component: Overview,
props: true,
},
],
},
];
Expand Down
70 changes: 67 additions & 3 deletions timesketch/frontend-v3/src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,56 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<template>
<v-container fluid>
<ts-sketch-list />
<v-container fluid class="pa-0">
<v-sheet class="pa-5" :color="$vuetify.theme.dark ? 'grey-darken-4' : 'grey-lighten-3'" min-height="200">
<h2>Start new investigation</h2>
<v-row no-gutters class="mt-5">
<v-dialog v-model="createSketchDialog" width="500">
<template v-slot:activator="{ props }">
<v-btn variant="flat" size="small" class="mr-5" color="primary" v-bind="props"> Blank sketch </v-btn>
</template>
<v-card class="pa-4">
<h3>New sketch</h3>
<br />
<v-form @submit.prevent="createSketch()">
<v-text-field
v-model="sketchForm.name"
variant="outlined"
density="compact"
placeholder="Name your sketch"
autofocus
clearable
:rules="sketchNameRules"
>
</v-text-field>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="createSketchDialog = false"> Cancel </v-btn>
<v-btn
:disabled="!sketchForm.name || sketchForm.name.length > 255"
@click="createSketch()"
color="primary"
text
>
Create
</v-btn>
</v-card-actions>
</v-form>
</v-card>
</v-dialog>
</v-row>
</v-sheet>
<div class="pa-5">
<h2>Your recent work</h2>
<ts-sketch-list></ts-sketch-list>
</div>
{{ testAppStore }}
</v-container>
</template>

<script>
import TsSketchList from "@/components/SketchList.vue";
import ApiClient from '../utils/RestApiClient.js'
import { useAppStore } from "@/stores/app";

export default {
Expand All @@ -30,14 +72,36 @@ export default {
},
data() {
return {
sketchForm: {
name: '',
},
appStore: useAppStore(),
createSketchDialog: false,
sketchNameRules: [
(v) => !!v || 'Sketch name is required.',
(v) => (v && v.length <= 255) || 'Sketch name is too long.',
],
};
},
computed: {
testAppStore() {
return this.appStore.testAppStore;
},
},
methods: {},
methods: {
clearFormData: function () {
this.sketchForm.name = ''
},
createSketch: function () {
ApiClient.createSketch(this.sketchForm)
.then((response) => {
let newSketchId = response.data.objects[0].id
this.clearFormData()
this.$router.push({ name: 'overview', params: { sketchId: newSketchId } })
})
.catch((e) => {})
},

},
};
</script>
24 changes: 24 additions & 0 deletions timesketch/frontend-v3/src/views/Overview.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!--
Copyright 2024 Google LLC

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

https://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.
-->
<template>
Overview
</template>

<script>

export default {
};
</script>