Git Product home page Git Product logo

angular-patternfly's Introduction

Build Status Dependency Status Code Climate NSP Status Join the chat at https://gitter.im/patternfly/angular-patternfly Coverage Status

AngularJS components for PatternFly

This project will provide a set of common AngularJS components for use with the PatternFly reference implementation.

Getting started

You have to install required software before you're able to use grunt:

  • Install Node.js - Find more information on Node.js

    Angular Patternfly stays up to date with the Node LTS Release Schedule. If you're using Angular Patternfly downstream, we suggest the use of an actively supported version of Node/NPM, although prior versions of Node may work.

  • Install npm - If npm is not already installed with Node.js, you have to install it manually. Find more information on NPM

  • Install Grunt globally - Find more information on Grunt

    $ npm install -g grunt-cli
  • Install npm dependencies with:

    $ npm install

You should have your environment ready now.

Angular-PatternFly can now be built with:

$ npm run build

To see all the grunt tasks that are available:

$ npm run help

Using Angular-PatternFly In Your Application

Note:

  1. Add Angular-PatternFly as dependencies for your project and you'll receive all the libraries you'll need:

    $ npm install angular-patternfly --save
  2. Add the core Patternfly CSS and script includes to your HTML file(s):

    Please see: https://github.com/patternfly/patternfly/blob/master/QUICKSTART.md

    Alternatively, the minimum you will need:

    <!-- PatternFly Styles -->
    <!-- Note: No other CSS files are needed regardless of what other JS packages located in patternfly/components that you decide to pull in -->
    <link rel="stylesheet" href="node_modules/angular-patternfly/node_modules/patternfly/dist/css/patternfly.min.css">
    <link rel="stylesheet" href="node_modules/angular-patternfly/node_modules/patternfly/dist/css/patternfly-additions.min.css">
    
    <!-- Patternfly required settings (no jquery or further JS dependencies required by this include) -->
    <script src="node_modules/angular-patternfly/node_modules/patternfly/dist/js/patternfly_settings.min.js"></script>
    
  3. Add the following CSS include to your HTML file(s):

    <!-- Angular-PatternFly Styles -->
    <link rel="stylesheet" href="node_modules/angular-patternfly/dist/styles/angular-patternfly.min.css" />
  4. Add the following script includes to your HTML file(s), adjusting where necessary to pull in only what you need:

    <!-- Angular -->
    <script src="node_modules/angular-patternfly/node_modules/angular/angular.min.js"></script>
    
    <!-- Bootstrap-Select (Optional): The following lines are only required if you use the pfBootstrapSelect directive -->
    <script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="node_modules/bootstrap-select/js/bootstrap-select.js"></script>
    
    <!-- Angular-Bootstrap -->
    <script src="node_modules/angular-patternfly/node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js"></script>
    <script src="node_modules/angular-patternfly/node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js"></script>
    
    <!-- Angular-Sanitize -->
    <script src="node_modules/angular-patternfly/node_modules/angular-sanitize/angular-sanitize.min.js"></script>
    
    <!-- Angular-Animate -->
    <script src="node_modules/angular-patternfly/node_modules/angular-animate/angular-animate.js"></script>
    
    <!-- Angular-PatternFly  -->
    <script src="node_modules/angular-patternfly/dist/angular-patternfly.min.js"></script>
    
    <!-- Lodash -->
    <script src="node_modules/angular-patternfly/node_modules/lodash/lodash.min.js"></script>
  5. (optional) The 'patternfly.charts' module is not a dependency in the default angular 'patternfly' module. In order to use patternfly charts you must add it as a dependency in your application:

    my-app.module.js:
    
    angular.module('myApp', [
     'patternfly',
     'patternfly.charts'
    ]);

    And script includes to your HTML file:

    <!-- C3, D3 - Charting Libraries. -->
    <script src="node_modules/angular-patternfly/node_modules/patternfly/node_modules/c3/c3.min.js"></script>
    <script src="node_modules/angular-patternfly/node_modules/patternfly/node_modules/d3/d3.min.js"></script>
  6. (optional) The 'patternfly.table' module is not a dependency in the default angular 'patternfly' module. In order to use pfTableView, you must add 'patternfly.table' as a dependency in your application:

    my-app.module.js:
    
    angular.module('myApp', [
     'patternfly',
     'patternfly.table'
    ]);

    Add the npm dependency:

    $ npm install angularjs-datatables --save

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

    <!-- Place before any patternfly css -->
    <link rel="stylesheet" href="node_modules/angular-patternfly/node_modules/datatables.net-dt/css/jquery.dataTables.css" />

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

    <script src="node_modules/angular-patternfly/node_modules/patternfly/node_modules/jquery/dist/jquery.js"></script>
    <script src="node_modules/angular-patternfly/node_modules/patternfly/node_modules/datatables.net/js/jquery.dataTables.js"></script>
    <script src="node_modules/angular-patternfly/node_modules/patternfly/node_modules/datatables.net-select/js/dataTables.select.js"></script>
    <script src="node_modules/angularjs-datatables/dist/angular-datatables.min.js"></script>
    <script src="node_modules/angularjs-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 npm dependencies:

    $ npm install jquery-ui-dist --save
    $ npm install angular-dragdrop --save
    $ npm install angular-svg-base-fix --save

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

     <!-- jquery before angular.js -->
     <script src="node_modules/angular-patternfly/node_modules/patternfly/node_modules/jquery/dist/jquery.js"></script>
     <script src="node_modules/jquery-ui-dist/jquery-ui.js"></script>
    
     <!-- angular-dragdrop and angular-svg-base-fix after angular.js -->
     <script src="node_modules/angular-dragdrop/src/angular-dragdrop.js"></script>
     <script src="node_modules/angular-svg-base-fix/src/svgBaseFix.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>

