Module: Morpheus::Routes
- Defined in:
- lib/morpheus/routes.rb
Overview
Constant Summary collapse
- SITE_MAP =
A static site map for the Morpheus UI. todo: move to YAML or load from api
{ operations: { dashboard: {}, reports: {}, analytics: {}, guidance: {}, wiki: {}, budgets: {}, invoices: {}, usage: {}, approvals: {}, activity: {}, alarms: {}, }, provisioning: { instances: {}, apps: {}, catalog: {}, jobs: {}, executions: {}, code: { respositories: {}, deployments: {}, # integrations: {}, # Integrations }, }, library: { automation: [ "#!tasks", "#!workflows", "#!thresholds", "#!power-schedules", "#!execute-schedules", ], blueprints: [ "#instance-types", "#!instance-type-layouts", "#!container-types", "#!app-templates", # App Blueprints (blueprints) "#!catalog-items", "#!compute-type-layouts", # Cluster Layouts "#!compute-type-packages", # Cluster Packages ], :'virtual-images' => {}, options: [ "#!forms", # Forms "#!option-types", # Inputs "#!option-type-lists", # Option Lists ], templates: [ "#!specs", "#!files", "#!scripts", "#!security-specs", ], services: {}, # Integrations }, infrastructure: { groups: {}, clouds: {}, clusters: {}, servers: {}, # Hosts (still used for loading by id) inventory: [ # Compute "#!hosts", "#!virtual-machines", "#!containers", "#!resources", "#!bare-metal", ], networks: {}, :'load-balancers' => {}, storage: { buckets: {}, shares: {}, # File Shares volumes: {}, :'data-stores' => {}, # ugh, should be datastores servers: {}, # Storage Servers }, trust: [ "#!credentials", "#!certificates", "#!keypairs", "#!services", ], boot: [ "#!mappings", "#!boot-menus", "#!answerfiles", "#!boot-images", "#!macs", ], }, backups: { list: {}, show: {}, jobs: {}, history: [ "#!restores", ], services: {} }, monitoring: { status: {}, logs: {}, apps: {}, checks: {}, groups: {}, incidents: {}, contacts: {}, :'alert-rules' => {}, }, tools: { cypher: {}, archives: { buckets: {}, }, :'image-builder' => {}, :vdi => {} }, admin: { accounts: {}, # Tenants :'service-plans' => [ "#!prices", "#!pricesets" ], roles: {}, users: {}, :'user-groups' => {}, integrations: {}, policies: {}, health: ["logs"], settings: [ "#!appliance", "#!whitelabel", "provisioning", "monitoring", "backups", "logs", "#!guidance", "environments", "software-licenses", "#!license", "#!utilities" ], }, :'user-settings' => {}, # User Settings (Profile) }
- @@routes =
A list of routes generated from the site map and cached
nil
Class Method Summary collapse
-
.lookup(path, id = nil) ⇒ Object
lookup a route in the morpheus UI.
-
.routes ⇒ Object
An array of well known Morpheus UI routes.
Class Method Details
.lookup(path, id = nil) ⇒ Object
lookup a route in the morpheus UI
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/morpheus/routes.rb', line 176 def self.lookup(path, id=nil) path = path.to_s if path.start_with?("/") # absolute path is being looked up return path else # todo: make this smarter, regex, case insensitive, etc # find the one with smallest match index # map well known aliases case(path.dasherize.pluralize) # when "forms" # path = "/library/options/#!forms" when "inputs" path = "/library/options/#!option-types" when "option-lists" path = "/library/options/#!option-type-lists" when "backups" path = id ? "/backups/show" : "/backups/list" when "backup-jobs" path = "/backups/jobs" when "backup-results" path = "/backups/history" when "backup-restores", "restores" path = "/backups/history/#!restores" when "servers","hosts","vms","virtual-machines" # actually should be "/infrastructure/inventory" unless id is passed, show route uses /servers though path = "/infrastructure/servers" when "computes", "inventories" path = "/infrastructure/inventory" when "tenants" path = "/admin/accounts" when "appliance-settings" path = "/admin/settings/#!appliance" when "whitelabel-settings" path = "/admin/settings/#!whitelabel" when "provisioning-settings" path = "/admin/settings/#!provisioning" when "monitoring-settings","monitor-settings" path = "/admin/settings/monitoring" when "backup-settings" path = "/admin/settings/backups" when "log-settings" path = "/admin/settings/logs" when "guidance-settings" path = "/admin/settings/#!guidance" when "environments" path = "/admin/settings/environments" when "software-licenses" path = "/admin/settings/software-licenses" when "license","licenses" path = "/admin/settings/#!license" end # todo: this is weird, fix it so "view license matches license before software-licenses without needing the above alias.. # dasherize path and attempt to match the plural first plural_path = path.pluralize paths = [path.dasherize] if plural_path != path paths.unshift(plural_path.dasherize) end best_route = nil #best_index = nil best_prefix_words = nil paths.each do |p| if best_route.nil? self.routes.each do |it| match_index = it.index(p) if match_index prefix_route = match_index == 0 ? "" : it[0..(match_index-1)] prefix_words = prefix_route.split("/") #if best_index.nil? || match_index < best_index if best_prefix_words.nil? || prefix_words.size < best_prefix_words.size best_route = it #best_index = match_index best_prefix_words = prefix_words end end end end end if best_route return best_route else # no match found return nil end end end |
.routes ⇒ Object
Returns an array of well known Morpheus UI routes.
165 166 167 168 169 170 |
# File 'lib/morpheus/routes.rb', line 165 def self.routes if !@@routes @@routes = build_routes(SITE_MAP) end return @@routes end |