Ejemplo n.º 1
0
        public static string GetAppStateString(AppIdTuple t, AppState?appState)
        {
            if (appState is null)
            {
                return(string.Empty);
            }

            var flags = GetAppStateFlags(appState);

            var now = DateTime.UtcNow;

            var stateStr = String.Format(
                System.Globalization.CultureInfo.InvariantCulture,
                "APP:{0}:{1}:{2}:{3:0.00}:{4}:{5}:{6}:{7}",
                t.ToString(),
                flags,
                appState.ExitCode,
                (now - appState.LastChange).TotalSeconds,
                appState.CPU,
                appState.GPU,
                appState.Memory,
                appState.PlanName
                );

            return(stateStr);
        }
Ejemplo n.º 2
0
        protected override async ValueTask OnInitialize()
        {
            var stateDirectoryPath     = Path.Combine(Directory.GetCurrentDirectory(), "../state/ui-desktop");
            var temporaryDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "../temp/ui-desktop");
            var bytesPool = BytesPool.Shared;

            _state = await AppState.Factory.CreateAsync(stateDirectoryPath, temporaryDirectoryPath, bytesPool);

            this.Model = new MainWindowModel(_state);
            this.FileViewControl.Model = new FileViewControlModel(_state);
        }
 internal IotCentralAppData(ResourceIdentifier id, string name, ResourceType resourceType, SystemData systemData, IDictionary <string, string> tags, AzureLocation location, AppSkuInfo sku, SystemAssignedServiceIdentity identity, ProvisioningState?provisioningState, string applicationId, string displayName, string subdomain, string template, AppState?state, PublicNetworkAccess?publicNetworkAccess, NetworkRuleSets networkRuleSets, IReadOnlyList <IotCentralPrivateEndpointConnectionData> privateEndpointConnections) : base(id, name, resourceType, systemData, tags, location)
 {
     Sku                        = sku;
     Identity                   = identity;
     ProvisioningState          = provisioningState;
     ApplicationId              = applicationId;
     DisplayName                = displayName;
     Subdomain                  = subdomain;
     Template                   = template;
     State                      = state;
     PublicNetworkAccess        = publicNetworkAccess;
     NetworkRuleSets            = networkRuleSets;
     PrivateEndpointConnections = privateEndpointConnections;
 }
