From e06e292be71ca699d90bafbd635118aa47c2d7a5 Mon Sep 17 00:00:00 2001
From: =Corey Hulen <corey@hulen.com>
Date: Thu, 10 Sep 2015 18:32:22 -0700
Subject: PLT-12 adding log viewer

---
 web/react/stores/admin_store.jsx | 67 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 web/react/stores/admin_store.jsx

(limited to 'web/react/stores/admin_store.jsx')

diff --git a/web/react/stores/admin_store.jsx b/web/react/stores/admin_store.jsx
new file mode 100644
index 000000000..ac474cd4b
--- /dev/null
+++ b/web/react/stores/admin_store.jsx
@@ -0,0 +1,67 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
+var EventEmitter = require('events').EventEmitter;
+
+var BrowserStore = require('../stores/browser_store.jsx');
+
+var Constants = require('../utils/constants.jsx');
+var ActionTypes = Constants.ActionTypes;
+
+var LOG_CHANGE_EVENT = 'log_change';
+
+class AdminStoreClass extends EventEmitter {
+    constructor() {
+        super();
+
+        this.logs = null;
+
+        this.emitLogChange = this.emitLogChange.bind(this);
+        this.addLogChangeListener = this.addLogChangeListener.bind(this);
+        this.removeLogChangeListener = this.removeLogChangeListener.bind(this);
+    }
+
+    emitLogChange() {
+        this.emit(LOG_CHANGE_EVENT);
+    }
+
+    addLogChangeListener(callback) {
+        this.on(LOG_CHANGE_EVENT, callback);
+    }
+
+    removeLogChangeListener(callback) {
+        this.removeListener(LOG_CHANGE_EVENT, callback);
+    }
+
+    getLogs() {
+        //return BrowserStore.getItem('logs');
+        return this.logs;
+    }
+
+    saveLogs(logs) {
+        // if (logs === null) {
+        //     BrowserStore.removeItem('logs');
+        // } else {
+        //     BrowserStore.setItem('logs', logs);
+        // }
+
+        this.logs = logs;
+    }
+}
+
+var AdminStore = new AdminStoreClass();
+
+AdminStoreClass.dispatchToken = AppDispatcher.register((payload) => {
+    var action = payload.action;
+
+    switch (action.type) {
+    case ActionTypes.RECIEVED_LOGS:
+        AdminStore.saveLogs(action.logs);
+        AdminStore.emitLogChange();
+        break;
+    default:
+    }
+});
+
+export default AdminStore;
-- 
cgit v1.2.3-1-g7c22

