Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module.exports = function (grunt) {
},
img: {
cwd: 'misc/',
src: 'patternfly-orb.svg',
src: ['patternfly-orb.svg', '*.png'],
dest: 'docs/img',
expand: true
},
Expand All @@ -76,6 +76,12 @@ module.exports = function (grunt) {
src: ['**'],
dest: 'dist/docs',
expand: true
},
distimg: {
cwd: 'misc',
src: ['canvas-dot-grid.png'],
dest: 'dist/imgs',
expand: true
}
},
less: {
Expand Down Expand Up @@ -131,6 +137,7 @@ module.exports = function (grunt) {
image: 'misc/logo-alt.svg',
scripts: [
'node_modules/jquery/dist/jquery.js',
'node_modules/components-jqueryui/jquery-ui.min.js',
'node_modules/datatables.net/js/jquery.dataTables.js',
'node_modules/datatables.net-select/js/dataTables.select.js',
'node_modules/moment/moment.js',
Expand All @@ -140,6 +147,7 @@ module.exports = function (grunt) {
'node_modules/patternfly/dist/js/patternfly-settings-colors.js',
'node_modules/patternfly/dist/js/patternfly-settings-charts.js',
'node_modules/angular/angular.js',
'node_modules/angular-dragdrop/src/angular-dragdrop.js',
'node_modules/angular-datatables/dist/angular-datatables.min.js',
'node_modules/angular-datatables/dist/plugins/select/angular-datatables.select.min.js',
'node_modules/angular-sanitize/angular-sanitize.js',
Expand Down Expand Up @@ -239,6 +247,11 @@ module.exports = function (grunt) {
cwd: 'src/',
src: ['wizard/**/*.html'],
dest: 'templates/wizard.js'
},
'patternfly.canvas': {
cwd: 'src/',
src: ['canvas-view/**/*.html'],
dest: 'templates/canvas.js'
}
},
// ng-annotate tries to make the code safe for minification automatically
Expand Down Expand Up @@ -271,16 +284,12 @@ module.exports = function (grunt) {
files: ['Gruntfile.js'],
tasks: ['eslint']
},
less: {
files: ['**/*.less'],
tasks: ['less']
},
test: {
files: ['test/**/*.js'],
tasks: ['test']
},
all: {
files: ['Gruntfile.js', 'src/**/*.js', 'src/**/*.html', 'styles/**/*.css'],
files: ['Gruntfile.js', 'src/**/*.js', 'src/**/*.html', 'styles/**/*.css', '**/*.less'],
tasks: ['build'],
options: {
livereload: 35722
Expand All @@ -289,7 +298,7 @@ module.exports = function (grunt) {
}
});

grunt.registerTask('copymain', ['copy:docdata', 'copy:fa', 'copy:img']);
grunt.registerTask('copymain', ['copy:docdata', 'copy:fa', 'copy:img', 'copy:distimg']);

// You can specify which modules to build as arguments of the build task.
grunt.registerTask('build', 'Create bootstrap build files', function () {
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,38 @@ Note:
<script src="node_modules/angular-datatables/dist/angular-datatables.min.js"></script>
<script src="node_modules/angular-datatables/dist/plugins/select/angular-datatables.select.min.js"></script>

7. (optional) The 'patternfly.canvas' module is not a dependency in the default angular 'patternfly' module.
In order to use pfCanvasEditor or pfCanvas, you must add 'patternfly.canvas' as a dependency in your application:

my-app.module.js:

angular.module('myApp', [
'patternfly',
'patternfly.canvas'
]);

Add the following Javascript includes to your HTML file(s):

<!-- jquery before angular.js -->
<script src="node_modules/jquery/dist/jquery.js"></script>
<script src="node_modules/components-jqueryui/jquery-ui.min.js"></script>

<script src="node_modules/angular/angular.js"></script>

<!-- angular-dragdrop after angular.js -->
<script src="node_modules/angular-dragdrop/src/angular-dragdrop.js"></script>

Also, the canvas background grid image is located in 'node_modules/angular-patternfly/dist/imgs/canvas-dot-grid.png'
please copy this image to your application's main images directory and reference it by overridding the '.canvas' css
class:

<style>
.canvas {
background-image: url('/myapp/imgs/canvas-dot-grid.png');
background-repeat: repeat;
}
</style>

### Using with Webpack

In order to use Angular-Patternfly in a Webpack-bundled application there are some things you need to keep in mind:
Expand Down
1 change: 1 addition & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"angular": "1.5.*",
"angular-animate": "1.5.*",
"angular-bootstrap": "2.2.x",
"angular-dragdrop": "1.0.13",
"angular-datatables": "^0.5.6",
"angular-drag-and-drop-lists": "2.0.0",
"angular-sanitize": "1.5.*",
Expand Down
Binary file added misc/canvas-dot-grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions misc/examples.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,10 @@ hr {
.dropdown-kebab-pf.red .btn-link {
color: red;
}

.canvas-demo-container {
height: 600px;
margin-left: 15px;
overflow: auto;
width: 99%;
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
"angular-animate": "1.5.*",
"angular-sanitize": "1.5.*",
"angular-ui-bootstrap": "2.3.x",
"angular-svg-base-fix": "2.0.0",
"lodash-amd": "4.x",
"patternfly": "git+https://git@github.com/patternfly/patternfly#list-view-dnd-branch-4.0-dev-dist"
},
"devDependencies": {
"angular-dragdrop": "1.0.13",
"angular-mocks": "1.3.0 - 1.5.*",
"angular-ui-router": "^0.3.2",
"express": "3.4.4",
Expand Down Expand Up @@ -53,9 +55,10 @@
"angular-drag-and-drop-lists": "2.0.0",
"bootstrap-select": "~1.10.0",
"c3": "~0.4.11",
"components-jqueryui": "components/jqueryui#1.12.1",
"d3": "~3.5.17",
"datatables.net": "^1.10.11",
"datatables.net-select": "~1.2.0",
"d3": "~3.5.17",
"jquery": "~2.1.4",
"moment": "~2.14.1"
},
Expand Down
166 changes: 166 additions & 0 deletions src/canvas-view/canvas-editor/canvas-editor.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
(function () {
'use strict';

angular.module('patternfly.canvas').component('pfCanvasEditor', {

bindings: {
chartDataModel: "=",
chartViewModel: "=?",
toolboxTabs: "=",
readOnly: '<?'
},
transclude: true,
templateUrl: "canvas-view/canvas-editor/canvas-editor.html",
controller: function ($timeout) {
var ctrl = this;
var newNodeCount = 0;
var prevClickedOnChart, prevInConnectingMode;

ctrl.$onInit = function () {
ctrl.toolboxVisible = false;
ctrl.hideConnectors = false;
ctrl.draggedItem = null;
};

// need to get these in next digest cycle, after pfCanvas sets chartViewModel
$timeout(function () {
prevClickedOnChart = ctrl.chartViewModel.clickedOnChart;
prevInConnectingMode = ctrl.chartViewModel.inConnectingMode;
});

ctrl.$doCheck = function () {
if (angular.isDefined(prevClickedOnChart) && angular.isDefined(prevInConnectingMode)) {
if (!angular.equals(ctrl.chartViewModel.clickedOnChart, prevClickedOnChart)) {
if (ctrl.chartViewModel.clickedOnChart) {
ctrl.chartViewModel.clickedOnChart = false;
ctrl.hideToolbox();
}
prevClickedOnChart = ctrl.chartViewModel.clickedOnChart;
}
if (!angular.equals(ctrl.chartViewModel.inConnectingMode, prevInConnectingMode)) {
if (ctrl.chartViewModel.inConnectingMode) {
ctrl.hideConnectors = false;
ctrl.hideToolbox();
}
prevInConnectingMode = ctrl.chartViewModel.inConnectingMode;
}
}
};

ctrl.addNodeToCanvas = function (newNode) {
ctrl.chartViewModel.addNode(newNode);
};

/*** Toolbox Methods ***/

ctrl.showToolbox = function () {
ctrl.toolboxVisible = true;
// add class to subtabs to apply PF style and
// focus to filter input box

$timeout(function () {
angular.element(".subtabs>ul").addClass('nav-tabs-pf');
angular.element("#filterFld").focus();
});
};

ctrl.hideToolbox = function () {
ctrl.toolboxVisible = false;
};

ctrl.toggleToolbox = function () {
if (!ctrl.readOnly && !ctrl.chartViewModel.inConnectingMode) {
if (ctrl.toolboxVisible === true) {
ctrl.hideToolbox();
} else {
ctrl.showToolbox();
}
}
};

ctrl.tabClicked = function () {
angular.element("#filterFld").focus();
};

/*** Toolbox ***/

ctrl.startCallback = function (event, ui, item) {
ctrl.draggedItem = item;
};

ctrl.dropCallback = function (event, ui) {
var newNode = angular.copy(ctrl.draggedItem);
newNodeCount++;
newNode.x = event.clientX - 600;
newNode.y = event.clientY - 200;
newNode.backgroundColor = newNode.backgroundColor ? newNode.backgroundColor : '#fff';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use pfUtils.colorPalette.white

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, but there isn't a 'white' in patternfly.pfPaletteColors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that is silly...


ctrl.chartViewModel.addNode(newNode);
};

ctrl.addNodeByClick = function (item) {
var newNode = angular.copy(item);
newNodeCount++;
newNode.x = 250 + (newNodeCount * 4 + 160);
newNode.y = 200 + (newNodeCount * 4 + 160);
newNode.backgroundColor = newNode.backgroundColor ? newNode.backgroundColor : '#fff';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should use pfUtils.colorPalette.white


ctrl.chartViewModel.addNode(newNode);
};

ctrl.tabClicked = function () {
angular.element("#filterFld").focus();
};

ctrl.activeTab = function () {
return ctrl.toolboxTabs.filter(function (tab) {
return tab.active;
})[0];
};

ctrl.activeSubTab = function () {
var activeTab = ctrl.activeTab();
if (activeTab && activeTab.subtabs) {
return activeTab.subtabs.filter(function (subtab) {
return subtab.active;
})[0];
}
};

ctrl.activeSubSubTab = function () {
var activeSubTab = ctrl.activeSubTab();
if (activeSubTab && activeSubTab.subtabs) {
return activeSubTab.subtabs.filter(function (subsubtab) {
return subsubtab.active;
})[0];
}
};

/*** Zoom ***/

ctrl.maxZoom = function () {
if (ctrl.chartViewModel && ctrl.chartViewModel.zoom) {
return ctrl.chartViewModel.zoom.isMax();
}

return false;
};

ctrl.minZoom = function () {
if (ctrl.chartViewModel && ctrl.chartViewModel.zoom) {
return ctrl.chartViewModel.zoom.isMin();
}

return false;
};

ctrl.zoomIn = function () {
ctrl.chartViewModel.zoom.in();
};

ctrl.zoomOut = function () {
ctrl.chartViewModel.zoom.out();
};
} // controller
}); // module
})();
Loading