Fix fileManager
Added filePath config
This commit is contained in:
Binary file not shown.
@@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<serverConfig>
|
||||
<ncConfig>
|
||||
<ncVendor>DEMO</ncVendor> <!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
|
||||
<ncVendor>OSAI</ncVendor> <!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
|
||||
<showNcHMI>true</showNcHMI>
|
||||
<ncIpAddress>localhost</ncIpAddress>
|
||||
<ncIpAddress>192.168.139.1</ncIpAddress>
|
||||
<ncPort>8080</ncPort>
|
||||
<machineModel>Ares 37 OF</machineModel>
|
||||
<sharedPath>C:\PartPrg\</sharedPath>
|
||||
<sharedName>//PARTPRG:/</sharedName>
|
||||
</ncConfig>
|
||||
<serverConfig>
|
||||
<serverPort>9000</serverPort>
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
<xs:element name="ncIpAddress" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="ncPort" type="xs:int" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="machineModel" type="xs:string" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="sharedPath" type="xs:string" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="sharedName" type="xs:string" minOccurs='1' maxOccurs='1'/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -172,10 +172,12 @@ namespace Step.Config
|
||||
.Select(x => new NcConfigModel()
|
||||
{
|
||||
NcVendor = x.Element("ncVendor").Value,
|
||||
showNcHMI = Convert.ToBoolean(x.Element("showNcHMI").Value),
|
||||
ShowNcHMI = Convert.ToBoolean(x.Element("showNcHMI").Value),
|
||||
NcIpAddress = x.Element("ncIpAddress").Value,
|
||||
NcPort = Convert.ToUInt16(x.Element("ncPort").Value),
|
||||
NcName = x.Element("machineModel").Value
|
||||
NcName = x.Element("machineModel").Value,
|
||||
SharedPath = x.Element("sharedPath").Value,
|
||||
SharedName = x.Element("sharedName").Value,
|
||||
}).FirstOrDefault();
|
||||
|
||||
// Read server config with LINQ and save into static config
|
||||
|
||||
@@ -9,10 +9,12 @@ namespace Step.Model.ConfigModels
|
||||
public class NcConfigModel
|
||||
{
|
||||
public string NcVendor { get; set; }
|
||||
public bool showNcHMI { get; set; }
|
||||
public bool ShowNcHMI { get; set; }
|
||||
public string NcIpAddress { get; set; }
|
||||
public ushort NcPort { get; set; }
|
||||
public string NcUniqueId { get; set; }
|
||||
public string NcName { get; set; }
|
||||
public string SharedPath { get; set; }
|
||||
public string SharedName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,9 @@ namespace Step.Model
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly string[] VALID_FILE_EXTENSIONS = { "", ".txt", ".cnc", ".ini", ".mpf", ".spf" };
|
||||
public const double EPSILON = 0.001;
|
||||
|
||||
|
||||
public enum ROLE_IDS
|
||||
{
|
||||
CMS_SERVICE_ONLY = 1,
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Step.Controllers.WebApi
|
||||
DTOClientConfigurationModel clientConfiguration = new DTOClientConfigurationModel()
|
||||
{
|
||||
NcVendor = NcConfig.NcVendor,
|
||||
ShowHMI = NcConfig.showNcHMI,
|
||||
ShowHMI = NcConfig.ShowNcHMI,
|
||||
DefaultLanguage = ServerStartupConfig.Language,
|
||||
NcIp = NcConfig.NcIpAddress,
|
||||
NcPort = NcConfig.NcPort
|
||||
|
||||
@@ -11,6 +11,9 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
using System.Linq;
|
||||
using static Step.Config.ServerConfig;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Step.Controllers.WebApi
|
||||
{
|
||||
@@ -24,7 +27,7 @@ namespace Step.Controllers.WebApi
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
CmsError cmsError = ncHandler.GetFileList(filePath, out List<PreviewFileModel> fileList);
|
||||
CmsError cmsError = ncHandler.GetFileList(filePath, out List<PreviewFileModel> fileList);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
@@ -33,7 +36,7 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
|
||||
[Route("file/info"), HttpGet]
|
||||
public IHttpActionResult GetFileInfo([FromUri]string filePath)
|
||||
public IHttpActionResult GetFileInfo([FromUri]string filePath)
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
@@ -113,5 +116,45 @@ namespace Step.Controllers.WebApi
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[Route("shared_files"), HttpGet]
|
||||
public IHttpActionResult GetSharedFolderFileList(string sharedPath)
|
||||
{
|
||||
List<object> filelist = new List<object>();
|
||||
|
||||
string sharedFullPath = NcConfig.SharedPath + sharedPath;
|
||||
|
||||
if (!Directory.Exists(sharedFullPath))
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
foreach (string item in Directory.GetDirectories(sharedFullPath))
|
||||
{
|
||||
filelist.Add(new
|
||||
{
|
||||
Name = Path.GetFileName(item),
|
||||
AbsolutePath = NcConfig.SharedPath + sharedPath,
|
||||
Path = sharedPath,
|
||||
IsDirectory = true
|
||||
});
|
||||
}
|
||||
|
||||
string sharedNcPath = NcConfig.SharedName + sharedPath.Replace('\\', '/');
|
||||
|
||||
foreach (string item in Directory.GetFiles(sharedFullPath))
|
||||
{
|
||||
if (VALID_FILE_EXTENSIONS.Contains(Path.GetExtension(item).ToLower()))
|
||||
filelist.Add(new
|
||||
{
|
||||
Name = Path.GetFileName(item),
|
||||
AbsolutePath = sharedNcPath + "/" + Path.GetFileName(item),
|
||||
Path = sharedPath + "\\" + Path.GetFileName(item),
|
||||
IsDirectory = false
|
||||
});
|
||||
}
|
||||
|
||||
return Ok(filelist);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,23 +144,24 @@ namespace Step.Controllers.WebApi
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
}
|
||||
|
||||
// If option is active
|
||||
if (!ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
// Copy only family
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel();
|
||||
SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily);
|
||||
// Update only family data
|
||||
DbNcFamilyModel dbFam = toolsManager.UpdateFamily(dtoToolWithFamily.FamilyId, newFamily);
|
||||
if (dbFam == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError;
|
||||
// If option is active
|
||||
if (!ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
// Copy only family
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel();
|
||||
SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily);
|
||||
// Update only family data
|
||||
cmsError = ncHandler.UpdateFamily(dtoToolWithFamily.FamilyId, newFamily, out DTONcFamilyModel newFam);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
}
|
||||
|
||||
ncHandler.Connect();
|
||||
// Update
|
||||
CmsError cmsError = ncHandler.UpdateTool(toolId, dtoToolWithFamily, out DTONcToolModel newTool);
|
||||
cmsError = ncHandler.UpdateTool(toolId, dtoToolWithFamily, out DTONcToolModel newTool);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ export default class ModalLoadProgram extends Vue {
|
||||
this.currentPath = absolutePath;
|
||||
this.lastClickPath = absolutePath;
|
||||
this.checkChangeNavigationType(local);
|
||||
var files = await this.getFilesForPath(absolutePath, local);
|
||||
var files = await this.getFilesForPath(absolutePath, path, local);
|
||||
|
||||
// controlla se impostare il currentDrive
|
||||
if (fromdepth == 0) this.currentDrive = absolutePath;
|
||||
@@ -97,7 +97,7 @@ export default class ModalLoadProgram extends Vue {
|
||||
this.fillArray(this.secondColumnData, files);
|
||||
this.currentFilterSecond = "";
|
||||
}
|
||||
this.calcBreadCrumb(path);
|
||||
this.calcBreadCrumb(absolutePath);
|
||||
}
|
||||
|
||||
fillArray(destinationArray: Array<any>, sourceArray: Array<any>) {
|
||||
@@ -118,10 +118,11 @@ export default class ModalLoadProgram extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
async getFilesForPath(path: string, local: boolean): Promise<Array<any>> {
|
||||
async getFilesForPath(absolutePath: string, path: string, local: boolean): Promise<Array<any>> {
|
||||
this.isLocalNavigation = local;
|
||||
var result = null;
|
||||
if (local) result = JSON.parse(cmsClient.getFileList(path));
|
||||
console.log(path);
|
||||
if (local) result = JSON.parse(cmsClient.getFileList(absolutePath));
|
||||
else result = await awaiter(fileService.getFiles(path));
|
||||
return this.toUpperCaseModel(result).sort(this.compareDirectoriesFirst);
|
||||
}
|
||||
@@ -131,6 +132,7 @@ export default class ModalLoadProgram extends Vue {
|
||||
}
|
||||
|
||||
toUpperCaseModel(data: Array<any>): Array<PathInfo> {
|
||||
console.log(data)
|
||||
return data.map(i => {
|
||||
return {
|
||||
Name: i.name || i.Name,
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
:selected="isInPath(val.AbsolutePath) || val.AbsolutePath == lastClickPath"
|
||||
:withArrow="val.IsDirectory == true"
|
||||
:iconType="val.IsDirectory? 'FOLDER':'FILE'"
|
||||
@click="val.IsDirectory ? navigateTo(val.AbsolutePath,val.AbsolutePath, isLocalNavigation, 2,1): fileInfo(val.AbsolutePath,1)"></card-folder-path>
|
||||
@click="val.IsDirectory ? navigateTo(val.Path, val.AbsolutePath, isLocalNavigation, 2,1): fileInfo(val.AbsolutePath,1)"></card-folder-path>
|
||||
</div>
|
||||
</div>
|
||||
<div class="third-column" v-if="navigationDepth <2"></div>
|
||||
@@ -68,7 +68,7 @@
|
||||
:selected="isInPath(val.AbsolutePath) || val.AbsolutePath == lastClickPath"
|
||||
:withArrow="val.IsDirectory == true"
|
||||
:iconType="val.IsDirectory? 'FOLDER':'FILE'"
|
||||
@click="val.IsDirectory? navigateTo(val.AbsolutePath,val.AbsolutePath, isLocalNavigation, 2,2):fileInfo(val.AbsolutePath,2) "></card-folder-path>
|
||||
@click="val.IsDirectory? navigateTo(val.Path, val.AbsolutePath, isLocalNavigation, 2,2):fileInfo(val.AbsolutePath,2) "></card-folder-path>
|
||||
<!-- <card-folder-path name="Cliente A" @click="selectItem()" :with-arrow="false"></card-folder-path>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -110,15 +110,14 @@ export class Hub {
|
||||
private static activeProgramData(data) {
|
||||
// Controllo se devo ricaricare l'immagine
|
||||
var cp = (store.state as AppModel).process.currentProgram;
|
||||
|
||||
if ((!cp || (cp && cp.path != data.path)) && data.path !="") {
|
||||
if(data.path != "" && (!cp || cp.path != data.path)){
|
||||
fileService.getFileInfo(data.path).then(r => {
|
||||
var image = r.previewBase64;
|
||||
processModelActions.setCurrentProgramImage(store, image);
|
||||
processModelActions.setCurrentProgramName(store, r.name);
|
||||
});
|
||||
}
|
||||
else
|
||||
else if(data.path =="")
|
||||
{
|
||||
processModelActions.setCurrentProgramImage(store, null);
|
||||
processModelActions.setCurrentProgramName(store, null);
|
||||
|
||||
Reference in New Issue
Block a user