Less to Sass Conversion

During the build process Less files are converted to Sass files in /dist/sass. Then the Sass files are compiled into /dist/sass/angular-patternfly.css. If you would like to copy the Sass generated css into the main /dist/styles directory, execute:

grunt build --sass

This task will copy /dist/sass/angular-patternfly.css to /dist/styles/angular-patternfly.css. Then the build process will minimize the css in /dist/styles.

The Less to Sass Conversion step will be accomplished and managed as a part of any Pull Request which includes Less file changes. Although contributors may want to build and test their style changes with Sass before submitting a Pull Request, this step should always be tested and validated by reviewers before a style change is merged and released. If a contributor is having issues with Sass conversion that they cannot resolve, Pull Request reviewers will need to ensure that the Sass conversion step is successfully accomplished, tested, and included in the Pull Request before it is approved and merged.

For more detailed information, please read PatternFly Less to Sass Conversion

Note: When a Less file is added/deleted/renamed it needs to be updated in the main Less import file /styles/angular-patternfly.less and the main Sass import file styles/_angular-patternfly.scss.

Using with Webpack

In order to use Angular-Patternfly in a Webpack-bundled application there are some things you need to keep in mind:

Create an alias for the jQuery module (if using JQuery dependency)

In order to let Webpack find the correct jQuery module when assembling all the dependencies you need to create an alias for it in the webpack.conf.js file:

...
resolve: {
  alias: {
    "jquery": "patternfly/node_modules/jquery"
  }
}
...

Additionally, you have to use the webpack.ProvidePlugin so the $ and the jQuery variables are added to the window object, making them available to the other modules (Patternfly included):

...
plugins: [
  new webpack.ProvidePlugin({
    $: "jquery",
    jQuery: "jquery",
    "window.jQuery": "jquery",
    "window.jquery": "jquery"
  })
]
...

API documentation

The API documentation can be built with:

$ npm run uidocs

If you're interested in reading the docs right away, you can use special target, which will start a web server:

$ npm run uidocs:view

After executing this tasks you'll be able to access the documentation at http://localhost:8000/. If a different port is desired, it may be specified on as an option:

$ npm run uidocs:view -- --port=8002

Git Commit Guidelines

PatternFly uses a semantic release process to automate npm and bower package publishing, based on the following commit message format.

Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject (full explanation):

<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
Patch Release
fix(pencil): stop graphite breaking when too much pressure applied
// Specific example using the component name as the scope
fix(pfEmptyState): add missing closing <span> tag
Feature Release
feat(pencil): add 'graphiteWidth' option
// Specific example using the component name as the scope
feat(pfNotificationDrawer): add empty state message to group without notifications
Breaking Release
perf(pencil): remove graphiteWidth option
// Specific example using the component name as the scope
perf(pfFakeComponent): remove pfFakeComponent
Non-Release

