Add first version of the frontend
As of now the only usable functionality is signin in/out and managing
authorized users, and even then there is much room for improvement.
Change-Id: Ib87fc6866f69113a230187710de8644b78391917
diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js
new file mode 100644
index 0000000..9dbf288
--- /dev/null
+++ b/frontend/src/store/index.js
@@ -0,0 +1,35 @@
+import {createStore} from 'vuex';
+
+import {KillSwitchServicePromiseClient} from '../api_proto/kill_switch_grpc_web_pb.js';
+
+export const store = createStore({
+ state() {
+ return {
+ jwtToken: localStorage.getItem('jwtToken'),
+ client: null,
+ };
+ },
+ mutations: {
+ setJwtToken(state, token) {
+ if (token == null)
+ localStorage.removeItem('jwtToken');
+ else
+ localStorage.jwtToken = token;
+
+ state.jwtToken = token;
+ },
+ },
+ getters: {
+ getJwtToken(state) {
+ return state.jwtToken;
+ },
+ isSignedIn(state) {
+ return state.jwtToken != null;
+ },
+ },
+ actions: {
+ connectClient(store, host) {
+ store.state.client = new KillSwitchServicePromiseClient(host, null, null);
+ },
+ },
+});