Ejemplo n.º 4
0
        public static string GetAppStateFlags(AppState?appState)
        {
            if (appState is null)
            {
                return(string.Empty);
            }

            var sbFlags = new StringBuilder();

            if (appState.Started)
            {
                sbFlags.Append("S");
            }
            if (appState.StartFailed)
            {
                sbFlags.Append("F");
            }
            if (appState.Running)
            {
                sbFlags.Append("R");
            }
            if (appState.Killed)
            {
                sbFlags.Append("K");
            }
            if (appState.Initialized)
            {
                sbFlags.Append("I");
            }
            if (appState.PlanApplied)
            {
                sbFlags.Append("P");
            }
            if (appState.Dying)
            {
                sbFlags.Append("D");
            }
            if (appState.Restarting)
            {
                sbFlags.Append("X");
            }

            return(sbFlags.ToString());
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Get an existing App resource's state with the given name, ID, and optional extra
 /// properties used to qualify the lookup.
 /// </summary>
 ///
 /// <param name="name">The unique name of the resulting resource.</param>
 /// <param name="id">The unique provider ID of the resource to lookup.</param>
 /// <param name="state">Any extra arguments used during the lookup.</param>
 /// <param name="options">A bag of options that control this resource's behavior</param>
 public static App Get(string name, Input <string> id, AppState?state = null, CustomResourceOptions?options = null)
 {
     return(new App(name, id, state, options));
 }
Ejemplo n.º 6
0
 private App(string name, Input <string> id, AppState?state = null, CustomResourceOptions?options = null)
     : base("aws:pinpoint/app:App", name, state, MakeResourceOptions(options, id))
 {
 }
Ejemplo n.º 7
0
 private App(string name, Input <string> id, AppState?state = null, CustomResourceOptions?options = null)
     : base("digitalocean:index/app:App", name, state, MakeResourceOptions(options, id))
 {
 }
Ejemplo n.º 8
0
 private App(string name, Input <string> id, AppState?state = null, CustomResourceOptions?options = null)
     : base("alicloud:apigateway/app:App", name, state, MakeResourceOptions(options, id))
 {
 }
Ejemplo n.º 9
0
 public PictureWindow(AppState state, NestedPath path)
     : this()
 {
     _state = state;
     _path  = path;
 }
Ejemplo n.º 10
0
        public void DrawUI()
        {
            ImGui.PushID(_uniqueUiId);

            AppDef?appDef = _appDef ?? _ctrl.GetAppDef(_id);

            AppState?appState = _ctrl.GetAppState(_id);

            PlanState?planState = null;

            if (appState != null && !string.IsNullOrEmpty(appState.PlanName))
            {
                planState = _ctrl.GetPlanState(appState.PlanName);
            }

            string statusText = appState != null?Tools.GetAppStateText(appState, planState, appDef) : string.Empty;

            string?planName = _appDef?.PlanName ?? appState?.PlanName;                  // prefer plan from appdef


            ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1.0f, 0f, 1f, 1f));
            bool opened = ImGui.TreeNodeEx($"{_id}##{_id}", ImGuiTreeNodeFlags.FramePadding);

            ImGui.PopStyleColor();
            if (ImGui.BeginPopupContextItem())
            {
                if (ImGui.MenuItem("Start"))
                {
                    _ctrl.Send(new Net.StartAppMessage(_ctrl.Name, _id, planName));
                }

                if (ImGui.MenuItem("Kill"))
                {
                    _ctrl.Send(new Net.KillAppMessage(_ctrl.Name, _id));
                }

                if (ImGui.MenuItem("Restart"))
                {
                    _ctrl.Send(new Net.RestartAppMessage(_ctrl.Name, _id));
                }
                ImGui.EndPopup();
            }
            ImGui.SameLine();
            ImGui.SetCursorPosX(ImGui.GetWindowWidth() * 3 / 4f);
            //if( ImGui.Button("S") )	_ctrl.Send( new Net.StartAppMessage( _id, planName ) );
            if (ImGuiTools.ImgBtn(_txStart))
            {
                _ctrl.Send(new Net.StartAppMessage(_ctrl.Name, _id, planName));
            }
            ImGui.SameLine();
            if (ImGuiTools.ImgBtn(_txKill))
            {
                _ctrl.Send(new Net.KillAppMessage(_ctrl.Name, _id));
            }
            ImGui.SameLine();
            if (ImGuiTools.ImgBtn(_txRestart))
            {
                _ctrl.Send(new Net.RestartAppMessage(_ctrl.Name, _id));
            }

            // enabled checkbox just for apps from a plan
            if (_appDef is not null && _appDef.PlanName is not null)
            {
                ImGui.SameLine();
                bool enabled = !_appDef.Disabled;
                if (ImGui.Checkbox("##enabled", ref enabled))
                {
                    _ctrl.Send(new Net.SetAppEnabledMessage(_ctrl.Name, _appDef.PlanName, _id, enabled));
                }
            }

            ImGui.SameLine();
            ImGui.SetCursorPosX(ImGui.GetWindowWidth() / 4 * 2f);
            ImGui.TextColored(GetAppStateColor(statusText, appDef), statusText);

            //ImGui.SameLine();
            //ImGui.SetCursorPosX( ImGui.GetWindowWidth()/4f);
            //DrawOptions();

            if (opened)
            {
                //DrawUIBody();
                string jsonString = JsonSerializer.Serialize(appDef, new JsonSerializerOptions()
                {
                    WriteIndented = true, IncludeFields = true
                });
                ImGui.TextWrapped(jsonString.Replace("%", "%%"));                 // TextWrapped doesn't like %s etc, percent signs needs to be doubled

                ImGui.TreePop();
            }

            ImGui.PopID();
        }