chore(pencil): rename internal graphiteDensity variable chore(pfNotificationDrawer): rename internal drawer expanded variable

Contributing

We're always interested in contributions from the community.

Please ensure that your PR provides the following:

  • Detailed description of the proposed changes
  • Follows the style rules for javascript and html.
  • Rebased onto the latest master commit
  • If you would like to become a maintainer, please see our Contributing Guide

Unit Testing Required

Applying a unit test, or an update to a unit test, is a contribution requirement.

If you're unfamiliar with Angular unit testing, or just need a refresher, here are the overall Angular 1x guidelines.

You can access the Angular PatternFly unit test spec files under the test directory.

To get started, some basic guidelines:

  • Provide a clear statement of what the component does. This encompasses what is expected, and what is produced.
  • The component has features, be clear and concise on what is expected, and what is produced from each.

Browser Support

Since PatternFly is based on Bootstrap, PatternFly generally supports the same browsers, see also Bootstrap browser support.

angular-patternfly's People

Contributors

abkieling avatar allenbw avatar amarie401 avatar ammendonca avatar aptmac avatar beanh66 avatar benjaminapetersen avatar bleathem avatar cdcabrera avatar cliffpyles avatar dabeng avatar dgutride avatar dlabrecq avatar dtaylor113 avatar huerlisi avatar hyperkid123 avatar jcaianirh avatar jeff-phillips-18 avatar jjlangholtz avatar jonathanchristison avatar kenfinnigan avatar nicolethoen avatar patternfly-build avatar priley86 avatar rhamilto avatar rhwood avatar spadgett avatar vitorsilvalima avatar vkrizan avatar yaacov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-patternfly's Issues

angular.merge is not a function .controller

Downloaded the latest, saw the above error when employing pfSimpleFilter / pfDataToolbar. Working on the issue presently, will provide additional information as the issue becomes clearer.

more info
the below commit does away with angular extend in lieu of merge, this is presently not supported by angular > 1.4 (ie 1.3.18)
be9c015

Incompatibility with patternfly-sass 3.x

Specifying patternfly as a dependency in this project causes SASS load path issues when used with patternfly-sass in a Rails application. My suggestion would be to create a fork or a special version calles angular-patternfly-sass where the bower.json and package.json files specify patternfly-sass as a dependency instead of patternfly.

Could you somehow fix this? I can help with testing by trying to integrate it into our application.

Missing info. in Sparkline chart ng-docs

Please add a description of 'total' to the chartData ng-doc

chartData object the data to be shown as an area chart
.xData - Array, X values for the data points, first element must be the name of the data
.yData - Array, Y Values for the data points, first element must be the name of the data
.total - (optional) The Total amount, used when determining percentages

patternfly new component

hi,
when wa can use the new component of patternfly as liste view toast .... ?
is not in github repository !
thanks

Notifications - support named notifications / prevent duplicates somehow?

Right now, there is no way to prevent multiple instances of the same notification at the same time, for example if you have an $http responseError interceptor that generates a session timeout message, multiple identical messages will be shown when multiple requests fail at the same time.

I'm not sure what the right approach to tackle that is, maybe we could get away with simply not adding a notification that deep equals to something already there.. Maybe something like having a concept of predefined notifications in Notifications might make more sense because then it should be at least easy to tell if it's already there or not...

What do you think?

Bower.json 'main' has minified and unminified files

The main section for bower.json lists both the unminified and minified versions of the code. Are both really needed?

We're using wiredep to include our bower components automatically and it is picking up both of these files.

Move to Angular 1.3.x?

Are there intentions to move to Angular 1.3.x. Just wanting to remove resolutions in our bower file.

Create a card directive

Create a directive that encapsulates the patternfly reference HTML for a the card component

Support i18n and l10n

We have several English strings in angular-patternfly and should support internationalization and localization.

I've used angular-gettext in the past but I think it would be better to provide files per language if possible using something like grunt-static-i18n perhaps? Then the consumer of angular-patternfly could just include the js file for the language they need.

