<div wfs-content="content">
    <div v-if="schemes.length > 0" style="margin-bottom: 10px;">
        <h1>Workflow</h1>
        <el-card v-for="item in schemes" class="wfs-index-card">
            <div slot="header" class="clearfix">
                <span>{{ item.Code }}</span>                  
            </div>
            <div class="text item">
                <a :href="'/workflow/' + item.Code" v-if="!item.AutoStart">
                    <el-button type="info" plain>Open</el-button>
                </a>
                <el-button v-if="item.AutoStart && !item.InitialCommands.length" type="info" plain
                    @click="WorkflowServer.launch(item.Code)">
                    Launch
                </el-button>
                
                <el-button v-for="command in item.InitialCommands" v-if="item.AutoStart"
                    @click="WorkflowServer.executeCommand(undefined, command.CommandName, item.Code)">
                    {{ command.LocalizedName }}
                </el-button>
                
            </div>                    
        </el-card>
    </div>
    <div style="clear: both;"></div>
    <div v-if="flows.length > 0">
        <h1>Flows</h1>
        <el-card v-for="item in flows" class="wfs-index-card">
            <div slot="header" class="clearfix">
                <span>{{ item.Name }}</span>                  
            </div>
            <div class="text item">
                <a :href="'/flow/' + item.Name" v-if="!item.AutoStart">
                    <el-button  type="info" plain>Open</el-button>
                </a>
               
                <el-button v-if="item.AutoStart && !item.InitialCommands.length" type="info" plain 
                    @click="WorkflowServer.launch(item.Name, 'flow')">
                    Launch
                </el-button>
                
                <el-button v-for="command in item.InitialCommands" v-if="item.AutoStart" 
                    @click="WorkflowServer.executeCommand(undefined, command.CommandName, { name: item.Name, type: 'flow'})">
                    {{ command.LocalizedName }}
                </el-button>
               
            </div>                    
        </el-card>
    </div>
    <script>
        WorkflowServer.DataExtend({
            schemes: [],
            flows: []
        });

        WorkflowServer.loadSchemes().then(function(data) {
            WorkflowServer.Data.schemes = data;
        });
            
         WorkflowServer.loadFlows().then(function(data) {
             WorkflowServer.Data.flows = data;
         });        
    </script>
</div>

