Skip to content

Commit

Permalink
injected angularjs dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gnehapk committed May 21, 2018
1 parent 079eef8 commit 3b49289
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ gulp.task("resource", function(done) {
gulp.task("jsbundle", ["eslint"], function() {

return gulp.src(paths.jsFiles, { cwd: paths.src })
.pipe(babel({ presets: ["es2015"] }))
.pipe(concat("plugin-bundle.js"))
.pipe(babel({ presets: ["es2015"] }))
.pipe(gulp.dest(paths.dest));
});

Expand Down Expand Up @@ -256,7 +256,7 @@ gulp.task("watcher", ["browser-sync", "common"], function(done) {

gulp.watch(filters.js, { cwd: paths.src }, function(event) {
log("Modified:", colors.yellow(event.path));
runSequence("preload", "jsbundle");
runSequence("preload", "jsbundle", "transform");
});

gulp.watch([filters.css, filters.scss], { cwd: paths.src }, function(event) {
Expand Down
9 changes: 7 additions & 2 deletions src/commons/js/ng-react-ng-deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
export const ngDeps = {};

export function injectNgDeps(deps) {
console.log(deps, "deps");
Object.assign(ngDeps, deps);
window.ngDeps = ngDeps;
};

export default ngDeps;
Expand All @@ -14,7 +16,10 @@ storageModule.run([
"$rootScope",
"$state",
"$q",
($rootScope, $state, $q) => {
injectNgDeps({ $rootScope, $state, $q });
"$http",
"utils",
($rootScope, $state, $q, $http, utils) => {
console.log("inside run");
injectNgDeps({ $rootScope, $state, $q, $http, utils });
},
]);
4 changes: 2 additions & 2 deletions src/commons/services/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@
getEventListRequest,
request;

//url = "/api/events.json";
url = config.baseUrl + "clusters/" + clusterId + "/notifications";
url = "/api/events.json";
//url = config.baseUrl + "clusters/" + clusterId + "/notifications";

getEventListRequest = {
method: "GET",
Expand Down
28 changes: 19 additions & 9 deletions src/commons/stores/events-store.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import React, { Component } from "react";
import ngDeps from "../js/ng-react-ng-deps.js";

console.log(ngDeps, "ngDeps");

const { $rootScope, $state, $q, $http } = ngDeps;

const EventStore = {
getAlertList: function() {
var list,
deferred;
deferred,
utils = window.ngDeps.utils,
$rootScope = window.ngDeps.$rootScope,
$q = window.ngDeps.$q;

console.log(window.ngDeps, "window");
deferred = $q.defer();

utils.getAlertList()
.then(function(data) {

$rootScope.showAlertIndication = false;
list = data ? _formatAlertData(data) : [];
deferred.resolve(list);
Expand All @@ -28,8 +37,8 @@ const EventStore = {
i;

for (i = 0; i < len; i++) {
temp = {},
temp.alertId = data[i].alert_id;
temp = {};
temp.alertId = data[i].alert_id;
temp.timeStamp = new Date(data[i].time_stamp);
temp.severity = severity[data[i].severity];
temp.nodeId = data[i].node_id;
Expand All @@ -49,7 +58,10 @@ const EventStore = {
},
getEventList: function(clusterId) {
var list,
deferred;
deferred,
utils = window.ngDeps.utils,
$rootScope = window.ngDeps.$rootScope,
$q = window.ngDeps.$q;

deferred = $q.defer();
utils.getEventList(clusterId)
Expand All @@ -69,8 +81,8 @@ const EventStore = {
i;

for (i = 0; i < len; i++) {
temp = {},
temp.timeStamp = new Date(data[i].timestamp);
temp = {};
temp.timeStamp = new Date(data[i].timestamp);
temp.priority = data[i].priority;
temp.message = data[i].message;
temp.message_id = data[i].message_id;
Expand All @@ -81,8 +93,6 @@ const EventStore = {
}
};

export default EventStore;

angular
.module("TendrlModule")
.service("eventStore", eventStore);
Expand Down

0 comments on commit 3b49289

Please sign in to comment.