pfSelect doesn't react to ng-options change

When the ng-options changes, the hidden element is correctly updated to reflect the change (as tested in https://github.com/patternfly/angular-patternfly/blob/aa38a2806d2df0f3ed156668104f4bd966707f82/test/select/select.spec.js#L44) but the generated dropdown (which is what's displayed in the browser) is not, and remains with the old options. This should be fixed and the test should test for it as well.

LICENSE.txt?

I would assume Angular-Patternfly to be under the Apache 2.0 License because Patternfly itself is but Angular-Patternfly does not have a license.txt.

What license is Angular-Patternfly intended to be used under?

Use ng-annotate

We should be using ng-annotate via grunt-ng-annotate to avoid verbose function declarations when using dependency injection.

It turns this:

angular.module("MyMod").controller("MyCtrl", function($scope, $timeout) {
});

into this

angular.module("MyMod").controller("MyCtrl", ["$scope", "$timeout", function($scope, $timeout) {
}]);

automatically at build time so minificaiton is safe.

Request for enhancement: angular-patternfly-style modal directive

I want to use modals in my angular-pf application, and it'd be nice to have a directive to take a lot of the repetitive work and boilerplate HTML out of it. angular-bootstrap has a modal service, but it doesn't really seem to match the angular-pf style. The modal service needs to be fed a full template to create the modal from, including all the boilerplate, whereas existing angular-pf directives appear to be more geared around supplying that boilerplate for you.

A hypothetical directive could look like this:

<div pf-modal modal-name="mymodal" modal-title="This is a modal" ok-label="Do it" ok-type="danger">
    Modal body content here.
</div>

Alternatively, it could be more based around the configuration object pattern that some of the more complex angular-pf directives use:

<div pf-modal config="configobject">
    Modal body content here.
</div>

$scope.configobject = {
    name: 'mymodal',
    title: 'This is a modal',
    okButton: {
        label: 'Do it',
        type: 'danger'
    }
};

In both those examples, the OK button type would map to the btn-<type> Bootstrap button class for the OK button. The latter pattern would make more sense if we want something a bit more configurable than a simple OK/Cancel button pair on the modal, with something more like the button config objects used by pfToolbar and pfListView.

Displaying the modal could be controlled via a service similar to the angular-bootstrap modal service, which would return a modal object with one or more promise properties (and methods to close/dismiss the modal programmatically). You'd use it in a similar fashion to this:

mycontroller.controller('mycontroller', ['$scope', 'pfModal',
    function($scope, pfModal) {
        // show the modal with the name 'mymodal'
        var modal = pfModal.show('mymodal');

        // modal object has a result property of type promise
        modal.result.then(function(result) {
            // do something when the user hits ok
        }, function(reason) {
            // or when they hit cancel
        });
    }
]);

Alternatively (and especially if the config object pattern is used), rather than using a return object with promises we could supply functions to call when the modal is closed/dismissed:

$scope.configobject ={
    ...
    onClose: function() { ... },
    onCancel: function() { ... }
};

I've had a go at doing an implementation myself (using the directive and service pattern), but my angular knowledge doesn't appear to be up to the job yet. If someone really wants to see my (likely quite terrible) code, I can make it available for ridicule.

I think it'd be really useful to get some sort of modal directive into angular-pf, even if the interface doesn't look like the above :)

Example not working

I have tried the following as suggested in the main page

<html>
  <head>
    <title>Website</title>
    <link rel="stylesheet" href="bower_components/angular-patternfly/dist/styles/angular-patternfly.min.css"/>

    <script src="/bower_components/angular/angular.js"></script>
    <script src="/bower_components/patternfly/components/c3/c3.min.js"></script>
    <script src="/bower_components/patternfly/components/d3/d3.min.js"></script>
    <script src="/bower_components/angular-patternfly/dist/angular-patternfly.min.js"></script>
    <script src="/js/main.js"></script>
  </head>
  <body ng-app="myapp">
    <div ng-controller="MainController"></div>
    <h1>Msg = {{ msg }}</h1>
  </body>
</html>

And

var app = angular.module("myapp", [
    'patternfly',
    'patternfly.charts',
]);

app.controller("MainController", function($scope) {
    $scope.msg = "Hello World";
})

