From 389e5b7a0669a7ce3feaaf78c9a20f53daae211b Mon Sep 17 00:00:00 2001 From: Shu Muto Date: Wed, 27 Jul 2016 14:17:51 +0900 Subject: [PATCH] change for Dashboard UI plugin --- .gitreview | 4 +- README.rst | 4 +- cookiecutter.json | 20 +- hooks/post_gen_project.sh | 2 +- {{cookiecutter.repo_name}}/.coveragerc | 7 - {{cookiecutter.repo_name}}/.eslintrc | 47 ++ {{cookiecutter.repo_name}}/.gitignore | 65 +-- {{cookiecutter.repo_name}}/.gitreview | 2 +- {{cookiecutter.repo_name}}/.jshintrc | 29 ++ {{cookiecutter.repo_name}}/.mailmap | 3 - {{cookiecutter.repo_name}}/.testr.conf | 7 - {{cookiecutter.repo_name}}/MANIFEST.in | 3 + {{cookiecutter.repo_name}}/README.rst | 61 ++- {{cookiecutter.repo_name}}/babel-django.cfg | 5 + {{cookiecutter.repo_name}}/babel-djangojs.cfg | 14 + {{cookiecutter.repo_name}}/babel.cfg | 2 - {{cookiecutter.repo_name}}/doc/Makefile | 152 ++++++ {{cookiecutter.repo_name}}/doc/source/conf.py | 434 ++++++++++++++++-- .../doc/source/contributing.rst | 4 - .../doc/source/index.rst | 93 +++- .../doc/source/installation.rst | 12 - .../doc/source/readme.rst | 1 - .../doc/source/releases/0.1.0.rst | 2 + .../doc/source/usage.rst | 7 - .../__init__.py => manage.py} | 12 +- .../releasenotes/source/conf.py | 16 +- {{cookiecutter.repo_name}}/requirements.txt | 39 +- {{cookiecutter.repo_name}}/setup.cfg | 28 -- {{cookiecutter.repo_name}}/setup.py | 4 +- .../test-requirements.txt | 37 +- .../__init__.py | 0 .../api/__init__.py | 0 .../api/client.py | 113 +++++ .../api/rest_api.py | 75 +++ .../content/__init__.py | 0 .../{{cookiecutter.panel}}s/__init__.py | 0 .../content/{{cookiecutter.panel}}s/panel.py | 22 + .../content/{{cookiecutter.panel}}s/tests.py | 19 + .../content/{{cookiecutter.panel}}s/urls.py | 19 + .../content/{{cookiecutter.panel}}s/views.py | 17 + ...{{cookiecutter.panel_group}}_panelgroup.py | 36 ++ ...l_group}}_{{cookiecutter.panel}}s_panel.py | 21 + .../{{cookiecutter.module_folder}}/models.py | 3 + .../{{cookiecutter.api_module}}.service.js | 79 ++++ .../{{cookiecutter.panel_group}}.module.js | 37 ++ ...{cookiecutter.panel_group}}.module.spec.js | 23 + .../{{cookiecutter.panel_group}}.scss | 8 + .../{{cookiecutter.panel}}s/actions.module.js | 73 +++ .../create/create-workflow.service.js | 50 ++ .../create/create.service.js | 100 ++++ .../create/info/info.help.html | 4 + .../create/info/info.html | 12 + .../{{cookiecutter.panel}}.info.controller.js | 40 ++ .../create/{{cookiecutter.panel}}-model.js | 67 +++ .../delete/delete.service.js | 151 ++++++ .../details/details.module.js | 55 +++ .../details/drawer.controller.js | 39 ++ .../details/drawer.html | 16 + .../details/overview.controller.js | 43 ++ .../details/overview.html | 26 ++ .../{{cookiecutter.panel}}s/panel.html | 4 + .../{{cookiecutter.panel}}s.module.js | 133 ++++++ .../{{cookiecutter.panel}}s.module.spec.js | 23 + .../{{cookiecutter.panel}}s.scss | 0 .../test/__init__.py | 0 .../{{cookiecutter.module_folder}}/version.py | 3 + .../tests/base.py | 23 - .../test_{{cookiecutter.module_name}}.py | 28 -- 68 files changed, 2203 insertions(+), 275 deletions(-) delete mode 100644 {{cookiecutter.repo_name}}/.coveragerc create mode 100644 {{cookiecutter.repo_name}}/.eslintrc create mode 100644 {{cookiecutter.repo_name}}/.jshintrc delete mode 100644 {{cookiecutter.repo_name}}/.mailmap delete mode 100644 {{cookiecutter.repo_name}}/.testr.conf create mode 100644 {{cookiecutter.repo_name}}/babel-django.cfg create mode 100644 {{cookiecutter.repo_name}}/babel-djangojs.cfg delete mode 100644 {{cookiecutter.repo_name}}/babel.cfg create mode 100644 {{cookiecutter.repo_name}}/doc/Makefile mode change 100755 => 100644 {{cookiecutter.repo_name}}/doc/source/conf.py delete mode 100644 {{cookiecutter.repo_name}}/doc/source/contributing.rst delete mode 100644 {{cookiecutter.repo_name}}/doc/source/installation.rst delete mode 100644 {{cookiecutter.repo_name}}/doc/source/readme.rst create mode 100644 {{cookiecutter.repo_name}}/doc/source/releases/0.1.0.rst delete mode 100644 {{cookiecutter.repo_name}}/doc/source/usage.rst rename {{cookiecutter.repo_name}}/{{{cookiecutter.module_name}}/__init__.py => manage.py} (64%) mode change 100644 => 100755 rename {{cookiecutter.repo_name}}/{{{cookiecutter.module_name}}/tests => {{cookiecutter.module_folder}}}/__init__.py (100%) create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/__init__.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/client.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/rest_api.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/__init__.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/__init__.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/panel.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/tests.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/urls.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/views.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/enabled/_90_{{cookiecutter.dashboard}}_{{cookiecutter.panel_group}}_panelgroup.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/enabled/_91_{{cookiecutter.dashboard}}_{{cookiecutter.panel_group}}_{{cookiecutter.panel}}s_panel.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/models.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.api_module}}.service.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.module.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.module.spec.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.scss create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/actions.module.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/create-workflow.service.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/create.service.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/info.help.html create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/info.html create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/{{cookiecutter.panel}}.info.controller.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/{{cookiecutter.panel}}-model.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/delete/delete.service.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/details.module.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/drawer.controller.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/drawer.html create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/overview.controller.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/overview.html create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/panel.html create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.module.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.module.spec.js create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.scss create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/test/__init__.py create mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/version.py delete mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/base.py delete mode 100644 {{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/test_{{cookiecutter.module_name}}.py diff --git a/.gitreview b/.gitreview index 7365660..1c0f30e 100644 --- a/.gitreview +++ b/.gitreview @@ -1,4 +1,4 @@ [gerrit] host=review.openstack.org -port=29418 -project=openstack-dev/cookiecutter.git +port=xxx +project=openstack-dev/ui-cookiecutter.git diff --git a/README.rst b/README.rst index f39004f..4e6c13e 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ cookiecutter-openstack ====================== -Cookiecutter template for an OpenStack project. See https://github.com/audreyr/cookiecutter. +Cookiecutter template for an OpenStack Dashboard UI plugin project. See https://github.com/audreyr/cookiecutter. * Free software: Apache license * pbr_: Set up to use Python Build Reasonableness @@ -17,7 +17,7 @@ Usage Generate a Python package project:: - cookiecutter https://git.openstack.org/openstack-dev/cookiecutter.git + cookiecutter https://git.openstack.org/shu-mutou/ui-cookiecutter.git OpenStack projects require a working git repo for pbr to work, on newer versions of cookiecutter (>= 0.7.0 released 2013-11-09) this inital commit will diff --git a/cookiecutter.json b/cookiecutter.json index dd0a675..b2ad9b6 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,7 +1,19 @@ { - "module_name": "replace with the name of the python module", + "module_name": "replace with the name of the python module. ex) magnum-ui", "repo_group": "openstack", - "repo_name": "replace with the name for the git repo", - "launchpad_project": "replace with the name of the project on launchpad", - "project_short_description": "OpenStack Boilerplate contains all the boilerplate you need to create an OpenStack package." + "repo_name": "replace with the name for the git repo. ex) magnum-ui", + "launchpad_project": "replace with the name of the project on launchpad. ex) magnum-ui", + "project_short_description": "OpenStack Boilerplate contains all the boilerplate you need to create an OpenStack package. ex) Magnum User Interface", + "call_by_name": "replace with the name for calling in text such as README or Help. ex) Magnum UI", + "dashboard": "replace with the name of the dashboard. ex) project", + "panel_group": "replace with the name of the panel_group. ex) container-infra", + "panel_group_name": "replace with the name of the panel_group. ex) Container Infra", + "panel": "replace with the name of the panel in singular. ex) bay", + "panel_func": "replace with the function name for the panel in singular. ex) Bay", + "module_folder": "replace with the name of the module folder. ex) magnum_ui", + "gerrit_id": "replace with the project ID of the gerrit", + "help_name": "replace with the name of the help. ex) Magnum-UI", + "api_module": "replace with the name of the API module. ex) magnum", + "api_name": "replace with the name for calling in text. ex) Magnum" } + diff --git a/hooks/post_gen_project.sh b/hooks/post_gen_project.sh index 4fe45be..5675985 100755 --- a/hooks/post_gen_project.sh +++ b/hooks/post_gen_project.sh @@ -2,4 +2,4 @@ git init git add . -git commit -a -m "Initial Cookiecutter Commit." +git commit -a -m "Initial UI-Cookiecutter Commit." diff --git a/{{cookiecutter.repo_name}}/.coveragerc b/{{cookiecutter.repo_name}}/.coveragerc deleted file mode 100644 index 31a14a9..0000000 --- a/{{cookiecutter.repo_name}}/.coveragerc +++ /dev/null @@ -1,7 +0,0 @@ -[run] -branch = True -source = {{cookiecutter.module_name}} -omit = {{cookiecutter.module_name}}/openstack/* - -[report] -ignore_errors = True diff --git a/{{cookiecutter.repo_name}}/.eslintrc b/{{cookiecutter.repo_name}}/.eslintrc new file mode 100644 index 0000000..3057c32 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.eslintrc @@ -0,0 +1,47 @@ +# Set up globals +globals: + angular: false + +extends: openstack + +# Most environment options are not explicitly enabled or disabled, only +# included here for completeness' sake. They are commented out, because the +# global updates.py script would otherwise override them during a global +# requirements synchronization. +# +# Individual projects should choose which platforms they deploy to. + +env: + # browser global variables. + browser: true + + # Adds all of the Jasmine testing global variables for version 1.3 and 2.0. + jasmine: true + + +# Below we adjust rules specific to horizon's usage of openstack's linting +# rules, and its own plugin inclusions. +rules: + ############################################################################# + # Disabled Rules from eslint-config-openstack + ############################################################################# + valid-jsdoc: [1, { + requireParamDescription: false + }] + no-undefined: 1 + brace-style: 1 + no-extra-parens: 1 + callback-return: 1 + block-scoped-var: 1 + + ############################################################################# + # Angular Plugin Customization + ############################################################################# + + angular/controller-as-vm: + - 1 + - "ctrl" + + # Remove after migrating to angular 1.4 or later. + angular/no-cookiestore: + - 1 diff --git a/{{cookiecutter.repo_name}}/.gitignore b/{{cookiecutter.repo_name}}/.gitignore index 963e589..dc20243 100644 --- a/{{cookiecutter.repo_name}}/.gitignore +++ b/{{cookiecutter.repo_name}}/.gitignore @@ -1,58 +1,11 @@ -*.py[cod] - -# C extensions -*.so - -# Packages -*.egg* -*.egg-info -dist -build -eggs -parts -bin -var -sdist -develop-eggs -.installed.cfg -lib -lib64 - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -cover/ -.coverage* -!.coveragerc -.tox -nosetests.xml -.testrepository -.venv - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# Complexity -output/*.html -output/*/index.html - -# Sphinx -doc/build - -# pbr generates these AUTHORS ChangeLog - -# Editors -*~ -.*.swp -.*sw? - -# Files created by releasenotes build -releasenotes/build \ No newline at end of file +build +doc/source/sourcecode +{{ cookiecutter.module_folder }}/test/.secret_key_store +.venv +.tox +*.py[cod] +*.lock +*.egg* +*.swp diff --git a/{{cookiecutter.repo_name}}/.gitreview b/{{cookiecutter.repo_name}}/.gitreview index 5426828..4e7b6ee 100644 --- a/{{cookiecutter.repo_name}}/.gitreview +++ b/{{cookiecutter.repo_name}}/.gitreview @@ -1,4 +1,4 @@ [gerrit] host=review.openstack.org -port=29418 +port={{ cookiecutter.gerrit_id }} project={{cookiecutter.repo_group}}/{{cookiecutter.repo_name}}.git diff --git a/{{cookiecutter.repo_name}}/.jshintrc b/{{cookiecutter.repo_name}}/.jshintrc new file mode 100644 index 0000000..579e758 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.jshintrc @@ -0,0 +1,29 @@ +{ +"browser": true, +"esnext": true, +"predef": ["angular", "horizon", "$"], +"globalstrict": true, +"quotmark": true, +"smarttabs": true, +"strict": false, +"trailing": true, +"undef": true, +"unused": true, +"bitwise": true, +"boss": true, +"curly": true, +"eqeqeq": false, +"eqnull": true, +"evil": false, +"forin": true, +"immed": true, +"latedef": true, +"laxbreak": true, +"loopfunc": true, +"newcap": true, +"noarg": true, +"noempty": true, +"nonew": true, +"supernew": true, +"validthis": true +} \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.mailmap b/{{cookiecutter.repo_name}}/.mailmap deleted file mode 100644 index 516ae6f..0000000 --- a/{{cookiecutter.repo_name}}/.mailmap +++ /dev/null @@ -1,3 +0,0 @@ -# Format is: -# -# diff --git a/{{cookiecutter.repo_name}}/.testr.conf b/{{cookiecutter.repo_name}}/.testr.conf deleted file mode 100644 index 6d83b3c..0000000 --- a/{{cookiecutter.repo_name}}/.testr.conf +++ /dev/null @@ -1,7 +0,0 @@ -[DEFAULT] -test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ - OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ - OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ - ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION -test_id_option=--load-list $IDFILE -test_list_option=--list diff --git a/{{cookiecutter.repo_name}}/MANIFEST.in b/{{cookiecutter.repo_name}}/MANIFEST.in index c978a52..5e592be 100644 --- a/{{cookiecutter.repo_name}}/MANIFEST.in +++ b/{{cookiecutter.repo_name}}/MANIFEST.in @@ -2,5 +2,8 @@ include AUTHORS include ChangeLog exclude .gitignore exclude .gitreview +include setup.py + +recursive-include ironic_ui *.js *.html *.scss global-exclude *.pyc diff --git a/{{cookiecutter.repo_name}}/README.rst b/{{cookiecutter.repo_name}}/README.rst index b85193f..7176684 100644 --- a/{{cookiecutter.repo_name}}/README.rst +++ b/{{cookiecutter.repo_name}}/README.rst @@ -1,19 +1,64 @@ =============================== -{{ cookiecutter.repo_name }} +{{ cookiecutter.call_by_name }} =============================== {{ cookiecutter.project_short_description}} -Please fill here a long description which must be at least 3 lines wrapped on -80 cols, so that distribution package maintainers can use it in their packages. -Note that this is a hard requirement. - * Free software: Apache license -* Documentation: http://docs.openstack.org/developer/{{ cookiecutter.repo_name }} -* Source: http://git.openstack.org/cgit/{{cookiecutter.repo_group}}/{{ cookiecutter.repo_name }} -* Bugs: http://bugs.launchpad.net/{{cookiecutter.launchpad_project}} +* Source: http://git.openstack.org/cgit/{{ cookiecutter.repo_group }}/{{ cookiecutter.repo_name }} +* Bugs: http://bugs.launchpad.net/{{ cookiecutter.launchpad_project }} Features -------- * TODO + +Enabling in DevStack +-------------------- + +Add this repo as an external repository into your ``local.conf`` file:: + + [[local|localrc]] + enable_plugin {{ cookiecutter.module_name }} https://github.com/{{ cookiecutter.repo_group }}/{{ cookiecutter.repo_name }} + +Manual Installation +------------------- + +Begin by cloning the Horizon and {{ cookiecutter.call_by_name }} repositories:: + + git clone https://github.com/openstack/horizon + git clone https://github.com/{{ cookiecutter.repo_group }}/{{ cookiecutter.repo_name }} + +Create a virtual environment and install Horizon dependencies:: + + cd horizon + python tools/install_venv.py + +Set up your ``local_settings.py`` file:: + + cp openstack_dashboard/local/local_settings.py.example openstack_dashboard/local/local_settings.py + +Open up the copied ``local_settings.py`` file in your preferred text +editor. You will want to customize several settings: + +- ``OPENSTACK_HOST`` should be configured with the hostname of your + OpenStack server. Verify that the ``OPENSTACK_KEYSTONE_URL`` and + ``OPENSTACK_KEYSTONE_DEFAULT_ROLE`` settings are correct for your + environment. (They should be correct unless you modified your + OpenStack server to change them.) + +Install {{ cookiecutter.call_by_name }} with all dependencies in your virtual environment:: + + tools/with_venv.sh pip install -e ../{{ cookiecutter.repo_name }}/ + +And enable it in Horizon:: + + ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_folder }}/enabled/_90_project_{{ cookiecutter.panel_group }}_panelgroup.py openstack_dashboard/local/enabled + ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_folder }}/enabled/_91_project_{{ cookiecutter.panel_group }}_{{ cookiecutter.panel }}s_panel.py openstack_dashboard/local/enabled + +To run horizon with the newly enabled {{ cookiecutter.call_by_name }} plugin run:: + + ./run_tests.sh --runserver 0.0.0.0:8080 + +to have the application start on port 8080 and the horizon dashboard will be +available in your browser at http://localhost:8080/ diff --git a/{{cookiecutter.repo_name}}/babel-django.cfg b/{{cookiecutter.repo_name}}/babel-django.cfg new file mode 100644 index 0000000..ad09d34 --- /dev/null +++ b/{{cookiecutter.repo_name}}/babel-django.cfg @@ -0,0 +1,5 @@ +[extractors] +django = django_babel.extract:extract_django + +[python: **.py] +[django: templates/**.html] diff --git a/{{cookiecutter.repo_name}}/babel-djangojs.cfg b/{{cookiecutter.repo_name}}/babel-djangojs.cfg new file mode 100644 index 0000000..a8273b6 --- /dev/null +++ b/{{cookiecutter.repo_name}}/babel-djangojs.cfg @@ -0,0 +1,14 @@ +[extractors] +# We use a custom extractor to find translatable strings in AngularJS +# templates. The extractor is included in horizon.utils for now. +# See http://babel.pocoo.org/docs/messages/#referencing-extraction-methods for +# details on how this works. +angular = horizon.utils.babel_extract_angular:extract_angular + +[javascript: **.js] + +# We need to look into all static folders for HTML files. +# The **/static ensures that we also search within +# /openstack_dashboard/dashboards/XYZ/static which will ensure +# that plugins are also translated. +[angular: **/static/**.html] diff --git a/{{cookiecutter.repo_name}}/babel.cfg b/{{cookiecutter.repo_name}}/babel.cfg deleted file mode 100644 index 15cd6cb..0000000 --- a/{{cookiecutter.repo_name}}/babel.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[python: **.py] - diff --git a/{{cookiecutter.repo_name}}/doc/Makefile b/{{cookiecutter.repo_name}}/doc/Makefile new file mode 100644 index 0000000..e42489e --- /dev/null +++ b/{{cookiecutter.repo_name}}/doc/Makefile @@ -0,0 +1,152 @@ +# Makefile for Sphinx documentation + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/{{ cookiecutter.help_name }}.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/{{ cookiecutter.help_name }}.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/{{ cookiecutter.help_name }}" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/{{ cookiecutter.help_name }}" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." diff --git a/{{cookiecutter.repo_name}}/doc/source/conf.py b/{{cookiecutter.repo_name}}/doc/source/conf.py old mode 100755 new mode 100644 index 40ecca6..d90c42c --- a/{{cookiecutter.repo_name}}/doc/source/conf.py +++ b/{{cookiecutter.repo_name}}/doc/source/conf.py @@ -1,75 +1,441 @@ -# -*- coding: utf-8 -*- -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# See the License for the specific language governing permissions and -# limitations under the License. +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# Horizon documentation build configuration file, created by +# sphinx-quickstart on Thu Oct 27 11:38:59 2011. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +from __future__ import print_function import os +import subprocess import sys -sys.path.insert(0, os.path.abspath('../..')) +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) +ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", "..")) + +sys.path.insert(0, ROOT) + +# This is required for ReadTheDocs.org, but isn't a bad idea anyway. +os.environ.setdefault('DJANGO_SETTINGS_MODULE', + '{{ cookiecutter.module_folder }}.test.settings') + +from {{ cookiecutter.module_folder }} \ + import version as ui_ver + + +def write_autodoc_index(): + + def find_autodoc_modules(module_name, sourcedir): + """returns a list of modules in the SOURCE directory.""" + modlist = [] + os.chdir(os.path.join(sourcedir, module_name)) + print("SEARCHING %s" % sourcedir) + for root, dirs, files in os.walk("."): + for filename in files: + if filename == 'tests.py': + continue + if filename.endswith(".py"): + # remove the pieces of the root + elements = root.split(os.path.sep) + # replace the leading "." with the module name + elements[0] = module_name + # and get the base module name + base, extension = os.path.splitext(filename) + if not (base == "__init__"): + elements.append(base) + result = ".".join(elements) + # print result + modlist.append(result) + return modlist + + RSTDIR = os.path.abspath(os.path.join(BASE_DIR, "sourcecode")) + SRCS = [('{{ cookiecutter.module_folder }}', ROOT), ] + + EXCLUDED_MODULES = () + CURRENT_SOURCES = {} + + if not(os.path.exists(RSTDIR)): + os.mkdir(RSTDIR) + CURRENT_SOURCES[RSTDIR] = ['autoindex.rst'] + + INDEXOUT = open(os.path.join(RSTDIR, "autoindex.rst"), "w") + INDEXOUT.write(""" +================= +Source Code Index +================= + +.. contents:: + :depth: 1 + :local: + +""") + + for modulename, path in SRCS: + sys.stdout.write("Generating source documentation for %s\n" % + modulename) + INDEXOUT.write("\n%s\n" % modulename.capitalize()) + INDEXOUT.write("%s\n" % ("=" * len(modulename),)) + INDEXOUT.write(".. toctree::\n") + INDEXOUT.write(" :maxdepth: 1\n") + INDEXOUT.write("\n") + + MOD_DIR = os.path.join(RSTDIR, modulename) + CURRENT_SOURCES[MOD_DIR] = [] + if not(os.path.exists(MOD_DIR)): + os.mkdir(MOD_DIR) + for module in find_autodoc_modules(modulename, path): + if any([module.startswith(exclude) for exclude + in EXCLUDED_MODULES]): + print("Excluded module %s." % module) + continue + mod_path = os.path.join(path, *module.split(".")) + generated_file = os.path.join(MOD_DIR, "%s.rst" % module) + + INDEXOUT.write(" %s/%s\n" % (modulename, module)) + + # Find the __init__.py module if this is a directory + if os.path.isdir(mod_path): + source_file = ".".join((os.path.join(mod_path, "__init__"), + "py",)) + else: + source_file = ".".join((os.path.join(mod_path), "py")) + + CURRENT_SOURCES[MOD_DIR].append("%s.rst" % module) + # Only generate a new file if the source has changed or we don't + # have a doc file to begin with. + if not os.access(generated_file, os.F_OK) or ( + os.stat(generated_file).st_mtime < + os.stat(source_file).st_mtime): + print("Module %s updated, generating new documentation." + % module) + FILEOUT = open(generated_file, "w") + header = "The :mod:`%s` Module" % module + FILEOUT.write("%s\n" % ("=" * len(header),)) + FILEOUT.write("%s\n" % header) + FILEOUT.write("%s\n" % ("=" * len(header),)) + FILEOUT.write(".. automodule:: %s\n" % module) + FILEOUT.write(" :members:\n") + FILEOUT.write(" :undoc-members:\n") + FILEOUT.write(" :show-inheritance:\n") + FILEOUT.write(" :noindex:\n") + FILEOUT.close() + + INDEXOUT.close() + + # Delete auto-generated .rst files for sources which no longer exist + for directory, subdirs, files in list(os.walk(RSTDIR)): + for old_file in files: + if old_file not in CURRENT_SOURCES.get(directory, []): + print("Removing outdated file for %s" % old_file) + os.remove(os.path.join(directory, old_file)) + + +write_autodoc_index() + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# sys.path.insert(0, os.path.abspath('.')) + # -- General configuration ---------------------------------------------------- -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = [ - 'sphinx.ext.autodoc', - #'sphinx.ext.intersphinx', - 'oslosphinx' -] +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.0' -# autodoc generation is a bit aggressive and a nuisance when doing heavy -# text edit cycles. -# execute "export SPHINX_DEBUG=1" in your terminal to disable +# Add any Sphinx extension module names here, as strings. +# They can be extensions coming with Sphinx (named 'sphinx.ext.*') +# or your custom ones. +extensions = ['sphinx.ext.autodoc', + 'sphinx.ext.todo', + 'sphinx.ext.coverage', + 'sphinx.ext.viewcode', + 'oslosphinx', + ] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' +# The encoding of source files. +# source_encoding = 'utf-8-sig' + # The master toctree document. master_doc = 'index' # General information about the project. -project = u'{{cookiecutter.repo_name}}' +project = u'{{ cookiecutter.call_by_name }}' copyright = u'2016, OpenStack Foundation' +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = ui_ver.version_info.version_string() +# The full version, including alpha/beta/rc tags. +release = ui_ver.version_info.release_string() + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['**/#*', '**~', '**/#*#'] + +# The reST default role (used for this markup: `text`) +# to use for all documents. +# default_role = None + # If true, '()' will be appended to :func: etc. cross-reference text. -add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -add_module_names = True +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +primary_domain = 'py' +nitpicky = False + + # -- Options for HTML output -------------------------------------------------- -# The theme to use for HTML and HTML Help pages. Major themes that come with -# Sphinx are currently 'default' and 'sphinxdoc'. -# html_theme_path = ["."] +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# html_theme_path = ['.'] # html_theme = '_theme' -# html_static_path = ['static'] + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +html_theme_options = { + "nosidebar": "false" +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' +git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local", + "-n1"] +html_last_updated_fmt = subprocess.check_output(git_cmd, + stdin=subprocess.PIPE) + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = '%sdoc' % project +htmlhelp_basename = 'Horizondoc' + + +# -- Options for LaTeX output ------------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # 'preamble': '', +} # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ - ('index', - '%s.tex' % project, - u'%s Documentation' % project, + ('index', 'Horizon.tex', u'Horizon Documentation', u'OpenStack Foundation', 'manual'), ] -# Example configuration for intersphinx: refer to the Python standard library. -#intersphinx_mapping = {'http://docs.python.org/': None} +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output ------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', u'{{ cookiecutter.call_by_name }} Documentation', + 'Documentation for the {{ cookiecutter.call_by_name }} plugin to the Openstack\ + Dashboard (Horizon)', + [u'OpenStack'], 1) +] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ----------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'Horizon', u'Horizon Documentation', u'OpenStack', + 'Horizon', 'One line description of project.', 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + + +# -- Options for Epub output -------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = u'Horizon' +epub_author = u'OpenStack' +epub_publisher = u'OpenStack' +epub_copyright = u'2012, OpenStack' + +# The language of the text. It defaults to the language option +# or en if the language is not set. +# epub_language = '' + +# The scheme of the identifier. Typical schemes are ISBN or URL. +# epub_scheme = '' + +# The unique identifier of the text. This can be an ISBN number +# or the project homepage. +# epub_identifier = '' + +# A unique identification for the text. +# epub_uid = '' + +# A tuple containing the cover image and cover page html template filenames. +# epub_cover = () + +# HTML files that should be inserted before the pages created by sphinx. +# The format is a list of tuples containing the path and title. +# epub_pre_files = [] + +# HTML files shat should be inserted after the pages created by sphinx. +# The format is a list of tuples containing the path and title. +# epub_post_files = [] + +# A list of files that should not be packed into the epub file. +# epub_exclude_files = [] + +# The depth of the table of contents in toc.ncx. +# epub_tocdepth = 3 + +# Allow duplicate toc entries. +# epub_tocdup = True diff --git a/{{cookiecutter.repo_name}}/doc/source/contributing.rst b/{{cookiecutter.repo_name}}/doc/source/contributing.rst deleted file mode 100644 index 1728a61..0000000 --- a/{{cookiecutter.repo_name}}/doc/source/contributing.rst +++ /dev/null @@ -1,4 +0,0 @@ -============ -Contributing -============ -.. include:: ../../CONTRIBUTING.rst diff --git a/{{cookiecutter.repo_name}}/doc/source/index.rst b/{{cookiecutter.repo_name}}/doc/source/index.rst index a5a7edd..773d1d7 100644 --- a/{{cookiecutter.repo_name}}/doc/source/index.rst +++ b/{{cookiecutter.repo_name}}/doc/source/index.rst @@ -1,25 +1,84 @@ -.. {{ cookiecutter.repo_name }} documentation master file, created by - sphinx-quickstart on Tue Jul 9 22:26:36 2013. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. +=============================== +{{ cookiecutter.call_by_name }} +=============================== -Welcome to {{ cookiecutter.repo_name }}'s documentation! -======================================================== +{{ cookiecutter.project_short_description}} -Contents: +* Free software: Apache license +* Source: http://git.openstack.org/cgit/{{ cookiecutter.repo_group }}/{{ cookiecutter.repo_name }} +* Bugs: http://bugs.launchpad.net/{{ cookiecutter.launchpad_project }} + +Features +-------- + +* TODO + +Enabling in DevStack +-------------------- + +Add this repo as an external repository into your ``local.conf`` file:: + + [[local|localrc]] + enable_plugin {{ cookiecutter.module_name }} https://github.com/{{ cookiecutter.repo_group }}/{{ cookiecutter.repo_name }} + +Manual Installation +------------------- + +Begin by cloning the Horizon and {{ cookiecutter.call_by_name }} repositories:: + + git clone https://github.com/openstack/horizon + git clone https://github.com/{{ cookiecutter.repo_group }}/{{ cookiecutter.repo_name }} + +Create a virtual environment and install Horizon dependencies:: + + cd horizon + python tools/install_venv.py + +Set up your ``local_settings.py`` file:: + + cp openstack_dashboard/local/local_settings.py.example openstack_dashboard/local/local_settings.py + +Open up the copied ``local_settings.py`` file in your preferred text +editor. You will want to customize several settings: + +- ``OPENSTACK_HOST`` should be configured with the hostname of your + OpenStack server. Verify that the ``OPENSTACK_KEYSTONE_URL`` and + ``OPENSTACK_KEYSTONE_DEFAULT_ROLE`` settings are correct for your + environment. (They should be correct unless you modified your + OpenStack server to change them.) + +Install {{ cookiecutter.call_by_name }} with all dependencies in your virtual environment:: + + tools/with_venv.sh pip install -e ../{{ cookiecutter.repo_name }}/ + +And enable it in Horizon:: + + ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_folder }}/enabled/_90_project_{{ cookiecutter.panel_group }}_panelgroup.py openstack_dashboard/local/enabled + ln -s ../{{ cookiecutter.repo_name }}/{{ cookiecutter.module_folder }}/enabled/_91_project_{{ cookiecutter.panel_group }}_{{ cookiecutter.panel }}s_panel.py openstack_dashboard/local/enabled + +To run horizon with the newly enabled {{ cookiecutter.call_by_name }} plugin run:: + + ./run_tests.sh --runserver 0.0.0.0:8080 + +to have the application start on port 8080 and the horizon dashboard will be +available in your browser at http://localhost:8080/ + +Release Notes +============= .. toctree:: - :maxdepth: 2 + :glob: + :maxdepth: 1 - readme - installation - usage - contributing + releases/* -Indices and tables -================== +Source Code Reference +===================== + +.. toctree:: + :glob: + :maxdepth: 1 + + sourcecode/autoindex -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/{{cookiecutter.repo_name}}/doc/source/installation.rst b/{{cookiecutter.repo_name}}/doc/source/installation.rst deleted file mode 100644 index 98401a0..0000000 --- a/{{cookiecutter.repo_name}}/doc/source/installation.rst +++ /dev/null @@ -1,12 +0,0 @@ -============ -Installation -============ - -At the command line:: - - $ pip install {{ cookiecutter.repo_name }} - -Or, if you have virtualenvwrapper installed:: - - $ mkvirtualenv {{ cookiecutter.repo_name }} - $ pip install {{ cookiecutter.repo_name }} diff --git a/{{cookiecutter.repo_name}}/doc/source/readme.rst b/{{cookiecutter.repo_name}}/doc/source/readme.rst deleted file mode 100644 index a6210d3..0000000 --- a/{{cookiecutter.repo_name}}/doc/source/readme.rst +++ /dev/null @@ -1 +0,0 @@ -.. include:: ../../README.rst diff --git a/{{cookiecutter.repo_name}}/doc/source/releases/0.1.0.rst b/{{cookiecutter.repo_name}}/doc/source/releases/0.1.0.rst new file mode 100644 index 0000000..9d4dbc5 --- /dev/null +++ b/{{cookiecutter.repo_name}}/doc/source/releases/0.1.0.rst @@ -0,0 +1,2 @@ +{{ cookiecutter.call_by_name }} 0.1.0 +=============================== diff --git a/{{cookiecutter.repo_name}}/doc/source/usage.rst b/{{cookiecutter.repo_name}}/doc/source/usage.rst deleted file mode 100644 index 03a1606..0000000 --- a/{{cookiecutter.repo_name}}/doc/source/usage.rst +++ /dev/null @@ -1,7 +0,0 @@ -======== -Usage -======== - -To use {{ cookiecutter.repo_name }} in a project:: - - import {{ cookiecutter.module_name }} diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/__init__.py b/{{cookiecutter.repo_name}}/manage.py old mode 100644 new mode 100755 similarity index 64% rename from {{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/__init__.py rename to {{cookiecutter.repo_name}}/manage.py index 5988b44..2c4d28a --- a/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/__init__.py +++ b/{{cookiecutter.repo_name}}/manage.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +#!/usr/bin/env python # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -12,8 +12,12 @@ # License for the specific language governing permissions and limitations # under the License. -import pbr.version +import os +import sys +from django.core.management import execute_from_command_line # noqa -__version__ = pbr.version.VersionInfo( - '{{cookiecutter.module_name}}').version_string() +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", + "{{ cookiecutter.module_folder }}.test.settings") + execute_from_command_line(sys.argv) diff --git a/{{cookiecutter.repo_name}}/releasenotes/source/conf.py b/{{cookiecutter.repo_name}}/releasenotes/source/conf.py index c2a125d..5527d3a 100644 --- a/{{cookiecutter.repo_name}}/releasenotes/source/conf.py +++ b/{{cookiecutter.repo_name}}/releasenotes/source/conf.py @@ -55,7 +55,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'{{cookiecutter.module_name}} Release Notes' +project = u'{{cookiecutter.call_by_name }} Release Notes' copyright = u'2016, OpenStack Foundation' # The version info for the project you're documenting, acts as replacement for @@ -189,7 +189,7 @@ html_static_path = ['_static'] # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'GlanceReleaseNotesdoc' +htmlhelp_basename = '{{cookiecutter.help_name }}ReleaseNotesdoc' # -- Options for LaTeX output --------------------------------------------- @@ -209,8 +209,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - ('index', 'GlanceReleaseNotes.tex', u'Glance Release Notes Documentation', - u'Glance Developers', 'manual'), + ('index', '{{cookiecutter.help_name }}ReleaseNotes.tex', u'{{cookiecutter.call_by_name }} Release Notes Documentation', + u'{{cookiecutter.call_by_name }} Developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -239,8 +239,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'glancereleasenotes', u'Glance Release Notes Documentation', - [u'Glance Developers'], 1) + ('index', '{{cookiecutter.module_name }}releasenotes', u'{{cookiecutter.call_by_name }} Release Notes Documentation', + [u'{{cookiecutter.call_by_name }} Developers'], 1) ] # If true, show URL addresses after external links. @@ -253,8 +253,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'GlanceReleaseNotes', u'Glance Release Notes Documentation', - u'Glance Developers', 'GlanceReleaseNotes', + ('index', '{{cookiecutter.help_name }}ReleaseNotes', u'{{cookiecutter.call_by_name }} Release Notes Documentation', + u'{{cookiecutter.call_by_name }} Developers', '{{cookiecutter.help_name }}ReleaseNotes', 'One line description of project.', 'Miscellaneous'), ] diff --git a/{{cookiecutter.repo_name}}/requirements.txt b/{{cookiecutter.repo_name}}/requirements.txt index 30806d5..1a0af2c 100644 --- a/{{cookiecutter.repo_name}}/requirements.txt +++ b/{{cookiecutter.repo_name}}/requirements.txt @@ -1,5 +1,40 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. - -pbr>=1.6 +# Order matters to the pip dependency resolver, so sorting this file +# changes how packages are installed. New dependencies should be +# added in alphabetical order, however, some dependencies may need to +# be installed in a specific order. +# +# PBR should always appear first +pbr>=1.6 # Apache-2.0 +# If python-higginsclient will be created, we will use it. +#python-higginsclient>=0.1.0 # Apache-2.0 +Babel>=2.3.4 # BSD +Django<1.9,>=1.8 # BSD +django-babel>=0.5.1 # BSD +django-compressor>=2.0 # MIT +django-openstack-auth>=2.2.0 # Apache-2.0 +django-pyscss>=2.0.2 # BSD License (2 clause) +XStatic>=1.0.0 # MIT License +XStatic-Angular>=1.3.7 # MIT License +XStatic-Angular-Bootstrap>=0.11.0.2 # MIT License +XStatic-Angular-Gettext>=2.1.0.2 # MIT License +XStatic-Angular-lrdragndrop>=1.0.2.2 # MIT License +XStatic-Bootstrap-Datepicker>=1.3.1.0 # Apache 2.0 License +XStatic-Bootstrap-SCSS>=3 # Apache 2.0 License +XStatic-D3>=3.1.6.2 # BSD License (3 clause) +XStatic-Hogan>=2.0.0.2 # Apache 2.0 License +XStatic-Font-Awesome>=4.3.0 # SIL OFL 1.1 License, MIT License +XStatic-Jasmine>=2.1.2.0 # MIT License +XStatic-jQuery>=1.7.2 # MIT License +XStatic-JQuery-Migrate>=1.2.1.1 # MIT License +XStatic-JQuery.quicksearch>=2.0.3.1 # MIT License +XStatic-JQuery.TableSorter>=2.14.5.1 # MIT License +XStatic-jquery-ui>=1.10.1 # MIT License +XStatic-JSEncrypt>=2.0.0.2 # MIT License +XStatic-Magic-Search>=0.2.5.1 # Apache 2.0 License +XStatic-Rickshaw>=1.5.0 # BSD License (prior) +XStatic-smart-table>=1.4.5.3 # MIT License +XStatic-Spin>=1.2.5.2 # MIT License +XStatic-term.js>=0.0.4 # MIT License diff --git a/{{cookiecutter.repo_name}}/setup.cfg b/{{cookiecutter.repo_name}}/setup.cfg index 70216f0..3b7ec80 100644 --- a/{{cookiecutter.repo_name}}/setup.cfg +++ b/{{cookiecutter.repo_name}}/setup.cfg @@ -16,36 +16,8 @@ classifier = Programming Language :: Python :: 2 Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 - Programming Language :: Python :: 3.3 Programming Language :: Python :: 3.4 [files] packages = {{ cookiecutter.module_name }} - -[build_sphinx] -source-dir = doc/source -build-dir = doc/build -all_files = 1 - -[upload_sphinx] -upload-dir = doc/build/html - -[compile_catalog] -directory = {{cookiecutter.module_name}}/locale -domain = {{cookiecutter.module_name}} - -[update_catalog] -domain = {{cookiecutter.module_name}} -output_dir = {{cookiecutter.module_name}}/locale -input_file = {{cookiecutter.module_name}}/locale/{{cookiecutter.module_name}}.pot - -[extract_messages] -keywords = _ gettext ngettext l_ lazy_gettext -mapping_file = babel.cfg -output_file = {{cookiecutter.module_name}}/locale/{{cookiecutter.module_name}}.pot - -[build_releasenotes] -all_files = 1 -build-dir = releasenotes/build -source-dir = releasenotes/source \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/setup.py b/{{cookiecutter.repo_name}}/setup.py index 056c16c..ddd1771 100644 --- a/{{cookiecutter.repo_name}}/setup.py +++ b/{{cookiecutter.repo_name}}/setup.py @@ -1,5 +1,3 @@ -# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. -# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -25,5 +23,5 @@ except ImportError: pass setuptools.setup( - setup_requires=['pbr'], + setup_requires=['pbr>=1.8'], pbr=True) diff --git a/{{cookiecutter.repo_name}}/test-requirements.txt b/{{cookiecutter.repo_name}}/test-requirements.txt index d354162..36a464c 100644 --- a/{{cookiecutter.repo_name}}/test-requirements.txt +++ b/{{cookiecutter.repo_name}}/test-requirements.txt @@ -1,17 +1,32 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. - -hacking<0.11,>=0.10.0 - -coverage>=3.6 -python-subunit>=0.0.18 -sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 -oslosphinx>=2.5.0 # Apache-2.0 -oslotest>=1.10.0 # Apache-2.0 -testrepository>=0.0.18 -testscenarios>=0.4 -testtools>=1.4.0 +# Order matters to the pip dependency resolver, so sorting this file +# changes how packages are installed. New dependencies should be +# added in alphabetical order, however, some dependencies may need to +# be installed in a specific order. +# +# Hacking should appear first in case something else depends on pep8 +hacking<0.11,>=0.10.2 +# +coverage>=3.6 # Apache-2.0 +django-nose>=1.2 # BSD +mock>=2.0 # BSD +mox3>=0.7.0 # Apache-2.0 +nodeenv>=0.9.4 # BSD License # BSD +nose # LGPL +nose-exclude # LGPL +nosehtmloutput>=0.0.3 # Apache-2.0 +nosexcover # BSD +openstack.nose-plugin>=0.7 # Apache-2.0 +oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0 +selenium>=2.50.1 # Apache-2.0 +sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD +testtools>=1.4.0 # MIT +# This also needs xvfb library installed on your OS +xvfbwrapper>=0.1.3 #license: MIT +# Include horizon as test requirement +http://tarballs.openstack.org/horizon/horizon-master.tar.gz#egg=horizon # releasenotes reno>=1.6.2 # Apache2 diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/__init__.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/__init__.py similarity index 100% rename from {{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/__init__.py rename to {{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/__init__.py diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/__init__.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/client.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/client.py new file mode 100644 index 0000000..7392230 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/client.py @@ -0,0 +1,113 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +from __future__ import absolute_import +import logging +#from {{cookiecutter.api_module}}client.v1 import client as {{cookiecutter.api_module}}_client + +from horizon import exceptions +from horizon.utils.memoized import memoized +from openstack_dashboard.api import base + +# for stab, should remove when use CLI API +import copy +import uuid + + +LOG = logging.getLogger(__name__) + +CREATE_ATTRS = ['name'] + +STUB_DATA = {} + +# for stab, should be removed when use CLI API +class StubResponse(object): + + def __init__(self, info): + self._info = info + + def __repr__(self): + reprkeys = sorted(k for k in self.__dict__.keys() if k[0] != '_') + info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys) + return "<%s %s>" % (self.__class__.__name__, info) + + def to_dict(self): + return copy.deepcopy(self._info) + + +@memoized +def apiclient(request): + api_url = "" + """" + try: + api_url = base.url_for(request, '{{cookiecutter.panel}}') + except exceptions.ServiceCatalogException: + LOG.debug('No {{cookiecutter.panel_func}} Management service is configured.') + return None + + LOG.debug('{{cookiecutter.api_module}}client connection created using the token "%s" and url' + '"%s"' % (request.user.token.id, api_url)) + c = {{cookiecutter.api_module}}_client.Client(username=request.user.username, + project_id=request.user.tenant_id, + input_auth_token=request.user.token.id, + api_url=api_url) + return c + """ + + +def {{cookiecutter.panel}}_create(request, **kwargs): + args = {} + for (key, value) in kwargs.items(): + if key in CREATE_ATTRS: + args[str(key)] = str(value) + else: + raise exceptions.BadRequest( + "Key must be in %s" % ",".join(CREATE_ATTRS)) + if key == "labels": + labels = {} + vals = value.split(",") + for v in vals: + kv = v.split("=", 1) + labels[kv[0]] = kv[1] + args["labels"] = labels + #created = apiclient(request).{{cookiecutter.panel}}s.create(**args) + + # create dummy response + args["uuid"] = uuid.uuid1().hex + created = StubResponse(args) + for k in args: + setattr(created, k, args[k]) + STUB_DATA[created.uuid] = created + + return created + + +def {{cookiecutter.panel}}_delete(request, id): + #deleted = apiclient(request).{{cookiecutter.panel}}s.delete(id) + deleted = STUB_DATA.pop(id) + + return deleted + + +def {{cookiecutter.panel}}_list(request, limit=None, marker=None, sort_key=None, + sort_dir=None, detail=True): + #list = apiclient(request).{{cookiecutter.panel_func}}s.list(limit, marker, sort_key, + # sort_dir, detail) + list = [STUB_DATA[data] for data in STUB_DATA] + return list + + +def {{cookiecutter.panel}}_show(request, id): + #show = apiclient(request).{{cookiecutter.panel}}s.get(id) + show = STUB_DATA.get(id) + return show diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/rest_api.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/rest_api.py new file mode 100644 index 0000000..4ef4ccb --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/api/rest_api.py @@ -0,0 +1,75 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from django.views import generic + +from {{cookiecutter.module_folder}}.api import client + +from openstack_dashboard.api.rest import urls +from openstack_dashboard.api.rest import utils as rest_utils + + +def change_to_id(obj): + """Change key named 'uuid' to 'id' + + API returns objects with a field called 'uuid' many of Horizons + directives however expect objects to have a field called 'id'. + """ + obj['id'] = obj.pop('uuid') + return obj + + +@urls.register +class {{cookiecutter.panel_func}}(generic.View): + """API for retrieving a single {{cookiecutter.panel_func}}""" + url_regex = r'{{cookiecutter.api_module}}/{{cookiecutter.panel}}s/(?P[^/]+)$' + + @rest_utils.ajax() + def get(self, request, id): + """Get a specific {{cookiecutter.panel}}""" + return change_to_id(client.{{cookiecutter.panel}}_show(request, id).to_dict()) + + +@urls.register +class {{cookiecutter.panel_func}}s(generic.View): + """API for {{cookiecutter.panel_func}}s""" + url_regex = r'{{cookiecutter.api_module}}/{{cookiecutter.panel}}s/$' + + @rest_utils.ajax() + def get(self, request): + """Get a list of the {{cookiecutter.panel_func}}s for a project. + + The returned result is an object with property 'items' and each + item under this is a {{cookiecutter.panel_func}}. + """ + result = client.{{cookiecutter.panel}}_list(request) + return {'items': [change_to_id(n.to_dict()) for n in result]} + + @rest_utils.ajax(data_required=True) + def delete(self, request): + """Delete one or more {{cookiecutter.panel_func}}s by id. + + Returns HTTP 204 (no content) on successful deletion. + """ + for id in request.DATA: + client.{{cookiecutter.panel}}_delete(request, id) + + @rest_utils.ajax(data_required=True) + def post(self, request): + """Create a new {{cookiecutter.panel_func}}. + + Returns the new {{cookiecutter.panel_func}} object on success. + """ + new_resource = client.{{cookiecutter.panel}}_create(request, **request.DATA) + return rest_utils.CreatedResponse( + '/api/{{cookiecutter.api_module}}/{{cookiecutter.panel}}/%s' % new_resource.uuid, + new_resource.to_dict()) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/__init__.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/__init__.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/panel.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/panel.py new file mode 100644 index 0000000..0e4302b --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/panel.py @@ -0,0 +1,22 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from django.utils.translation import ugettext_lazy as _ +import horizon + +# This panel will be loaded from horizon, because specified in enabled file. +# To register REST api, import below here. +from {{cookiecutter.module_folder}}.api import rest_api # noqa + +class {{cookiecutter.panel_func}}s(horizon.Panel): + name = _("{{cookiecutter.panel_func}}s") + slug = "{{cookiecutter.panel}}s" diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/tests.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/tests.py new file mode 100644 index 0000000..30622d0 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/tests.py @@ -0,0 +1,19 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from openstack_dashboard.test import helpers as test + + +class {{cookiecutter.panel_func}}sTests(test.TestCase): + # Unit tests for {{cookiecutter.panel}}. + def test_me(self): + self.assertTrue(1 + 1 == 2) diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/urls.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/urls.py new file mode 100644 index 0000000..a789007 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/urls.py @@ -0,0 +1,19 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from django.conf.urls import url +from {{cookiecutter.module_folder}}.content.{{cookiecutter.panel}}s.views import IndexView + + +urlpatterns = [ + url('', IndexView.as_view(), name='index'), +] diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/views.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/views.py new file mode 100644 index 0000000..82a7949 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/content/{{cookiecutter.panel}}s/views.py @@ -0,0 +1,17 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from django.views import generic + + +class IndexView(generic.TemplateView): + template_name = 'angular.html' diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/enabled/_90_{{cookiecutter.dashboard}}_{{cookiecutter.panel_group}}_panelgroup.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/enabled/_90_{{cookiecutter.dashboard}}_{{cookiecutter.panel_group}}_panelgroup.py new file mode 100644 index 0000000..6656b29 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/enabled/_90_{{cookiecutter.dashboard}}_{{cookiecutter.panel_group}}_panelgroup.py @@ -0,0 +1,36 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from django.utils.translation import ugettext_lazy as _ + +# The slug of the panel group to be added to HORIZON_CONFIG. Required. +PANEL_GROUP = '{{cookiecutter.panel_group}}' +# The display name of the PANEL_GROUP. Required. +PANEL_GROUP_NAME = _('{{cookiecutter.panel_group_name}}') +# The slug of the dashboard the PANEL_GROUP associated with. Required. +PANEL_GROUP_DASHBOARD = '{{cookiecutter.dashboard}}' + +ADD_INSTALLED_APPS = ['{{cookiecutter.module_folder}}'] + +ADD_ANGULAR_MODULES = [ + 'horizon.dashboard.{{cookiecutter.panel_group}}' +] + +ADD_JS_FILES = [ + 'horizon/lib/angular/angular-route.js' +] + +ADD_SCSS_FILES = [ + 'dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.scss' +] + +AUTO_DISCOVER_STATIC_FILES = True diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/enabled/_91_{{cookiecutter.dashboard}}_{{cookiecutter.panel_group}}_{{cookiecutter.panel}}s_panel.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/enabled/_91_{{cookiecutter.dashboard}}_{{cookiecutter.panel_group}}_{{cookiecutter.panel}}s_panel.py new file mode 100644 index 0000000..519d8f6 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/enabled/_91_{{cookiecutter.dashboard}}_{{cookiecutter.panel_group}}_{{cookiecutter.panel}}s_panel.py @@ -0,0 +1,21 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +# The slug of the panel to be added to HORIZON_CONFIG. Required. +PANEL = '{{cookiecutter.panel}}s' +# The slug of the panel group the PANEL is associated with. +PANEL_GROUP = '{{cookiecutter.panel_group}}' +# The slug of the dashboard the PANEL associated with. Required. +PANEL_DASHBOARD = '{{cookiecutter.dashboard}}' + +# Python panel class of the PANEL to be added. +ADD_PANEL = '{{cookiecutter.module_folder}}.content.{{cookiecutter.panel}}s.panel.{{cookiecutter.panel_func}}s' diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/models.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/models.py new file mode 100644 index 0000000..1b3d5f9 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/models.py @@ -0,0 +1,3 @@ +""" +Stub file to work around django bug: https://code.djangoproject.com/ticket/7198 +""" diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.api_module}}.service.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.api_module}}.service.js new file mode 100644 index 0000000..70235aa --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.api_module}}.service.js @@ -0,0 +1,79 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function () { + 'use strict'; + + angular + .module('horizon.app.core.openstack-service-api') + .factory('horizon.app.core.openstack-service-api.{{cookiecutter.api_module}}', API); + + API.$inject = [ + 'horizon.framework.util.http.service', + 'horizon.framework.widgets.toast.service', + 'horizon.framework.util.i18n.gettext' + ]; + + function API(apiService, toastService, gettext) { + var service = { + create{{cookiecutter.panel_func}}: create{{cookiecutter.panel_func}}, + get{{cookiecutter.panel_func}}: get{{cookiecutter.panel_func}}, + get{{cookiecutter.panel_func}}s: get{{cookiecutter.panel_func}}s, + delete{{cookiecutter.panel_func}}: delete{{cookiecutter.panel_func}}, + delete{{cookiecutter.panel_func}}s: delete{{cookiecutter.panel_func}}s, + }; + + return service; + + /////////////// + // {{cookiecutter.panel_func}}s // + /////////////// + + function create{{cookiecutter.panel_func}}(params) { + return apiService.post('/api/{{cookiecutter.api_module}}/{{cookiecutter.panel}}s/', params) + .error(function() { + toastService.add('error', gettext('Unable to create {{cookiecutter.panel_func}}')); + }); + } + + function get{{cookiecutter.panel_func}}(id) { + return apiService.get('/api/{{cookiecutter.api_module}}/{{cookiecutter.panel}}s/' + id) + .error(function() { + toastService.add('error', gettext('Unable to retrieve the {{cookiecutter.panel_func}}.')); + }); + } + + function get{{cookiecutter.panel_func}}s() { + return apiService.get('/api/{{cookiecutter.api_module}}/{{cookiecutter.panel}}s/') + .error(function() { + toastService.add('error', gettext('Unable to retrieve the {{cookiecutter.panel_func}}s.')); + }); + } + + function delete{{cookiecutter.panel_func}}(id, suppressError) { + var promise = apiService.delete('/api/{{cookiecutter.api_module}}/{{cookiecutter.panel}}s/', [id]); + return suppressError ? promise : promise.error(function() { + var msg = gettext('Unable to delete the {{cookiecutter.panel_func}} with id: %(id)s'); + toastService.add('error', interpolate(msg, { id: id }, true)); + }); + } + + // FIXME(shu-mutou): Unused for batch-delete in Horizon framework in Feb, 2016. + function delete{{cookiecutter.panel_func}}s(ids) { + return apiService.delete('/api/{{cookiecutter.api_module}}/{{cookiecutter.panel}}s/', ids) + .error(function() { + toastService.add('error', gettext('Unable to delete the {{cookiecutter.panel_func}}s.')); + }) + } + } +}()); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.module.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.module.js new file mode 100644 index 0000000..eae6b1f --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.module.js @@ -0,0 +1,37 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngdoc overview + * @name horizon.dashboard.{{cookiecutter.panel_group}} + * @description + * Dashboard module to host various {{cookiecutter.panel_group}} panels. + */ + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}', [ + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s', + 'ngRoute' + ]) + .config(config) + + config.$inject = ['$provide', '$windowProvider', '$routeProvider']; + + function config($provide, $windowProvider, $routeProvider) { + var path = $windowProvider.$get().STATIC_URL + 'dashboard/{{cookiecutter.panel_group}}/'; + $provide.constant('horizon.dashboard.{{cookiecutter.panel_group}}.basePath', path); + } +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.module.spec.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.module.spec.js new file mode 100644 index 0000000..fe66692 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.module.spec.js @@ -0,0 +1,23 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +(function() { + 'use strict'; + + describe('horizon.dashboard.{{cookiecutter.panel_group}}', function() { + it('should exist', function() { + expect(angular.module('horizon.dashboard.{{cookiecutter.panel_group}}')).toBeDefined(); + }); + }); + +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.scss b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.scss new file mode 100644 index 0000000..94a14b6 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel_group}}.scss @@ -0,0 +1,8 @@ +@import "{{cookiecutter.panel}}s/{{cookiecutter.panel}}s"; + +.batch-action { + float: right; + action-list { + padding-left: 0.3em; + } +} diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/actions.module.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/actions.module.js new file mode 100644 index 0000000..4938751 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/actions.module.js @@ -0,0 +1,73 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngdoc overview + * @ngname horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.actions + * + * @description + * Provides all of the actions for {{cookiecutter.panel_func}}s. + */ + angular.module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.actions', ['horizon.framework', 'horizon.dashboard.{{cookiecutter.panel_group}}']) + .run(register); + + register.$inject = [ + 'horizon.framework.conf.resource-type-registry.service', + 'horizon.framework.util.i18n.gettext', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.create.service', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.delete.service', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.resourceType', + ]; + + function register{{cookiecutter.panel_func}}Actions( + registry, + gettext, + create{{cookiecutter.panel_func}}Service, + delete{{cookiecutter.panel_func}}Service, + resourceType) + { + var {{cookiecutter.panel}}sResourceType = registry.getResourceType(resourceType); + {{cookiecutter.panel}}sResourceType.itemActions + .append({ + id: 'delete{{cookiecutter.panel_func}}Action', + service: delete{{cookiecutter.panel_func}}Service, + template: { + type: 'delete', + text: gettext('Delete {{cookiecutter.panel_func}}') + } + }); + + {{cookiecutter.panel}}sResourceType.batchActions + .append({ + id: 'create{{cookiecutter.panel_func}}Action', + service: create{{cookiecutter.panel_func}}Service, + template: { + type: 'create', + text: gettext('Create {{cookiecutter.panel_func}}') + } + }) + .append({ + id: 'batchDelete{{cookiecutter.panel_func}}Action', + service: delete{{cookiecutter.panel_func}}Service, + template: { + type: 'delete-selected', + text: gettext('Delete {{cookiecutter.panel_func}}s') + } + }); + } + +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/create-workflow.service.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/create-workflow.service.js new file mode 100644 index 0000000..52ba673 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/create-workflow.service.js @@ -0,0 +1,50 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s') + .factory('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.workflow', {{cookiecutter.panel}}Workflow); + + {{cookiecutter.panel}}Workflow.$inject = [ + 'horizon.dashboard.{{cookiecutter.panel_group}}.basePath', + 'horizon.app.core.workflow.factory', + 'horizon.framework.util.i18n.gettext' + ]; + + function {{cookiecutter.panel}}Workflow(basePath, dashboardWorkflow, gettext) { + return dashboardWorkflow({ + title: gettext('Create {{cookiecutter.panel_func}}'), + + steps: [ + { + title: gettext('Info'), + templateUrl: basePath + '{{cookiecutter.panel}}s/create/info/info.html', + helpUrl: basePath + '{{cookiecutter.panel}}s/create/info/info.help.html', + formName: '{{cookiecutter.panel}}InfoForm' + } + ], + + btnText: { + finish: gettext('Create') + }, + + btnIcon: { + finish: 'fa fa-check' + } + }); + } +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/create.service.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/create.service.js new file mode 100644 index 0000000..70ebbe1 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/create.service.js @@ -0,0 +1,100 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngdoc overview + * @name horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.create.service + * @description Service for the {{cookiecutter.panel}} create modal + */ + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s') + .factory('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.create.service', createService); + + createService.$inject = [ + '$location', + 'horizon.app.core.openstack-service-api.policy', + 'horizon.framework.util.actions.action-result.service', + 'horizon.framework.util.i18n.gettext', + 'horizon.framework.util.q.extensions', + 'horizon.framework.widgets.modal.wizard-modal.service', + 'horizon.framework.widgets.toast.service', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.{{cookiecutter.panel}}Model', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.events', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.resourceType', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.workflow' + ]; + + function createService( + $location, policy, actionResult, gettext, $qExtensions, wizardModalService, toast, model, events, resourceType, createWorkflow + ) { + + var scope; + var message = { + success: gettext('{{cookiecutter.panel_func}} %s was successfully created.') + }; + + var service = { + initScope: initScope, + perform: perform, + allowed: allowed + }; + + return service; + + ////////////// + + function initScope($scope) { + scope = $scope; + scope.workflow = createWorkflow; + scope.model = model; + scope.$on('$destroy', function() { + }); + } + + function perform(selected) { + scope.model.init(); + // for creation according to selected item + scope.selected = selected; + return wizardModalService.modal({ + scope: scope, + workflow: createWorkflow, + submit: submit + }).result; + } + + function allowed() { + return $qExtensions.booleanAsPromise(true); + //return policy.ifAllowed({ rules: [['{{cookiecutter.panel}}', 'add_{{cookiecutter.panel}}']] }); + } + + function submit(){ + return model.create{{cookiecutter.panel_func}}().then(success); + } + + function success(response) { + response.data.id = response.data.uuid; + toast.add('success', interpolate(message.success, [response.data.id])); + var result = actionResult.getActionResult() + .created(resourceType, response.data.id); + if(result.result.failed.length == 0 && result.result.created.length > 0){ + $location.path('/{{cookiecutter.dashboard}}/{{cookiecutter.panel}}s'); + }else{ + return result.result; + } + } + } +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/info.help.html b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/info.help.html new file mode 100644 index 0000000..8ec957c --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/info.help.html @@ -0,0 +1,4 @@ +
+
{{cookiecutter.panel_func}} Name
+
An arbitrary human-readable name
+
diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/info.html b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/info.html new file mode 100644 index 0000000..07532fc --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/info.html @@ -0,0 +1,12 @@ +
+
+
+
+ + +
+
+
+
diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/{{cookiecutter.panel}}.info.controller.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/{{cookiecutter.panel}}.info.controller.js new file mode 100644 index 0000000..aab4dc1 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/info/{{cookiecutter.panel}}.info.controller.js @@ -0,0 +1,40 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngdoc controller + * @name create{{cookiecutter.panel_func}}InfoController + * @ngController + * @description + * Controller for the {{cookiecutter.panel}} info step in create workflow + */ + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s') + .controller('create{{cookiecutter.panel_func}}InfoController', create{{cookiecutter.panel_func}}InfoController); + + create{{cookiecutter.panel_func}}InfoController.$inject = [ + '$q', + '$scope', + 'horizon.dashboard.{{cookiecutter.panel_group}}.basePath', + 'horizon.app.core.openstack-service-api.{{cookiecutter.api_module}}', + 'horizon.framework.util.i18n.gettext' + ]; + + function create{{cookiecutter.panel_func}}InfoController($q, $scope, basePath, api, gettext) { + var ctrl = this; + } +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/{{cookiecutter.panel}}-model.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/{{cookiecutter.panel}}-model.js new file mode 100644 index 0000000..6ad6647 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/create/{{cookiecutter.panel}}-model.js @@ -0,0 +1,67 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s') + .factory('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.{{cookiecutter.panel}}Model', {{cookiecutter.panel}}Model); + + {{cookiecutter.panel}}Model.$inject = [ + 'horizon.app.core.openstack-service-api.{{cookiecutter.api_module}}' + ]; + + function {{cookiecutter.panel}}Model(api) { + var model = { + newSpec: {}, + + // API methods + init: init, + create{{cookiecutter.panel_func}}: create{{cookiecutter.panel_func}} + }; + + function initNewSpec() { + model.newSpec = { + name: null, + }; + } + + function init() { + // Reset the new {{cookiecutter.panel_func}} spec + initNewSpec(); + } + + function create{{cookiecutter.panel_func}}() { + var finalSpec = angular.copy(model.newSpec); + + cleanNullProperties(finalSpec); + + return api.create{{cookiecutter.panel_func}}(finalSpec); + } + + function cleanNullProperties(finalSpec) { + // Initially clean fields that don't have any value. + // Not only "null", blank too. + for (var key in finalSpec) { + if (finalSpec.hasOwnProperty(key) && finalSpec[key] === null + || finalSpec[key] === "") { + delete finalSpec[key]; + } + } + } + + return model; + } +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/delete/delete.service.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/delete/delete.service.js new file mode 100644 index 0000000..d8bfed4 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/delete/delete.service.js @@ -0,0 +1,151 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use self file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s') + .factory('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.delete.service', deleteService); + + deleteService.$inject = [ + '$location', + '$q', + 'horizon.app.core.openstack-service-api.{{cookiecutter.api_module}}', + 'horizon.app.core.openstack-service-api.policy', + 'horizon.framework.util.actions.action-result.service', + 'horizon.framework.util.i18n.gettext', + 'horizon.framework.util.q.extensions', + 'horizon.framework.widgets.modal.deleteModalService', + 'horizon.framework.widgets.toast.service', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.resourceType', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.events' + ]; + + /** + * @ngDoc factory + * @name horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.delete.service + * @Description + * Brings up the delete {{cookiecutter.panel}}s confirmation modal dialog. + * On submit, delete selected resources. + * On cancel, do nothing. + */ + function deleteService( + $location, $q, api, policy, actionResult, gettext, $qExtensions, deleteModal, toast, resourceType, events + ) { + var scope; + var context = { + labels: null, + deleteEntity: deleteEntity, + successEvent: events.DELETE_SUCCESS + }; + var service = { + initScope: initScope, + allowed: allowed, + perform: perform + }; + var notAllowedMessage = gettext("You are not allowed to delete {{cookiecutter.panel}}s: %s"); + + return service; + + ////////////// + + // include this function in your service + // if you plan to emit events to the parent controller + function initScope($scope) { + scope = $scope; + } + + function allowed() { + return $qExtensions.booleanAsPromise(true); + } + + // delete selected resource objects + function perform(selected) { + var selected = angular.isArray(selected) ? selected : [selected]; + context.labels = labelize(selected.length); + return $qExtensions.allSettled(selected.map(checkPermission)).then(afterCheck); + } + + function labelize(count){ + return { + title: ngettext('Confirm Delete {{cookiecutter.panel_func}}', + 'Confirm Delete {{cookiecutter.panel_func}}s', count), + /* eslint-disable max-len */ + message: ngettext('You have selected "%s". Please confirm your selection. Deleted {{cookiecutter.panel}} is not recoverable.', + 'You have selected "%s". Please confirm your selection. Deleted {{cookiecutter.panel}}s are not recoverable.', count), + /* eslint-enable max-len */ + submit: ngettext('Delete {{cookiecutter.panel_func}}', + 'Delete {{cookiecutter.panel_func}}s', count), + success: ngettext('Deleted {{cookiecutter.panel_func}}: %s.', + 'Deleted {{cookiecutter.panel_func}}s: %s.', count), + error: ngettext('Unable to delete {{cookiecutter.panel_func}}: %s.', + 'Unable to delete {{cookiecutter.panel_func}}s: %s.', count) + }; + } + + // for batch delete + function checkPermission(selected) { + return {promise: allowed(selected), context: selected}; + } + + // for batch delete + function afterCheck(result){ + var outcome = $q.reject(); // Reject the promise by default + if (result.fail.length > 0) { + toast.add('error', getMessage(notAllowedMessage, result.fail)); + outcome = $q.reject(result.fail); + } + if (result.pass.length > 0) { + outcome = deleteModal.open(scope, result.pass.map(getEntity), context).then(createResult); + } + return outcome; + } + + function createResult(deleteModalResult) { + // To make the result of this action generically useful, reformat the return + // from the deleteModal into a standard form + var result = actionResult.getActionResult(); + deleteModalResult.pass.forEach(function markDeleted(item) { + result.deleted(resourceType, getEntity(item).id); + }); + deleteModalResult.fail.forEach(function markFailed(item) { + result.failed(resourceType, getEntity(item).id); + }); + if(result.result.failed.length == 0 && result.result.deleted.length > 0){ + $location.path('/{{cookiecutter.dashboard}}/{{cookiecutter.panel}}s'); + }else{ + return result.result; + } + } + + function getMessage(message, entities) { + return interpolate(message, [entities.map(getName).join(", ")]); + } + + function getName(result) { + return getEntity(result).name; + } + + // for batch delete + function getEntity(result) { + return result.context; + } + + // call delete REST API + function deleteEntity(id){ + return api.delete{{cookiecutter.panel_func}}(id, true); + } + } +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/details.module.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/details.module.js new file mode 100644 index 0000000..7972354 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/details.module.js @@ -0,0 +1,55 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngdoc overview + * @ngname horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.details + * + * @description + * Provides details features for {{cookiecutter.panel_func}}. + */ + angular.module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.details', + ['horizon.framework.conf', 'horizon.app.core']) + .run(registerDetails); + + registerDetails.$inject = [ + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.basePath', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.resourceType', + 'horizon.app.core.openstack-service-api.{{cookiecutter.api_module}}', + 'horizon.framework.conf.resource-type-registry.service' + ]; + + function registerDetails( + basePath, + resourceType, + api, + registry + ) { + registry.getResourceType(resourceType) + .setLoadFunction(loadFunction) + .detailsViews.append({ + id: '{{cookiecutter.panel}}DetailsOverview', + name: gettext('Overview'), + template: basePath + 'details/overview.html' + }); + + function loadFunction(identifier) { + return api.get{{cookiecutter.panel_func}}(identifier); + } + } + +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/drawer.controller.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/drawer.controller.js new file mode 100644 index 0000000..66d71ac --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/drawer.controller.js @@ -0,0 +1,39 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngdoc controller + * @name horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.DrawerController + * @description + * This is the controller for the drawer (summary) view. + * Its primary purpose is to provide the metadata definitions to + * the template via the ctrl.metadataDefs member. + */ + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s') + .controller('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.DrawerController', controller); + + controller.$inject = [ + 'horizon.app.core.openstack-service-api.{{cookiecutter.api_module}}', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.resourceType' + ]; + + function controller(api, resourceType) { + var ctrl = this; + } + +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/drawer.html b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/drawer.html new file mode 100644 index 0000000..bed480b --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/drawer.html @@ -0,0 +1,16 @@ +
+
+ +
+
ID
+
{$ item.id $}
+
+
+
+
+
+
Name
+
{$ item.name $}
+
+
+
diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/overview.controller.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/overview.controller.js new file mode 100644 index 0000000..c9f30e1 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/overview.controller.js @@ -0,0 +1,43 @@ +/* + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +(function() { + "use strict"; + + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s') + .controller('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.OverviewController', controller); + + controller.$inject = [ + '$scope', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.resourceType', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.events', + 'horizon.framework.conf.resource-type-registry.service' + ]; + + function controller( + $scope, + resourceType, + events, + registry + ) { + var ctrl = this; + ctrl.{{cookiecutter.panel}} = {}; + + $scope.context.loadPromise.then(onGet{{cookiecutter.panel_func}}); + + function onGet{{cookiecutter.panel_func}}({{cookiecutter.panel}}) { + ctrl.{{cookiecutter.panel}} = {{cookiecutter.panel}}.data; + } + } +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/overview.html b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/overview.html new file mode 100644 index 0000000..85ecfe2 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/details/overview.html @@ -0,0 +1,26 @@ +
+
+
+

Info

+
+
+
Name
+
{$ ctrl.{{cookiecutter.panel}}.name|noName $}
+
+
+
+
+
+

Record Properties

+
+
+
Created
+
{$ ctrl.{{cookiecutter.panel}}.created_at | date:'short' $}
+
Updated
+
{$ ctrl.{{cookiecutter.panel}}.updated_at | date:'short' $}
+
ID
+
{$ ctrl.{{cookiecutter.panel}}.id $}
+
+
+
+
diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/panel.html b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/panel.html new file mode 100644 index 0000000..d9e4b80 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/panel.html @@ -0,0 +1,4 @@ + + + diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.module.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.module.js new file mode 100644 index 0000000..87dec7d --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.module.js @@ -0,0 +1,133 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + /** + * @ngdoc overview + * @name horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s + * @ngModule + * @description + * Provides all the services and widgets require to display the {{cookiecutter.panel_func}} + * panel + */ + angular + .module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s', [ + 'ngRoute', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.actions', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.details' + ]) + .constant('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.events', events()) + .constant('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.resourceType', 'OS::{{cookiecutter.api_name}}::{{cookiecutter.panel_func}}') + .run(run) + .config(config); + + /** + * @ngdoc constant + * @name horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.events + * @description A list of events used by {{cookiecutter.panel_func}} + */ + function events() { + return { + CREATE_SUCCESS: 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.CREATE_SUCCESS', + DELETE_SUCCESS: 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.DELETE_SUCCESS' + }; + } + + run.$inject = [ + 'horizon.framework.conf.resource-type-registry.service', + 'horizon.app.core.openstack-service-api.{{cookiecutter.api_module}}', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.basePath', + 'horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.resourceType' + ]; + + function run(registry, api, basePath, resourceType) { + registry.getResourceType(resourceType) + .setNames(gettext('{{cookiecutter.panel_func}}'), gettext('{{cookiecutter.panel_func}}s')) + // for detail summary view on table row + .setSummaryTemplateUrl(basePath + 'details/drawer.html') + // for table row items and detail summary view. + .setProperty('name', { + label: gettext('Name') + }) + .setProperty('id', { + label: gettext('ID') + }) + .setListFunction(listFunction) + .tableColumns + .append({ + id: 'name', + priority: 1, + sortDefault: true, + filters: ['noName'], + urlFunction: urlFunction + }) + .append({ + id: 'id', + priority: 2 + }); + // for magic-search + registry.getResourceType(resourceType).filterFacets + .append({ + 'label': gettext('Name'), + 'name': 'name', + 'singleton': true + }) + .append({ + 'label': gettext('ID'), + 'name': 'id', + 'singleton': true + }); + + function listFunction(params) { + return api.get{{cookiecutter.panel_func}}s(params).then(modifyResponse); + + function modifyResponse(response) { + return {data: {items: response.data.items.map(addTrackBy)}}; + + function addTrackBy(item) { + item.trackBy = item.id; + return item; + } + } + } + + function urlFunction(item) { + return 'project/ngdetails/OS::{{cookiecutter.api_name}}::{{cookiecutter.panel_func}}/' + item.id; + } + } + + config.$inject = [ + '$provide', + '$windowProvider', + '$routeProvider' + ]; + + /** + * @name config + * @param {Object} $provide + * @param {Object} $windowProvider + * @param {Object} $routeProvider + * @description Routes used by this module. + * @returns {undefined} Returns nothing + */ + function config($provide, $windowProvider, $routeProvider) { + var path = $windowProvider.$get().STATIC_URL + 'dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/'; + $provide.constant('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.basePath', path); + $routeProvider.when('/{{cookiecutter.dashboard}}/{{cookiecutter.panel}}s/', { + templateUrl: path + 'panel.html' + }); + } +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.module.spec.js b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.module.spec.js new file mode 100644 index 0000000..8863610 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.module.spec.js @@ -0,0 +1,23 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +(function() { + 'use strict'; + + describe('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s', function() { + it('should exist', function() { + expect(angular.module('horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s')).toBeDefined(); + }); + }); + +})(); diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.scss b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/static/dashboard/{{cookiecutter.panel_group}}/{{cookiecutter.panel}}s/{{cookiecutter.panel}}s.scss new file mode 100644 index 0000000..e69de29 diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/test/__init__.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/test/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/version.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/version.py new file mode 100644 index 0000000..10083b4 --- /dev/null +++ b/{{cookiecutter.repo_name}}/{{cookiecutter.module_folder}}/version.py @@ -0,0 +1,3 @@ +import pbr.version + +version_info = pbr.version.VersionInfo('{{ cookiecutter.module_name }}') diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/base.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/base.py deleted file mode 100644 index 1c30cdb..0000000 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/base.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2010-2011 OpenStack Foundation -# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from oslotest import base - - -class TestCase(base.BaseTestCase): - - """Test case base class for all unit tests.""" diff --git a/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/test_{{cookiecutter.module_name}}.py b/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/test_{{cookiecutter.module_name}}.py deleted file mode 100644 index ce611f9..0000000 --- a/{{cookiecutter.repo_name}}/{{cookiecutter.module_name}}/tests/test_{{cookiecutter.module_name}}.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- - -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -test_{{ cookiecutter.module_name }} ----------------------------------- - -Tests for `{{ cookiecutter.module_name }}` module. -""" - -from {{ cookiecutter.module_name }}.tests import base - - -class Test{{ cookiecutter.module_name|capitalize }}(base.TestCase): - - def test_something(self): - pass