note description: "Summary description for {ES_CLOUD_INSTALLATIONS_HANDLER}." fixme: "Show the Revoke or Assign behavior only if permitted." date: "$Date$" revision: "$Revision$" class ES_CLOUD_INSTALLATIONS_HANDLER inherit CMS_HANDLER rename make as make_with_cms_api end WSF_URI_TEMPLATE_HANDLER create make feature {NONE} -- Initialization make (a_mod: ES_CLOUD_MODULE; a_mod_api: ES_CLOUD_API) do es_cloud_module := a_mod make_with_cms_api (a_mod_api.cms_api) es_cloud_api := a_mod_api end feature -- API es_cloud_module: ES_CLOUD_MODULE es_cloud_api: ES_CLOUD_API feature -- Execution execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute handler for `req' and respond in `res'. do if req.is_get_request_method then if attached req.path_parameter ("installation_id") as l_inst_id then process_installation_get (l_inst_id.string_representation, req, res) else process_installations_get (req, res) end else send_bad_request (req, res) end end process_installation_get (a_inst_id: READABLE_STRING_GENERAL; req: WSF_REQUEST; res: WSF_RESPONSE) local r: like new_generic_response s: STRING l_user: ES_CLOUD_USER inst: ES_CLOUD_INSTALLATION do if attached api.user as u then inst := es_cloud_api.user_installation (u, a_inst_id) if inst = Void then if attached es_cloud_api.installations_for (a_inst_id) as lst and then lst.count = 1 then inst := lst.first if attached es_cloud_api.license (inst.license_id) as inst_lic and then attached es_cloud_api.user_for_license (inst_lic) as inst_user then if u.same_as (inst_user) or else api.has_permission (es_cloud_module.perm_view_es_installations) then l_user := inst_user else l_user := Void end end end else l_user := u end if inst /= Void and then l_user /= Void and then ( u.same_as (l_user) or else api.has_permission (es_cloud_module.perm_view_es_installations) ) then r := new_generic_response (req, res) r.add_javascript_url (r.module_name_resource_url ({ES_CLOUD_MODULE}.name, "/files/js/es_cloud.js", Void)) r.add_style (r.module_name_resource_url ({ES_CLOUD_MODULE}.name, "/files/css/es_cloud.css", Void), Void) r.set_title ("Installation") s := "" s.append ("
") append_installation_to_html (inst, l_user, s) s.append ("
") -- es-installation r.set_main_content (s) r.execute else send_access_denied (req, res) end else send_access_denied (req, res) end end process_installations_get (req: WSF_REQUEST; res: WSF_RESPONSE) local r: like new_generic_response s: STRING ago: DATE_TIME_AGO_CONVERTER inst: ES_CLOUD_INSTALLATION do r := new_generic_response (req, res) r.add_javascript_url (r.module_name_resource_url ({ES_CLOUD_MODULE}.name, "/files/js/es_cloud.js", Void)) r.add_style (r.module_name_resource_url ({ES_CLOUD_MODULE}.name, "/files/css/es_cloud.css", Void), Void) r.set_title ("EiffelStudio Installations") s := "" create ago.make if attached api.user as u then s.append ("
Account: "+ api.html_encoded (api.real_user_display_name (u)) +"
") -- List of licenses s.append ("
") else s.append ("

Please Login or Register...

") end r.set_main_content (s) r.execute end append_installation_to_html (inst: ES_CLOUD_INSTALLATION; u: ES_CLOUD_USER; s: STRING_8) local l_inst_lic, lic: ES_CLOUD_LICENSE do s.append ("

") s.append (percent_encoded (inst.id)) s.append (":") if inst.is_active then s.append (" (Active)") end s.append ("

") l_inst_lic := es_cloud_api.license (inst.license_id) if l_inst_lic /= Void then s.append ("
Associated license
%N") es_cloud_api.append_one_line_license_view_to_html (l_inst_lic, u, es_cloud_module, s) s.append ("
") end if attached es_cloud_api.other_adapted_licenses (u, inst) as lst then s.append ("
Other available license(s)
%N") s.append ("
It is possible to change the license used by the installation with one of following license(s)...
%N") s.append ("
") end s.append ("
") end note copyright: "2011-2020, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end