diff --git a/src/Ombi/ClientApp/src/app/interfaces/IPlex.ts b/src/Ombi/ClientApp/src/app/interfaces/IPlex.ts index de3fc8cf1..6afc13e21 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/IPlex.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/IPlex.ts @@ -14,6 +14,8 @@ export interface IPlexOAuthViewModel { export interface IPlexOAuthAccessToken { accessToken: string; + success: boolean; + error: string; } export interface IPlexUser { diff --git a/src/Ombi/ClientApp/src/app/wizard/createadmin/createadmin.component.html b/src/Ombi/ClientApp/src/app/wizard/createadmin/createadmin.component.html index 50371c346..ff44f7093 100644 --- a/src/Ombi/ClientApp/src/app/wizard/createadmin/createadmin.component.html +++ b/src/Ombi/ClientApp/src/app/wizard/createadmin/createadmin.component.html @@ -15,7 +15,7 @@ - You'll need to configure e-mail to recover any lost password! + You'll need to configure e-mail to reset your password! diff --git a/src/Ombi/ClientApp/src/app/wizard/ombiconfig/ombiconfig.component.html b/src/Ombi/ClientApp/src/app/wizard/ombiconfig/ombiconfig.component.html index fc51eae7c..33d15bb58 100644 --- a/src/Ombi/ClientApp/src/app/wizard/ombiconfig/ombiconfig.component.html +++ b/src/Ombi/ClientApp/src/app/wizard/ombiconfig/ombiconfig.component.html @@ -4,21 +4,22 @@
-

Customize your Ombi

+

Customize your Ombi

+

Customize your {{config.applicationName}}

- +
- + -
+
Custom Logo - +
diff --git a/src/Ombi/ClientApp/src/app/wizard/ombiconfig/ombiconfig.component.ts b/src/Ombi/ClientApp/src/app/wizard/ombiconfig/ombiconfig.component.ts index 9f1ac22f5..0b7e3863b 100644 --- a/src/Ombi/ClientApp/src/app/wizard/ombiconfig/ombiconfig.component.ts +++ b/src/Ombi/ClientApp/src/app/wizard/ombiconfig/ombiconfig.component.ts @@ -1,4 +1,6 @@ import { Component, Input } from "@angular/core"; +import { IOmbiConfigModel } from "../models/OmbiConfigModel"; +import { WizardService } from "../services/wizard.service"; @Component({ selector: "wizard-ombi", @@ -7,5 +9,5 @@ }) export class OmbiConfigComponent { - constructor() { } + @Input() public config: IOmbiConfigModel; } diff --git a/src/Ombi/ClientApp/src/app/wizard/plex/plex.component.html b/src/Ombi/ClientApp/src/app/wizard/plex/plex.component.html index 4c3ee268a..611dc4500 100644 --- a/src/Ombi/ClientApp/src/app/wizard/plex/plex.component.html +++ b/src/Ombi/ClientApp/src/app/wizard/plex/plex.component.html @@ -1,4 +1,4 @@ -
+
@@ -8,12 +8,12 @@
- +
- +
@@ -21,13 +21,15 @@
- +

OR

- +
diff --git a/src/Ombi/ClientApp/src/app/wizard/plex/plex.component.ts b/src/Ombi/ClientApp/src/app/wizard/plex/plex.component.ts index 03c8cfa9a..bc80c65cb 100644 --- a/src/Ombi/ClientApp/src/app/wizard/plex/plex.component.ts +++ b/src/Ombi/ClientApp/src/app/wizard/plex/plex.component.ts @@ -16,6 +16,8 @@ export class PlexComponent implements OnInit, OnDestroy { public login: string; public password: string; public pinTimer: any; + public completed: boolean; + public oauthLoading: boolean; private clientId: string; @@ -43,7 +45,7 @@ export class PlexComponent implements OnInit, OnDestroy { usePlexAdminAccount: true, }).subscribe(y => { if (y.result) { - this.router.navigate(["login"]); + this.notificationService.success("Created your Plex User!"); } else { this.notificationService.error("Could not get the Plex Admin Information"); if (y.errors.length > 0) { @@ -57,6 +59,7 @@ export class PlexComponent implements OnInit, OnDestroy { } public oauth() { + this.oauthLoading = true; const oAuthWindow = window.open(window.location.toString(), "_blank", `toolbar=0, location=0, status=0, @@ -69,20 +72,24 @@ export class PlexComponent implements OnInit, OnDestroy { this.authService.login({ usePlexOAuth: true, password: "", rememberMe: true, username: "", plexTvPin: pin }).subscribe(x => { oAuthWindow!.location.replace(x.url); - this.pinTimer = setInterval(() => { // this.notify.info("Authenticating", "Loading... Please Wait"); this.getPinResult(x.pinId); - }, 10000); + }, 3000); }); }); } public getPinResult(pinId: number) { this.plexOauth.oAuth(pinId).subscribe(x => { + if (!x.accessToken) { + if(!x.success) { + this.oauthLoading = false; + clearInterval(this.pinTimer); + this.notificationService.error(`Error From Plex: ${x.error}`) + } return; - // RETURN } this.identityService.createWizardUser({ @@ -93,10 +100,14 @@ export class PlexComponent implements OnInit, OnDestroy { if (u.result) { this.authService.oAuth(pinId).subscribe(c => { this.store.save("id_token", c.access_token); - this.router.navigate(["login"]); + this.completed = true; + this.notificationService.success("Created your Plex User!"); + this.oauthLoading = false; + clearInterval(this.pinTimer); }); } else { + this.oauthLoading = false; if (u.errors.length > 0) { console.log(u.errors[0]); } diff --git a/src/Ombi/ClientApp/src/app/wizard/services/wizard.service.ts b/src/Ombi/ClientApp/src/app/wizard/services/wizard.service.ts index d39bda9ed..0f6511265 100644 --- a/src/Ombi/ClientApp/src/app/wizard/services/wizard.service.ts +++ b/src/Ombi/ClientApp/src/app/wizard/services/wizard.service.ts @@ -1,6 +1,7 @@ import { PlatformLocation, APP_BASE_HREF } from "@angular/common"; import { HttpClient } from "@angular/common/http"; import { Injectable, Inject } from "@angular/core"; +import { Observable } from "rxjs"; import { ICustomizationSettings } from "../../interfaces"; import { ServiceHelpers } from "../../services"; import { IOmbiConfigModel } from "../models/OmbiConfigModel"; @@ -12,7 +13,7 @@ export class WizardService extends ServiceHelpers { super(http, "/api/v2/wizard/", href); } - public async addOmbiConfig(config: IOmbiConfigModel): Promise { - return await this.http.post(`${this.url}config`, config, {headers: this.headers}).toPromise(); + public addOmbiConfig(config: IOmbiConfigModel): Observable { + return this.http.post(`${this.url}config`, config, {headers: this.headers}); } } diff --git a/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.html b/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.html index 0268d7e7e..6f46803c4 100644 --- a/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.html +++ b/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.html @@ -44,7 +44,7 @@ -
+ Create a local admin
@@ -56,7 +56,7 @@ Ombi config - +
@@ -84,4 +84,4 @@
-
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.ts b/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.ts index 76bad5fb4..849977b55 100644 --- a/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.ts +++ b/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.ts @@ -1,37 +1,53 @@ -import { Component, OnInit } from "@angular/core"; +import { AfterViewInit, Component, OnInit, ViewChild } from "@angular/core"; import { Router } from "@angular/router"; import { ICreateWizardUser } from "../../interfaces"; import { IdentityService, NotificationService } from "../../services"; - +import { IOmbiConfigModel } from "../models/OmbiConfigModel"; +import { WizardService } from "../services/wizard.service"; +import { MatHorizontalStepper } from'@angular/material/stepper'; +import { StepperSelectionEvent } from "@angular/cdk/stepper"; @Component({ templateUrl: "./welcome.component.html", styleUrls: ["./welcome.component.scss"], }) export class WelcomeComponent implements OnInit { - + + @ViewChild('stepper', {static: false}) public stepper: MatHorizontalStepper; public localUser: ICreateWizardUser; - - constructor(private router: Router, - private identityService: IdentityService, private notificationService: NotificationService) { } + public config: IOmbiConfigModel; - public ngOnInit(): void { + constructor(private router: Router, private identityService: IdentityService, + private notificationService: NotificationService, private WizardService: WizardService) { } + + public ngOnInit(): void { this.localUser = { password:"", username:"", usePlexAdminAccount:false } + this.config = { + applicationName: null, + applicationUrl: null, + logo: null + }; } public createUser() { - this.identityService.createWizardUser(this.localUser).subscribe(x => { - if (x.result) { + this.WizardService.addOmbiConfig(this.config).subscribe(config => { + if(config != null) { + this.identityService.createWizardUser(this.localUser).subscribe(x => { + if (x.result) { + // save the config this.router.navigate(["login"]); } else { if (x.errors.length > 0) { this.notificationService.error(x.errors[0]); + this.stepper.previous(); } } }); } + }, configErr => this.notificationService.error(configErr)); + } } diff --git a/src/Ombi/Controllers/V1/IdentityController.cs b/src/Ombi/Controllers/V1/IdentityController.cs index 63f8211ca..342e4620d 100644 --- a/src/Ombi/Controllers/V1/IdentityController.cs +++ b/src/Ombi/Controllers/V1/IdentityController.cs @@ -139,7 +139,7 @@ namespace Ombi.Controllers.V1 public async Task CreateWizardUser([FromBody] CreateUserWizardModel user) { var users = UserManager.Users; - if (users.Any(x => x.NormalizedUserName != "API")) + if (users.Any(x => x.UserType == UserType.LocalUser)) { // No one should be calling this. Only the wizard return new SaveWizardResult { Result = false, Errors = new List { "Looks like there is an existing user!" } }; @@ -169,7 +169,7 @@ namespace Ombi.Controllers.V1 ImportPlexAdmin = true }); - return await SaveWizardUser(user, adminUser); + return await SaveWizardUser(user, adminUser, false); } var userToCreate = new OmbiUser @@ -179,10 +179,10 @@ namespace Ombi.Controllers.V1 StreamingCountry = "US" }; - return await SaveWizardUser(user, userToCreate); + return await SaveWizardUser(user, userToCreate, true); } - private async Task SaveWizardUser(CreateUserWizardModel user, OmbiUser userToCreate) + private async Task SaveWizardUser(CreateUserWizardModel user, OmbiUser userToCreate, bool completeWizard) { IdentityResult result; var retVal = new SaveWizardResult(); @@ -210,10 +210,13 @@ namespace Ombi.Controllers.V1 _log.LogInformation("Added the Admin role"); } - // Update the wizard flag - var settings = await OmbiSettings.GetSettingsAsync(); - settings.Wizard = true; - await OmbiSettings.SaveSettingsAsync(settings); + if (completeWizard) + { + // Update the wizard flag + var settings = await OmbiSettings.GetSettingsAsync(); + settings.Wizard = true; + await OmbiSettings.SaveSettingsAsync(settings); + } } if (!result.Succeeded) {