Akumina Developer Documentation

Akumina Developer Documentation

  • API
  • Docs
  • Blog

›Site Creator

Akumina

  • Quickstart

Yo Akumina

  • Yo Akumina
  • Start with Yeoman
  • React
  • Simple template

Widget Builder

  • Widget Builder Structure
  • Akumina Widget Builder
  • Skipping instances
  • Token replacement for widget properties

Widget Development Quickstart

  • Setting up the Project
  • Configuring .env file
  • Configuring - akumina.sitedployer.config.json file
  • Configuring - akumina.config.json file
  • Extras

Widget Info

  • Akumina Widgets Overview
  • Building a New Widget Instance
  • Widget Views
  • Widget Properties
  • Global vs Local widgets (Widget Scoping)
  • Akumina React Widgets
  • Callbacks
  • RenderChildWidgets
  • Vendor Package List

Virtual Page Builder

  • Akumina Virtual Page Builder
  • Using Virtual Page Layouts
  • Creating a Custom Layout

Stream Card Builder

  • Installation
  • Stream Card Builder
  • Custom Cards
  • Activity Comments Config
  • Akumina Activity Stream PUSH Subscription using PowerAutomate to connect to ServiceNow
  • Akumina Activity Stream PUSH Subscription using PowerAutomate to connect to Dynamic 365

Site Deployer

  • Overview
  • Version 6.0
  • List Attribute Deployments
  • NPM Commands
  • SPA Updates and Deploying to multiple sites

Authoring

  • Content Action Event
  • Publish Validation Integration
  • Field Event Integration
  • CK Editor external plugins

Headless

  • Quickstart
  • Headless Teams support
  • Headless Troubleshooting

Modern

  • Overview
  • FAQ
  • Single Page Application
  • Modern Web Part Library
  • Google Analytics for Modern Pages

Site Creator

  • Overview
  • Adding A Custom Site Definition
  • Core Step Classes
  • Custom Site Definition Components
  • Custom Site Definition XML
  • Custom Subsite Definitions
  • Sample Step Code
  • Supported Tokens

Azure DevOps

  • CI/CD using Azure DevOps
  • Setting up a build to deploy a site package
  • Setting up a build to deploy file to App Manager hosted in an app service

Configuration

  • Configuration Context Overview
  • Edit the Redis cache timeout
  • Using a key vault for the client id and client secret

Debugging

  • Debugging in Akumina

Advanced

  • Central Site Collection Support
  • Eventing OOB Digital Workplace Events
  • Working with custom JSX Views
  • Page Indexing

Service Hub

  • Quickstart

Patch Notes

  • Patch Notes

Sample Step Code

Sample Step Code

This provides an example step for the Deployment Manager.

Download

You can download the code the for SampleSite project here

SampleService.cs

We will utilize SampleService as the service for our Sample Steps

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SiteProvisioning.SampleSite.Services
{
    public class SampleService 
    {
        public SampleService()
        {

        }

        public void DoSomething()
        {
            //Wait 3 seconds
            System.Threading.Thread.Sleep(3000);
        }

        public string DoSomethingWithTitle(string title)
        {
            //Wait 2 seconds
            System.Threading.Thread.Sleep(2000);
            //Return Title
            return title;
        }
    }
}

Sample Step Code - No User Inputs

SampleStep.cs (Step)

A step that calls one method in SampleService and completes

using Akumina.SiteProvisioning.Common.Models;
using Akumina.SiteProvisioning.Core;
using Akumina.SiteProvisioning.Core.Interfaces;
using Akumina.SiteProvisioning.Core.Services;
using SiteProvisioning.SampleSite.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SiteProvisioning.SampleSite.Steps
{
    public class SampleStep : SiteProvisionerStepBase, ISiteProvisionerStep
    {
        public override string StepName
        {
            get { return "Executing a Sample Step"; }
        }

        public override SiteProvisionerStepResponse Execute()
        {
            var response = new SiteProvisionerStepResponse();

            SampleService sampleService = new SampleService();
            sampleService.AssetDirectory = this.Properties.AssetDirectory;

            try
            {              
                sampleService.DoSomething();
                response.Message = "We did something";
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Success = false;
            }

            return response;
        }
    }
}

Example.cs (Inherits SiteProvisionerSiteBase)

Our site deployment will consist of one step, SampleStep.cs

using Akumina.SiteProvisioning.Core.Interfaces;
using SiteProvisioning.SampleSite.Steps;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SiteProvisioning.SampleSite
{
    public class Example : SiteProvisionerSiteBase
    {
        public override string AssetDirectory
        {
            get { return "Example"; }
        }

        public override string Javascript
        {
            get { return ""; }
        }
        public override string FriendlyName
        {
            get { return "Example Site"; }
        }

        public override List<ISiteProvisionerStep> Steps
        {
            get 
            {
                var _steps = new List<ISiteProvisionerStep>();

                _steps.Add(new SampleStep());

                return _steps;
            }
        }

        public override List<SiteProvisionerSettingsField> UserSettings
        {
            get 
            { 
                return new List<SiteProvisionerSettingsField>(); 
            }
        }   
    }
}

Once you integrate your custom site definition with the Deployment Manager App you should be able to see it in the UI image 11 image 12

Sample Step Code – With User Inputs

For this example we will reuse the SampleService.cs class from the previous example.

SampleStepWithUserInputs.cs (Step)

Our new step will utilize a "Title" field for user input