But the following error is given:

localhost/:1 GET http://localhost:5000/bower_components/patternfly/components/c3/c3.min.js 
localhost/:1 GET http://localhost:5000/bower_components/patternfly/components/d3/d3.min.js 
localhost/:1 GET http://localhost:5000/bower_components/patternfly/components/c3/c3.min.js 
localhost/:1 GET http://localhost:5000/bower_components/patternfly/components/d3/d3.min.js 
angular-patternfly.min.js:1 Uncaught ReferenceError: $ is not defined(anonymous function) @ angular-patternfly.min.js:1(anonymous function) @ angular-patternfly.min.js:1
angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module myapp due to:
Error: [$injector:modulerr] Failed to instantiate module patternfly due to:
Error: [$injector:modulerr] Failed to instantiate module patternfly.filters due to:
Error: [$injector:modulerr] Failed to instantiate module patternfly.select due to:
Error: [$injector:nomod] Module 'patternfly.select' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.5/$injector/nomod?p0=patternfly.select

Two major reasons:

  • There is no /bower_components/patternfly/components/d3/d3.min.js and for c3. They are in seperate folders.
  • When I used the non-minified patternfly.js, and corrected the d3 and c3 paths, I see the error is generated from this line where $ is undefined. var patternflyDefaults = $().c3ChartDefaults();

What to do?

Create a demo.css file

Create a demo.css file so that we can put demo css into it. This file should be for showcase purposes only and not get distributed via bower.

There is no patternfly.formgroup module

In dist/angular-patternfly.js there is a declaration of patternfly module, and in that declaration one of stated dependencies is patternfly.formgroup. However, there is no such module so error is returned, and I am guessing it would be correct to put patternfly.form instead.

Make angular-patternfly available in node packages

We are trying to port some things to angular in ManageIq and for that we use custom ui components which depends on angular patternfly, but we are trying to use only npm for managing these custom ui components. So it would be nice if this repository would be also available in node packages and not only at bower.

most bower devDependencies should be dependencies

Bower's devDependencies are meant for things needed only for development, tests, etc. Packages that are actually depended upon for the daily operation should be listed as dependencies instead. (That's according to the bower spec.)

Right now, angular-patternfly's bower.json has no dependencies and everything in devDependencies, but I think there are no real devDependencies and everything should be a dependency. But I'm quite sure that since charts depends on ui.bootstrap and ngSanitize, at least angular-sanitize and angular-bootstrap should definitely be in dependencies..

pfCard Ng-Docs issues

1 - The Parameters show that the "showTopBorder" is false by default, but the Demo, shows the border. If it isn't the default, i'd suggest it's not shown. Can the demo be enhanced to allow the option to show/hide the border?
2 - Typo here ... "subtTtle"

pfcardtype

selectpicker undefined

I get error that .selectpicker() is undefined on line 674 in directive patternfly.select.
Do you maybe know what is the problem here? Where is this selectpicker supposed to come from?
I included patternfly in my project but I did not include any bootstrap, I am supposed to include bootstrap?

Action button in pfToolbar has broken style

It looks that there is wrong padding for button, In case I have just one Action button used in pfToolbar:

code example:

    vm.toolbarConfig = {
      actionsConfig: {
        primaryActions: [
          {
            name: 'Edit',
            title: 'Edit service dialog',
            actionFn: performAction
          }
        ]
      }
    };

screenshots:

single action button:
screencapture-localhost-3001-self_service-dialogs-1456343129813

action button together with filters:
screencapture-localhost-3001-self_service-dialogs-1456343561548

pfSelect doesn't support "track by" in ngOptions

When trying to use "track by" expression with pfSelect, an error is thrown.

eg:
<select pf-select ng-model="pet" id="pet" ng-options="o as o for o in pets track by $index"></select>
throws
Error: [$parse:syntax] Syntax Error: Token 'track' is an unexpected token at column 6 of the expression [pets track by $index] starting at [track by $index].

It should be possible to use it, as it is without the pfSelect directive.

Fix i18n issue with Sort Icons

Sort icons for alphabetic and numeric are using A-Z and 1-9. This doesn't translate so we need to add an alternative for non english languages.

License

What is the license for Angular Patternfly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.