-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Content Views: Initial work to generate a content view prototype.
- Loading branch information
Showing
52 changed files
with
3,458 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Copyright 2013 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public | ||
# License as published by the Free Software Foundation; either version | ||
# 2 of the License (GPLv2) or (at your option) any later version. | ||
# There is NO WARRANTY for this software, express or implied, | ||
# including the implied warranties of MERCHANTABILITY, | ||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
# have received a copy of GPLv2 along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
module Katello | ||
class ContentViewsController < Katello::ApplicationController | ||
|
||
before_filter :authorize | ||
|
||
def rules | ||
index_rule = lambda { true } | ||
|
||
{ | ||
:index => index_rule, | ||
:all => index_rule | ||
} | ||
end | ||
|
||
def index | ||
render 'bastion/layouts/application', :layout => false | ||
end | ||
|
||
def all | ||
redirect_to :action => 'index', :anchor => '/content_views' | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# | ||
# Copyright 2013 Red Hat, Inc. | ||
# | ||
# This software is licensed to you under the GNU General Public | ||
# License as published by the Free Software Foundation; either version | ||
# 2 of the License (GPLv2) or (at your option) any later version. | ||
# There is NO WARRANTY for this software, express or implied, | ||
# including the implied warranties of MERCHANTABILITY, | ||
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
# have received a copy of GPLv2 along with this software; if not, see | ||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
|
||
module Katello | ||
module Navigation | ||
module Items | ||
class ContentViews < Navigation::Item | ||
|
||
def initialize(organization) | ||
@key = :content_views | ||
@display = _("Content Views (new)") | ||
@authorization = lambda{ ContentView.any_readable?(organization) } | ||
@url = content_views_path + '#/content_views' | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
274 changes: 274 additions & 0 deletions
274
engines/bastion/app/assets/javascripts/bastion/content-views/content-view-mock.factory.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,274 @@ | ||
/** | ||
* Copyright 2013 Red Hat, Inc. | ||
* | ||
* This software is licensed to you under the GNU General Public | ||
* License as published by the Free Software Foundation; either version | ||
* 2 of the License (GPLv2) or (at your option) any later version. | ||
* There is NO WARRANTY for this software, express or implied, | ||
* including the implied warranties of MERCHANTABILITY, | ||
* NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should | ||
* have received a copy of GPLv2 along with this software; if not, see | ||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
**/ | ||
|
||
/** | ||
* @ngdoc service | ||
* @name Bastion.content-views.factory:ContentView | ||
* | ||
* @description | ||
* Provides a $Resource for interacting with environments. | ||
*/ | ||
angular.module('Bastion.content-views').factory('ContentView', | ||
[function($resource, Routes, CurrentOrganization) { | ||
|
||
var Resource = function(id, create) { | ||
var name = id ? 'Content View ' + id : '', | ||
label = id ? 'content_view_' + id : '', | ||
generatedVersions = [], | ||
counts = { | ||
products: 0, | ||
repositories: 0, | ||
puppet_modules: 0 | ||
}; | ||
|
||
this.id = id; | ||
|
||
if (id !== undefined && !create) { | ||
versions.call(this, function(response) { | ||
generatedVersions = response.results; | ||
}); | ||
|
||
counts = { | ||
products: id + id, | ||
repositories: id * id, | ||
puppet_modules: id * id - id | ||
}; | ||
} | ||
|
||
return { | ||
id: id, | ||
name: name, | ||
label: label, | ||
created: new Date(), | ||
environments: [ | ||
'Library', | ||
'Dev' | ||
], | ||
counts: counts, | ||
user: 'mister manager', | ||
permissions: { | ||
editable: true | ||
}, | ||
organization: { | ||
id: 1, | ||
name: 'ACME_Corporation' | ||
}, | ||
$save: save, | ||
$versions: versions, | ||
$version: version, | ||
versions: generatedVersions, | ||
repositories: [], | ||
filters: [], | ||
$publish: publish, | ||
$puppetModules: puppetModules, | ||
$filters: filters, | ||
$addFilter: addFilter | ||
}; | ||
}; | ||
|
||
var Version = function(id) { | ||
return { | ||
id: id, | ||
name: 'Version ' + id, | ||
label: 'version_' + id, | ||
promoted: new Date(), | ||
environments: [ | ||
{ | ||
id: 1, | ||
name: 'Library' | ||
},{ | ||
id: 2, | ||
name: 'Dev' | ||
} | ||
], | ||
counts: { | ||
products: id + id, | ||
repositories: id * id, | ||
packages: id^id, | ||
puppet_modules: id * id - id, | ||
errata: { | ||
bugs: id, | ||
security: id + id, | ||
enhancements: id | ||
} | ||
}, | ||
user: 'mister manager' | ||
}; | ||
}; | ||
|
||
var Filter = function(id) { | ||
return { | ||
id: id, | ||
name: 'Version ' + id, | ||
created: new Date(), | ||
description: '', | ||
contentType: '', | ||
counts: { | ||
products: 0, | ||
repositories: 0, | ||
packages: 0, | ||
puppet_modules: id * id - id, | ||
errata: { | ||
bugs: 0, | ||
security: 0, | ||
enhancements: 0 | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
var save = function(successCallback, errorCallback) { | ||
var view = new Resource(results.length + 1, true); | ||
|
||
view.name = this.name; | ||
|
||
results.push(view); | ||
successCallback(view); | ||
}; | ||
|
||
var versions = function(callback) { | ||
var versions = generateVersions(this.id); | ||
|
||
if (this.id < 10) { | ||
this.versions = versions; | ||
} | ||
|
||
callback({ | ||
offset: 0, | ||
total: versions.length, | ||
subtotal: versions.length, | ||
limit: 25, | ||
search: "", | ||
sort: {by: "name", order: "ASC"}, | ||
results: this.versions | ||
}); | ||
}; | ||
|
||
var version = function(params, callback) { | ||
var found; | ||
|
||
angular.forEach(this.versions, function(version) { | ||
if (params.toString() === version.id.toString()) { | ||
found = version; | ||
} | ||
}); | ||
|
||
callback(found); | ||
}; | ||
|
||
var publish = function(params, callback) { | ||
var version = new Version(this.versions.length + 1); | ||
|
||
version.name = params.name; | ||
|
||
this.versions.push(version); | ||
callback(version); | ||
}; | ||
|
||
var puppetModules = function(callback) { | ||
var modules = generatePuppetModules(this.id); | ||
|
||
if (this.modules.length === 0) { | ||
this.modules = modules; | ||
} | ||
|
||
callback({ | ||
offset: 0, | ||
total: modules.length, | ||
subtotal: modules.length, | ||
limit: 25, | ||
search: "", | ||
sort: {by: "name", order: "ASC"}, | ||
results: this.modules | ||
}); | ||
}; | ||
|
||
var filters = function(callback) { | ||
var filters = this.filters; | ||
|
||
callback({ | ||
offset: 0, | ||
total: filters.length, | ||
subtotal: filters.length, | ||
limit: 25, | ||
search: "", | ||
sort: {by: "name", order: "ASC"}, | ||
results: filters | ||
}); | ||
}; | ||
|
||
var addFilter = function(params, callback) { | ||
var filter = new Filter(this.filters.length + 1); | ||
|
||
filter.name = params.name; | ||
filter.description = params.description; | ||
filter.contentType = params.contentType; | ||
|
||
this.filters.push(filter); | ||
callback(filter); | ||
}; | ||
|
||
var results = generateViews(10, save, versions, publish, puppetModules); | ||
|
||
Resource.query = function(params, callback) { | ||
callback({ | ||
offset: 0, | ||
total: 10, | ||
subtotal: 10, | ||
limit: 25, | ||
search: "", | ||
sort: {by: "name", order: "ASC"}, | ||
results: results | ||
}); | ||
}; | ||
|
||
Resource.get = function(params, callback) { | ||
var view; | ||
|
||
angular.forEach(results, function(result) { | ||
if (params.id.toString() === result.id.toString()) { | ||
view = result; | ||
} | ||
}); | ||
|
||
callback(view); | ||
|
||
return view; | ||
}; | ||
|
||
function generateViews(numViews, save, versions, publish, puppetModules) { | ||
var views = [], | ||
i; | ||
|
||
for(i = 1; i <= numViews; i += 1) { | ||
views.push(new Resource(i)); | ||
} | ||
|
||
return views; | ||
} | ||
|
||
function generateVersions(numVersions) { | ||
var versions = [], | ||
i; | ||
|
||
for(i = 1; i <= numVersions; i += 1) { | ||
versions.push(new Version(i)); | ||
} | ||
|
||
return versions; | ||
} | ||
|
||
return Resource; | ||
|
||
}] | ||
); |
Oops, something went wrong.