You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spot.apache.org by ev...@apache.org on 2017/01/25 18:36:50 UTC

[38/49] incubator-spot git commit: flow/js/stores/IngestSummaryStore.js is not needed anymore

flow/js/stores/IngestSummaryStore.js is not needed anymore


Project: http://git-wip-us.apache.org/repos/asf/incubator-spot/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-spot/commit/5ecde790
Tree: http://git-wip-us.apache.org/repos/asf/incubator-spot/tree/5ecde790
Diff: http://git-wip-us.apache.org/repos/asf/incubator-spot/diff/5ecde790

Branch: refs/heads/master
Commit: 5ecde79070bec2954d91390b2ca5b99d27016aa0
Parents: 4647064
Author: Diego Ortiz Huerta <di...@intel.com>
Authored: Mon Dec 12 10:20:15 2016 -0800
Committer: Everardo Lopez Sandoval (Intel) <el...@elopezsa-mac02.ra.intel.com>
Committed: Fri Jan 20 17:01:02 2017 -0800

----------------------------------------------------------------------
 spot-oa/ui/flow/js/stores/IngestSummaryStore.js | 161 -------------------
 1 file changed, 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spot/blob/5ecde790/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
----------------------------------------------------------------------
diff --git a/spot-oa/ui/flow/js/stores/IngestSummaryStore.js b/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
deleted file mode 100755
index 55f2106..0000000
--- a/spot-oa/ui/flow/js/stores/IngestSummaryStore.js
+++ /dev/null
@@ -1,161 +0,0 @@
-const assign = require('object-assign');
-const d3 = require('d3');
-
-const SpotDispatcher = require('../../../js/dispatchers/SpotDispatcher');
-const SpotConstants = require('../../../js/constants/SpotConstants');
-const NetflowConstants = require('../constants/NetflowConstants');
-const DateUtils = require('../../../js/utils/DateUtils');
-const RestStore = require('../../../js/stores/RestStore');
-
-const START_DATE_FILTER = SpotConstants.START_DATE;
-const END_DATE_FILTER = SpotConstants.END_DATE;
-const CURRENT_DATE_FILTER = 'current_date';
-
-const requestQueue = [];
-const requestErrors = [];
-
-const IngestSummaryStore = assign(new RestStore(NetflowConstants.API_INGEST_SUMMARY), {
-    errorMessages: {
-        404: 'No details available'
-    },
-    setStartDate: function (date) {
-        this.setRestFilter(START_DATE_FILTER, date);
-    },
-    getStartDate: function () {
-        return this.getRestFilter(START_DATE_FILTER);
-    },
-    setEndDate: function (date) {
-        this.setRestFilter(END_DATE_FILTER, date);
-    },
-    getEndDate: function () {
-        return this.getRestFilter(END_DATE_FILTER);
-    },
-    /**
-     *  Start asking the server for CSV data to create the chart
-     **/
-    requestSummary: function () {
-        var startDate, endDate, date, delta, startRequests, i, month;
-
-        startDate = DateUtils.parseDate(this.getRestFilter(START_DATE_FILTER));
-        endDate = DateUtils.parseDate(this.getRestFilter(END_DATE_FILTER));
-
-        // Find out how many request need to be made
-        delta = (endDate.getFullYear() - startDate.getFullYear()) * 12 + (endDate.getMonth() - startDate.getMonth());
-
-        startRequests = requestQueue.length == 0;
-
-        // Go to first day in month
-        date = new Date(startDate);
-        date.setDate(1);
-
-        // Queue date requests
-        requestQueue.push(date);
-        for (i = 1; i <= delta; i++) {
-            requestQueue.push(DateUtils.calcDate(date, i, 'month'));
-        }
-
-        // dequeue is no request is running
-        startRequests && this.dequeue();
-    },
-    dequeue: function () {
-        var date, year, month;
-
-        if (requestQueue.length == 0) return;
-
-        date = requestQueue.shift();
-        this.setRestFilter(CURRENT_DATE_FILTER, date);
-        year = date.getFullYear();
-        month = date.getMonth() + 1 + "";
-        month = month.length == 1 ? "0" + month : month;
-
-        this.setEndpoint(NetflowConstants.API_INGEST_SUMMARY.replace('${year}', year).replace('${month}', month));
-
-        this.reload();
-    },
-    setData: function (data) {
-        var startDate, endDate, date, dayFilter, parse;
-
-        // Does the loading indicator needs to be displayed?
-        if (data.loading) {
-            if (!this._data.loading) {
-                this._data = data;
-                this.emitChangeData();
-            }
-
-            // Do nothing when loading is in progress
-            return;
-        }
-
-        // Store errors for later usage
-        if (data.error) {
-            requestErrors.push(data);
-        }
-        else if (data.data) {
-            parse = d3.time.format("%Y-%m-%d %H:%M").parse; // Date formatting parser
-            startDate = DateUtils.parseDate(this.getRestFilter(START_DATE_FILTER));
-            endDate = DateUtils.parseDate(this.getRestFilter(END_DATE_FILTER));
-            date = DateUtils.parseDate(this.getRestFilter(CURRENT_DATE_FILTER));
-
-            if (date.getFullYear() == startDate.getFullYear() && date.getMonth() == startDate.getMonth()) {
-                dayFilter = startDate.getDate();
-                data.data = data.data.filter(function (row) {
-                    return DateUtils.parseDate(row.date, true).getDate() >= dayFilter
-                });
-            }
-
-            if (date.getFullYear() == endDate.getFullYear() && date.getMonth() == endDate.getMonth()) {
-                dayFilter = endDate.getDate();
-                data.data = data.data.filter(function (row) {
-                    return DateUtils.parseDate(row.date, true).getDate() <= dayFilter
-                });
-            }
-
-            // Parse dates and numbers.
-            data.data.forEach(function (d) {
-                d.date = parse(d.date);
-                d.flows = +d.flows;
-            });
-
-            // Sort the data by date ASC
-            data.data.sort(function (a, b) {
-                return a.date - b.date;
-            });
-
-            if (!this._data.data) this._data.data = [];
-            this._data.data.push(data.data);
-        }
-
-        this._data.loading = requestQueue.length > 0;
-
-        if (!this._data.loading) {
-            if (this._data.data && this._data.data.length==0) {
-                // Broadcast first found error
-                this._data = requestErrors[0];
-            }
-            this.emitChangeData();
-        }
-        else {
-            setTimeout(this.dequeue.bind(this), 1);
-        }
-    }
-});
-
-SpotDispatcher.register(function (action) {
-    switch (action.actionType) {
-        case SpotConstants.UPDATE_DATE:
-            switch (action.name) {
-                case SpotConstants.START_DATE:
-                    IngestSummaryStore.setStartDate(action.date);
-                    break;
-                case SpotConstants.END_DATE:
-                    IngestSummaryStore.setEndDate(action.date);
-                    break;
-            }
-            break;
-        case SpotConstants.RELOAD_INGEST_SUMMARY:
-            IngestSummaryStore.requestSummary();
-            break;
-    }
-});
-
-module.exports = IngestSummaryStore;