mirror of https://github.com/portainer/portainer
				
				
				
			fix(templates): checking windows endpoint and template properties. (#5108)
* fix(templates): checking windows endpoint and template properties. * fix(templates): removed debug code. * fix(templates): fixed type issue in custom template.pull/5114/head
							parent
							
								
									6bfbf58cdb
								
							
						
					
					
						commit
						d7fcfee2a2
					
				| 
						 | 
				
			
			@ -34,13 +34,16 @@ class CustomTemplatesViewController {
 | 
			
		|||
    this.StateManager = StateManager;
 | 
			
		||||
    this.StackService = StackService;
 | 
			
		||||
 | 
			
		||||
    this.DOCKER_STANDALONE = 'DOCKER_STANDALONE';
 | 
			
		||||
    this.DOCKER_SWARM_MODE = 'DOCKER_SWARM_MODE';
 | 
			
		||||
 | 
			
		||||
    this.state = {
 | 
			
		||||
      selectedTemplate: null,
 | 
			
		||||
      showAdvancedOptions: false,
 | 
			
		||||
      formValidationError: '',
 | 
			
		||||
      actionInProgress: false,
 | 
			
		||||
      isEditorVisible: false,
 | 
			
		||||
      provider: 0,
 | 
			
		||||
      deployable: false,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    this.currentUser = {
 | 
			
		||||
| 
						 | 
				
			
			@ -182,7 +185,8 @@ class CustomTemplatesViewController {
 | 
			
		|||
    this.formValues.name = template.Title ? template.Title : '';
 | 
			
		||||
    this.state.selectedTemplate = template;
 | 
			
		||||
    this.$anchorScroll('view-top');
 | 
			
		||||
 | 
			
		||||
    const applicationState = this.StateManager.getState();
 | 
			
		||||
    this.state.deployable = this.isDeployable(applicationState.endpoint, template.Type);
 | 
			
		||||
    const file = await this.CustomTemplateService.customTemplateFile(template.Id);
 | 
			
		||||
    this.formValues.fileContent = file;
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -224,6 +228,21 @@ class CustomTemplatesViewController {
 | 
			
		|||
    this.formValues.fileContent = cm.getValue();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  isDeployable(endpoint, templateType) {
 | 
			
		||||
    let deployable = false;
 | 
			
		||||
    switch (templateType) {
 | 
			
		||||
      case 1:
 | 
			
		||||
        deployable = endpoint.mode.provider === this.DOCKER_SWARM_MODE;
 | 
			
		||||
        break;
 | 
			
		||||
      case 2:
 | 
			
		||||
        deployable = endpoint.mode.provider === this.DOCKER_STANDALONE;
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return deployable;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  $onInit() {
 | 
			
		||||
    const applicationState = this.StateManager.getState();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -232,7 +251,6 @@ class CustomTemplatesViewController {
 | 
			
		|||
      apiVersion,
 | 
			
		||||
    } = applicationState;
 | 
			
		||||
 | 
			
		||||
    this.state.provider = endpointMode.provider === 'DOCKER_STANDALONE' ? 2 : 1;
 | 
			
		||||
    this.getTemplates(endpointMode);
 | 
			
		||||
    this.getNetworks(endpointMode.provider, apiVersion);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -260,7 +260,6 @@ angular.module('portainer.app').controller('TemplatesController', [
 | 
			
		|||
          deployable = endpoint.mode.provider === DOCKER_STANDALONE;
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return deployable;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue