change for Dashboard UI plugin

This commit is contained in:
Shu Muto 2016-07-27 14:17:51 +09:00
parent e1397252dd
commit 389e5b7a06
68 changed files with 2203 additions and 275 deletions

View File

@ -1,4 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
project=openstack-dev/cookiecutter.git
port=xxx
project=openstack-dev/ui-cookiecutter.git

View File

@ -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

View File

@ -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"
}

View File

@ -2,4 +2,4 @@
git init
git add .
git commit -a -m "Initial Cookiecutter Commit."
git commit -a -m "Initial UI-Cookiecutter Commit."

View File

@ -1,7 +0,0 @@
[run]
branch = True
source = {{cookiecutter.module_name}}
omit = {{cookiecutter.module_name}}/openstack/*
[report]
ignore_errors = True

View File

@ -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

View File

@ -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
build
doc/source/sourcecode
{{ cookiecutter.module_folder }}/test/.secret_key_store
.venv
.tox
*.py[cod]
*.lock
*.egg*
*.swp

View File

@ -1,4 +1,4 @@
[gerrit]
host=review.openstack.org
port=29418
port={{ cookiecutter.gerrit_id }}
project={{cookiecutter.repo_group}}/{{cookiecutter.repo_name}}.git

View File

@ -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
}

View File

@ -1,3 +0,0 @@
# Format is:
# <preferred e-mail> <other e-mail 1>
# <preferred e-mail> <other e-mail 2>

View File

@ -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

View File

@ -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

View File

@ -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/

View File

@ -0,0 +1,5 @@
[extractors]
django = django_babel.extract:extract_django
[python: **.py]
[django: templates/**.html]

View File

@ -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]

View File

@ -1,2 +0,0 @@
[python: **.py]

View File

@ -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 <target>' where <target> 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."

434
{{cookiecutter.repo_name}}/doc/source/conf.py Executable file → Normal file
View File

@ -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
# "<project> v<release> 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 <link> 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

View File

@ -1,4 +0,0 @@
============
Contributing
============
.. include:: ../../CONTRIBUTING.rst

View File

@ -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`

View File

@ -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 }}

View File

@ -1 +0,0 @@
.. include:: ../../README.rst

View File

@ -0,0 +1,2 @@
{{ cookiecutter.call_by_name }} 0.1.0
===============================

View File

@ -1,7 +0,0 @@
========
Usage
========
To use {{ cookiecutter.repo_name }} in a project::
import {{ cookiecutter.module_name }}

View File

@ -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)

View File

@ -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'),
]

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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<id>[^/]+)$'
@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())

View File

@ -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"

View File

@ -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)

View File

@ -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'),
]

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -0,0 +1,3 @@
"""
Stub file to work around django bug: https://code.djangoproject.com/ticket/7198
"""

View File

@ -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.'));
})
}
}
}());

View File

@ -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);
}
})();

View File

@ -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();
});
});
})();

View File

@ -0,0 +1,8 @@
@import "{{cookiecutter.panel}}s/{{cookiecutter.panel}}s";
.batch-action {
float: right;
action-list {
padding-left: 0.3em;
}
}

View File

@ -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')
}
});
}
})();

View File

@ -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'
}
});
}
})();

View File

@ -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;
}
}
}
})();

View File

@ -0,0 +1,4 @@
<dl>
<dt translate>{{cookiecutter.panel_func}} Name</dt>
<dd translate>An arbitrary human-readable name</dd>
</dl>

View File

@ -0,0 +1,12 @@
<div ng-controller="create{{cookiecutter.panel_func}}InfoController as ctrl">
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label class="control-label" for="{{cookiecutter.panel}}-name" translate>{{cookiecutter.panel_func}} Name</label>
<input name="{{cookiecutter.panel}}-name" type="text" class="form-control" id="{{cookiecutter.panel}}-name"
ng-model="model.newSpec.name"
placeholder="{$ 'Name of the {{cookiecutter.panel}} to create.'|translate $}">
</div>
</div>
</div>
</div>

View File

@ -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;
}
})();

View File

@ -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;
}
})();

View File

@ -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);
}
}
})();

View File

@ -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);
}
}
})();

View File

@ -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;
}
})();

View File

@ -0,0 +1,16 @@
<div ng-controller="horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.DrawerController as drawerCtrl">
<div class="row">
<span class="rsp-alt-p2">
<dl class="col-md-5">
<dt translate>ID</dt>
<dd>{$ item.id $}</dd>
</dl>
</span>
</div>
<div class="row">
<dl class="col-md-5">
<dt translate>Name</dt>
<dd>{$ item.name $}</dd>
</dl>
</div>
</div>

View File

@ -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;
}
}
})();

View File

@ -0,0 +1,26 @@
<div ng-controller="horizon.dashboard.{{cookiecutter.panel_group}}.{{cookiecutter.panel}}s.OverviewController as ctrl">
<div class="row">
<div class="col-md-6 detail">
<h3 translate>Info</h3>
<hr>
<dl class="dl-horizontal">
<dt translate>Name</dt>
<dd>{$ ctrl.{{cookiecutter.panel}}.name|noName $}</dd>
</dl>
</div>
</div>
<div class="row">
<div class="col-md-6 detail">
<h3 translate>Record Properties</h3>
<hr>
<dl class="dl-horizontal">
<dt translate>Created</dt>
<dd>{$ ctrl.{{cookiecutter.panel}}.created_at | date:'short' $}</dd>
<dt translate>Updated</dt>
<dd>{$ ctrl.{{cookiecutter.panel}}.updated_at | date:'short' $}</dd>
<dt translate>ID</dt>
<dd>{$ ctrl.{{cookiecutter.panel}}.id $}</dd>
</dl>
</div>
</div>
</div>

View File

@ -0,0 +1,4 @@
<hz-resource-panel resource-type-name="OS::{{cookiecutter.api_name}}::{{cookiecutter.panel_func}}">
<hz-resource-table resource-type-name="OS::{{cookiecutter.api_name}}::{{cookiecutter.panel_func}}"
track-by="trackBy"></hz-resource-table>
</hz-resource-panel>

View File

@ -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'
});
}
})();

View File

@ -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();
});
});
})();

View File

@ -0,0 +1,3 @@
import pbr.version
version_info = pbr.version.VersionInfo('{{ cookiecutter.module_name }}')

View File

@ -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."""

View File

@ -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