-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HWKINVENT-2: WIP: Mocked out sample inventory plugin.
- Loading branch information
Showing
18 changed files
with
410 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/// <reference path="../libs/hawtio-utilities/defs.d.ts"/> | ||
|
||
/// <reference path="../../includes.ts"/> | ||
var Inventory; | ||
(function (Inventory) { | ||
Inventory.pluginName = "inventory"; | ||
Inventory.log = Logger.get(Inventory.pluginName); | ||
Inventory.templatePath = "plugins/inventory/html"; | ||
})(Inventory || (Inventory = {})); | ||
|
||
/// <reference path="../../includes.ts"/> | ||
/// <reference path="inventoryGlobals.ts"/> | ||
var Inventory; | ||
(function (Inventory) { | ||
Inventory._module = angular.module(Inventory.pluginName, []); | ||
var tab = undefined; | ||
Inventory._module.config(['$locationProvider', '$routeProvider', 'HawtioNavBuilderProvider', function ($locationProvider, $routeProvider, builder) { | ||
tab = builder.create().id(Inventory.pluginName).title(function () { return "Inventory"; }).href(function () { return "/inventory"; }).subPath("Inventory List", "Inventory", builder.join(Inventory.templatePath, 'inventory.html')).build(); | ||
builder.configureRouting($routeProvider, tab); | ||
$locationProvider.html5Mode(true); | ||
}]); | ||
Inventory._module.run(['HawtioNav', function (HawtioNav) { | ||
HawtioNav.add(tab); | ||
}]); | ||
hawtioPluginLoader.addModule(Inventory.pluginName); | ||
})(Inventory || (Inventory = {})); | ||
|
||
/// <reference path="inventoryPlugin.ts"/> | ||
var Inventory; | ||
(function (Inventory) { | ||
Inventory.InventoryController = Inventory._module.controller("Inventory.InventoryController", ['$scope', function ($scope) { | ||
$scope.inventory = [ | ||
{ resourceId: "cpu0.rh1001", resourceName: "CPU0 on RH1001" }, | ||
{ resourceId: "cpu2.rh1001", resourceName: "CPU2 on RH1001" }, | ||
{ resourceId: "cpu1.rh1001", resourceName: "CP10 on RH1001" } | ||
]; | ||
}]); | ||
})(Inventory || (Inventory = {})); | ||
|
||
angular.module("hawkular-inventory-templates", []).run(["$templateCache", function($templateCache) {$templateCache.put("plugins/inventory/html/inventory.html","<div class=\"row\">\n <div class=\"col-md-12\" ng-controller=\"Inventory.InventoryController\">\n <h1>Inventory List</h1>\n <ul class=\"list-group\" ng-repeat=\"inventoryItem in inventory\">\n <li class=\"list-group-item\">{{inventoryItem.resourceName}}</li>\n </ul>\n </div>\n</div>\n\n");}]); hawtioPluginLoader.addModule("hawkular-inventory-templates"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory" : "libs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
libs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "hawkular-inventory", | ||
"version": "0.1.0", | ||
"keywords": [ | ||
"hawtio" | ||
], | ||
"main": [ | ||
"dist/hawkular-inventory.js" | ||
], | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"libs", | ||
"test", | ||
"tests", | ||
"plugins" | ||
], | ||
"dependencies": { | ||
"hawtio-core": "~2.0.0", | ||
"hawtio-core-navigation": "~2.0.0", | ||
"hawtio-utilities": "~2.0.0" | ||
}, | ||
"devDependencies": { | ||
"bootstrap": "~3.3.1", | ||
"patternfly": "~1.1.2", | ||
"hawtio-core-dts": "~2.0.0", | ||
"angular-mocks": "~1.3.7" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../libs/hawtio-utilities/defs.d.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// <reference path="inventoryPlugin.d.ts" /> | ||
declare module Inventory { | ||
var InventoryController: ng.IModule; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// <reference path="../../includes.d.ts" /> | ||
declare module Inventory { | ||
var pluginName: string; | ||
var log: Logging.Logger; | ||
var templatePath: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference path="../../includes.d.ts" /> | ||
/// <reference path="inventoryGlobals.d.ts" /> | ||
declare module Inventory { | ||
var _module: ng.IModule; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// <reference path="d.ts/includes.d.ts"/> | ||
/// <reference path="d.ts/inventory/ts/inventoryGlobals.d.ts"/> | ||
/// <reference path="d.ts/inventory/ts/inventoryPlugin.d.ts"/> | ||
/// <reference path="d.ts/inventory/ts/inventory.d.ts"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/// <reference path="../libs/hawtio-utilities/defs.d.ts"/> | ||
|
||
/// <reference path="../../includes.ts"/> | ||
var Inventory; | ||
(function (Inventory) { | ||
Inventory.pluginName = "inventory"; | ||
Inventory.log = Logger.get(Inventory.pluginName); | ||
Inventory.templatePath = "plugins/inventory/html"; | ||
})(Inventory || (Inventory = {})); | ||
|
||
/// <reference path="../../includes.ts"/> | ||
/// <reference path="inventoryGlobals.ts"/> | ||
var Inventory; | ||
(function (Inventory) { | ||
Inventory._module = angular.module(Inventory.pluginName, []); | ||
var tab = undefined; | ||
Inventory._module.config(['$locationProvider', '$routeProvider', 'HawtioNavBuilderProvider', function ($locationProvider, $routeProvider, builder) { | ||
tab = builder.create().id(Inventory.pluginName).title(function () { return "Inventory"; }).href(function () { return "/inventory"; }).subPath("Inventory List", "Inventory", builder.join(Inventory.templatePath, 'inventory.html')).build(); | ||
builder.configureRouting($routeProvider, tab); | ||
$locationProvider.html5Mode(true); | ||
}]); | ||
Inventory._module.run(['HawtioNav', function (HawtioNav) { | ||
HawtioNav.add(tab); | ||
}]); | ||
hawtioPluginLoader.addModule(Inventory.pluginName); | ||
})(Inventory || (Inventory = {})); | ||
|
||
/// <reference path="inventoryPlugin.ts"/> | ||
var Inventory; | ||
(function (Inventory) { | ||
Inventory.InventoryController = Inventory._module.controller("Inventory.InventoryController", ['$scope', function ($scope) { | ||
$scope.inventory = [ | ||
{ resourceId: "cpu0.rh1001", resourceName: "CPU0 on RH1001" }, | ||
{ resourceId: "cpu2.rh1001", resourceName: "CPU2 on RH1001" }, | ||
{ resourceId: "cpu1.rh1001", resourceName: "CP10 on RH1001" } | ||
]; | ||
}]); | ||
})(Inventory || (Inventory = {})); | ||
|
||
angular.module("hawkular-inventory-templates", []).run(["$templateCache", function($templateCache) {$templateCache.put("plugins/inventory/html/inventory.html","<div class=\"row\">\n <div class=\"col-md-12\" ng-controller=\"Inventory.InventoryController\">\n <h1>Inventory List</h1>\n <ul class=\"list-group\" ng-repeat=\"inventoryItem in inventory\">\n <li class=\"list-group-item\">{{inventoryItem.resourceName}}</li>\n </ul>\n </div>\n</div>\n\n");}]); hawtioPluginLoader.addModule("hawkular-inventory-templates"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
var gulp = require('gulp'), | ||
wiredep = require('wiredep').stream, | ||
eventStream = require('event-stream'), | ||
gulpLoadPlugins = require('gulp-load-plugins'), | ||
map = require('vinyl-map'), | ||
fs = require('fs'), | ||
path = require('path'), | ||
s = require('underscore.string'); | ||
|
||
var plugins = gulpLoadPlugins({}); | ||
var pkg = require('./package.json'); | ||
|
||
var config = { | ||
main: '.', | ||
ts: ['plugins/**/*.ts'], | ||
templates: ['plugins/**/*.html'], | ||
templateModule: pkg.name + '-templates', | ||
dist: './dist/', | ||
rootDist: '../../dist/', | ||
js: pkg.name + '.js', | ||
tsProject: plugins.typescript.createProject({ | ||
target: 'ES5', | ||
module: 'commonjs', | ||
declarationFiles: true, | ||
noExternalResolve: false | ||
}) | ||
}; | ||
|
||
gulp.task('bower', function () { | ||
gulp.src('index.html') | ||
.pipe(wiredep({})) | ||
.pipe(gulp.dest('.')); | ||
}); | ||
|
||
/** Adjust the reference path of any typescript-built plugin this project depends on */ | ||
gulp.task('path-adjust', function () { | ||
gulp.src('libs/**/includes.d.ts') | ||
.pipe(map(function (buf, filename) { | ||
var textContent = buf.toString(); | ||
var newTextContent = textContent.replace(/"\.\.\/libs/gm, '"../../../libs'); | ||
// console.log("Filename: ", filename, " old: ", textContent, " new:", newTextContent); | ||
return newTextContent; | ||
})) | ||
.pipe(gulp.dest('libs')); | ||
}); | ||
|
||
gulp.task('clean-defs', function () { | ||
return gulp.src('defs.d.ts', {read: false}) | ||
.pipe(plugins.clean()); | ||
}); | ||
|
||
gulp.task('tsc', ['clean-defs'], function () { | ||
var cwd = process.cwd(); | ||
var tsResult = gulp.src(config.ts) | ||
.pipe(plugins.typescript(config.tsProject)) | ||
.on('error', plugins.notify.onError({ | ||
message: '#{ error.message }', | ||
title: 'Typescript compilation error' | ||
})); | ||
|
||
return eventStream.merge( | ||
tsResult.js | ||
.pipe(plugins.concat('compiled.js')) | ||
.pipe(gulp.dest('.')), | ||
tsResult.dts | ||
.pipe(gulp.dest('d.ts'))) | ||
.pipe(map(function (buf, filename) { | ||
if (!s.endsWith(filename, 'd.ts')) { | ||
return buf; | ||
} | ||
var relative = path.relative(cwd, filename); | ||
fs.appendFileSync('defs.d.ts', '/// <reference path="' + relative + '"/>\n'); | ||
return buf; | ||
})); | ||
}); | ||
|
||
gulp.task('template', ['tsc'], function () { | ||
return gulp.src(config.templates) | ||
.pipe(plugins.angularTemplatecache({ | ||
filename: 'templates.js', | ||
root: 'plugins/', | ||
standalone: true, | ||
module: config.templateModule, | ||
templateFooter: '}]); hawtioPluginLoader.addModule("' + config.templateModule + '");' | ||
})) | ||
.pipe(gulp.dest('.')); | ||
}); | ||
|
||
gulp.task('concat', ['template'], function () { | ||
return gulp.src(['compiled.js', 'templates.js']) | ||
.pipe(plugins.concat(config.js)) | ||
.pipe(gulp.dest(config.dist)) | ||
.pipe(gulp.dest(config.rootDist)); | ||
}); | ||
|
||
gulp.task('clean', ['concat'], function () { | ||
return gulp.src(['templates.js', 'compiled.js'], {read: false}) | ||
.pipe(plugins.clean()); | ||
}); | ||
|
||
gulp.task('watch', ['build'], function () { | ||
plugins.watch(['libs/**/*.js', 'libs/**/*.css', 'index.html', config.dist + '/' + config.js], function () { | ||
gulp.start('reload'); | ||
}); | ||
plugins.watch(['libs/**/*.d.ts', config.ts, config.templates], function () { | ||
gulp.start(['tsc', 'template', 'concat', 'clean']); | ||
}); | ||
}); | ||
|
||
gulp.task('connect', ['watch'], function () { | ||
plugins.connect.server({ | ||
root: '.', | ||
livereload: true, | ||
port: 2772, | ||
fallback: 'index.html' | ||
}); | ||
}); | ||
|
||
gulp.task('reload', function () { | ||
gulp.src('.') | ||
.pipe(plugins.connect.reload()); | ||
}); | ||
|
||
gulp.task('build', ['bower', 'path-adjust', 'tsc', 'template', 'concat', 'clean']); | ||
|
||
gulp.task('default', ['connect']); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<title>hawkular-inventory</title> | ||
<base href='/'></base> | ||
<meta charset="UTF8"> | ||
|
||
|
||
<link rel="stylesheet" href="libs/bootstrap/dist/css/bootstrap.css" /> | ||
<link rel="stylesheet" href="libs/patternfly/dist/css/patternfly.css" /> | ||
|
||
<!-- bower:css --> | ||
<!-- endbower --> | ||
|
||
<!-- ES6/ES6 shim --> | ||
<!--[if IE 8]> | ||
<script src="libs/es5-dom-shim/__COMIPLE/a.ie8.js"></script> | ||
<![endif]--> | ||
<script src="libs/es5-dom-shim/__COMPILE/a.js"></script> | ||
|
||
<!-- bower:js --> | ||
<script src="libs/jquery/dist/jquery.js"></script> | ||
<script src="libs/angular/angular.js"></script> | ||
<script src="libs/angular-sanitize/angular-sanitize.js"></script> | ||
<script src="libs/js-logger/src/logger.js"></script> | ||
<script src="libs/hawtio-core/hawtio-core.js"></script> | ||
<script src="libs/lodash/dist/lodash.compat.js"></script> | ||
<script src="libs/angular-route/angular-route.js"></script> | ||
<script src="libs/hawtio-core-navigation/dist/hawtio-core-navigation.js"></script> | ||
<script src="libs/uri.js/src/URI.js"></script> | ||
<script src="libs/uri.js/src/IPv6.js"></script> | ||
<script src="libs/uri.js/src/SecondLevelDomains.js"></script> | ||
<script src="libs/uri.js/src/punycode.js"></script> | ||
<script src="libs/uri.js/src/URITemplate.js"></script> | ||
<script src="libs/uri.js/src/jquery.URI.js"></script> | ||
<script src="libs/uri.js/src/URI.min.js"></script> | ||
<script src="libs/uri.js/src/jquery.URI.min.js"></script> | ||
<script src="libs/uri.js/src/URI.fragmentQuery.js"></script> | ||
<script src="libs/uri.js/src/URI.fragmentURI.js"></script> | ||
<script src="libs/hawtio-utilities/dist/sugar.js"></script> | ||
<script src="libs/hawtio-utilities/dist/angular-file-upload.js"></script> | ||
<script src="libs/hawtio-utilities/dist/hawtio-utilities.js"></script> | ||
<!-- endbower --> | ||
|
||
<script src="libs/bootstrap/dist/js/bootstrap.js"></script> | ||
<script src="libs/patternfly/dist/js/patternfly.js"></script> | ||
|
||
</head> | ||
|
||
<body> | ||
<nav class="navbar navbar-default navbar-pf" role="navigation"> | ||
<ul class="nav navbar-nav navbar-primary" hawtio-main-nav></ul> | ||
<ul class="nav navbar-nav" hawtio-sub-tabs></ul> | ||
</nav> | ||
|
||
<div id="main" class="container-fluid ng-cloak" ng-controller="HawtioNav.ViewController"> | ||
<div ng-include src="viewPartial"></div> | ||
</div> | ||
|
||
<!-- add any scripts under dist/ here --> | ||
<script src="dist/hawkular-inventory.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "hawkular-inventory", | ||
"version": "0.1.0", | ||
"devDependencies": { | ||
"bower": "^1.3.12", | ||
"event-stream": "^3.1.7", | ||
"gulp": "^3.8.10", | ||
"gulp-angular-templatecache": "^1.5.0", | ||
"gulp-clean": "^0.3.1", | ||
"gulp-concat": "^2.4.2", | ||
"gulp-connect": "^2.2.0", | ||
"gulp-load-plugins": "^0.8.0", | ||
"gulp-notify": "^2.1.0", | ||
"gulp-typescript": "^2.3.0", | ||
"gulp-watch": "^3.0.0", | ||
"through2": "^0.6.3", | ||
"underscore.string": "^2.4.0", | ||
"vinyl-map": "^1.0.1", | ||
"which": "^1.0.8", | ||
"wiredep": "^2.2.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference path="../libs/hawtio-utilities/defs.d.ts"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="row"> | ||
<div class="col-md-12" ng-controller="Inventory.InventoryController"> | ||
<h1>Inventory List</h1> | ||
<ul class="list-group" ng-repeat="inventoryItem in inventory"> | ||
<li class="list-group-item">{{inventoryItem.resourceName}}</li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/// <reference path="inventoryPlugin.ts"/> | ||
module Inventory { | ||
|
||
export var InventoryController = _module.controller("Inventory.InventoryController", ['$scope', ($scope) => { | ||
$scope.inventory = [ | ||
{resourceId: "cpu0.rh1001", resourceName:"CPU0 on RH1001" }, | ||
{resourceId: "cpu2.rh1001", resourceName:"CPU2 on RH1001" }, | ||
{resourceId: "cpu1.rh1001", resourceName:"CP10 on RH1001" } | ||
|
||
]; | ||
}]); | ||
|
||
} |
Oops, something went wrong.