Skip to content

Commit

Permalink
HWKINVENT-2: WIP: Mocked out sample inventory plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtho11 committed Feb 3, 2015
1 parent 57482c8 commit db23dcb
Show file tree
Hide file tree
Showing 18 changed files with 410 additions and 0 deletions.
40 changes: 40 additions & 0 deletions dist/hawkular-inventory.js
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");
3 changes: 3 additions & 0 deletions plugins/inventory/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory" : "libs"
}
2 changes: 2 additions & 0 deletions plugins/inventory/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
libs/
30 changes: 30 additions & 0 deletions plugins/inventory/bower.json
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"
}
}
1 change: 1 addition & 0 deletions plugins/inventory/d.ts/includes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../libs/hawtio-utilities/defs.d.ts" />
4 changes: 4 additions & 0 deletions plugins/inventory/d.ts/inventory/ts/inventory.d.ts
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;
}
6 changes: 6 additions & 0 deletions plugins/inventory/d.ts/inventory/ts/inventoryGlobals.d.ts
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;
}
5 changes: 5 additions & 0 deletions plugins/inventory/d.ts/inventory/ts/inventoryPlugin.d.ts
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;
}
4 changes: 4 additions & 0 deletions plugins/inventory/defs.d.ts
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"/>
40 changes: 40 additions & 0 deletions plugins/inventory/dist/hawkular-inventory.js
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");
129 changes: 129 additions & 0 deletions plugins/inventory/gulpfile.js
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']);



65 changes: 65 additions & 0 deletions plugins/inventory/index.html
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>
22 changes: 22 additions & 0 deletions plugins/inventory/package.json
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"
}
}
1 change: 1 addition & 0 deletions plugins/inventory/plugins/includes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../libs/hawtio-utilities/defs.d.ts"/>
9 changes: 9 additions & 0 deletions plugins/inventory/plugins/inventory/html/inventory.html
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>

13 changes: 13 additions & 0 deletions plugins/inventory/plugins/inventory/ts/inventory.ts
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" }

];
}]);

}

0 comments on commit db23dcb

Please sign in to comment.