Skip to content

Commit

Permalink
Enable the installation process in the HTTP-based version (#1132)
Browse files Browse the repository at this point in the history
The HTTP-based version of Agama does not allow performing the
installation at all. First of all, the installation button is commented
and the rest of the process has not been tested.

This pull request aims to enable the installation process again, from
clicking the installation
button to rebooting the system.

## Tasks

- [x] Enable the installation button.
- [x] Comment (or adapt) the Questions.js client.
- [x] Enable questions backend to use camelCase.
- [x] ~~Fix the installation progress (already working)~~
- [x] Implement the "reboot" system action.
- [x] Fix the installation finished screen (it does not work properly
due to problems with the storage client).
- [ ] Make sure that the transition between the overview and the
progress happens properly
  • Loading branch information
imobachgs authored Apr 8, 2024
2 parents c118d06 + d803057 commit ccea4e9
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 163 deletions.
11 changes: 9 additions & 2 deletions rust/agama-server/src/manager/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct ManagerState<'a> {

/// Holds information about the manager's status.
#[derive(Clone, Serialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct InstallerStatus {
/// Current installation phase.
phase: InstallationPhase,
Expand Down Expand Up @@ -128,10 +129,16 @@ async fn finish_action(State(state): State<ManagerState<'_>>) -> Result<(), Erro
async fn installer_status(
State(state): State<ManagerState<'_>>,
) -> Result<Json<InstallerStatus>, Error> {
let phase = state.manager.current_installation_phase().await?;
// CanInstall gets blocked during installation
let can_install = match phase {
InstallationPhase::Install => false,
_ => state.manager.can_install().await?,
};
let status = InstallerStatus {
phase: state.manager.current_installation_phase().await?,
phase,
can_install,
busy: state.manager.busy_services().await?,
can_install: state.manager.can_install().await?,
iguana: state.manager.use_iguana().await?,
};
Ok(Json(status))
Expand Down
7 changes: 7 additions & 0 deletions rust/agama-server/src/questions/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ struct QuestionsState<'a> {
}

#[derive(Clone, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Question {
generic: GenericQuestion,
with_password: Option<QuestionWithPassword>,
Expand All @@ -154,6 +155,7 @@ pub struct Question {
/// question and its answer. So here it is split into GenericQuestion
/// and GenericAnswer
#[derive(Clone, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct GenericQuestion {
id: u32,
class: String,
Expand All @@ -171,27 +173,32 @@ pub struct GenericQuestion {
/// Here for web API we want to have in json that separation that would
/// allow to compose any possible future specialization of question
#[derive(Clone, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct QuestionWithPassword {
password: String,
}

#[derive(Clone, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct Answer {
generic: GenericAnswer,
with_password: Option<PasswordAnswer>,
}

/// Answer needed for GenericQuestion
#[derive(Clone, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct GenericAnswer {
answer: String,
}

/// Answer needed for Password specific questions.
#[derive(Clone, Serialize, Deserialize, utoipa::ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct PasswordAnswer {
password: String,
}

/// Sets up and returns the axum service for the questions module.
pub async fn questions_service(dbus: zbus::Connection) -> Result<Router, ServiceError> {
let questions = QuestionsClient::new(dbus.clone()).await?;
Expand Down
4 changes: 2 additions & 2 deletions rust/agama-server/src/web/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,12 @@ async fn build_issues_proxy<'a>(
/// struct HelloWorldState {};
///
/// let dbus = connection().await.unwrap();
/// let issues_router = validation_router(
/// let validation_routes = validation_router(
/// &dbus, "org.opensuse.HelloWorld", "/org/opensuse/hello"
/// ).await.unwrap();
/// let router: Router<HelloWorldState> = Router::new()
/// .route("/hello", get(hello))
/// .merge(validation_router)
/// .merge(validation_routes)
/// .with_state(HelloWorldState {});
/// });
/// ```
Expand Down
32 changes: 16 additions & 16 deletions web/src/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const createClient = (url) => {
const software = new SoftwareClient(client);
// const storage = new StorageClient(address);
const users = new UsersClient(client);
// const questions = new QuestionsClient(address);
const questions = new QuestionsClient(client);

/**
* Gets all issues, grouping them by context.
Expand All @@ -91,13 +91,13 @@ const createClient = (url) => {
*
* @returns {Promise<Issues>}
*/
// const issues = async () => {
// return {
// product: await software.product.getIssues(),
// storage: await storage.getIssues(),
// software: await software.getIssues(),
// };
// };
const issues = async () => {
return {
product: await product.getIssues(),
// storage: await storage.getIssues(),
software: await software.getIssues(),
};
};

/**
* Registers a callback to be executed when issues change.
Expand All @@ -108,15 +108,15 @@ const createClient = (url) => {
const onIssuesChange = (handler) => {
const unsubscribeCallbacks = [];

// unsubscribeCallbacks.push(
// software.product.onIssuesChange((i) => handler({ product: i })),
// );
unsubscribeCallbacks.push(
product.onIssuesChange((i) => handler({ product: i })),
);
// unsubscribeCallbacks.push(
// storage.onIssuesChange((i) => handler({ storage: i })),
// );
// unsubscribeCallbacks.push(
// software.onIssuesChange((i) => handler({ software: i })),
// );
unsubscribeCallbacks.push(
software.onIssuesChange((i) => handler({ software: i })),
);

return () => {
unsubscribeCallbacks.forEach((cb) => cb());
Expand All @@ -142,8 +142,8 @@ const createClient = (url) => {
software,
// storage,
users,
// questions,
// issues,
questions,
issues,
onIssuesChange,
isConnected,
onDisconnect: (handler) => {
Expand Down
4 changes: 2 additions & 2 deletions web/src/client/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ManagerBaseClient {
*/
async canInstall() {
const installer = await this.client.get("/manager/installer");
return installer.can_install;
return installer.canInstall;
}

/**
Expand Down Expand Up @@ -112,7 +112,7 @@ class ManagerBaseClient {
* Runs cleanup when installation is done
*/
finishInstallation() {
return this.client.post("/manager/install");
return this.client.post("/manager/finish");
}

/**
Expand Down
Loading

0 comments on commit ccea4e9

Please sign in to comment.