예제 #1
0
        public EditAppPage() : base()
        {
            InitializeComponent();

            // Setup ViewModel
            ViewModel                       = IoC.Get <EditAppViewModel>();
            this.DataContext                = ViewModel;
            this.AnimateOutStarted         += SaveCurrentSelectedItem;
            this.AnimateOutStarted         += Dispose;
            IoC.Get <MainWindow>().Closing += OnMainWindowClosing;
        }
예제 #2
0
    public EditAppPage(ApplicationViewModel applicationViewModel) : base()
    {
        SwappedOut += () =>
        {
            SaveSelectedItemOnAnimateOut();
            Dispose();
        };

        InitializeComponent();

        // Setup ViewModel
        ViewModel        = new EditAppViewModel(Lib.IoC.Get <ApplicationConfigService>(), applicationViewModel);
        this.DataContext = ViewModel;
        Lib.IoC.Get <MainWindow>().Closing += OnMainWindowClosing;
        DataObject.AddPastingHandler(ApplicationPathTextbox, HandleSymlinkOnPaste);
    }
예제 #3
0
        public IActionResult Create([FromForm] EditAppViewModel appModel)
        {
            var stupidRegexCheck = true; // [RegularExpressionAttribute] marks null or empty strings as valid

            if (appModel.IPRestrictedDeployer)
            {
                stupidRegexCheck = !string.IsNullOrEmpty(appModel.DeployerIP);
            }
            if (ModelState.IsValid && stupidRegexCheck)
            {
                var newApp = new Application()
                {
                    ID                   = RNG.GetRandomString(10),
                    OwnerEmail           = User.Identity.Name,
                    DeployerIP           = appModel.DeployerIP,
                    Description          = appModel.Description,
                    Encrypted            = appModel.Encrypted,
                    EncryptionAlgorithm  = EncryptionAlgorithm.AES256,
                    IPRestrictedDeployer = appModel.IPRestrictedDeployer,
                    LastUpdate           = DateTime.MinValue,
                    Name                 = appModel.Name,
                    PostdeployActions    = appModel.PostdeployActions,
                    PredeployActions     = appModel.PredeployActions
                };
                _context.Applications.Add(newApp);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                if (!stupidRegexCheck)
                {
                    ModelState.AddModelError(nameof(appModel.DeployerIP), "Invalid IP address");
                }
                return(View("EditApp", appModel));
            }
        }
예제 #4
0
 public SetApplicationImageCommand(EditAppViewModel model)
 {
     _editAppViewModel = model;
 }
예제 #5
0
        public async Task <IActionResult> Edit([FromForm] EditAppViewModel appModel)
        {
            var stupidRegexCheck = true; // [RegularExpressionAttribute] marks null or empty strings as valid

            if (appModel.IPRestrictedDeployer)
            {
                stupidRegexCheck = !string.IsNullOrEmpty(appModel.DeployerIP);
            }
            if (ModelState.IsValid && stupidRegexCheck)
            {
                if (appModel.ID != null && _context.Applications.Exists(appModel.ID))
                {
                    var foundApp = _context.Applications.Find(appModel.ID);
                    if (foundApp.HasOwner(User))
                    {
                        var newApp = new Application()
                        {
                            ID                   = foundApp.ID,
                            OwnerEmail           = foundApp.OwnerEmail,
                            DeployerIP           = appModel.DeployerIP,
                            Description          = appModel.Description,
                            Encrypted            = appModel.Encrypted,
                            EncryptionAlgorithm  = EncryptionAlgorithm.AES256,
                            IPRestrictedDeployer = appModel.IPRestrictedDeployer,
                            LastUpdate           = foundApp.LastUpdate,
                            Name                 = appModel.Name,
                            PredeployActions     = appModel.PredeployActions,
                            PostdeployActions    = appModel.PostdeployActions
                        };
                        _context.Applications.Remove(foundApp);
                        _context.Applications.Add(newApp);
                        _context.SaveChanges();
                        if (newApp.Encrypted)
                        {
                            await _fileManager.DeleteAllNonEncryptedFilesAsync(newApp.ID);
                        }
                        else
                        {
                            await _fileManager.DeleteAllEncryptedFilesAsync(newApp.ID);
                        }
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(Unauthorized("Nice try.")); //In case someone tries to modify someone else's app using a known ID
                    }
                }
                else
                {
                    return(NotFound());
                }
            }
            else
            {
                if (!stupidRegexCheck)
                {
                    ModelState.AddModelError(nameof(appModel.DeployerIP), "Invalid IP address");
                }
                return(View("EditApp", appModel));
            }
        }
예제 #6
0
 public DeleteApplicationCommand(EditAppViewModel editAppViewModel)
 {
     _editAppViewModel = editAppViewModel;
 }
예제 #7
0
 public DeployAsiLoaderCommand(EditAppViewModel addAppViewModel)
 {
     ViewModel = addAppViewModel;
     ViewModel.PropertyChanged += OnApplicationChanged;
     SetCurrentApplication();
 }