using Akumina.SiteProvisioning.Common.Models;
using Akumina.SiteProvisioning.Core;
using Akumina.SiteProvisioning.Core.Interfaces;
using Akumina.SiteProvisioning.Core.Services;
using SiteProvisioning.SampleSite.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SiteProvisioning.SampleSite.Steps
{
    public class SampleStepWithUserInputs : SiteProvisionerStepBase, ISiteProvisionerStep
    {
        public override string StepName
        {
            get { return "Executing a Sample Step with User Inputs"; }
        }

        public override SiteProvisionerStepResponse Execute()
        {
            var response = new SiteProvisionerStepResponse();

            SampleService sampleService = new SampleService();
            sampleService.AssetDirectory = this.Properties.AssetDirectory;

            try
            {
                var siteTitle = GetProperty("Title");

                if (string.IsNullOrEmpty(siteTitle))
                {
                    throw new Exception("The Title value is required");
                }
                response.Message = sampleService.DoSomethingWithTitle(siteTitle);
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Success = false;
            }

            return response;
        }
    }
}

Example.cs (Inherits SiteProvisionerSiteBase)

We will reuse Example.cs from the previous sample, but with a couple modifications. We will add our SampleStepWithUserInputs class to the step list and add an entry to the SiteProvisionerSettingsField list. Changes from the previous version are highlighted.

using Akumina.Logging;
using Akumina.SiteProvisioning.Common.Models;
using Akumina.SiteProvisioning.Core;
using Akumina.SiteProvisioning.Core.Interfaces;
using SiteProvisioning.SampleSite.Steps;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; 

namespace SiteProvisioning.SampleSite
{
    public class Example : SiteProvisionerSiteBase
    {
        public override string AssetDirectory
        {
            get { return "Example"; }
        }

      public override string Javascript
        {
            get { return "~/SiteDefinitions/Example/ProvisionerFiles/js/example.js"; }
        }

        public override string FriendlyName
        {
            get { return "Example Site"; }
        }

        public override string ClassName
        {
            get { return "SiteCreator.Example"; }
        }
        public override List<ISiteProvisionerStep> Steps
        {
            get 
            {
                var _steps = new List<ISiteProvisionerStep>();

                _steps.Add(new SampleStep());

                _steps.Add(new SampleStepWithUserInputs());

                return _steps;
            }
        }

        public override List<SiteProvisionerSettingsField> UserSettings
        {
            get
            {
                var _userSettings = new List<SiteProvisionerSettingsField>();

                _userSettings.Add(
                    new SiteProvisionerSettingsField()
                    {
                        Name = "Title",
                        Description = "This is a Sample Field",
                        DefaultValue = "",
                        Required = true
                    }
                );

                return _userSettings;
            }
        }
    }
}

~/SiteDefinitions/Example/ProvisionerFiles/js/example.js

Under the SiteDefinitions folder you will need to create the following folder structure.

image 13

And it will contain the example.js file

var SiteCreator = SiteCreator ? SiteCreator : {};

if ((typeof SiteCreator.Example) === 'undefined') {
    SiteCreator.Example = function () {
        var _cur = this;

        this.Init = function (model) {
            SiteCreator.Eventing.Subscribe('/SiteCreator/DeployButtonclick/', _cur.OnDeploymentClick);
            SiteCreator.Eventing.Subscribe('/SiteCreator/SelectActionChange/', _cur.SelectActionChange);
            SiteCreator.Eventing.Subscribe('/SiteCreator/SiteChange/', _cur.OnSiteChange);
            SiteCreator.Eventing.Subscribe('/SiteCreator/GetFeatureName/', _cur.GetFeatureName);
            _cur.className = model.className;
            _cur.siteContainerId = model.siteContainerId;
        };

        this.OnDeploymentClick = function (model) {
            BaseDeployment(model, _cur.siteContainerId);
        };

        this.SelectActionChange = function (model) {
            if (model.siteContainerId == _cur.siteContainerId) {
                //Detect Add mode
                if ($('input[type=radio][name=select-an-action][value=CreateNewInstallation]').is(':checked')) {
                }//Detect Update mode
                else if ($('input[type=radio][name=select-an-action][value=UpdateConfigurationSettings]').is(':checked')) {
                }
            }
        };

        this.OnSiteChange = function (model) {
            if (model.siteContainerId == _cur.siteContainerId) {
                $("#selectActionDiv").show();
                $("#updateConfigOption").hide();
            }
        };

        this.GetFeatureName = function (model) {
            BaseGetFeatureName(model, _cur.siteContainerId);
        };
    }
};

After we integrate our project with the Deployment Manager App, we should see our steps and user input appear when we select the Example site within the app. image 14

Download

You can download the code the for SampleSite project here

References

To learn how to leverage the Deployment Manager SDK see the following articles:

  • Overview
  • Adding A Custom Site Definition
  • Core Step Classes
  • Custom Site Definition Components
  • Custom Subsite Definitions
  • Sample Step Code
  • Supported Tokens
← Custom Subsite DefinitionsSupported Tokens →
  • Download
  • SampleService.cs
  • Sample Step Code - No User Inputs
    • SampleStep.cs (Step)
    • Example.cs (Inherits SiteProvisionerSiteBase)
  • Sample Step Code – With User Inputs
    • SampleStepWithUserInputs.cs (Step)
    • Example.cs (Inherits SiteProvisionerSiteBase)
    • ~/SiteDefinitions/Example/ProvisionerFiles/js/example.js
  • Download
  • References
Akumina Developer Documentation
Docs
Akumina Framework 5.0Akumina Widget BuilderAkumina Yeoman GeneratorSite Deployer
Community
Akumina Community Site
More
GitHubStar
Copyright © 2024 Akumina